bimplus-websdk 1.0.63 → 1.0.65

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.
@@ -0,0 +1,116 @@
1
+ ---
2
+ applyTo: "websdk/types/bimplus-websdk.d.ts"
3
+ ---
4
+
5
+ # Bimplus WebSDK — TypeScript Declarations
6
+
7
+ ## File Structure
8
+
9
+ All declarations live inside a single module augmentation — never add top-level exports outside it:
10
+
11
+ ```ts
12
+ declare module 'bimplus-websdk' {
13
+ // all types here
14
+ }
15
+ ```
16
+
17
+ ---
18
+
19
+ ## Base Type Aliases
20
+
21
+ These are already defined — use them for parameter and return types instead of plain `string`:
22
+
23
+ ```ts
24
+ Guid // string UUID
25
+ ProjectId // Guid
26
+ ModelId // Guid
27
+ LayerId // Guid
28
+ DivisionTopologyId // Guid
29
+ RevisionId // string
30
+ TeamSlug // string
31
+ AccessToken // string
32
+ AccessTokenType // string
33
+ HTML // string
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Pattern for a New Resource Module
39
+
40
+ For each new `src/Api/MyResource.js`, add three things:
41
+
42
+ ### 1. A data interface
43
+
44
+ ```ts
45
+ export interface MyResourceData {
46
+ id: Guid;
47
+ name: string;
48
+ // match field names from the REST API response exactly
49
+ }
50
+ ```
51
+
52
+ ### 2. A class declaration
53
+
54
+ ```ts
55
+ export class MyResource {
56
+ constructor(api: Api);
57
+ get(id?: Guid): Promise<MyResourceData | MyResourceData[]>;
58
+ post(data: string): Promise<MyResourceData>;
59
+ put(id: Guid, data: string): Promise<MyResourceData>;
60
+ delete(id: Guid): Promise<void>;
61
+ }
62
+ ```
63
+
64
+ ### 3. A property on the `Api` class
65
+
66
+ Add to the existing `Api` class body, matching the exact property name from `src/Api/Api.js`:
67
+
68
+ ```ts
69
+ // In src/Api/Api.js: this.myResource = new MyResource(this)
70
+ myResource: MyResource;
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Conventions
76
+
77
+ - All async methods return `Promise<T>` — never use jQuery types (`JQuery.Promise`, `$.Deferred`) in declarations
78
+ - For optional parameters use `?`: `get(id?: Guid)`
79
+ - For methods that return a single item or an array: `Promise<T | T[]>`
80
+ - `data` parameters passed as `JSON.stringify(...)` in the source are typed as `string`
81
+ - Keep parameter names consistent with the JSDoc `@param` names in the corresponding source file
82
+ - For complex `data` shapes that are always structured objects (not stringified), define a dedicated interface and use it: `post(data: MyResourceData): Promise<MyResourceData>`
83
+ - For query-param-only options (e.g. `additionalParams`), use a typed object or the existing `AdditionalParams` alias:
84
+ ```ts
85
+ type AdditionalParams = { [key: string]: string };
86
+ ```
87
+
88
+ ---
89
+
90
+ ## Api Class Declaration
91
+
92
+ The `Api` class in this file is the single source of truth for TypeScript consumers. Every namespace instantiated in `src/Api/Api.js` must appear as a property:
93
+
94
+ ```ts
95
+ export class Api {
96
+ constructor(config?: ApiConfig);
97
+ setAccessToken(token: AccessToken): void;
98
+ setTokenType(tokenType: AccessTokenType): void;
99
+ setAccessTokenAndType(token: AccessToken, tokenType: AccessTokenType): void;
100
+ getAccessToken(): AccessToken;
101
+ getTokenType(): AccessTokenType;
102
+ getAccessTokenAndType(): { token: AccessToken; tokenType: AccessTokenType };
103
+ setTeamSlug(slug: TeamSlug): void;
104
+ getTeamSlug(): TeamSlug;
105
+ getApiUrl(): string;
106
+ getApiTeamUrl(): string;
107
+
108
+ // resource namespaces
109
+ authorize: Authorize;
110
+ projects: Projects;
111
+ models: Models;
112
+ // ... one line per namespace
113
+ }
114
+ ```
115
+
116
+ When adding a new module, append its property in the same order it appears in the `Api` constructor in `src/Api/Api.js`.