@api-client/core 0.14.0 → 0.14.1
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/build/src/amf/AmfTypes.d.ts +1 -1
- package/build/src/amf/AmfTypes.js +1 -1
- package/build/src/amf/AmfTypes.js.map +1 -1
- package/build/src/amf/Utils.d.ts +0 -6
- package/build/src/amf/Utils.d.ts.map +1 -1
- package/build/src/amf/Utils.js +0 -14
- package/build/src/amf/Utils.js.map +1 -1
- package/build/src/browser.d.ts +1 -0
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +1 -0
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +1 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +1 -0
- package/build/src/index.js.map +1 -1
- package/build/src/legacy.d.ts +0 -8
- package/build/src/legacy.d.ts.map +1 -1
- package/build/src/legacy.js +0 -9
- package/build/src/legacy.js.map +1 -1
- package/build/src/modeling/Bindings.d.ts +1 -1
- package/build/src/modeling/Bindings.js.map +1 -1
- package/build/src/modeling/DataDomain.js +2 -2
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DataFormat.d.ts +0 -40
- package/build/src/modeling/DataFormat.d.ts.map +1 -1
- package/build/src/modeling/DataFormat.js +0 -27
- package/build/src/modeling/DataFormat.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +28 -0
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
- package/build/src/modeling/DomainAssociation.js +73 -4
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.d.ts +25 -9
- package/build/src/modeling/DomainEntity.d.ts.map +1 -1
- package/build/src/modeling/DomainEntity.js +65 -21
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainFile.d.ts +1 -1
- package/build/src/modeling/DomainFile.js +1 -1
- package/build/src/modeling/DomainFile.js.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
- package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.js +3 -3
- package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
- package/build/src/modeling/DomainModel.d.ts +2 -2
- package/build/src/modeling/DomainModel.js +2 -2
- package/build/src/modeling/DomainModel.js.map +1 -1
- package/build/src/modeling/DomainProperty.d.ts +28 -12
- package/build/src/modeling/DomainProperty.d.ts.map +1 -1
- package/build/src/modeling/DomainProperty.js +61 -26
- package/build/src/modeling/DomainProperty.js.map +1 -1
- package/build/src/modeling/Semantics.d.ts +109 -0
- package/build/src/modeling/Semantics.d.ts.map +1 -0
- package/build/src/modeling/Semantics.js +97 -0
- package/build/src/modeling/Semantics.js.map +1 -0
- package/build/src/models/kinds.d.ts +0 -24
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +0 -24
- package/build/src/models/kinds.js.map +1 -1
- package/build/src/models/store/data_catalog.d.ts +1 -1
- package/build/src/models/store/data_catalog.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +11 -11
- package/package.json +1 -1
- package/src/amf/AmfTypes.ts +1 -1
- package/src/amf/Utils.ts +0 -15
- package/src/modeling/Bindings.ts +1 -1
- package/src/modeling/DataDomain.ts +2 -2
- package/src/modeling/DataFormat.ts +0 -48
- package/src/modeling/DomainAssociation.ts +66 -3
- package/src/modeling/DomainEntity.ts +56 -17
- package/src/modeling/DomainFile.ts +1 -1
- package/src/modeling/DomainImpactAnalysis.ts +3 -3
- package/src/modeling/DomainModel.ts +2 -2
- package/src/modeling/DomainProperty.ts +60 -21
- package/src/modeling/Semantics.ts +178 -0
- package/src/modeling/graph.md +14 -14
- package/src/modeling/readme.md +29 -29
- package/src/models/kinds.ts +0 -25
- package/src/models/store/data_catalog.ts +1 -1
- package/tests/unit/modeling/data_domain_change_observers.spec.ts +11 -10
- package/tests/unit/modeling/data_domain_entities.spec.ts +129 -1
- package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
- package/tests/unit/modeling/domain_asociation.spec.ts +177 -0
- package/tests/unit/modeling/domain_entity.spec.ts +27 -26
- package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +11 -11
- package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +10 -10
- package/tests/unit/modeling/{domain.property.spec.ts → domain_property.spec.ts} +139 -23
- package/build/src/amf/AmfShapeGenerator.d.ts +0 -103
- package/build/src/amf/AmfShapeGenerator.d.ts.map +0 -1
- package/build/src/amf/AmfShapeGenerator.js +0 -416
- package/build/src/amf/AmfShapeGenerator.js.map +0 -1
- package/build/src/modeling/legacy/DataAssociation.d.ts +0 -284
- package/build/src/modeling/legacy/DataAssociation.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataAssociation.js +0 -443
- package/build/src/modeling/legacy/DataAssociation.js.map +0 -1
- package/build/src/modeling/legacy/DataEntity.d.ts +0 -358
- package/build/src/modeling/legacy/DataEntity.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataEntity.js +0 -855
- package/build/src/modeling/legacy/DataEntity.js.map +0 -1
- package/build/src/modeling/legacy/DataEntityBuilder.d.ts +0 -162
- package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataEntityBuilder.js +0 -221
- package/build/src/modeling/legacy/DataEntityBuilder.js.map +0 -1
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +0 -298
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataImpactAnalysis.js +0 -441
- package/build/src/modeling/legacy/DataImpactAnalysis.js.map +0 -1
- package/build/src/modeling/legacy/DataModel.d.ts +0 -99
- package/build/src/modeling/legacy/DataModel.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataModel.js +0 -237
- package/build/src/modeling/legacy/DataModel.js.map +0 -1
- package/build/src/modeling/legacy/DataNamespace.d.ts +0 -340
- package/build/src/modeling/legacy/DataNamespace.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataNamespace.js +0 -784
- package/build/src/modeling/legacy/DataNamespace.js.map +0 -1
- package/build/src/modeling/legacy/DataProperty.d.ts +0 -332
- package/build/src/modeling/legacy/DataProperty.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataProperty.js +0 -415
- package/build/src/modeling/legacy/DataProperty.js.map +0 -1
- package/build/src/models/store/DataFile.d.ts +0 -29
- package/build/src/models/store/DataFile.d.ts.map +0 -1
- package/build/src/models/store/DataFile.js +0 -87
- package/build/src/models/store/DataFile.js.map +0 -1
- package/src/amf/AmfShapeGenerator.ts +0 -477
- package/src/modeling/legacy/DataAssociation.ts +0 -554
- package/src/modeling/legacy/DataEntity.ts +0 -1019
- package/src/modeling/legacy/DataEntityBuilder.ts +0 -236
- package/src/modeling/legacy/DataImpactAnalysis.ts +0 -530
- package/src/modeling/legacy/DataModel.ts +0 -276
- package/src/modeling/legacy/DataNamespace.ts +0 -929
- package/src/modeling/legacy/DataProperty.ts +0 -630
- package/src/models/store/DataFile.ts +0 -95
- package/tests/unit/modeling/legacy/amf_shape_generator.spec.ts +0 -1041
- package/tests/unit/modeling/legacy/data_association.spec.ts +0 -710
- package/tests/unit/modeling/legacy/data_entity.spec.ts +0 -2061
- package/tests/unit/modeling/legacy/data_entity_generator_json.spec.ts +0 -987
- package/tests/unit/modeling/legacy/data_entity_generator_xml.spec.ts +0 -1451
- package/tests/unit/modeling/legacy/data_model.spec.ts +0 -395
- package/tests/unit/modeling/legacy/data_namespace.spec.ts +0 -1312
- package/tests/unit/modeling/legacy/data_property.spec.ts +0 -887
- package/tests/unit/modeling/legacy/impact_analysis.spec.ts +0 -373
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
import { Thing } from '../../models/Thing.js';
|
|
2
|
-
import { nanoid } from '../../nanoid.js';
|
|
3
|
-
import { AmfShapeGenerator } from '../../amf/AmfShapeGenerator.js';
|
|
4
|
-
import { DataPropertyKind } from '../../models/kinds.js';
|
|
5
|
-
import { BinaryFormats, DataPropertyAttributes, DataPropertyList, DataPropertyTypes, NumberFormats, } from '../DataFormat.js';
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated
|
|
8
|
-
*/
|
|
9
|
-
export class DataProperty {
|
|
10
|
-
root;
|
|
11
|
-
kind = DataPropertyKind;
|
|
12
|
-
key = '';
|
|
13
|
-
/**
|
|
14
|
-
* The description of the data namespace.
|
|
15
|
-
*/
|
|
16
|
-
info = Thing.fromName('');
|
|
17
|
-
/**
|
|
18
|
-
* Wether the data property is required.
|
|
19
|
-
*/
|
|
20
|
-
required;
|
|
21
|
-
/**
|
|
22
|
-
* Whether the data property allows multiple items.
|
|
23
|
-
*/
|
|
24
|
-
multiple;
|
|
25
|
-
/**
|
|
26
|
-
* Whether this property describes a primary key of the entity.
|
|
27
|
-
*/
|
|
28
|
-
primary;
|
|
29
|
-
/**
|
|
30
|
-
* Whether this property describes an indexed property of the entity.
|
|
31
|
-
*/
|
|
32
|
-
index;
|
|
33
|
-
/**
|
|
34
|
-
* Whether the property is read only in the schema.
|
|
35
|
-
*/
|
|
36
|
-
readOnly;
|
|
37
|
-
/**
|
|
38
|
-
* Whether the property is write only in the schema.
|
|
39
|
-
*/
|
|
40
|
-
writeOnly;
|
|
41
|
-
/**
|
|
42
|
-
* Whether this property is deprecated.
|
|
43
|
-
*/
|
|
44
|
-
deprecated;
|
|
45
|
-
/**
|
|
46
|
-
* Optional general purpose tags for the UI.
|
|
47
|
-
*
|
|
48
|
-
* Note to implementations, use the `addTag()` method as it propagates the "tag" value in the namespace.
|
|
49
|
-
*/
|
|
50
|
-
tags = [];
|
|
51
|
-
/**
|
|
52
|
-
* Reserved for future use.
|
|
53
|
-
*
|
|
54
|
-
* The keys of the taxonomy items associated with the property.
|
|
55
|
-
*/
|
|
56
|
-
taxonomy = [];
|
|
57
|
-
/**
|
|
58
|
-
* The data type for this property.
|
|
59
|
-
* Note, not all schemas support the same type. For example, defining `sint32`
|
|
60
|
-
* works for protocol buffers but does not for JSON. In such case we use default
|
|
61
|
-
* translation `sint32` -> `number`. Another way it to create
|
|
62
|
-
* a derivative entity for specific schema to describe specific schema case.
|
|
63
|
-
*/
|
|
64
|
-
type = 'string';
|
|
65
|
-
/**
|
|
66
|
-
* The general schema definition of this property.
|
|
67
|
-
* This is propagated to all bindings (when they support these properties).
|
|
68
|
-
*/
|
|
69
|
-
schema;
|
|
70
|
-
/**
|
|
71
|
-
* The list of bindings for this property.
|
|
72
|
-
*
|
|
73
|
-
* A binding defines a translation from a data model to a specific format.
|
|
74
|
-
* For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs
|
|
75
|
-
* or a protocol buffer schema.
|
|
76
|
-
*/
|
|
77
|
-
bindings = [];
|
|
78
|
-
/**
|
|
79
|
-
* @deprecated Use the direct import of types.
|
|
80
|
-
*/
|
|
81
|
-
static get supportedTypes() {
|
|
82
|
-
return [...DataPropertyTypes];
|
|
83
|
-
}
|
|
84
|
-
static fromName(root, name) {
|
|
85
|
-
const property = new DataProperty(root);
|
|
86
|
-
property.info = Thing.fromName(name);
|
|
87
|
-
return property;
|
|
88
|
-
}
|
|
89
|
-
static fromType(root, type) {
|
|
90
|
-
const result = new DataProperty(root);
|
|
91
|
-
result.type = type;
|
|
92
|
-
return result;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* @param input The data property definition to restore.
|
|
96
|
-
*/
|
|
97
|
-
constructor(root, input) {
|
|
98
|
-
this.root = root;
|
|
99
|
-
let init;
|
|
100
|
-
if (typeof input === 'string') {
|
|
101
|
-
init = JSON.parse(input);
|
|
102
|
-
}
|
|
103
|
-
else if (typeof input === 'object') {
|
|
104
|
-
init = input;
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
init = {
|
|
108
|
-
kind: DataPropertyKind,
|
|
109
|
-
key: nanoid(),
|
|
110
|
-
info: Thing.fromName('').toJSON(),
|
|
111
|
-
type: 'string',
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
this.new(init);
|
|
115
|
-
}
|
|
116
|
-
new(init) {
|
|
117
|
-
if (!DataProperty.isDataProperty(init)) {
|
|
118
|
-
throw new Error(`Not a data property.`);
|
|
119
|
-
}
|
|
120
|
-
const { info, key = nanoid(), kind = DataPropertyKind, multiple, required, type = DataPropertyList.string, index, primary, readOnly, writeOnly, tags, taxonomy, deprecated, schema, bindings, } = init;
|
|
121
|
-
this.kind = kind;
|
|
122
|
-
this.key = key;
|
|
123
|
-
this.type = type;
|
|
124
|
-
if (info) {
|
|
125
|
-
this.info = new Thing(info);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
this.info = Thing.fromName('');
|
|
129
|
-
}
|
|
130
|
-
if (typeof multiple === 'boolean') {
|
|
131
|
-
this.multiple = multiple;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
this.multiple = undefined;
|
|
135
|
-
}
|
|
136
|
-
if (typeof required === 'boolean') {
|
|
137
|
-
this.required = required;
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
this.required = undefined;
|
|
141
|
-
}
|
|
142
|
-
if (typeof index === 'boolean') {
|
|
143
|
-
this.index = index;
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
this.index = undefined;
|
|
147
|
-
}
|
|
148
|
-
if (typeof deprecated === 'boolean') {
|
|
149
|
-
this.deprecated = deprecated;
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
this.deprecated = undefined;
|
|
153
|
-
}
|
|
154
|
-
if (typeof primary === 'boolean') {
|
|
155
|
-
this.primary = primary;
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
this.primary = undefined;
|
|
159
|
-
}
|
|
160
|
-
if (typeof readOnly === 'boolean') {
|
|
161
|
-
this.readOnly = readOnly;
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
this.readOnly = undefined;
|
|
165
|
-
}
|
|
166
|
-
if (typeof writeOnly === 'boolean') {
|
|
167
|
-
this.writeOnly = writeOnly;
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
this.writeOnly = undefined;
|
|
171
|
-
}
|
|
172
|
-
if (Array.isArray(tags)) {
|
|
173
|
-
this.tags = [...tags];
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
this.tags = [];
|
|
177
|
-
}
|
|
178
|
-
if (Array.isArray(taxonomy)) {
|
|
179
|
-
this.taxonomy = [...taxonomy];
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
this.taxonomy = [];
|
|
183
|
-
}
|
|
184
|
-
if (schema) {
|
|
185
|
-
this.schema = structuredClone(schema);
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
this.schema = undefined;
|
|
189
|
-
}
|
|
190
|
-
if (Array.isArray(bindings)) {
|
|
191
|
-
this.bindings = bindings.map((i) => structuredClone(i));
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
this.bindings = [];
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
static isDataProperty(input) {
|
|
198
|
-
const typed = input;
|
|
199
|
-
if (!input || typed.kind !== DataPropertyKind) {
|
|
200
|
-
return false;
|
|
201
|
-
}
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
204
|
-
toJSON() {
|
|
205
|
-
const result = {
|
|
206
|
-
kind: DataPropertyKind,
|
|
207
|
-
info: this.info.toJSON(),
|
|
208
|
-
key: this.key,
|
|
209
|
-
type: this.type || DataPropertyList.string,
|
|
210
|
-
};
|
|
211
|
-
if (typeof this.index === 'boolean') {
|
|
212
|
-
result.index = this.index;
|
|
213
|
-
}
|
|
214
|
-
if (typeof this.deprecated === 'boolean') {
|
|
215
|
-
result.deprecated = this.deprecated;
|
|
216
|
-
}
|
|
217
|
-
if (typeof this.primary === 'boolean') {
|
|
218
|
-
result.primary = this.primary;
|
|
219
|
-
}
|
|
220
|
-
if (typeof this.multiple === 'boolean') {
|
|
221
|
-
result.multiple = this.multiple;
|
|
222
|
-
}
|
|
223
|
-
if (typeof this.required === 'boolean') {
|
|
224
|
-
result.required = this.required;
|
|
225
|
-
}
|
|
226
|
-
if (typeof this.readOnly === 'boolean') {
|
|
227
|
-
result.readOnly = this.readOnly;
|
|
228
|
-
}
|
|
229
|
-
if (typeof this.writeOnly === 'boolean') {
|
|
230
|
-
result.writeOnly = this.writeOnly;
|
|
231
|
-
}
|
|
232
|
-
if (Array.isArray(this.tags) && this.tags.length) {
|
|
233
|
-
result.tags = [...this.tags];
|
|
234
|
-
}
|
|
235
|
-
if (Array.isArray(this.taxonomy) && this.taxonomy.length) {
|
|
236
|
-
result.taxonomy = [...this.taxonomy];
|
|
237
|
-
}
|
|
238
|
-
if (this.schema) {
|
|
239
|
-
result.schema = structuredClone(this.schema);
|
|
240
|
-
}
|
|
241
|
-
if (Array.isArray(this.bindings) && this.bindings.length) {
|
|
242
|
-
result.bindings = this.bindings.map((i) => structuredClone(i));
|
|
243
|
-
}
|
|
244
|
-
return result;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Removes self from the parent entity and the namespace definition.
|
|
248
|
-
*/
|
|
249
|
-
remove() {
|
|
250
|
-
const { root } = this;
|
|
251
|
-
const entity = root.definitions.entities.find((i) => i.properties.some((j) => j.key === this.key));
|
|
252
|
-
if (entity) {
|
|
253
|
-
const assocIndex = entity.properties.findIndex((i) => i.key === this.key);
|
|
254
|
-
entity.properties.splice(assocIndex, 1);
|
|
255
|
-
}
|
|
256
|
-
const defIndex = this.root.definitions.properties.findIndex((i) => i.key === this.key);
|
|
257
|
-
if (defIndex >= 0) {
|
|
258
|
-
this.root.definitions.properties.splice(defIndex, 1);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Adds a new tag to the property. It also populates the root namespace's tags when tag is new.
|
|
263
|
-
*
|
|
264
|
-
* Note, it does nothing when the tag is already defined.
|
|
265
|
-
*
|
|
266
|
-
* @param tag The tag to add.
|
|
267
|
-
*/
|
|
268
|
-
addTag(tag) {
|
|
269
|
-
if (!tag) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
const lower = tag.toLowerCase();
|
|
273
|
-
const { tags } = this;
|
|
274
|
-
if (tags.some((t) => t.toLowerCase() === lower)) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
tags.push(tag);
|
|
278
|
-
const { definitions } = this.root;
|
|
279
|
-
if (!definitions.tags.some((t) => t.toLowerCase() === lower)) {
|
|
280
|
-
definitions.tags.push(tag);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Removes a tag from the property. Unlike the `addTag()` this won't remove a `tag` from the root namespace.
|
|
285
|
-
*
|
|
286
|
-
* @param tag The tag to remove.
|
|
287
|
-
*/
|
|
288
|
-
removeTag(tag) {
|
|
289
|
-
if (!tag) {
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
const lower = tag.toLowerCase();
|
|
293
|
-
const { tags } = this;
|
|
294
|
-
const index = tags.findIndex((t) => t.toLowerCase() === lower);
|
|
295
|
-
if (index >= 0) {
|
|
296
|
-
tags.splice(index, 1);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Creates a Property Shape of AMF.
|
|
301
|
-
* The property itself is auto-generated. If the `schema` is defined then it is used
|
|
302
|
-
* as the `range` of the property. Otherwise basic shape is generated for the range.
|
|
303
|
-
*
|
|
304
|
-
* This is a preferred way of reading the AMF shape as this synchronizes changed
|
|
305
|
-
* data properties with the shape definition.
|
|
306
|
-
*
|
|
307
|
-
* @returns AMF property shape definition.
|
|
308
|
-
*/
|
|
309
|
-
toApiShape() {
|
|
310
|
-
const serializer = new AmfShapeGenerator();
|
|
311
|
-
return serializer.property(this);
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Checks whether the passed value is one of the supported data types.
|
|
315
|
-
* @param value The value to test
|
|
316
|
-
* @returns True when the passed value is one of the supported data types.
|
|
317
|
-
*/
|
|
318
|
-
static isValidType(value) {
|
|
319
|
-
if (typeof value !== 'string') {
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
|
-
return DataPropertyTypes.includes(value);
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Checks whether the passed value is one of the supported data property attributes.
|
|
326
|
-
* @param value The value to test
|
|
327
|
-
* @returns True when the passed value is one of the supported data property attributes.
|
|
328
|
-
*/
|
|
329
|
-
static isValidAttribute(value) {
|
|
330
|
-
if (typeof value !== 'string') {
|
|
331
|
-
return false;
|
|
332
|
-
}
|
|
333
|
-
return DataPropertyAttributes.includes(value);
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Checks whether the passed value of one of the supported `format` values.
|
|
337
|
-
*
|
|
338
|
-
* @param value The value to test
|
|
339
|
-
* @returns `true` when the value is one of the supported `format` values.
|
|
340
|
-
*/
|
|
341
|
-
static isValidFormat(value) {
|
|
342
|
-
if (value === undefined) {
|
|
343
|
-
// It is the valid value.
|
|
344
|
-
return true;
|
|
345
|
-
}
|
|
346
|
-
if (typeof value !== 'string') {
|
|
347
|
-
return false;
|
|
348
|
-
}
|
|
349
|
-
if (NumberFormats.includes(value)) {
|
|
350
|
-
return true;
|
|
351
|
-
}
|
|
352
|
-
if (BinaryFormats.includes(value)) {
|
|
353
|
-
return true;
|
|
354
|
-
}
|
|
355
|
-
return false;
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Creates the `schema` object if missing and returns it.
|
|
359
|
-
* @returns The schema object.
|
|
360
|
-
*/
|
|
361
|
-
ensureSchema() {
|
|
362
|
-
if (!this.schema) {
|
|
363
|
-
this.schema = {};
|
|
364
|
-
}
|
|
365
|
-
return this.schema;
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Creates if not existing and returns web bindings definition.
|
|
369
|
-
* @returns The web binding definition
|
|
370
|
-
*/
|
|
371
|
-
getWebBinding() {
|
|
372
|
-
let object = this.bindings.find((i) => i.type === 'web');
|
|
373
|
-
if (!object) {
|
|
374
|
-
object = { type: 'web', schema: {} };
|
|
375
|
-
this.bindings.push(object);
|
|
376
|
-
}
|
|
377
|
-
return object.schema;
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Returns the schema value of the binding, if any was created.
|
|
381
|
-
* @param type The type of the binding to read.
|
|
382
|
-
* @returns The binding schema, if any
|
|
383
|
-
*/
|
|
384
|
-
readBinding(type) {
|
|
385
|
-
const item = this.bindings.find((i) => i.type === type);
|
|
386
|
-
return item?.schema;
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* Returns a parent data entity where this data property exist.
|
|
390
|
-
*/
|
|
391
|
-
getParentInstance() {
|
|
392
|
-
return this.root.definitions.entities.find((e) => e.properties.some((e) => e.key === this.key));
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Checks whether the property is a child of the given namespace, data model, or an entity.
|
|
396
|
-
* The relationship doesn't have to be direct, as long as the property is in the hierarchy it will return true.
|
|
397
|
-
*
|
|
398
|
-
* @param key The key of the parent to check.
|
|
399
|
-
* @returns True if this data property is a child of the given namespace, data model, or an entity
|
|
400
|
-
*/
|
|
401
|
-
isChildOf(key) {
|
|
402
|
-
if (this.key === key) {
|
|
403
|
-
return false;
|
|
404
|
-
}
|
|
405
|
-
const parent = this.getParentInstance();
|
|
406
|
-
if (!parent) {
|
|
407
|
-
return false;
|
|
408
|
-
}
|
|
409
|
-
if (parent.key === key) {
|
|
410
|
-
return true;
|
|
411
|
-
}
|
|
412
|
-
return parent.isChildOf(key);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
//# sourceMappingURL=DataProperty.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DataProperty.js","sourceRoot":"","sources":["../../../../src/modeling/legacy/DataProperty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,i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AM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../../models/Thing.js'\nimport { nanoid } from '../../nanoid.js'\nimport { DataNamespace } from './DataNamespace.js'\nimport { IApiPropertyShape } from '../../amf/definitions/Shapes.js'\nimport { AmfShapeGenerator } from '../../amf/AmfShapeGenerator.js'\nimport { PropertyBinding, PropertyBindings, PropertyWebBindings } from '../Bindings.js'\nimport { DataPropertyKind } from '../../models/kinds.js'\nimport {\n type BinaryFormat,\n BinaryFormats,\n type DataPropertyAttribute,\n DataPropertyAttributes,\n type DataPropertyFormat,\n DataPropertyList,\n type DataPropertyType,\n DataPropertyTypes,\n type NumberFormat,\n NumberFormats,\n} from '../DataFormat.js'\nimport type { DataEntity } from './DataEntity.js'\n\n/**\n * Describes the default value set on a property schema.\n * @deprecated\n */\nexport interface SchemaDefaultValue {\n /**\n * The type of the default value.\n *\n * - `literal` The `value` should be used as-is.\n * - `function` The value represents the name of the function to be used.\n */\n type: 'literal' | 'function'\n /**\n * The actual value type depends on the `type`.\n * It is always a string and it has to be casted to the property's data type.\n */\n value: string\n}\n\n/**\n * A general schema definition for a property.\n * This is propagated to all bindings (when they support these properties).\n * @deprecated\n */\nexport interface DataPropertySchema {\n /**\n * The minimum value of the property.\n *\n * By default it is inclusive value. Use the `exclusiveMinimum` property to make it exclusive.\n *\n * Used with:\n * - string\n * - number\n * - date\n * - time\n * - datetime\n */\n minimum?: number\n /**\n * The maximum value of the property.\n *\n * By default it is inclusive value. Use the `exclusiveMaximum` property to make it exclusive.\n *\n * Used with:\n * - string\n * - number\n * - date\n * - time\n * - datetime\n */\n maximum?: number\n /**\n * When set, the minimum value is exclusive.\n *\n * - When `false`: value ≥ minimum.\n * - When `true`: value > minimum.\n */\n exclusiveMinimum?: boolean\n /**\n * When set, the exclusiveMaximum value is exclusive.\n *\n * - When `false`: value ≤ maximum.\n * - When `true`: value < minimum.\n */\n exclusiveMaximum?: boolean\n /**\n * The multiplier value for a number scalar.\n *\n * Examples:\n * - if `1` then every integer is allowed\n * - if `2` than every even number is allowed\n * - if `0.5` than every number dividable by `0.5` is allowed\n */\n multipleOf?: number\n /**\n * The enum values for the property.\n * They are always encoded as strings. The actual type is defined in the `dataType` property.\n */\n enum?: string[]\n /**\n * The default value for the property.\n * This is always encoded as a string. The actual type is defined in the `dataType` property.\n */\n defaultValue?: SchemaDefaultValue\n /**\n * The example values for the property.\n * They are always encoded as strings. The actual type is defined in the `dataType` property.\n */\n examples?: string[]\n}\n\n/**\n * @deprecated\n */\nexport interface IDataProperty {\n kind: typeof DataPropertyKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data 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: DataPropertyType\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n schema?: DataPropertySchema\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 * @deprecated\n */\nexport class DataProperty {\n kind = DataPropertyKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * Wether the data property is required.\n */\n required?: boolean\n\n /**\n * Whether the data property allows multiple items.\n */\n multiple?: boolean\n\n /**\n * Whether this property describes a primary key of the entity.\n */\n primary?: boolean\n\n /**\n * Whether this property describes an indexed property of the entity.\n */\n index?: boolean\n\n /**\n * Whether the property is read only in the schema.\n */\n readOnly?: boolean\n\n /**\n * Whether the property is write only in the schema.\n */\n writeOnly?: boolean\n\n /**\n * Whether this property is deprecated.\n */\n deprecated?: boolean\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 */\n tags: string[] = []\n\n /**\n * Reserved for future use.\n *\n * The keys of the taxonomy items associated with the property.\n */\n 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 type: DataPropertyType = '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 schema?: DataPropertySchema\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 * @deprecated Use the direct import of types.\n */\n static get supportedTypes(): DataPropertyType[] {\n return [...DataPropertyTypes]\n }\n\n static fromName(root: DataNamespace, name: string): DataProperty {\n const property = new DataProperty(root)\n property.info = Thing.fromName(name)\n return property\n }\n\n static fromType(root: DataNamespace, type: DataPropertyType): DataProperty {\n const result = new DataProperty(root)\n result.type = type\n return result\n }\n\n /**\n * @param input The data property definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataProperty\n ) {\n let init: IDataProperty\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataPropertyKind,\n key: nanoid(),\n info: Thing.fromName('').toJSON(),\n type: 'string',\n }\n }\n this.new(init)\n }\n\n new(init: IDataProperty): void {\n if (!DataProperty.isDataProperty(init)) {\n throw new Error(`Not a data property.`)\n }\n const {\n info,\n key = nanoid(),\n kind = DataPropertyKind,\n multiple,\n required,\n type = DataPropertyList.string,\n index,\n primary,\n readOnly,\n writeOnly,\n tags,\n taxonomy,\n deprecated,\n schema,\n bindings,\n } = init\n this.kind = kind\n this.key = key\n this.type = type\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (typeof multiple === 'boolean') {\n this.multiple = multiple\n } else {\n this.multiple = undefined\n }\n if (typeof required === 'boolean') {\n this.required = required\n } else {\n this.required = undefined\n }\n if (typeof index === 'boolean') {\n this.index = index\n } else {\n this.index = undefined\n }\n if (typeof deprecated === 'boolean') {\n this.deprecated = deprecated\n } else {\n this.deprecated = undefined\n }\n if (typeof primary === 'boolean') {\n this.primary = primary\n } else {\n this.primary = undefined\n }\n if (typeof readOnly === 'boolean') {\n this.readOnly = readOnly\n } else {\n this.readOnly = undefined\n }\n if (typeof writeOnly === 'boolean') {\n this.writeOnly = writeOnly\n } else {\n this.writeOnly = undefined\n }\n if (Array.isArray(tags)) {\n this.tags = [...tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(taxonomy)) {\n this.taxonomy = [...taxonomy]\n } else {\n this.taxonomy = []\n }\n if (schema) {\n this.schema = structuredClone(schema)\n } else {\n this.schema = undefined\n }\n if (Array.isArray(bindings)) {\n this.bindings = bindings.map((i) => structuredClone(i))\n } else {\n this.bindings = []\n }\n }\n\n static isDataProperty(input: unknown): boolean {\n const typed = input as IDataProperty\n if (!input || typed.kind !== DataPropertyKind) {\n return false\n }\n return true\n }\n\n toJSON(): IDataProperty {\n const result: IDataProperty = {\n kind: DataPropertyKind,\n info: this.info.toJSON(),\n key: this.key,\n type: this.type || DataPropertyList.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(this.schema)\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = this.bindings.map((i) => structuredClone(i))\n }\n return result\n }\n\n /**\n * Removes self from the parent entity and the namespace definition.\n */\n remove(): void {\n const { root } = this\n const entity = root.definitions.entities.find((i) => i.properties.some((j) => j.key === this.key))\n if (entity) {\n const assocIndex = entity.properties.findIndex((i) => i.key === this.key)\n entity.properties.splice(assocIndex, 1)\n }\n const defIndex = this.root.definitions.properties.findIndex((i) => i.key === this.key)\n if (defIndex >= 0) {\n this.root.definitions.properties.splice(defIndex, 1)\n }\n }\n\n /**\n * Adds a new tag to the property. It also populates the root namespace's tags when tag is new.\n *\n * Note, it does nothing when the tag is already defined.\n *\n * @param tag The tag to add.\n */\n addTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n if (tags.some((t) => t.toLowerCase() === lower)) {\n return\n }\n tags.push(tag)\n const { definitions } = this.root\n if (!definitions.tags.some((t) => t.toLowerCase() === lower)) {\n definitions.tags.push(tag)\n }\n }\n\n /**\n * Removes a tag from the property. Unlike the `addTag()` this won't remove a `tag` from the root namespace.\n *\n * @param tag The tag to remove.\n */\n removeTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n const index = tags.findIndex((t) => t.toLowerCase() === lower)\n if (index >= 0) {\n tags.splice(index, 1)\n }\n }\n\n /**\n * Creates a Property Shape of AMF.\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new AmfShapeGenerator()\n return serializer.property(this)\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 DataPropertyType {\n if (typeof value !== 'string') {\n return false\n }\n return DataPropertyTypes.includes(value as DataPropertyType)\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 DataPropertyAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DataPropertyAttributes.includes(value as DataPropertyAttribute)\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 DataPropertyFormat {\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(): DataPropertySchema {\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\n }\n\n /**\n * Returns a parent data entity where this data property exist.\n */\n getParentInstance(): DataEntity | undefined {\n return this.root.definitions.entities.find((e) => e.properties.some((e) => e.key === this.key))\n }\n\n /**\n * Checks whether the property is a child of the given namespace, data model, or an entity.\n * The relationship doesn't have to be direct, as long as the property is in the hierarchy it will return true.\n *\n * @param key The key of the parent to check.\n * @returns True if this data property is a child of the given namespace, data model, or an entity\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n return parent.isChildOf(key)\n }\n}\n"]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { File, IFile } from './File.js';
|
|
2
|
-
import { DataNamespace, IDataNamespace } from '../../modeling/legacy/DataNamespace.js';
|
|
3
|
-
import { DataFileKind as Kind } from '../kinds.js';
|
|
4
|
-
export interface IDataFile extends IFile {
|
|
5
|
-
kind: typeof Kind;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Used by the store. A file definition for the DataNamespace
|
|
9
|
-
* @deprecated Use DomainFile instead.
|
|
10
|
-
*/
|
|
11
|
-
export declare class DataFile extends File {
|
|
12
|
-
kind: string;
|
|
13
|
-
/**
|
|
14
|
-
* Creates the file definition for a DataNamespace contents.
|
|
15
|
-
*
|
|
16
|
-
* @param input The data namespace instance or schema.
|
|
17
|
-
* @deprecated Use DomainFile instead.
|
|
18
|
-
*/
|
|
19
|
-
static fromDataNamespace(input: DataNamespace | IDataNamespace): DataFile;
|
|
20
|
-
/**
|
|
21
|
-
* @param name The name to set.
|
|
22
|
-
*/
|
|
23
|
-
static fromName(name: string): DataFile;
|
|
24
|
-
constructor(input?: string | IDataFile);
|
|
25
|
-
new(init: IDataFile): this;
|
|
26
|
-
static isDataFile(input: unknown): boolean;
|
|
27
|
-
toJSON(): IDataFile;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=DataFile.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DataFile.d.ts","sourceRoot":"","sources":["../../../../src/models/store/DataFile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEvC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AACtF,OAAO,EAAE,YAAY,IAAI,IAAI,EAAE,MAAM,aAAa,CAAA;AAElD,MAAM,WAAW,SAAU,SAAQ,KAAK;IACtC,IAAI,EAAE,OAAO,IAAI,CAAA;CAClB;AAED;;;GAGG;AACH,qBAAa,QAAS,SAAQ,IAAI;IACvB,IAAI,SAAO;IAEpB;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,cAAc,GAAG,QAAQ;IAmBzE;;OAEG;WACa,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ;gBAIpC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS;IAqB7B,GAAG,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IASnC,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAQjC,MAAM,IAAI,SAAS;CAO7B"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { nanoid } from '../../nanoid.js';
|
|
2
|
-
import { File } from './File.js';
|
|
3
|
-
import { Thing } from '../Thing.js';
|
|
4
|
-
import { DataFileKind as Kind } from '../kinds.js';
|
|
5
|
-
/**
|
|
6
|
-
* Used by the store. A file definition for the DataNamespace
|
|
7
|
-
* @deprecated Use DomainFile instead.
|
|
8
|
-
*/
|
|
9
|
-
export class DataFile extends File {
|
|
10
|
-
kind = Kind;
|
|
11
|
-
/**
|
|
12
|
-
* Creates the file definition for a DataNamespace contents.
|
|
13
|
-
*
|
|
14
|
-
* @param input The data namespace instance or schema.
|
|
15
|
-
* @deprecated Use DomainFile instead.
|
|
16
|
-
*/
|
|
17
|
-
static fromDataNamespace(input) {
|
|
18
|
-
let final;
|
|
19
|
-
if (typeof input.toJSON === 'function') {
|
|
20
|
-
final = input.toJSON();
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
final = input;
|
|
24
|
-
}
|
|
25
|
-
const init = {
|
|
26
|
-
kind: Kind,
|
|
27
|
-
key: final.key,
|
|
28
|
-
info: { ...final.info },
|
|
29
|
-
lastModified: { user: '', time: 0, byMe: false },
|
|
30
|
-
parents: [],
|
|
31
|
-
permissionIds: [],
|
|
32
|
-
permissions: [],
|
|
33
|
-
};
|
|
34
|
-
return new DataFile(init);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @param name The name to set.
|
|
38
|
-
*/
|
|
39
|
-
static fromName(name) {
|
|
40
|
-
return super.fromName(name, Kind);
|
|
41
|
-
}
|
|
42
|
-
constructor(input) {
|
|
43
|
-
super();
|
|
44
|
-
let init;
|
|
45
|
-
if (typeof input === 'string') {
|
|
46
|
-
init = JSON.parse(input);
|
|
47
|
-
}
|
|
48
|
-
else if (typeof input === 'object') {
|
|
49
|
-
init = input;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
init = {
|
|
53
|
-
kind: Kind,
|
|
54
|
-
key: nanoid(),
|
|
55
|
-
info: Thing.fromName('').toJSON(),
|
|
56
|
-
parents: [],
|
|
57
|
-
permissionIds: [],
|
|
58
|
-
permissions: [],
|
|
59
|
-
lastModified: { user: '', time: 0, byMe: false },
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
this.new(init);
|
|
63
|
-
}
|
|
64
|
-
new(init) {
|
|
65
|
-
if (!DataFile.isDataFile(init)) {
|
|
66
|
-
throw new Error(`Not a data file.`);
|
|
67
|
-
}
|
|
68
|
-
super.new(init);
|
|
69
|
-
this.kind = Kind;
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
static isDataFile(input) {
|
|
73
|
-
const typed = input;
|
|
74
|
-
if (!input || typed.kind !== Kind) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
toJSON() {
|
|
80
|
-
const result = {
|
|
81
|
-
...super.toJSON(),
|
|
82
|
-
kind: Kind,
|
|
83
|
-
};
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=DataFile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DataFile.js","sourceRoot":"","sources":["../../../../src/models/store/DataFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAS,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC,OAAO,EAAE,YAAY,IAAI,IAAI,EAAE,MAAM,aAAa,CAAA;AAMlD;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,IAAI;IACvB,IAAI,GAAG,IAAI,CAAA;IAEpB;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,KAAqC;QAC5D,IAAI,KAAqB,CAAA;QACzB,IAAI,OAAQ,KAAuB,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YAC1D,KAAK,GAAI,KAAuB,CAAC,MAAM,EAAE,CAAA;QAC3C,CAAC;aAAM,CAAC;YACN,KAAK,GAAG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CAAC,IAAe;QAC1B,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;QACrC,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,KAAc;QAC9B,MAAM,KAAK,GAAG,KAAkB,CAAA;QAChC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAClC,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAEQ,MAAM;QACb,MAAM,MAAM,GAAc;YACxB,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,IAAI,EAAE,IAAI;SACX,CAAA;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { nanoid } from '../../nanoid.js'\nimport { File, IFile } from './File.js'\nimport { Thing } from '../Thing.js'\nimport { DataNamespace, IDataNamespace } from '../../modeling/legacy/DataNamespace.js'\nimport { DataFileKind as Kind } from '../kinds.js'\n\nexport interface IDataFile extends IFile {\n kind: typeof Kind\n}\n\n/**\n * Used by the store. A file definition for the DataNamespace\n * @deprecated Use DomainFile instead.\n */\nexport class DataFile extends File {\n override kind = Kind\n\n /**\n * Creates the file definition for a DataNamespace contents.\n *\n * @param input The data namespace instance or schema.\n * @deprecated Use DomainFile instead.\n */\n static fromDataNamespace(input: DataNamespace | IDataNamespace): DataFile {\n let final: IDataNamespace\n if (typeof (input as DataNamespace).toJSON === 'function') {\n final = (input as DataNamespace).toJSON()\n } else {\n final = input as IDataNamespace\n }\n const init: IDataFile = {\n kind: Kind,\n key: final.key,\n info: { ...final.info },\n lastModified: { user: '', time: 0, byMe: false },\n parents: [],\n permissionIds: [],\n permissions: [],\n }\n return new DataFile(init)\n }\n\n /**\n * @param name The name to set.\n */\n static override fromName(name: string): DataFile {\n return super.fromName(name, Kind) as DataFile\n }\n\n constructor(input?: string | IDataFile) {\n super()\n let init: IDataFile\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: Kind,\n key: nanoid(),\n info: Thing.fromName('').toJSON(),\n parents: [],\n permissionIds: [],\n permissions: [],\n lastModified: { user: '', time: 0, byMe: false },\n }\n }\n this.new(init)\n }\n\n override new(init: IDataFile): this {\n if (!DataFile.isDataFile(init)) {\n throw new Error(`Not a data file.`)\n }\n super.new(init)\n this.kind = Kind\n return this\n }\n\n static isDataFile(input: unknown): boolean {\n const typed = input as IDataFile\n if (!input || typed.kind !== Kind) {\n return false\n }\n return true\n }\n\n override toJSON(): IDataFile {\n const result: IDataFile = {\n ...super.toJSON(),\n kind: Kind,\n }\n return result\n }\n}\n"]}
|