@thatopen/services 0.35.1 → 0.36.0
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.
- package/README.md +66 -66
- package/dist/built-in/index.d.ts +13 -13
- package/dist/cli/lib/browser-session.d.ts +17 -0
- package/dist/cli/lib/config.d.ts +6 -0
- package/dist/cli.js +334 -38
- package/dist/cli.js.map +1 -1
- package/dist/core/browser-sign-in.d.ts +50 -0
- package/dist/core/browser-sign-in.test.d.ts +1 -0
- package/dist/core/builtin-recipes/index.d.ts +2 -2
- package/dist/core/builtin-recipes/layer-to-native.d.ts +19 -0
- package/dist/core/builtin-recipes/records-to-native.d.ts +43 -0
- package/dist/core/builtin-recipes/shapes-to-families.d.ts +9 -4
- package/dist/core/builtin-recipes/shared.d.ts +8 -11
- package/dist/core/channel.d.ts +1 -1
- package/dist/core/client.d.ts +46 -2
- package/dist/core/frag-items.d.ts +1 -1
- package/dist/core/history.d.ts +9 -9
- package/dist/core/op-builder.d.ts +2 -2
- package/dist/core/platform-client.d.ts +6 -3
- package/dist/core/project-recipes.d.ts +1 -1
- package/dist/core/recipes.d.ts +31 -5
- package/dist/index.cjs.js +23 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +4284 -3455
- package/dist/index.es.js.map +1 -1
- package/dist/vite-env.d.ts +1 -1
- package/docs/ai-quickstart.md +548 -548
- package/docs/builtin/paths.json +130 -130
- package/docs/cli/create.md +29 -29
- package/docs/cli/local-server.md +38 -38
- package/docs/cli/login.md +35 -32
- package/docs/cli/mcp.md +46 -46
- package/docs/cli/publish.md +31 -31
- package/docs/cli/run.md +26 -26
- package/docs/cli/serve.md +43 -43
- package/docs/cli/swap.md +30 -30
- package/docs/client/paths.json +2 -2
- package/docs/cloud/GaussianSplatConverter.md +43 -43
- package/docs/cloud/PointCloudConverter.md +53 -53
- package/docs/flow-architecture.md +393 -393
- package/docs/flow-plugin-guide.md +354 -354
- package/docs/platform-token.md +81 -81
- package/docs/rate-limits.md +133 -133
- package/docs/recipes-guide.md +243 -243
- package/docs/revit-collab-quickstart.md +445 -445
- package/docs/rhino-interop-quickstart.md +387 -387
- package/docs/sheet-sets-guide.md +69 -69
- package/package.json +1 -1
- package/resources/AGENTS.md +57 -57
- package/src/built-in/CDEManager/example.ts +214 -214
- package/src/built-in/CDEManager/examples/FileEditing/example.ts +226 -226
- package/src/built-in/CDEManager/examples/FileMoves/example.ts +186 -186
- package/src/built-in/CDEManager/examples/FileOperations/example.ts +295 -295
- package/src/built-in/CDEManager/examples/FileTransfers/example.ts +210 -210
- package/src/built-in/CDEManager/examples/FolderManagement/example.ts +230 -230
- package/src/built-in/CDEManager/examples/MetadataSchema/example.ts +230 -230
- package/src/built-in/CDEManager/examples/MetadataViews/example.ts +166 -166
- package/src/built-in/CDEManager/examples/ProjectConfig/example.ts +177 -177
- package/src/built-in/ClashesManager/example.ts +283 -283
- package/src/built-in/GISManager/example.ts +355 -355
- package/src/built-in/ProjectManager/example.ts +124 -124
- package/src/built-in/UIManager/src/app/example.ts +97 -97
- package/src/built-in/UIManager/src/app/examples/AppState/example.ts +140 -140
- package/src/built-in/UIManager/src/app/examples/Banner/example.ts +159 -159
- package/src/built-in/UIManager/src/app/examples/Contexts/example.ts +123 -123
- package/src/built-in/UIManager/src/app/examples/FileDrop/example.ts +124 -124
- package/src/built-in/UIManager/src/app/examples/FloatingLayout/example.ts +90 -90
- package/src/built-in/UIManager/src/app/examples/Modal/example.ts +163 -163
- package/src/built-in/UIManager/src/app/examples/Notifications/example.ts +133 -133
- package/src/built-in/UIManager/src/app/examples/ProjectFileStorage/example.ts +150 -150
- package/src/built-in/UIManager/src/app/examples/Sidebar/example.ts +105 -105
- package/src/built-in/UIManager/src/clashes-panel/example.ts +183 -183
- package/src/built-in/UIManager/src/gis-panel/example.ts +163 -163
- package/src/built-in/UIManager/src/gis-properties-panel/example.ts +168 -168
- package/src/built-in/UIManager/src/git-history-panel/example.ts +70 -70
- package/src/built-in/UIManager/src/map-panel/example.ts +189 -189
- package/src/built-in/UIManager/src/models-list/example.ts +181 -181
- package/src/built-in/UIManager/src/settings-panel/example.ts +303 -303
- package/src/built-in/UIManager/src/topics-panel/example.ts +170 -170
- package/src/built-in/UIManager/src/viewer/example.ts +182 -182
- package/src/built-in/UIManager/src/viewer-toolbar/example.ts +376 -376
- package/src/built-in/index.ts +2995 -2995
- package/src/cli/templates/app/README.md +250 -250
- package/src/cli/templates/app/index.html +35 -35
- package/src/cli/templates/app/package.json +32 -32
- package/src/cli/templates/app/src/app.ts +37 -37
- package/src/cli/templates/app/src/assets/tool-placeholder.ts +50 -50
- package/src/cli/templates/app/src/bim-components/CloudRunner/index.ts +95 -95
- package/src/cli/templates/app/src/bim-components/CloudRunner/src/index.ts +1 -1
- package/src/cli/templates/app/src/bim-components/CloudRunner/src/types.ts +5 -5
- package/src/cli/templates/app/src/bim-components/index.ts +1 -1
- package/src/cli/templates/app/src/globals.ts +1 -1
- package/src/cli/templates/app/src/main.history.ts +191 -191
- package/src/cli/templates/app/src/main.ts +226 -226
- package/src/cli/templates/app/src/setups/channel.ts +76 -76
- package/src/cli/templates/app/src/setups/reality-capture/lib/hidden-tiles-plugin.ts +88 -88
- package/src/cli/templates/app/src/setups/reality-capture/lib/point-tile-plugin.ts +166 -166
- package/src/cli/templates/app/src/setups/reality-capture/lib/render-frame.ts +31 -31
- package/src/cli/templates/app/src/setups/reality-capture/lib/splat-tile-plugin.ts +51 -51
- package/src/cli/templates/app/src/setups/reality-capture-viewer.ts +1383 -1383
- package/src/cli/templates/app/src/ui-components/app-info-section/index.ts +26 -26
- package/src/cli/templates/app/src/ui-components/app-info-section/src/index.ts +1 -1
- package/src/cli/templates/app/src/ui-components/app-info-section/src/types.ts +15 -15
- package/src/cli/templates/app/src/ui-components/cloud-runner-section/index.ts +37 -37
- package/src/cli/templates/app/src/ui-components/cloud-runner-section/src/index.ts +1 -1
- package/src/cli/templates/app/src/ui-components/cloud-runner-section/src/types.ts +14 -14
- package/src/cli/templates/app/src/ui-components/index.ts +2 -2
- package/src/cli/templates/app/tsconfig.json +16 -16
- package/src/cli/templates/app/vite.config.js +57 -57
- package/src/cli/templates/cloud-component/README.md +205 -205
- package/src/cli/templates/cloud-component/_thatopen +5 -5
- package/src/cli/templates/cloud-component/declarations.json +4 -4
- package/src/cli/templates/cloud-component/package.json +21 -21
- package/src/cli/templates/cloud-component/src/main.ts +70 -70
- package/src/cli/templates/cloud-component/tsconfig.json +16 -16
- package/src/cli/templates/cloud-component/vite.config.js +46 -46
- package/src/cli/templates/shared/AGENTS.md +8 -8
- package/src/cli/templates/shared/CLAUDE.md +1 -1
- package/src/cli/templates/shared/_gitignore +5 -5
- package/src/core/examples/.env.example +7 -7
- package/src/core/examples/apps.ts +67 -67
- package/src/core/examples/batch-reads.ts +99 -99
- package/src/core/examples/channel.ts +65 -65
- package/src/core/examples/components.ts +91 -91
- package/src/core/examples/execution.ts +75 -75
- package/src/core/examples/file-metadata.ts +94 -94
- package/src/core/examples/files.ts +81 -81
- package/src/core/examples/folders.ts +82 -82
- package/src/core/examples/hidden-files.ts +88 -88
- package/src/core/examples/history.ts +103 -103
- package/src/core/examples/icons.ts +68 -68
- package/src/core/examples/permissions.ts +87 -87
- package/dist/core/builtin-recipes/records-to-revit.d.ts +0 -28
- package/dist/core/builtin-recipes/rhino-to-revit.d.ts +0 -16
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
// Production build config — builds dist/bundle.js as IIFE.
|
|
2
|
-
// For local development, use: npm run dev (runs thatopen serve with esbuild).
|
|
3
|
-
// Do NOT run "vite" or "vite build --watch" directly for dev.
|
|
4
|
-
import { defineConfig } from 'vite';
|
|
5
|
-
import { resolve } from 'path';
|
|
6
|
-
import { existsSync, readFileSync } from 'fs';
|
|
7
|
-
|
|
8
|
-
function getBetaAliases() {
|
|
9
|
-
if (!existsSync('.thatopen')) return {};
|
|
10
|
-
try {
|
|
11
|
-
const config = JSON.parse(readFileSync('.thatopen', 'utf-8'));
|
|
12
|
-
if (!config.beta) return {};
|
|
13
|
-
return {
|
|
14
|
-
'@thatopen/components': '@thatopen-platform/components-beta',
|
|
15
|
-
'@thatopen/components-front': '@thatopen-platform/components-front-beta',
|
|
16
|
-
'@thatopen/fragments': '@thatopen-platform/fragments-beta',
|
|
17
|
-
};
|
|
18
|
-
} catch {
|
|
19
|
-
return {};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default defineConfig({
|
|
24
|
-
resolve: {
|
|
25
|
-
alias: getBetaAliases(),
|
|
26
|
-
},
|
|
27
|
-
build: {
|
|
28
|
-
lib: {
|
|
29
|
-
entry: resolve(__dirname, 'src/main.ts'),
|
|
30
|
-
name: 'ThatOpenComponent',
|
|
31
|
-
formats: ['iife'],
|
|
32
|
-
fileName: () => 'bundle.js',
|
|
33
|
-
},
|
|
34
|
-
outDir: 'dist',
|
|
35
|
-
rollupOptions: {
|
|
36
|
-
// Only @thatopen/services is externalized — the execution wrapper
|
|
37
|
-
// provides it at runtime via require('@thatopen/services'). Every
|
|
38
|
-
// other dependency (including @thatopen/components, three, web-ifc,
|
|
39
|
-
// or any npm package you install) must be bundled into bundle.js.
|
|
40
|
-
external: ['@thatopen/services'],
|
|
41
|
-
output: {
|
|
42
|
-
footer: 'var main = ThatOpenComponent.main;',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
});
|
|
1
|
+
// Production build config — builds dist/bundle.js as IIFE.
|
|
2
|
+
// For local development, use: npm run dev (runs thatopen serve with esbuild).
|
|
3
|
+
// Do NOT run "vite" or "vite build --watch" directly for dev.
|
|
4
|
+
import { defineConfig } from 'vite';
|
|
5
|
+
import { resolve } from 'path';
|
|
6
|
+
import { existsSync, readFileSync } from 'fs';
|
|
7
|
+
|
|
8
|
+
function getBetaAliases() {
|
|
9
|
+
if (!existsSync('.thatopen')) return {};
|
|
10
|
+
try {
|
|
11
|
+
const config = JSON.parse(readFileSync('.thatopen', 'utf-8'));
|
|
12
|
+
if (!config.beta) return {};
|
|
13
|
+
return {
|
|
14
|
+
'@thatopen/components': '@thatopen-platform/components-beta',
|
|
15
|
+
'@thatopen/components-front': '@thatopen-platform/components-front-beta',
|
|
16
|
+
'@thatopen/fragments': '@thatopen-platform/fragments-beta',
|
|
17
|
+
};
|
|
18
|
+
} catch {
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default defineConfig({
|
|
24
|
+
resolve: {
|
|
25
|
+
alias: getBetaAliases(),
|
|
26
|
+
},
|
|
27
|
+
build: {
|
|
28
|
+
lib: {
|
|
29
|
+
entry: resolve(__dirname, 'src/main.ts'),
|
|
30
|
+
name: 'ThatOpenComponent',
|
|
31
|
+
formats: ['iife'],
|
|
32
|
+
fileName: () => 'bundle.js',
|
|
33
|
+
},
|
|
34
|
+
outDir: 'dist',
|
|
35
|
+
rollupOptions: {
|
|
36
|
+
// Only @thatopen/services is externalized — the execution wrapper
|
|
37
|
+
// provides it at runtime via require('@thatopen/services'). Every
|
|
38
|
+
// other dependency (including @thatopen/components, three, web-ifc,
|
|
39
|
+
// or any npm package you install) must be bundled into bundle.js.
|
|
40
|
+
external: ['@thatopen/services'],
|
|
41
|
+
output: {
|
|
42
|
+
footer: 'var main = ThatOpenComponent.main;',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# That Open Platform — Agent Guide
|
|
2
|
-
|
|
3
|
-
Read these two files before doing anything else:
|
|
4
|
-
|
|
5
|
-
1. `node_modules/@thatopen/services/resources/AGENTS.md` — rules, hard constraints, and the full navigation table for the That Open Platform. Always current for the installed library version.
|
|
6
|
-
2. `README.md` (this folder) — what this specific project is, its commands, architecture, and patterns.
|
|
7
|
-
|
|
8
|
-
If `node_modules/` doesn't exist yet, run `npm install` first or ask the user to do it.
|
|
1
|
+
# That Open Platform — Agent Guide
|
|
2
|
+
|
|
3
|
+
Read these two files before doing anything else:
|
|
4
|
+
|
|
5
|
+
1. `node_modules/@thatopen/services/resources/AGENTS.md` — rules, hard constraints, and the full navigation table for the That Open Platform. Always current for the installed library version.
|
|
6
|
+
2. `README.md` (this folder) — what this specific project is, its commands, architecture, and patterns.
|
|
7
|
+
|
|
8
|
+
If `node_modules/` doesn't exist yet, run `npm install` first or ask the user to do it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
See [AGENTS.md](./AGENTS.md).
|
|
1
|
+
See [AGENTS.md](./AGENTS.md).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
node_modules
|
|
2
|
-
dist
|
|
3
|
-
*.zip
|
|
4
|
-
.thatopen
|
|
5
|
-
.npmrc
|
|
1
|
+
node_modules
|
|
2
|
+
dist
|
|
3
|
+
*.zip
|
|
4
|
+
.thatopen
|
|
5
|
+
.npmrc
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
ACCESS_TOKEN=your-access-token-here
|
|
2
|
-
API_URL=https://api.thatopen.com
|
|
3
|
-
PROJECT_ID=your-project-id-here
|
|
4
|
-
# Required only for permissions.ts — obtain from DevTools → Network → any /api request → Authorization header (without "Bearer ")
|
|
5
|
-
JWT=
|
|
6
|
-
# Required only for execution.ts — obtain from listComponents() or the platform dashboard
|
|
7
|
-
COMPONENT_ID=
|
|
1
|
+
ACCESS_TOKEN=your-access-token-here
|
|
2
|
+
API_URL=https://api.thatopen.com
|
|
3
|
+
PROJECT_ID=your-project-id-here
|
|
4
|
+
# Required only for permissions.ts — obtain from DevTools → Network → any /api request → Authorization header (without "Bearer ")
|
|
5
|
+
JWT=
|
|
6
|
+
# Required only for execution.ts — obtain from listComponents() or the platform dashboard
|
|
7
|
+
COMPONENT_ID=
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
// description: "App lifecycle — list, get with versions, create, download bundle, and archive."
|
|
2
|
-
import { config } from 'dotenv';
|
|
3
|
-
import { resolve } from 'path';
|
|
4
|
-
import { EngineServicesClient } from '../client';
|
|
5
|
-
|
|
6
|
-
config({ path: resolve(__dirname, '.env') });
|
|
7
|
-
|
|
8
|
-
const ACCESS_TOKEN = process.env.ACCESS_TOKEN;
|
|
9
|
-
const API_URL = process.env.API_URL;
|
|
10
|
-
const PROJECT_ID = process.env.PROJECT_ID;
|
|
11
|
-
|
|
12
|
-
if (!ACCESS_TOKEN || !API_URL) {
|
|
13
|
-
throw new Error('ACCESS_TOKEN and API_URL are required in src/core/examples/.env');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async function main() {
|
|
17
|
-
const client = new EngineServicesClient(ACCESS_TOKEN!, API_URL!);
|
|
18
|
-
|
|
19
|
-
// --- List ---
|
|
20
|
-
const apps = await client.listApps();
|
|
21
|
-
console.log(`\nFound ${apps.length} app(s):`);
|
|
22
|
-
for (const app of apps) {
|
|
23
|
-
console.log(` [${app._id}] ${app.name}`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// --- Get ---
|
|
27
|
-
if (apps.length > 0) {
|
|
28
|
-
const detail = await client.listApps({ ShowVersions: true });
|
|
29
|
-
console.log('\nFirst app detail (with versions):');
|
|
30
|
-
console.log(JSON.stringify(detail[0], null, 2));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (!PROJECT_ID) {
|
|
34
|
-
console.log('\nSkipping create/download/archive — set PROJECT_ID in .env to run the full cycle.');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// --- Create ---
|
|
39
|
-
// The file must be a valid ZIP produced by the thatopen CLI toolchain (`thatopen publish`).
|
|
40
|
-
// Uploading an invalid or empty ZIP causes the server to close the connection — use a real built app ZIP here.
|
|
41
|
-
// appProps is optional; omitting it uses platform defaults.
|
|
42
|
-
const bundle = new Blob([''], { type: 'application/zip' });
|
|
43
|
-
const appName = `__example-test__-${Date.now()}`;
|
|
44
|
-
const created = await client.createApp({
|
|
45
|
-
file: bundle,
|
|
46
|
-
name: appName,
|
|
47
|
-
versionTag: 'v1',
|
|
48
|
-
projectId: PROJECT_ID,
|
|
49
|
-
});
|
|
50
|
-
console.log(`\nCreated app: [${created.item._id}] ${created.item.name}`);
|
|
51
|
-
|
|
52
|
-
const appId = created.item._id;
|
|
53
|
-
|
|
54
|
-
// --- Download bundle ---
|
|
55
|
-
// downloadAppBundle extracts only the JS bundle from the ZIP — not the full archive.
|
|
56
|
-
const bundleResponse = await client.downloadAppBundle(appId);
|
|
57
|
-
const bundleText = await bundleResponse.text();
|
|
58
|
-
console.log(`\nDownloaded bundle (latest): ${bundleText.slice(0, 80)}...`);
|
|
59
|
-
|
|
60
|
-
// --- Archive ---
|
|
61
|
-
// archiveApp is a soft-delete. Unlike files and components, there is no recoverApp method —
|
|
62
|
-
// archived apps can only be managed via the platform UI.
|
|
63
|
-
await client.archiveApp(appId);
|
|
64
|
-
console.log(`\nArchived app [${appId}] — account is clean.`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
main().catch(console.error);
|
|
1
|
+
// description: "App lifecycle — list, get with versions, create, download bundle, and archive."
|
|
2
|
+
import { config } from 'dotenv';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
import { EngineServicesClient } from '../client';
|
|
5
|
+
|
|
6
|
+
config({ path: resolve(__dirname, '.env') });
|
|
7
|
+
|
|
8
|
+
const ACCESS_TOKEN = process.env.ACCESS_TOKEN;
|
|
9
|
+
const API_URL = process.env.API_URL;
|
|
10
|
+
const PROJECT_ID = process.env.PROJECT_ID;
|
|
11
|
+
|
|
12
|
+
if (!ACCESS_TOKEN || !API_URL) {
|
|
13
|
+
throw new Error('ACCESS_TOKEN and API_URL are required in src/core/examples/.env');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function main() {
|
|
17
|
+
const client = new EngineServicesClient(ACCESS_TOKEN!, API_URL!);
|
|
18
|
+
|
|
19
|
+
// --- List ---
|
|
20
|
+
const apps = await client.listApps();
|
|
21
|
+
console.log(`\nFound ${apps.length} app(s):`);
|
|
22
|
+
for (const app of apps) {
|
|
23
|
+
console.log(` [${app._id}] ${app.name}`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// --- Get ---
|
|
27
|
+
if (apps.length > 0) {
|
|
28
|
+
const detail = await client.listApps({ ShowVersions: true });
|
|
29
|
+
console.log('\nFirst app detail (with versions):');
|
|
30
|
+
console.log(JSON.stringify(detail[0], null, 2));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!PROJECT_ID) {
|
|
34
|
+
console.log('\nSkipping create/download/archive — set PROJECT_ID in .env to run the full cycle.');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// --- Create ---
|
|
39
|
+
// The file must be a valid ZIP produced by the thatopen CLI toolchain (`thatopen publish`).
|
|
40
|
+
// Uploading an invalid or empty ZIP causes the server to close the connection — use a real built app ZIP here.
|
|
41
|
+
// appProps is optional; omitting it uses platform defaults.
|
|
42
|
+
const bundle = new Blob([''], { type: 'application/zip' });
|
|
43
|
+
const appName = `__example-test__-${Date.now()}`;
|
|
44
|
+
const created = await client.createApp({
|
|
45
|
+
file: bundle,
|
|
46
|
+
name: appName,
|
|
47
|
+
versionTag: 'v1',
|
|
48
|
+
projectId: PROJECT_ID,
|
|
49
|
+
});
|
|
50
|
+
console.log(`\nCreated app: [${created.item._id}] ${created.item.name}`);
|
|
51
|
+
|
|
52
|
+
const appId = created.item._id;
|
|
53
|
+
|
|
54
|
+
// --- Download bundle ---
|
|
55
|
+
// downloadAppBundle extracts only the JS bundle from the ZIP — not the full archive.
|
|
56
|
+
const bundleResponse = await client.downloadAppBundle(appId);
|
|
57
|
+
const bundleText = await bundleResponse.text();
|
|
58
|
+
console.log(`\nDownloaded bundle (latest): ${bundleText.slice(0, 80)}...`);
|
|
59
|
+
|
|
60
|
+
// --- Archive ---
|
|
61
|
+
// archiveApp is a soft-delete. Unlike files and components, there is no recoverApp method —
|
|
62
|
+
// archived apps can only be managed via the platform UI.
|
|
63
|
+
await client.archiveApp(appId);
|
|
64
|
+
console.log(`\nArchived app [${appId}] — account is clean.`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
main().catch(console.error);
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
// description: "Batch reads — sign many hidden files, list versions and metadata for many files, and resolve many folders in one request each."
|
|
2
|
-
import { config } from 'dotenv';
|
|
3
|
-
import { resolve } from 'path';
|
|
4
|
-
import { EngineServicesClient } from '../client';
|
|
5
|
-
|
|
6
|
-
config({ path: resolve(__dirname, '.env') });
|
|
7
|
-
|
|
8
|
-
const ACCESS_TOKEN = process.env.ACCESS_TOKEN;
|
|
9
|
-
const API_URL = process.env.API_URL;
|
|
10
|
-
const PROJECT_ID = process.env.PROJECT_ID;
|
|
11
|
-
|
|
12
|
-
if (!ACCESS_TOKEN || !API_URL) {
|
|
13
|
-
throw new Error('ACCESS_TOKEN and API_URL are required in src/core/examples/.env');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async function main() {
|
|
17
|
-
const client = new EngineServicesClient(ACCESS_TOKEN!, API_URL!);
|
|
18
|
-
|
|
19
|
-
if (!PROJECT_ID) {
|
|
20
|
-
console.log('Set PROJECT_ID in .env to run this example.');
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const files = await client.listFiles({ projectId: PROJECT_ID });
|
|
25
|
-
if (!files.length) {
|
|
26
|
-
console.log('No files in this project — nothing to batch.');
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const fileIds = files.map((file) => String(file._id));
|
|
30
|
-
|
|
31
|
-
// --- Versions for a whole page of files ---
|
|
32
|
-
// One request instead of one per file. Entries come back in request order,
|
|
33
|
-
// and a file the token cannot read carries an `error` instead of `versions`.
|
|
34
|
-
const versionEntries = await client.listVersionsBatch(fileIds);
|
|
35
|
-
console.log('\nVersions per file:');
|
|
36
|
-
for (const entry of versionEntries) {
|
|
37
|
-
if (entry.error) {
|
|
38
|
-
console.log(` ${entry.itemId} → ${entry.error.status} ${entry.error.message}`);
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
console.log(` ${entry.itemId} → ${entry.versions?.length ?? 0} version(s)`);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// --- Metadata for specific (file, version) pairs ---
|
|
45
|
-
// The versions above already carry their metadata, so this is only needed
|
|
46
|
-
// when the version list itself is not wanted.
|
|
47
|
-
const pairs = versionEntries
|
|
48
|
-
.filter((entry) => entry.versions?.length)
|
|
49
|
-
.map((entry) => ({
|
|
50
|
-
itemId: entry.itemId,
|
|
51
|
-
versionTag: entry.versions![0].tag,
|
|
52
|
-
}));
|
|
53
|
-
const metadataEntries = await client.getFileVersionMetadataBatch(pairs);
|
|
54
|
-
console.log('\nLatest-version metadata:');
|
|
55
|
-
for (const entry of metadataEntries) {
|
|
56
|
-
console.log(
|
|
57
|
-
` ${entry.itemId}@${entry.versionTag} → ${JSON.stringify(entry.metadata ?? entry.error)}`,
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// --- Folders by id ---
|
|
62
|
-
// Use listFolders({ projectId }) for the whole tree; this is for a known set
|
|
63
|
-
// of ids, such as the parents behind a breadcrumb.
|
|
64
|
-
const folderIds = [
|
|
65
|
-
...new Set(files.map((file) => file.folderId).filter(Boolean).map(String)),
|
|
66
|
-
];
|
|
67
|
-
if (folderIds.length) {
|
|
68
|
-
const folderEntries = await client.getFoldersBatch(folderIds);
|
|
69
|
-
console.log('\nFolders:');
|
|
70
|
-
for (const entry of folderEntries) {
|
|
71
|
-
console.log(` ${entry.folderId} → ${entry.folder?.name ?? entry.error?.message}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// --- Signed URLs for many hidden files ---
|
|
76
|
-
// This is the call tile-based viewers (splats, point clouds) should use.
|
|
77
|
-
// Minting one URL per tile as the camera moves is what pushes a single
|
|
78
|
-
// session past the rate limit; one request covers up to 100 tiles, and
|
|
79
|
-
// longer lists are split into several requests automatically.
|
|
80
|
-
const hiddenFiles = await client.getHiddenFilesByParent(fileIds[0]);
|
|
81
|
-
if (!hiddenFiles.length) {
|
|
82
|
-
console.log('\nNo hidden files on the first file — skipping signed URLs.');
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const signedEntries = await client.getHiddenFileSignedUrlsBatch(
|
|
86
|
-
hiddenFiles.map((hiddenFile) => String(hiddenFile._id)),
|
|
87
|
-
3600,
|
|
88
|
-
);
|
|
89
|
-
console.log('\nSigned hidden file URLs:');
|
|
90
|
-
for (const entry of signedEntries) {
|
|
91
|
-
if (entry.error) {
|
|
92
|
-
console.log(` ${entry.hiddenFileId} → ${entry.error.status} ${entry.error.message}`);
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
console.log(` ${entry.hiddenFileId} → expires ${entry.expiresAt}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
main().catch(console.error);
|
|
1
|
+
// description: "Batch reads — sign many hidden files, list versions and metadata for many files, and resolve many folders in one request each."
|
|
2
|
+
import { config } from 'dotenv';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
import { EngineServicesClient } from '../client';
|
|
5
|
+
|
|
6
|
+
config({ path: resolve(__dirname, '.env') });
|
|
7
|
+
|
|
8
|
+
const ACCESS_TOKEN = process.env.ACCESS_TOKEN;
|
|
9
|
+
const API_URL = process.env.API_URL;
|
|
10
|
+
const PROJECT_ID = process.env.PROJECT_ID;
|
|
11
|
+
|
|
12
|
+
if (!ACCESS_TOKEN || !API_URL) {
|
|
13
|
+
throw new Error('ACCESS_TOKEN and API_URL are required in src/core/examples/.env');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function main() {
|
|
17
|
+
const client = new EngineServicesClient(ACCESS_TOKEN!, API_URL!);
|
|
18
|
+
|
|
19
|
+
if (!PROJECT_ID) {
|
|
20
|
+
console.log('Set PROJECT_ID in .env to run this example.');
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const files = await client.listFiles({ projectId: PROJECT_ID });
|
|
25
|
+
if (!files.length) {
|
|
26
|
+
console.log('No files in this project — nothing to batch.');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const fileIds = files.map((file) => String(file._id));
|
|
30
|
+
|
|
31
|
+
// --- Versions for a whole page of files ---
|
|
32
|
+
// One request instead of one per file. Entries come back in request order,
|
|
33
|
+
// and a file the token cannot read carries an `error` instead of `versions`.
|
|
34
|
+
const versionEntries = await client.listVersionsBatch(fileIds);
|
|
35
|
+
console.log('\nVersions per file:');
|
|
36
|
+
for (const entry of versionEntries) {
|
|
37
|
+
if (entry.error) {
|
|
38
|
+
console.log(` ${entry.itemId} → ${entry.error.status} ${entry.error.message}`);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
console.log(` ${entry.itemId} → ${entry.versions?.length ?? 0} version(s)`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// --- Metadata for specific (file, version) pairs ---
|
|
45
|
+
// The versions above already carry their metadata, so this is only needed
|
|
46
|
+
// when the version list itself is not wanted.
|
|
47
|
+
const pairs = versionEntries
|
|
48
|
+
.filter((entry) => entry.versions?.length)
|
|
49
|
+
.map((entry) => ({
|
|
50
|
+
itemId: entry.itemId,
|
|
51
|
+
versionTag: entry.versions![0].tag,
|
|
52
|
+
}));
|
|
53
|
+
const metadataEntries = await client.getFileVersionMetadataBatch(pairs);
|
|
54
|
+
console.log('\nLatest-version metadata:');
|
|
55
|
+
for (const entry of metadataEntries) {
|
|
56
|
+
console.log(
|
|
57
|
+
` ${entry.itemId}@${entry.versionTag} → ${JSON.stringify(entry.metadata ?? entry.error)}`,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// --- Folders by id ---
|
|
62
|
+
// Use listFolders({ projectId }) for the whole tree; this is for a known set
|
|
63
|
+
// of ids, such as the parents behind a breadcrumb.
|
|
64
|
+
const folderIds = [
|
|
65
|
+
...new Set(files.map((file) => file.folderId).filter(Boolean).map(String)),
|
|
66
|
+
];
|
|
67
|
+
if (folderIds.length) {
|
|
68
|
+
const folderEntries = await client.getFoldersBatch(folderIds);
|
|
69
|
+
console.log('\nFolders:');
|
|
70
|
+
for (const entry of folderEntries) {
|
|
71
|
+
console.log(` ${entry.folderId} → ${entry.folder?.name ?? entry.error?.message}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// --- Signed URLs for many hidden files ---
|
|
76
|
+
// This is the call tile-based viewers (splats, point clouds) should use.
|
|
77
|
+
// Minting one URL per tile as the camera moves is what pushes a single
|
|
78
|
+
// session past the rate limit; one request covers up to 100 tiles, and
|
|
79
|
+
// longer lists are split into several requests automatically.
|
|
80
|
+
const hiddenFiles = await client.getHiddenFilesByParent(fileIds[0]);
|
|
81
|
+
if (!hiddenFiles.length) {
|
|
82
|
+
console.log('\nNo hidden files on the first file — skipping signed URLs.');
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const signedEntries = await client.getHiddenFileSignedUrlsBatch(
|
|
86
|
+
hiddenFiles.map((hiddenFile) => String(hiddenFile._id)),
|
|
87
|
+
3600,
|
|
88
|
+
);
|
|
89
|
+
console.log('\nSigned hidden file URLs:');
|
|
90
|
+
for (const entry of signedEntries) {
|
|
91
|
+
if (entry.error) {
|
|
92
|
+
console.log(` ${entry.hiddenFileId} → ${entry.error.status} ${entry.error.message}`);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
console.log(` ${entry.hiddenFileId} → expires ${entry.expiresAt}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
main().catch(console.error);
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
// description: "Platform channel (app-side, runs inside the platform iframe) — a collaboration room with presence, and typed commands from external tools (MCP, CLI,
|
|
2
|
-
import { PlatformClient } from '../platform-client';
|
|
3
|
-
|
|
4
|
-
// Unlike the other examples this is not a Node script: `client.channel` only
|
|
5
|
-
// exists inside an app running in the platform's iframe, and throws anywhere
|
|
6
|
-
// else. Copy `setupChannel` into your app.
|
|
7
|
-
|
|
8
|
-
// The contract with an external tool, written once. Each command names its
|
|
9
|
-
// payload and, if the caller waits for an answer, its reply. Use `type`, and
|
|
10
|
-
// list only what the app handles.
|
|
11
|
-
type McpCommands = {
|
|
12
|
-
'select-by-category': {
|
|
13
|
-
payload: { category: string };
|
|
14
|
-
reply: { count: number };
|
|
15
|
-
};
|
|
16
|
-
'get-loaded-models': { payload: undefined; reply: { models: string[] } };
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// What tabs of this app send each other. No replies: these are events.
|
|
20
|
-
type CollabEvents = {
|
|
21
|
-
'cursor-position': { userName: string; x: number; y: number; z: number };
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export async function setupChannel(client: PlatformClient) {
|
|
25
|
-
// Commands from this account's MCP server only. `external()` with no kind
|
|
26
|
-
// hears every kind of external tool (MCP, CLI,
|
|
27
|
-
const mcp = client.channel.external<McpCommands>('mcp');
|
|
28
|
-
|
|
29
|
-
// What you return is sent back to whoever asked. Throw and it gets an error
|
|
30
|
-
// instead of waiting for a timeout. A command that was sent without waiting
|
|
31
|
-
// for an answer (a notification) has its return value ignored.
|
|
32
|
-
mcp.on('select-by-category', async ({ category }) => {
|
|
33
|
-
const count = await selectByCategory(category);
|
|
34
|
-
return { count };
|
|
35
|
-
});
|
|
36
|
-
mcp.on('get-loaded-models', () => ({ models: listModels() }));
|
|
37
|
-
|
|
38
|
-
// Joining is opt-in. Nothing reaches this app until it joins, so wire it to
|
|
39
|
-
// a button, or join at startup if the app should always listen.
|
|
40
|
-
await mcp.join();
|
|
41
|
-
|
|
42
|
-
// Collaboration: other users' tabs of this same app, across accounts.
|
|
43
|
-
const collab = client.channel.collab<CollabEvents>();
|
|
44
|
-
collab.on('cursor-position', (cursor, { from }) => moveAvatar(from, cursor));
|
|
45
|
-
// `from` identifies a tab, so a departure removes exactly its avatar.
|
|
46
|
-
collab.onPeerLeft(({ from }) => removeAvatar(from));
|
|
47
|
-
await collab.join();
|
|
48
|
-
|
|
49
|
-
// Sending does nothing until the platform has confirmed the join.
|
|
50
|
-
collab.send('cursor-position', { userName: 'Ada', x: 0, y: 0, z: 0 });
|
|
51
|
-
|
|
52
|
-
// Being in a room says this tab is listening, not that anyone is there.
|
|
53
|
-
// `peers` is who the platform reports on the other end right now.
|
|
54
|
-
mcp.onChange(() => {
|
|
55
|
-
console.log(`MCP: ${mcp.joined ? 'listening' : 'off'}, ${mcp.peers.length} connected`);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return { mcp, collab };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Stand-ins for the app's own logic.
|
|
62
|
-
declare function selectByCategory(category: string): Promise<number>;
|
|
63
|
-
declare function listModels(): string[];
|
|
64
|
-
declare function moveAvatar(id: string, cursor: unknown): void;
|
|
65
|
-
declare function removeAvatar(id: string): void;
|
|
1
|
+
// description: "Platform channel (app-side, runs inside the platform iframe) — a collaboration room with presence, and typed commands from external tools (MCP, CLI, authoring-tool plugins, etc) with automatic replies."
|
|
2
|
+
import { PlatformClient } from '../platform-client';
|
|
3
|
+
|
|
4
|
+
// Unlike the other examples this is not a Node script: `client.channel` only
|
|
5
|
+
// exists inside an app running in the platform's iframe, and throws anywhere
|
|
6
|
+
// else. Copy `setupChannel` into your app.
|
|
7
|
+
|
|
8
|
+
// The contract with an external tool, written once. Each command names its
|
|
9
|
+
// payload and, if the caller waits for an answer, its reply. Use `type`, and
|
|
10
|
+
// list only what the app handles.
|
|
11
|
+
type McpCommands = {
|
|
12
|
+
'select-by-category': {
|
|
13
|
+
payload: { category: string };
|
|
14
|
+
reply: { count: number };
|
|
15
|
+
};
|
|
16
|
+
'get-loaded-models': { payload: undefined; reply: { models: string[] } };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// What tabs of this app send each other. No replies: these are events.
|
|
20
|
+
type CollabEvents = {
|
|
21
|
+
'cursor-position': { userName: string; x: number; y: number; z: number };
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export async function setupChannel(client: PlatformClient) {
|
|
25
|
+
// Commands from this account's MCP server only. `external()` with no kind
|
|
26
|
+
// hears every kind of external tool (MCP, CLI, authoring-tool plugin, etc...).
|
|
27
|
+
const mcp = client.channel.external<McpCommands>('mcp');
|
|
28
|
+
|
|
29
|
+
// What you return is sent back to whoever asked. Throw and it gets an error
|
|
30
|
+
// instead of waiting for a timeout. A command that was sent without waiting
|
|
31
|
+
// for an answer (a notification) has its return value ignored.
|
|
32
|
+
mcp.on('select-by-category', async ({ category }) => {
|
|
33
|
+
const count = await selectByCategory(category);
|
|
34
|
+
return { count };
|
|
35
|
+
});
|
|
36
|
+
mcp.on('get-loaded-models', () => ({ models: listModels() }));
|
|
37
|
+
|
|
38
|
+
// Joining is opt-in. Nothing reaches this app until it joins, so wire it to
|
|
39
|
+
// a button, or join at startup if the app should always listen.
|
|
40
|
+
await mcp.join();
|
|
41
|
+
|
|
42
|
+
// Collaboration: other users' tabs of this same app, across accounts.
|
|
43
|
+
const collab = client.channel.collab<CollabEvents>();
|
|
44
|
+
collab.on('cursor-position', (cursor, { from }) => moveAvatar(from, cursor));
|
|
45
|
+
// `from` identifies a tab, so a departure removes exactly its avatar.
|
|
46
|
+
collab.onPeerLeft(({ from }) => removeAvatar(from));
|
|
47
|
+
await collab.join();
|
|
48
|
+
|
|
49
|
+
// Sending does nothing until the platform has confirmed the join.
|
|
50
|
+
collab.send('cursor-position', { userName: 'Ada', x: 0, y: 0, z: 0 });
|
|
51
|
+
|
|
52
|
+
// Being in a room says this tab is listening, not that anyone is there.
|
|
53
|
+
// `peers` is who the platform reports on the other end right now.
|
|
54
|
+
mcp.onChange(() => {
|
|
55
|
+
console.log(`MCP: ${mcp.joined ? 'listening' : 'off'}, ${mcp.peers.length} connected`);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return { mcp, collab };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Stand-ins for the app's own logic.
|
|
62
|
+
declare function selectByCategory(category: string): Promise<number>;
|
|
63
|
+
declare function listModels(): string[];
|
|
64
|
+
declare function moveAvatar(id: string, cursor: unknown): void;
|
|
65
|
+
declare function removeAvatar(id: string): void;
|