@ifc-lite/sdk 1.14.2 → 1.14.3
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/dist/context.d.ts +41 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +75 -0
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/namespaces/bcf.d.ts +108 -10
- package/dist/namespaces/bcf.d.ts.map +1 -1
- package/dist/namespaces/bcf.js +184 -11
- package/dist/namespaces/bcf.js.map +1 -1
- package/dist/namespaces/bsdd.d.ts +140 -0
- package/dist/namespaces/bsdd.d.ts.map +1 -0
- package/dist/namespaces/bsdd.js +278 -0
- package/dist/namespaces/bsdd.js.map +1 -0
- package/dist/namespaces/drawing.d.ts +118 -6
- package/dist/namespaces/drawing.d.ts.map +1 -1
- package/dist/namespaces/drawing.js +181 -10
- package/dist/namespaces/drawing.js.map +1 -1
- package/dist/namespaces/files.d.ts +15 -0
- package/dist/namespaces/files.d.ts.map +1 -0
- package/dist/namespaces/files.js +27 -0
- package/dist/namespaces/files.js.map +1 -0
- package/dist/namespaces/ids.d.ts +64 -6
- package/dist/namespaces/ids.d.ts.map +1 -1
- package/dist/namespaces/ids.js +113 -4
- package/dist/namespaces/ids.js.map +1 -1
- package/dist/namespaces/list.d.ts +49 -4
- package/dist/namespaces/list.d.ts.map +1 -1
- package/dist/namespaces/list.js +69 -5
- package/dist/namespaces/list.js.map +1 -1
- package/dist/namespaces/mutate.d.ts +2 -0
- package/dist/namespaces/mutate.d.ts.map +1 -1
- package/dist/namespaces/mutate.js +4 -0
- package/dist/namespaces/mutate.js.map +1 -1
- package/dist/namespaces/query.d.ts +17 -1
- package/dist/namespaces/query.d.ts.map +1 -1
- package/dist/namespaces/query.js +43 -0
- package/dist/namespaces/query.js.map +1 -1
- package/dist/namespaces/sandbox.d.ts +83 -0
- package/dist/namespaces/sandbox.d.ts.map +1 -0
- package/dist/namespaces/sandbox.js +141 -0
- package/dist/namespaces/sandbox.js.map +1 -0
- package/dist/transport/remote-backend.d.ts +2 -1
- package/dist/transport/remote-backend.d.ts.map +1 -1
- package/dist/transport/remote-backend.js +1 -0
- package/dist/transport/remote-backend.js.map +1 -1
- package/dist/types.d.ts +97 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +14 -14
package/dist/namespaces/bcf.js
CHANGED
|
@@ -1,42 +1,215 @@
|
|
|
1
1
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
-
//
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Dynamic import
|
|
6
|
+
// ============================================================================
|
|
5
7
|
async function loadBCF() {
|
|
6
8
|
const name = '@ifc-lite/bcf';
|
|
7
9
|
return import(/* webpackIgnore: true */ name);
|
|
8
10
|
}
|
|
9
|
-
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// BCFNamespace
|
|
13
|
+
// ============================================================================
|
|
14
|
+
/** bim.bcf — BIM Collaboration Format (topics, viewpoints, comments, I/O) */
|
|
10
15
|
export class BCFNamespace {
|
|
16
|
+
// --------------------------------------------------------------------------
|
|
17
|
+
// Project management
|
|
18
|
+
// --------------------------------------------------------------------------
|
|
11
19
|
/** Create a new BCF project. */
|
|
12
|
-
async createProject(
|
|
20
|
+
async createProject(options) {
|
|
13
21
|
const mod = await loadBCF();
|
|
14
|
-
return mod.createBCFProject(
|
|
22
|
+
return mod.createBCFProject(options);
|
|
15
23
|
}
|
|
16
|
-
|
|
24
|
+
// --------------------------------------------------------------------------
|
|
25
|
+
// Topic (issue) management
|
|
26
|
+
// --------------------------------------------------------------------------
|
|
27
|
+
/** Create a new topic (issue). */
|
|
17
28
|
async createTopic(options) {
|
|
18
29
|
const mod = await loadBCF();
|
|
19
|
-
return mod.createBCFTopic(
|
|
30
|
+
return mod.createBCFTopic({
|
|
31
|
+
title: options.title,
|
|
32
|
+
description: options.description,
|
|
33
|
+
author: options.author,
|
|
34
|
+
topicType: options.topicType,
|
|
35
|
+
topicStatus: options.status,
|
|
36
|
+
priority: options.priority,
|
|
37
|
+
assignedTo: options.assignedTo,
|
|
38
|
+
dueDate: options.dueDate,
|
|
39
|
+
labels: options.labels,
|
|
40
|
+
});
|
|
20
41
|
}
|
|
21
|
-
/**
|
|
42
|
+
/** Add a topic to a project. */
|
|
43
|
+
async addTopic(project, topic) {
|
|
44
|
+
const mod = await loadBCF();
|
|
45
|
+
mod.addTopicToProject(project, topic);
|
|
46
|
+
}
|
|
47
|
+
/** Update the status of a topic. */
|
|
48
|
+
async updateTopicStatus(topic, status, modifiedAuthor) {
|
|
49
|
+
const mod = await loadBCF();
|
|
50
|
+
mod.updateTopicStatus(topic, status, modifiedAuthor);
|
|
51
|
+
}
|
|
52
|
+
// --------------------------------------------------------------------------
|
|
53
|
+
// Comments
|
|
54
|
+
// --------------------------------------------------------------------------
|
|
55
|
+
/** Create a new comment. */
|
|
22
56
|
async createComment(options) {
|
|
23
57
|
const mod = await loadBCF();
|
|
24
58
|
return mod.createBCFComment(options);
|
|
25
59
|
}
|
|
26
|
-
/**
|
|
60
|
+
/** Add a comment to a topic. */
|
|
61
|
+
async addComment(topic, comment) {
|
|
62
|
+
const mod = await loadBCF();
|
|
63
|
+
mod.addCommentToTopic(topic, comment);
|
|
64
|
+
}
|
|
65
|
+
// --------------------------------------------------------------------------
|
|
66
|
+
// Viewpoints
|
|
67
|
+
// --------------------------------------------------------------------------
|
|
68
|
+
/** Create a BCF viewpoint from viewer camera/section state. */
|
|
69
|
+
async createViewpoint(options) {
|
|
70
|
+
const mod = await loadBCF();
|
|
71
|
+
if (!options)
|
|
72
|
+
return mod.createViewpoint({});
|
|
73
|
+
// Map SDK's GlobalId (IFC convention) to BCF library's guid-based lists
|
|
74
|
+
const comps = options.components;
|
|
75
|
+
const bcfOptions = {};
|
|
76
|
+
if (options.camera)
|
|
77
|
+
bcfOptions.camera = options.camera;
|
|
78
|
+
if (options.sectionPlane)
|
|
79
|
+
bcfOptions.sectionPlane = options.sectionPlane;
|
|
80
|
+
if (comps?.selection) {
|
|
81
|
+
bcfOptions.selectedGuids = comps.selection.map(c => c.GlobalId);
|
|
82
|
+
}
|
|
83
|
+
if (comps?.visibility) {
|
|
84
|
+
if (comps.visibility.defaultVisibility) {
|
|
85
|
+
// Default visible → exceptions are hidden
|
|
86
|
+
bcfOptions.hiddenGuids = comps.visibility.exceptions?.map(c => c.GlobalId);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Default hidden → exceptions are visible (isolation mode)
|
|
90
|
+
bcfOptions.visibleGuids = comps.visibility.exceptions?.map(c => c.GlobalId);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (comps?.coloring) {
|
|
94
|
+
bcfOptions.coloredGuids = comps.coloring.map(g => ({
|
|
95
|
+
color: g.color,
|
|
96
|
+
guids: g.components.map(c => c.GlobalId),
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
return mod.createViewpoint(bcfOptions);
|
|
100
|
+
}
|
|
101
|
+
/** Add a viewpoint to a topic. */
|
|
102
|
+
async addViewpoint(topic, viewpoint) {
|
|
103
|
+
const mod = await loadBCF();
|
|
104
|
+
mod.addViewpointToTopic(topic, viewpoint);
|
|
105
|
+
}
|
|
106
|
+
/** Extract viewer state from a BCF viewpoint. */
|
|
107
|
+
async extractViewpointState(viewpoint) {
|
|
108
|
+
const mod = await loadBCF();
|
|
109
|
+
return mod.extractViewpointState(viewpoint);
|
|
110
|
+
}
|
|
111
|
+
// --------------------------------------------------------------------------
|
|
112
|
+
// Camera conversion helpers
|
|
113
|
+
// --------------------------------------------------------------------------
|
|
114
|
+
/** Convert viewer camera state to BCF perspective camera. */
|
|
115
|
+
async cameraToPerspective(camera) {
|
|
116
|
+
const mod = await loadBCF();
|
|
117
|
+
return mod.cameraToPerspective(camera);
|
|
118
|
+
}
|
|
119
|
+
/** Convert viewer camera state to BCF orthogonal camera. */
|
|
120
|
+
async cameraToOrthogonal(camera) {
|
|
121
|
+
const mod = await loadBCF();
|
|
122
|
+
return mod.cameraToOrthogonal(camera);
|
|
123
|
+
}
|
|
124
|
+
/** Convert BCF perspective camera to viewer camera state. */
|
|
125
|
+
async perspectiveToCamera(perspective) {
|
|
126
|
+
const mod = await loadBCF();
|
|
127
|
+
return mod.perspectiveToCamera(perspective);
|
|
128
|
+
}
|
|
129
|
+
/** Convert BCF orthogonal camera to viewer camera state. */
|
|
130
|
+
async orthogonalToCamera(orthogonal) {
|
|
131
|
+
const mod = await loadBCF();
|
|
132
|
+
return mod.orthogonalToCamera(orthogonal);
|
|
133
|
+
}
|
|
134
|
+
// --------------------------------------------------------------------------
|
|
135
|
+
// Section plane conversion
|
|
136
|
+
// --------------------------------------------------------------------------
|
|
137
|
+
/** Convert viewer section plane to BCF clipping plane. */
|
|
138
|
+
async sectionPlaneToClippingPlane(section) {
|
|
139
|
+
const mod = await loadBCF();
|
|
140
|
+
return mod.sectionPlaneToClippingPlane(section);
|
|
141
|
+
}
|
|
142
|
+
/** Convert BCF clipping plane to viewer section plane. */
|
|
143
|
+
async clippingPlaneToSectionPlane(clippingPlane) {
|
|
144
|
+
const mod = await loadBCF();
|
|
145
|
+
return mod.clippingPlaneToSectionPlane(clippingPlane);
|
|
146
|
+
}
|
|
147
|
+
// --------------------------------------------------------------------------
|
|
148
|
+
// I/O — Read / Write BCF files
|
|
149
|
+
// --------------------------------------------------------------------------
|
|
150
|
+
/** Read a BCF file (ZIP archive) into a BCF project structure. */
|
|
27
151
|
async read(data) {
|
|
28
152
|
const mod = await loadBCF();
|
|
29
153
|
return mod.readBCF(data);
|
|
30
154
|
}
|
|
31
|
-
/** Write a BCF project to a downloadable Blob. */
|
|
155
|
+
/** Write a BCF project to a downloadable Blob (ZIP archive). */
|
|
32
156
|
async write(project) {
|
|
33
157
|
const mod = await loadBCF();
|
|
34
158
|
return mod.writeBCF(project);
|
|
35
159
|
}
|
|
36
|
-
|
|
37
|
-
|
|
160
|
+
// --------------------------------------------------------------------------
|
|
161
|
+
// IDS → BCF conversion
|
|
162
|
+
// --------------------------------------------------------------------------
|
|
163
|
+
/** Convert an IDS validation report into BCF issues (one topic per failed spec). */
|
|
164
|
+
async createFromIDSReport(report, options) {
|
|
165
|
+
const mod = await loadBCF();
|
|
166
|
+
return mod.createBCFFromIDSReport(report, options);
|
|
167
|
+
}
|
|
168
|
+
// --------------------------------------------------------------------------
|
|
169
|
+
// GUID utilities
|
|
170
|
+
// --------------------------------------------------------------------------
|
|
171
|
+
/** Generate a new IFC GUID (22-char base64). */
|
|
172
|
+
async generateIfcGuid() {
|
|
38
173
|
const mod = await loadBCF();
|
|
39
174
|
return mod.generateIfcGuid();
|
|
40
175
|
}
|
|
176
|
+
/** Generate a new UUID (36-char). */
|
|
177
|
+
async generateUuid() {
|
|
178
|
+
const mod = await loadBCF();
|
|
179
|
+
return mod.generateUuid();
|
|
180
|
+
}
|
|
181
|
+
/** Convert UUID to IFC GUID. */
|
|
182
|
+
async uuidToIfcGuid(uuid) {
|
|
183
|
+
const mod = await loadBCF();
|
|
184
|
+
return mod.uuidToIfcGuid(uuid);
|
|
185
|
+
}
|
|
186
|
+
/** Convert IFC GUID to UUID. */
|
|
187
|
+
async ifcGuidToUuid(guid) {
|
|
188
|
+
const mod = await loadBCF();
|
|
189
|
+
return mod.ifcGuidToUuid(guid);
|
|
190
|
+
}
|
|
191
|
+
/** Validate whether a string is a valid IFC GUID. */
|
|
192
|
+
async isValidIfcGuid(guid) {
|
|
193
|
+
const mod = await loadBCF();
|
|
194
|
+
return mod.isValidIfcGuid(guid);
|
|
195
|
+
}
|
|
196
|
+
/** Validate whether a string is a valid UUID. */
|
|
197
|
+
async isValidUuid(uuid) {
|
|
198
|
+
const mod = await loadBCF();
|
|
199
|
+
return mod.isValidUuid(uuid);
|
|
200
|
+
}
|
|
201
|
+
// --------------------------------------------------------------------------
|
|
202
|
+
// Color utilities
|
|
203
|
+
// --------------------------------------------------------------------------
|
|
204
|
+
/** Parse ARGB hex color string (BCF format) to RGBA values. */
|
|
205
|
+
async parseARGBColor(argb) {
|
|
206
|
+
const mod = await loadBCF();
|
|
207
|
+
return mod.parseARGBColor(argb);
|
|
208
|
+
}
|
|
209
|
+
/** Create ARGB hex color string (BCF format) from RGBA values. */
|
|
210
|
+
async toARGBColor(r, g, b, a) {
|
|
211
|
+
const mod = await loadBCF();
|
|
212
|
+
return mod.toARGBColor(r, g, b, a);
|
|
213
|
+
}
|
|
41
214
|
}
|
|
42
215
|
//# sourceMappingURL=bcf.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bcf.js","sourceRoot":"","sources":["../../src/namespaces/bcf.ts"],"names":[],"mappings":"AAAA;;+DAE+D;
|
|
1
|
+
{"version":3,"file":"bcf.js","sourceRoot":"","sources":["../../src/namespaces/bcf.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAwE/D,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E,KAAK,UAAU,OAAO;IACpB,MAAM,IAAI,GAAG,eAAe,CAAC;IAC7B,OAAO,MAAM,CAAC,yBAAyB,CAAC,IAAI,CAAqC,CAAC;AACpF,CAAC;AAID,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E,6EAA6E;AAC7E,MAAM,OAAO,YAAY;IAEvB,6EAA6E;IAC7E,qBAAqB;IACrB,6EAA6E;IAE7E,gCAAgC;IAChC,KAAK,CAAC,aAAa,CAAC,OAAoD;QACtE,MAAM,GAAG,GAAG,MAAM,OAAO,EAAE,CAAC;QAC5B,OAAQ,GAAG,CAAC,gBAA0B,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,6EAA6E;IAC7E,2BAA2B;IAC3B,6EAA6E;IAE7E,kCAAkC;IAClC,KAAK,CAAC,W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W,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAU;QAC3D,MAAM,GAAG,GAAG,MAAM,OAAO,EAAE,CAAC;QAC5B,OAAQ,GAAG,CAAC,WAAuE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAClG,CAAC;CACF"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bim.bsdd — buildingSMART Data Dictionary (bSDD) integration
|
|
3
|
+
*
|
|
4
|
+
* Provides access to the bSDD REST API for discovering schema-defined
|
|
5
|
+
* property sets, properties, and classifications for IFC entity types.
|
|
6
|
+
*
|
|
7
|
+
* The bSDD is the canonical source for IFC property definitions,
|
|
8
|
+
* quantity sets, and related dictionaries (Uniclass, OmniClass, etc.).
|
|
9
|
+
*
|
|
10
|
+
* @see https://app.swaggerhub.com/apis/buildingSMART/Dictionaries/v1
|
|
11
|
+
*/
|
|
12
|
+
/** A property definition from the bSDD for a given IFC class */
|
|
13
|
+
export interface BsddClassProperty {
|
|
14
|
+
/** Property name, e.g. "IsExternal" */
|
|
15
|
+
name: string;
|
|
16
|
+
/** URI of the property definition */
|
|
17
|
+
uri: string;
|
|
18
|
+
/** Human-readable description */
|
|
19
|
+
description: string | null;
|
|
20
|
+
/** bSDD data type, e.g. "Boolean", "Real", "String" */
|
|
21
|
+
dataType: string | null;
|
|
22
|
+
/** Name of the property set this property belongs to (null = entity attribute) */
|
|
23
|
+
propertySet: string | null;
|
|
24
|
+
/** Allowed values (enum constraints) */
|
|
25
|
+
allowedValues: Array<{
|
|
26
|
+
uri?: string;
|
|
27
|
+
value: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
}> | null;
|
|
30
|
+
/** Units (e.g. ["m"], ["m²"]) */
|
|
31
|
+
units: string[] | null;
|
|
32
|
+
/** Whether this property is from the IFC standard dictionary */
|
|
33
|
+
isIfcStandard: boolean;
|
|
34
|
+
}
|
|
35
|
+
/** Full class information from the bSDD */
|
|
36
|
+
export interface BsddClassInfo {
|
|
37
|
+
/** Class URI */
|
|
38
|
+
uri: string;
|
|
39
|
+
/** IFC entity code, e.g. "IfcWall" */
|
|
40
|
+
code: string;
|
|
41
|
+
/** Human-readable name */
|
|
42
|
+
name: string;
|
|
43
|
+
/** Class description / definition */
|
|
44
|
+
definition: string | null;
|
|
45
|
+
/** Parent class URI */
|
|
46
|
+
parentClassUri: string | null;
|
|
47
|
+
/** Properties defined for this class */
|
|
48
|
+
classProperties: BsddClassProperty[];
|
|
49
|
+
/** Related IFC entity names */
|
|
50
|
+
relatedIfcEntityNames: string[] | null;
|
|
51
|
+
}
|
|
52
|
+
/** Lightweight search result from bSDD */
|
|
53
|
+
export interface BsddSearchResult {
|
|
54
|
+
uri: string;
|
|
55
|
+
code: string;
|
|
56
|
+
name: string;
|
|
57
|
+
definition: string | null;
|
|
58
|
+
dictionaryUri: string;
|
|
59
|
+
}
|
|
60
|
+
export interface BsddOptions {
|
|
61
|
+
/**
|
|
62
|
+
* Base URL for the bSDD API.
|
|
63
|
+
* Default: 'https://api.bsdd.buildingsmart.org'
|
|
64
|
+
*
|
|
65
|
+
* Override this if you use a proxy (e.g. '/api/bsdd' for same-origin proxy).
|
|
66
|
+
*/
|
|
67
|
+
apiBase?: string;
|
|
68
|
+
/** Cache TTL in milliseconds. Default: 600000 (10 minutes) */
|
|
69
|
+
cacheTtlMs?: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* bim.bsdd — buildingSMART Data Dictionary lookup
|
|
73
|
+
*
|
|
74
|
+
* Discover schema-defined properties, quantities, and classifications
|
|
75
|
+
* for any IFC entity type from the bSDD REST API.
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* const info = await bim.bsdd.fetchClassInfo('IfcWall');
|
|
79
|
+
* for (const prop of info.classProperties) {
|
|
80
|
+
* console.log(prop.propertySet, prop.name, prop.dataType);
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare class BsddNamespace {
|
|
85
|
+
private apiBase;
|
|
86
|
+
private cache;
|
|
87
|
+
private cacheTtl;
|
|
88
|
+
constructor(options?: BsddOptions);
|
|
89
|
+
/** Build the bSDD class URI for an IFC entity type. */
|
|
90
|
+
ifcClassUri(ifcType: string): string;
|
|
91
|
+
/** Build the bSDD search URL for an IFC entity type (for browser links). */
|
|
92
|
+
ifcClassUrl(ifcType: string): string;
|
|
93
|
+
/**
|
|
94
|
+
* Fetch full class info (including properties) for an IFC entity type.
|
|
95
|
+
*
|
|
96
|
+
* Results are cached for 10 minutes (configurable).
|
|
97
|
+
* Returns null if the bSDD has no data for this type.
|
|
98
|
+
*/
|
|
99
|
+
fetchClassInfo(ifcType: string): Promise<BsddClassInfo | null>;
|
|
100
|
+
/**
|
|
101
|
+
* Fetch class info by full bSDD URI (not just IFC type name).
|
|
102
|
+
* Useful for non-IFC dictionaries (Uniclass, OmniClass, etc.).
|
|
103
|
+
*/
|
|
104
|
+
fetchClassByUri(classUri: string): Promise<BsddClassInfo | null>;
|
|
105
|
+
/**
|
|
106
|
+
* Search bSDD for classes related to an IFC entity type across all dictionaries.
|
|
107
|
+
*
|
|
108
|
+
* Returns lightweight results. Use `fetchClassByUri()` on a specific result
|
|
109
|
+
* to get full property details.
|
|
110
|
+
*/
|
|
111
|
+
searchRelatedClasses(ifcType: string): Promise<BsddSearchResult[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Free-text search across all bSDD dictionaries.
|
|
114
|
+
*/
|
|
115
|
+
search(query: string): Promise<BsddSearchResult[]>;
|
|
116
|
+
/**
|
|
117
|
+
* Get only the property sets (Pset_*) for an IFC type.
|
|
118
|
+
* Groups properties by their propertySet name.
|
|
119
|
+
*/
|
|
120
|
+
getPropertySets(ifcType: string): Promise<Map<string, BsddClassProperty[]>>;
|
|
121
|
+
/**
|
|
122
|
+
* Get only the quantity sets (Qto_*) for an IFC type.
|
|
123
|
+
* Groups quantities by their propertySet name.
|
|
124
|
+
*/
|
|
125
|
+
getQuantitySets(ifcType: string): Promise<Map<string, BsddClassProperty[]>>;
|
|
126
|
+
/**
|
|
127
|
+
* Get entity-level attributes (properties with no propertySet).
|
|
128
|
+
*/
|
|
129
|
+
getEntityAttributes(ifcType: string): Promise<BsddClassProperty[]>;
|
|
130
|
+
/** Map bSDD dataType string to a human-friendly label. */
|
|
131
|
+
dataTypeLabel(dt: string | null): string;
|
|
132
|
+
/** Clear the bSDD cache. */
|
|
133
|
+
clearCache(): void;
|
|
134
|
+
/** Get cache statistics. */
|
|
135
|
+
cacheStats(): {
|
|
136
|
+
entries: number;
|
|
137
|
+
oldestMs: number;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=bsdd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bsdd.d.ts","sourceRoot":"","sources":["../../src/namespaces/bsdd.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAMH,gEAAgE;AAChE,MAAM,WAAW,iBAAiB;IAChC,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,iCAAiC;IACjC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,uDAAuD;IACvD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,kFAAkF;IAClF,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,wCAAwC;IACxC,aAAa,EAAE,KAAK,CAAC;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;IACnF,iCAAiC;IACjC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACvB,gEAAgE;IAChE,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,2CAA2C;AAC3C,MAAM,WAAW,aA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AAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAiBxE;;OAEG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAqBxD;;;OAGG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAejF;;;OAGG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAejF;;OAEG;IACG,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAUxE,0DAA0D;IAC1D,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM;IAcxC,4BAA4B;IAC5B,UAAU,IAAI,IAAI;IAIlB,4BAA4B;IAC5B,UAAU,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;CAOpD"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Internal cache & helpers
|
|
6
|
+
// ============================================================================
|
|
7
|
+
const IFC_DICTIONARY_URI = 'https://identifier.buildingsmart.org/uri/buildingsmart/ifc/4.3';
|
|
8
|
+
// Cache helpers — operate on instance-scoped cache passed as argument
|
|
9
|
+
function getCached(cache, key, ttl) {
|
|
10
|
+
const entry = cache.get(key);
|
|
11
|
+
if (entry && Date.now() - entry.ts < ttl)
|
|
12
|
+
return entry.data;
|
|
13
|
+
if (entry)
|
|
14
|
+
cache.delete(key);
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
function setCache(cache, key, data) {
|
|
18
|
+
cache.set(key, { data, ts: Date.now() });
|
|
19
|
+
}
|
|
20
|
+
async function fetchJson(url) {
|
|
21
|
+
const res = await fetch(url, {
|
|
22
|
+
headers: { Accept: 'application/json' },
|
|
23
|
+
});
|
|
24
|
+
if (!res.ok)
|
|
25
|
+
throw new Error(`bSDD API ${res.status}: ${res.statusText}`);
|
|
26
|
+
return res.json();
|
|
27
|
+
}
|
|
28
|
+
function mapProperty(p, isIfcStandard) {
|
|
29
|
+
return {
|
|
30
|
+
name: String(p.name ?? p.propertyCode ?? ''),
|
|
31
|
+
uri: String(p.propertyUri ?? p.uri ?? ''),
|
|
32
|
+
description: p.description ? String(p.description) : null,
|
|
33
|
+
dataType: p.dataType ? String(p.dataType) : null,
|
|
34
|
+
propertySet: p.propertySet ? String(p.propertySet) : null,
|
|
35
|
+
allowedValues: Array.isArray(p.allowedValues)
|
|
36
|
+
? p.allowedValues.map((v) => ({
|
|
37
|
+
uri: v.uri ? String(v.uri) : undefined,
|
|
38
|
+
value: String(v.value ?? ''),
|
|
39
|
+
description: v.description ? String(v.description) : undefined,
|
|
40
|
+
}))
|
|
41
|
+
: null,
|
|
42
|
+
units: Array.isArray(p.units) ? p.units : null,
|
|
43
|
+
isIfcStandard,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function mapClassResponse(raw, isIfcStandard) {
|
|
47
|
+
const props = raw.classProperties;
|
|
48
|
+
return {
|
|
49
|
+
uri: String(raw.uri ?? ''),
|
|
50
|
+
code: String(raw.code ?? raw.name ?? ''),
|
|
51
|
+
name: String(raw.name ?? ''),
|
|
52
|
+
definition: raw.definition ? String(raw.definition) : null,
|
|
53
|
+
parentClassUri: raw.parentClassReference
|
|
54
|
+
? String(raw.parentClassReference.uri ?? '')
|
|
55
|
+
: null,
|
|
56
|
+
relatedIfcEntityNames: raw.relatedIfcEntityNames,
|
|
57
|
+
classProperties: (props ?? []).map((p) => mapProperty(p, isIfcStandard)),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// ============================================================================
|
|
61
|
+
// BsddNamespace
|
|
62
|
+
// ============================================================================
|
|
63
|
+
/**
|
|
64
|
+
* bim.bsdd — buildingSMART Data Dictionary lookup
|
|
65
|
+
*
|
|
66
|
+
* Discover schema-defined properties, quantities, and classifications
|
|
67
|
+
* for any IFC entity type from the bSDD REST API.
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* const info = await bim.bsdd.fetchClassInfo('IfcWall');
|
|
71
|
+
* for (const prop of info.classProperties) {
|
|
72
|
+
* console.log(prop.propertySet, prop.name, prop.dataType);
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export class BsddNamespace {
|
|
77
|
+
apiBase;
|
|
78
|
+
cache = new Map();
|
|
79
|
+
cacheTtl;
|
|
80
|
+
constructor(options) {
|
|
81
|
+
this.apiBase = options?.apiBase ?? 'https://api.bsdd.buildingsmart.org';
|
|
82
|
+
this.cacheTtl = options?.cacheTtlMs ?? 10 * 60 * 1000;
|
|
83
|
+
}
|
|
84
|
+
// --------------------------------------------------------------------------
|
|
85
|
+
// URI helpers
|
|
86
|
+
// --------------------------------------------------------------------------
|
|
87
|
+
/** Build the bSDD class URI for an IFC entity type. */
|
|
88
|
+
ifcClassUri(ifcType) {
|
|
89
|
+
return `${IFC_DICTIONARY_URI}/class/${ifcType}`;
|
|
90
|
+
}
|
|
91
|
+
/** Build the bSDD search URL for an IFC entity type (for browser links). */
|
|
92
|
+
ifcClassUrl(ifcType) {
|
|
93
|
+
return `https://search.bsdd.buildingsmart.org/uri/buildingsmart/ifc/4.3/class/${ifcType}`;
|
|
94
|
+
}
|
|
95
|
+
// --------------------------------------------------------------------------
|
|
96
|
+
// Class info
|
|
97
|
+
// --------------------------------------------------------------------------
|
|
98
|
+
/**
|
|
99
|
+
* Fetch full class info (including properties) for an IFC entity type.
|
|
100
|
+
*
|
|
101
|
+
* Results are cached for 10 minutes (configurable).
|
|
102
|
+
* Returns null if the bSDD has no data for this type.
|
|
103
|
+
*/
|
|
104
|
+
async fetchClassInfo(ifcType) {
|
|
105
|
+
const uri = this.ifcClassUri(ifcType);
|
|
106
|
+
const cached = getCached(this.cache, uri, this.cacheTtl);
|
|
107
|
+
if (cached)
|
|
108
|
+
return cached;
|
|
109
|
+
try {
|
|
110
|
+
const raw = await fetchJson(`${this.apiBase}/api/Class/v1?Uri=${encodeURIComponent(uri)}&IncludeClassProperties=true&IncludeClassRelations=true`);
|
|
111
|
+
let info = mapClassResponse(raw, true);
|
|
112
|
+
// Fallback: if inline classProperties came back empty, try paginated endpoint
|
|
113
|
+
if (info.classProperties.length === 0) {
|
|
114
|
+
const propsRaw = await fetchJson(`${this.apiBase}/api/Class/Properties/v1?ClassUri=${encodeURIComponent(uri)}`).catch(() => null);
|
|
115
|
+
if (propsRaw) {
|
|
116
|
+
const propsList = propsRaw.classProperties;
|
|
117
|
+
if (propsList && propsList.length > 0) {
|
|
118
|
+
info = { ...info, classProperties: propsList.map((p) => mapProperty(p, true)) };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
setCache(this.cache, uri, info);
|
|
123
|
+
return info;
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Fetch class info by full bSDD URI (not just IFC type name).
|
|
131
|
+
* Useful for non-IFC dictionaries (Uniclass, OmniClass, etc.).
|
|
132
|
+
*/
|
|
133
|
+
async fetchClassByUri(classUri) {
|
|
134
|
+
const cached = getCached(this.cache, classUri, this.cacheTtl);
|
|
135
|
+
if (cached)
|
|
136
|
+
return cached;
|
|
137
|
+
try {
|
|
138
|
+
const raw = await fetchJson(`${this.apiBase}/api/Class/v1?Uri=${encodeURIComponent(classUri)}&IncludeClassProperties=true`);
|
|
139
|
+
const info = mapClassResponse(raw, false);
|
|
140
|
+
setCache(this.cache, classUri, info);
|
|
141
|
+
return info;
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// --------------------------------------------------------------------------
|
|
148
|
+
// Search
|
|
149
|
+
// --------------------------------------------------------------------------
|
|
150
|
+
/**
|
|
151
|
+
* Search bSDD for classes related to an IFC entity type across all dictionaries.
|
|
152
|
+
*
|
|
153
|
+
* Returns lightweight results. Use `fetchClassByUri()` on a specific result
|
|
154
|
+
* to get full property details.
|
|
155
|
+
*/
|
|
156
|
+
async searchRelatedClasses(ifcType) {
|
|
157
|
+
try {
|
|
158
|
+
const raw = await fetchJson(`${this.apiBase}/api/Class/Search/v1?SearchText=${encodeURIComponent(ifcType)}&RelatedIfcEntities=${encodeURIComponent(ifcType)}`);
|
|
159
|
+
return (raw.classes ?? []).map((c) => ({
|
|
160
|
+
uri: String(c.uri ?? ''),
|
|
161
|
+
code: String(c.code ?? c.name ?? ''),
|
|
162
|
+
name: String(c.name ?? ''),
|
|
163
|
+
definition: c.definition ? String(c.definition) : null,
|
|
164
|
+
dictionaryUri: String(c.dictionaryUri ?? ''),
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Free-text search across all bSDD dictionaries.
|
|
173
|
+
*/
|
|
174
|
+
async search(query) {
|
|
175
|
+
try {
|
|
176
|
+
const raw = await fetchJson(`${this.apiBase}/api/Class/Search/v1?SearchText=${encodeURIComponent(query)}`);
|
|
177
|
+
return (raw.classes ?? []).map((c) => ({
|
|
178
|
+
uri: String(c.uri ?? ''),
|
|
179
|
+
code: String(c.code ?? c.name ?? ''),
|
|
180
|
+
name: String(c.name ?? ''),
|
|
181
|
+
definition: c.definition ? String(c.definition) : null,
|
|
182
|
+
dictionaryUri: String(c.dictionaryUri ?? ''),
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// --------------------------------------------------------------------------
|
|
190
|
+
// Property helpers
|
|
191
|
+
// --------------------------------------------------------------------------
|
|
192
|
+
/**
|
|
193
|
+
* Get only the property sets (Pset_*) for an IFC type.
|
|
194
|
+
* Groups properties by their propertySet name.
|
|
195
|
+
*/
|
|
196
|
+
async getPropertySets(ifcType) {
|
|
197
|
+
const info = await this.fetchClassInfo(ifcType);
|
|
198
|
+
if (!info)
|
|
199
|
+
return new Map();
|
|
200
|
+
const result = new Map();
|
|
201
|
+
for (const prop of info.classProperties) {
|
|
202
|
+
const pset = prop.propertySet;
|
|
203
|
+
if (!pset || pset.startsWith('Qto_'))
|
|
204
|
+
continue;
|
|
205
|
+
const list = result.get(pset);
|
|
206
|
+
if (list)
|
|
207
|
+
list.push(prop);
|
|
208
|
+
else
|
|
209
|
+
result.set(pset, [prop]);
|
|
210
|
+
}
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get only the quantity sets (Qto_*) for an IFC type.
|
|
215
|
+
* Groups quantities by their propertySet name.
|
|
216
|
+
*/
|
|
217
|
+
async getQuantitySets(ifcType) {
|
|
218
|
+
const info = await this.fetchClassInfo(ifcType);
|
|
219
|
+
if (!info)
|
|
220
|
+
return new Map();
|
|
221
|
+
const result = new Map();
|
|
222
|
+
for (const prop of info.classProperties) {
|
|
223
|
+
const pset = prop.propertySet;
|
|
224
|
+
if (!pset || !pset.startsWith('Qto_'))
|
|
225
|
+
continue;
|
|
226
|
+
const list = result.get(pset);
|
|
227
|
+
if (list)
|
|
228
|
+
list.push(prop);
|
|
229
|
+
else
|
|
230
|
+
result.set(pset, [prop]);
|
|
231
|
+
}
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Get entity-level attributes (properties with no propertySet).
|
|
236
|
+
*/
|
|
237
|
+
async getEntityAttributes(ifcType) {
|
|
238
|
+
const info = await this.fetchClassInfo(ifcType);
|
|
239
|
+
if (!info)
|
|
240
|
+
return [];
|
|
241
|
+
return info.classProperties.filter((p) => p.propertySet === null);
|
|
242
|
+
}
|
|
243
|
+
// --------------------------------------------------------------------------
|
|
244
|
+
// Data type helpers
|
|
245
|
+
// --------------------------------------------------------------------------
|
|
246
|
+
/** Map bSDD dataType string to a human-friendly label. */
|
|
247
|
+
dataTypeLabel(dt) {
|
|
248
|
+
if (!dt)
|
|
249
|
+
return 'String';
|
|
250
|
+
const lower = dt.toLowerCase();
|
|
251
|
+
if (lower === 'boolean')
|
|
252
|
+
return 'Boolean';
|
|
253
|
+
if (lower === 'real' || lower === 'number')
|
|
254
|
+
return 'Real';
|
|
255
|
+
if (lower === 'integer')
|
|
256
|
+
return 'Integer';
|
|
257
|
+
if (lower === 'string' || lower === 'character')
|
|
258
|
+
return 'String';
|
|
259
|
+
return dt;
|
|
260
|
+
}
|
|
261
|
+
// --------------------------------------------------------------------------
|
|
262
|
+
// Cache management
|
|
263
|
+
// --------------------------------------------------------------------------
|
|
264
|
+
/** Clear the bSDD cache. */
|
|
265
|
+
clearCache() {
|
|
266
|
+
this.cache.clear();
|
|
267
|
+
}
|
|
268
|
+
/** Get cache statistics. */
|
|
269
|
+
cacheStats() {
|
|
270
|
+
let oldest = Date.now();
|
|
271
|
+
for (const entry of this.cache.values()) {
|
|
272
|
+
if (entry.ts < oldest)
|
|
273
|
+
oldest = entry.ts;
|
|
274
|
+
}
|
|
275
|
+
return { entries: this.cache.size, oldestMs: this.cache.size > 0 ? Date.now() - oldest : 0 };
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=bsdd.js.map
|