@thatopen/services 0.0.4 → 0.0.5
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 +24 -263
- package/dist/cli/commands/swap.d.ts +3 -0
- package/dist/cli/lib/beta.d.ts +2 -0
- package/dist/cli/lib/config.d.ts +2 -0
- package/dist/cli.js +85 -126
- package/dist/core/examples/apps.d.ts +1 -0
- package/dist/core/examples/components.d.ts +1 -0
- package/dist/core/examples/execution.d.ts +1 -0
- package/dist/core/examples/file-metadata.d.ts +1 -0
- package/dist/core/examples/files.d.ts +1 -0
- package/dist/core/examples/folders.d.ts +1 -0
- package/dist/core/examples/hidden-files.d.ts +1 -0
- package/dist/core/examples/icons.d.ts +1 -0
- package/dist/core/examples/permissions.d.ts +1 -0
- package/dist/types/items.d.ts +2 -0
- package/docs/builtin/paths.json +54 -0
- package/docs/cli/create.md +28 -0
- package/docs/cli/local-server.md +38 -0
- package/docs/cli/login.md +32 -0
- package/docs/cli/paths.json +30 -0
- package/docs/cli/publish.md +31 -0
- package/docs/cli/run.md +26 -0
- package/docs/cli/serve.md +43 -0
- package/docs/cli/swap.md +30 -0
- package/docs/client/paths.json +38 -0
- package/package.json +8 -10
- package/resources/AGENTS.md +39 -0
- package/src/built-in/AppManager/example.ts +86 -0
- package/src/built-in/CDEManager/example.ts +214 -0
- package/src/built-in/CDEManager/examples/FileEditing/example.ts +226 -0
- package/src/built-in/CDEManager/examples/FileMoves/example.ts +186 -0
- package/src/built-in/CDEManager/examples/FileOperations/example.ts +295 -0
- package/src/built-in/CDEManager/examples/FileTransfers/example.ts +210 -0
- package/src/built-in/CDEManager/examples/FolderManagement/example.ts +230 -0
- package/src/built-in/CDEManager/examples/MetadataSchema/example.ts +230 -0
- package/src/built-in/CDEManager/examples/MetadataViews/example.ts +166 -0
- package/src/built-in/CDEManager/examples/ProjectConfig/example.ts +177 -0
- package/src/built-in/FileList/example.ts +107 -0
- package/src/built-in/TabbedNavigation/example.ts +115 -0
- package/src/built-in/ViewportsManager/example.ts +106 -0
- package/src/cli/templates/{shared/app → app}/vite.config.js +42 -23
- package/src/cli/templates/{shared/cloud → cloud-component}/vite.config.js +46 -27
- package/src/cli/templates/shared/AGENTS.md +8 -30
- package/src/cli/templates/shared/CLAUDE.md +1 -1
- package/AGENTS.md +0 -86
- package/CONTEXT.md +0 -258
- package/dist/built-in/index.d.ts +0 -723
- package/dist/cli/commands/create-tests.d.ts +0 -3
- package/dist/cli/commands/serve-tests.d.ts +0 -3
- package/docs/access-backend-data.md +0 -19
- package/docs/app-architecture.md +0 -94
- package/docs/app-layout.md +0 -139
- package/docs/app-wiring.md +0 -123
- package/docs/bim-components/coding-conventions.md +0 -128
- package/docs/bim-components/element-collections.md +0 -69
- package/docs/bim-components/expose-events.md +0 -84
- package/docs/bim-components/library-examples.md +0 -28
- package/docs/bim-components/observable-collections.md +0 -83
- package/docs/bim-components/overview.md +0 -160
- package/docs/bim-components/per-frame-updates.md +0 -20
- package/docs/bim-components/save-and-restore-state.md +0 -21
- package/docs/bim-components/setup-and-cleanup.md +0 -64
- package/docs/bim-components/type-conventions.md +0 -49
- package/docs/bim-components/user-driven-object-creation.md +0 -56
- package/docs/cli-setup.md +0 -54
- package/docs/cloud-components.md +0 -74
- package/docs/connect-logic-to-ui.md +0 -113
- package/docs/previewing.md +0 -45
- package/docs/publishing.md +0 -35
- package/docs/scaffolding.md +0 -71
- package/docs/ui-components/async-actions.md +0 -18
- package/docs/ui-components/confirmation-dialog.md +0 -39
- package/docs/ui-components/data-table.md +0 -185
- package/docs/ui-components/display-text.md +0 -39
- package/docs/ui-components/inline-form.md +0 -44
- package/docs/ui-components/library-examples.md +0 -24
- package/docs/ui-components/overview.md +0 -194
- package/docs/ui-components/rendering-patterns.md +0 -129
- package/docs/ui-components/sections-layout.md +0 -123
- package/docs/update-grid-elements.md +0 -46
- package/docs/using-colors.md +0 -32
- package/docs/using-icons.md +0 -37
- package/src/cli/templates/bim/src/bim-components/CloudRunner/src/index.ts +0 -1
- package/src/cli/templates/bim/src/bim-components/CloudRunner/src/types.ts +0 -5
- package/src/cli/templates/bim/src/bim-components/index.ts +0 -1
- package/src/cli/templates/bim/src/globals.ts +0 -1
- package/src/cli/templates/bim/src/setups/index.ts +0 -3
- package/src/cli/templates/bim/src/ui-components/app-info-section/index.ts +0 -26
- package/src/cli/templates/bim/src/ui-components/app-info-section/src/index.ts +0 -1
- package/src/cli/templates/bim/src/ui-components/cloud-runner-section/index.ts +0 -37
- package/src/cli/templates/bim/src/ui-components/cloud-runner-section/src/index.ts +0 -1
- package/src/cli/templates/bim/src/ui-components/index.ts +0 -2
- package/src/cli/templates/bim-beta/CONTEXT.md +0 -241
- package/src/cli/templates/bim-beta/package.json +0 -25
- package/src/cli/templates/bim-beta/src/app.ts +0 -16
- package/src/cli/templates/bim-beta/src/bim-components/CloudRunner/index.ts +0 -91
- package/src/cli/templates/bim-beta/src/main.ts +0 -93
- package/src/cli/templates/bim-beta/src/setups/cloud-runner.ts +0 -13
- package/src/cli/templates/bim-beta/src/setups/ui-manager.ts +0 -27
- package/src/cli/templates/bim-beta/src/setups/viewports-manager.ts +0 -22
- package/src/cli/templates/bim-beta/src/ui-components/app-info-section/src/types.ts +0 -15
- package/src/cli/templates/bim-beta/src/ui-components/cloud-runner-section/src/types.ts +0 -14
- package/src/cli/templates/cloud/_thatopen +0 -5
- package/src/cli/templates/cloud/package.json +0 -22
- package/src/cli/templates/cloud-test/CONTEXT.md +0 -56
- package/src/cli/templates/cloud-test/src/main.ts +0 -565
- package/src/cli/templates/default/CONTEXT.md +0 -92
- package/src/cli/templates/default/package.json +0 -18
- package/src/cli/templates/default/src/main.ts +0 -62
- package/src/cli/templates/test/CONTEXT.md +0 -53
- package/src/cli/templates/test/package.json +0 -25
- package/src/cli/templates/test/src/main.ts +0 -955
- /package/src/cli/templates/{bim/CONTEXT.md → app/README.md} +0 -0
- /package/src/cli/templates/{shared/app → app}/index.html +0 -0
- /package/src/cli/templates/{bim → app}/package.json +0 -0
- /package/src/cli/templates/{bim → app}/src/app.ts +0 -0
- /package/src/cli/templates/{bim → app}/src/bim-components/CloudRunner/index.ts +0 -0
- /package/src/cli/templates/{bim-beta → app}/src/bim-components/CloudRunner/src/index.ts +0 -0
- /package/src/cli/templates/{bim-beta → app}/src/bim-components/CloudRunner/src/types.ts +0 -0
- /package/src/cli/templates/{bim-beta → app}/src/bim-components/index.ts +0 -0
- /package/src/cli/templates/{bim-beta → app}/src/globals.ts +0 -0
- /package/src/cli/templates/{bim → app}/src/main.ts +0 -0
- /package/src/cli/templates/{bim → app}/src/setups/cloud-runner.ts +0 -0
- /package/src/cli/templates/{bim-beta → app}/src/setups/index.ts +0 -0
- /package/src/cli/templates/{bim → app}/src/setups/ui-manager.ts +0 -0
- /package/src/cli/templates/{bim → app}/src/setups/viewports-manager.ts +0 -0
- /package/src/cli/templates/{bim-beta → app}/src/ui-components/app-info-section/index.ts +0 -0
- /package/src/cli/templates/{bim-beta → app}/src/ui-components/app-info-section/src/index.ts +0 -0
- /package/src/cli/templates/{bim → app}/src/ui-components/app-info-section/src/types.ts +0 -0
- /package/src/cli/templates/{bim-beta → app}/src/ui-components/cloud-runner-section/index.ts +0 -0
- /package/src/cli/templates/{bim-beta → app}/src/ui-components/cloud-runner-section/src/index.ts +0 -0
- /package/src/cli/templates/{bim → app}/src/ui-components/cloud-runner-section/src/types.ts +0 -0
- /package/src/cli/templates/{bim-beta → app}/src/ui-components/index.ts +0 -0
- /package/src/cli/templates/{shared/app → app}/tsconfig.json +0 -0
- /package/src/cli/templates/{cloud/CONTEXT.md → cloud-component/README.md} +0 -0
- /package/src/cli/templates/{cloud-test → cloud-component}/_thatopen +0 -0
- /package/src/cli/templates/{cloud → cloud-component}/declarations.json +0 -0
- /package/src/cli/templates/{cloud-test → cloud-component}/package.json +0 -0
- /package/src/cli/templates/{cloud → cloud-component}/src/main.ts +0 -0
- /package/src/cli/templates/{shared/cloud → cloud-component}/tsconfig.json +0 -0
|
@@ -1,30 +1,8 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
2. **Check engine components first** — `@thatopen/components` (`OBC`) / `@thatopen/components-front`
|
|
10
|
-
(`OBF`) — before building anything custom.
|
|
11
|
-
3. **Propose a short plan and get the user's OK** before changing files.
|
|
12
|
-
|
|
13
|
-
## Where the full build guides live
|
|
14
|
-
The complete, up-to-date guides ship with the library. Read them from the installed package:
|
|
15
|
-
- `node_modules/@thatopen/services/AGENTS.md` — the router; **start here**
|
|
16
|
-
- `node_modules/@thatopen/services/docs/` — detailed guides (app wiring, layout, connecting logic
|
|
17
|
-
to UI, building BIM/UI components, cloud components, publishing, icons, colors, …)
|
|
18
|
-
- `node_modules/@thatopen/services/CONTEXT.md` — library API reference (`PlatformClient` vs
|
|
19
|
-
`EngineServicesClient`, permissions)
|
|
20
|
-
|
|
21
|
-
## Beta libraries
|
|
22
|
-
If you scaffold **another** app, first ask the user whether they have **beta access** and want the
|
|
23
|
-
latest features/progress. If yes, use `thatopen create <name> -t bim-beta` — it scaffolds on the
|
|
24
|
-
private `@thatopen-platform/*-beta` packages (the line the platform runs). Founding members have
|
|
25
|
-
permanent beta access; the beta packages are private, so the user's beta token must be configured
|
|
26
|
-
for `npm install`.
|
|
27
|
-
|
|
28
|
-
## This project
|
|
29
|
-
- `CONTEXT.md` (this folder) — the context for *this specific* project.
|
|
30
|
-
- `package.json` scripts — `npm run dev` (preview), `npm run login`, `npm run publish`.
|
|
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).
|
package/AGENTS.md
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
# Building on the That Open Platform — Agent Guide
|
|
2
|
-
|
|
3
|
-
You are an AI assistant helping a user build a **BIM app** or **cloud component** on the
|
|
4
|
-
That Open Platform using **`@thatopen/services`** (the `thatopen` CLI + client library).
|
|
5
|
-
|
|
6
|
-
**Read this file first.** It states the rules you must follow, then routes you to the one
|
|
7
|
-
detailed doc for whatever you're doing. Open only the doc you need — don't load everything.
|
|
8
|
-
|
|
9
|
-
> This guide is tool-agnostic: it works with any AI (Claude, Codex, your own). All docs it
|
|
10
|
-
> references ship inside the `@thatopen/services` package under `docs/`.
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## How to work
|
|
15
|
-
|
|
16
|
-
- 🚩 **BEFORE creating anything, ask the user about beta access — this is important.** Ask:
|
|
17
|
-
*"Do you have That Open beta access? It gives you the latest libraries, features and progress —
|
|
18
|
-
and it's what the platform currently runs. Do you want to use it?"* **If yes, scaffold with the
|
|
19
|
-
`bim-beta` template** (`thatopen create <name> -t bim-beta`). Founding members have **permanent** beta
|
|
20
|
-
access, so for them the answer is almost always yes. Using the matching library line avoids
|
|
21
|
-
runtime errors against the platform. (Beta packages are private — the user needs their beta
|
|
22
|
-
access token configured in npm, or `npm install` will fail.) See
|
|
23
|
-
[docs/scaffolding.md](./docs/scaffolding.md).
|
|
24
|
-
- **New app or component?** The **first step is always the CLI** (`thatopen create`) — never
|
|
25
|
-
hand-write the scaffold. See [docs/cli-setup.md](./docs/cli-setup.md) then
|
|
26
|
-
[docs/scaffolding.md](./docs/scaffolding.md).
|
|
27
|
-
- **The scaffold is already a complete, working viewer** (model loading, spatial tree, properties).
|
|
28
|
-
**Run it first** (`npm run dev`) to see it work, *then* extend it — don't rebuild a viewer from scratch.
|
|
29
|
-
- **Propose a short plan and get the user's OK** before changing files. If scope is unclear, ask.
|
|
30
|
-
- Prefer existing engine functionality over custom code (see rule 2).
|
|
31
|
-
|
|
32
|
-
## Hard rules (always apply)
|
|
33
|
-
|
|
34
|
-
1. **All business logic lives in a BIM component** (`src/bim-components/`).
|
|
35
|
-
`setups/` only wire; `ui-components/` only render; `main.ts` only boots. Logic that doesn't
|
|
36
|
-
fit an existing component → create a new one. Never put logic in a setup, template, or `main.ts`.
|
|
37
|
-
2. **Check engine components first** — `@thatopen/components` (`OBC`) and
|
|
38
|
-
`@thatopen/components-front` (`OBF`) — before building anything custom.
|
|
39
|
-
3. **Platform built-ins** (`AppManager`, `ViewportsManager`, `UIManager`, …) come from
|
|
40
|
-
`@thatopen/services` and are available after `client.setup()`. Don't reinvent them.
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## What are you doing? → open the right doc
|
|
45
|
-
|
|
46
|
-
### Set up & ship
|
|
47
|
-
| Goal | Doc |
|
|
48
|
-
|---|---|
|
|
49
|
-
| Install the CLI + authenticate | [docs/cli-setup.md](./docs/cli-setup.md) |
|
|
50
|
-
| Scaffold a new app / component | [docs/scaffolding.md](./docs/scaffolding.md) |
|
|
51
|
-
| Preview the app inside the platform | [docs/previewing.md](./docs/previewing.md) |
|
|
52
|
-
| Publish an app or component | [docs/publishing.md](./docs/publishing.md) |
|
|
53
|
-
|
|
54
|
-
### Structure & wire an app
|
|
55
|
-
| Goal | Doc |
|
|
56
|
-
|---|---|
|
|
57
|
-
| Project structure, architecture rules, component tiers | [docs/app-architecture.md](./docs/app-architecture.md) |
|
|
58
|
-
| Boot / `app.ts` / `main.ts` / `client.setup()` | [docs/app-wiring.md](./docs/app-wiring.md) |
|
|
59
|
-
| Configure layout, add/reorganize grid sections | [docs/app-layout.md](./docs/app-layout.md) |
|
|
60
|
-
| Connect component logic to the UI | [docs/connect-logic-to-ui.md](./docs/connect-logic-to-ui.md) |
|
|
61
|
-
| Update a grid element's state at runtime | [docs/update-grid-elements.md](./docs/update-grid-elements.md) |
|
|
62
|
-
| Access the backend client / project data | [docs/access-backend-data.md](./docs/access-backend-data.md) |
|
|
63
|
-
| Register and use icons | [docs/using-icons.md](./docs/using-icons.md) |
|
|
64
|
-
| Declare and use colors | [docs/using-colors.md](./docs/using-colors.md) |
|
|
65
|
-
|
|
66
|
-
### Build a custom BIM component
|
|
67
|
-
Start at [docs/bim-components/overview.md](./docs/bim-components/overview.md) — conventions,
|
|
68
|
-
lifecycle (setup/cleanup), exposing events, observable/element collections, per-frame updates,
|
|
69
|
-
saving/restoring state, user-driven object creation.
|
|
70
|
-
|
|
71
|
-
### Build a UI component
|
|
72
|
-
Start at [docs/ui-components/overview.md](./docs/ui-components/overview.md) — rendering patterns,
|
|
73
|
-
section layout, data tables, inline forms, confirmation dialogs, display text, async actions.
|
|
74
|
-
|
|
75
|
-
### Cloud components & automations
|
|
76
|
-
[docs/cloud-components.md](./docs/cloud-components.md) — build / run locally / publish a cloud
|
|
77
|
-
component, the execution globals, and event-triggered automations.
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## Reference (also shipped in this package)
|
|
82
|
-
|
|
83
|
-
- **Library API** — `PlatformClient` vs `EngineServicesClient`, the permissions contract, and the
|
|
84
|
-
full method surface → [CONTEXT.md](./CONTEXT.md)
|
|
85
|
-
- **Built-in components API** — config interfaces, method signatures, `@example` blocks →
|
|
86
|
-
`src/built-in/index.ts` (in the installed package, `node_modules/@thatopen/services/`)
|
package/CONTEXT.md
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
# @thatopen/services
|
|
2
|
-
|
|
3
|
-
Client library and CLI for the That Open Platform — a cloud platform for building BIM (Building Information Modeling) software.
|
|
4
|
-
|
|
5
|
-
## What this repo contains
|
|
6
|
-
|
|
7
|
-
1. **Library** (`src/core/client.ts`) — `EngineServicesClient`, a TypeScript API client for managing files, folders, apps, cloud components, and executions on the platform.
|
|
8
|
-
2. **CLI** (`src/cli/`) — The `thatopen` command-line tool for scaffolding and publishing apps and cloud components.
|
|
9
|
-
3. **Built-in components** (`src/built-in/`) — Type stubs for platform-provided UI components (AppManager, ViewportManager, etc.) that are fetched and evaluated at runtime.
|
|
10
|
-
|
|
11
|
-
## Project structure
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
src/
|
|
15
|
-
core/client.ts # EngineServicesClient — the main API class
|
|
16
|
-
cli/
|
|
17
|
-
commands/create.ts # thatopen create — scaffolds new projects
|
|
18
|
-
commands/serve.ts # thatopen serve — dev server (esbuild watch + serve)
|
|
19
|
-
commands/login.ts # thatopen login — authenticate with the platform
|
|
20
|
-
commands/publish.ts # thatopen publish — build and upload to the platform
|
|
21
|
-
commands/run.ts # thatopen run — test cloud components locally
|
|
22
|
-
commands/create-tests.ts # thatopen create-tests — scaffolds test app + test component
|
|
23
|
-
commands/serve-tests.ts # thatopen serve-tests — serves both test projects in parallel
|
|
24
|
-
templates/ # Template generators for scaffolded projects
|
|
25
|
-
lib/ # CLI helper utilities (config, certificates)
|
|
26
|
-
built-in/index.ts # Built-in component type stubs + runtime UUID constants
|
|
27
|
-
types/ # TypeScript type definitions (items, execution, etc.)
|
|
28
|
-
index.ts # Library entry point (re-exports everything)
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Build system
|
|
32
|
-
|
|
33
|
-
- **Library** builds to CommonJS (`dist/index.cjs.js`) + ESM (`dist/index.es.js`) + types (`dist/index.d.ts`) via Vite (`vite.config.mts`).
|
|
34
|
-
- **CLI** builds to a single `dist/cli.js` executable via Vite (`vite.config.cli.mts`). It bundles commander, jszip, and all library code.
|
|
35
|
-
- TypeScript strict mode is enabled.
|
|
36
|
-
|
|
37
|
-
### Commands
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
npm run build # Full build (library + CLI)
|
|
41
|
-
npm run build:lib # Library only
|
|
42
|
-
npm run build:cli # CLI only
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Testing
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npm run test # Run vitest unit tests (HTTP client contract)
|
|
49
|
-
npm run test:watch # Vitest watch mode
|
|
50
|
-
npm run test:ui # Interactive browser test page
|
|
51
|
-
npm run test:cli-build-app # Scaffold + build a test app
|
|
52
|
-
npm run test:cli-build-component # Scaffold + build a test cloud component
|
|
53
|
-
npm run test:cli-run-component # Run the test cloud component locally
|
|
54
|
-
npm run test:cli-build-tests # Build CLI + scaffold test app & test component into temp/
|
|
55
|
-
npm run test:cli-serve-tests # Serve the test app and test component's local server in parallel
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Two clients — components vs apps/FE
|
|
59
|
-
|
|
60
|
-
This package ships two clients with overlapping but intentionally different
|
|
61
|
-
surfaces. Pick the one that matches who's calling.
|
|
62
|
-
|
|
63
|
-
### `EngineServicesClient`
|
|
64
|
-
**For cloud components running inside the platform.** Authenticates via
|
|
65
|
-
API token by default (`?accessToken=`). Supports local-server execution,
|
|
66
|
-
WebSocket execution progress, built-in component runtime helpers, and the
|
|
67
|
-
low-level HTTP surface. This is what you get via
|
|
68
|
-
`EngineServicesClient.fromPlatformContext()` inside a component bundle.
|
|
69
|
-
|
|
70
|
-
### `PlatformClient`
|
|
71
|
-
**For apps, frontends, and any caller using a user JWT.** Extends
|
|
72
|
-
`EngineServicesClient`; the API-token-compatible surface is inherited and
|
|
73
|
-
the constructor forces `useBearer: true`. On top, it owns the JWT-only
|
|
74
|
-
routes — `getProject`, `getProjectData`, `checkPermission`,
|
|
75
|
-
`checkPermissionBatch` — which hit `ProjectController` in the backend
|
|
76
|
-
(guarded by JWT) and are not reachable with an access token.
|
|
77
|
-
|
|
78
|
-
The constructor accepts either a static JWT or a provider function
|
|
79
|
-
(sync or async) that returns the current JWT. The provider is called on
|
|
80
|
-
every request, so Auth0's `getAccessTokenSilently()` and similar
|
|
81
|
-
refreshing sources Just Work:
|
|
82
|
-
|
|
83
|
-
```ts
|
|
84
|
-
import { PlatformClient } from '@thatopen/services';
|
|
85
|
-
const client = new PlatformClient(
|
|
86
|
-
() => auth0.getAccessTokenSilently(),
|
|
87
|
-
'https://api.thatopen.com',
|
|
88
|
-
);
|
|
89
|
-
await client.getProjectData(projectId);
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
`PlatformClient.fromPlatformContext()` is available for apps running inside
|
|
93
|
-
the platform iframe — it pulls the JWT from
|
|
94
|
-
`window.__THATOPEN_CONTEXT__` and returns a ready-to-use client.
|
|
95
|
-
|
|
96
|
-
Choose by audience:
|
|
97
|
-
- Component code → `EngineServicesClient` (or `EngineServicesClient.fromPlatformContext()`).
|
|
98
|
-
- App / FE / integration with a user JWT → `PlatformClient`.
|
|
99
|
-
|
|
100
|
-
## Permissions contract (backend coupling)
|
|
101
|
-
|
|
102
|
-
The platform API enforces **project-scoped permission checks**: whenever a
|
|
103
|
-
request carries a `projectId` (URL param, query, or body), the backend
|
|
104
|
-
rejects the call if the resource does not belong to that project or the
|
|
105
|
-
caller lacks permission there — regardless of whether the caller has access
|
|
106
|
-
to the same resource in a different project.
|
|
107
|
-
|
|
108
|
-
Relevant client methods:
|
|
109
|
-
|
|
110
|
-
- `executeComponent(componentId, executionParams, versionTag?)`: include
|
|
111
|
-
`projectId` in `executionParams` to scope the execution. The backend
|
|
112
|
-
validates that the component is linked to that project. Without a
|
|
113
|
-
`projectId`, the execution runs in the user's personal/ownership scope.
|
|
114
|
-
- `listExecutions(componentId, projectId?)`: pass `projectId` to filter
|
|
115
|
-
executions to that project's context.
|
|
116
|
-
- `checkPermission({ resourceType, action, resourceId?, projectId? })`:
|
|
117
|
-
returns `{ hasPermission, scope }`. `scope` is `'global' | 'project' |
|
|
118
|
-
'entity' | 'none'` — `global` for admin/owner bypass, `project` for a
|
|
119
|
-
role broad grant, `entity` for a per-entity override, `none` for denied.
|
|
120
|
-
- `checkPermissionBatch(checks)`: evaluates a list of checks in one
|
|
121
|
-
round-trip. Useful for hydrating action visibility for many rows without
|
|
122
|
-
N+1 calls.
|
|
123
|
-
|
|
124
|
-
Per-entity permission overrides (`ResourcePermission.removePermission`,
|
|
125
|
-
`ResourcePermission.appliesToDescendants`) are applied automatically on the
|
|
126
|
-
server side when listing project files/folders — no client change needed.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
### Publishing to npm
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
yarn create-version # Build → changeset → version → publish
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## Key concepts
|
|
136
|
-
|
|
137
|
-
### Apps vs Cloud Components
|
|
138
|
-
|
|
139
|
-
| | Apps | Cloud Components |
|
|
140
|
-
|---|---|---|
|
|
141
|
-
| **Runs in** | Browser (iframe on the platform) | Server (Node.js child process) |
|
|
142
|
-
| **Item type** | `APP` | `TOOL` |
|
|
143
|
-
| **Entry point** | Side effects in `main.ts` (renders UI) | `export async function main()` |
|
|
144
|
-
| **Context** | `window.__THATOPEN_CONTEXT__` provides `{ appId, projectId, accessToken, apiUrl }` | Globals: `thatOpenServices`, `executionParams`, `executionContext` (`{ projectId?, executionId, toolId, toolVersion }`), `executionReporter` (`message/error/progress`). `OBC`, `THREE`, `web-ifc`, `fs` are NOT injected — import them and let the bundler include them. |
|
|
145
|
-
| **Build output** | IIFE `dist/bundle.js` (all deps bundled) | IIFE `dist/bundle.js` (only `@thatopen/services` externalized) |
|
|
146
|
-
| **Template** | `bim`, `default`, or `test` | `cloud` or `cloud-test` |
|
|
147
|
-
|
|
148
|
-
### Authentication
|
|
149
|
-
|
|
150
|
-
Two modes, controlled by `useBearer` in the constructor:
|
|
151
|
-
- **Query parameter** (default): Sends `accessToken` as a URL query param. Used with platform API tokens.
|
|
152
|
-
- **Bearer header** (`useBearer: true`): Sends as `Authorization: Bearer <token>`. Used with Auth0 JWTs inside platform apps.
|
|
153
|
-
|
|
154
|
-
### Built-in components
|
|
155
|
-
|
|
156
|
-
Built-in components are platform-hosted UI modules fetched at runtime. Usage pattern:
|
|
157
|
-
|
|
158
|
-
```ts
|
|
159
|
-
import { AppManager, ViewportManager } from "@thatopen/services";
|
|
160
|
-
|
|
161
|
-
// Register all library globals once
|
|
162
|
-
client.setBuiltInGlobals({ OBC, OBF, BUI, CUI, THREE, FRAGS });
|
|
163
|
-
|
|
164
|
-
// Fetch, evaluate, and register with OBC — globals are automatically applied
|
|
165
|
-
await client.initBuiltInComponent(AppManager, components);
|
|
166
|
-
await client.initBuiltInComponent(ViewportManager, components);
|
|
167
|
-
|
|
168
|
-
// Use via OBC component system
|
|
169
|
-
const app = components.get(AppManager);
|
|
170
|
-
const viewports = components.get(ViewportManager);
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
Available built-in components:
|
|
174
|
-
|
|
175
|
-
| Component | Purpose |
|
|
176
|
-
|-----------|---------|
|
|
177
|
-
| `AppManager` | App shell — CSS grid layout with sidebar for switching layouts |
|
|
178
|
-
| `ViewportManager` | Factory for 3D viewports with pre-configured world |
|
|
179
|
-
| `LoadModelButton` | Button + dropdown for loading IFC / Fragments files |
|
|
180
|
-
| `ViewerToolbar` | Toolbar with Show/Hide/Focus/Isolate and color palette |
|
|
181
|
-
| `ModelsPanel` | Panel listing loaded models with search and load button |
|
|
182
|
-
| `ModelsDropdown` | Dropdown selector listing loaded models |
|
|
183
|
-
| `ClassificationsList` | Hierarchical table of IFC classification data |
|
|
184
|
-
| `ClashesList` | Interactive clash detection results with highlighting |
|
|
185
|
-
| `ClippingsList` | Panel listing clipping planes with controls |
|
|
186
|
-
| `LengthMeasuringsList` | Panel listing length measurements with totals |
|
|
187
|
-
| `AreaMeasuringsList` | Panel listing area measurements with totals |
|
|
188
|
-
| `ColorsPalette` | Color picker with Highlighter style swatches |
|
|
189
|
-
| `HighlightersList` | Panel listing Highlighter styles with manage actions |
|
|
190
|
-
| `QtoComparisonList` | Side-by-side quantity comparison for two elements |
|
|
191
|
-
| `QueriesHierarchy` | Recursive multi-level query browser |
|
|
192
|
-
| `CustomViewLegend` | Color legend overlay |
|
|
193
|
-
| `ScreenshotAnnotator` | Modal for annotating screenshots via MarkerJS |
|
|
194
|
-
|
|
195
|
-
Full API reference with config interfaces, method signatures, and `@example` blocks: `src/built-in/index.ts`.
|
|
196
|
-
|
|
197
|
-
### Configuration files
|
|
198
|
-
|
|
199
|
-
- **Global**: `~/.thatopen/config.json` — `{ accessToken, apiUrl }`
|
|
200
|
-
- **Local** (per project): `.thatopen` — `{ accessToken, apiUrl, appId?, componentId?, itemType? }`
|
|
201
|
-
- Local config takes priority. Created by `thatopen login --local`.
|
|
202
|
-
|
|
203
|
-
## API surface (EngineServicesClient)
|
|
204
|
-
|
|
205
|
-
### Files
|
|
206
|
-
- `listFiles(filters?)` / `getFile(id, props?)` / `createFile(data)` / `updateFile(id, data)`
|
|
207
|
-
- `archiveFile(id)` / `recoverFile(id)` / `downloadFile(id, params?)` / `getFileMetadata(id, params?)`
|
|
208
|
-
|
|
209
|
-
### Folders
|
|
210
|
-
- `listFolders(params?)` / `getFolder(id)` / `createFolder(name, parentId?)`
|
|
211
|
-
- `updateFolder(id, params)` / `archiveFolder(id)` / `recoverFolder(id)` / `downloadFolder(id)`
|
|
212
|
-
|
|
213
|
-
### Components
|
|
214
|
-
- `listComponents(params?)` / `getComponent(id, props?)` / `createComponent(data)` / `updateComponent(id, data)`
|
|
215
|
-
- `archiveComponent(id)` / `recoverComponent(id)` / `downloadComponent(id, params?)` / `downloadComponentBundle(id, params?)`
|
|
216
|
-
|
|
217
|
-
### Apps
|
|
218
|
-
- `listApps(params?)` / `createApp(data)` / `archiveApp(id)`
|
|
219
|
-
- `downloadApp(id, params?)` / `downloadAppBundle(id, params?)`
|
|
220
|
-
|
|
221
|
-
### Execution (cloud components)
|
|
222
|
-
- `executeComponent(componentId, params, versionTag?)` — triggers server-side execution, returns `{ executionId }`
|
|
223
|
-
- `abortExecution(executionId)` / `listExecutions(componentId)` / `getExecution(executionId)`
|
|
224
|
-
- `onExecutionProgress(executionId, callback)` — real-time WebSocket subscription
|
|
225
|
-
|
|
226
|
-
### Built-in components
|
|
227
|
-
- `setBuiltInGlobals(globals)` — registers globals once; subsequent `initBuiltInComponent` calls use them automatically
|
|
228
|
-
- `getBuiltInComponent(name)` — fetches JS bundle by name
|
|
229
|
-
- `initBuiltInComponent(component, components, globals?)` — fetches, evaluates, and registers (uses stored globals if `globals` omitted)
|
|
230
|
-
|
|
231
|
-
### Hidden files
|
|
232
|
-
- `createHiddenFile(file, parentId)` / `deleteHiddenFile(id)` / `getHiddenFile(id)`
|
|
233
|
-
- `downloadHiddenFile(id)` / `getHiddenFilesByParent(parentId)` / `deleteHiddenFilesByParent(parentId)`
|
|
234
|
-
|
|
235
|
-
### General
|
|
236
|
-
- `updateItem(id, params)` / `createVersion(id, file, tag, extraProps?, metadata?)`
|
|
237
|
-
- `getProjectData(projectId)` / `checkPermission(params)`
|
|
238
|
-
|
|
239
|
-
## CLI commands
|
|
240
|
-
|
|
241
|
-
```bash
|
|
242
|
-
thatopen create <name> [--template bim|default|cloud|test|cloud-test]
|
|
243
|
-
# Scaffold project + auto npm install
|
|
244
|
-
# Use "." as name to scaffold in current directory
|
|
245
|
-
thatopen serve [--port N] # Dev server (esbuild watch + serve bundle)
|
|
246
|
-
thatopen login [--token T] [--api-url U] [--local] # Authenticate
|
|
247
|
-
thatopen publish [--name N] [--version-tag T] [--skip-build] [--app-id ID | --component-id ID]
|
|
248
|
-
thatopen run [--params '{}'] [--skip-build] # Test cloud component locally
|
|
249
|
-
thatopen local-server [--port N] [--skip-build] # Local execution server (API-compatible)
|
|
250
|
-
thatopen create-tests [directory] # Scaffold test app + test component (cleans directory first)
|
|
251
|
-
thatopen serve-tests [directory] # Serve test app + test component in parallel
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
## Dependencies
|
|
255
|
-
|
|
256
|
-
- **Runtime**: `dotenv`, `socket.io-client`
|
|
257
|
-
- **Peer** (optional): `@thatopen/components` ^3.3.1, `@thatopen/ui` ^3.3.3, `three` ^0.182.0
|
|
258
|
-
- **CLI bundled**: `commander`, `jszip`
|