@ifc-lite/create 2.6.0 → 2.7.0
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 +8 -0
- package/dist/cost-authoring-rules.d.ts +70 -0
- package/dist/cost-authoring-rules.d.ts.map +1 -0
- package/dist/cost-authoring-rules.js +118 -0
- package/dist/cost-authoring-rules.js.map +1 -0
- package/dist/ifc-creator-cost.d.ts +3 -14
- package/dist/ifc-creator-cost.d.ts.map +1 -1
- package/dist/ifc-creator-cost.js +4 -62
- package/dist/ifc-creator-cost.js.map +1 -1
- package/dist/in-store/cost-nesting-cycle.d.ts +8 -0
- package/dist/in-store/cost-nesting-cycle.d.ts.map +1 -0
- package/dist/in-store/cost-nesting-cycle.js +28 -0
- package/dist/in-store/cost-nesting-cycle.js.map +1 -0
- package/dist/in-store/cost-reference-validation.d.ts +13 -0
- package/dist/in-store/cost-reference-validation.d.ts.map +1 -0
- package/dist/in-store/cost-reference-validation.js +49 -0
- package/dist/in-store/cost-reference-validation.js.map +1 -0
- package/dist/in-store/cost-removal.d.ts +40 -0
- package/dist/in-store/cost-removal.d.ts.map +1 -0
- package/dist/in-store/cost-removal.js +107 -0
- package/dist/in-store/cost-removal.js.map +1 -0
- package/dist/in-store/cost.d.ts +109 -0
- package/dist/in-store/cost.d.ts.map +1 -0
- package/dist/in-store/cost.js +323 -0
- package/dist/in-store/cost.js.map +1 -0
- package/dist/in-store/resolve-source.d.ts.map +1 -1
- package/dist/in-store/resolve-source.js +11 -8
- package/dist/in-store/resolve-source.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/types-cost.d.ts +2 -2
- package/dist/types-cost.d.ts.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -29,6 +29,14 @@ const { content } = creator.toIfc(); // IFC STEP text
|
|
|
29
29
|
- Property sets, element quantities, materials, and colors
|
|
30
30
|
- 4D scheduling entities: IfcWorkSchedule, IfcTask, IfcRelSequence
|
|
31
31
|
- In-store builders (`addWallToStore`, `addSlabToStore`, ...) that emit elements into an existing parsed model
|
|
32
|
+
- Loaded-model cost builders (`addCostScheduleToStore`, `addCostItemToStore`, `addCostValueToStore`,
|
|
33
|
+
`addCostQuantityToStore`) plus relationship helpers for nesting, schedule/object assignment, value lists,
|
|
34
|
+
and safe removal. They require a `CostAnchor` for schema/owner-history/GUID allocation, accept existing
|
|
35
|
+
relationship maps from the host, reject IFC2X3 authoring, and make destructive removal explicit with
|
|
36
|
+
`{ detach: true }` when surviving references must be rewritten. Removal referrer data distinguishes
|
|
37
|
+
required relationship endpoints (whose relationship is deleted) from optional scalar and list
|
|
38
|
+
attributes on non-relationship owners. Optional scalars are rewritten to `$`; optional lists retain
|
|
39
|
+
their surviving members, or become `$` when emptied, so detaching a cost value never deletes its owner.
|
|
32
40
|
- Space generation: `generateSpacesFromWalls` and `detectEnclosedAreas` derive IfcSpace footprints from wall layouts
|
|
33
41
|
- Fully typed parameter objects for every element
|
|
34
42
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema-free validation shared by both cost-entity emitters (#4857 PR A):
|
|
3
|
+
* the STEP-TEXT emitter `ifc-creator-cost.ts` (`IfcCreator`, building a file
|
|
4
|
+
* from scratch) and the in-store builder `in-store/cost.ts`
|
|
5
|
+
* (`bim.store.addCost*`, authoring into an already-loaded model). Neither
|
|
6
|
+
* caller's serialization concern lives here — `ifc-creator-cost.ts` writes a
|
|
7
|
+
* raw STEP argument string, `in-store/cost.ts` writes a `StoreEditor`
|
|
8
|
+
* attribute array — only WHETHER an authored value is legal, decided once, so
|
|
9
|
+
* the same typo or out-of-range value is rejected identically from either
|
|
10
|
+
* entry point rather than by two allow-lists that can drift.
|
|
11
|
+
*/
|
|
12
|
+
/** The schemas cost entities can be authored in (IFC2X3 is refused up front). */
|
|
13
|
+
export type CostSchema = 'IFC2X3' | 'IFC4' | 'IFC4X3';
|
|
14
|
+
/** A typed IFC value: the SELECT branch name plus its numeric value. */
|
|
15
|
+
export interface CostTypedValueInput {
|
|
16
|
+
Type: string;
|
|
17
|
+
Value: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Runtime allow-lists for every closed vocabulary a cost method writes. The
|
|
21
|
+
* TypeScript unions at the call sites only bind typed callers; the sandbox
|
|
22
|
+
* hands these methods untyped script input, and an unchecked string becomes
|
|
23
|
+
* `IFCBOGUSMEASURE(1.)` or `.BOGUS.` — well-formed STEP naming nothing in the
|
|
24
|
+
* schema.
|
|
25
|
+
*/
|
|
26
|
+
export declare const MEASURE_TYPES: ReadonlySet<string>;
|
|
27
|
+
export declare const QUANTITY_KINDS: ReadonlySet<string>;
|
|
28
|
+
export declare const ARITHMETIC_OPERATORS: ReadonlySet<string>;
|
|
29
|
+
export declare const COST_SCHEDULE_TYPES: ReadonlySet<string>;
|
|
30
|
+
export declare const COST_ITEM_TYPES: ReadonlySet<string>;
|
|
31
|
+
/** Validate a loaded model's schema at the untyped runtime boundary. */
|
|
32
|
+
export declare function requireCostSchema(schema: unknown): CostSchema;
|
|
33
|
+
/** Refuse a value outside its closed vocabulary; `undefined` (absent) passes. */
|
|
34
|
+
export declare function assertOneOf(value: unknown, allowed: ReadonlySet<string>, what: string, context: string): void;
|
|
35
|
+
/** Validate IfcArithmeticOperatorEnum, whose MODULO member exists only in IFC4X3. */
|
|
36
|
+
export declare function validateArithmeticOperator(value: unknown, schema: CostSchema, context: string): void;
|
|
37
|
+
/** EXPRESS INTEGER-valued measures: IfcInteger always, IfcCountMeasure from IFC4X3 on. */
|
|
38
|
+
export declare function isIntegerMeasure(type: string, schema: CostSchema): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Refuse IFC2X3 cost authoring by name, loudly.
|
|
41
|
+
*
|
|
42
|
+
* IFC2X3 lays IfcCostSchedule / IfcCostItem / IfcCostValue out differently
|
|
43
|
+
* (IfcCostSchedule carries an `ID` and IfcDateAndTime references where IFC4
|
|
44
|
+
* carries `Identification` and IfcDateTime strings; IfcCostValue has
|
|
45
|
+
* `CostType` where IFC4 has `Category`, and no `Components` at all). Writing
|
|
46
|
+
* the IFC4 layout into an IFC2X3 file would produce records that parse and are
|
|
47
|
+
* wrong. A no-op — or a method that returned an id having written nothing —
|
|
48
|
+
* would look like success at the call site, so this throws instead.
|
|
49
|
+
*/
|
|
50
|
+
export declare function assertCostSchema(schema: string, method: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Validate a typed IFC value (`IfcCostValue.AppliedValue`,
|
|
53
|
+
* `IfcMeasureWithUnit.ValueComponent` — both `IfcValue`/SELECT-typed
|
|
54
|
+
* attributes). Does not serialize: the caller picks the STEP form (a named
|
|
55
|
+
* SELECT branch as raw text, or a `{ typed: { type, value } }` overlay
|
|
56
|
+
* marker) once this passes.
|
|
57
|
+
*/
|
|
58
|
+
export declare function validateTypedValue(value: CostTypedValueInput | undefined, schema: CostSchema, context: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Validate an optional LIST-of-reference attribute.
|
|
61
|
+
*
|
|
62
|
+
* `undefined` is absent. An empty array is NOT absent: the EXPRESS
|
|
63
|
+
* declaration is `[1:?]`, so `()` would be a malformed list that the reader
|
|
64
|
+
* reports as INVALID_LIST. Refusing here keeps the two states distinct end to
|
|
65
|
+
* end, for both emitters.
|
|
66
|
+
*/
|
|
67
|
+
export declare function validateRefList(ids: number[] | undefined, attribute: string, context: string): void;
|
|
68
|
+
/** Require a positive integer express id for a single-reference attribute. */
|
|
69
|
+
export declare function requireRef(id: number, attribute: string, context: string): void;
|
|
70
|
+
//# sourceMappingURL=cost-authoring-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-authoring-rules.d.ts","sourceRoot":"","sources":["../src/cost-authoring-rules.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAEH,iFAAiF;AACjF,MAAM,MAAM,UAA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AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAYnG;AAED,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI/E"}
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
* Runtime allow-lists for every closed vocabulary a cost method writes. The
|
|
6
|
+
* TypeScript unions at the call sites only bind typed callers; the sandbox
|
|
7
|
+
* hands these methods untyped script input, and an unchecked string becomes
|
|
8
|
+
* `IFCBOGUSMEASURE(1.)` or `.BOGUS.` — well-formed STEP naming nothing in the
|
|
9
|
+
* schema.
|
|
10
|
+
*/
|
|
11
|
+
export const MEASURE_TYPES = new Set([
|
|
12
|
+
'IfcMonetaryMeasure', 'IfcAreaMeasure', 'IfcVolumeMeasure', 'IfcLengthMeasure',
|
|
13
|
+
'IfcMassMeasure', 'IfcTimeMeasure', 'IfcCountMeasure', 'IfcNumericMeasure',
|
|
14
|
+
'IfcRatioMeasure', 'IfcReal', 'IfcInteger',
|
|
15
|
+
]);
|
|
16
|
+
export const QUANTITY_KINDS = new Set([
|
|
17
|
+
'IfcQuantityLength', 'IfcQuantityArea', 'IfcQuantityVolume', 'IfcQuantityWeight',
|
|
18
|
+
'IfcQuantityTime', 'IfcQuantityCount', 'IfcQuantityNumber',
|
|
19
|
+
]);
|
|
20
|
+
export const ARITHMETIC_OPERATORS = new Set(['ADD', 'DIVIDE', 'MODULO', 'MULTIPLY', 'SUBTRACT']);
|
|
21
|
+
export const COST_SCHEDULE_TYPES = new Set([
|
|
22
|
+
'BUDGET', 'COSTPLAN', 'ESTIMATE', 'TENDER', 'PRICEDBILLOFQUANTITIES',
|
|
23
|
+
'UNPRICEDBILLOFQUANTITIES', 'SCHEDULEOFRATES', 'USERDEFINED', 'NOTDEFINED',
|
|
24
|
+
]);
|
|
25
|
+
export const COST_ITEM_TYPES = new Set(['USERDEFINED', 'NOTDEFINED']);
|
|
26
|
+
/** Validate a loaded model's schema at the untyped runtime boundary. */
|
|
27
|
+
export function requireCostSchema(schema) {
|
|
28
|
+
if (schema !== 'IFC2X3' && schema !== 'IFC4' && schema !== 'IFC4X3') {
|
|
29
|
+
throw new Error('CostAnchor.schema is required and must match the loaded model schema');
|
|
30
|
+
}
|
|
31
|
+
return schema;
|
|
32
|
+
}
|
|
33
|
+
/** Refuse a value outside its closed vocabulary; `undefined` (absent) passes. */
|
|
34
|
+
export function assertOneOf(value, allowed, what, context) {
|
|
35
|
+
if (value === undefined)
|
|
36
|
+
return;
|
|
37
|
+
if (typeof value !== 'string' || !allowed.has(value)) {
|
|
38
|
+
throw new Error(`${context}: ${what} '${String(value)}' is not one of ${[...allowed].join(', ')}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Validate IfcArithmeticOperatorEnum, whose MODULO member exists only in IFC4X3. */
|
|
42
|
+
export function validateArithmeticOperator(value, schema, context) {
|
|
43
|
+
assertOneOf(value, ARITHMETIC_OPERATORS, 'ArithmeticOperator', context);
|
|
44
|
+
if (value === 'MODULO' && schema !== 'IFC4X3') {
|
|
45
|
+
throw new Error(`${context}: ArithmeticOperator 'MODULO' is only valid in IFC4X3`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** EXPRESS INTEGER-valued measures: IfcInteger always, IfcCountMeasure from IFC4X3 on. */
|
|
49
|
+
export function isIntegerMeasure(type, schema) {
|
|
50
|
+
return type === 'IfcInteger' || (type === 'IfcCountMeasure' && schema === 'IFC4X3');
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Refuse IFC2X3 cost authoring by name, loudly.
|
|
54
|
+
*
|
|
55
|
+
* IFC2X3 lays IfcCostSchedule / IfcCostItem / IfcCostValue out differently
|
|
56
|
+
* (IfcCostSchedule carries an `ID` and IfcDateAndTime references where IFC4
|
|
57
|
+
* carries `Identification` and IfcDateTime strings; IfcCostValue has
|
|
58
|
+
* `CostType` where IFC4 has `Category`, and no `Components` at all). Writing
|
|
59
|
+
* the IFC4 layout into an IFC2X3 file would produce records that parse and are
|
|
60
|
+
* wrong. A no-op — or a method that returned an id having written nothing —
|
|
61
|
+
* would look like success at the call site, so this throws instead.
|
|
62
|
+
*/
|
|
63
|
+
export function assertCostSchema(schema, method) {
|
|
64
|
+
if (schema === 'IFC2X3') {
|
|
65
|
+
throw new Error(`${method} is not supported for IFC2X3: the IFC2X3 cost entities have a different `
|
|
66
|
+
+ 'attribute layout. Create or load the model as IFC4 or IFC4X3.');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Validate a typed IFC value (`IfcCostValue.AppliedValue`,
|
|
71
|
+
* `IfcMeasureWithUnit.ValueComponent` — both `IfcValue`/SELECT-typed
|
|
72
|
+
* attributes). Does not serialize: the caller picks the STEP form (a named
|
|
73
|
+
* SELECT branch as raw text, or a `{ typed: { type, value } }` overlay
|
|
74
|
+
* marker) once this passes.
|
|
75
|
+
*/
|
|
76
|
+
export function validateTypedValue(value, schema, context) {
|
|
77
|
+
if (value === undefined || value === null)
|
|
78
|
+
throw new Error(`${context}: a typed value is required`);
|
|
79
|
+
if (value.Type === undefined)
|
|
80
|
+
throw new Error(`${context}: Type is required on a typed value`);
|
|
81
|
+
assertOneOf(value.Type, MEASURE_TYPES, 'Type', context);
|
|
82
|
+
if (!Number.isFinite(value.Value)) {
|
|
83
|
+
throw new Error(`${context}: ${value.Type} value must be a finite number`);
|
|
84
|
+
}
|
|
85
|
+
// Rounding would silently change the caller's number: an INTEGER measure
|
|
86
|
+
// given a fraction is a caller error, not something to fix up.
|
|
87
|
+
if (isIntegerMeasure(value.Type, schema) && !Number.isInteger(value.Value)) {
|
|
88
|
+
throw new Error(`${context}: ${value.Type} value must be an integer in ${schema}, got ${value.Value}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Validate an optional LIST-of-reference attribute.
|
|
93
|
+
*
|
|
94
|
+
* `undefined` is absent. An empty array is NOT absent: the EXPRESS
|
|
95
|
+
* declaration is `[1:?]`, so `()` would be a malformed list that the reader
|
|
96
|
+
* reports as INVALID_LIST. Refusing here keeps the two states distinct end to
|
|
97
|
+
* end, for both emitters.
|
|
98
|
+
*/
|
|
99
|
+
export function validateRefList(ids, attribute, context) {
|
|
100
|
+
if (ids === undefined)
|
|
101
|
+
return;
|
|
102
|
+
if (ids.length === 0) {
|
|
103
|
+
throw new Error(`${context}: ${attribute} must name at least one entity. Omit the field entirely `
|
|
104
|
+
+ 'to write it as absent — an empty list is a malformed IFC list, not "no value".');
|
|
105
|
+
}
|
|
106
|
+
for (const id of ids) {
|
|
107
|
+
if (!Number.isInteger(id) || id <= 0) {
|
|
108
|
+
throw new Error(`${context}: ${attribute} contains '${id}', which is not an express id`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** Require a positive integer express id for a single-reference attribute. */
|
|
113
|
+
export function requireRef(id, attribute, context) {
|
|
114
|
+
if (!Number.isInteger(id) || id <= 0) {
|
|
115
|
+
throw new Error(`${context}: ${attribute} must be an express id, got '${id}'`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=cost-authoring-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-authoring-rules.js","sourceRoot":"","sources":["../src/cost-authoring-rules.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAuB/D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAS;IAChE,oBAAoB,EAAE,gB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CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,KAAK,SAAS,gCAAgC,EAAE,GAAG,CAAC,CAAC;IACjF,CAAC;AACH,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { type CostSchema } from './cost-authoring-rules.js';
|
|
1
2
|
import type { CostItemParams, CostQuantityParams, CostScheduleParams, CostTypedValue, CostValueParams, SIUnitParams } from './types-cost.js';
|
|
3
|
+
export type { CostSchema };
|
|
2
4
|
/** Allocate an express id, emit `#id=TYPE(attrs);`, and return the id. */
|
|
3
5
|
export type EmitEntity = (type: string, attrs: string) => number;
|
|
4
|
-
/** The schemas cost entities can be authored in (IFC2X3 is refused up front). */
|
|
5
|
-
export type CostSchema = 'IFC2X3' | 'IFC4' | 'IFC4X3';
|
|
6
6
|
/**
|
|
7
7
|
* Serialize a finite number as an exact STEP REAL.
|
|
8
8
|
*
|
|
@@ -13,18 +13,7 @@ export type CostSchema = 'IFC2X3' | 'IFC4' | 'IFC4X3';
|
|
|
13
13
|
* `toString()` are kept and only rewritten into STEP's spelling.
|
|
14
14
|
*/
|
|
15
15
|
export declare function stepReal(v: number): string;
|
|
16
|
-
|
|
17
|
-
* Refuse IFC2X3 cost authoring by name, loudly.
|
|
18
|
-
*
|
|
19
|
-
* IFC2X3 lays IfcCostSchedule / IfcCostItem / IfcCostValue out differently
|
|
20
|
-
* (IfcCostSchedule carries an `ID` and IfcDateAndTime references where IFC4
|
|
21
|
-
* carries `Identification` and IfcDateTime strings; IfcCostValue has
|
|
22
|
-
* `CostType` where IFC4 has `Category`, and no `Components` at all). Writing
|
|
23
|
-
* the IFC4 layout into an IFC2X3 file would produce records that parse and are
|
|
24
|
-
* wrong. A no-op — or a method that returned an id having written nothing —
|
|
25
|
-
* would look like success at the call site, so this throws instead.
|
|
26
|
-
*/
|
|
27
|
-
export declare function assertCostSchema(schema: string, method: string): void;
|
|
16
|
+
export { assertCostSchema } from './cost-authoring-rules.js';
|
|
28
17
|
/**
|
|
29
18
|
* Serialize a typed IFC value as a named SELECT branch.
|
|
30
19
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ifc-creator-cost.d.ts","sourceRoot":"","sources":["../src/ifc-creator-cost.ts"],"names":[],"mappings":"AA0CA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,YAAY,EACb,MAAM,iBAAiB,CAAC;AAEzB,0EAA0E;AAC1E,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAEjE
|
|
1
|
+
{"version":3,"file":"ifc-creator-cost.d.ts","sourceRoot":"","sources":["../src/ifc-creator-cost.ts"],"names":[],"mappings":"AA0CA,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,YAAY,EACb,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B,0EAA0E;AAC1E,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAEjE;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAO1C;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM7F;AAiCD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAM3E;AAgBD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAczE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,GACf,MAAM,CAGR;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,GACf,MAAM,CAwBR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAqBnG;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU,GACf,MAAM,CAQR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,iBAAiB,EAAE,MAAM,EACzB,gBAAgB,EAAE,MAAM,EAAE,EAC1B,WAAW,EAAE,MAAM,MAAM,EACzB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU,GACf,MAAM,CAKR;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU,GACf,MAAM,CAOR"}
|
package/dist/ifc-creator-cost.js
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
* lists `[1:?]`) and is refused loudly rather than degraded to `$`.
|
|
39
39
|
*/
|
|
40
40
|
import { esc, optStr, optEnum, refList } from './ifc-creator-math.js';
|
|
41
|
+
import { COST_ITEM_TYPES, COST_SCHEDULE_TYPES, QUANTITY_KINDS, assertOneOf, isIntegerMeasure, validateArithmeticOperator, validateTypedValue, } from './cost-authoring-rules.js';
|
|
41
42
|
/**
|
|
42
43
|
* Serialize a finite number as an exact STEP REAL.
|
|
43
44
|
*
|
|
@@ -56,56 +57,7 @@ export function stepReal(v) {
|
|
|
56
57
|
const exponent = s.slice(e + 1).replace(/^\+/, '');
|
|
57
58
|
return `${mantissa.includes('.') ? mantissa : `${mantissa}.`}E${exponent}`;
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
* Runtime allow-lists for every closed vocabulary a cost method writes. The
|
|
61
|
-
* TypeScript unions only bind typed callers; the sandbox hands these methods
|
|
62
|
-
* untyped script input, and an unchecked string becomes `IFCBOGUSMEASURE(1.)`
|
|
63
|
-
* or `.BOGUS.` — well-formed STEP naming nothing in the schema.
|
|
64
|
-
*/
|
|
65
|
-
const MEASURE_TYPES = new Set([
|
|
66
|
-
'IfcMonetaryMeasure', 'IfcAreaMeasure', 'IfcVolumeMeasure', 'IfcLengthMeasure',
|
|
67
|
-
'IfcMassMeasure', 'IfcTimeMeasure', 'IfcCountMeasure', 'IfcNumericMeasure',
|
|
68
|
-
'IfcRatioMeasure', 'IfcReal', 'IfcInteger',
|
|
69
|
-
]);
|
|
70
|
-
const QUANTITY_KINDS = new Set([
|
|
71
|
-
'IfcQuantityLength', 'IfcQuantityArea', 'IfcQuantityVolume', 'IfcQuantityWeight',
|
|
72
|
-
'IfcQuantityTime', 'IfcQuantityCount', 'IfcQuantityNumber',
|
|
73
|
-
]);
|
|
74
|
-
const ARITHMETIC_OPERATORS = new Set(['ADD', 'DIVIDE', 'MULTIPLY', 'SUBTRACT']);
|
|
75
|
-
const COST_SCHEDULE_TYPES = new Set([
|
|
76
|
-
'BUDGET', 'COSTPLAN', 'ESTIMATE', 'TENDER', 'PRICEDBILLOFQUANTITIES',
|
|
77
|
-
'UNPRICEDBILLOFQUANTITIES', 'SCHEDULEOFRATES', 'USERDEFINED', 'NOTDEFINED',
|
|
78
|
-
]);
|
|
79
|
-
const COST_ITEM_TYPES = new Set(['USERDEFINED', 'NOTDEFINED']);
|
|
80
|
-
/** Refuse a value outside its closed vocabulary; `undefined` (absent) passes. */
|
|
81
|
-
function assertOneOf(value, allowed, what, context) {
|
|
82
|
-
if (value === undefined)
|
|
83
|
-
return;
|
|
84
|
-
if (typeof value !== 'string' || !allowed.has(value)) {
|
|
85
|
-
throw new Error(`${context}: ${what} '${String(value)}' is not one of ${[...allowed].join(', ')}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/** EXPRESS INTEGER-valued measures: IfcInteger always, IfcCountMeasure from IFC4X3 on. */
|
|
89
|
-
function isIntegerMeasure(type, schema) {
|
|
90
|
-
return type === 'IfcInteger' || (type === 'IfcCountMeasure' && schema === 'IFC4X3');
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Refuse IFC2X3 cost authoring by name, loudly.
|
|
94
|
-
*
|
|
95
|
-
* IFC2X3 lays IfcCostSchedule / IfcCostItem / IfcCostValue out differently
|
|
96
|
-
* (IfcCostSchedule carries an `ID` and IfcDateAndTime references where IFC4
|
|
97
|
-
* carries `Identification` and IfcDateTime strings; IfcCostValue has
|
|
98
|
-
* `CostType` where IFC4 has `Category`, and no `Components` at all). Writing
|
|
99
|
-
* the IFC4 layout into an IFC2X3 file would produce records that parse and are
|
|
100
|
-
* wrong. A no-op — or a method that returned an id having written nothing —
|
|
101
|
-
* would look like success at the call site, so this throws instead.
|
|
102
|
-
*/
|
|
103
|
-
export function assertCostSchema(schema, method) {
|
|
104
|
-
if (schema === 'IFC2X3') {
|
|
105
|
-
throw new Error(`${method} is not supported for IFC2X3: the IFC2X3 cost entities have a different `
|
|
106
|
-
+ 'attribute layout. Create the IfcCreator with Schema "IFC4" or "IFC4X3".');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
60
|
+
export { assertCostSchema } from './cost-authoring-rules.js';
|
|
109
61
|
/**
|
|
110
62
|
* Serialize a typed IFC value as a named SELECT branch.
|
|
111
63
|
*
|
|
@@ -114,18 +66,8 @@ export function assertCostSchema(schema, method) {
|
|
|
114
66
|
* and picking one by inspecting the value would silently retype the file.
|
|
115
67
|
*/
|
|
116
68
|
export function typedValue(value, schema, context) {
|
|
117
|
-
|
|
118
|
-
throw new Error(`${context}: a typed value is required`);
|
|
119
|
-
assertOneOf(value.Type, MEASURE_TYPES, 'Type', context);
|
|
120
|
-
if (!Number.isFinite(value.Value)) {
|
|
121
|
-
throw new Error(`${context}: ${value.Type} value must be a finite number`);
|
|
122
|
-
}
|
|
123
|
-
// Rounding would silently change the caller's number: an INTEGER measure
|
|
124
|
-
// given a fraction is a caller error, not something to fix up.
|
|
69
|
+
validateTypedValue(value, schema, context);
|
|
125
70
|
if (isIntegerMeasure(value.Type, schema)) {
|
|
126
|
-
if (!Number.isInteger(value.Value)) {
|
|
127
|
-
throw new Error(`${context}: ${value.Type} value must be an integer in ${schema}, got ${value.Value}`);
|
|
128
|
-
}
|
|
129
71
|
return `${value.Type.toUpperCase()}(${value.Value.toString()})`;
|
|
130
72
|
}
|
|
131
73
|
return `${value.Type.toUpperCase()}(${stepReal(value.Value)})`;
|
|
@@ -266,7 +208,7 @@ export function emitPhysicalQuantity(params, schema, emit) {
|
|
|
266
208
|
* [8] ArithmeticOperator, [9] Components.
|
|
267
209
|
*/
|
|
268
210
|
export function emitCostValue(params, schema, emit) {
|
|
269
|
-
|
|
211
|
+
validateArithmeticOperator(params.ArithmeticOperator, schema, 'addIfcCostValue');
|
|
270
212
|
if (params.AppliedValue !== undefined && params.AppliedValueRef !== undefined) {
|
|
271
213
|
throw new Error('addIfcCostValue: AppliedValue and AppliedValueRef are the two branches of one SELECT — give at most one');
|
|
272
214
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ifc-creator-cost.js","sourceRoot":"","sources":["../src/ifc-creator-cost.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AAClE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAA0B,EAC1B,QAAgB,EAChB,QAAgB,EAChB,IAAgB;IAEhB,WAAW,CAAC,MAAM,CAAC,cAAc,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;IAChG,OAAO,IAAI,CAAC,iBAAiB,EAC3B,IAAI,QAAQ,KAAK,QAAQ,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG;UAC9E,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG;UAChE,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG;UAC7D,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface NestMembership {
|
|
2
|
+
relId?: number;
|
|
3
|
+
relatingId?: number;
|
|
4
|
+
}
|
|
5
|
+
/** Refuse a proposed parent→child edge when the child is already an ancestor. */
|
|
6
|
+
export declare function assertNoNestingCycle(parentId: number, childIds: readonly number[], existingByChild: ReadonlyMap<number, readonly NestMembership[]>): void;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=cost-nesting-cycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-nesting-cycle.d.ts","sourceRoot":"","sources":["../../src/in-store/cost-nesting-cycle.ts"],"names":[],"mappings":"AAIA,UAAU,cAAc;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC,GAC9D,IAAI,CAyBN"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
/** Refuse a proposed parent→child edge when the child is already an ancestor. */
|
|
5
|
+
export function assertNoNestingCycle(parentId, childIds, existingByChild) {
|
|
6
|
+
const requested = new Set(childIds);
|
|
7
|
+
const visited = new Set();
|
|
8
|
+
const ancestors = [parentId];
|
|
9
|
+
while (ancestors.length > 0) {
|
|
10
|
+
const current = ancestors.pop();
|
|
11
|
+
if (visited.has(current))
|
|
12
|
+
continue;
|
|
13
|
+
visited.add(current);
|
|
14
|
+
for (const membership of existingByChild.get(current) ?? []) {
|
|
15
|
+
if (membership.relatingId === undefined) {
|
|
16
|
+
throw new Error(`nestCostItems: existing nesting relationship #${membership.relId ?? 'unknown'} `
|
|
17
|
+
+ 'is missing relatingId; '
|
|
18
|
+
+ 'the nesting graph is incomplete, so cycle safety cannot be established.');
|
|
19
|
+
}
|
|
20
|
+
if (requested.has(membership.relatingId)) {
|
|
21
|
+
throw new Error(`nestCostItems: parentId #${parentId} is already a descendant of childId #${membership.relatingId} `
|
|
22
|
+
+ 'in the existing nesting hierarchy — nesting it here would create a cycle.');
|
|
23
|
+
}
|
|
24
|
+
ancestors.push(membership.relatingId);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=cost-nesting-cycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-nesting-cycle.js","sourceRoot":"","sources":["../../src/in-store/cost-nesting-cycle.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAO/D,iFAAiF;AACjF,MAAM,UAAU,oBAAoB,CAClC,QAAgB,EAChB,QAA2B,EAC3B,eAA+D;IAE/D,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,SAAS,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7B,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,EAAG,CAAC;QACjC,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,SAAS;QACnC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,KAAK,MAAM,UAAU,IAAI,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;YAC5D,IAAI,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;gBACxC,MAAM,IAAI,KAAK,CACb,iDAAiD,UAAU,CAAC,KAAK,IAAI,SAAS,GAAG;sBAC/E,yBAAyB;sBACzB,yEAAyE,CAC5E,CAAC;YACJ,CAAC;YACD,IAAI,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBACzC,MAAM,IAAI,KAAK,CACb,4BAA4B,QAAQ,wCAAwC,UAAU,CAAC,UAAU,GAAG;sBAClG,2EAA2E,CAC9E,CAAC;YACJ,CAAC;YACD,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StoreEditor } from '@ifc-lite/mutations';
|
|
2
|
+
import { type CostSchema } from '../cost-authoring-rules.js';
|
|
3
|
+
/** Validate the caller's anchor against the schema of the loaded store. */
|
|
4
|
+
export declare function requireMatchingCostSchema(editor: StoreEditor, declaredSchema: unknown): CostSchema;
|
|
5
|
+
/** Require a live entity of one exact IFC class. */
|
|
6
|
+
export declare function requireEntityType(editor: StoreEditor, id: number, expectedType: string, attribute: string, context: string): void;
|
|
7
|
+
/** Require a live entity whose exact class belongs to `allowedTypes`. */
|
|
8
|
+
export declare function requireEntityTypeOneOf(editor: StoreEditor, id: number, allowedTypes: ReadonlySet<string>, attribute: string, context: string): void;
|
|
9
|
+
/** Require a live entity that descends from one IFC schema supertype. */
|
|
10
|
+
export declare function requireEntitySubtype(editor: StoreEditor, id: number, supertype: string, attribute: string, context: string): void;
|
|
11
|
+
/** Validate one cost-control relationship member against the IFC hierarchy. */
|
|
12
|
+
export declare function requireAssignableIfcObjectDefinition(editor: StoreEditor, id: number, relatingControlId: number, context: string): void;
|
|
13
|
+
//# sourceMappingURL=cost-reference-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-reference-validation.d.ts","sourceRoot":"","sources":["../../src/in-store/cost-reference-validation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAEhF,2EAA2E;AAC3E,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,GAAG,UAAU,CAOlG;AAED,oDAAoD;AACpD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GACxF,IAAI,CAMN;AAED,yEAAyE;AACzE,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GACrG,IAAI,CAMN;AAED,yEAAyE;AACzE,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GACrF,IAAI,CAMN;AAED,+EAA+E;AAC/E,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAC1E,IAAI,CAKN"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
import { getInheritanceChainAcrossSchemas } from '@ifc-lite/parser';
|
|
5
|
+
import { requireCostSchema } from '../cost-authoring-rules.js';
|
|
6
|
+
/** Validate the caller's anchor against the schema of the loaded store. */
|
|
7
|
+
export function requireMatchingCostSchema(editor, declaredSchema) {
|
|
8
|
+
const declared = requireCostSchema(declaredSchema);
|
|
9
|
+
const loaded = requireCostSchema(editor.getSchemaVersion());
|
|
10
|
+
if (declared !== loaded) {
|
|
11
|
+
throw new Error(`CostAnchor.schema ${declared} does not match the loaded model schema ${loaded}`);
|
|
12
|
+
}
|
|
13
|
+
return loaded;
|
|
14
|
+
}
|
|
15
|
+
/** Require a live entity of one exact IFC class. */
|
|
16
|
+
export function requireEntityType(editor, id, expectedType, attribute, context) {
|
|
17
|
+
const actual = editor.getEntityType(id);
|
|
18
|
+
if (actual === undefined)
|
|
19
|
+
throw new Error(`${context}: ${attribute} #${id} does not exist in this model`);
|
|
20
|
+
if (actual.toUpperCase() !== expectedType.toUpperCase()) {
|
|
21
|
+
throw new Error(`${context}: ${attribute} #${id} must be an ${expectedType}, got ${actual}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Require a live entity whose exact class belongs to `allowedTypes`. */
|
|
25
|
+
export function requireEntityTypeOneOf(editor, id, allowedTypes, attribute, context) {
|
|
26
|
+
const actual = editor.getEntityType(id);
|
|
27
|
+
if (actual === undefined)
|
|
28
|
+
throw new Error(`${context}: ${attribute} #${id} does not exist in this model`);
|
|
29
|
+
if (!allowedTypes.has(actual.toUpperCase())) {
|
|
30
|
+
throw new Error(`${context}: ${attribute} #${id} must be one of ${[...allowedTypes].join(', ')}, got ${actual}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Require a live entity that descends from one IFC schema supertype. */
|
|
34
|
+
export function requireEntitySubtype(editor, id, supertype, attribute, context) {
|
|
35
|
+
const actual = editor.getEntityType(id);
|
|
36
|
+
if (actual === undefined)
|
|
37
|
+
throw new Error(`${context}: ${attribute} #${id} does not exist in this model`);
|
|
38
|
+
if (!getInheritanceChainAcrossSchemas(actual).includes(supertype)) {
|
|
39
|
+
throw new Error(`${context}: ${attribute} #${id} must be an ${supertype}, got ${actual}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Validate one cost-control relationship member against the IFC hierarchy. */
|
|
43
|
+
export function requireAssignableIfcObjectDefinition(editor, id, relatingControlId, context) {
|
|
44
|
+
if (id === relatingControlId) {
|
|
45
|
+
throw new Error(`${context}: relatingControlId #${id} cannot also be one of relatedObjectIds`);
|
|
46
|
+
}
|
|
47
|
+
requireEntitySubtype(editor, id, 'IfcObjectDefinition', 'relatedObjectIds', context);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=cost-reference-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-reference-validation.js","sourceRoot":"","sources":["../../src/in-store/cost-reference-validation.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAG/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAmB,MAAM,4BAA4B,CAAC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AAC,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,KAAK,SAAS,KAAK,EAAE,mBAAmB,CAAC,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;IACnH,CAAC;AACH,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,oBAAoB,CAClC,MAAmB,EAAE,EAAU,EAAE,SAAiB,EAAE,SAAiB,EAAE,OAAe;IAEtF,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IACxC,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,KAAK,SAAS,KAAK,EAAE,+BAA+B,CAAC,CAAC;IAC1G,IAAI,CAAC,gCAAgC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,KAAK,SAAS,KAAK,EAAE,eAAe,SAAS,SAAS,MAAM,EAAE,CAAC,CAAC;IAC5F,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,oCAAoC,CAClD,MAAmB,EAAE,EAAU,EAAE,iBAAyB,EAAE,OAAe;IAE3E,IAAI,EAAE,KAAK,iBAAiB,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,wBAAwB,EAAE,yCAAyC,CAAC,CAAC;IACjG,CAAC;IACD,oBAAoB,CAAC,MAAM,EAAE,EAAE,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Safe removal of loaded-model cost entities and their relationship references. */
|
|
2
|
+
import type { StoreEditor } from '@ifc-lite/mutations';
|
|
3
|
+
import type { CostAnchor } from './cost.js';
|
|
4
|
+
/** Every reference the caller found pointing at the entity being removed. */
|
|
5
|
+
export interface CostRemovalReferrers {
|
|
6
|
+
itemCostValues?: ReadonlyMap<number, readonly number[]>;
|
|
7
|
+
valueComponents?: ReadonlyMap<number, readonly number[]>;
|
|
8
|
+
valueAppliedValueRef?: ReadonlyMap<number, number>;
|
|
9
|
+
nestRelatedObjects?: ReadonlyMap<number, readonly number[]>;
|
|
10
|
+
assignmentRelatedObjects?: ReadonlyMap<number, readonly number[]>;
|
|
11
|
+
nestsAsParent?: readonly number[];
|
|
12
|
+
assignmentsAsControl?: readonly number[];
|
|
13
|
+
/** Other relationship list attributes that can retain their surviving members. */
|
|
14
|
+
otherRelationshipLists?: readonly {
|
|
15
|
+
relId: number;
|
|
16
|
+
attributeIndex: number;
|
|
17
|
+
relatedIds: readonly number[];
|
|
18
|
+
}[];
|
|
19
|
+
/** Relationships where the target occupies a required scalar endpoint. */
|
|
20
|
+
otherRelationships?: readonly number[];
|
|
21
|
+
/** Non-relationship entities whose optional scalar attribute references the target. */
|
|
22
|
+
optionalScalarReferrers?: readonly {
|
|
23
|
+
entityId: number;
|
|
24
|
+
attributeIndex: number;
|
|
25
|
+
}[];
|
|
26
|
+
/** Non-relationship entities whose optional list attribute contains the target. */
|
|
27
|
+
optionalListReferrers?: readonly {
|
|
28
|
+
entityId: number;
|
|
29
|
+
attributeIndex: number;
|
|
30
|
+
referencedIds: readonly number[];
|
|
31
|
+
}[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Safe-delete an `IfcCostSchedule` / `IfcCostItem` / `IfcCostValue`, refusing
|
|
35
|
+
* live value references unless `detach` explicitly requests their rewrite.
|
|
36
|
+
*/
|
|
37
|
+
export declare function removeCostEntityInStore(editor: StoreEditor, anchor: CostAnchor, expressId: number, referrers: CostRemovalReferrers, options?: {
|
|
38
|
+
detach?: boolean;
|
|
39
|
+
}): void;
|
|
40
|
+
//# sourceMappingURL=cost-removal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-removal.d.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