@api-client/core 0.11.11 → 0.12.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/Testing.md +1 -1
- package/bin/plugins/events/EventPlugin.ts +61 -0
- package/bin/plugins/events/assert.ts +193 -0
- package/bin/plugins/events/types.ts +6 -0
- package/bin/test.ts +8 -1
- package/build/src/amf/AmfShapeGenerator.d.ts +6 -3
- package/build/src/amf/AmfShapeGenerator.d.ts.map +1 -1
- package/build/src/amf/AmfShapeGenerator.js +4 -1
- package/build/src/amf/AmfShapeGenerator.js.map +1 -1
- package/build/src/amf/AmfTypes.d.ts +2 -2
- package/build/src/amf/AmfTypes.d.ts.map +1 -1
- package/build/src/amf/AmfTypes.js.map +1 -1
- package/build/src/amf/DataValueGenerator.d.ts +15 -15
- package/build/src/amf/DataValueGenerator.d.ts.map +1 -1
- package/build/src/amf/DataValueGenerator.js +14 -14
- package/build/src/amf/DataValueGenerator.js.map +1 -1
- package/build/src/browser.d.ts +12 -9
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +11 -8
- package/build/src/browser.js.map +1 -1
- package/build/src/exceptions/attach_exception.d.ts +11 -0
- package/build/src/exceptions/attach_exception.d.ts.map +1 -0
- package/build/src/exceptions/attach_exception.js +11 -0
- package/build/src/exceptions/attach_exception.js.map +1 -0
- package/build/src/exceptions/detach_exception.d.ts +11 -0
- package/build/src/exceptions/detach_exception.d.ts.map +1 -0
- package/build/src/exceptions/detach_exception.js +11 -0
- package/build/src/exceptions/detach_exception.js.map +1 -0
- package/build/src/exceptions/remove_model_exception.d.ts +8 -0
- package/build/src/exceptions/remove_model_exception.d.ts.map +1 -0
- package/build/src/exceptions/remove_model_exception.js +8 -0
- package/build/src/exceptions/remove_model_exception.js.map +1 -0
- package/build/src/exceptions/remove_namespace_exception.d.ts +8 -0
- package/build/src/exceptions/remove_namespace_exception.d.ts.map +1 -0
- package/build/src/exceptions/remove_namespace_exception.js +8 -0
- package/build/src/exceptions/remove_namespace_exception.js.map +1 -0
- package/build/src/index.d.ts +12 -9
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +11 -8
- package/build/src/index.js.map +1 -1
- package/build/src/legacy.d.ts +8 -0
- package/build/src/legacy.d.ts.map +1 -1
- package/build/src/legacy.js +9 -0
- package/build/src/legacy.js.map +1 -1
- package/build/src/modeling/Bindings.d.ts +2 -2
- package/build/src/modeling/Bindings.d.ts.map +1 -1
- package/build/src/modeling/Bindings.js.map +1 -1
- package/build/src/modeling/DataDomain.d.ts +601 -0
- package/build/src/modeling/DataDomain.d.ts.map +1 -0
- package/build/src/modeling/DataDomain.js +1142 -0
- package/build/src/modeling/DataDomain.js.map +1 -0
- package/build/src/modeling/DataFormat.d.ts +42 -41
- package/build/src/modeling/DataFormat.d.ts.map +1 -1
- package/build/src/modeling/DataFormat.js +30 -131
- package/build/src/modeling/DataFormat.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +281 -0
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -0
- package/build/src/modeling/DomainAssociation.js +440 -0
- package/build/src/modeling/DomainAssociation.js.map +1 -0
- package/build/src/modeling/DomainElement.d.ts +33 -0
- package/build/src/modeling/DomainElement.d.ts.map +1 -0
- package/build/src/modeling/DomainElement.js +32 -0
- package/build/src/modeling/DomainElement.js.map +1 -0
- package/build/src/modeling/DomainEntity.d.ts +383 -0
- package/build/src/modeling/DomainEntity.d.ts.map +1 -0
- package/build/src/modeling/DomainEntity.js +718 -0
- package/build/src/modeling/DomainEntity.js.map +1 -0
- package/build/src/modeling/DomainFile.d.ts +25 -0
- package/build/src/modeling/DomainFile.d.ts.map +1 -0
- package/build/src/modeling/DomainFile.js +86 -0
- package/build/src/modeling/DomainFile.js.map +1 -0
- package/build/src/modeling/DomainImpactAnalysis.d.ts +60 -47
- package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.js +201 -132
- package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
- package/build/src/modeling/DomainModel.d.ts +226 -0
- package/build/src/modeling/DomainModel.d.ts.map +1 -0
- package/build/src/modeling/DomainModel.js +401 -0
- package/build/src/modeling/DomainModel.js.map +1 -0
- package/build/src/modeling/DomainNamespace.d.ts +268 -0
- package/build/src/modeling/DomainNamespace.d.ts.map +1 -0
- package/build/src/modeling/DomainNamespace.js +512 -0
- package/build/src/modeling/DomainNamespace.js.map +1 -0
- package/build/src/modeling/DomainProperty.d.ts +281 -0
- package/build/src/modeling/DomainProperty.d.ts.map +1 -0
- package/build/src/modeling/DomainProperty.js +560 -0
- package/build/src/modeling/DomainProperty.js.map +1 -0
- package/build/src/modeling/DomainSerialization.d.ts +40 -0
- package/build/src/modeling/DomainSerialization.d.ts.map +1 -0
- package/build/src/modeling/DomainSerialization.js +288 -0
- package/build/src/modeling/DomainSerialization.js.map +1 -0
- package/build/src/modeling/DomainVersioning.d.ts +17 -0
- package/build/src/modeling/DomainVersioning.d.ts.map +1 -0
- package/build/src/modeling/DomainVersioning.js +124 -0
- package/build/src/modeling/DomainVersioning.js.map +1 -0
- package/build/src/modeling/GraphUtils.d.ts +8 -0
- package/build/src/modeling/GraphUtils.d.ts.map +1 -0
- package/build/src/modeling/GraphUtils.js +26 -0
- package/build/src/modeling/GraphUtils.js.map +1 -0
- package/build/src/modeling/amf/ShapeGenerator.d.ts +164 -0
- package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -0
- package/build/src/modeling/amf/ShapeGenerator.js +492 -0
- package/build/src/modeling/amf/ShapeGenerator.js.map +1 -0
- package/build/src/modeling/{DataAssociation.d.ts → legacy/DataAssociation.d.ts} +10 -5
- package/build/src/modeling/legacy/DataAssociation.d.ts.map +1 -0
- package/build/src/modeling/{DataAssociation.js → legacy/DataAssociation.js} +9 -6
- package/build/src/modeling/legacy/DataAssociation.js.map +1 -0
- package/build/src/modeling/{DataEntity.d.ts → legacy/DataEntity.d.ts} +12 -7
- package/build/src/modeling/legacy/DataEntity.d.ts.map +1 -0
- package/build/src/modeling/{DataEntity.js → legacy/DataEntity.js} +19 -18
- package/build/src/modeling/legacy/DataEntity.js.map +1 -0
- package/build/src/modeling/{DataEntityBuilder.d.ts → legacy/DataEntityBuilder.d.ts} +3 -2
- package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +1 -0
- package/build/src/modeling/{DataEntityBuilder.js → legacy/DataEntityBuilder.js} +3 -2
- package/build/src/modeling/legacy/DataEntityBuilder.js.map +1 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +298 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +1 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.js +441 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.js.map +1 -0
- package/build/src/modeling/{DataModel.d.ts → legacy/DataModel.d.ts} +6 -4
- package/build/src/modeling/legacy/DataModel.d.ts.map +1 -0
- package/build/src/modeling/{DataModel.js → legacy/DataModel.js} +7 -6
- package/build/src/modeling/legacy/DataModel.js.map +1 -0
- package/build/src/modeling/{DataNamespace.d.ts → legacy/DataNamespace.d.ts} +22 -3
- package/build/src/modeling/legacy/DataNamespace.d.ts.map +1 -0
- package/build/src/modeling/{DataNamespace.js → legacy/DataNamespace.js} +7 -3
- package/build/src/modeling/legacy/DataNamespace.js.map +1 -0
- package/build/src/modeling/{DataProperty.d.ts → legacy/DataProperty.d.ts} +13 -5
- package/build/src/modeling/legacy/DataProperty.d.ts.map +1 -0
- package/build/src/modeling/{DataProperty.js → legacy/DataProperty.js} +8 -5
- package/build/src/modeling/legacy/DataProperty.js.map +1 -0
- package/build/src/modeling/observed.d.ts +67 -0
- package/build/src/modeling/observed.d.ts.map +1 -0
- package/build/src/modeling/observed.js +230 -0
- package/build/src/modeling/observed.js.map +1 -0
- package/build/src/modeling/types.d.ts +165 -1
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/src/models/Thing.d.ts +26 -5
- package/build/src/models/Thing.d.ts.map +1 -1
- package/build/src/models/Thing.js +193 -91
- package/build/src/models/Thing.js.map +1 -1
- package/build/src/models/kinds.d.ts +31 -6
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +31 -6
- package/build/src/models/kinds.js.map +1 -1
- package/build/src/models/store/DataFile.d.ts +3 -1
- package/build/src/models/store/DataFile.d.ts.map +1 -1
- package/build/src/models/store/DataFile.js +2 -0
- package/build/src/models/store/DataFile.js.map +1 -1
- package/build/src/models/types.d.ts +12 -0
- package/build/src/models/types.d.ts.map +1 -0
- package/build/src/models/types.js +2 -0
- package/build/src/models/types.js.map +1 -0
- package/build/src/runtime/store/FilesSdk.d.ts +2 -2
- package/build/src/runtime/store/FilesSdk.d.ts.map +1 -1
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/data/models/example-generator-api.json +16 -16
- package/package.json +20 -6
- package/readme.md +1 -1
- package/src/amf/AmfShapeGenerator.ts +7 -4
- package/src/amf/AmfTypes.ts +2 -2
- package/src/amf/DataValueGenerator.ts +21 -21
- package/src/exceptions/attach_exception.ts +11 -0
- package/src/exceptions/detach_exception.ts +11 -0
- package/src/exceptions/remove_model_exception.ts +8 -0
- package/src/exceptions/remove_namespace_exception.ts +8 -0
- package/src/modeling/Bindings.ts +2 -2
- package/src/modeling/DataDomain.ts +1221 -0
- package/src/modeling/DataFormat.ts +54 -163
- package/src/modeling/DomainAssociation.ts +476 -0
- package/src/modeling/DomainElement.ts +50 -0
- package/src/modeling/DomainEntity.ts +769 -0
- package/src/modeling/DomainFile.ts +94 -0
- package/src/modeling/DomainImpactAnalysis.ts +218 -144
- package/src/modeling/DomainModel.ts +421 -0
- package/src/modeling/DomainNamespace.ts +537 -0
- package/src/modeling/DomainProperty.ts +548 -0
- package/src/modeling/DomainSerialization.ts +312 -0
- package/src/modeling/DomainVersioning.ts +144 -0
- package/src/modeling/GraphUtils.ts +28 -0
- package/src/modeling/amf/ShapeGenerator.ts +552 -0
- package/src/modeling/graph.md +115 -0
- package/src/modeling/{DataAssociation.ts → legacy/DataAssociation.ts} +13 -8
- package/src/modeling/{DataEntity.ts → legacy/DataEntity.ts} +28 -23
- package/src/modeling/{DataEntityBuilder.ts → legacy/DataEntityBuilder.ts} +4 -3
- package/src/modeling/legacy/DataImpactAnalysis.ts +530 -0
- package/src/modeling/{DataModel.ts → legacy/DataModel.ts} +10 -8
- package/src/modeling/{DataNamespace.ts → legacy/DataNamespace.ts} +23 -5
- package/src/modeling/{DataProperty.ts → legacy/DataProperty.ts} +15 -7
- package/src/modeling/observed.ts +267 -0
- package/src/modeling/types.ts +174 -1
- package/src/models/Thing.ts +70 -5
- package/src/models/kinds.ts +32 -6
- package/src/models/store/DataFile.ts +3 -1
- package/src/models/types.ts +11 -0
- package/src/runtime/store/FilesSdk.ts +2 -2
- package/tests/unit/amf/data_value_generator.spec.ts +15 -15
- package/tests/unit/legacy-transformers/ARC-legacy-import.spec.ts +1 -1
- package/tests/unit/modeling/amf/shape_generator.spec.ts +1174 -0
- package/tests/unit/modeling/data_domain.spec.ts +444 -0
- package/tests/unit/modeling/data_domain_associations.spec.ts +279 -0
- package/tests/unit/modeling/data_domain_change_observers.spec.ts +681 -0
- package/tests/unit/modeling/data_domain_entities.spec.ts +449 -0
- package/tests/unit/modeling/data_domain_foreign.spec.ts +355 -0
- package/tests/unit/modeling/data_domain_models.spec.ts +658 -0
- package/tests/unit/modeling/data_domain_namespaces.spec.ts +668 -0
- package/tests/unit/modeling/data_domain_property.spec.ts +264 -0
- package/tests/unit/modeling/data_domain_serialization.spec.ts +294 -0
- package/tests/unit/modeling/domain.property.spec.ts +822 -0
- package/tests/unit/modeling/domain_asociation.spec.ts +643 -0
- package/tests/unit/modeling/domain_asociation_targets.spec.ts +350 -0
- package/tests/unit/modeling/domain_entity.spec.ts +730 -0
- package/tests/unit/modeling/domain_entity_associations.spec.ts +330 -0
- package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +988 -0
- package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +1451 -0
- package/tests/unit/modeling/domain_entity_fields.spec.ts +113 -0
- package/tests/unit/modeling/domain_entity_generators.spec.ts +20 -0
- package/tests/unit/modeling/domain_entity_parents.spec.ts +291 -0
- package/tests/unit/modeling/domain_entity_properties.spec.ts +305 -0
- package/tests/unit/modeling/{data_file.spec.ts → domain_file.spec.ts} +29 -85
- package/tests/unit/modeling/domain_impact_analysis.spec.ts +452 -0
- package/tests/unit/modeling/domain_model.spec.ts +568 -0
- package/tests/unit/modeling/domain_model_entities.spec.ts +408 -0
- package/tests/unit/modeling/domain_namespace.spec.ts +514 -0
- package/tests/unit/modeling/domain_namespace_models.spec.ts +324 -0
- package/tests/unit/modeling/domain_namespace_namespaces.spec.ts +404 -0
- package/tests/unit/modeling/domain_versioning.spec.ts +140 -0
- package/tests/unit/{amf → modeling/legacy}/amf_shape_generator.spec.ts +11 -11
- package/tests/unit/modeling/{data_association.spec.ts → legacy/data_association.spec.ts} +3 -11
- package/tests/unit/modeling/{data_entity.spec.ts → legacy/data_entity.spec.ts} +10 -8
- package/tests/unit/modeling/{data_entity_generator_json.spec.ts → legacy/data_entity_generator_json.spec.ts} +1 -1
- package/tests/unit/modeling/{data_entity_generator_xml.spec.ts → legacy/data_entity_generator_xml.spec.ts} +1 -1
- package/tests/unit/modeling/{data_model.spec.ts → legacy/data_model.spec.ts} +3 -3
- package/tests/unit/modeling/{data_namespace.spec.ts → legacy/data_namespace.spec.ts} +3 -10
- package/tests/unit/modeling/{data_property.spec.ts → legacy/data_property.spec.ts} +3 -6
- package/tests/unit/modeling/{impact_analysis.spec.ts → legacy/impact_analysis.spec.ts} +9 -9
- package/tests/unit/models/File/new.spec.ts +1 -1
- package/tests/unit/models/HttpProject.spec.ts +3 -3
- package/tsconfig.node.json +35 -0
- package/build/src/modeling/DataAssociation.d.ts.map +0 -1
- package/build/src/modeling/DataAssociation.js.map +0 -1
- package/build/src/modeling/DataEntity.d.ts.map +0 -1
- package/build/src/modeling/DataEntity.js.map +0 -1
- package/build/src/modeling/DataEntityBuilder.d.ts.map +0 -1
- package/build/src/modeling/DataEntityBuilder.js.map +0 -1
- package/build/src/modeling/DataModel.d.ts.map +0 -1
- package/build/src/modeling/DataModel.js.map +0 -1
- package/build/src/modeling/DataNamespace.d.ts.map +0 -1
- package/build/src/modeling/DataNamespace.js.map +0 -1
- package/build/src/modeling/DataProperty.d.ts.map +0 -1
- package/build/src/modeling/DataProperty.js.map +0 -1
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { DomainPropertyKind } from '../models/kinds.js';
|
|
3
|
+
import { DomainElement } from './DomainElement.js';
|
|
4
|
+
import { nanoid } from 'nanoid';
|
|
5
|
+
import { Thing } from '../models/Thing.js';
|
|
6
|
+
import { observed, retargetChange, toRaw } from './observed.js';
|
|
7
|
+
import { BinaryFormats, DomainPropertyAttributes, DomainPropertyList, DomainPropertyTypes, NumberFormats, } from './DataFormat.js';
|
|
8
|
+
import { ShapeGenerator } from './amf/ShapeGenerator.js';
|
|
9
|
+
/**
|
|
10
|
+
* Represents a property within a data domain entity.
|
|
11
|
+
*
|
|
12
|
+
* A `DomainProperty` defines a single data element within a
|
|
13
|
+
* `DomainEntity`. It specifies the data type, constraints,
|
|
14
|
+
* and other metadata for a specific piece of information.
|
|
15
|
+
*
|
|
16
|
+
* **Key Features:**
|
|
17
|
+
*
|
|
18
|
+
* - **Data Type:** Defines the type of data the property
|
|
19
|
+
* holds (e.g., string, number, boolean, date).
|
|
20
|
+
* - **Constraints:** Supports defining constraints such as
|
|
21
|
+
* minimum/maximum values, enum values, and default values.
|
|
22
|
+
* - **Bindings:** Allows defining how the property is
|
|
23
|
+
* represented in different formats (e.g., web APIs,
|
|
24
|
+
* protocol buffers).
|
|
25
|
+
* - **Metadata:** Supports metadata such as tags, taxonomy,
|
|
26
|
+
* read-only/write-only status, and deprecation.
|
|
27
|
+
* - **Schema:** Allows defining a general schema for the
|
|
28
|
+
* property, which is propagated to all bindings.
|
|
29
|
+
*
|
|
30
|
+
* **Usage:**
|
|
31
|
+
*
|
|
32
|
+
* Use the `DataEntity.addProperty` method to add a new property to an
|
|
33
|
+
* entity. The property can be created using the constructor, but it
|
|
34
|
+
* won't be added to the graph until you call the `addProperty` method.
|
|
35
|
+
*
|
|
36
|
+
* **Example:**
|
|
37
|
+
*
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const entity = dataModel.addEntity({ key: 'user' });
|
|
40
|
+
* const property = entity.addProperty({
|
|
41
|
+
* key: 'name',
|
|
42
|
+
* type: 'string',
|
|
43
|
+
* required: true,
|
|
44
|
+
* schema: {
|
|
45
|
+
* minimum: 3,
|
|
46
|
+
* maximum: 50,
|
|
47
|
+
* },
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
let DomainProperty = (() => {
|
|
52
|
+
let _classSuper = DomainElement;
|
|
53
|
+
let _info_decorators;
|
|
54
|
+
let _info_initializers = [];
|
|
55
|
+
let _info_extraInitializers = [];
|
|
56
|
+
let _required_decorators;
|
|
57
|
+
let _required_initializers = [];
|
|
58
|
+
let _required_extraInitializers = [];
|
|
59
|
+
let _multiple_decorators;
|
|
60
|
+
let _multiple_initializers = [];
|
|
61
|
+
let _multiple_extraInitializers = [];
|
|
62
|
+
let _primary_decorators;
|
|
63
|
+
let _primary_initializers = [];
|
|
64
|
+
let _primary_extraInitializers = [];
|
|
65
|
+
let _index_decorators;
|
|
66
|
+
let _index_initializers = [];
|
|
67
|
+
let _index_extraInitializers = [];
|
|
68
|
+
let _readOnly_decorators;
|
|
69
|
+
let _readOnly_initializers = [];
|
|
70
|
+
let _readOnly_extraInitializers = [];
|
|
71
|
+
let _writeOnly_decorators;
|
|
72
|
+
let _writeOnly_initializers = [];
|
|
73
|
+
let _writeOnly_extraInitializers = [];
|
|
74
|
+
let _deprecated_decorators;
|
|
75
|
+
let _deprecated_initializers = [];
|
|
76
|
+
let _deprecated_extraInitializers = [];
|
|
77
|
+
let _tags_decorators;
|
|
78
|
+
let _tags_initializers = [];
|
|
79
|
+
let _tags_extraInitializers = [];
|
|
80
|
+
let _taxonomy_decorators;
|
|
81
|
+
let _taxonomy_initializers = [];
|
|
82
|
+
let _taxonomy_extraInitializers = [];
|
|
83
|
+
let _type_decorators;
|
|
84
|
+
let _type_initializers = [];
|
|
85
|
+
let _type_extraInitializers = [];
|
|
86
|
+
let _schema_decorators;
|
|
87
|
+
let _schema_initializers = [];
|
|
88
|
+
let _schema_extraInitializers = [];
|
|
89
|
+
let _bindings_decorators;
|
|
90
|
+
let _bindings_initializers = [];
|
|
91
|
+
let _bindings_extraInitializers = [];
|
|
92
|
+
return class DomainProperty extends _classSuper {
|
|
93
|
+
static {
|
|
94
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
95
|
+
_info_decorators = [retargetChange()];
|
|
96
|
+
_required_decorators = [observed()];
|
|
97
|
+
_multiple_decorators = [observed()];
|
|
98
|
+
_primary_decorators = [observed()];
|
|
99
|
+
_index_decorators = [observed()];
|
|
100
|
+
_readOnly_decorators = [observed()];
|
|
101
|
+
_writeOnly_decorators = [observed()];
|
|
102
|
+
_deprecated_decorators = [observed()];
|
|
103
|
+
_tags_decorators = [observed({ deep: true })];
|
|
104
|
+
_taxonomy_decorators = [observed({ deep: true })];
|
|
105
|
+
_type_decorators = [observed()];
|
|
106
|
+
_schema_decorators = [observed({ deep: true })];
|
|
107
|
+
_bindings_decorators = [observed({ deep: true })];
|
|
108
|
+
__esDecorate(this, null, _info_decorators, { kind: "accessor", name: "info", static: false, private: false, access: { has: obj => "info" in obj, get: obj => obj.info, set: (obj, value) => { obj.info = value; } }, metadata: _metadata }, _info_initializers, _info_extraInitializers);
|
|
109
|
+
__esDecorate(this, null, _required_decorators, { kind: "accessor", name: "required", static: false, private: false, access: { has: obj => "required" in obj, get: obj => obj.required, set: (obj, value) => { obj.required = value; } }, metadata: _metadata }, _required_initializers, _required_extraInitializers);
|
|
110
|
+
__esDecorate(this, null, _multiple_decorators, { kind: "accessor", name: "multiple", static: false, private: false, access: { has: obj => "multiple" in obj, get: obj => obj.multiple, set: (obj, value) => { obj.multiple = value; } }, metadata: _metadata }, _multiple_initializers, _multiple_extraInitializers);
|
|
111
|
+
__esDecorate(this, null, _primary_decorators, { kind: "accessor", name: "primary", static: false, private: false, access: { has: obj => "primary" in obj, get: obj => obj.primary, set: (obj, value) => { obj.primary = value; } }, metadata: _metadata }, _primary_initializers, _primary_extraInitializers);
|
|
112
|
+
__esDecorate(this, null, _index_decorators, { kind: "accessor", name: "index", static: false, private: false, access: { has: obj => "index" in obj, get: obj => obj.index, set: (obj, value) => { obj.index = value; } }, metadata: _metadata }, _index_initializers, _index_extraInitializers);
|
|
113
|
+
__esDecorate(this, null, _readOnly_decorators, { kind: "accessor", name: "readOnly", static: false, private: false, access: { has: obj => "readOnly" in obj, get: obj => obj.readOnly, set: (obj, value) => { obj.readOnly = value; } }, metadata: _metadata }, _readOnly_initializers, _readOnly_extraInitializers);
|
|
114
|
+
__esDecorate(this, null, _writeOnly_decorators, { kind: "accessor", name: "writeOnly", static: false, private: false, access: { has: obj => "writeOnly" in obj, get: obj => obj.writeOnly, set: (obj, value) => { obj.writeOnly = value; } }, metadata: _metadata }, _writeOnly_initializers, _writeOnly_extraInitializers);
|
|
115
|
+
__esDecorate(this, null, _deprecated_decorators, { kind: "accessor", name: "deprecated", static: false, private: false, access: { has: obj => "deprecated" in obj, get: obj => obj.deprecated, set: (obj, value) => { obj.deprecated = value; } }, metadata: _metadata }, _deprecated_initializers, _deprecated_extraInitializers);
|
|
116
|
+
__esDecorate(this, null, _tags_decorators, { kind: "accessor", name: "tags", static: false, private: false, access: { has: obj => "tags" in obj, get: obj => obj.tags, set: (obj, value) => { obj.tags = value; } }, metadata: _metadata }, _tags_initializers, _tags_extraInitializers);
|
|
117
|
+
__esDecorate(this, null, _taxonomy_decorators, { kind: "accessor", name: "taxonomy", static: false, private: false, access: { has: obj => "taxonomy" in obj, get: obj => obj.taxonomy, set: (obj, value) => { obj.taxonomy = value; } }, metadata: _metadata }, _taxonomy_initializers, _taxonomy_extraInitializers);
|
|
118
|
+
__esDecorate(this, null, _type_decorators, { kind: "accessor", name: "type", static: false, private: false, access: { has: obj => "type" in obj, get: obj => obj.type, set: (obj, value) => { obj.type = value; } }, metadata: _metadata }, _type_initializers, _type_extraInitializers);
|
|
119
|
+
__esDecorate(this, null, _schema_decorators, { kind: "accessor", name: "schema", static: false, private: false, access: { has: obj => "schema" in obj, get: obj => obj.schema, set: (obj, value) => { obj.schema = value; } }, metadata: _metadata }, _schema_initializers, _schema_extraInitializers);
|
|
120
|
+
__esDecorate(this, null, _bindings_decorators, { kind: "accessor", name: "bindings", static: false, private: false, access: { has: obj => "bindings" in obj, get: obj => obj.bindings, set: (obj, value) => { obj.bindings = value; } }, metadata: _metadata }, _bindings_initializers, _bindings_extraInitializers);
|
|
121
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
122
|
+
}
|
|
123
|
+
kind;
|
|
124
|
+
#info_accessor_storage = __runInitializers(this, _info_initializers, void 0);
|
|
125
|
+
/**
|
|
126
|
+
* The description of the domain property.
|
|
127
|
+
*/
|
|
128
|
+
get info() { return this.#info_accessor_storage; }
|
|
129
|
+
set info(value) { this.#info_accessor_storage = value; }
|
|
130
|
+
#required_accessor_storage = (__runInitializers(this, _info_extraInitializers), __runInitializers(this, _required_initializers, void 0));
|
|
131
|
+
/**
|
|
132
|
+
* Wether the data property is required.
|
|
133
|
+
*/
|
|
134
|
+
get required() { return this.#required_accessor_storage; }
|
|
135
|
+
set required(value) { this.#required_accessor_storage = value; }
|
|
136
|
+
#multiple_accessor_storage = (__runInitializers(this, _required_extraInitializers), __runInitializers(this, _multiple_initializers, void 0));
|
|
137
|
+
/**
|
|
138
|
+
* Whether the data property allows multiple items.
|
|
139
|
+
*/
|
|
140
|
+
get multiple() { return this.#multiple_accessor_storage; }
|
|
141
|
+
set multiple(value) { this.#multiple_accessor_storage = value; }
|
|
142
|
+
#primary_accessor_storage = (__runInitializers(this, _multiple_extraInitializers), __runInitializers(this, _primary_initializers, void 0));
|
|
143
|
+
/**
|
|
144
|
+
* Whether this property describes a primary key of the entity.
|
|
145
|
+
*/
|
|
146
|
+
get primary() { return this.#primary_accessor_storage; }
|
|
147
|
+
set primary(value) { this.#primary_accessor_storage = value; }
|
|
148
|
+
#index_accessor_storage = (__runInitializers(this, _primary_extraInitializers), __runInitializers(this, _index_initializers, void 0));
|
|
149
|
+
/**
|
|
150
|
+
* Whether this property describes an indexed property of the entity.
|
|
151
|
+
*/
|
|
152
|
+
get index() { return this.#index_accessor_storage; }
|
|
153
|
+
set index(value) { this.#index_accessor_storage = value; }
|
|
154
|
+
#readOnly_accessor_storage = (__runInitializers(this, _index_extraInitializers), __runInitializers(this, _readOnly_initializers, void 0));
|
|
155
|
+
/**
|
|
156
|
+
* Whether the property is read only in the schema.
|
|
157
|
+
*/
|
|
158
|
+
get readOnly() { return this.#readOnly_accessor_storage; }
|
|
159
|
+
set readOnly(value) { this.#readOnly_accessor_storage = value; }
|
|
160
|
+
#writeOnly_accessor_storage = (__runInitializers(this, _readOnly_extraInitializers), __runInitializers(this, _writeOnly_initializers, void 0));
|
|
161
|
+
/**
|
|
162
|
+
* Whether the property is write only in the schema.
|
|
163
|
+
*/
|
|
164
|
+
get writeOnly() { return this.#writeOnly_accessor_storage; }
|
|
165
|
+
set writeOnly(value) { this.#writeOnly_accessor_storage = value; }
|
|
166
|
+
#deprecated_accessor_storage = (__runInitializers(this, _writeOnly_extraInitializers), __runInitializers(this, _deprecated_initializers, void 0));
|
|
167
|
+
/**
|
|
168
|
+
* Whether this property is deprecated.
|
|
169
|
+
*/
|
|
170
|
+
get deprecated() { return this.#deprecated_accessor_storage; }
|
|
171
|
+
set deprecated(value) { this.#deprecated_accessor_storage = value; }
|
|
172
|
+
#tags_accessor_storage = (__runInitializers(this, _deprecated_extraInitializers), __runInitializers(this, _tags_initializers, []
|
|
173
|
+
/**
|
|
174
|
+
* Reserved for future use.
|
|
175
|
+
*
|
|
176
|
+
* The keys of the taxonomy items associated with the property.
|
|
177
|
+
*/
|
|
178
|
+
));
|
|
179
|
+
/**
|
|
180
|
+
* Optional general purpose tags for the UI.
|
|
181
|
+
*
|
|
182
|
+
* Note to implementations, use the `addTag()` method as it propagates the "tag" value in the namespace.
|
|
183
|
+
* Also, the tags property is excluded from the observer properties.
|
|
184
|
+
* Changes to this property will not notify the observers.
|
|
185
|
+
*/
|
|
186
|
+
get tags() { return this.#tags_accessor_storage; }
|
|
187
|
+
set tags(value) { this.#tags_accessor_storage = value; }
|
|
188
|
+
#taxonomy_accessor_storage = (__runInitializers(this, _tags_extraInitializers), __runInitializers(this, _taxonomy_initializers, []
|
|
189
|
+
/**
|
|
190
|
+
* The data type for this property.
|
|
191
|
+
* Note, not all schemas support the same type. For example, defining `sint32`
|
|
192
|
+
* works for protocol buffers but does not for JSON. In such case we use default
|
|
193
|
+
* translation `sint32` -> `number`. Another way it to create
|
|
194
|
+
* a derivative entity for specific schema to describe specific schema case.
|
|
195
|
+
*/
|
|
196
|
+
));
|
|
197
|
+
/**
|
|
198
|
+
* Reserved for future use.
|
|
199
|
+
*
|
|
200
|
+
* The keys of the taxonomy items associated with the property.
|
|
201
|
+
*/
|
|
202
|
+
get taxonomy() { return this.#taxonomy_accessor_storage; }
|
|
203
|
+
set taxonomy(value) { this.#taxonomy_accessor_storage = value; }
|
|
204
|
+
#type_accessor_storage = (__runInitializers(this, _taxonomy_extraInitializers), __runInitializers(this, _type_initializers, 'string'
|
|
205
|
+
/**
|
|
206
|
+
* The general schema definition of this property.
|
|
207
|
+
* This is propagated to all bindings (when they support these properties).
|
|
208
|
+
*/
|
|
209
|
+
));
|
|
210
|
+
/**
|
|
211
|
+
* The data type for this property.
|
|
212
|
+
* Note, not all schemas support the same type. For example, defining `sint32`
|
|
213
|
+
* works for protocol buffers but does not for JSON. In such case we use default
|
|
214
|
+
* translation `sint32` -> `number`. Another way it to create
|
|
215
|
+
* a derivative entity for specific schema to describe specific schema case.
|
|
216
|
+
*/
|
|
217
|
+
get type() { return this.#type_accessor_storage; }
|
|
218
|
+
set type(value) { this.#type_accessor_storage = value; }
|
|
219
|
+
#schema_accessor_storage = (__runInitializers(this, _type_extraInitializers), __runInitializers(this, _schema_initializers, void 0));
|
|
220
|
+
/**
|
|
221
|
+
* The general schema definition of this property.
|
|
222
|
+
* This is propagated to all bindings (when they support these properties).
|
|
223
|
+
*/
|
|
224
|
+
get schema() { return this.#schema_accessor_storage; }
|
|
225
|
+
set schema(value) { this.#schema_accessor_storage = value; }
|
|
226
|
+
#bindings_accessor_storage = (__runInitializers(this, _schema_extraInitializers), __runInitializers(this, _bindings_initializers, []
|
|
227
|
+
/**
|
|
228
|
+
* Creates a full data model schema with defaults.
|
|
229
|
+
*
|
|
230
|
+
* @param input The partial data model schema.
|
|
231
|
+
* @returns The data model schema.
|
|
232
|
+
*/
|
|
233
|
+
));
|
|
234
|
+
/**
|
|
235
|
+
* The list of bindings for this property.
|
|
236
|
+
*
|
|
237
|
+
* A binding defines a translation from a data model to a specific format.
|
|
238
|
+
* For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs
|
|
239
|
+
* or a protocol buffer schema.
|
|
240
|
+
*/
|
|
241
|
+
get bindings() { return this.#bindings_accessor_storage; }
|
|
242
|
+
set bindings(value) { this.#bindings_accessor_storage = value; }
|
|
243
|
+
/**
|
|
244
|
+
* Creates a full data model schema with defaults.
|
|
245
|
+
*
|
|
246
|
+
* @param input The partial data model schema.
|
|
247
|
+
* @returns The data model schema.
|
|
248
|
+
*/
|
|
249
|
+
static createSchema(input = {}) {
|
|
250
|
+
const { key = nanoid(), multiple, required, type = DomainPropertyList.string, index, primary, readOnly, writeOnly, tags, taxonomy, deprecated, schema, bindings, } = input;
|
|
251
|
+
if (typeof type === 'string') {
|
|
252
|
+
if (!DomainPropertyTypes.includes(type)) {
|
|
253
|
+
throw new Error(`Invalid data property type ${type}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const info = Thing.fromJSON(input.info, { name: 'New property' }).toJSON();
|
|
257
|
+
const result = {
|
|
258
|
+
kind: DomainPropertyKind,
|
|
259
|
+
key,
|
|
260
|
+
info,
|
|
261
|
+
type,
|
|
262
|
+
};
|
|
263
|
+
if (typeof multiple === 'boolean') {
|
|
264
|
+
result.multiple = multiple;
|
|
265
|
+
}
|
|
266
|
+
if (typeof required === 'boolean') {
|
|
267
|
+
result.required = required;
|
|
268
|
+
}
|
|
269
|
+
if (typeof index === 'boolean') {
|
|
270
|
+
result.index = index;
|
|
271
|
+
}
|
|
272
|
+
if (typeof primary === 'boolean') {
|
|
273
|
+
result.primary = primary;
|
|
274
|
+
}
|
|
275
|
+
if (typeof readOnly === 'boolean') {
|
|
276
|
+
result.readOnly = readOnly;
|
|
277
|
+
}
|
|
278
|
+
if (typeof writeOnly === 'boolean') {
|
|
279
|
+
result.writeOnly = writeOnly;
|
|
280
|
+
}
|
|
281
|
+
if (typeof deprecated === 'boolean') {
|
|
282
|
+
result.deprecated = deprecated;
|
|
283
|
+
}
|
|
284
|
+
if (Array.isArray(tags)) {
|
|
285
|
+
result.tags = [...tags];
|
|
286
|
+
}
|
|
287
|
+
if (Array.isArray(taxonomy)) {
|
|
288
|
+
result.taxonomy = [...taxonomy];
|
|
289
|
+
}
|
|
290
|
+
if (schema) {
|
|
291
|
+
result.schema = structuredClone(schema);
|
|
292
|
+
}
|
|
293
|
+
if (Array.isArray(bindings)) {
|
|
294
|
+
result.bindings = bindings.map((i) => structuredClone(i));
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
result.bindings = [];
|
|
298
|
+
}
|
|
299
|
+
return result;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* The key of the parent entity.
|
|
303
|
+
*/
|
|
304
|
+
parent = __runInitializers(this, _bindings_extraInitializers);
|
|
305
|
+
/**
|
|
306
|
+
* Creates a new domain property instance.
|
|
307
|
+
* It does not add it to the graph.
|
|
308
|
+
* You need to call the `addProperty` method of the graph or a data model to add it.
|
|
309
|
+
*
|
|
310
|
+
* Domain objects constructors shouldn't be used directly. Use methods
|
|
311
|
+
* provided on the DataDomain class to create new objects.
|
|
312
|
+
*
|
|
313
|
+
* @param root A reference to the root DataDomain instance.
|
|
314
|
+
* @param parent The key of the parent entity.
|
|
315
|
+
* @param input The partial domain property schema.
|
|
316
|
+
* @returns Created domain property instance.
|
|
317
|
+
*/
|
|
318
|
+
constructor(root, parent, input = {}) {
|
|
319
|
+
const init = DomainProperty.createSchema(input);
|
|
320
|
+
super(root, init.key);
|
|
321
|
+
this.parent = parent;
|
|
322
|
+
this.kind = DomainPropertyKind;
|
|
323
|
+
this.info = new Thing(init.info);
|
|
324
|
+
this.type = init.type;
|
|
325
|
+
if (typeof init.multiple === 'boolean') {
|
|
326
|
+
this.multiple = init.multiple;
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
this.multiple = undefined;
|
|
330
|
+
}
|
|
331
|
+
if (typeof init.required === 'boolean') {
|
|
332
|
+
this.required = init.required;
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
this.required = undefined;
|
|
336
|
+
}
|
|
337
|
+
if (typeof init.index === 'boolean') {
|
|
338
|
+
this.index = init.index;
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
this.index = undefined;
|
|
342
|
+
}
|
|
343
|
+
if (typeof init.deprecated === 'boolean') {
|
|
344
|
+
this.deprecated = init.deprecated;
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
this.deprecated = undefined;
|
|
348
|
+
}
|
|
349
|
+
if (typeof init.primary === 'boolean') {
|
|
350
|
+
this.primary = init.primary;
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
this.primary = undefined;
|
|
354
|
+
}
|
|
355
|
+
if (typeof init.readOnly === 'boolean') {
|
|
356
|
+
this.readOnly = init.readOnly;
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
this.readOnly = undefined;
|
|
360
|
+
}
|
|
361
|
+
if (typeof init.writeOnly === 'boolean') {
|
|
362
|
+
this.writeOnly = init.writeOnly;
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
this.writeOnly = undefined;
|
|
366
|
+
}
|
|
367
|
+
if (Array.isArray(init.tags)) {
|
|
368
|
+
this.tags = [...init.tags];
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
this.tags = [];
|
|
372
|
+
}
|
|
373
|
+
if (Array.isArray(init.taxonomy)) {
|
|
374
|
+
this.taxonomy = [...init.taxonomy];
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
this.taxonomy = [];
|
|
378
|
+
}
|
|
379
|
+
if (init.schema) {
|
|
380
|
+
this.schema = structuredClone(init.schema);
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
this.schema = undefined;
|
|
384
|
+
}
|
|
385
|
+
if (Array.isArray(init.bindings)) {
|
|
386
|
+
this.bindings = init.bindings.map((i) => structuredClone(i));
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
this.bindings = [];
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Checks whether the input is a valid definition of a domain property.
|
|
394
|
+
*
|
|
395
|
+
* @param input The input to validate.
|
|
396
|
+
* @param options Validation options.
|
|
397
|
+
* @returns true when the passed input is a valid definition of a domain property.
|
|
398
|
+
*/
|
|
399
|
+
static validate(input, options = {}) {
|
|
400
|
+
if (!input || (typeof input !== 'object' && input !== null)) {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
const typed = input;
|
|
404
|
+
if (options.strict && typed.kind !== DomainPropertyKind) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
toJSON() {
|
|
410
|
+
const result = {
|
|
411
|
+
kind: this.kind,
|
|
412
|
+
key: this.key,
|
|
413
|
+
info: this.info.toJSON(),
|
|
414
|
+
type: this.type || DomainPropertyList.string,
|
|
415
|
+
};
|
|
416
|
+
if (typeof this.index === 'boolean') {
|
|
417
|
+
result.index = this.index;
|
|
418
|
+
}
|
|
419
|
+
if (typeof this.deprecated === 'boolean') {
|
|
420
|
+
result.deprecated = this.deprecated;
|
|
421
|
+
}
|
|
422
|
+
if (typeof this.primary === 'boolean') {
|
|
423
|
+
result.primary = this.primary;
|
|
424
|
+
}
|
|
425
|
+
if (typeof this.multiple === 'boolean') {
|
|
426
|
+
result.multiple = this.multiple;
|
|
427
|
+
}
|
|
428
|
+
if (typeof this.required === 'boolean') {
|
|
429
|
+
result.required = this.required;
|
|
430
|
+
}
|
|
431
|
+
if (typeof this.readOnly === 'boolean') {
|
|
432
|
+
result.readOnly = this.readOnly;
|
|
433
|
+
}
|
|
434
|
+
if (typeof this.writeOnly === 'boolean') {
|
|
435
|
+
result.writeOnly = this.writeOnly;
|
|
436
|
+
}
|
|
437
|
+
if (Array.isArray(this.tags) && this.tags.length) {
|
|
438
|
+
result.tags = [...this.tags];
|
|
439
|
+
}
|
|
440
|
+
if (Array.isArray(this.taxonomy) && this.taxonomy.length) {
|
|
441
|
+
result.taxonomy = [...this.taxonomy];
|
|
442
|
+
}
|
|
443
|
+
if (this.schema) {
|
|
444
|
+
result.schema = structuredClone(toRaw(this, this.schema));
|
|
445
|
+
}
|
|
446
|
+
if (Array.isArray(this.bindings) && this.bindings.length) {
|
|
447
|
+
result.bindings = toRaw(this, this.bindings)?.map((i) => structuredClone(i));
|
|
448
|
+
}
|
|
449
|
+
return result;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Removes this property from the parent entity.
|
|
453
|
+
* It calls the `removeProperty()` method of the parent entity.
|
|
454
|
+
*/
|
|
455
|
+
remove() {
|
|
456
|
+
const parent = this.getParentInstance();
|
|
457
|
+
parent?.removeProperty(this.key);
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Returns a parent data entity where this data property exist.
|
|
461
|
+
*/
|
|
462
|
+
getParentInstance() {
|
|
463
|
+
return this.root.graph.node(this.parent);
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Checks whether the passed value is one of the supported data types.
|
|
467
|
+
* @param value The value to test
|
|
468
|
+
* @returns True when the passed value is one of the supported data types.
|
|
469
|
+
*/
|
|
470
|
+
static isValidType(value) {
|
|
471
|
+
if (typeof value !== 'string') {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
return DomainPropertyTypes.includes(value);
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Checks whether the passed value is one of the supported data property attributes.
|
|
478
|
+
* @param value The value to test
|
|
479
|
+
* @returns True when the passed value is one of the supported data property attributes.
|
|
480
|
+
*/
|
|
481
|
+
static isValidAttribute(value) {
|
|
482
|
+
if (typeof value !== 'string') {
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
return DomainPropertyAttributes.includes(value);
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Checks whether the passed value of one of the supported `format` values.
|
|
489
|
+
*
|
|
490
|
+
* @param value The value to test
|
|
491
|
+
* @returns `true` when the value is one of the supported `format` values.
|
|
492
|
+
*/
|
|
493
|
+
static isValidFormat(value) {
|
|
494
|
+
if (value === undefined) {
|
|
495
|
+
// It is the valid value.
|
|
496
|
+
return true;
|
|
497
|
+
}
|
|
498
|
+
if (typeof value !== 'string') {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
if (NumberFormats.includes(value)) {
|
|
502
|
+
return true;
|
|
503
|
+
}
|
|
504
|
+
if (BinaryFormats.includes(value)) {
|
|
505
|
+
return true;
|
|
506
|
+
}
|
|
507
|
+
return false;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Creates the `schema` object if missing and returns it.
|
|
511
|
+
* @returns The schema object.
|
|
512
|
+
*/
|
|
513
|
+
ensureSchema() {
|
|
514
|
+
if (!this.schema) {
|
|
515
|
+
this.schema = {};
|
|
516
|
+
}
|
|
517
|
+
return this.schema;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Creates if not existing and returns web bindings definition.
|
|
521
|
+
* @returns The web binding definition
|
|
522
|
+
*/
|
|
523
|
+
getWebBinding() {
|
|
524
|
+
let object = this.bindings.find((i) => i.type === 'web');
|
|
525
|
+
if (!object) {
|
|
526
|
+
object = { type: 'web', schema: {} };
|
|
527
|
+
this.bindings.push(object);
|
|
528
|
+
}
|
|
529
|
+
return object.schema;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Returns the schema value of the binding, if any was created.
|
|
533
|
+
* @param type The type of the binding to read.
|
|
534
|
+
* @returns The binding schema, if any
|
|
535
|
+
*/
|
|
536
|
+
readBinding(type) {
|
|
537
|
+
const item = this.bindings.find((i) => i.type === type);
|
|
538
|
+
return item?.schema || undefined;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Creates a Property Shape of AMF.
|
|
542
|
+
*
|
|
543
|
+
* The property itself is auto-generated. If the `schema` is
|
|
544
|
+
* defined then it is used as the `range` of the property.
|
|
545
|
+
* Otherwise basic shape is generated for the range.
|
|
546
|
+
*
|
|
547
|
+
* This is a preferred way of reading the AMF shape as this
|
|
548
|
+
* synchronizes changed data properties with the shape
|
|
549
|
+
* definition.
|
|
550
|
+
*
|
|
551
|
+
* @returns AMF property shape definition.
|
|
552
|
+
*/
|
|
553
|
+
toApiShape() {
|
|
554
|
+
const serializer = new ShapeGenerator();
|
|
555
|
+
return serializer.property(this);
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
})();
|
|
559
|
+
export { DomainProperty };
|
|
560
|
+
//# sourceMappingURL=DomainProperty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomainProperty.js","sourceRoot":"","s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U,cAAc","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainPropertyKind } from '../models/kinds.js'\nimport { DomainElement, type DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from 'nanoid'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange, toRaw } from './observed.js'\nimport {\n type BinaryFormat,\n BinaryFormats,\n type DomainPropertyAttribute,\n DomainPropertyAttributes,\n type DomainPropertyFormat,\n DomainPropertyList,\n type DomainPropertyType,\n DomainPropertyTypes,\n type NumberFormat,\n NumberFormats,\n} from './DataFormat.js'\nimport type { PropertyBinding, PropertyBindings, PropertyWebBindings } from './Bindings.js'\nimport type { ModelValidationOptions } from '../models/types.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport { ShapeGenerator } from './amf/ShapeGenerator.js'\nimport { PropertySchema } from './types.js'\n\nexport interface DomainPropertySchema extends DomainElementSchema {\n kind: typeof DomainPropertyKind\n /**\n * The domain property description.\n */\n info: IThing\n /**\n * Wether the data property is required.\n */\n required?: boolean\n /**\n * Whether the data property allows multiple items.\n */\n multiple?: boolean\n /**\n * Whether this property describes a primary key of the entity.\n */\n primary?: boolean\n /**\n * Whether this property describes an indexed property of the entity.\n */\n index?: boolean\n /**\n * Whether the property is read only in the schema.\n */\n readOnly?: boolean\n /**\n * Whether the property is write only in the schema.\n */\n writeOnly?: boolean\n /**\n * Whether this property is deprecated.\n */\n deprecated?: boolean\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n /**\n * For future use.\n *\n * The keys of the taxonomy items associated with the property.\n */\n taxonomy?: string[]\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers, but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n type: DomainPropertyType\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n schema?: PropertySchema\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings?: PropertyBinding[]\n}\n\n/**\n * Represents a property within a data domain entity.\n *\n * A `DomainProperty` defines a single data element within a\n * `DomainEntity`. It specifies the data type, constraints,\n * and other metadata for a specific piece of information.\n *\n * **Key Features:**\n *\n * - **Data Type:** Defines the type of data the property\n * holds (e.g., string, number, boolean, date).\n * - **Constraints:** Supports defining constraints such as\n * minimum/maximum values, enum values, and default values.\n * - **Bindings:** Allows defining how the property is\n * represented in different formats (e.g., web APIs,\n * protocol buffers).\n * - **Metadata:** Supports metadata such as tags, taxonomy,\n * read-only/write-only status, and deprecation.\n * - **Schema:** Allows defining a general schema for the\n * property, which is propagated to all bindings.\n *\n * **Usage:**\n *\n * Use the `DataEntity.addProperty` method to add a new property to an\n * entity. The property can be created using the constructor, but it\n * won't be added to the graph until you call the `addProperty` method.\n *\n * **Example:**\n *\n * ```typescript\n * const entity = dataModel.addEntity({ key: 'user' });\n * const property = entity.addProperty({\n * key: 'name',\n * type: 'string',\n * required: true,\n * schema: {\n * minimum: 3,\n * maximum: 50,\n * },\n * });\n * ```\n */\nexport class DomainProperty extends DomainElement {\n override kind: typeof DomainPropertyKind\n\n /**\n * The description of the domain property.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * Wether the data property is required.\n */\n @observed() accessor required: boolean | undefined\n\n /**\n * Whether the data property allows multiple items.\n */\n @observed() accessor multiple: boolean | undefined\n\n /**\n * Whether this property describes a primary key of the entity.\n */\n @observed() accessor primary: boolean | undefined\n\n /**\n * Whether this property describes an indexed property of the entity.\n */\n @observed() accessor index: boolean | undefined\n\n /**\n * Whether the property is read only in the schema.\n */\n @observed() accessor readOnly: boolean | undefined\n\n /**\n * Whether the property is write only in the schema.\n */\n @observed() accessor writeOnly: boolean | undefined\n\n /**\n * Whether this property is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Optional general purpose tags for the UI.\n *\n * Note to implementations, use the `addTag()` method as it propagates the \"tag\" value in the namespace.\n * Also, the tags property is excluded from the observer properties.\n * Changes to this property will not notify the observers.\n */\n @observed({ deep: true }) accessor tags: string[] = []\n\n /**\n * Reserved for future use.\n *\n * The keys of the taxonomy items associated with the property.\n */\n @observed({ deep: true }) accessor taxonomy: string[] = []\n\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n @observed() accessor type: DomainPropertyType = 'string'\n\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n @observed({ deep: true }) accessor schema: PropertySchema | undefined\n\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n @observed({ deep: true }) accessor bindings: PropertyBinding[] = []\n\n /**\n * Creates a full data model schema with defaults.\n *\n * @param input The partial data model schema.\n * @returns The data model schema.\n */\n static createSchema(input: Partial<DomainPropertySchema> = {}): DomainPropertySchema {\n const {\n key = nanoid(),\n multiple,\n required,\n type = DomainPropertyList.string,\n index,\n primary,\n readOnly,\n writeOnly,\n tags,\n taxonomy,\n deprecated,\n schema,\n bindings,\n } = input\n if (typeof type === 'string') {\n if (!DomainPropertyTypes.includes(type as DomainPropertyType)) {\n throw new Error(`Invalid data property type ${type}`)\n }\n }\n const info = Thing.fromJSON(input.info, { name: 'New property' }).toJSON()\n const result: DomainPropertySchema = {\n kind: DomainPropertyKind,\n key,\n info,\n type,\n }\n if (typeof multiple === 'boolean') {\n result.multiple = multiple\n }\n if (typeof required === 'boolean') {\n result.required = required\n }\n if (typeof index === 'boolean') {\n result.index = index\n }\n if (typeof primary === 'boolean') {\n result.primary = primary\n }\n if (typeof readOnly === 'boolean') {\n result.readOnly = readOnly\n }\n if (typeof writeOnly === 'boolean') {\n result.writeOnly = writeOnly\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n if (Array.isArray(tags)) {\n result.tags = [...tags]\n }\n if (Array.isArray(taxonomy)) {\n result.taxonomy = [...taxonomy]\n }\n if (schema) {\n result.schema = structuredClone(schema)\n }\n if (Array.isArray(bindings)) {\n result.bindings = bindings.map((i) => structuredClone(i))\n } else {\n result.bindings = []\n }\n return result\n }\n\n /**\n * The key of the parent entity.\n */\n protected parent: string\n\n /**\n * Creates a new domain property instance.\n * It does not add it to the graph.\n * You need to call the `addProperty` method of the graph or a data model to add it.\n *\n * Domain objects constructors shouldn't be used directly. Use methods\n * provided on the DataDomain class to create new objects.\n *\n * @param root A reference to the root DataDomain instance.\n * @param parent The key of the parent entity.\n * @param input The partial domain property schema.\n * @returns Created domain property instance.\n */\n constructor(root: DataDomain, parent: string, input: Partial<DomainPropertySchema> = {}) {\n const init = DomainProperty.createSchema(input)\n super(root, init.key)\n this.parent = parent\n this.kind = DomainPropertyKind\n this.info = new Thing(init.info)\n this.type = init.type\n\n if (typeof init.multiple === 'boolean') {\n this.multiple = init.multiple\n } else {\n this.multiple = undefined\n }\n if (typeof init.required === 'boolean') {\n this.required = init.required\n } else {\n this.required = undefined\n }\n if (typeof init.index === 'boolean') {\n this.index = init.index\n } else {\n this.index = undefined\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n if (typeof init.primary === 'boolean') {\n this.primary = init.primary\n } else {\n this.primary = undefined\n }\n if (typeof init.readOnly === 'boolean') {\n this.readOnly = init.readOnly\n } else {\n this.readOnly = undefined\n }\n if (typeof init.writeOnly === 'boolean') {\n this.writeOnly = init.writeOnly\n } else {\n this.writeOnly = undefined\n }\n if (Array.isArray(init.tags)) {\n this.tags = [...init.tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(init.taxonomy)) {\n this.taxonomy = [...init.taxonomy]\n } else {\n this.taxonomy = []\n }\n if (init.schema) {\n this.schema = structuredClone(init.schema)\n } else {\n this.schema = undefined\n }\n if (Array.isArray(init.bindings)) {\n this.bindings = init.bindings.map((i) => structuredClone(i))\n } else {\n this.bindings = []\n }\n }\n\n /**\n * Checks whether the input is a valid definition of a domain property.\n *\n * @param input The input to validate.\n * @param options Validation options.\n * @returns true when the passed input is a valid definition of a domain property.\n */\n static validate(input: unknown, options: ModelValidationOptions = {}): boolean {\n if (!input || (typeof input !== 'object' && input !== null)) {\n return false\n }\n const typed = input as DomainPropertySchema\n if (options.strict && typed.kind !== DomainPropertyKind) {\n return false\n }\n return true\n }\n\n toJSON(): DomainPropertySchema {\n const result: DomainPropertySchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n type: this.type || DomainPropertyList.string,\n }\n if (typeof this.index === 'boolean') {\n result.index = this.index\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n if (typeof this.primary === 'boolean') {\n result.primary = this.primary\n }\n if (typeof this.multiple === 'boolean') {\n result.multiple = this.multiple\n }\n if (typeof this.required === 'boolean') {\n result.required = this.required\n }\n if (typeof this.readOnly === 'boolean') {\n result.readOnly = this.readOnly\n }\n if (typeof this.writeOnly === 'boolean') {\n result.writeOnly = this.writeOnly\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (this.schema) {\n result.schema = structuredClone(toRaw(this, this.schema))\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = toRaw(this, this.bindings)?.map((i) => structuredClone(i))\n }\n return result\n }\n\n /**\n * Removes this property from the parent entity.\n * It calls the `removeProperty()` method of the parent entity.\n */\n remove(): void {\n const parent = this.getParentInstance()\n parent?.removeProperty(this.key)\n }\n\n /**\n * Returns a parent data entity where this data property exist.\n */\n getParentInstance(): DomainEntity | undefined {\n return this.root.graph.node(this.parent) as DomainEntity | undefined\n }\n\n /**\n * Checks whether the passed value is one of the supported data types.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data types.\n */\n static isValidType(value: unknown): value is DomainPropertyType {\n if (typeof value !== 'string') {\n return false\n }\n return DomainPropertyTypes.includes(value as DomainPropertyType)\n }\n\n /**\n * Checks whether the passed value is one of the supported data property attributes.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data property attributes.\n */\n static isValidAttribute(value: unknown): value is DomainPropertyAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DomainPropertyAttributes.includes(value as DomainPropertyAttribute)\n }\n\n /**\n * Checks whether the passed value of one of the supported `format` values.\n *\n * @param value The value to test\n * @returns `true` when the value is one of the supported `format` values.\n */\n static isValidFormat(value: unknown): value is DomainPropertyFormat {\n if (value === undefined) {\n // It is the valid value.\n return true\n }\n if (typeof value !== 'string') {\n return false\n }\n if (NumberFormats.includes(value as NumberFormat)) {\n return true\n }\n if (BinaryFormats.includes(value as BinaryFormat)) {\n return true\n }\n return false\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n * @returns The schema object.\n */\n ensureSchema(): PropertySchema {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Creates if not existing and returns web bindings definition.\n * @returns The web binding definition\n */\n getWebBinding(): PropertyWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as PropertyBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as PropertyBinding\n this.bindings.push(object)\n }\n return object.schema as PropertyWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was created.\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n */\n readBinding(type: 'web' | 'protobuf'): PropertyBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as PropertyBinding\n return item?.schema || undefined\n }\n\n /**\n * Creates a Property Shape of AMF.\n *\n * The property itself is auto-generated. If the `schema` is\n * defined then it is used as the `range` of the property.\n * Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this\n * synchronizes changed data properties with the shape\n * definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new ShapeGenerator()\n return serializer.property(this)\n }\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { DataDomainGraph, SerializedGraph } from './types.js';
|
|
2
|
+
import type { DataDomain } from './DataDomain.js';
|
|
3
|
+
interface GraphMergeResult {
|
|
4
|
+
/**
|
|
5
|
+
* The set of node ids generated for the foreign nodes.
|
|
6
|
+
*/
|
|
7
|
+
nodes: Set<string>;
|
|
8
|
+
/**
|
|
9
|
+
* The set of edge ids generated for the foreign edges.
|
|
10
|
+
*/
|
|
11
|
+
edges: Set<string>;
|
|
12
|
+
}
|
|
13
|
+
export declare function serialize(g: DataDomainGraph, domainKey: string): SerializedGraph;
|
|
14
|
+
/**
|
|
15
|
+
* Removes all foreign nodes, edges, and parents from the graph.
|
|
16
|
+
* @param g The graph to remove the foreign nodes from
|
|
17
|
+
* @param domainKey The key of the domain to remove
|
|
18
|
+
*/
|
|
19
|
+
export declare function removeForeignGraph(g: DataDomainGraph, domainKey: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Merges a foreign domain graph into the current domain graph.
|
|
22
|
+
* @param own Our domain graph
|
|
23
|
+
* @param foreign The foreign domain graph
|
|
24
|
+
* @param domain The key of the foreign domain
|
|
25
|
+
*/
|
|
26
|
+
export declare function mergeGraph(own: DataDomainGraph, foreign: DataDomainGraph, domain: string): GraphMergeResult;
|
|
27
|
+
/**
|
|
28
|
+
* To deserialize a graph:
|
|
29
|
+
*
|
|
30
|
+
* - Create a new DataDomain instance
|
|
31
|
+
* - Restore all foreign nodes and edges
|
|
32
|
+
* - Call the deserialize function
|
|
33
|
+
*
|
|
34
|
+
* @param root The DataDomain instance to use as the root for the graph
|
|
35
|
+
* @param json The previously serialized graph
|
|
36
|
+
* @returns Deserialized graph instance
|
|
37
|
+
*/
|
|
38
|
+
export declare function deserialize(root: DataDomain, json?: SerializedGraph, dependencies?: DataDomain[]): DataDomainGraph;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=DomainSerialization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomainSerialization.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainSerialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAwC,eAAe,EAAE,MAAM,YAAY,CAAA;AASxG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAMjD,UAAU,gBAAgB;IACxB;;OAEG;IACH,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAClB;;OAEG;IACH,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CACnB;AAsDD,wBAAgB,SAAS,CAAC,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,GAAG,eAAe,CAWhF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAa9E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAyD3G;AA+DD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,eAAe,EAAE,YAAY,CAAC,EAAE,UAAU,EAAE,GAAG,eAAe,CA8DlH"}
|