@matter/model 0.16.0-alpha.0-20251018-dd1ea6a8a → 0.16.0-alpha.0-20251020-3f6e46245
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/cjs/common/Metatype.d.ts +1 -1
- package/dist/cjs/decoration/decorators/attribute.d.ts +11 -0
- package/dist/cjs/decoration/decorators/attribute.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/attribute.js +32 -0
- package/dist/cjs/decoration/decorators/attribute.js.map +6 -0
- package/dist/cjs/decoration/decorators/cluster.d.ts +11 -0
- package/dist/cjs/decoration/decorators/cluster.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/cluster.js +32 -0
- package/dist/cjs/decoration/decorators/cluster.js.map +6 -0
- package/dist/cjs/decoration/decorators/command.d.ts +12 -0
- package/dist/cjs/decoration/decorators/command.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/command.js +34 -0
- package/dist/cjs/decoration/decorators/command.js.map +6 -0
- package/dist/cjs/decoration/decorators/datatype.d.ts +11 -0
- package/dist/cjs/decoration/decorators/datatype.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/datatype.js +32 -0
- package/dist/cjs/decoration/decorators/datatype.js.map +6 -0
- package/dist/cjs/decoration/decorators/element.d.ts +40 -0
- package/dist/cjs/decoration/decorators/element.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/element.js +101 -0
- package/dist/cjs/decoration/decorators/element.js.map +6 -0
- package/dist/cjs/decoration/decorators/event.d.ts +14 -0
- package/dist/cjs/decoration/decorators/event.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/event.js +32 -0
- package/dist/cjs/decoration/decorators/event.js.map +6 -0
- package/dist/cjs/decoration/decorators/field.d.ts +14 -0
- package/dist/cjs/decoration/decorators/field.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/field.js +32 -0
- package/dist/cjs/decoration/decorators/field.js.map +6 -0
- package/dist/cjs/decoration/decorators/index.d.ts +16 -0
- package/dist/cjs/decoration/decorators/index.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/index.js +33 -0
- package/dist/cjs/decoration/decorators/index.js.map +6 -0
- package/dist/cjs/decoration/decorators/listOf.d.ts +12 -0
- package/dist/cjs/decoration/decorators/listOf.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/listOf.js +47 -0
- package/dist/cjs/decoration/decorators/listOf.js.map +6 -0
- package/dist/cjs/decoration/decorators/mandatory.d.ts +11 -0
- package/dist/cjs/decoration/decorators/mandatory.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/mandatory.js +41 -0
- package/dist/cjs/decoration/decorators/mandatory.js.map +6 -0
- package/dist/cjs/decoration/decorators/nonvolatile.d.ts +11 -0
- package/dist/cjs/decoration/decorators/nonvolatile.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/nonvolatile.js +41 -0
- package/dist/cjs/decoration/decorators/nonvolatile.js.map +6 -0
- package/dist/cjs/decoration/decorators/nullable.d.ts +11 -0
- package/dist/cjs/decoration/decorators/nullable.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/nullable.js +41 -0
- package/dist/cjs/decoration/decorators/nullable.js.map +6 -0
- package/dist/cjs/decoration/decorators/response.d.ts +12 -0
- package/dist/cjs/decoration/decorators/response.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/response.js +49 -0
- package/dist/cjs/decoration/decorators/response.js.map +6 -0
- package/dist/cjs/decoration/errors.d.ts +29 -0
- package/dist/cjs/decoration/errors.d.ts.map +1 -0
- package/dist/cjs/decoration/errors.js +44 -0
- package/dist/cjs/decoration/errors.js.map +6 -0
- package/dist/cjs/decoration/index.d.ts +9 -0
- package/dist/cjs/decoration/index.d.ts.map +1 -0
- package/dist/cjs/decoration/index.js +26 -0
- package/dist/cjs/decoration/index.js.map +6 -0
- package/dist/cjs/decoration/semantics/ClassSemantics.d.ts +84 -0
- package/dist/cjs/decoration/semantics/ClassSemantics.d.ts.map +1 -0
- package/dist/cjs/decoration/semantics/ClassSemantics.js +266 -0
- package/dist/cjs/decoration/semantics/ClassSemantics.js.map +6 -0
- package/dist/cjs/decoration/semantics/FieldSemantics.d.ts +21 -0
- package/dist/cjs/decoration/semantics/FieldSemantics.d.ts.map +1 -0
- package/dist/cjs/decoration/semantics/FieldSemantics.js +57 -0
- package/dist/cjs/decoration/semantics/FieldSemantics.js.map +6 -0
- package/dist/cjs/decoration/semantics/Semantics.d.ts +68 -0
- package/dist/cjs/decoration/semantics/Semantics.d.ts.map +1 -0
- package/dist/cjs/decoration/semantics/Semantics.js +156 -0
- package/dist/cjs/decoration/semantics/Semantics.js.map +6 -0
- package/dist/cjs/decoration/semantics/index.d.ts +9 -0
- package/dist/cjs/decoration/semantics/index.d.ts.map +1 -0
- package/dist/cjs/decoration/semantics/index.js +26 -0
- package/dist/cjs/decoration/semantics/index.js.map +6 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/models/AttributeModel.d.ts +1 -0
- package/dist/cjs/models/AttributeModel.d.ts.map +1 -1
- package/dist/cjs/models/AttributeModel.js +1 -0
- package/dist/cjs/models/AttributeModel.js.map +1 -1
- package/dist/cjs/models/Children.js +3 -3
- package/dist/cjs/models/Children.js.map +1 -1
- package/dist/cjs/models/CommandModel.d.ts +1 -0
- package/dist/cjs/models/CommandModel.d.ts.map +1 -1
- package/dist/cjs/models/CommandModel.js +1 -0
- package/dist/cjs/models/CommandModel.js.map +1 -1
- package/dist/cjs/models/EventModel.d.ts +1 -0
- package/dist/cjs/models/EventModel.d.ts.map +1 -1
- package/dist/cjs/models/EventModel.js +1 -0
- package/dist/cjs/models/EventModel.js.map +1 -1
- package/dist/cjs/models/Globals.d.ts +1 -1
- package/dist/cjs/models/Model.d.ts +12 -3
- package/dist/cjs/models/Model.d.ts.map +1 -1
- package/dist/cjs/models/Model.js +16 -10
- package/dist/cjs/models/Model.js.map +1 -1
- package/dist/cjs/models/Schema.d.ts +14 -0
- package/dist/cjs/models/Schema.d.ts.map +1 -1
- package/dist/cjs/models/Schema.js +29 -1
- package/dist/cjs/models/Schema.js.map +1 -1
- package/dist/cjs/models/ScopeModel.d.ts +1 -1
- package/dist/cjs/models/ScopeModel.d.ts.map +1 -1
- package/dist/cjs/models/ScopeModel.js +2 -2
- package/dist/cjs/models/ScopeModel.js.map +1 -1
- package/dist/cjs/standard/elements/definitions.d.ts +1 -1
- package/dist/cjs/standard/elements/definitions.js +1 -1
- package/dist/cjs/standard/elements/{interval.element.d.ts → duration.element.d.ts} +1 -1
- package/dist/cjs/standard/elements/duration.element.d.ts.map +1 -0
- package/dist/cjs/standard/elements/{interval.element.js → duration.element.js} +4 -4
- package/dist/cjs/standard/elements/{interval.element.js.map → duration.element.js.map} +1 -1
- package/dist/cjs/standard/elements/models.d.ts +1 -1
- package/dist/cjs/standard/elements/models.js +2 -2
- package/dist/esm/common/Metatype.d.ts +1 -1
- package/dist/esm/decoration/decorators/attribute.d.ts +11 -0
- package/dist/esm/decoration/decorators/attribute.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/attribute.js +12 -0
- package/dist/esm/decoration/decorators/attribute.js.map +6 -0
- package/dist/esm/decoration/decorators/cluster.d.ts +11 -0
- package/dist/esm/decoration/decorators/cluster.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/cluster.js +12 -0
- package/dist/esm/decoration/decorators/cluster.js.map +6 -0
- package/dist/esm/decoration/decorators/command.d.ts +12 -0
- package/dist/esm/decoration/decorators/command.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/command.js +14 -0
- package/dist/esm/decoration/decorators/command.js.map +6 -0
- package/dist/esm/decoration/decorators/datatype.d.ts +11 -0
- package/dist/esm/decoration/decorators/datatype.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/datatype.js +12 -0
- package/dist/esm/decoration/decorators/datatype.js.map +6 -0
- package/dist/esm/decoration/decorators/element.d.ts +40 -0
- package/dist/esm/decoration/decorators/element.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/element.js +81 -0
- package/dist/esm/decoration/decorators/element.js.map +6 -0
- package/dist/esm/decoration/decorators/event.d.ts +14 -0
- package/dist/esm/decoration/decorators/event.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/event.js +12 -0
- package/dist/esm/decoration/decorators/event.js.map +6 -0
- package/dist/esm/decoration/decorators/field.d.ts +14 -0
- package/dist/esm/decoration/decorators/field.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/field.js +12 -0
- package/dist/esm/decoration/decorators/field.js.map +6 -0
- package/dist/esm/decoration/decorators/index.d.ts +16 -0
- package/dist/esm/decoration/decorators/index.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/index.js +16 -0
- package/dist/esm/decoration/decorators/index.js.map +6 -0
- package/dist/esm/decoration/decorators/listOf.d.ts +12 -0
- package/dist/esm/decoration/decorators/listOf.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/listOf.js +27 -0
- package/dist/esm/decoration/decorators/listOf.js.map +6 -0
- package/dist/esm/decoration/decorators/mandatory.d.ts +11 -0
- package/dist/esm/decoration/decorators/mandatory.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/mandatory.js +21 -0
- package/dist/esm/decoration/decorators/mandatory.js.map +6 -0
- package/dist/esm/decoration/decorators/nonvolatile.d.ts +11 -0
- package/dist/esm/decoration/decorators/nonvolatile.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/nonvolatile.js +21 -0
- package/dist/esm/decoration/decorators/nonvolatile.js.map +6 -0
- package/dist/esm/decoration/decorators/nullable.d.ts +11 -0
- package/dist/esm/decoration/decorators/nullable.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/nullable.js +21 -0
- package/dist/esm/decoration/decorators/nullable.js.map +6 -0
- package/dist/esm/decoration/decorators/response.d.ts +12 -0
- package/dist/esm/decoration/decorators/response.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/response.js +29 -0
- package/dist/esm/decoration/decorators/response.js.map +6 -0
- package/dist/esm/decoration/errors.d.ts +29 -0
- package/dist/esm/decoration/errors.d.ts.map +1 -0
- package/dist/esm/decoration/errors.js +24 -0
- package/dist/esm/decoration/errors.js.map +6 -0
- package/dist/esm/decoration/index.d.ts +9 -0
- package/dist/esm/decoration/index.d.ts.map +1 -0
- package/dist/esm/decoration/index.js +9 -0
- package/dist/esm/decoration/index.js.map +6 -0
- package/dist/esm/decoration/semantics/ClassSemantics.d.ts +84 -0
- package/dist/esm/decoration/semantics/ClassSemantics.d.ts.map +1 -0
- package/dist/esm/decoration/semantics/ClassSemantics.js +246 -0
- package/dist/esm/decoration/semantics/ClassSemantics.js.map +6 -0
- package/dist/esm/decoration/semantics/FieldSemantics.d.ts +21 -0
- package/dist/esm/decoration/semantics/FieldSemantics.d.ts.map +1 -0
- package/dist/esm/decoration/semantics/FieldSemantics.js +37 -0
- package/dist/esm/decoration/semantics/FieldSemantics.js.map +6 -0
- package/dist/esm/decoration/semantics/Semantics.d.ts +68 -0
- package/dist/esm/decoration/semantics/Semantics.d.ts.map +1 -0
- package/dist/esm/decoration/semantics/Semantics.js +126 -0
- package/dist/esm/decoration/semantics/Semantics.js.map +6 -0
- package/dist/esm/decoration/semantics/index.d.ts +9 -0
- package/dist/esm/decoration/semantics/index.d.ts.map +1 -0
- package/dist/esm/decoration/semantics/index.js +9 -0
- package/dist/esm/decoration/semantics/index.js.map +6 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/models/AttributeModel.d.ts +1 -0
- package/dist/esm/models/AttributeModel.d.ts.map +1 -1
- package/dist/esm/models/AttributeModel.js +1 -0
- package/dist/esm/models/AttributeModel.js.map +1 -1
- package/dist/esm/models/Children.js +3 -3
- package/dist/esm/models/Children.js.map +1 -1
- package/dist/esm/models/CommandModel.d.ts +1 -0
- package/dist/esm/models/CommandModel.d.ts.map +1 -1
- package/dist/esm/models/CommandModel.js +1 -0
- package/dist/esm/models/CommandModel.js.map +1 -1
- package/dist/esm/models/EventModel.d.ts +1 -0
- package/dist/esm/models/EventModel.d.ts.map +1 -1
- package/dist/esm/models/EventModel.js +1 -0
- package/dist/esm/models/EventModel.js.map +1 -1
- package/dist/esm/models/Globals.d.ts +1 -1
- package/dist/esm/models/Model.d.ts +12 -3
- package/dist/esm/models/Model.d.ts.map +1 -1
- package/dist/esm/models/Model.js +16 -10
- package/dist/esm/models/Model.js.map +1 -1
- package/dist/esm/models/Schema.d.ts +14 -0
- package/dist/esm/models/Schema.d.ts.map +1 -1
- package/dist/esm/models/Schema.js +29 -1
- package/dist/esm/models/Schema.js.map +1 -1
- package/dist/esm/models/ScopeModel.d.ts +1 -1
- package/dist/esm/models/ScopeModel.d.ts.map +1 -1
- package/dist/esm/models/ScopeModel.js +2 -2
- package/dist/esm/models/ScopeModel.js.map +1 -1
- package/dist/esm/standard/elements/definitions.d.ts +1 -1
- package/dist/esm/standard/elements/definitions.js +1 -1
- package/dist/esm/standard/elements/{interval.element.d.ts → duration.element.d.ts} +1 -1
- package/dist/esm/standard/elements/duration.element.d.ts.map +1 -0
- package/dist/esm/standard/elements/{interval.element.js → duration.element.js} +1 -1
- package/dist/esm/standard/elements/{interval.element.js.map → duration.element.js.map} +1 -1
- package/dist/esm/standard/elements/models.d.ts +1 -1
- package/dist/esm/standard/elements/models.js +2 -2
- package/package.json +4 -4
- package/src/decoration/decorators/attribute.ts +13 -0
- package/src/decoration/decorators/cluster.ts +13 -0
- package/src/decoration/decorators/command.ts +16 -0
- package/src/decoration/decorators/datatype.ts +13 -0
- package/src/decoration/decorators/element.ts +128 -0
- package/src/decoration/decorators/event.ts +16 -0
- package/src/decoration/decorators/field.ts +16 -0
- package/src/decoration/decorators/index.ts +16 -0
- package/src/decoration/decorators/listOf.ts +30 -0
- package/src/decoration/decorators/mandatory.ts +22 -0
- package/src/decoration/decorators/nonvolatile.ts +22 -0
- package/src/decoration/decorators/nullable.ts +22 -0
- package/src/decoration/decorators/response.ts +34 -0
- package/src/decoration/errors.ts +29 -0
- package/src/decoration/index.ts +9 -0
- package/src/decoration/semantics/ClassSemantics.ts +374 -0
- package/src/decoration/semantics/FieldSemantics.ts +49 -0
- package/src/decoration/semantics/Semantics.ts +170 -0
- package/src/decoration/semantics/index.ts +9 -0
- package/src/index.ts +1 -0
- package/src/models/AttributeModel.ts +1 -0
- package/src/models/Children.ts +3 -3
- package/src/models/CommandModel.ts +1 -0
- package/src/models/EventModel.ts +1 -0
- package/src/models/Model.ts +34 -12
- package/src/models/Schema.ts +51 -0
- package/src/models/ScopeModel.ts +2 -2
- package/src/standard/elements/definitions.ts +1 -1
- package/src/standard/elements/models.ts +1 -1
- package/dist/cjs/standard/elements/interval.element.d.ts.map +0 -1
- package/dist/esm/standard/elements/interval.element.d.ts.map +0 -1
- /package/src/standard/elements/{interval.element.ts → duration.element.ts} +0 -0
package/src/models/Children.ts
CHANGED
|
@@ -556,9 +556,9 @@ export function Children<T extends Model = Model>(
|
|
|
556
556
|
});
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
-
function
|
|
559
|
+
function finalize() {
|
|
560
560
|
for (const child of self) {
|
|
561
|
-
(child as Model).
|
|
561
|
+
(child as Model).finalize();
|
|
562
562
|
}
|
|
563
563
|
Object.freeze(children);
|
|
564
564
|
}
|
|
@@ -621,7 +621,7 @@ export function Children<T extends Model = Model>(
|
|
|
621
621
|
return splice;
|
|
622
622
|
|
|
623
623
|
case "freeze":
|
|
624
|
-
return
|
|
624
|
+
return finalize;
|
|
625
625
|
|
|
626
626
|
case "toString":
|
|
627
627
|
return () => `[Children: ${children.length}]`;
|
package/src/models/EventModel.ts
CHANGED
package/src/models/Model.ts
CHANGED
|
@@ -31,7 +31,7 @@ export abstract class Model<E extends BaseElement = BaseElement, C extends Model
|
|
|
31
31
|
|
|
32
32
|
#id: E["id"];
|
|
33
33
|
#name: string;
|
|
34
|
-
#
|
|
34
|
+
#isFinal?: boolean;
|
|
35
35
|
#resource?: Resource;
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -65,7 +65,7 @@ export abstract class Model<E extends BaseElement = BaseElement, C extends Model
|
|
|
65
65
|
set id(value: E["id"]) {
|
|
66
66
|
const oldId = this.effectiveId;
|
|
67
67
|
this.#id = value;
|
|
68
|
-
(this.#parent?.children as InternalChildren)
|
|
68
|
+
(this.#parent?.children as InternalChildren | undefined)?.updateId(this, oldId);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
get name() {
|
|
@@ -75,7 +75,7 @@ export abstract class Model<E extends BaseElement = BaseElement, C extends Model
|
|
|
75
75
|
set name(value: string) {
|
|
76
76
|
const oldName = this.#name;
|
|
77
77
|
this.#name = value;
|
|
78
|
-
(this.#parent?.children as InternalChildren)
|
|
78
|
+
(this.#parent?.children as InternalChildren | undefined)?.updateName(this, oldName);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/**
|
|
@@ -598,28 +598,36 @@ export abstract class Model<E extends BaseElement = BaseElement, C extends Model
|
|
|
598
598
|
if (children.length) {
|
|
599
599
|
this.children.push(...children);
|
|
600
600
|
}
|
|
601
|
+
|
|
602
|
+
if (!isClone && definition.parent) {
|
|
603
|
+
this.parent = definition.parent;
|
|
604
|
+
}
|
|
601
605
|
}
|
|
602
606
|
|
|
603
607
|
/**
|
|
604
|
-
*
|
|
608
|
+
* Finalize the model hierarchy rooted at this model.
|
|
605
609
|
*
|
|
606
610
|
* When using a model as operational schema we implement various optimizations that assume the schema is immutable.
|
|
607
611
|
* This function enforces that assumption and caches a few values that only make sense with frozen schema.
|
|
608
612
|
*
|
|
609
|
-
* To make changes to a
|
|
613
|
+
* To make changes to a final model use {@link clone}.
|
|
610
614
|
*/
|
|
611
|
-
|
|
612
|
-
if (this.#
|
|
615
|
+
finalize() {
|
|
616
|
+
if (this.#isFinal) {
|
|
613
617
|
return;
|
|
614
618
|
}
|
|
615
619
|
|
|
616
620
|
const base = this.operationalBase ?? (this.operationalBase = this.base ?? null);
|
|
617
621
|
const shadow = this.operationalShadow ?? (this.operationalShadow = this.shadow ?? null);
|
|
618
|
-
this.#
|
|
622
|
+
this.#isFinal = true;
|
|
619
623
|
(this.children as InternalChildren<C>).freeze();
|
|
620
624
|
Object.freeze(this);
|
|
621
|
-
base?.
|
|
622
|
-
shadow?.
|
|
625
|
+
base?.finalize();
|
|
626
|
+
shadow?.finalize();
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
get isFinal() {
|
|
630
|
+
return this.#isFinal;
|
|
623
631
|
}
|
|
624
632
|
|
|
625
633
|
toString() {
|
|
@@ -743,9 +751,20 @@ export namespace Model {
|
|
|
743
751
|
* In most places elements and models are interchangeable on input.
|
|
744
752
|
*/
|
|
745
753
|
export type Definition<T extends Model> =
|
|
746
|
-
| (BaseElement.Properties<ElementOf<T>> & {
|
|
754
|
+
| (BaseElement.Properties<ElementOf<T>> & {
|
|
755
|
+
parent?: Model;
|
|
756
|
+
operationalBase?: Model;
|
|
757
|
+
operationalShadow?: Model;
|
|
758
|
+
})
|
|
747
759
|
| T;
|
|
748
760
|
|
|
761
|
+
/**
|
|
762
|
+
* An object that may be used in some places where a model is required.
|
|
763
|
+
*
|
|
764
|
+
* This is either a model, a class constructor or a DecoratorContext.
|
|
765
|
+
*/
|
|
766
|
+
export type Source = Model | NewableFunction;
|
|
767
|
+
|
|
749
768
|
/**
|
|
750
769
|
* Tagged input. Like {@link Definition} but for places where model type is not implied.
|
|
751
770
|
*/
|
|
@@ -769,7 +788,10 @@ export namespace Model {
|
|
|
769
788
|
/**
|
|
770
789
|
* A model constructor for a specific element type.
|
|
771
790
|
*/
|
|
772
|
-
export type ConcreteType<T extends Model = Model> = (new (definition: any) => T) & {
|
|
791
|
+
export type ConcreteType<T extends Model = Model> = (new (definition: any) => T) & {
|
|
792
|
+
Tag: ElementTag;
|
|
793
|
+
requiresId?: boolean;
|
|
794
|
+
};
|
|
773
795
|
|
|
774
796
|
/**
|
|
775
797
|
* A patch to a model tree.
|
package/src/models/Schema.ts
CHANGED
|
@@ -4,11 +4,17 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { ImplementationError } from "#general";
|
|
7
8
|
import type { ClusterModel } from "#models/ClusterModel.js";
|
|
8
9
|
import { DatatypeModel } from "#models/DatatypeModel.js";
|
|
10
|
+
import type { Model } from "#models/Model.js";
|
|
9
11
|
import type { ValueModel } from "#models/ValueModel.js";
|
|
12
|
+
import { MissingMetadataError } from "../decoration/errors.js";
|
|
13
|
+
import { Semantics } from "../decoration/semantics/Semantics.js";
|
|
10
14
|
|
|
11
15
|
/**
|
|
16
|
+
* Matter data structure semantics
|
|
17
|
+
*
|
|
12
18
|
* Here we use the term "schema" to mean any model element that defines a datatype. For schema we allow any Matter
|
|
13
19
|
* model for such an element.
|
|
14
20
|
*
|
|
@@ -18,9 +24,54 @@ import type { ValueModel } from "#models/ValueModel.js";
|
|
|
18
24
|
* to JS objects and arrays respectively. Thus we tend to use struct/object and list/array interchangeably.
|
|
19
25
|
*
|
|
20
26
|
* If schema is a {@link ClusterModel}, it models a struct with attributes as fields.
|
|
27
|
+
*
|
|
28
|
+
* Schema is immutable and cannot change moving forward.
|
|
21
29
|
*/
|
|
22
30
|
export type Schema = ClusterModel | ValueModel;
|
|
23
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Obtain {@link Schema} for a {@link Schema.Source} if present.
|
|
34
|
+
*/
|
|
35
|
+
export function Schema(source: Model.Source) {
|
|
36
|
+
let model;
|
|
37
|
+
if ("tag" in source) {
|
|
38
|
+
source.finalize();
|
|
39
|
+
|
|
40
|
+
model = source;
|
|
41
|
+
} else {
|
|
42
|
+
const semantics = Semantics.classOf(source);
|
|
43
|
+
|
|
44
|
+
semantics.finalize();
|
|
45
|
+
|
|
46
|
+
model = semantics.semanticModel;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!model) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (model.tag !== "cluster" && !model.isType) {
|
|
54
|
+
throw new ImplementationError(`Model ${model.name} tag ${model.tag} is not legal for schema`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return model as Schema;
|
|
58
|
+
}
|
|
59
|
+
|
|
24
60
|
export namespace Schema {
|
|
61
|
+
/**
|
|
62
|
+
* Obtain {@link Schema} that is required for operation.
|
|
63
|
+
*/
|
|
64
|
+
export function Required(source: Model.Source) {
|
|
65
|
+
const schema = Schema(source);
|
|
66
|
+
|
|
67
|
+
if (schema === undefined) {
|
|
68
|
+
throw new MissingMetadataError(`Metadata missing for class ${source.name}`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return schema;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type Source = Schema | NewableFunction;
|
|
75
|
+
|
|
25
76
|
export const empty = new DatatypeModel({ name: "Empty", type: "struct" });
|
|
26
77
|
}
|
package/src/models/ScopeModel.ts
CHANGED
|
@@ -33,11 +33,11 @@ export abstract class ScopeModel<
|
|
|
33
33
|
return Scope(this);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
override
|
|
36
|
+
override finalize() {
|
|
37
37
|
if (!this.#operationalScope) {
|
|
38
38
|
this.#operationalScope = Scope(this);
|
|
39
39
|
}
|
|
40
|
-
super.
|
|
40
|
+
super.finalize();
|
|
41
41
|
return this;
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -210,7 +210,7 @@ export * from "./locationdesc.element.js";
|
|
|
210
210
|
export * from "./wildcard-path-flags-bitmap.element.js";
|
|
211
211
|
export * from "./software-version-certification-status-enum.element.js";
|
|
212
212
|
export * from "./any.element.js";
|
|
213
|
-
export * from "./
|
|
213
|
+
export * from "./duration.element.js";
|
|
214
214
|
export * from "./subject-id.element.js";
|
|
215
215
|
export * from "./cluster-revision.element.js";
|
|
216
216
|
export * from "./feature-map.element.js";
|
|
@@ -230,7 +230,7 @@ export const SoftwareVersionCertificationStatusEnum = new DatatypeModel(
|
|
|
230
230
|
definitions.SoftwareVersionCertificationStatusEnum,
|
|
231
231
|
);
|
|
232
232
|
export const any = new DatatypeModel(definitions.any);
|
|
233
|
-
export const
|
|
233
|
+
export const duration = new DatatypeModel(definitions.duration);
|
|
234
234
|
export const subjectId = new DatatypeModel(definitions.subjectId);
|
|
235
235
|
export const ClusterRevision = new AttributeModel(definitions.ClusterRevision);
|
|
236
236
|
export const FeatureMap = new AttributeModel(definitions.FeatureMap);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interval.element.d.ts","sourceRoot":"","sources":["../../../../src/standard/elements/interval.element.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,eAAe,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEtE,eAAO,MAAM,QAAQ,UAAuD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interval.element.d.ts","sourceRoot":"","sources":["../../../../src/standard/elements/interval.element.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,eAAe,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEtE,eAAO,MAAM,QAAQ,UAAuD,CAAC"}
|
|
File without changes
|