@api-client/core 0.6.14 → 0.6.17
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/browser.d.ts +9 -2
- package/build/browser.js +12 -2
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +9 -2
- package/build/index.js +12 -2
- package/build/index.js.map +1 -1
- package/build/src/amf/AmfMixin.d.ts +395 -0
- package/build/src/amf/AmfMixin.js +1146 -0
- package/build/src/amf/AmfMixin.js.map +1 -0
- package/build/src/amf/AmfSerializer.d.ts +136 -0
- package/build/src/amf/AmfSerializer.js +1913 -0
- package/build/src/amf/AmfSerializer.js.map +1 -0
- package/build/src/amf/AmfShapeGenerator.d.ts +85 -0
- package/build/src/amf/AmfShapeGenerator.js +385 -0
- package/build/src/amf/AmfShapeGenerator.js.map +1 -0
- package/build/src/amf/AmfTypes.d.ts +24 -0
- package/build/src/amf/AmfTypes.js +122 -0
- package/build/src/amf/AmfTypes.js.map +1 -0
- package/build/src/amf/ApiExampleGenerator.d.ts +36 -0
- package/build/src/amf/ApiExampleGenerator.js +109 -0
- package/build/src/amf/ApiExampleGenerator.js.map +1 -0
- package/build/src/amf/ApiMonacoSchemaGenerator.d.ts +67 -0
- package/build/src/amf/ApiMonacoSchemaGenerator.js +243 -0
- package/build/src/amf/ApiMonacoSchemaGenerator.js.map +1 -0
- package/build/src/amf/ApiSchemaGenerator.d.ts +55 -0
- package/build/src/amf/ApiSchemaGenerator.js +94 -0
- package/build/src/amf/ApiSchemaGenerator.js.map +1 -0
- package/build/src/amf/ApiSchemaValues.d.ts +98 -0
- package/build/src/amf/ApiSchemaValues.js +382 -0
- package/build/src/amf/ApiSchemaValues.js.map +1 -0
- package/build/src/amf/Utils.d.ts +41 -0
- package/build/src/amf/Utils.js +176 -0
- package/build/src/amf/Utils.js.map +1 -0
- package/build/src/amf/data-node/DataNodeBase.d.ts +31 -0
- package/build/src/amf/data-node/DataNodeBase.js +77 -0
- package/build/src/amf/data-node/DataNodeBase.js.map +1 -0
- package/build/src/amf/data-node/JsonDataNodeGenerator.d.ts +15 -0
- package/build/src/amf/data-node/JsonDataNodeGenerator.js +24 -0
- package/build/src/amf/data-node/JsonDataNodeGenerator.js.map +1 -0
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.d.ts +13 -0
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.js +42 -0
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.js.map +1 -0
- package/build/src/amf/data-node/XmlDataNodeGenerator.d.ts +21 -0
- package/build/src/amf/data-node/XmlDataNodeGenerator.js +30 -0
- package/build/src/amf/data-node/XmlDataNodeGenerator.js.map +1 -0
- package/build/src/amf/definitions/Amf.d.ts +362 -0
- package/build/src/amf/definitions/Amf.js +2 -0
- package/build/src/amf/definitions/Amf.js.map +1 -0
- package/build/src/amf/definitions/Api.d.ts +381 -0
- package/build/src/amf/definitions/Api.js +2 -0
- package/build/src/amf/definitions/Api.js.map +1 -0
- package/build/src/amf/definitions/Base.d.ts +11 -0
- package/build/src/amf/definitions/Base.js +2 -0
- package/build/src/amf/definitions/Base.js.map +1 -0
- package/build/src/amf/definitions/Namespace.d.ts +311 -0
- package/build/src/amf/definitions/Namespace.js +330 -0
- package/build/src/amf/definitions/Namespace.js.map +1 -0
- package/build/src/amf/definitions/Shapes.d.ts +309 -0
- package/build/src/amf/definitions/Shapes.js +87 -0
- package/build/src/amf/definitions/Shapes.js.map +1 -0
- package/build/src/amf/models/AmfDataNode.d.ts +68 -0
- package/build/src/amf/models/AmfDataNode.js +188 -0
- package/build/src/amf/models/AmfDataNode.js.map +1 -0
- package/build/src/amf/shape/ShapeBase.d.ts +75 -0
- package/build/src/amf/shape/ShapeBase.js +90 -0
- package/build/src/amf/shape/ShapeBase.js.map +1 -0
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.d.ts +46 -0
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.js +406 -0
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.js.map +1 -0
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.d.ts +84 -0
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.js +820 -0
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.js.map +1 -0
- package/build/src/models/data/Bindings.d.ts +161 -0
- package/build/src/models/data/Bindings.js +2 -0
- package/build/src/models/data/Bindings.js.map +1 -0
- package/build/src/models/data/DataAssociation.d.ts +135 -14
- package/build/src/models/data/DataAssociation.js +154 -21
- package/build/src/models/data/DataAssociation.js.map +1 -1
- package/build/src/models/data/DataAssociationSchema.d.ts +36 -0
- package/build/src/models/data/DataEntity.d.ts +71 -15
- package/build/src/models/data/DataEntity.js +133 -53
- package/build/src/models/data/DataEntity.js.map +1 -1
- package/build/src/models/data/DataFile.d.ts +3 -0
- package/build/src/models/data/DataFile.js +3 -0
- package/build/src/models/data/DataFile.js.map +1 -1
- package/build/src/models/data/DataModel.d.ts +1 -1
- package/build/src/models/data/DataModel.js.map +1 -1
- package/build/src/models/data/DataNamespace.d.ts +14 -0
- package/build/src/models/data/DataNamespace.js +50 -0
- package/build/src/models/data/DataNamespace.js.map +1 -1
- package/build/src/models/data/DataProperty.d.ts +107 -36
- package/build/src/models/data/DataProperty.js +147 -17
- package/build/src/models/data/DataProperty.js.map +1 -1
- package/data/apis/oas-date/oas-date.yaml +28 -0
- package/data/apis/oas-types/oas-types.yaml +159 -0
- package/data/apis/oas-unions/oas-unions.yaml +75 -0
- package/data/apis/raml-date/raml-date.raml +28 -0
- package/data/apis/recursive/recursive.raml +14 -0
- package/data/apis/schema-api/examples/person.json +14 -0
- package/data/apis/schema-api/examples/person.raml +14 -0
- package/data/apis/schema-api/examples/person.url.encoded +1 -0
- package/data/apis/schema-api/examples/person.xml +14 -0
- package/data/apis/schema-api/library/demo-types.raml +43 -0
- package/data/apis/schema-api/schema-api.raml +644 -0
- package/data/apis/schema-api/schemas/person.json +104 -0
- package/data/apis/schema-api/schemas/person.xsd +26 -0
- package/data/apis/schema-api/types/DemoPerson.raml +67 -0
- package/data/model.js +106 -0
- package/data/models/oas-date.json +637 -0
- package/data/models/oas-types.json +5352 -0
- package/data/models/oas-unions.json +1881 -0
- package/data/models/raml-date.json +1096 -0
- package/data/models/recursive.json +610 -0
- package/data/models/schema-api.json +37319 -0
- package/package.json +9 -6
- package/src/amf/AmfMixin.ts +1623 -0
- package/src/amf/AmfSerializer.ts +2028 -0
- package/src/amf/AmfShapeGenerator.ts +400 -0
- package/src/amf/AmfTypes.ts +126 -0
- package/src/amf/ApiExampleGenerator.ts +112 -0
- package/src/amf/ApiMonacoSchemaGenerator.ts +296 -0
- package/src/amf/ApiSchemaGenerator.ts +108 -0
- package/src/amf/ApiSchemaValues.ts +411 -0
- package/src/amf/Utils.ts +182 -0
- package/src/amf/data-node/DataNodeBase.ts +81 -0
- package/src/amf/data-node/JsonDataNodeGenerator.ts +26 -0
- package/src/amf/data-node/README.md +3 -0
- package/src/amf/data-node/UrlEncodedDataNodeGenerator.ts +43 -0
- package/src/amf/data-node/XmlDataNodeGenerator.ts +38 -0
- package/src/amf/definitions/Amf.ts +443 -0
- package/src/amf/definitions/Api.ts +427 -0
- package/src/amf/definitions/Base.ts +13 -0
- package/src/amf/definitions/Namespace.ts +341 -0
- package/src/amf/definitions/Shapes.ts +414 -0
- package/src/amf/models/AmfDataNode.ts +200 -0
- package/src/amf/shape/README.md +4 -0
- package/src/amf/shape/ShapeBase.ts +160 -0
- package/src/amf/shape/ShapeJsonSchemaGenerator.ts +422 -0
- package/src/amf/shape/ShapeXmlSchemaGenerator.ts +876 -0
- package/src/models/data/Bindings.ts +186 -0
- package/src/models/data/DataAssociation.ts +226 -29
- package/src/models/data/DataAssociationSchema.ts +38 -0
- package/src/models/data/DataEntity.ts +162 -60
- package/src/models/data/DataFile.ts +3 -0
- package/src/models/data/DataModel.ts +1 -1
- package/src/models/data/DataNamespace.ts +54 -0
- package/src/models/data/DataProperty.ts +191 -47
- package/build/src/models/data/DataPropertySchema.d.ts +0 -125
- package/build/src/models/data/DataPropertySchema.js +0 -33
- package/build/src/models/data/DataPropertySchema.js.map +0 -1
- package/src/models/data/DataPropertySchema.ts +0 -156
|
@@ -1,51 +1,44 @@
|
|
|
1
|
+
import { Core as JsonCore } from '@api-client/json';
|
|
1
2
|
import { IThing, Thing } from "../Thing.js";
|
|
2
3
|
import v4 from '../../lib/uuid.js';
|
|
3
4
|
import { DataNamespace } from "./DataNamespace.js";
|
|
4
|
-
import {
|
|
5
|
+
import { IPropertyShape } from "../../amf/definitions/Shapes.js";
|
|
6
|
+
import { AmfShapeGenerator } from '../../amf/AmfShapeGenerator.js';
|
|
7
|
+
import { IPropertyBindings, IPropertySchema } from './Bindings.js';
|
|
5
8
|
|
|
6
|
-
export type DataPropertyType = 'string' | 'number' | 'nil' | 'boolean' | 'date' | 'datetime' |
|
|
7
|
-
'time' | 'bytes' | 'any' | 'file';
|
|
9
|
+
export type DataPropertyType = 'string' | 'number' | 'integer' | 'nil' | 'boolean' | 'date' | 'datetime' | 'time' | 'any' | 'binary';
|
|
8
10
|
export const DataPropertyTypes: DataPropertyType[] = [
|
|
9
|
-
'string', 'number', 'nil', 'boolean', 'date', 'datetime', 'time'
|
|
11
|
+
'string', 'number', 'integer', 'nil', 'boolean', 'date', 'datetime', 'time' , 'any', 'binary'
|
|
10
12
|
];
|
|
11
13
|
|
|
12
14
|
export enum DataPropertyList {
|
|
13
15
|
string = 'string',
|
|
14
16
|
number = 'number',
|
|
17
|
+
integer = 'integer', // RAML, OAS and JSON schema define numbers and integers separately
|
|
15
18
|
nil = 'nil',
|
|
16
19
|
boolean = 'boolean',
|
|
17
20
|
date = 'date',
|
|
18
21
|
datetime = 'datetime',
|
|
19
22
|
time = 'time',
|
|
20
|
-
bytes = 'bytes',
|
|
21
23
|
any = 'any',
|
|
22
|
-
file = '
|
|
24
|
+
file = 'binary',
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
export
|
|
27
|
+
export type DateFormat = 'rfc3339' | 'rfc2616';
|
|
28
|
+
export const DateFormats: DateFormat[] = ['rfc3339', 'rfc2616'];
|
|
29
|
+
export enum DateFormatList {
|
|
28
30
|
/**
|
|
29
|
-
*
|
|
30
|
-
* All other schemas inherit from this one. This allows creating global schema description
|
|
31
|
-
* like examples, default values, minimum value, etc and then use it as a base to generate specific formats.
|
|
32
|
-
*
|
|
33
|
-
* A property may not have a global schema.
|
|
31
|
+
* The "date-time" notation of RFC3339
|
|
34
32
|
*/
|
|
35
|
-
|
|
33
|
+
rfc3339 = 'rfc3339',
|
|
36
34
|
/**
|
|
37
|
-
* The
|
|
38
|
-
* For JSON it is `application/json`, for XML it is `application/xml` (or `text/xml`) adn so on.
|
|
39
|
-
*
|
|
40
|
-
* Note, when this value is missing then it is assumed that the schema is `global`.
|
|
35
|
+
* The format defined in RFC2616.
|
|
41
36
|
*/
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The schema definition.
|
|
45
|
-
*/
|
|
46
|
-
value: IDataPropertySchema<T>;
|
|
37
|
+
rfc2616 = 'rfc2616',
|
|
47
38
|
}
|
|
48
39
|
|
|
40
|
+
export const Kind = 'Core#DataProperty';
|
|
41
|
+
|
|
49
42
|
export interface IDataProperty {
|
|
50
43
|
kind: typeof Kind;
|
|
51
44
|
/**
|
|
@@ -72,6 +65,21 @@ export interface IDataProperty {
|
|
|
72
65
|
* Whether this property describes an indexed property of the entity.
|
|
73
66
|
*/
|
|
74
67
|
index?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the property is read only in the schema.
|
|
70
|
+
*/
|
|
71
|
+
readOnly?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Whether the property is write only in the schema.
|
|
74
|
+
*/
|
|
75
|
+
writeOnly?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Whether the attribute is hidden in the schema (not a part of it).
|
|
78
|
+
*
|
|
79
|
+
* The hidden attribute should only appear in the adapted attribute.
|
|
80
|
+
* Has no effect when added to the "main" attribute.
|
|
81
|
+
*/
|
|
82
|
+
hidden?: boolean;
|
|
75
83
|
/**
|
|
76
84
|
* Whether this property is deprecated.
|
|
77
85
|
*/
|
|
@@ -94,16 +102,30 @@ export interface IDataProperty {
|
|
|
94
102
|
* a derivative entity for specific schema to describe specific schema case.
|
|
95
103
|
*/
|
|
96
104
|
type: DataPropertyType;
|
|
97
|
-
|
|
98
105
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
|
|
106
|
+
* The general schema definition of this property.
|
|
107
|
+
* This is propagated to all bindings (when they support these properties).
|
|
108
|
+
*
|
|
109
|
+
* Note, schema can only occur on an adapted property. Has no effect on the "main"
|
|
110
|
+
* property.
|
|
111
|
+
*/
|
|
112
|
+
schema?: IPropertySchema;
|
|
113
|
+
/**
|
|
114
|
+
* The list of bindings for this property.
|
|
115
|
+
*
|
|
116
|
+
* A binding defines a translation from a data model to a specific format.
|
|
117
|
+
* For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs
|
|
118
|
+
* or a protocol buffer schema.
|
|
119
|
+
*/
|
|
120
|
+
bindings?: IPropertyBindings[];
|
|
121
|
+
/**
|
|
122
|
+
* The key of the property that is adapted by this property.
|
|
123
|
+
* Adapted properties can manipulate the shape of the schema for the property.
|
|
124
|
+
*
|
|
125
|
+
* Each value defined on the adapted property changes the original value defined on
|
|
126
|
+
* the property.
|
|
105
127
|
*/
|
|
106
|
-
|
|
128
|
+
adapts?: string;
|
|
107
129
|
}
|
|
108
130
|
|
|
109
131
|
export class DataProperty {
|
|
@@ -136,6 +158,23 @@ export class DataProperty {
|
|
|
136
158
|
*/
|
|
137
159
|
index?: boolean;
|
|
138
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Whether the property is read only in the schema.
|
|
163
|
+
*/
|
|
164
|
+
readOnly?: boolean;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Whether the property is write only in the schema.
|
|
168
|
+
*/
|
|
169
|
+
writeOnly?: boolean;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Whether the attribute is hidden in the schema (not a part of it).
|
|
173
|
+
* The hidden attribute should only appear in the adapted attribute.
|
|
174
|
+
* Has no effect when added to the "main" attribute.
|
|
175
|
+
*/
|
|
176
|
+
hidden?: boolean;
|
|
177
|
+
|
|
139
178
|
/**
|
|
140
179
|
* Whether this property is deprecated.
|
|
141
180
|
*/
|
|
@@ -165,14 +204,30 @@ export class DataProperty {
|
|
|
165
204
|
type: DataPropertyType = 'string';
|
|
166
205
|
|
|
167
206
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
|
|
207
|
+
* The general schema definition of this property.
|
|
208
|
+
* This is propagated to all bindings (when they support these properties).
|
|
209
|
+
*
|
|
210
|
+
* Note, schema can only occur on an adapted property. Has no effect on the "main"
|
|
211
|
+
* property.
|
|
212
|
+
*/
|
|
213
|
+
schema?: IPropertySchema;
|
|
214
|
+
/**
|
|
215
|
+
* The list of bindings for this property.
|
|
216
|
+
*
|
|
217
|
+
* A binding defines a translation from a data model to a specific format.
|
|
218
|
+
* For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs
|
|
219
|
+
* or a protocol buffer schema.
|
|
220
|
+
*/
|
|
221
|
+
bindings: IPropertyBindings[] = [];
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* The key of the property that is adapted by this property.
|
|
225
|
+
* Adapted properties can manipulate the shape of the schema for the property.
|
|
226
|
+
*
|
|
227
|
+
* Each value defined on the adapted property changes the original value defined on
|
|
228
|
+
* the property.
|
|
174
229
|
*/
|
|
175
|
-
|
|
230
|
+
adapts?: string;
|
|
176
231
|
|
|
177
232
|
static get supportedTypes(): DataPropertyType[] {
|
|
178
233
|
return [...DataPropertyTypes];
|
|
@@ -193,7 +248,7 @@ export class DataProperty {
|
|
|
193
248
|
/**
|
|
194
249
|
* @param input The data property definition to restore.
|
|
195
250
|
*/
|
|
196
|
-
constructor(
|
|
251
|
+
constructor(public root: DataNamespace, input?: string | IDataProperty) {
|
|
197
252
|
let init: IDataProperty;
|
|
198
253
|
if (typeof input === 'string') {
|
|
199
254
|
init = JSON.parse(input);
|
|
@@ -214,7 +269,11 @@ export class DataProperty {
|
|
|
214
269
|
if (!DataProperty.isDataProperty(init)) {
|
|
215
270
|
throw new Error(`Not a data property.`);
|
|
216
271
|
}
|
|
217
|
-
const {
|
|
272
|
+
const {
|
|
273
|
+
info, key = v4(), kind = Kind, multiple, required, type = DataPropertyList.string,
|
|
274
|
+
index, primary, readOnly, writeOnly, adapts, hidden, tags, taxonomy, deprecated,
|
|
275
|
+
schema, bindings,
|
|
276
|
+
} = init;
|
|
218
277
|
this.kind = kind;
|
|
219
278
|
this.key = key;
|
|
220
279
|
this.type = type;
|
|
@@ -248,6 +307,26 @@ export class DataProperty {
|
|
|
248
307
|
} else {
|
|
249
308
|
this.primary = undefined;
|
|
250
309
|
}
|
|
310
|
+
if (typeof readOnly === 'boolean') {
|
|
311
|
+
this.readOnly = readOnly;
|
|
312
|
+
} else {
|
|
313
|
+
this.readOnly = undefined;
|
|
314
|
+
}
|
|
315
|
+
if (typeof writeOnly === 'boolean') {
|
|
316
|
+
this.writeOnly = writeOnly;
|
|
317
|
+
} else {
|
|
318
|
+
this.writeOnly = undefined;
|
|
319
|
+
}
|
|
320
|
+
if (typeof hidden === 'boolean') {
|
|
321
|
+
this.hidden = hidden;
|
|
322
|
+
} else {
|
|
323
|
+
this.hidden = undefined;
|
|
324
|
+
}
|
|
325
|
+
if (typeof adapts === 'string') {
|
|
326
|
+
this.adapts = adapts;
|
|
327
|
+
} else {
|
|
328
|
+
this.adapts = undefined;
|
|
329
|
+
}
|
|
251
330
|
if (Array.isArray(tags)) {
|
|
252
331
|
this.tags = [...tags];
|
|
253
332
|
} else {
|
|
@@ -258,10 +337,15 @@ export class DataProperty {
|
|
|
258
337
|
} else {
|
|
259
338
|
this.taxonomy = [];
|
|
260
339
|
}
|
|
261
|
-
if (
|
|
262
|
-
this.
|
|
340
|
+
if (schema) {
|
|
341
|
+
this.schema = JsonCore.clone(schema);
|
|
342
|
+
} else {
|
|
343
|
+
this.schema = undefined;
|
|
344
|
+
}
|
|
345
|
+
if (Array.isArray(bindings)) {
|
|
346
|
+
this.bindings = bindings.map(i => JsonCore.clone(i));
|
|
263
347
|
} else {
|
|
264
|
-
this.
|
|
348
|
+
this.bindings = [];
|
|
265
349
|
}
|
|
266
350
|
}
|
|
267
351
|
|
|
@@ -295,14 +379,29 @@ export class DataProperty {
|
|
|
295
379
|
if (typeof this.required === 'boolean') {
|
|
296
380
|
result.required = this.required;
|
|
297
381
|
}
|
|
382
|
+
if (typeof this.readOnly === 'boolean') {
|
|
383
|
+
result.readOnly = this.readOnly;
|
|
384
|
+
}
|
|
385
|
+
if (typeof this.writeOnly === 'boolean') {
|
|
386
|
+
result.writeOnly = this.writeOnly;
|
|
387
|
+
}
|
|
388
|
+
if (typeof this.hidden === 'boolean') {
|
|
389
|
+
result.hidden = this.hidden;
|
|
390
|
+
}
|
|
391
|
+
if (this.adapts) {
|
|
392
|
+
result.adapts = this.adapts;
|
|
393
|
+
}
|
|
298
394
|
if (Array.isArray(this.tags) && this.tags.length) {
|
|
299
395
|
result.tags = [...this.tags];
|
|
300
396
|
}
|
|
301
397
|
if (Array.isArray(this.taxonomy) && this.taxonomy.length) {
|
|
302
398
|
result.taxonomy = [...this.taxonomy];
|
|
303
399
|
}
|
|
304
|
-
if (
|
|
305
|
-
result.
|
|
400
|
+
if (this.schema) {
|
|
401
|
+
result.schema = JsonCore.clone(this.schema);
|
|
402
|
+
}
|
|
403
|
+
if (Array.isArray(this.bindings) && this.bindings.length) {
|
|
404
|
+
result.taxonomy = this.taxonomy.map(i => JsonCore.clone(i));
|
|
306
405
|
}
|
|
307
406
|
return result;
|
|
308
407
|
}
|
|
@@ -311,7 +410,7 @@ export class DataProperty {
|
|
|
311
410
|
* Removes self from the parent entity and the namespace definition.
|
|
312
411
|
*/
|
|
313
412
|
remove(): void {
|
|
314
|
-
const { root } = this;
|
|
413
|
+
const { root, adapts } = this;
|
|
315
414
|
const entity = root.definitions.entities.find(i => i.properties.some(j => j === this));
|
|
316
415
|
if (entity) {
|
|
317
416
|
const assocIndex = entity.properties.findIndex(i => i === this);
|
|
@@ -321,6 +420,12 @@ export class DataProperty {
|
|
|
321
420
|
if (defIndex >= 0) {
|
|
322
421
|
this.root.definitions.properties.splice(defIndex, 1);
|
|
323
422
|
}
|
|
423
|
+
if (adapts) {
|
|
424
|
+
const adaptsIndex = this.root.definitions.properties.findIndex(i => i.key === adapts);
|
|
425
|
+
if (adaptsIndex >= 0) {
|
|
426
|
+
this.root.definitions.properties.splice(adaptsIndex, 1);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
324
429
|
}
|
|
325
430
|
|
|
326
431
|
/**
|
|
@@ -362,4 +467,43 @@ export class DataProperty {
|
|
|
362
467
|
tags.splice(index, 1);
|
|
363
468
|
}
|
|
364
469
|
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Creates a Property Shape of AMF.
|
|
473
|
+
* The property itself is auto-generated. If the `schema` is defined then it is used
|
|
474
|
+
* as the `range` of the property. Otherwise basic shape is generated for the range.
|
|
475
|
+
*
|
|
476
|
+
* This is a preferred way of reading the AMF shape as this synchronizes changed
|
|
477
|
+
* data properties with the shape definition.
|
|
478
|
+
*
|
|
479
|
+
* @returns AMF property shape definition.
|
|
480
|
+
*/
|
|
481
|
+
toApiShape(): IPropertyShape {
|
|
482
|
+
const serializer = new AmfShapeGenerator();
|
|
483
|
+
return serializer.property(this);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* @returns The adapted property, if any
|
|
488
|
+
*/
|
|
489
|
+
readAdapted(): DataProperty | undefined {
|
|
490
|
+
const { adapts } = this;
|
|
491
|
+
if (!adapts) {
|
|
492
|
+
return undefined;
|
|
493
|
+
}
|
|
494
|
+
return this.root.definitions.properties.find(i => i.key === adapts);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Creates new adapted property and associates it with this property.
|
|
499
|
+
* @returns The instance of the created property.
|
|
500
|
+
*/
|
|
501
|
+
createAdapted(): DataProperty {
|
|
502
|
+
const property = new DataProperty(this.root);
|
|
503
|
+
// disallow defaults as this would influence the schema generation
|
|
504
|
+
property.info.name = undefined;
|
|
505
|
+
this.root.definitions.properties.push(property);
|
|
506
|
+
this.adapts = property.key;
|
|
507
|
+
return property;
|
|
508
|
+
}
|
|
365
509
|
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
export declare type NumberFormat = 'integer' | 'float' | 'long' | 'double' | 'int32' | 'int64' | 'uint32' | 'uint64' | 'sint32' | 'sint64' | 'fixed32' | 'fixed64' | 'sfixed32' | 'sfixed64';
|
|
2
|
-
export declare const NumberFormats: NumberFormat[];
|
|
3
|
-
export declare enum NumberFormatList {
|
|
4
|
-
integer = "integer",
|
|
5
|
-
float = "float",
|
|
6
|
-
int32 = "int32",
|
|
7
|
-
int64 = "int64",
|
|
8
|
-
uint32 = "uint32",
|
|
9
|
-
uint64 = "uint64",
|
|
10
|
-
sint32 = "sint32",
|
|
11
|
-
sint64 = "sint64",
|
|
12
|
-
fixed32 = "fixed32",
|
|
13
|
-
fixed64 = "fixed64",
|
|
14
|
-
sfixed32 = "sfixed32",
|
|
15
|
-
sfixed64 = "sfixed64",
|
|
16
|
-
double = "double"
|
|
17
|
-
}
|
|
18
|
-
export declare type DateFormat = 'rfc3339' | 'rfc2616';
|
|
19
|
-
export declare const DateFormats: DateFormat[];
|
|
20
|
-
export declare enum DateFormatList {
|
|
21
|
-
/**
|
|
22
|
-
* The "date-time" notation of RFC3339
|
|
23
|
-
*/
|
|
24
|
-
rfc3339 = "rfc3339",
|
|
25
|
-
/**
|
|
26
|
-
* The format defined in RFC2616.
|
|
27
|
-
*/
|
|
28
|
-
rfc2616 = "rfc2616"
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* The difference between the DataProperty and this is that the `DataProperty` describes the general shape of
|
|
32
|
-
* the data and `IDataPropertySchema` describes how this property is translated into a specific format
|
|
33
|
-
* (like JSON, Protocol Buffer, XML, etc)
|
|
34
|
-
*/
|
|
35
|
-
export interface IDataPropertySchema<T> {
|
|
36
|
-
/**
|
|
37
|
-
* The default value for the property.
|
|
38
|
-
*/
|
|
39
|
-
default?: T;
|
|
40
|
-
/**
|
|
41
|
-
* Enum values for the property.
|
|
42
|
-
*/
|
|
43
|
-
enum?: T[];
|
|
44
|
-
/**
|
|
45
|
-
* The example value for the property.
|
|
46
|
-
*/
|
|
47
|
-
examples?: T[];
|
|
48
|
-
/**
|
|
49
|
-
* The format of a `number` or `datetime` type.
|
|
50
|
-
*/
|
|
51
|
-
format?: NumberFormat | DateFormat;
|
|
52
|
-
/**
|
|
53
|
-
* Minimum length of the string or a file. Value MUST be equal to or greater than 0.
|
|
54
|
-
*/
|
|
55
|
-
minLength?: number;
|
|
56
|
-
/**
|
|
57
|
-
* The minimum length of the string or a file. Value MUST be equal to or greater than 0.
|
|
58
|
-
*/
|
|
59
|
-
maxLength?: number;
|
|
60
|
-
/**
|
|
61
|
-
* Regular expression that this string MUST match.
|
|
62
|
-
*/
|
|
63
|
-
pattern?: string;
|
|
64
|
-
/**
|
|
65
|
-
* The minimum value.
|
|
66
|
-
*/
|
|
67
|
-
minimum?: number;
|
|
68
|
-
/**
|
|
69
|
-
* The maximum value.
|
|
70
|
-
*/
|
|
71
|
-
maximum?: number;
|
|
72
|
-
/**
|
|
73
|
-
* A numeric instance is valid against "multipleOf" if the result of dividing the instance by this
|
|
74
|
-
* value is an integer.
|
|
75
|
-
*/
|
|
76
|
-
multipleOf?: number;
|
|
77
|
-
/**
|
|
78
|
-
* A list of valid content-type strings for the file. The file type `*\/*` is a valid value.
|
|
79
|
-
*/
|
|
80
|
-
fileTypes?: string[];
|
|
81
|
-
/**
|
|
82
|
-
* Describes XML specific serialization.
|
|
83
|
-
*/
|
|
84
|
-
xml?: {
|
|
85
|
-
/**
|
|
86
|
-
* Whether is property should be represented as an attribute of the parent entity.
|
|
87
|
-
*
|
|
88
|
-
* ```
|
|
89
|
-
* <Person name="John Doe"></Person>
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
attribute?: boolean;
|
|
93
|
-
/**
|
|
94
|
-
* The name of the attribute or a wrapped property to use when serializing the property.
|
|
95
|
-
*
|
|
96
|
-
* ```
|
|
97
|
-
* <Person fullName="John Doe"></Person>
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
name?: string;
|
|
101
|
-
/**
|
|
102
|
-
* When the property is an array (has the `multiple` set to true)
|
|
103
|
-
* then it tells that the list of values should be wrapped with a parent
|
|
104
|
-
* element:
|
|
105
|
-
*
|
|
106
|
-
* ```
|
|
107
|
-
* <Person>
|
|
108
|
-
* <Person fullName="John Doe"></Person>
|
|
109
|
-
* </Person>
|
|
110
|
-
* ```
|
|
111
|
-
*
|
|
112
|
-
* Use this with the combination with `name` to describe the name of the wrapped
|
|
113
|
-
* element
|
|
114
|
-
*
|
|
115
|
-
* ```
|
|
116
|
-
* <people>
|
|
117
|
-
* <Person fullName="John Doe"></Person>
|
|
118
|
-
* </people>
|
|
119
|
-
* ```
|
|
120
|
-
*
|
|
121
|
-
* Note, this is mutually exclusive with `attribute`.
|
|
122
|
-
*/
|
|
123
|
-
wrapped?: boolean;
|
|
124
|
-
};
|
|
125
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export const NumberFormats = [
|
|
2
|
-
'integer', 'float', 'long', 'double', 'int32', 'int64', 'uint32', 'uint64', 'sint32', 'sint64', 'fixed32', 'fixed64',
|
|
3
|
-
'sfixed32', 'sfixed64'
|
|
4
|
-
];
|
|
5
|
-
export var NumberFormatList;
|
|
6
|
-
(function (NumberFormatList) {
|
|
7
|
-
NumberFormatList["integer"] = "integer";
|
|
8
|
-
NumberFormatList["float"] = "float";
|
|
9
|
-
NumberFormatList["int32"] = "int32";
|
|
10
|
-
NumberFormatList["int64"] = "int64";
|
|
11
|
-
NumberFormatList["uint32"] = "uint32";
|
|
12
|
-
NumberFormatList["uint64"] = "uint64";
|
|
13
|
-
NumberFormatList["sint32"] = "sint32";
|
|
14
|
-
NumberFormatList["sint64"] = "sint64";
|
|
15
|
-
NumberFormatList["fixed32"] = "fixed32";
|
|
16
|
-
NumberFormatList["fixed64"] = "fixed64";
|
|
17
|
-
NumberFormatList["sfixed32"] = "sfixed32";
|
|
18
|
-
NumberFormatList["sfixed64"] = "sfixed64";
|
|
19
|
-
NumberFormatList["double"] = "double";
|
|
20
|
-
})(NumberFormatList || (NumberFormatList = {}));
|
|
21
|
-
export const DateFormats = ['rfc3339', 'rfc2616'];
|
|
22
|
-
export var DateFormatList;
|
|
23
|
-
(function (DateFormatList) {
|
|
24
|
-
/**
|
|
25
|
-
* The "date-time" notation of RFC3339
|
|
26
|
-
*/
|
|
27
|
-
DateFormatList["rfc3339"] = "rfc3339";
|
|
28
|
-
/**
|
|
29
|
-
* The format defined in RFC2616.
|
|
30
|
-
*/
|
|
31
|
-
DateFormatList["rfc2616"] = "rfc2616";
|
|
32
|
-
})(DateFormatList || (DateFormatList = {}));
|
|
33
|
-
//# sourceMappingURL=DataPropertySchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DataPropertySchema.js","sourceRoot":"","sources":["../../../../src/models/data/DataPropertySchema.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAmB;IAC3C,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS;IACpH,UAAU,EAAE,UAAU;CACvB,CAAC;AAEF,MAAM,CAAN,IAAY,gBAcX;AAdD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,mCAAe,CAAA;IACf,mCAAe,CAAA;IACf,mCAAe,CAAA;IACf,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;IACnB,uCAAmB,CAAA;IACnB,yCAAqB,CAAA;IACrB,yCAAqB,CAAA;IACrB,qCAAiB,CAAA;AACnB,CAAC,EAdW,gBAAgB,KAAhB,gBAAgB,QAc3B;AAGD,MAAM,CAAC,MAAM,WAAW,GAAiB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAChE,MAAM,CAAN,IAAY,cASX;AATD,WAAY,cAAc;IACxB;;OAEG;IACH,qCAAmB,CAAA;IACnB;;OAEG;IACH,qCAAmB,CAAA;AACrB,CAAC,EATW,cAAc,KAAd,cAAc,QASzB"}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
export type NumberFormat = 'integer' | 'float' | 'long' | 'double' | 'int32' | 'int64' | 'uint32' | 'uint64' |
|
|
2
|
-
'sint32' | 'sint64' | 'fixed32' | 'fixed64' | 'sfixed32' | 'sfixed64';
|
|
3
|
-
export const NumberFormats: NumberFormat[] = [
|
|
4
|
-
'integer', 'float', 'long', 'double', 'int32', 'int64', 'uint32', 'uint64', 'sint32', 'sint64', 'fixed32', 'fixed64',
|
|
5
|
-
'sfixed32', 'sfixed64'
|
|
6
|
-
];
|
|
7
|
-
|
|
8
|
-
export enum NumberFormatList {
|
|
9
|
-
integer = 'integer',
|
|
10
|
-
float = 'float',
|
|
11
|
-
int32 = 'int32',
|
|
12
|
-
int64 = 'int64',
|
|
13
|
-
uint32 = 'uint32',
|
|
14
|
-
uint64 = 'uint64',
|
|
15
|
-
sint32 = 'sint32',
|
|
16
|
-
sint64 = 'sint64',
|
|
17
|
-
fixed32 = 'fixed32',
|
|
18
|
-
fixed64 = 'fixed64',
|
|
19
|
-
sfixed32 = 'sfixed32',
|
|
20
|
-
sfixed64 = 'sfixed64',
|
|
21
|
-
double = 'double',
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type DateFormat = 'rfc3339' | 'rfc2616';
|
|
25
|
-
export const DateFormats: DateFormat[] = ['rfc3339', 'rfc2616'];
|
|
26
|
-
export enum DateFormatList {
|
|
27
|
-
/**
|
|
28
|
-
* The "date-time" notation of RFC3339
|
|
29
|
-
*/
|
|
30
|
-
rfc3339 = 'rfc3339',
|
|
31
|
-
/**
|
|
32
|
-
* The format defined in RFC2616.
|
|
33
|
-
*/
|
|
34
|
-
rfc2616 = 'rfc2616',
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The difference between the DataProperty and this is that the `DataProperty` describes the general shape of
|
|
39
|
-
* the data and `IDataPropertySchema` describes how this property is translated into a specific format
|
|
40
|
-
* (like JSON, Protocol Buffer, XML, etc)
|
|
41
|
-
*/
|
|
42
|
-
export interface IDataPropertySchema<T> {
|
|
43
|
-
// Common
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The default value for the property.
|
|
47
|
-
*/
|
|
48
|
-
default?: T;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Enum values for the property.
|
|
52
|
-
*/
|
|
53
|
-
enum?: T[];
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* The example value for the property.
|
|
57
|
-
*/
|
|
58
|
-
examples?: T[];
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* The format of a `number` or `datetime` type.
|
|
62
|
-
*/
|
|
63
|
-
format?: NumberFormat | DateFormat;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Minimum length of the string or a file. Value MUST be equal to or greater than 0.
|
|
67
|
-
*/
|
|
68
|
-
minLength?: number;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* The minimum length of the string or a file. Value MUST be equal to or greater than 0.
|
|
72
|
-
*/
|
|
73
|
-
maxLength?: number;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// STRING
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Regular expression that this string MUST match.
|
|
80
|
-
*/
|
|
81
|
-
pattern?: string;
|
|
82
|
-
|
|
83
|
-
// NUMBER
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* The minimum value.
|
|
87
|
-
*/
|
|
88
|
-
minimum?: number;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* The maximum value.
|
|
92
|
-
*/
|
|
93
|
-
maximum?: number;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* A numeric instance is valid against "multipleOf" if the result of dividing the instance by this
|
|
97
|
-
* value is an integer.
|
|
98
|
-
*/
|
|
99
|
-
multipleOf?: number;
|
|
100
|
-
|
|
101
|
-
// File
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* A list of valid content-type strings for the file. The file type `*\/*` is a valid value.
|
|
105
|
-
*/
|
|
106
|
-
fileTypes?: string[];
|
|
107
|
-
|
|
108
|
-
// XML serialization
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Describes XML specific serialization.
|
|
112
|
-
*/
|
|
113
|
-
xml?: {
|
|
114
|
-
/**
|
|
115
|
-
* Whether is property should be represented as an attribute of the parent entity.
|
|
116
|
-
*
|
|
117
|
-
* ```
|
|
118
|
-
* <Person name="John Doe"></Person>
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
attribute?: boolean;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* The name of the attribute or a wrapped property to use when serializing the property.
|
|
125
|
-
*
|
|
126
|
-
* ```
|
|
127
|
-
* <Person fullName="John Doe"></Person>
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
name?: string;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* When the property is an array (has the `multiple` set to true)
|
|
134
|
-
* then it tells that the list of values should be wrapped with a parent
|
|
135
|
-
* element:
|
|
136
|
-
*
|
|
137
|
-
* ```
|
|
138
|
-
* <Person>
|
|
139
|
-
* <Person fullName="John Doe"></Person>
|
|
140
|
-
* </Person>
|
|
141
|
-
* ```
|
|
142
|
-
*
|
|
143
|
-
* Use this with the combination with `name` to describe the name of the wrapped
|
|
144
|
-
* element
|
|
145
|
-
*
|
|
146
|
-
* ```
|
|
147
|
-
* <people>
|
|
148
|
-
* <Person fullName="John Doe"></Person>
|
|
149
|
-
* </people>
|
|
150
|
-
* ```
|
|
151
|
-
*
|
|
152
|
-
* Note, this is mutually exclusive with `attribute`.
|
|
153
|
-
*/
|
|
154
|
-
wrapped?: boolean;
|
|
155
|
-
}
|
|
156
|
-
}
|