@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,62 @@
1
+ // ThatOpen App — Default Template
2
+ //
3
+ // This is a minimal app that runs inside the That Open Platform.
4
+ // It renders into the #that-open-app element in index.html.
5
+ //
6
+ // Platform context (client.context):
7
+ // appId — this app's unique identifier
8
+ // projectId — the project this app belongs to
9
+ // accessToken — Auth0 JWT for API calls
10
+ // apiUrl — base URL for the That Open API
11
+ //
12
+ // To add BIM capabilities (3D viewer, model loading), install:
13
+ // npm install @thatopen/components @thatopen/ui three thatopen-services
14
+ // Then see the "bim" template for the full pattern.
15
+
16
+ import { PlatformClient } from "thatopen-services";
17
+ import type { ThatOpenContext, ProjectData } from "thatopen-services";
18
+
19
+ declare global {
20
+ interface Window {
21
+ __THATOPEN_CONTEXT__?: ThatOpenContext;
22
+ }
23
+ }
24
+
25
+ async function main() {
26
+ const app = document.getElementById('that-open-app')!;
27
+
28
+ // ─── Engine Services Client ───────────────────────────────────
29
+ // Reads the auth context from window.__THATOPEN_CONTEXT__ (injected
30
+ // by the platform) and creates a client with Bearer auth.
31
+ const client = PlatformClient.fromPlatformContext();
32
+
33
+ // ─── Project Data ───────────────────────────────────────────────
34
+ // Fetches project data (users, roles, files, folders) in one call.
35
+ let projectData: ProjectData | null = null;
36
+ if (client.context.projectId) {
37
+ try {
38
+ projectData = await client.getProjectData(client.context.projectId);
39
+ } catch (err) {
40
+ console.warn("Could not fetch project data:", err);
41
+ }
42
+ }
43
+
44
+ const projectTitle = projectData?.project.title || 'N/A';
45
+ const userName = projectData?.currentUser?.user.fullName || 'N/A';
46
+ const membersCount = projectData?.users.length ?? 0;
47
+ const filesCount = projectData?.files.length ?? 0;
48
+
49
+ // Render the app. Replace this with your own UI.
50
+ app.innerHTML = `
51
+ <div style="padding: 32px; font-family: system-ui, sans-serif; max-width: 600px; margin: 0 auto;">
52
+ <h1 style="color: #6528e0; margin-bottom: 16px;">My ThatOpen App</h1>
53
+ <p style="margin-bottom: 8px;"><strong>Project:</strong> ${projectTitle}</p>
54
+ <p style="margin-bottom: 8px;"><strong>User:</strong> ${userName}</p>
55
+ <p style="margin-bottom: 8px;"><strong>Members:</strong> ${membersCount}</p>
56
+ <p style="margin-bottom: 8px;"><strong>Files:</strong> ${filesCount}</p>
57
+ <p style="color: #888; margin-top: 24px;">Edit <code>src/main.ts</code> to start building your app.</p>
58
+ </div>
59
+ `;
60
+ }
61
+
62
+ main().catch(console.error);
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ dist
3
+ *.zip
4
+ .thatopen
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>ThatOpen App</title>
7
+ <style>
8
+ *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
9
+ html, body { width: 100%; height: 100%; overflow: hidden; font-family: system-ui, -apple-system, sans-serif; }
10
+ #that-open-app { width: 100%; height: 100%; }
11
+ </style>
12
+ </head>
13
+ <body>
14
+ <div id="that-open-app"></div>
15
+ <script>
16
+ // Simulates the context that the platform provides in production.
17
+ // When running inside the platform iframe, these values come from query params.
18
+ window.__THATOPEN_CONTEXT__ = {
19
+ appId: 'local-dev',
20
+ projectId: 'local-project',
21
+ accessToken: '',
22
+ apiUrl: 'http://localhost:3000',
23
+ };
24
+ </script>
25
+ <script type="module" src="/src/main.ts"></script>
26
+ </body>
27
+ </html>
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "skipLibCheck": true,
7
+ "esModuleInterop": true,
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "noEmit": true,
13
+ "strict": true
14
+ },
15
+ "include": ["src"]
16
+ }
@@ -0,0 +1,23 @@
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
+
7
+ export default defineConfig({
8
+ build: {
9
+ lib: {
10
+ entry: resolve(__dirname, 'src/main.ts'),
11
+ name: 'ThatOpenApp',
12
+ formats: ['iife'],
13
+ fileName: () => 'bundle.js',
14
+ },
15
+ outDir: 'dist',
16
+ sourcemap: true,
17
+ rollupOptions: {
18
+ output: {
19
+ entryFileNames: 'bundle.js',
20
+ },
21
+ },
22
+ },
23
+ });
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "lib": ["ES2020"],
6
+ "skipLibCheck": true,
7
+ "esModuleInterop": true,
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "noEmit": true,
13
+ "strict": true
14
+ },
15
+ "include": ["src"]
16
+ }
@@ -0,0 +1,27 @@
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
+
7
+ export default defineConfig({
8
+ build: {
9
+ lib: {
10
+ entry: resolve(__dirname, 'src/main.ts'),
11
+ name: 'ThatOpenComponent',
12
+ formats: ['iife'],
13
+ fileName: () => 'bundle.js',
14
+ },
15
+ outDir: 'dist',
16
+ rollupOptions: {
17
+ // Only thatopen-services is externalized — the execution wrapper
18
+ // provides it at runtime via require('thatopen-services'). Every
19
+ // other dependency (including @thatopen/components, three, web-ifc,
20
+ // or any npm package you install) must be bundled into bundle.js.
21
+ external: ['thatopen-services'],
22
+ output: {
23
+ footer: 'var main = ThatOpenComponent.main;',
24
+ },
25
+ },
26
+ },
27
+ });
@@ -0,0 +1,53 @@
1
+ # ThatOpen Platform API Test Suite (App)
2
+
3
+ This is a test app that exercises every EngineServicesClient endpoint to verify the
4
+ That Open Platform is working correctly. It runs in the browser inside the platform's
5
+ iframe and renders a test results dashboard.
6
+
7
+ ## How this app works
8
+
9
+ - **Entry point**: `src/main.ts` — an IIFE loaded by the platform.
10
+ - **Build output**: `dist/bundle.js` — built by Vite.
11
+ - **Platform context**: The platform injects `window.__THATOPEN_CONTEXT__` with
12
+ `appId`, `projectId`, `accessToken`, and `apiUrl`.
13
+ - **Mount point**: Renders into `#that-open-app` in `index.html`.
14
+
15
+ ## What it tests
16
+
17
+ The test suite covers every API group in EngineServicesClient:
18
+
19
+ | Group | Endpoints tested |
20
+ |-------|-----------------|
21
+ | **Context & Auth** | Validates all context fields are present |
22
+ | **Projects** | getProject, getProjectData, checkPermission |
23
+ | **Folders** | createFolder, getFolder, listFolders, updateFolder, archiveFolder, recoverFolder, downloadFolder |
24
+ | **Files** | createFile, getFile, listFiles, downloadFile, getFileVersionMetadata, updateFileVersionMetadata, deleteFileVersionMetadata, updateFile, archiveFile, recoverFile |
25
+ | **Hidden Files** | createHiddenFile, getHiddenFile, getHiddenFilesByParent, downloadHiddenFile, deleteHiddenFile, deleteHiddenFilesByParent |
26
+ | **Icons** | uploadItemIcon, getItemIcon, removeItemIcon |
27
+ | **General Items** | updateItem, createVersion |
28
+ | **Components** | createComponent, getComponent, listComponents, updateComponent, downloadComponent, downloadComponentBundle, archiveComponent, recoverComponent |
29
+ | **Apps** | createApp, listApps, downloadApp, downloadAppBundle, archiveApp |
30
+ | **Execution** | executeComponent, getExecution, listExecutions, onExecutionProgress, abortExecution |
31
+ | **Built-in** | getBuiltInComponent |
32
+
33
+ ## Running
34
+
35
+ 1. Publish to the platform: `npm run publish`
36
+ 2. Open the app in a project on the platform
37
+ 3. Click **Run All Tests**
38
+ 4. Review the pass/fail results
39
+
40
+ ## Commands
41
+
42
+ ```bash
43
+ npm run dev # Start dev server
44
+ npm run build # Build dist/bundle.js
45
+ npm run login # Authenticate with the platform
46
+ npm run publish # Publish to the platform
47
+ ```
48
+
49
+ ## Cleanup
50
+
51
+ The test suite creates temporary folders, files, components, apps, and hidden files
52
+ during execution. All test resources are archived (soft-deleted) after tests complete.
53
+ The execution tests use the test component created in the Components test group.
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "{{PROJECT_NAME}}",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "thatopen serve",
7
+ "build": "vite build",
8
+ "login": "thatopen login --local",
9
+ "publish": "thatopen publish"
10
+ },
11
+ "dependencies": {
12
+ "@thatopen/components": "~3.4.0",
13
+ "@thatopen/components-front": "~3.4.0",
14
+ "@thatopen/fragments": "~3.4.0",
15
+ "@thatopen/ui": "~3.4.0",
16
+ "@thatopen/ui-obc": "~3.4.0",
17
+ "thatopen-services": "^{{VERSION}}",
18
+ "three": "^0.182.0"
19
+ },
20
+ "devDependencies": {
21
+ "@types/three": "^0.182.0",
22
+ "typescript": "^5.2.0",
23
+ "vite": "^5.2.0"
24
+ }
25
+ }