@thatopen/services 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CONTEXT.md +258 -0
  2. package/README.md +285 -0
  3. package/dist/built-in/index.d.ts +723 -0
  4. package/dist/cli/commands/create-tests.d.ts +3 -0
  5. package/dist/cli/commands/create.d.ts +3 -0
  6. package/dist/cli/commands/local-server.d.ts +3 -0
  7. package/dist/cli/commands/login.d.ts +3 -0
  8. package/dist/cli/commands/publish.d.ts +3 -0
  9. package/dist/cli/commands/run.d.ts +3 -0
  10. package/dist/cli/commands/serve-tests.d.ts +3 -0
  11. package/dist/cli/commands/serve.d.ts +3 -0
  12. package/dist/cli/index.d.ts +1 -0
  13. package/dist/cli/lib/config.d.ts +25 -0
  14. package/dist/cli/lib/declarations.d.ts +19 -0
  15. package/dist/cli/lib/engine-script.d.ts +10 -0
  16. package/dist/cli/lib/execution-manager.d.ts +52 -0
  17. package/dist/cli/lib/zip.d.ts +6 -0
  18. package/dist/cli.js +11566 -0
  19. package/dist/core/client.d.ts +682 -0
  20. package/dist/core/client.test.d.ts +1 -0
  21. package/dist/core/platform-client.d.ts +106 -0
  22. package/dist/core/platform-client.test.d.ts +1 -0
  23. package/dist/core/request-error.d.ts +25 -0
  24. package/dist/core/request-error.test.d.ts +1 -0
  25. package/dist/index.cjs.js +2 -0
  26. package/dist/index.d.ts +12 -0
  27. package/dist/index.es.js +3310 -0
  28. package/dist/types/base.d.ts +9 -0
  29. package/dist/types/context.d.ts +20 -0
  30. package/dist/types/execution.d.ts +19 -0
  31. package/dist/types/files.d.ts +19 -0
  32. package/dist/types/item.dto.d.ts +24 -0
  33. package/dist/types/items.d.ts +57 -0
  34. package/dist/types/projects.d.ts +59 -0
  35. package/dist/types/response.d.ts +10 -0
  36. package/dist/types/storage.d.ts +11 -0
  37. package/dist/vite-env.d.ts +1 -0
  38. package/package.json +100 -0
  39. package/src/built-in/index.ts +755 -0
  40. package/src/cli/templates/bim/CONTEXT.md +244 -0
  41. package/src/cli/templates/bim/package.json +26 -0
  42. package/src/cli/templates/bim/src/app.ts +16 -0
  43. package/src/cli/templates/bim/src/bim-components/CloudRunner/index.ts +91 -0
  44. package/src/cli/templates/bim/src/bim-components/CloudRunner/src/index.ts +1 -0
  45. package/src/cli/templates/bim/src/bim-components/CloudRunner/src/types.ts +5 -0
  46. package/src/cli/templates/bim/src/bim-components/index.ts +1 -0
  47. package/src/cli/templates/bim/src/globals.ts +1 -0
  48. package/src/cli/templates/bim/src/main.ts +90 -0
  49. package/src/cli/templates/bim/src/setups/cloud-runner.ts +13 -0
  50. package/src/cli/templates/bim/src/setups/index.ts +3 -0
  51. package/src/cli/templates/bim/src/setups/ui-manager.ts +27 -0
  52. package/src/cli/templates/bim/src/setups/viewports-manager.ts +22 -0
  53. package/src/cli/templates/bim/src/ui-components/app-info-section/index.ts +26 -0
  54. package/src/cli/templates/bim/src/ui-components/app-info-section/src/index.ts +1 -0
  55. package/src/cli/templates/bim/src/ui-components/app-info-section/src/types.ts +15 -0
  56. package/src/cli/templates/bim/src/ui-components/cloud-runner-section/index.ts +37 -0
  57. package/src/cli/templates/bim/src/ui-components/cloud-runner-section/src/index.ts +1 -0
  58. package/src/cli/templates/bim/src/ui-components/cloud-runner-section/src/types.ts +14 -0
  59. package/src/cli/templates/bim/src/ui-components/index.ts +2 -0
  60. package/src/cli/templates/cloud/CONTEXT.md +205 -0
  61. package/src/cli/templates/cloud/_thatopen +5 -0
  62. package/src/cli/templates/cloud/declarations.json +4 -0
  63. package/src/cli/templates/cloud/package.json +22 -0
  64. package/src/cli/templates/cloud/src/main.ts +70 -0
  65. package/src/cli/templates/cloud-test/CONTEXT.md +56 -0
  66. package/src/cli/templates/cloud-test/_thatopen +5 -0
  67. package/src/cli/templates/cloud-test/package.json +22 -0
  68. package/src/cli/templates/cloud-test/src/main.ts +565 -0
  69. package/src/cli/templates/default/CONTEXT.md +92 -0
  70. package/src/cli/templates/default/package.json +15 -0
  71. package/src/cli/templates/default/src/main.ts +62 -0
  72. package/src/cli/templates/shared/_gitignore +4 -0
  73. package/src/cli/templates/shared/app/index.html +27 -0
  74. package/src/cli/templates/shared/app/tsconfig.json +16 -0
  75. package/src/cli/templates/shared/app/vite.config.js +23 -0
  76. package/src/cli/templates/shared/cloud/tsconfig.json +16 -0
  77. package/src/cli/templates/shared/cloud/vite.config.js +27 -0
  78. package/src/cli/templates/test/CONTEXT.md +53 -0
  79. package/src/cli/templates/test/package.json +25 -0
  80. package/src/cli/templates/test/src/main.ts +955 -0
@@ -0,0 +1,682 @@
1
+ import { ExecutionEntity, ExecutionSuscriptionReturnType } from '../types/execution';
2
+ import { AppVersionProps, ComponentVersionProps, ComponentItem, AppItem, Item, ItemFolder, ItemVersion, ItemWithVersions } from '../types/items';
3
+ import { CreateItemResponse, UpdateItemResponse } from '../types/response';
4
+ import { CreateHiddenItemResult, HiddenFileEntity, Metadata } from '../types/files';
5
+ import { ThatOpenContext } from '../types/context';
6
+
7
+ declare global {
8
+ interface Window {
9
+ __THATOPEN_CONTEXT__?: ThatOpenContext;
10
+ ThatOpenCompany?: Record<string, unknown>;
11
+ }
12
+ }
13
+ /**
14
+ * Minimal shape of an OBC.Components-like object.
15
+ * Avoids hard-coupling to `@thatopen/components` at the public API level.
16
+ */
17
+ export interface ComponentsLike {
18
+ get<T>(c: new (...args: any[]) => T): T;
19
+ init(): void;
20
+ }
21
+ /** Properties for creating a new item (file, component, or app). */
22
+ export type CreateItemProps = {
23
+ /** The file to upload (File in browsers, Blob in Node.js). */
24
+ file: File | Blob;
25
+ /** Display name of the item. */
26
+ name: string;
27
+ /** Semantic version tag (e.g. "v1", "v1.0.0"). */
28
+ versionTag: string;
29
+ /** Optional folder ID to place the item in. */
30
+ parentFolderId?: string;
31
+ /** Optional project ID to associate the item with. */
32
+ projectId?: string;
33
+ /** Optional free-JSON metadata stored on the first version. */
34
+ metadata?: Metadata;
35
+ };
36
+ /** Properties for updating an existing item. Combines rename/move with optional new version upload. */
37
+ export type UpdateItemProps = {
38
+ /** New display name. */
39
+ name?: string;
40
+ /** New parent folder ID (moves the item). */
41
+ parentFolderId?: string;
42
+ /** New file to upload as a new version (File in browsers, Blob in Node.js). */
43
+ file?: File | Blob;
44
+ /** Version tag for the new file version. */
45
+ versionTag?: string;
46
+ /** Optional free-JSON metadata stored on the new version. */
47
+ metadata?: Metadata;
48
+ };
49
+ /** Properties for creating an app. Extends {@link CreateItemProps} with app-specific version props. */
50
+ export type CreateAppProps = CreateItemProps & {
51
+ /** App version properties (isOnline, url). */
52
+ appProps?: AppVersionProps;
53
+ };
54
+ /** Properties for creating a component. Extends {@link CreateItemProps} with component-specific version props. */
55
+ export type CreateComponentProps = CreateItemProps & {
56
+ /** Component version properties (type, tier, isPublic, etc.). Required. */
57
+ componentProps: ComponentVersionProps;
58
+ };
59
+ /** Properties for updating a component. Extends {@link UpdateItemProps} with component-specific version props. */
60
+ export type UpdateComponentProps = UpdateItemProps & {
61
+ /** Component version properties for the new version. */
62
+ componentProps?: ComponentVersionProps;
63
+ };
64
+ /** Options for retrieving a single item. */
65
+ export type GetItemProps = {
66
+ /** If true, includes the item's version history. */
67
+ showVersions?: boolean;
68
+ };
69
+ /** Filter/query params for listing items. */
70
+ export type GetItemsParams = {
71
+ /** Filter by folder. */
72
+ folderId?: string;
73
+ /** If true, includes version history for each item. */
74
+ ShowVersions?: boolean;
75
+ };
76
+ /** Parameters for downloading a specific item version. */
77
+ export type DownloadItemFileParams = {
78
+ /** Download a specific version by tag instead of the latest. */
79
+ versionTag?: string;
80
+ /** If true, includes draft versions in resolution. */
81
+ withDraft?: boolean;
82
+ };
83
+ /** Configuration options for the {@link EngineServicesClient} constructor. */
84
+ export type EngineServicesClientProps = {
85
+ /** Number of automatic retries on request failure. Default: 0. */
86
+ retries?: number;
87
+ /**
88
+ * If true, sends the token as an `Authorization: Bearer` header instead of
89
+ * an `accessToken` query parameter. Use this when authenticating with an
90
+ * Auth0 JWT (e.g. inside platform apps) rather than a platform API token.
91
+ */
92
+ useBearer?: boolean;
93
+ /**
94
+ * URL of a local execution server started with `thatopen local-server`.
95
+ * When set, execution methods (executeComponent, onExecutionProgress,
96
+ * listExecutions, getExecution, abortExecution) are routed to this server
97
+ * instead of the cloud API. All other methods remain unchanged.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const client = new EngineServicesClient(token, apiUrl, {
102
+ * localServerUrl: 'http://localhost:4001',
103
+ * });
104
+ * ```
105
+ */
106
+ localServerUrl?: string;
107
+ };
108
+ /**
109
+ * Client for the That Open Engine Services API.
110
+ *
111
+ * Provides methods for managing files, folders, components, apps,
112
+ * executions, hidden files, projects, and permissions.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * import { EngineServicesClient } from 'thatopen-services';
117
+ *
118
+ * const client = new EngineServicesClient('my-access-token', 'https://api.thatopen.com');
119
+ * const files = await client.listFiles();
120
+ * ```
121
+ */
122
+ export declare class EngineServicesClient {
123
+ #private;
124
+ private apiUrl;
125
+ private accessToken;
126
+ private wsUrl;
127
+ private retries;
128
+ private useBearer;
129
+ private builtInGlobals;
130
+ /**
131
+ * URL of a local execution server (e.g. `http://localhost:4001`).
132
+ * When set, execution methods are routed to this server instead of the cloud API.
133
+ * Set to `null` to disable local routing and use the cloud API.
134
+ */
135
+ localServerUrl: string | null;
136
+ /**
137
+ * The platform context this client was created with.
138
+ * Contains `appId`, `projectId`, `accessToken`, and `apiUrl`.
139
+ * Populated automatically when using {@link fromPlatformContext}.
140
+ */
141
+ readonly context: ThatOpenContext;
142
+ /**
143
+ * Creates a client from the platform context injected into
144
+ * `window.__THATOPEN_CONTEXT__` by the That Open Platform.
145
+ *
146
+ * This is the recommended way to create a client inside platform apps.
147
+ * It automatically reads the auth context and sets `useBearer: true`.
148
+ *
149
+ * @param props - Optional configuration (retry count, local server URL, etc.).
150
+ * @returns A new EngineServicesClient instance.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * const client = EngineServicesClient.fromPlatformContext();
155
+ * console.log(client.context.projectId);
156
+ * ```
157
+ */
158
+ static fromPlatformContext(props?: Omit<EngineServicesClientProps, 'useBearer'>): EngineServicesClient;
159
+ /**
160
+ * Creates a new EngineServicesClient instance.
161
+ * @param accessToken - API access token (obtained from the platform dashboard)
162
+ * or an Auth0 JWT (when using `useBearer: true`).
163
+ * @param apiUrl - Base URL of the API (e.g. "https://api.thatopen.com").
164
+ * @param props - Optional configuration (retry count, auth mode, etc.).
165
+ */
166
+ constructor(accessToken: string, apiUrl: string, props?: EngineServicesClientProps);
167
+ /**
168
+ * Sets the number of automatic retries for failed requests.
169
+ * @param retries - Number of retries (0 = no retries).
170
+ */
171
+ setRetries(retries: number): void;
172
+ /**
173
+ * Registers the global libraries that built-in components need at runtime.
174
+ *
175
+ * Call this once after importing your libraries. Then every subsequent
176
+ * {@link initBuiltInComponent} call will use these globals automatically
177
+ * — you no longer need to pass a `globals` argument to each one.
178
+ *
179
+ * @param globals - Map of global names to module namespaces.
180
+ * Common keys: `OBC`, `OBF`, `BUI`, `CUI`, `THREE`, `FRAGS`, `MARKERJS`.
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * import * as OBC from "@thatopen/components";
185
+ * import * as OBF from "@thatopen/components-front";
186
+ * import * as BUI from "@thatopen/ui";
187
+ * import * as CUI from "@thatopen/ui-obc";
188
+ * import * as THREE from "three";
189
+ * import * as FRAGS from "@thatopen/fragments";
190
+ *
191
+ * client.setBuiltInGlobals({ OBC, OBF, BUI, CUI, THREE, FRAGS });
192
+ *
193
+ * // Now just pass the component — no globals needed:
194
+ * await client.initBuiltInComponent(AppManager, components);
195
+ * await client.initBuiltInComponent(ViewerToolbar, components);
196
+ * await client.initBuiltInComponent(ModelsPanel, components);
197
+ * ```
198
+ */
199
+ setBuiltInGlobals(globals: Record<string, unknown>): void;
200
+ /**
201
+ * Protected extension point for subclasses that need dynamic tokens
202
+ * (e.g. `PlatformClient` with an auth provider callback). The default
203
+ * returns the static token captured at construction time.
204
+ *
205
+ * When a subclass overrides this to call an async refresh function,
206
+ * the new token is picked up on every request — expired tokens no
207
+ * longer stick around.
208
+ */
209
+ protected resolveAccessToken(): Promise<string>;
210
+ /**
211
+ * Protected extension hook for subclasses (e.g. `PlatformClient`) that
212
+ * need to add HTTP methods against additional backend routes. Delegates
213
+ * to the private `#requestApi` implementation so retry / auth / query-
214
+ * cleaning logic is applied identically.
215
+ */
216
+ protected request<T = object>(method: string, path: string, requestData?: {
217
+ body?: BodyInit;
218
+ query?: object;
219
+ contentType?: 'application/json' | 'multipart/form-data' | 'application/x-www-form-urlencoded';
220
+ retries?: number;
221
+ }): Promise<T>;
222
+ /**
223
+ * Lists all files accessible by the current token.
224
+ * @param filters - Optional filters for folder and archive status.
225
+ * @returns Array of file items.
226
+ */
227
+ listFiles(filters?: {
228
+ folderId?: string;
229
+ archived?: boolean;
230
+ /**
231
+ * Scope the listing to a project. Requires the token owner to have
232
+ * `STORAGE:READ` role in that project; otherwise the backend returns
233
+ * 403. Per-entity permission overrides are applied server-side.
234
+ */
235
+ projectId?: string;
236
+ }): Promise<Item[]>;
237
+ /**
238
+ * Gets a single file by ID, optionally including version history.
239
+ * @param fileId - The file's unique identifier.
240
+ * @param props - Options such as whether to include versions.
241
+ * @returns The file item, optionally with version history.
242
+ */
243
+ getFile(fileId: string, props?: GetItemProps): Promise<ItemWithVersions<ItemWithVersions<Item>>>;
244
+ /**
245
+ * Uploads a new file.
246
+ * @param fileData - File content, name, and version tag.
247
+ * @returns The created item and its first version.
248
+ */
249
+ createFile(fileData: CreateItemProps): Promise<CreateItemResponse<Item>>;
250
+ /**
251
+ * Updates an existing file. Can rename, move to a different folder,
252
+ * and/or upload a new version — all in a single call.
253
+ * @param fileId - The file's unique identifier.
254
+ * @param fileData - Properties to update (name, folderId, file, versionTag).
255
+ * @returns The updated item and/or the new version.
256
+ */
257
+ updateFile(fileId: string, fileData: UpdateItemProps): Promise<UpdateItemResponse>;
258
+ /**
259
+ * Archives (soft-deletes) a file. Can be recovered with {@link recoverFile}.
260
+ * @param fileId - The file's unique identifier.
261
+ */
262
+ archiveFile(fileId: string): Promise<Item>;
263
+ /**
264
+ * Recovers a previously archived file.
265
+ * @param fileId - The file's unique identifier.
266
+ */
267
+ recoverFile(fileId: string): Promise<Item>;
268
+ /**
269
+ * Downloads a file's content. Returns the raw fetch Response.
270
+ * @param fileId - The file's unique identifier.
271
+ * @param params - Optional version selection parameters.
272
+ * @returns A fetch Response containing the file data.
273
+ */
274
+ downloadFile(fileId: string, params?: DownloadItemFileParams): Promise<Response>;
275
+ /**
276
+ * Retrieves the free-JSON metadata for a specific file version.
277
+ * Returns `{}` when the version exists but has no metadata.
278
+ * @param fileId - The file's unique identifier.
279
+ * @param versionTag - The version tag (e.g. "v1").
280
+ * @param params - Optional flags such as `withDraft`.
281
+ */
282
+ getFileVersionMetadata(fileId: string, versionTag: string, params?: {
283
+ withDraft?: boolean;
284
+ }): Promise<Metadata>;
285
+ /**
286
+ * Replaces the metadata of a specific file version with the provided object.
287
+ * @param fileId - The file's unique identifier.
288
+ * @param versionTag - The version tag.
289
+ * @param metadata - Free-JSON object (max 200 fields, 50-char keys/values).
290
+ */
291
+ updateFileVersionMetadata(fileId: string, versionTag: string, metadata: Metadata): Promise<Metadata>;
292
+ /**
293
+ * Clears all metadata from a specific file version.
294
+ * @param fileId - The file's unique identifier.
295
+ * @param versionTag - The version tag.
296
+ */
297
+ deleteFileVersionMetadata(fileId: string, versionTag: string): Promise<{
298
+ success: boolean;
299
+ }>;
300
+ /**
301
+ * Lists all folders accessible by the current token.
302
+ * @param params - Optional filters for parent folder and archive status.
303
+ * @returns Array of folder items.
304
+ */
305
+ listFolders(params?: {
306
+ parentFolderId?: string;
307
+ archived?: boolean;
308
+ /**
309
+ * Scope the listing to a project. Requires the token owner to have
310
+ * `STORAGE:READ` in that project; returns 403 otherwise.
311
+ */
312
+ projectId?: string;
313
+ }): Promise<ItemFolder[]>;
314
+ /**
315
+ * Gets a single folder by ID.
316
+ * @param folderId - The folder's unique identifier.
317
+ */
318
+ getFolder(folderId: string): Promise<ItemFolder>;
319
+ /**
320
+ * Creates a new folder.
321
+ * @param name - Display name for the folder.
322
+ * @param parentId - Optional parent folder ID for nesting.
323
+ * @returns The created folder.
324
+ */
325
+ createFolder(name: string, parentId?: string, projectId?: string): Promise<ItemFolder>;
326
+ /**
327
+ * Renames a folder.
328
+ * @param folderId - The folder's unique identifier.
329
+ * @param updateFolderParams - New name for the folder.
330
+ * @returns The updated folder.
331
+ */
332
+ updateFolder(folderId: string, updateFolderParams: {
333
+ name?: string;
334
+ }): Promise<ItemFolder>;
335
+ /**
336
+ * Archives (soft-deletes) a folder. Can be recovered with {@link recoverFolder}.
337
+ * @param folderId - The folder's unique identifier.
338
+ */
339
+ archiveFolder(folderId: string): Promise<ItemFolder>;
340
+ /**
341
+ * Recovers a previously archived folder.
342
+ * @param folderId - The folder's unique identifier.
343
+ */
344
+ recoverFolder(folderId: string): Promise<ItemFolder>;
345
+ /**
346
+ * Downloads an entire folder as a ZIP archive.
347
+ * @param folderId - The folder's unique identifier.
348
+ * @returns A fetch Response containing the ZIP data.
349
+ */
350
+ downloadFolder(folderId: string): Promise<Response>;
351
+ /**
352
+ * Lists all components (tools) accessible by the current token.
353
+ * @param params - Optional filters for folder and version inclusion.
354
+ * @returns Array of component items.
355
+ */
356
+ listComponents(params?: GetItemsParams & {
357
+ projectId?: string;
358
+ }): Promise<ComponentItem[]>;
359
+ /**
360
+ * Gets a single component by ID, optionally including version history.
361
+ * @param componentId - The component's unique identifier.
362
+ * @param props - Options such as whether to include versions.
363
+ */
364
+ getComponent(componentId: string, props?: GetItemProps): Promise<ItemWithVersions<ItemWithVersions<ComponentItem>>>;
365
+ /**
366
+ * Creates a new component with the given file and version properties.
367
+ * @param componentData - File content, name, version tag, and component-specific props.
368
+ * @returns The created component item and its first version.
369
+ */
370
+ createComponent(componentData: CreateComponentProps): Promise<CreateItemResponse<ComponentItem>>;
371
+ /**
372
+ * Updates an existing component. Can rename, move, and/or upload a new version.
373
+ * @param componentId - The component's unique identifier.
374
+ * @param componentData - Properties to update, including optional new componentProps.
375
+ * @returns The updated item and/or new version.
376
+ */
377
+ updateComponent(componentId: string, componentData: UpdateComponentProps): Promise<UpdateItemResponse<ComponentItem>>;
378
+ /**
379
+ * Downloads a component's full ZIP file. Returns the raw fetch Response.
380
+ * @param componentId - The component's unique identifier.
381
+ * @param params - Optional version selection parameters.
382
+ * @returns A fetch Response containing the ZIP data.
383
+ */
384
+ downloadComponent(componentId: string, params?: DownloadItemFileParams): Promise<Response>;
385
+ /**
386
+ * Downloads only the JavaScript bundle from a component's ZIP.
387
+ * This is the extracted `bundle` entry, returned as text.
388
+ * @param componentId - The component's unique identifier.
389
+ * @param params - Optional version selection parameters.
390
+ * @returns A fetch Response containing the bundle JavaScript text.
391
+ */
392
+ downloadComponentBundle(componentId: string, params?: DownloadItemFileParams): Promise<Response>;
393
+ /**
394
+ * Archives (soft-deletes) a component. Can be recovered with {@link recoverComponent}.
395
+ * @param componentId - The component's unique identifier.
396
+ */
397
+ archiveComponent(componentId: string): Promise<ComponentItem>;
398
+ /**
399
+ * Recovers a previously archived component.
400
+ * @param componentId - The component's unique identifier.
401
+ */
402
+ recoverComponent(componentId: string): Promise<ComponentItem>;
403
+ /**
404
+ * Fetches a built-in component's JavaScript bundle by name.
405
+ * @param name - The built-in component name (e.g. "hello-world").
406
+ * @returns The component's JavaScript source code as a string.
407
+ */
408
+ getBuiltInComponent(name: string): Promise<string>;
409
+ /**
410
+ * Fetches a built-in component bundle, evaluates it, and registers it
411
+ * with the given `components` instance via `components.get()`.
412
+ *
413
+ * After calling this, retrieve the singleton instance with
414
+ * `components.get(ComponentClass)`.
415
+ *
416
+ * @param component - The component class stub (must have a static `uuid`).
417
+ * @param components - The OBC `Components` instance used to register the
418
+ * component (must expose a `.get()` method).
419
+ * @param globals - Map of global names to values that the component source
420
+ * expects in scope (e.g. `{ OBC, BUI }`). If omitted, falls back to
421
+ * globals registered via {@link setBuiltInGlobals}, then to
422
+ * `window.ThatOpenCompany`.
423
+ *
424
+ * @example
425
+ * ```ts
426
+ * // Option 1: register globals once, then init without passing them
427
+ * client.setBuiltInGlobals({ OBC, OBF, BUI, CUI, THREE, FRAGS });
428
+ * await client.initBuiltInComponent(AppManager, components);
429
+ * await client.initBuiltInComponent(ViewerToolbar, components);
430
+ *
431
+ * // Option 2: pass globals per component (still works)
432
+ * await client.initBuiltInComponent(HelloWorld, components, { OBC, BUI });
433
+ * ```
434
+ */
435
+ initBuiltInComponent(component: {
436
+ uuid: string;
437
+ }, components: ComponentsLike, globals?: Record<string, unknown>): Promise<void>;
438
+ /**
439
+ * Loads multiple built-in components in parallel.
440
+ *
441
+ * Convenience wrapper around {@link initBuiltInComponent} that fetches
442
+ * and registers all given component stubs concurrently.
443
+ *
444
+ * @param components - The OBC `Components` instance.
445
+ * @param stubs - One or more component stubs (e.g. `AppManager`, `ViewportManager`).
446
+ *
447
+ * @example
448
+ * ```ts
449
+ * await client.initBuiltInComponents(components, AppManager, ViewportManager);
450
+ * ```
451
+ */
452
+ initBuiltInComponents(components: ComponentsLike, ...stubs: {
453
+ uuid: string;
454
+ }[]): Promise<void>;
455
+ /**
456
+ * High-level helper that creates an OBC component system, initialises BUI,
457
+ * loads built-in components, and starts the engine — all in one call.
458
+ *
459
+ * @param globals - Map of global names to module namespaces
460
+ * (must include at least `OBC` and `BUI`).
461
+ * @param builtIns - Built-in component stubs to load (e.g. `AppManager`, `ViewportManager`).
462
+ * @returns An object containing the initialised `components` instance.
463
+ *
464
+ * @example
465
+ * ```ts
466
+ * const { components } = await client.setup(
467
+ * { OBC, OBF, BUI, CUI, THREE, FRAGS },
468
+ * AppManager, ViewportManager,
469
+ * );
470
+ *
471
+ * const viewports = components.get(ViewportManager);
472
+ * const { element, world } = await viewports.create();
473
+ * ```
474
+ */
475
+ setup<TComponents extends ComponentsLike = ComponentsLike>(globals: Record<string, unknown>, ...builtIns: {
476
+ uuid: string;
477
+ }[]): Promise<{
478
+ components: TComponents;
479
+ }>;
480
+ /**
481
+ * Reports an error to the platform via the {@link AppEventOrchestrator.appError} callback.
482
+ * @param code - Numeric error code.
483
+ * @param data - Arbitrary error data to send to the platform.
484
+ */
485
+ throwError(code: number, data: Record<string, string>): void;
486
+ /**
487
+ * Lists all apps accessible by the current token.
488
+ * @param params - Optional filters for folder and version inclusion.
489
+ * @returns Array of app items.
490
+ */
491
+ listApps(params?: GetItemsParams & {
492
+ projectId?: string;
493
+ }): Promise<AppItem[]>;
494
+ /**
495
+ * Creates a new app with the given file and optional version properties.
496
+ * @param appData - File content, name, version tag, and optional app-specific props.
497
+ * @returns The created app item and its first version.
498
+ */
499
+ createApp(appData: CreateAppProps): Promise<CreateItemResponse<AppItem>>;
500
+ /**
501
+ * Downloads an app's full ZIP file. Returns the raw fetch Response.
502
+ * @param appId - The app's unique identifier.
503
+ * @param params - Optional version selection parameters.
504
+ * @returns A fetch Response containing the ZIP data.
505
+ */
506
+ downloadApp(appId: string, params?: DownloadItemFileParams): Promise<Response>;
507
+ /**
508
+ * Downloads only the JavaScript bundle from an app's ZIP.
509
+ * This is the extracted `bundle` entry, returned as text.
510
+ * @param appId - The app's unique identifier.
511
+ * @param params - Optional version selection parameters.
512
+ * @returns A fetch Response containing the bundle JavaScript text.
513
+ */
514
+ downloadAppBundle(appId: string, params?: DownloadItemFileParams): Promise<Response>;
515
+ /**
516
+ * Archives (soft-deletes) an app.
517
+ * @param appId - The app's unique identifier.
518
+ */
519
+ archiveApp(appId: string): Promise<AppItem>;
520
+ /**
521
+ * Triggers server-side execution of a cloud component.
522
+ *
523
+ * Pass `projectId` in `executionParams` when running the component in the
524
+ * context of a specific project. The backend validates that the component
525
+ * is linked to that project AND that the user has execute permission
526
+ * there; a foreign `projectId` is rejected with 403. Omit `projectId` for
527
+ * personal executions (ownership path).
528
+ *
529
+ * @param componentId - The component's unique identifier.
530
+ * @param executionParams - Arbitrary parameters passed to the component's `main()` function. Include `projectId` to scope the execution.
531
+ * @param versionTag - Optional version to execute (defaults to latest).
532
+ * @returns An object containing the `executionId` to track progress.
533
+ */
534
+ executeComponent(componentId: string, executionParams: {
535
+ projectId?: string;
536
+ [key: string]: unknown;
537
+ }, versionTag?: string): Promise<{
538
+ executionId: string;
539
+ }>;
540
+ /**
541
+ * Aborts a running execution.
542
+ * @param executionId - The execution's unique identifier.
543
+ */
544
+ abortExecution(executionId: string): Promise<ExecutionEntity>;
545
+ /**
546
+ * Lists all executions for a given component.
547
+ *
548
+ * When `projectId` is supplied, the backend scopes the query to that
549
+ * project — returning only executions launched in that context AND
550
+ * enforcing that the caller has access to the component there. Without
551
+ * `projectId`, the caller's personal executions for the component are
552
+ * returned.
553
+ *
554
+ * @param componentId - The component's unique identifier.
555
+ * @param projectId - Optional project scope.
556
+ * @returns Array of execution entities.
557
+ */
558
+ listExecutions(componentId: string, projectId?: string): Promise<ExecutionEntity[]>;
559
+ /**
560
+ * Gets details of a specific execution, including its messages.
561
+ * @param executionId - The execution's unique identifier.
562
+ * @returns The execution entity with progress and result info.
563
+ */
564
+ getExecution(executionId: string): Promise<ExecutionEntity>;
565
+ /**
566
+ * Subscribes to real-time execution progress via WebSocket.
567
+ * The callback fires on each progress update until the execution completes.
568
+ * @param executionId - The execution's unique identifier.
569
+ * @param onUpdateCallback - Callback invoked on each progress/result event.
570
+ */
571
+ onExecutionProgress(executionId: string, onUpdateCallback: (data: ExecutionSuscriptionReturnType) => void): Promise<void>;
572
+ /**
573
+ * Creates a hidden file attached to a parent item (e.g., dependencies, assets).
574
+ * @param file - The file to upload.
575
+ * @param parentFileId - The parent item's unique identifier.
576
+ * @returns The hidden file ID.
577
+ */
578
+ createHiddenFile(file: File | Blob, parentFileId: string): Promise<CreateHiddenItemResult>;
579
+ /**
580
+ * Deletes a hidden file by its ID.
581
+ * @param hiddenId - The hidden file's unique identifier.
582
+ */
583
+ deleteHiddenFile(hiddenId: string): Promise<Item>;
584
+ /**
585
+ * Gets metadata for a hidden file.
586
+ * @param hiddenId - The hidden file's unique identifier.
587
+ */
588
+ getHiddenFile(hiddenId: string): Promise<HiddenFileEntity>;
589
+ /**
590
+ * Downloads a hidden file's content. Returns the raw fetch Response.
591
+ * @param hiddenId - The hidden file's unique identifier.
592
+ */
593
+ downloadHiddenFile(hiddenId: string): Promise<Response>;
594
+ /**
595
+ * Lists all hidden files attached to a parent item.
596
+ * @param parentFileId - The parent item's unique identifier.
597
+ * @returns Array of hidden file entities.
598
+ */
599
+ getHiddenFilesByParent(parentFileId: string): Promise<HiddenFileEntity[]>;
600
+ /**
601
+ * Deletes all hidden files attached to a parent item.
602
+ * @param parentFileId - The parent item's unique identifier.
603
+ */
604
+ deleteHiddenFilesByParent(parentFileId: string): Promise<Item[]>;
605
+ /**
606
+ * Uploads or replaces the icon for an item (app, component, or file).
607
+ * Accepts PNG, WebP, or ICO images up to 512 KB.
608
+ * @param itemId - The item's unique identifier.
609
+ * @param icon - The icon image file (File in browsers, Blob in Node.js).
610
+ * @returns The updated item with `iconFileId` and `iconMimeType` set.
611
+ */
612
+ uploadItemIcon(itemId: string, icon: File | Blob): Promise<Item>;
613
+ /**
614
+ * Downloads the icon for an item as a binary stream.
615
+ * @param itemId - The item's unique identifier.
616
+ * @returns The raw Response (use `.blob()`, `.arrayBuffer()`, or pipe the body).
617
+ */
618
+ getItemIcon(itemId: string): Promise<Response>;
619
+ /**
620
+ * Removes the icon from an item.
621
+ * @param itemId - The item's unique identifier.
622
+ * @returns The updated item with icon fields removed.
623
+ */
624
+ removeItemIcon(itemId: string): Promise<Item>;
625
+ /**
626
+ * Renames or moves an item (file, component, or app) without creating a new version.
627
+ * @param itemId - The item's unique identifier.
628
+ * @param params - New name and/or new folder ID.
629
+ * @returns The updated item.
630
+ */
631
+ updateItem(itemId: string, params: {
632
+ name?: string;
633
+ folderId?: string;
634
+ }): Promise<Item>;
635
+ /**
636
+ * Creates a new version of an item by uploading a new file.
637
+ * For APP and TOOL types, `extraProps` is required by the backend.
638
+ * @param itemId - The item's unique identifier.
639
+ * @param file - The new file to upload.
640
+ * @param versionTag - Version tag for the new version (e.g. "v2").
641
+ * @param extraProps - Version-specific properties (required for APP/TOOL types).
642
+ * @param metadata - Optional free-JSON metadata to store on the new version.
643
+ * @returns The created version.
644
+ */
645
+ createVersion(itemId: string, file: File | Blob, versionTag: string, extraProps?: object, metadata?: Metadata): Promise<ItemVersion>;
646
+ /**
647
+ * Lists versions of an item. Pass `archived: true` to fetch only archived
648
+ * versions, `false` to fetch only active ones, or omit to receive both.
649
+ * @param itemId - The item's unique identifier.
650
+ * @param params - Optional `{ archived }` filter.
651
+ * @returns Array of versions, sorted by creation date descending.
652
+ */
653
+ listVersions(itemId: string, params?: {
654
+ archived?: boolean;
655
+ }): Promise<ItemVersion[]>;
656
+ /**
657
+ * Archives a version of an item. Archived versions remain available via
658
+ * `listVersions({ archived: true })` and can be recovered or permanently
659
+ * deleted. Cleanup runs daily and removes archived versions older than the
660
+ * platform retention period.
661
+ * @param itemId - The item's unique identifier.
662
+ * @param versionTag - The version's tag (e.g. "v2").
663
+ * @returns The archived version.
664
+ */
665
+ archiveVersion(itemId: string, versionTag: string): Promise<ItemVersion>;
666
+ /**
667
+ * Recovers a previously archived version, restoring it to the active list.
668
+ * @param itemId - The item's unique identifier.
669
+ * @param versionTag - The version's tag (e.g. "v2").
670
+ * @returns The recovered version.
671
+ */
672
+ recoverVersion(itemId: string, versionTag: string): Promise<ItemVersion>;
673
+ /**
674
+ * Permanently deletes a version, including its file in object storage.
675
+ * The version must be archived first; otherwise the call is rejected.
676
+ * @param itemId - The item's unique identifier.
677
+ * @param versionTag - The version's tag (e.g. "v2").
678
+ */
679
+ deleteVersion(itemId: string, versionTag: string): Promise<{
680
+ success: boolean;
681
+ }>;
682
+ }
@@ -0,0 +1 @@
1
+ export {};