@ifc-lite/codegen 1.15.3 → 1.15.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.
Files changed (41) hide show
  1. package/README.md +17 -14
  2. package/dist/serialization-generator.d.ts +7 -2
  3. package/dist/serialization-generator.d.ts.map +1 -1
  4. package/dist/serialization-generator.js +30 -301
  5. package/dist/serialization-generator.js.map +1 -1
  6. package/package.json +18 -7
  7. package/.turbo/turbo-build.log +0 -4
  8. package/CHANGELOG.md +0 -117
  9. package/INTEGRATION.md +0 -354
  10. package/generated/ifc4/entities.ts +0 -7400
  11. package/generated/ifc4/enums.ts +0 -2467
  12. package/generated/ifc4/index.ts +0 -17
  13. package/generated/ifc4/schema-registry.ts +0 -63186
  14. package/generated/ifc4/selects.ts +0 -315
  15. package/generated/ifc4/serializers.ts +0 -322
  16. package/generated/ifc4/test-compile.ts +0 -49
  17. package/generated/ifc4/type-ids.ts +0 -1682
  18. package/generated/ifc4/types.ts +0 -401
  19. package/generated/ifc4x3/entities.ts +0 -8300
  20. package/generated/ifc4x3/enums.ts +0 -3096
  21. package/generated/ifc4x3/index.ts +0 -17
  22. package/generated/ifc4x3/schema-registry.ts +0 -71489
  23. package/generated/ifc4x3/selects.ts +0 -312
  24. package/generated/ifc4x3/serializers.ts +0 -322
  25. package/generated/ifc4x3/test-compile.ts +0 -49
  26. package/generated/ifc4x3/type-ids.ts +0 -1882
  27. package/generated/ifc4x3/types.ts +0 -407
  28. package/src/cli.ts +0 -72
  29. package/src/crc32.ts +0 -77
  30. package/src/express-parser.ts +0 -457
  31. package/src/generator.ts +0 -268
  32. package/src/index.ts +0 -57
  33. package/src/rust-generator.ts +0 -714
  34. package/src/serialization-generator.ts +0 -343
  35. package/src/type-ids-generator.ts +0 -166
  36. package/src/typescript-generator.ts +0 -631
  37. package/test/express-parser.test.ts +0 -363
  38. package/test/integration.test.ts +0 -246
  39. package/test/typescript-generator.test.ts +0 -348
  40. package/tsconfig.json +0 -21
  41. package/vitest.config.ts +0 -18
@@ -1,315 +0,0 @@
1
- /**
2
- * IFC SELECT Types (Unions)
3
- * Generated from EXPRESS schema: IFC4_ADD2_TC1
4
- *
5
- * DO NOT EDIT - This file is auto-generated
6
- */
7
-
8
- import type {
9
- IfcActorRole,
10
- IfcAddress,
11
- IfcAppliedValue,
12
- IfcApproval,
13
- IfcAxis2Placement2D,
14
- IfcAxis2Placement3D,
15
- IfcBooleanResult,
16
- IfcBoundedCurve,
17
- IfcCartesianPoint,
18
- IfcClassification,
19
- IfcClassificationReference,
20
- IfcClosedShell,
21
- IfcColourRgb,
22
- IfcColourSpecification,
23
- IfcCompositeCurveOnSurface,
24
- IfcConstraint,
25
- IfcContextDependentUnit,
26
- IfcConversionBasedUnit,
27
- IfcCoordinateReferenceSystem,
28
- IfcCsgPrimitive3D,
29
- IfcCurve,
30
- IfcCurveStyle,
31
- IfcCurveStyleFont,
32
- IfcCurveStyleFontAndScaling,
33
- IfcDerivedUnit,
34
- IfcDirection,
35
- IfcDocumentInformation,
36
- IfcDocumentReference,
37
- IfcEdgeCurve,
38
- IfcElement,
39
- IfcExternalInformation,
40
- IfcExternalReference,
41
- IfcExternalSpatialElement,
42
- IfcExternallyDefinedHatchStyle,
43
- IfcExternallyDefinedSurfaceStyle,
44
- IfcExternallyDefinedTextFont,
45
- IfcFaceBasedSurfaceModel,
46
- IfcFaceSurface,
47
- IfcFillAreaStyle,
48
- IfcFillAreaStyleHatching,
49
- IfcFillAreaStyleTiles,
50
- IfcGeometricRepresentationContext,
51
- IfcHalfSpaceSolid,
52
- IfcLibraryInformation,
53
- IfcLibraryReference,
54
- IfcLightIntensityDistribution,
55
- IfcMaterialDefinition,
56
- IfcMaterialList,
57
- IfcMaterialUsageDefinition,
58
- IfcMeasureWithUnit,
59
- IfcMonetaryUnit,
60
- IfcNamedUnit,
61
- IfcObjectDefinition,
62
- IfcOpenShell,
63
- IfcOrganization,
64
- IfcPcurve,
65
- IfcPerson,
66
- IfcPersonAndOrganization,
67
- IfcPhysicalQuantity,
68
- IfcPoint,
69
- IfcPreDefinedColour,
70
- IfcPreDefinedCurveFont,
71
- IfcPreDefinedTextFont,
72
- IfcPresentationStyle,
73
- IfcPresentationStyleAssignment,
74
- IfcProcess,
75
- IfcProduct,
76
- IfcProductDefinitionShape,
77
- IfcProfileDef,
78
- IfcPropertyAbstraction,
79
- IfcPropertyDefinition,
80
- IfcPropertySetDefinition,
81
- IfcReference,
82
- IfcRepresentation,
83
- IfcRepresentationItem,
84
- IfcRepresentationMap,
85
- IfcResource,
86
- IfcSolidModel,
87
- IfcSpace,
88
- IfcStructuralItem,
89
- IfcSurface,
90
- IfcSurfaceCurve,
91
- IfcSurfaceStyle,
92
- IfcSurfaceStyleLighting,
93
- IfcSurfaceStyleRefraction,
94
- IfcSurfaceStyleShading,
95
- IfcSurfaceStyleWithTextures,
96
- IfcTable,
97
- IfcTessellatedFaceSet,
98
- IfcTextStyle,
99
- IfcTimeSeries,
100
- IfcTypeProcess,
101
- IfcTypeProduct,
102
- IfcTypeResource,
103
- IfcVector,
104
- IfcVertexPoint,
105
- IfcVirtualGridIntersection,
106
- } from './entities.js';
107
-
108
- import type {
109
- IfcArcIndex,
110
- IfcBinary,
111
- IfcBoolean,
112
- IfcComplexNumber,
113
- IfcDate,
114
- IfcDateTime,
115
- IfcDuration,
116
- IfcIdentifier,
117
- IfcInteger,
118
- IfcLabel,
119
- IfcLineIndex,
120
- IfcLogical,
121
- IfcParameterValue,
122
- IfcPositiveInteger,
123
- IfcPropertySetDefinitionSet,
124
- IfcReal,
125
- IfcSpecularExponent,
126
- IfcSpecularRoughness,
127
- IfcText,
128
- IfcTime,
129
- IfcTimeStamp,
130
- } from './types.js';
131
-
132
- import type {
133
- IfcNullStyle,
134
- } from './enums.js';
135
-
136
- /** IfcActorSelect */
137
- export type IfcActorSelect = IfcOrganization | IfcPerson | IfcPersonAndOrganization;
138
-
139
- /** IfcAppliedValueSelect */
140
- export type IfcAppliedValueSelect = IfcMeasureWithUnit | IfcReference | IfcValue;
141
-
142
- /** IfcAxis2Placement */
143
- export type IfcAxis2Placement = IfcAxis2Placement2D | IfcAxis2Placement3D;
144
-
145
- /** IfcBendingParameterSelect */
146
- export type IfcBendingParameterSelect = number | number;
147
-
148
- /** IfcBooleanOperand */
149
- export type IfcBooleanOperand = IfcBooleanResult | IfcCsgPrimitive3D | IfcHalfSpaceSolid | IfcSolidModel | IfcTessellatedFaceSet;
150
-
151
- /** IfcClassificationReferenceSelect */
152
- export type IfcClassificationReferenceSelect = IfcClassification | IfcClassificationReference;
153
-
154
- /** IfcClassificationSelect */
155
- export type IfcClassificationSelect = IfcClassification | IfcClassificationReference;
156
-
157
- /** IfcColour */
158
- export type IfcColour = IfcColourSpecification | IfcPreDefinedColour;
159
-
160
- /** IfcColourOrFactor */
161
- export type IfcColourOrFactor = IfcColourRgb | number;
162
-
163
- /** IfcCoordinateReferenceSystemSelect */
164
- export type IfcCoordinateReferenceSystemSelect = IfcCoordinateReferenceSystem | IfcGeometricRepresentationContext;
165
-
166
- /** IfcCsgSelect */
167
- export type IfcCsgSelect = IfcBooleanResult | IfcCsgPrimitive3D;
168
-
169
- /** IfcCurveFontOrScaledCurveFontSelect */
170
- export type IfcCurveFontOrScaledCurveFontSelect = IfcCurveStyleFontAndScaling | IfcCurveStyleFontSelect;
171
-
172
- /** IfcCurveOnSurface */
173
- export type IfcCurveOnSurface = IfcCompositeCurveOnSurface | IfcPcurve | IfcSurfaceCurve;
174
-
175
- /** IfcCurveOrEdgeCurve */
176
- export type IfcCurveOrEdgeCurve = IfcBoundedCurve | IfcEdgeCurve;
177
-
178
- /** IfcCurveStyleFontSelect */
179
- export type IfcCurveStyleFontSelect = IfcCurveStyleFont | IfcPreDefinedCurveFont;
180
-
181
- /** IfcDefinitionSelect */
182
- export type IfcDefinitionSelect = IfcObjectDefinition | IfcPropertyDefinition;
183
-
184
- /** IfcDerivedMeasureValue */
185
- export type IfcDerivedMeasureValue = number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number | number;
186
-
187
- /** IfcDocumentSelect */
188
- export type IfcDocumentSelect = IfcDocumentInformation | IfcDocumentReference;
189
-
190
- /** IfcFillStyleSelect */
191
- export type IfcFillStyleSelect = IfcColour | IfcExternallyDefinedHatchStyle | IfcFillAreaStyleHatching | IfcFillAreaStyleTiles;
192
-
193
- /** IfcGeometricSetSelect */
194
- export type IfcGeometricSetSelect = IfcCurve | IfcPoint | IfcSurface;
195
-
196
- /** IfcGridPlacementDirectionSelect */
197
- export type IfcGridPlacementDirectionSelect = IfcDirection | IfcVirtualGridIntersection;
198
-
199
- /** IfcHatchLineDistanceSelect */
200
- export type IfcHatchLineDistanceSelect = number | IfcVector;
201
-
202
- /** IfcLayeredItem */
203
- export type IfcLayeredItem = IfcRepresentation | IfcRepresentationItem;
204
-
205
- /** IfcLibrarySelect */
206
- export type IfcLibrarySelect = IfcLibraryInformation | IfcLibraryReference;
207
-
208
- /** IfcLightDistributionDataSourceSelect */
209
- export type IfcLightDistributionDataSourceSelect = IfcExternalReference | IfcLightIntensityDistribution;
210
-
211
- /** IfcMaterialSelect */
212
- export type IfcMaterialSelect = IfcMaterialDefinition | IfcMaterialList | IfcMaterialUsageDefinition;
213
-
214
- /** IfcMeasureValue */
215
- export type IfcMeasureValue = number | number | IfcComplexNumber | number | number | number | number | number | number | number | number | number | number | IfcParameterValue | number | number | number | number | number | number | number | number | number;
216
-
217
- /** IfcMetricValueSelect */
218
- export type IfcMetricValueSelect = IfcAppliedValue | IfcMeasureWithUnit | IfcReference | IfcTable | IfcTimeSeries | IfcValue;
219
-
220
- /** IfcModulusOfRotationalSubgradeReactionSelect */
221
- export type IfcModulusOfRotationalSubgradeReactionSelect = IfcBoolean | number;
222
-
223
- /** IfcModulusOfSubgradeReactionSelect */
224
- export type IfcModulusOfSubgradeReactionSelect = IfcBoolean | number;
225
-
226
- /** IfcModulusOfTranslationalSubgradeReactionSelect */
227
- export type IfcModulusOfTranslationalSubgradeReactionSelect = IfcBoolean | number;
228
-
229
- /** IfcObjectReferenceSelect */
230
- export type IfcObjectReferenceSelect = IfcAddress | IfcAppliedValue | IfcExternalReference | IfcMaterialDefinition | IfcOrganization | IfcPerson | IfcPersonAndOrganization | IfcTable | IfcTimeSeries;
231
-
232
- /** IfcPointOrVertexPoint */
233
- export type IfcPointOrVertexPoint = IfcPoint | IfcVertexPoint;
234
-
235
- /** IfcPresentationStyleSelect */
236
- export type IfcPresentationStyleSelect = IfcCurveStyle | IfcFillAreaStyle | IfcNullStyle | IfcSurfaceStyle | IfcTextStyle;
237
-
238
- /** IfcProcessSelect */
239
- export type IfcProcessSelect = IfcProcess | IfcTypeProcess;
240
-
241
- /** IfcProductRepresentationSelect */
242
- export type IfcProductRepresentationSelect = IfcProductDefinitionShape | IfcRepresentationMap;
243
-
244
- /** IfcProductSelect */
245
- export type IfcProductSelect = IfcProduct | IfcTypeProduct;
246
-
247
- /** IfcPropertySetDefinitionSelect */
248
- export type IfcPropertySetDefinitionSelect = IfcPropertySetDefinition | IfcPropertySetDefinitionSet;
249
-
250
- /** IfcResourceObjectSelect */
251
- export type IfcResourceObjectSelect = IfcActorRole | IfcAppliedValue | IfcApproval | IfcConstraint | IfcContextDependentUnit | IfcConversionBasedUnit | IfcExternalInformation | IfcExternalReference | IfcMaterialDefinition | IfcOrganization | IfcPerson | IfcPersonAndOrganization | IfcPhysicalQuantity | IfcProfileDef | IfcPropertyAbstraction | IfcTimeSeries;
252
-
253
- /** IfcResourceSelect */
254
- export type IfcResourceSelect = IfcResource | IfcTypeResource;
255
-
256
- /** IfcRotationalStiffnessSelect */
257
- export type IfcRotationalStiffnessSelect = IfcBoolean | number;
258
-
259
- /** IfcSegmentIndexSelect */
260
- export type IfcSegmentIndexSelect = IfcArcIndex | IfcLineIndex;
261
-
262
- /** IfcShell */
263
- export type IfcShell = IfcClosedShell | IfcOpenShell;
264
-
265
- /** IfcSimpleValue */
266
- export type IfcSimpleValue = IfcBinary | IfcBoolean | IfcDate | IfcDateTime | IfcDuration | IfcIdentifier | IfcInteger | IfcLabel | IfcLogical | IfcPositiveInteger | IfcReal | IfcText | IfcTime | IfcTimeStamp;
267
-
268
- /** IfcSizeSelect */
269
- export type IfcSizeSelect = number | number | number | number | number | number;
270
-
271
- /** IfcSolidOrShell */
272
- export type IfcSolidOrShell = IfcClosedShell | IfcSolidModel;
273
-
274
- /** IfcSpaceBoundarySelect */
275
- export type IfcSpaceBoundarySelect = IfcExternalSpatialElement | IfcSpace;
276
-
277
- /** IfcSpecularHighlightSelect */
278
- export type IfcSpecularHighlightSelect = IfcSpecularExponent | IfcSpecularRoughness;
279
-
280
- /** IfcStructuralActivityAssignmentSelect */
281
- export type IfcStructuralActivityAssignmentSelect = IfcElement | IfcStructuralItem;
282
-
283
- /** IfcStyleAssignmentSelect */
284
- export type IfcStyleAssignmentSelect = IfcPresentationStyle | IfcPresentationStyleAssignment;
285
-
286
- /** IfcSurfaceOrFaceSurface */
287
- export type IfcSurfaceOrFaceSurface = IfcFaceBasedSurfaceModel | IfcFaceSurface | IfcSurface;
288
-
289
- /** IfcSurfaceStyleElementSelect */
290
- export type IfcSurfaceStyleElementSelect = IfcExternallyDefinedSurfaceStyle | IfcSurfaceStyleLighting | IfcSurfaceStyleRefraction | IfcSurfaceStyleShading | IfcSurfaceStyleWithTextures;
291
-
292
- /** IfcTextFontSelect */
293
- export type IfcTextFontSelect = IfcExternallyDefinedTextFont | IfcPreDefinedTextFont;
294
-
295
- /** IfcTimeOrRatioSelect */
296
- export type IfcTimeOrRatioSelect = IfcDuration | number;
297
-
298
- /** IfcTranslationalStiffnessSelect */
299
- export type IfcTranslationalStiffnessSelect = IfcBoolean | number;
300
-
301
- /** IfcTrimmingSelect */
302
- export type IfcTrimmingSelect = IfcCartesianPoint | IfcParameterValue;
303
-
304
- /** IfcUnit */
305
- export type IfcUnit = IfcDerivedUnit | IfcMonetaryUnit | IfcNamedUnit;
306
-
307
- /** IfcValue */
308
- export type IfcValue = IfcDerivedMeasureValue | IfcMeasureValue | IfcSimpleValue;
309
-
310
- /** IfcVectorOrDirection */
311
- export type IfcVectorOrDirection = IfcDirection | IfcVector;
312
-
313
- /** IfcWarpingStiffnessSelect */
314
- export type IfcWarpingStiffnessSelect = IfcBoolean | number;
315
-
@@ -1,322 +0,0 @@
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
- /**
6
- * IFC Serialization Support
7
- * Generated from EXPRESS schema: IFC4_ADD2_TC1
8
- *
9
- * Utilities for serializing IFC entities to STEP format.
10
- *
11
- * DO NOT EDIT - This file is auto-generated
12
- */
13
-
14
- import { SCHEMA_REGISTRY } from './schema-registry.js';
15
-
16
- /**
17
- * STEP value types
18
- */
19
- export type StepValue =
20
- | string
21
- | number
22
- | boolean
23
- | null
24
- | undefined
25
- | StepValue[]
26
- | EntityRef
27
- | EnumValue;
28
-
29
- /**
30
- * Entity reference (#123)
31
- */
32
- export interface EntityRef {
33
- ref: number;
34
- }
35
-
36
- /**
37
- * Enum value (.VALUE.)
38
- */
39
- export interface EnumValue {
40
- enum: string;
41
- }
42
-
43
- /**
44
- * Check if value is an entity reference
45
- */
46
- export function isEntityRef(value: unknown): value is EntityRef {
47
- return typeof value === 'object' && value !== null && 'ref' in value;
48
- }
49
-
50
- /**
51
- * Check if value is an enum value
52
- */
53
- export function isEnumValue(value: unknown): value is EnumValue {
54
- return typeof value === 'object' && value !== null && 'enum' in value;
55
- }
56
-
57
- /**
58
- * Create an entity reference
59
- */
60
- export function ref(id: number): EntityRef {
61
- return { ref: id };
62
- }
63
-
64
- /**
65
- * Create an enum value
66
- */
67
- export function enumVal(value: string): EnumValue {
68
- return { enum: value };
69
- }
70
-
71
- /**
72
- * Base interface for serializable entities
73
- */
74
- export interface StepEntity {
75
- /** Express ID (#123) */
76
- expressId: number;
77
- /** IFC type name */
78
- type: string;
79
- /** Attribute values */
80
- [key: string]: unknown;
81
- }
82
-
83
- /**
84
- * Serialize a single value to STEP format
85
- */
86
- export function serializeValue(value: StepValue): string {
87
- // Null/undefined -> $
88
- if (value === null || value === undefined) {
89
- return '$';
90
- }
91
-
92
- // Derived value -> *
93
- if (value === '*') {
94
- return '*';
95
- }
96
-
97
- // Boolean
98
- if (typeof value === 'boolean') {
99
- return value ? '.T.' : '.F.';
100
- }
101
-
102
- // Number
103
- if (typeof value === 'number') {
104
- if (!Number.isFinite(value)) {
105
- return '$';
106
- }
107
- // Use exponential notation for large/small numbers
108
- if (Math.abs(value) > 1e10 || (Math.abs(value) < 1e-10 && value !== 0)) {
109
- return value.toExponential(10).toUpperCase().replace('E+', 'E');
110
- }
111
- // Otherwise use fixed notation
112
- const str = value.toString();
113
- // Ensure there's a decimal point for REAL values
114
- return str.includes('.') ? str : str + '.';
115
- }
116
-
117
- // String
118
- if (typeof value === 'string') {
119
- return "'" + escapeStepString(value) + "'";
120
- }
121
-
122
- // Entity reference
123
- if (isEntityRef(value)) {
124
- return '#' + value.ref;
125
- }
126
-
127
- // Enum value
128
- if (isEnumValue(value)) {
129
- return '.' + value.enum + '.';
130
- }
131
-
132
- // Array/List
133
- if (Array.isArray(value)) {
134
- if (value.length === 0) {
135
- return '()';
136
- }
137
- return '(' + value.map(v => serializeValue(v as StepValue)).join(',') + ')';
138
- }
139
-
140
- // Object (shouldn't happen for valid STEP values)
141
- return '$';
142
- }
143
-
144
- /**
145
- * Escape a string for STEP format
146
- */
147
- function escapeStepString(str: string): string {
148
- return str
149
- .replace(/\\/g, '\\\\') // Backslash
150
- .replace(/'/g, "''"); // Single quote
151
- }
152
-
153
- /**
154
- * Serialize an entity to a STEP line
155
- */
156
- export function toStepLine(entity: StepEntity): string {
157
- const schema = SCHEMA_REGISTRY.entities[entity.type];
158
- if (!schema) {
159
- throw new Error(`Unknown entity type: ${entity.type}`);
160
- }
161
-
162
- // Get all attributes in order
163
- const values: string[] = [];
164
- for (const attr of schema.allAttributes) {
165
- const value = entity[attr.name];
166
- values.push(serializeValue(value as StepValue));
167
- }
168
-
169
- return `#${entity.expressId}=${entity.type.toUpperCase()}(${values.join(',')});`;
170
- }
171
-
172
- /**
173
- * Generate STEP file header
174
- */
175
- export function generateHeader(options: {
176
- description?: string;
177
- author?: string;
178
- organization?: string;
179
- application?: string;
180
- schema: 'IFC2X3' | 'IFC4' | 'IFC4X3' | 'IFC5';
181
- filename?: string;
182
- }): string {
183
- const now = new Date().toISOString().replace(/[-:]/g, '').split('.')[0];
184
- const desc = options.description || 'ViewDefinition [CoordinationView]';
185
- const author = options.author || '';
186
- const org = options.organization || '';
187
- const app = options.application || 'ifc-lite';
188
- const filename = options.filename || 'output.ifc';
189
-
190
- return `ISO-10303-21;
191
- HEADER;
192
- FILE_DESCRIPTION('${desc}','2;1');
193
- FILE_NAME('${filename}','${now}',('${author}'),('${org}'),'${app}','${app}','');
194
- FILE_SCHEMA(('${options.schema}'));
195
- ENDSEC;
196
- `;
197
- }
198
-
199
- /**
200
- * Generate complete STEP file content
201
- */
202
- export function generateStepFile(
203
- entities: StepEntity[],
204
- options: Parameters<typeof generateHeader>[0]
205
- ): string {
206
- const header = generateHeader(options);
207
-
208
- // Sort entities by ID for deterministic output
209
- const sorted = [...entities].sort((a, b) => a.expressId - b.expressId);
210
-
211
- const data = sorted.map(e => toStepLine(e)).join('\n');
212
-
213
- return `${header}DATA;
214
- ${data}
215
- ENDSEC;
216
- END-ISO-10303-21;
217
- `;
218
- }
219
-
220
- /**
221
- * Parse a STEP value from string
222
- */
223
- export function parseStepValue(str: string): StepValue {
224
- str = str.trim();
225
-
226
- // Null
227
- if (str === '$') {
228
- return null;
229
- }
230
-
231
- // Derived
232
- if (str === '*') {
233
- return '*' as unknown as StepValue;
234
- }
235
-
236
- // Boolean
237
- if (str === '.T.') {
238
- return true;
239
- }
240
- if (str === '.F.') {
241
- return false;
242
- }
243
- if (str === '.U.') {
244
- return null; // Unknown/indeterminate
245
- }
246
-
247
- // Entity reference
248
- if (str.startsWith('#')) {
249
- return { ref: parseInt(str.substring(1), 10) };
250
- }
251
-
252
- // Enum
253
- if (str.startsWith('.') && str.endsWith('.')) {
254
- return { enum: str.substring(1, str.length - 1) };
255
- }
256
-
257
- // String
258
- if (str.startsWith("'") && str.endsWith("'")) {
259
- return unescapeStepString(str.substring(1, str.length - 1));
260
- }
261
-
262
- // List
263
- if (str.startsWith('(') && str.endsWith(')')) {
264
- return parseStepList(str);
265
- }
266
-
267
- // Number
268
- const num = parseFloat(str);
269
- if (!isNaN(num)) {
270
- return num;
271
- }
272
-
273
- // Unknown
274
- return str;
275
- }
276
-
277
- /**
278
- * Parse a STEP list
279
- */
280
- function parseStepList(str: string): StepValue[] {
281
- // Remove outer parentheses
282
- const inner = str.substring(1, str.length - 1).trim();
283
- if (inner === '') {
284
- return [];
285
- }
286
-
287
- const values: StepValue[] = [];
288
- let depth = 0;
289
- let current = '';
290
-
291
- for (let i = 0; i < inner.length; i++) {
292
- const char = inner[i];
293
-
294
- if (char === '(' || char === '[') {
295
- depth++;
296
- current += char;
297
- } else if (char === ')' || char === ']') {
298
- depth--;
299
- current += char;
300
- } else if (char === ',' && depth === 0) {
301
- values.push(parseStepValue(current));
302
- current = '';
303
- } else {
304
- current += char;
305
- }
306
- }
307
-
308
- if (current.trim()) {
309
- values.push(parseStepValue(current));
310
- }
311
-
312
- return values;
313
- }
314
-
315
- /**
316
- * Unescape a STEP string
317
- */
318
- function unescapeStepString(str: string): string {
319
- return str
320
- .replace(/''/g, "'")
321
- .replace(/\\\\/g, '\\');
322
- }
@@ -1,49 +0,0 @@
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
- /**
6
- * Type-check test file
7
- * This file is used to verify the generated types compile correctly.
8
- *
9
- * DO NOT EDIT - This file is auto-generated
10
- */
11
-
12
- import type { IfcWall, IfcProject, IfcExtrudedAreaSolid } from './entities.js';
13
- import { TYPE_IDS, getTypeId, getTypeName } from './type-ids.js';
14
- import { SCHEMA_REGISTRY, getEntityMetadata } from './schema-registry.js';
15
- import { toStepLine, serializeValue, ref, enumVal, type StepEntity } from './serializers.js';
16
-
17
- // Test type IDs
18
- const wallId: number = TYPE_IDS.IfcWall;
19
- const projectId: number = TYPE_IDS.IfcProject;
20
-
21
- // Test ID lookup
22
- const wallIdFromName = getTypeId('IfcWall');
23
- const nameFromId = getTypeName(wallId);
24
-
25
- // Test schema registry
26
- const wallMeta = getEntityMetadata('IfcWall');
27
- const wallAttrs = wallMeta?.allAttributes;
28
-
29
- // Test serialization
30
- const testEntity: StepEntity = {
31
- expressId: 1,
32
- type: 'IfcProject',
33
- GlobalId: '0YvctVUKr0kugbFTf53O9L',
34
- OwnerHistory: ref(2),
35
- Name: 'Test Project',
36
- Description: null,
37
- ObjectType: null,
38
- LongName: null,
39
- Phase: null,
40
- RepresentationContexts: [ref(3)],
41
- UnitsInContext: ref(4),
42
- };
43
-
44
- const stepLine = toStepLine(testEntity);
45
-
46
- console.log('✓ All types compile correctly');
47
- console.log(' Wall ID:', wallId);
48
- console.log(' Project ID:', projectId);
49
- console.log(' STEP line:', stepLine);