mirror of
https://github.com/HeyPuter/puter.git
synced 2025-12-30 17:50:00 -06:00
Fix FS types (#2134)
This commit is contained in:
committed by
GitHub
parent
697b3424c7
commit
e431ac265c
4
src/puter-js/index.d.ts
vendored
4
src/puter-js/index.d.ts
vendored
@@ -4,7 +4,7 @@ import type { Apps, AppListOptions, AppRecord, CreateAppOptions, UpdateAppAttrib
|
||||
import type { Auth, APIUsage, AllowanceInfo, AppUsage, AuthUser, DetailedAppUsage, MonthlyUsage } from './types/modules/auth.d.ts';
|
||||
import type { Debug } from './types/modules/debug.d.ts';
|
||||
import type { Driver, DriverDescriptor, Drivers } from './types/modules/drivers.d.ts';
|
||||
import type { PuterJSFileSystemModule, CopyOptions, DeleteOptions, MkdirOptions, MoveOptions, ReadOptions, ReaddirOptions, SignResult, SpaceInfo, UploadOptions, WriteOptions } from './types/modules/filesystem.d.ts';
|
||||
import type { FS, CopyOptions, DeleteOptions, MkdirOptions, MoveOptions, ReadOptions, ReaddirOptions, SignResult, SpaceInfo, UploadOptions, WriteOptions } from './types/modules/filesystem.d.ts';
|
||||
import type { FSItem, FileSignatureInfo, InternalFSProperties } from './types/modules/fs-item.d.ts';
|
||||
import type { Hosting, Subdomain } from './types/modules/hosting.d.ts';
|
||||
import type { KV, KVIncrementPath, KVPair } from './types/modules/kv.d.ts';
|
||||
@@ -83,7 +83,7 @@ export type {
|
||||
PTLSSocket,
|
||||
Puter,
|
||||
PuterEnvironment,
|
||||
PuterJSFileSystemModule,
|
||||
FS,
|
||||
ReadOptions,
|
||||
ReaddirOptions,
|
||||
RequestCallbacks,
|
||||
|
||||
106
src/puter-js/types/modules/filesystem.d.ts
vendored
106
src/puter-js/types/modules/filesystem.d.ts
vendored
@@ -7,37 +7,43 @@ export interface SpaceInfo {
|
||||
}
|
||||
|
||||
export interface CopyOptions extends RequestCallbacks<FSItem> {
|
||||
source: string;
|
||||
destination: string;
|
||||
source?: string;
|
||||
destination?: string;
|
||||
overwrite?: boolean;
|
||||
newName?: string;
|
||||
createMissingParents?: boolean;
|
||||
dedupeName?: boolean;
|
||||
newMetadata?: Record<string, unknown>;
|
||||
excludeSocketID?: string;
|
||||
original_client_socket_id?: string;
|
||||
}
|
||||
|
||||
export interface MoveOptions extends RequestCallbacks<FSItem> {
|
||||
source: string;
|
||||
destination: string;
|
||||
source?: string;
|
||||
destination?: string;
|
||||
overwrite?: boolean;
|
||||
newName?: string;
|
||||
createMissingParents?: boolean;
|
||||
newMetadata?: Record<string, unknown>;
|
||||
excludeSocketID?: string;
|
||||
original_client_socket_id?: string;
|
||||
}
|
||||
|
||||
export interface MkdirOptions extends RequestCallbacks<FSItem> {
|
||||
path?: string;
|
||||
overwrite?: boolean;
|
||||
dedupeName?: boolean;
|
||||
rename?: boolean;
|
||||
createMissingParents?: boolean;
|
||||
recursive?: boolean;
|
||||
shortcutTo?: string;
|
||||
}
|
||||
|
||||
export interface DeleteOptions extends RequestCallbacks<void> {
|
||||
path?: string;
|
||||
paths?: string | string[];
|
||||
recursive?: boolean;
|
||||
descendantsOnly?: boolean;
|
||||
descendants_only?: boolean;
|
||||
}
|
||||
|
||||
export interface ReadOptions extends RequestCallbacks<Blob> {
|
||||
@@ -57,24 +63,48 @@ export interface ReaddirOptions extends RequestCallbacks<FSItem[]> {
|
||||
export interface RenameOptions extends RequestCallbacks<FSItem> {
|
||||
uid?: string;
|
||||
path?: string;
|
||||
newName: string;
|
||||
newName?: string;
|
||||
excludeSocketID?: string;
|
||||
original_client_socket_id?: string;
|
||||
}
|
||||
|
||||
export interface UploadOptions extends RequestCallbacks<FSItem[]> {
|
||||
export interface StatOptions extends RequestCallbacks<FSItem> {
|
||||
path?: string;
|
||||
uid?: string;
|
||||
consistency?: 'strong' | 'eventual';
|
||||
returnSubdomains?: boolean;
|
||||
returnPermissions?: boolean;
|
||||
returnVersions?: boolean;
|
||||
returnSize?: boolean;
|
||||
}
|
||||
|
||||
export interface UploadOptions extends RequestCallbacks<FSItem | FSItem[]> {
|
||||
overwrite?: boolean;
|
||||
dedupeName?: boolean;
|
||||
name?: string;
|
||||
parsedDataTransferItems?: boolean;
|
||||
createFileParent?: boolean;
|
||||
createMissingAncestors?: boolean;
|
||||
createMissingParents?: boolean;
|
||||
shortcutTo?: string;
|
||||
appUID?: string;
|
||||
strict?: boolean;
|
||||
init?: (operationId: string, xhr: XMLHttpRequest) => void;
|
||||
error?: (e: unknown) => void;
|
||||
start?: () => void;
|
||||
progress?: (operationId: string, progress: number) => void;
|
||||
abort?: (operationId: string) => void;
|
||||
}
|
||||
|
||||
export interface WriteOptions extends RequestCallbacks<FSItem> {
|
||||
overwrite?: boolean;
|
||||
dedupeName?: boolean;
|
||||
createMissingParents?: boolean;
|
||||
createMissingAncestors?: boolean;
|
||||
name?: string;
|
||||
init?: (operationId: string, xhr: XMLHttpRequest) => void;
|
||||
start?: () => void;
|
||||
progress?: (operationId: string, progress: number) => void;
|
||||
abort?: (operationId: string) => void;
|
||||
}
|
||||
|
||||
export interface SignResult<T = Record<string, unknown>> {
|
||||
@@ -82,23 +112,51 @@ export interface SignResult<T = Record<string, unknown>> {
|
||||
items: T | T[];
|
||||
}
|
||||
|
||||
export class PuterJSFileSystemModule {
|
||||
constructor (context: Record<string, unknown>);
|
||||
export type UploadItems = DataTransferItemList | DataTransferItem | FileList | File[] | Blob[] | Blob | File | string | unknown[];
|
||||
|
||||
export class FS {
|
||||
space (): Promise<SpaceInfo>;
|
||||
space (options: RequestCallbacks<SpaceInfo>): Promise<SpaceInfo>;
|
||||
space (success: (value: SpaceInfo) => void, error?: (reason: unknown) => void): Promise<SpaceInfo>;
|
||||
|
||||
mkdir (options: MkdirOptions): Promise<FSItem>;
|
||||
mkdir (path: string, options?: MkdirOptions): Promise<FSItem>;
|
||||
mkdir (path: string, options: MkdirOptions, success: (value: FSItem) => void, error?: (reason: unknown) => void): Promise<FSItem>;
|
||||
mkdir (path: string, success: (value: FSItem) => void, error?: (reason: unknown) => void): Promise<FSItem>;
|
||||
|
||||
copy (options: CopyOptions): Promise<FSItem>;
|
||||
copy (source: string, destination: string, options?: CopyOptions): Promise<FSItem>;
|
||||
copy (source: string, destination: string, options: CopyOptions | undefined, success: (value: FSItem) => void, error?: (reason: unknown) => void): Promise<FSItem>;
|
||||
|
||||
move (options: MoveOptions): Promise<FSItem>;
|
||||
move (source: string, destination: string, options?: MoveOptions): Promise<FSItem>;
|
||||
|
||||
rename (options: RenameOptions): Promise<FSItem>;
|
||||
rename (path: string, newName: string, success?: (value: FSItem) => void, error?: (reason: unknown) => void): Promise<FSItem>;
|
||||
|
||||
read (options: ReadOptions): Promise<Blob>;
|
||||
read (path: string, options?: ReadOptions): Promise<Blob>;
|
||||
read (path: string, success: (value: Blob) => void, error?: (reason: unknown) => void): Promise<Blob>;
|
||||
|
||||
readdir (options: ReaddirOptions): Promise<FSItem[]>;
|
||||
readdir (path: string, success?: (value: FSItem[]) => void, error?: (reason: unknown) => void): Promise<FSItem[]>;
|
||||
|
||||
stat (options: StatOptions): Promise<FSItem>;
|
||||
stat (path: string, options?: StatOptions): Promise<FSItem>;
|
||||
stat (path: string, options: StatOptions, success: (value: FSItem) => void, error?: (reason: unknown) => void): Promise<FSItem>;
|
||||
stat (path: string, success: (value: FSItem) => void, error?: (reason: unknown) => void): Promise<FSItem>;
|
||||
|
||||
delete (options: DeleteOptions): Promise<void>;
|
||||
delete (paths: string | string[], options?: DeleteOptions): Promise<void>;
|
||||
|
||||
upload (items: UploadItems, dirPath?: string, options?: UploadOptions): Promise<FSItem | FSItem[]>;
|
||||
|
||||
write (file: File): Promise<FSItem>;
|
||||
write (path: string, data: string | File | Blob | ArrayBuffer | ArrayBufferView, options?: WriteOptions): Promise<FSItem>;
|
||||
|
||||
space (options?: RequestCallbacks<SpaceInfo>): Promise<SpaceInfo>;
|
||||
mkdir (pathOrOptions: string | MkdirOptions, options?: MkdirOptions): Promise<FSItem>;
|
||||
copy (sourceOrOptions: string | CopyOptions, destination?: string, options?: CopyOptions): Promise<FSItem>;
|
||||
rename (pathOrUid: string, newName: string, options?: RenameOptions): Promise<FSItem>;
|
||||
upload (items: FileList | File[] | Blob[] | Blob | string | unknown[], dirPath?: string, options?: UploadOptions): Promise<FSItem[]>;
|
||||
read (pathOrOptions: string | ReadOptions, options?: ReadOptions): Promise<Blob>;
|
||||
delete (pathOrOptions: string | DeleteOptions, options?: DeleteOptions): Promise<void>;
|
||||
move (sourceOrOptions: string | MoveOptions, destination?: string, options?: MoveOptions): Promise<FSItem>;
|
||||
write (path: string, data?: string | File | Blob | ArrayBuffer | ArrayBufferView, options?: WriteOptions): Promise<FSItem>;
|
||||
sign (appUid: string, items: unknown | unknown[], success?: (result: SignResult) => void, error?: (reason: unknown) => void): Promise<SignResult>;
|
||||
symlink (targetPath: string, linkPath: string, options?: Record<string, unknown>): Promise<FSItem>;
|
||||
getReadURL (path: string, expiresIn?: number): Promise<string>;
|
||||
readdir (pathOrOptions?: string | ReaddirOptions, options?: ReaddirOptions): Promise<FSItem[]>;
|
||||
stat (pathOrUid: string, options?: Record<string, unknown>): Promise<FSItem>;
|
||||
|
||||
FSItem: typeof FSItem;
|
||||
symlink (target: string, linkPath: string): Promise<void>;
|
||||
|
||||
getReadURL (path: string, expiresIn?: string): Promise<string>;
|
||||
}
|
||||
|
||||
4
src/puter-js/types/puter.d.ts
vendored
4
src/puter-js/types/puter.d.ts
vendored
@@ -3,7 +3,7 @@ import type { Apps } from './modules/apps.d.ts';
|
||||
import type { Auth } from './modules/auth.d.ts';
|
||||
import type { Debug } from './modules/debug.d.ts';
|
||||
import type { Drivers } from './modules/drivers.d.ts';
|
||||
import type { PuterJSFileSystemModule, SpaceInfo } from './modules/filesystem.d.ts';
|
||||
import type { FS } from './modules/filesystem.d.ts';
|
||||
import type { FSItem } from './modules/fs-item.d.ts';
|
||||
import type { Hosting } from './modules/hosting.d.ts';
|
||||
import type { KV } from './modules/kv.d.ts';
|
||||
@@ -51,7 +51,7 @@ export class Puter {
|
||||
apps: Apps;
|
||||
auth: Auth;
|
||||
os: OS;
|
||||
fs: PuterJSFileSystemModule;
|
||||
fs: FS;
|
||||
ui: UI;
|
||||
hosting: Hosting;
|
||||
kv: KV;
|
||||
|
||||
Reference in New Issue
Block a user