@ifc-lite/create 2.5.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.
Files changed (51) hide show
  1. package/README.md +8 -0
  2. package/dist/cost-authoring-rules.d.ts +70 -0
  3. package/dist/cost-authoring-rules.d.ts.map +1 -0
  4. package/dist/cost-authoring-rules.js +118 -0
  5. package/dist/cost-authoring-rules.js.map +1 -0
  6. package/dist/ifc-creator-cost.d.ts +107 -0
  7. package/dist/ifc-creator-cost.d.ts.map +1 -0
  8. package/dist/ifc-creator-cost.js +279 -0
  9. package/dist/ifc-creator-cost.js.map +1 -0
  10. package/dist/ifc-creator-definitions.d.ts +21 -0
  11. package/dist/ifc-creator-definitions.d.ts.map +1 -0
  12. package/dist/ifc-creator-definitions.js +56 -0
  13. package/dist/ifc-creator-definitions.js.map +1 -0
  14. package/dist/ifc-creator-math.d.ts +15 -1
  15. package/dist/ifc-creator-math.d.ts.map +1 -1
  16. package/dist/ifc-creator-math.js +42 -0
  17. package/dist/ifc-creator-math.js.map +1 -1
  18. package/dist/ifc-creator.d.ts +23 -2
  19. package/dist/ifc-creator.d.ts.map +1 -1
  20. package/dist/ifc-creator.js +82 -67
  21. package/dist/ifc-creator.js.map +1 -1
  22. package/dist/in-store/cost-nesting-cycle.d.ts +8 -0
  23. package/dist/in-store/cost-nesting-cycle.d.ts.map +1 -0
  24. package/dist/in-store/cost-nesting-cycle.js +28 -0
  25. package/dist/in-store/cost-nesting-cycle.js.map +1 -0
  26. package/dist/in-store/cost-reference-validation.d.ts +13 -0
  27. package/dist/in-store/cost-reference-validation.d.ts.map +1 -0
  28. package/dist/in-store/cost-reference-validation.js +49 -0
  29. package/dist/in-store/cost-reference-validation.js.map +1 -0
  30. package/dist/in-store/cost-removal.d.ts +40 -0
  31. package/dist/in-store/cost-removal.d.ts.map +1 -0
  32. package/dist/in-store/cost-removal.js +107 -0
  33. package/dist/in-store/cost-removal.js.map +1 -0
  34. package/dist/in-store/cost.d.ts +109 -0
  35. package/dist/in-store/cost.d.ts.map +1 -0
  36. package/dist/in-store/cost.js +323 -0
  37. package/dist/in-store/cost.js.map +1 -0
  38. package/dist/in-store/resolve-source.d.ts.map +1 -1
  39. package/dist/in-store/resolve-source.js +11 -8
  40. package/dist/in-store/resolve-source.js.map +1 -1
  41. package/dist/index.d.ts +3 -0
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +2 -0
  44. package/dist/index.js.map +1 -1
  45. package/dist/types-cost.d.ts +134 -0
  46. package/dist/types-cost.d.ts.map +1 -0
  47. package/dist/types-cost.js +5 -0
  48. package/dist/types-cost.js.map +1 -0
  49. package/dist/types.d.ts +7 -0
  50. package/dist/types.d.ts.map +1 -1
  51. package/package.json +5 -4
@@ -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;AAEhF,2EAA2E;AAC3E,MAAM,UAAU,yBAAyB,CAAC,MAAmB,EAAE,cAAuB;IACpF,MAAM,QAAQ,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC5D,IAAI,QAAQ,KAAK,MAAM,EAAE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C,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.ts","sourceRoot":"","sources":["../../src/in-store/cost-removal.ts"],"names":[],"mappings":"AAIA,oFAAoF;AAEpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAI5C,6EAA6E;AAC7E,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IACxD,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IACzD,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAC5D,wBAAwB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAClE,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,kFAAkF;IAClF,sBAAsB,CAAC,EAAE,SAAS;QAChC,KAAK,EAAE,MAAM,CAAC;QACd,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;KAC/B,EAAE,CAAC;IACJ,0EAA0E;IAC1E,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,uFAAuF;IACvF,uBAAuB,CAAC,EAAE,SAAS;QACjC,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,EAAE,MAAM,CAAC;KACxB,EAAE,CAAC;IACJ,mFAAmF;IACnF,qBAAqB,CAAC,EAAE,SAAS;QAC/B,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;KAClC,EAAE,CAAC;CACL;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,oBAAoB,EAC/B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,IAAI,CAkFN"}
@@ -0,0 +1,107 @@
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 { assertCostSchema } from '../cost-authoring-rules.js';
5
+ import { requireEntityTypeOneOf, requireMatchingCostSchema } from './cost-reference-validation.js';
6
+ const REMOVABLE_COST_ENTITY_TYPES = new Set(['IFCCOSTSCHEDULE', 'IFCCOSTITEM', 'IFCCOSTVALUE']);
7
+ /**
8
+ * Safe-delete an `IfcCostSchedule` / `IfcCostItem` / `IfcCostValue`, refusing
9
+ * live value references unless `detach` explicitly requests their rewrite.
10
+ */
11
+ export function removeCostEntityInStore(editor, anchor, expressId, referrers, options = {}) {
12
+ assertCostSchema(requireMatchingCostSchema(editor, anchor.schema), 'removeCostEntity');
13
+ requireEntityTypeOneOf(editor, expressId, REMOVABLE_COST_ENTITY_TYPES, 'expressId', 'removeCostEntity');
14
+ const blockers = [];
15
+ for (const [itemId, values] of referrers.itemCostValues ?? []) {
16
+ if (values.includes(expressId))
17
+ blockers.push(`IfcCostItem #${itemId}.CostValues`);
18
+ }
19
+ for (const [valueId, components] of referrers.valueComponents ?? []) {
20
+ if (components.includes(expressId))
21
+ blockers.push(`IfcCostValue #${valueId}.Components`);
22
+ }
23
+ for (const [valueId, ref] of referrers.valueAppliedValueRef ?? []) {
24
+ if (ref === expressId)
25
+ blockers.push(`IfcCostValue #${valueId}.AppliedValue (AppliedValueRef)`);
26
+ }
27
+ for (const ref of referrers.otherRelationshipLists ?? []) {
28
+ if (ref.relatedIds.includes(expressId))
29
+ blockers.push(`relationship #${ref.relId}`);
30
+ }
31
+ for (const relId of referrers.otherRelationships ?? [])
32
+ blockers.push(`relationship #${relId}`);
33
+ for (const ref of referrers.optionalScalarReferrers ?? []) {
34
+ blockers.push(`entity #${ref.entityId} attribute ${ref.attributeIndex}`);
35
+ }
36
+ for (const ref of referrers.optionalListReferrers ?? []) {
37
+ if (ref.referencedIds.includes(expressId)) {
38
+ blockers.push(`entity #${ref.entityId} attribute ${ref.attributeIndex}`);
39
+ }
40
+ }
41
+ if (blockers.length > 0 && !options.detach) {
42
+ throw new Error(`removeCostEntity: #${expressId} is still referenced by ${blockers.join(', ')}. `
43
+ + 'Pass { detach: true } to rewrite those lists first.');
44
+ }
45
+ if (blockers.length > 0) {
46
+ for (const [itemId, values] of referrers.itemCostValues ?? []) {
47
+ if (!values.includes(expressId))
48
+ continue;
49
+ const remaining = values.filter(id => id !== expressId);
50
+ editor.setPositionalAttribute(itemId, 7, remaining.length === 0 ? null : remaining.map(id => `#${id}`));
51
+ }
52
+ for (const [valueId, components] of referrers.valueComponents ?? []) {
53
+ if (!components.includes(expressId))
54
+ continue;
55
+ const remaining = components.filter(id => id !== expressId);
56
+ editor.setPositionalAttribute(valueId, 9, remaining.length === 0 ? null : remaining.map(id => `#${id}`));
57
+ }
58
+ for (const [valueId, ref] of referrers.valueAppliedValueRef ?? []) {
59
+ if (ref === expressId)
60
+ editor.setPositionalAttribute(valueId, 2, null);
61
+ }
62
+ for (const ref of referrers.otherRelationshipLists ?? []) {
63
+ if (!ref.relatedIds.includes(expressId))
64
+ continue;
65
+ const remaining = ref.relatedIds.filter(id => id !== expressId);
66
+ if (remaining.length === 0)
67
+ editor.removeEntity(ref.relId);
68
+ else
69
+ editor.setPositionalAttribute(ref.relId, ref.attributeIndex, remaining.map(id => `#${id}`));
70
+ }
71
+ for (const relId of referrers.otherRelationships ?? [])
72
+ editor.removeEntity(relId);
73
+ for (const ref of referrers.optionalScalarReferrers ?? []) {
74
+ editor.setPositionalAttribute(ref.entityId, ref.attributeIndex, null);
75
+ }
76
+ for (const ref of referrers.optionalListReferrers ?? []) {
77
+ if (!ref.referencedIds.includes(expressId))
78
+ continue;
79
+ const remaining = ref.referencedIds.filter(id => id !== expressId);
80
+ editor.setPositionalAttribute(ref.entityId, ref.attributeIndex, remaining.length === 0 ? null : remaining.map(id => `#${id}`));
81
+ }
82
+ }
83
+ for (const [relId, related] of referrers.nestRelatedObjects ?? []) {
84
+ if (!related.includes(expressId))
85
+ continue;
86
+ const remaining = related.filter(id => id !== expressId);
87
+ if (remaining.length === 0)
88
+ editor.removeEntity(relId);
89
+ else
90
+ editor.setPositionalAttribute(relId, 5, remaining.map(id => `#${id}`));
91
+ }
92
+ for (const [relId, related] of referrers.assignmentRelatedObjects ?? []) {
93
+ if (!related.includes(expressId))
94
+ continue;
95
+ const remaining = related.filter(id => id !== expressId);
96
+ if (remaining.length === 0)
97
+ editor.removeEntity(relId);
98
+ else
99
+ editor.setPositionalAttribute(relId, 4, remaining.map(id => `#${id}`));
100
+ }
101
+ for (const relId of referrers.nestsAsParent ?? [])
102
+ editor.removeEntity(relId);
103
+ for (const relId of referrers.assignmentsAsControl ?? [])
104
+ editor.removeEntity(relId);
105
+ editor.removeEntity(expressId);
106
+ }
107
+ //# sourceMappingURL=cost-removal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cost-removal.js","sourceRoot":"","sources":["../../src/in-store/cost-removal.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAK/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAGnG,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAAC,CAAC,iBAAiB,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC;AAgChG;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAmB,EACnB,MAAkB,EAClB,SAAiB,EACjB,SAA+B,EAC/B,UAAgC,EAAE;IAElC,gBAAgB,CAAC,yBAAyB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC,CAAC;IACvF,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,2BAA2B,EAAE,WAAW,EAAE,kBAAkB,CAAC,CAAC;IACxG,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,SAAS,CAAC,cAAc,IAAI,EAAE,EAAE,CAAC;QAC9D,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,gBAAgB,MAAM,aAAa,CAAC,CAAC;IACrF,CAAC;IACD,KAAK,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,SAAS,CAAC,eAAe,IAAI,EAAE,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,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,aAAa,IAAI,EAAE;QAAE,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAC9E,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,oBAAoB,IAAI,EAAE;QAAE,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACrF,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Loaded-model cost authoring (#4857 PR A) — `bim.store.addCost*` / `nestCostItems`
3
+ * / `assignCostItemsToSchedule` / `assignToCostItem` / `setCostItemValues` /
4
+ * `removeCostEntity`. The counterpart of `ifc-creator-cost.ts` for a model
5
+ * that is already parsed and loaded rather than being built from scratch:
6
+ * same validation (`cost-authoring-rules.ts`, shared so a value illegal from
7
+ * one entry point is illegal from the other), different serialization —
8
+ * `StoreEditor.addEntity` takes a typed attribute array, not raw STEP text.
9
+ *
10
+ * Pure: no I/O, no parser access, no read of the store's OWN existing graph.
11
+ * `nestCostItemsInStore` (reparenting) and `removeCostEntityInStore`
12
+ * (safe-delete / cascade) both need to know what ALREADY references an
13
+ * entity, which only a graph READ can answer — the caller resolves referrers
14
+ * first and hands them in. The editor is the only mutable thing touched.
15
+ */
16
+ import { type RandomSource } from '@ifc-lite/encoding';
17
+ import type { StoreEditor } from '@ifc-lite/mutations';
18
+ import { type CostSchema } from '../cost-authoring-rules.js';
19
+ import type { CostItemParams, CostQuantityParams, CostScheduleParams, CostValueParams } from '../types-cost.js';
20
+ /** What `nestCostItemsInStore` / `assign*InStore` / `removeCostEntityInStore` need to
21
+ * reparent or detach cleanly — the model's owner history and target schema. */
22
+ export interface CostAnchor {
23
+ /** IfcOwnerHistory expressId, or null when the model has none (written as `$`). */
24
+ ownerHistoryId: number | null;
25
+ /** Target schema; IFC2X3 is refused (see `assertCostSchema`). */
26
+ schema: CostSchema;
27
+ /** Optional seeded randomness for authored GlobalIds — see `SpatialAnchor.guidRandom`. */
28
+ guidRandom?: RandomSource;
29
+ }
30
+ /**
31
+ * Emit an `IfcCostSchedule` into the loaded model's overlay.
32
+ *
33
+ * [0] GlobalId, [1] OwnerHistory, [2] Name, [3] Description, [4] ObjectType,
34
+ * [5] Identification, [6] PredefinedType, [7] Status, [8] SubmittedOn,
35
+ * [9] UpdateDate — same IFC4 layout `emitCostSchedule` writes; refused for
36
+ * IFC2X3 (different layout, see `assertCostSchema`).
37
+ */
38
+ export declare function addCostScheduleToStore(editor: StoreEditor, anchor: CostAnchor, params: CostScheduleParams): number;
39
+ /**
40
+ * Emit an `IfcCostItem`. [0] GlobalId, [1] OwnerHistory, [2] Name,
41
+ * [3] Description, [4] ObjectType, [5] Identification, [6] PredefinedType,
42
+ * [7] CostValues, [8] CostQuantities — an empty `CostValues`/`CostQuantities`
43
+ * array is refused (EXPRESS `[1:?]`); use `attachCostValuesToItemInStore` to
44
+ * attach them after the fact instead.
45
+ */
46
+ export declare function addCostItemToStore(editor: StoreEditor, anchor: CostAnchor, params: CostItemParams): number;
47
+ /**
48
+ * Emit an `IfcCostValue`. [0] Name, [1] Description, [2] AppliedValue,
49
+ * [3] UnitBasis, [4] ApplicableDate, [5] FixedUntilDate, [6] Category,
50
+ * [7] Condition, [8] ArithmeticOperator, [9] Components.
51
+ *
52
+ * `AppliedValue` and `AppliedValueRef` are the two branches of one SELECT —
53
+ * at most one may be given (mirrors `emitCostValue`).
54
+ */
55
+ export declare function addCostValueToStore(editor: StoreEditor, anchor: CostAnchor, params: CostValueParams): number;
56
+ /**
57
+ * Emit an `IfcPhysicalSimpleQuantity` (the same subtypes `emitPhysicalQuantity`
58
+ * writes), for `IfcCostItem.CostQuantities`. [0] Name, [1] Description,
59
+ * [2] Unit, [3] `<Kind>Value`, [4] Formula.
60
+ */
61
+ export declare function addCostQuantityToStore(editor: StoreEditor, anchor: CostAnchor, params: CostQuantityParams): number;
62
+ /** One relationship the caller already found referencing an id, so the builders below
63
+ * never need to scan the store themselves — see the module header. */
64
+ export interface ExistingRelatedList {
65
+ relId: number;
66
+ /** The relationship's RelatingObject, when the caller is supplying a nesting graph. */
67
+ relatingId?: number;
68
+ /** The relationship's current RelatedObjects (or Components), in file order. */
69
+ relatedIds: readonly number[];
70
+ /**
71
+ * When a controller legally has MORE THAN ONE relationship of this kind
72
+ * (e.g. two separate `IfcRelAssignsToControl` records for the same
73
+ * schedule), every member across ALL of them — used only to decide which
74
+ * requested ids are genuinely new, never as the list written back. Writing
75
+ * this union into `relId`'s own slot would copy a secondary relationship's
76
+ * members into the primary one, duplicating membership while leaving the
77
+ * secondary relationship untouched. Defaults to `relatedIds` when absent
78
+ * (the single-relationship case, where the two are the same set).
79
+ */
80
+ allMemberIds?: readonly number[];
81
+ }
82
+ /**
83
+ * Nest `childIds` under `parentId` as `IfcRelNests.RelatedObjects` (slot 5),
84
+ * `RelatingObject` = parent.
85
+ *
86
+ * A child already nested under one or more DIFFERENT `IfcRelNests` is
87
+ * reparented: it is removed from EVERY one of those rels' `RelatedObjects`
88
+ * first (a file may legally list a child under more than one nest —
89
+ * `MULTIPLE_NESTING_PARENTS` is a diagnostic, not a refusal — so detaching
90
+ * from only the first one found would leave it still nested under the rest),
91
+ * tombstoning a rel if that empties it (`RelatedObjects` is `[1:?]`, so an
92
+ * emptied list cannot be left as `()`), then added to (or its own new) the
93
+ * target rel.
94
+ */
95
+ export declare function nestCostItemsInStore(editor: StoreEditor, anchor: CostAnchor, parentId: number, childIds: number[], existingNestByChild: ReadonlyMap<number, readonly ExistingRelatedList[]>, existingTargetNest?: ExistingRelatedList): number;
96
+ /** Assign `itemIds` (IfcCostItem) to `scheduleId` (IfcCostSchedule) as its controlled objects. */
97
+ export declare function assignCostItemsToScheduleInStore(editor: StoreEditor, anchor: CostAnchor, scheduleId: number, itemIds: number[], existingAssignment?: ExistingRelatedList): number;
98
+ /**
99
+ * Assign IFC objects (products, tasks, resources, etc.) to a cost item.
100
+ * The controlling item itself is not a legal related member.
101
+ */
102
+ export declare function assignObjectsToCostItemInStore(editor: StoreEditor, anchor: CostAnchor, costItemId: number, objectIds: number[], existingAssignment?: ExistingRelatedList): number;
103
+ /**
104
+ * Set (replace) `itemId`'s `IfcCostItem.CostValues` (slot 7). `valueIds` is
105
+ * REQUIRED, not optional: an empty array is how a caller CLEARS the list,
106
+ * written as `$` — never `()`, which `[1:?]` forbids.
107
+ */
108
+ export declare function attachCostValuesToItemInStore(editor: StoreEditor, anchor: CostAnchor, itemId: number, valueIds: readonly number[]): void;
109
+ //# sourceMappingURL=cost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../../src/in-store/cost.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,qBAAqB,CAAC;AAM1E,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EACxE,MAAM,kBAAkB,CAAC;AAG1B;gFACgF;AAChF,MAAM,WAAW,UAAU;IACzB,mFAAmF;IACnF,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,iEAAiE;IACjE,MAAM,EAAE,UAAU,CAAC;IACnB,0FAA0F;IAC1F,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B;AAeD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAmBlH;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAA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