Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions src/puter-js/types/modules/apps.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PaginationOptions, RequestCallbacks } from '../shared.d.ts';

export interface AppRecord {
export interface App {
uid: string;
name: string;
index_url: string;
Expand All @@ -21,7 +21,7 @@ export interface AppListOptions extends PaginationOptions {
icon_size?: null | 16 | 32 | 64 | 128 | 256 | 512;
}

export interface CreateAppOptions extends RequestCallbacks<AppRecord> {
export interface CreateAppOptions extends RequestCallbacks<App> {
name: string;
indexURL: string;
title?: string;
Expand All @@ -34,7 +34,7 @@ export interface CreateAppOptions extends RequestCallbacks<AppRecord> {
dedupeName?: boolean;
}

export interface UpdateAppAttributes extends RequestCallbacks<AppRecord> {
export interface UpdateAppAttributes extends RequestCallbacks<App> {
name?: string;
indexURL?: string;
title?: string;
Expand All @@ -47,16 +47,11 @@ export interface UpdateAppAttributes extends RequestCallbacks<AppRecord> {
}

export class Apps {
constructor (context: { authToken?: string; APIOrigin: string; appID?: string });

setAuthToken (authToken: string): void;
setAPIOrigin (APIOrigin: string): void;

list (options?: AppListOptions): Promise<AppRecord[]>;
create (name: string, indexURL: string, title?: string): Promise<AppRecord>;
create (options: CreateAppOptions): Promise<AppRecord>;
update (name: string, attributes: UpdateAppAttributes): Promise<AppRecord>;
get (name: string, options?: AppListOptions): Promise<AppRecord>;
list (options?: AppListOptions): Promise<App[]>;
create (name: string, indexURL: string, title?: string): Promise<App>;
create (options: CreateAppOptions): Promise<App>;
update (name: string, attributes: UpdateAppAttributes): Promise<App>;
get (name: string, options?: AppListOptions): Promise<App>;
delete (name: string): Promise<{ success?: boolean }>;
getDeveloperProfile (options?: RequestCallbacks<Record<string, unknown>>): Promise<Record<string, unknown>>;
}
2 changes: 1 addition & 1 deletion src/puter-js/types/modules/networking.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class PSocket {
close (): void;
on (event: 'open', handler: () => void): void;
on (event: 'data', handler: (buffer: Uint8Array) => void): void;
on (event: 'error', handler: (reason: unknown) => void): void;
on (event: 'error', handler: (reason: string) => void): void;
on (event: 'close', handler: (hadError: boolean) => void): void;
addListener (event: SocketEvent, handler: (...args: unknown[]) => void): void;
}
Expand Down
9 changes: 2 additions & 7 deletions src/puter-js/types/modules/os.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import type { RequestCallbacks } from '../shared.d.ts';
import type { AuthUser } from './auth.d.ts';
import type { User } from './auth.d.ts';

export class OS {
constructor (context: { authToken?: string; APIOrigin: string; appID?: string });

setAuthToken (authToken: string): void;
setAPIOrigin (APIOrigin: string): void;

user (options?: RequestCallbacks<AuthUser> & { query?: Record<string, string> }): Promise<AuthUser>;
user (options?: RequestCallbacks<User> & { query?: Record<string, string> }): Promise<User>;
version (options?: RequestCallbacks<Record<string, unknown>>): Promise<Record<string, unknown>>;
}
17 changes: 10 additions & 7 deletions src/puter-js/types/modules/ui.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { RequestCallbacks } from '../shared.d.ts';
import type { FSItem } from './fs-item.d.ts';

export interface AlertButton {
Expand Down Expand Up @@ -36,8 +35,12 @@ export interface WindowOptions {

export interface LaunchAppOptions {
name?: string;
app_name?: string;
args?: Record<string, unknown>;
appInstanceID?: string;
file_paths?: string[];
items?: FSItem[];
pseudonym?: string;
callback?: (connection: AppConnection) => void;
}

export interface ThemeData {
Expand Down Expand Up @@ -90,17 +93,17 @@ export class AppConnection {
}

export class UI {
constructor (context: Record<string, unknown>, parameters: { appInstanceID?: string; parentInstanceID?: string });

alert (message?: string, buttons?: AlertButton[]): Promise<string>;
prompt (message?: string, defaultValue?: string): Promise<string | null>;
authenticateWithPuter (): Promise<unknown>;
prompt (message?: string, placeholder?: string): Promise<string | null>;
authenticateWithPuter (): Promise<void>;
contextMenu (options: ContextMenuOptions): void;
createWindow (options?: WindowOptions): void;
exit (statusCode?: number): void;
getLanguage (): Promise<string>;
hideSpinner (): void;
hideWindow (): void;
showSpinner (): void;
showWindow (): void;
showColorPicker (defaultColor?: string | Record<string, unknown>): Promise<string>;
showDirectoryPicker (options?: DirectoryPickerOptions): Promise<FSItem | FSItem[]>;
showFontPicker (defaultFont?: string | Record<string, unknown>): Promise<{ fontFamily: string }>;
Expand All @@ -127,7 +130,7 @@ export class UI {
on (eventName: 'localeChanged', handler: (data: { language: string }) => void): void;
on (eventName: 'themeChanged', handler: (data: ThemeData) => void): void;
parentApp (): AppConnection | null;
launchApp (appName?: string, args?: Record<string, unknown>): Promise<AppConnection>;
launchApp (appName?: string, args?: Record<string, unknown>, callback?: (connection: AppConnection) => void): Promise<AppConnection>;
launchApp (options: LaunchAppOptions): Promise<AppConnection>;

getEntriesFromDataTransferItems (dataTransferItems: DataTransferItemList, options?: { raw?: boolean }): Promise<Array<File | FileSystemEntry>>;
Expand Down
1 change: 0 additions & 1 deletion src/puter-js/types/modules/util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ export class UtilRPC {
}

export default class Util {
constructor ();
rpc: UtilRPC;
}
4 changes: 0 additions & 4 deletions src/puter-js/types/modules/workers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@ export interface WorkerInfo {
file_path?: string;
file_uid?: string;
created_at?: string;
[key: string]: unknown;
}

export interface WorkerDeployment {
success: boolean;
url: string;
errors?: unknown[];
[key: string]: unknown;
}

export class WorkersHandler {
constructor (authToken?: string);

create (workerName: string, filePath: string, appName?: string): Promise<WorkerDeployment>;
delete (workerName: string): Promise<boolean>;
exec (request: RequestInfo | URL, init?: RequestInit): Promise<Response>;
Expand Down
6 changes: 1 addition & 5 deletions src/puter-js/types/puter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import type Util from './modules/util.d.ts';
import type { WorkersHandler } from './modules/workers.d.ts';
import type { APICallLogger, APILoggingConfig, PuterEnvironment, ToolSchema } from './shared.d.ts';

export interface NetAPI extends Networking {}

export interface PuterArgs {
[key: string]: unknown;
}
Expand Down Expand Up @@ -65,13 +63,11 @@ export class Puter {
[key: string]: unknown;
};

net: NetAPI;
net: Networking;
workers: WorkersHandler;

static FSItem: typeof FSItem;

constructor();

setAuthToken(authToken: string): void;
resetAuthToken(): void;
setAPIOrigin(APIOrigin: string): void;
Expand Down
Loading