@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,9 @@
1
+ export interface Base {
2
+ _id: ObjectId;
3
+ createdAt: Date;
4
+ updatedAt?: Date;
5
+ creatingUser: ObjectId;
6
+ creatingToken?: ObjectId;
7
+ archived?: boolean;
8
+ }
9
+ export type ObjectId = string;
@@ -0,0 +1,20 @@
1
+ /** Callbacks the platform can pass to embedded apps via the context object. */
2
+ export interface AppEventOrchestrator {
3
+ /** Called when the app has finished loading (components initialised). */
4
+ appLoaded?: () => void;
5
+ /** Called when the app reports an error to the platform. */
6
+ appError?: (code: number, data: Record<string, string>) => void;
7
+ }
8
+ /** Auth context injected by the That Open Platform into `window.__THATOPEN_CONTEXT__`. */
9
+ export interface ThatOpenContext {
10
+ /** This app's unique identifier. */
11
+ appId: string;
12
+ /** The project this app belongs to. */
13
+ projectId: string;
14
+ /** Auth0 JWT for API calls. */
15
+ accessToken: string;
16
+ /** Base URL for the That Open API. */
17
+ apiUrl: string;
18
+ /** Platform-to-app event callbacks. */
19
+ appEventOrchestrator?: AppEventOrchestrator;
20
+ }
@@ -0,0 +1,19 @@
1
+ import { ObjectId, Base } from './base';
2
+
3
+ export type ExecutionEntity = Base & {
4
+ toolId: ObjectId;
5
+ toolVersion: string;
6
+ progress: number;
7
+ result?: ExecutionResultType;
8
+ resultMessage?: string;
9
+ messages?: ExecutionMessageEntity[];
10
+ };
11
+ export type ExecutionMessageEntity = Base & {
12
+ executionId: ObjectId;
13
+ content: string;
14
+ };
15
+ export type ExecutionResultType = 'SUCCESS' | 'ERROR' | 'WARNING';
16
+ export type ExecutionSuscriptionReturnType = {
17
+ progressUpdate?: ExecutionEntity;
18
+ messageUpdate?: ExecutionMessageEntity;
19
+ };
@@ -0,0 +1,19 @@
1
+ import { Readable } from 'stream';
2
+ import { ObjectId } from './base';
3
+
4
+ export type FileType = string | Uint8Array | Buffer | Readable;
5
+ export type HiddenFileEntity = {
6
+ fileId: string;
7
+ _id: ObjectId;
8
+ parentItemId: ObjectId;
9
+ };
10
+ export type CreateHiddenItemResult = {
11
+ hiddenFileId: string;
12
+ };
13
+ export type MetadataValue = string | number | boolean | null;
14
+ export type Metadata = Record<string, MetadataValue>;
15
+ export declare const METADATA_LIMITS: {
16
+ readonly MAX_FIELDS: 200;
17
+ readonly MAX_KEY_LENGTH: 50;
18
+ readonly MAX_VALUE_LENGTH: 50;
19
+ };
@@ -0,0 +1,24 @@
1
+ import { ItemType } from './items';
2
+
3
+ export type CreateItemDto = {
4
+ name?: string;
5
+ fileExtension?: string;
6
+ versionTag?: string;
7
+ folderId?: string;
8
+ file: File;
9
+ itemType?: ItemType;
10
+ };
11
+ export type UpdateItemDto = {
12
+ name?: string;
13
+ folderId?: string;
14
+ };
15
+ export type CreateItemVersionDto = {
16
+ versionTag: string;
17
+ file: File;
18
+ };
19
+ export type CreateItemFolderDto = {
20
+ name: string;
21
+ };
22
+ export type UpdateItemFolderDto = {
23
+ name: string;
24
+ };
@@ -0,0 +1,57 @@
1
+ import { Base, ObjectId } from './base';
2
+
3
+ export interface Item extends Base {
4
+ fileExtension?: string;
5
+ name: string;
6
+ itemType: ItemType;
7
+ folderId?: ObjectId;
8
+ internalId: string;
9
+ }
10
+ export type ItemType = 'APP' | 'TOOL' | 'HIDDEN' | 'FILE';
11
+ export interface ItemVersion extends Base {
12
+ itemId: ObjectId;
13
+ tag: string;
14
+ fileVersionId: string;
15
+ fileId: string;
16
+ fileSize: number;
17
+ extraProps?: AppVersionProps | ComponentVersionProps;
18
+ isDraft?: boolean;
19
+ }
20
+ export interface ItemFolder extends Base {
21
+ name: string;
22
+ parentId?: ObjectId;
23
+ }
24
+ export type ItemWithVersions<T = Item> = T & {
25
+ versions: ItemVersion[];
26
+ };
27
+ export type AppVersionProps = {
28
+ isOnline?: boolean;
29
+ url?: string;
30
+ /** When set, the app viewer loads the bundle from this URL instead of the API (for local development). */
31
+ devUrl?: string;
32
+ };
33
+ export type AppItem = Item & {
34
+ itemType: 'APP';
35
+ };
36
+ export type AppItemVersion = ItemVersion & {
37
+ extraProps: AppVersionProps;
38
+ };
39
+ export type ComponentType = 'FRONTEND' | 'CLOUD';
40
+ export type ComponentTier = 'FREE' | 'PREMIUM';
41
+ export type ComponentItemProps = {
42
+ generatedId: string;
43
+ };
44
+ export type ComponentVersionProps = {
45
+ isPublic?: boolean;
46
+ isOpenSource?: boolean;
47
+ type: ComponentType;
48
+ tier: ComponentTier;
49
+ executionEngineVersion?: string;
50
+ };
51
+ export type ComponentItem = Item & {
52
+ itemType: 'TOOL';
53
+ };
54
+ export type ComponentItemVersion = ItemVersion & {
55
+ extraProps: ComponentVersionProps;
56
+ };
57
+ export type ItemEntity = Item | AppItem | ComponentItem;
@@ -0,0 +1,59 @@
1
+ import { Base, ObjectId } from './base';
2
+
3
+ export type PermissionSubject = 'PROJECT' | 'MEMBERS' | 'ROLES' | 'APP' | 'STORAGE' | 'EVENTS' | 'ALL';
4
+ export type PermissionAction = 'CREATE' | 'READ' | 'UPDATE' | 'DELETE' | 'MANAGE';
5
+ export interface Permission {
6
+ action: PermissionAction;
7
+ subject?: PermissionSubject;
8
+ }
9
+ export interface Project extends Base {
10
+ title: string;
11
+ description?: string;
12
+ }
13
+ export interface ProjectRole extends Base {
14
+ projectId: ObjectId;
15
+ name: string;
16
+ description?: string;
17
+ permissions: Permission[];
18
+ fixed?: boolean;
19
+ }
20
+ export interface ProjectWithRole {
21
+ project: Project;
22
+ role: ProjectRole | null;
23
+ }
24
+ /** Stripped-down user info safe for app consumption. */
25
+ export interface ProjectDataUser {
26
+ _id: string;
27
+ fullName: string;
28
+ email: string;
29
+ }
30
+ /** A project member with their role info. */
31
+ export interface ProjectDataMember {
32
+ projectUserId: string;
33
+ user: ProjectDataUser;
34
+ role: ProjectRole;
35
+ }
36
+ /** Minimal file info for the project data. */
37
+ export interface ProjectDataFile {
38
+ _id: string;
39
+ name: string;
40
+ fileExtension?: string;
41
+ folderId?: string;
42
+ itemType: string;
43
+ createdAt: string;
44
+ }
45
+ /** Minimal folder info for the project data. */
46
+ export interface ProjectDataFolder {
47
+ _id: string;
48
+ name: string;
49
+ parentId?: string;
50
+ }
51
+ /** Aggregated project data returned by `getProjectData()`. */
52
+ export interface ProjectData {
53
+ project: Project;
54
+ currentUser: ProjectDataMember | null;
55
+ users: ProjectDataMember[];
56
+ roles: ProjectRole[];
57
+ files: ProjectDataFile[];
58
+ folders: ProjectDataFolder[];
59
+ }
@@ -0,0 +1,10 @@
1
+ import { Item, ItemVersion } from './items';
2
+
3
+ export type CreateItemResponse<T = Item> = {
4
+ item: T;
5
+ version: ItemVersion;
6
+ };
7
+ export type UpdateItemResponse<T = Item> = {
8
+ item?: T;
9
+ version?: ItemVersion;
10
+ };
@@ -0,0 +1,11 @@
1
+ import { Base, ObjectId } from './base';
2
+ import { ItemVersion } from './items';
3
+
4
+ export type StorageData = Base & {
5
+ name: string;
6
+ versions?: ItemVersion[];
7
+ size: number;
8
+ type: StorageDataType;
9
+ parentId?: ObjectId;
10
+ };
11
+ export type StorageDataType = 'folder' | 'file';
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
package/package.json ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "@thatopen/services",
3
+ "description": "Client library and CLI for building BIM apps and cloud components on the That Open Platform",
4
+ "author": "That Open Company",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/ThatOpen/engine_services#readme",
7
+ "bugs": {
8
+ "url": "https://github.com/ThatOpen/engine_services/issues"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/ThatOpen/engine_services.git"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "private": false,
18
+ "version": "0.0.1",
19
+ "main": "dist/index.cjs.js",
20
+ "module": "dist/index.es.js",
21
+ "types": "dist/index.d.ts",
22
+ "bin": {
23
+ "thatopen": "dist/cli.js"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "src/cli/templates",
28
+ "src/built-in",
29
+ "CONTEXT.md"
30
+ ],
31
+ "scripts": {
32
+ "dev": "vite",
33
+ "lint": "eslint src/",
34
+ "build": "eslint src/ && tsc && vite build && vite build --config vite.config.cli.mts",
35
+ "build:lib": "tsc && vite build",
36
+ "test": "vitest run",
37
+ "test:watch": "vitest",
38
+ "build:cli": "vite build --config vite.config.cli.mts && node scripts/copy-templates.mjs",
39
+ "preview": "vite preview",
40
+ "test:ui": "vite --config test/vite.config.mts",
41
+ "test:cli-build-app": "npm run build:cli && node test/setup-test-app.mjs",
42
+ "test:cli-serve-app": "cd temp/test-app && thatopen serve",
43
+ "test:cli-build-component": "npm run build:cli && node test/setup-test-component.mjs",
44
+ "test:cli-run-component": "cd temp/test-component && thatopen run --skip-build",
45
+ "test:cli-serve-component": "cd temp/test-component && thatopen local-server",
46
+ "test:cli-build-tests": "npm run build:cli && thatopen create-tests temp",
47
+ "test:cli-serve-tests": "thatopen serve-tests temp",
48
+ "template:bim": "cd src/cli/templates/bim && npm install && cd ../../../.. && node scripts/generate-template-tsconfig.mjs",
49
+ "template:bim:dev": "cd src/cli/templates/bim && npm run dev",
50
+ "changeset": "changeset",
51
+ "version": "changeset version"
52
+ },
53
+ "devDependencies": {
54
+ "@changesets/cli": "^2.27.7",
55
+ "@thatopen/components": "~3.4.0",
56
+ "@thatopen/components-front": "~3.4.0",
57
+ "@thatopen/fragments": "~3.4.0",
58
+ "@thatopen/ui": "~3.4.0",
59
+ "@thatopen/ui-obc": "~3.4.0",
60
+ "@types/node": "^20.12.12",
61
+ "@types/three": "^0.182.0",
62
+ "commander": "^14.0.3",
63
+ "esbuild": "^0.27.3",
64
+ "eslint": "9.x",
65
+ "eslint-config-prettier": "^9.1.0",
66
+ "eslint-plugin-prettier": "^5.1.3",
67
+ "globals": "^15.3.0",
68
+ "jszip": "^3.10.1",
69
+ "prettier": "^3.2.5",
70
+ "three": "^0.182.0",
71
+ "tsx": "^4.16.2",
72
+ "typescript": "^5.2.2",
73
+ "typescript-eslint": "^7.10.0",
74
+ "vite": "^5.2.0",
75
+ "vite-plugin-dts": "^3.9.1",
76
+ "vite-plugin-eslint": "^1.8.1",
77
+ "vitest": "^4.1.4"
78
+ },
79
+ "dependencies": {
80
+ "dotenv": "^16.4.5",
81
+ "socket.io": "^4.8.0",
82
+ "socket.io-client": "^4.8.0"
83
+ },
84
+ "peerDependencies": {
85
+ "@thatopen/components": "~3.4.0",
86
+ "@thatopen/ui": "~3.4.0",
87
+ "three": "^0.182.0"
88
+ },
89
+ "peerDependenciesMeta": {
90
+ "@thatopen/components": {
91
+ "optional": true
92
+ },
93
+ "@thatopen/ui": {
94
+ "optional": true
95
+ },
96
+ "three": {
97
+ "optional": true
98
+ }
99
+ }
100
+ }