@api-client/core 0.7.11 → 0.8.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/SECURITY.md +14 -0
- package/build/browser.d.ts +6 -0
- package/build/browser.js +6 -0
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +6 -0
- package/build/index.js +6 -0
- package/build/index.js.map +1 -1
- package/build/src/amf/AmfMixin.d.ts +55 -42
- package/build/src/amf/AmfMixin.js +9 -3
- package/build/src/amf/AmfMixin.js.map +1 -1
- package/build/src/amf/AmfSerializer.d.ts +72 -72
- package/build/src/amf/AmfSerializer.js +9 -4
- package/build/src/amf/AmfSerializer.js.map +1 -1
- package/build/src/amf/AmfShapeGenerator.d.ts +17 -17
- package/build/src/amf/AmfShapeGenerator.js +4 -4
- package/build/src/amf/AmfShapeGenerator.js.map +1 -1
- package/build/src/amf/AmfTypes.d.ts +16 -16
- package/build/src/amf/AmfTypes.js +16 -16
- package/build/src/amf/AmfTypes.js.map +1 -1
- package/build/src/amf/ApiExampleGenerator.d.ts +3 -3
- package/build/src/amf/ApiExampleGenerator.js.map +1 -1
- package/build/src/amf/ApiMonacoSchemaGenerator.d.ts +6 -6
- package/build/src/amf/ApiMonacoSchemaGenerator.js.map +1 -1
- package/build/src/amf/ApiSchemaGenerator.d.ts +2 -2
- package/build/src/amf/ApiSchemaGenerator.js.map +1 -1
- package/build/src/amf/ApiSchemaValues.d.ts +12 -12
- package/build/src/amf/ApiSchemaValues.js.map +1 -1
- package/build/src/amf/Parsing.d.ts +5 -5
- package/build/src/amf/Utils.d.ts +6 -6
- package/build/src/amf/Utils.js.map +1 -1
- package/build/src/amf/data-node/DataNodeBase.d.ts +5 -5
- package/build/src/amf/data-node/DataNodeBase.js.map +1 -1
- package/build/src/amf/data-node/JsonDataNodeGenerator.d.ts +2 -2
- package/build/src/amf/data-node/JsonDataNodeGenerator.js.map +1 -1
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.d.ts +2 -2
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.js.map +1 -1
- package/build/src/amf/data-node/XmlDataNodeGenerator.d.ts +2 -2
- package/build/src/amf/data-node/XmlDataNodeGenerator.js.map +1 -1
- package/build/src/amf/definitions/Amf.d.ts +339 -339
- package/build/src/amf/definitions/Api.d.ts +158 -158
- package/build/src/amf/definitions/Base.d.ts +5 -5
- package/build/src/amf/definitions/Shapes.d.ts +46 -46
- package/build/src/amf/definitions/Shapes.js +11 -11
- package/build/src/amf/definitions/Shapes.js.map +1 -1
- package/build/src/amf/models/AmfDataNode.d.ts +5 -5
- package/build/src/amf/models/AmfDataNode.js +4 -4
- package/build/src/amf/models/AmfDataNode.js.map +1 -1
- package/build/src/amf/shape/ShapeBase.d.ts +13 -13
- package/build/src/amf/shape/ShapeBase.js.map +1 -1
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.d.ts +13 -13
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.js.map +1 -1
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.d.ts +16 -16
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.js +1 -1
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.js.map +1 -1
- package/build/src/events/amf/AmfEvents.d.ts +4 -4
- package/build/src/events/amf/AmfEvents.js.map +1 -1
- package/build/src/models/data/Bindings.d.ts +2 -2
- package/build/src/models/data/DataAssociation.d.ts +4 -4
- package/build/src/models/data/DataAssociation.js.map +1 -1
- package/build/src/models/data/DataEntity.d.ts +2 -2
- package/build/src/models/data/DataProperty.d.ts +2 -2
- package/build/src/runtime/variables/VariablesProcessor.js.map +1 -1
- package/data/models/oas-date.json +1 -1
- package/data/models/oas-types.json +1 -1
- package/data/models/oas-unions.json +1 -1
- package/data/models/raml-date.json +1 -1
- package/data/models/recursive.json +1 -1
- package/data/models/schema-api.json +14 -6
- package/package.json +6 -6
- package/src/amf/AmfMixin.ts +124 -117
- package/src/amf/AmfSerializer.ts +245 -240
- package/src/amf/AmfShapeGenerator.ts +24 -24
- package/src/amf/AmfTypes.ts +16 -16
- package/src/amf/ApiExampleGenerator.ts +4 -4
- package/src/amf/ApiMonacoSchemaGenerator.ts +11 -11
- package/src/amf/ApiSchemaGenerator.ts +3 -3
- package/src/amf/ApiSchemaValues.ts +21 -21
- package/src/amf/Parsing.ts +5 -5
- package/src/amf/Utils.ts +15 -15
- package/src/amf/data-node/DataNodeBase.ts +8 -8
- package/src/amf/data-node/JsonDataNodeGenerator.ts +2 -2
- package/src/amf/data-node/UrlEncodedDataNodeGenerator.ts +2 -2
- package/src/amf/data-node/XmlDataNodeGenerator.ts +2 -2
- package/src/amf/definitions/Amf.ts +315 -314
- package/src/amf/definitions/Api.ts +158 -157
- package/src/amf/definitions/Base.ts +5 -5
- package/src/amf/definitions/Shapes.ts +60 -60
- package/src/amf/models/AmfDataNode.ts +17 -17
- package/src/amf/shape/ShapeBase.ts +16 -16
- package/src/amf/shape/ShapeJsonSchemaGenerator.ts +27 -27
- package/src/amf/shape/ShapeXmlSchemaGenerator.ts +44 -44
- package/src/events/amf/AmfEvents.ts +7 -7
- package/src/models/data/Bindings.ts +2 -2
- package/src/models/data/DataAssociation.ts +4 -4
- package/src/models/data/DataEntity.ts +2 -2
- package/src/models/data/DataProperty.ts +2 -2
- package/src/runtime/variables/VariablesProcessor.ts +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { IAmfAnyTypes, IAmfArrayTypes, IAmfFileTypes, IAmfNodeTypes, IAmfPropertyTypes, IAmfRecursiveTypes, IAmfScalarTypes, IAmfTupleTypes, IAmfUnionTypes, IAmfXmlSerializationTypes } from '../AmfTypes.js';
|
|
2
|
+
import { IApiDocumentation, IApiDocumentSourceMaps } from './Api.js';
|
|
3
|
+
import { IApiDomainProperty } from './Base.js';
|
|
4
4
|
|
|
5
|
-
export type IShapeUnion =
|
|
5
|
+
export type IShapeUnion = IApiScalarShape | IApiNodeShape | IApiUnionShape | IApiFileShape | IApiSchemaShape | IApiAnyShape | IApiArrayShape | IApiTupleShape | IApiRecursiveShape;
|
|
6
6
|
|
|
7
|
-
export interface
|
|
7
|
+
export interface IApiAssociationShape {
|
|
8
8
|
/**
|
|
9
9
|
* This is custom property not available in AMF and used with data associations.
|
|
10
10
|
*
|
|
@@ -53,7 +53,7 @@ export interface IAssociationShape {
|
|
|
53
53
|
unionType?: 'allOf' | 'anyOf' | 'oneOf' | 'not';
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export interface
|
|
56
|
+
export interface IApiDataExample extends IApiDomainProperty {
|
|
57
57
|
name?: string;
|
|
58
58
|
displayName?: string;
|
|
59
59
|
description?: string;
|
|
@@ -61,23 +61,23 @@ export interface IDataExample extends IDomainProperty {
|
|
|
61
61
|
* This is the "raw" property of AMF
|
|
62
62
|
*/
|
|
63
63
|
value?: string;
|
|
64
|
-
structuredValue?:
|
|
64
|
+
structuredValue?: IApiDataNodeUnion;
|
|
65
65
|
strict: boolean;
|
|
66
66
|
mediaType?: string;
|
|
67
67
|
location?: string;
|
|
68
|
-
sourceMaps?:
|
|
68
|
+
sourceMaps?: IApiDocumentSourceMaps;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export function xmlSerializer(id: string):
|
|
71
|
+
export function xmlSerializer(id: string): IApiXmlSerializer {
|
|
72
72
|
return {
|
|
73
73
|
id: `xml-serializer-${id}`,
|
|
74
|
-
types:
|
|
74
|
+
types: IAmfXmlSerializationTypes,
|
|
75
75
|
customDomainProperties: [],
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export function shape(id: string):
|
|
80
|
-
const result:
|
|
79
|
+
export function shape(id: string): IApiShape {
|
|
80
|
+
const result: IApiShape = {
|
|
81
81
|
id,
|
|
82
82
|
types: [],
|
|
83
83
|
values: [],
|
|
@@ -90,19 +90,19 @@ export function shape(id: string): IShape {
|
|
|
90
90
|
return result;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
export function anyShape(id: string):
|
|
94
|
-
const result:
|
|
93
|
+
export function anyShape(id: string): IApiAnyShape {
|
|
94
|
+
const result: IApiAnyShape = {
|
|
95
95
|
...shape(id),
|
|
96
|
-
types:
|
|
96
|
+
types: IAmfAnyTypes,
|
|
97
97
|
examples: [],
|
|
98
98
|
xmlSerialization: xmlSerializer(id),
|
|
99
99
|
};
|
|
100
100
|
return result;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
export function nodeShape(id: string):
|
|
103
|
+
export function nodeShape(id: string): IApiNodeShape {
|
|
104
104
|
const result = anyShape(id);
|
|
105
|
-
result.types =
|
|
105
|
+
result.types = IAmfNodeTypes;
|
|
106
106
|
result.id = `node-shape-${id}`;
|
|
107
107
|
return {
|
|
108
108
|
...result,
|
|
@@ -113,62 +113,62 @@ export function nodeShape(id: string): INodeShape {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
export function scalarShape(id: string):
|
|
116
|
+
export function scalarShape(id: string): IApiScalarShape {
|
|
117
117
|
const result = anyShape(id);
|
|
118
118
|
result.id = `scalar-shape-${id}`;
|
|
119
|
-
result.types =
|
|
119
|
+
result.types = IAmfScalarTypes;
|
|
120
120
|
return result;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
export function unionShape(id: string):
|
|
123
|
+
export function unionShape(id: string): IApiUnionShape {
|
|
124
124
|
const result = anyShape(id);
|
|
125
125
|
result.id = `union-shape-${id}`;
|
|
126
|
-
result.types =
|
|
126
|
+
result.types = IAmfUnionTypes;
|
|
127
127
|
return { ...result, anyOf: [] };
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
export function fileShape(id: string):
|
|
130
|
+
export function fileShape(id: string): IApiFileShape {
|
|
131
131
|
const result = anyShape(id);
|
|
132
132
|
result.id = `file-shape-${id}`;
|
|
133
|
-
result.types =
|
|
133
|
+
result.types = IAmfFileTypes;
|
|
134
134
|
return result;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
export function arrayShape(id: string):
|
|
137
|
+
export function arrayShape(id: string): IApiArrayShape {
|
|
138
138
|
const result = anyShape(id);
|
|
139
139
|
result.id = `array-shape-${id}`;
|
|
140
|
-
result.types =
|
|
140
|
+
result.types = IAmfArrayTypes;
|
|
141
141
|
return result;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
export function tupleShape(id: string):
|
|
144
|
+
export function tupleShape(id: string): IApiTupleShape {
|
|
145
145
|
const result = anyShape(id);
|
|
146
146
|
result.id = `tuple-shape-${id}`;
|
|
147
|
-
result.types =
|
|
147
|
+
result.types = IAmfTupleTypes;
|
|
148
148
|
return { ...result, items: [] };
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
export function propertyShape(id: string):
|
|
151
|
+
export function propertyShape(id: string): IApiPropertyShape {
|
|
152
152
|
const result = anyShape(id);
|
|
153
|
-
result.types =
|
|
153
|
+
result.types = IAmfPropertyTypes;
|
|
154
154
|
return result;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
export function recursiveShape(id: string, fixedId?: string):
|
|
158
|
-
const result:
|
|
157
|
+
export function recursiveShape(id: string, fixedId?: string): IApiRecursiveShape {
|
|
158
|
+
const result: IApiRecursiveShape = {
|
|
159
159
|
...shape(id),
|
|
160
160
|
id: `recursive-${id}`,
|
|
161
|
-
types:
|
|
161
|
+
types: IAmfRecursiveTypes,
|
|
162
162
|
fixPoint: fixedId || '',
|
|
163
163
|
};
|
|
164
164
|
return result;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
export interface
|
|
167
|
+
export interface IApiShape extends IApiDomainProperty {
|
|
168
168
|
/**
|
|
169
169
|
* Enum values for this shape.
|
|
170
170
|
*/
|
|
171
|
-
values:
|
|
171
|
+
values: IApiDataNodeUnion[];
|
|
172
172
|
/**
|
|
173
173
|
* The list of shapes that this shape inherits from
|
|
174
174
|
*/
|
|
@@ -204,7 +204,7 @@ export interface IShape extends IDomainProperty {
|
|
|
204
204
|
/**
|
|
205
205
|
* The description of the default value of the shape.
|
|
206
206
|
*/
|
|
207
|
-
defaultValue?:
|
|
207
|
+
defaultValue?: IApiDataNodeUnion;
|
|
208
208
|
/**
|
|
209
209
|
* Whether the shape is deprecated.
|
|
210
210
|
*/
|
|
@@ -222,13 +222,13 @@ export interface IShape extends IDomainProperty {
|
|
|
222
222
|
* A label that appeared on a link.
|
|
223
223
|
*/
|
|
224
224
|
linkLabel?: string;
|
|
225
|
-
sourceMaps?:
|
|
225
|
+
sourceMaps?: IApiDocumentSourceMaps;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
/**
|
|
229
229
|
* A property of an API operation.
|
|
230
230
|
*/
|
|
231
|
-
export interface
|
|
231
|
+
export interface IApiPropertyShape<T = IShapeUnion> extends IApiShape {
|
|
232
232
|
/**
|
|
233
233
|
* The path of the property. Essentially, it is link generated by the AMF library
|
|
234
234
|
* where the fragment part is the name of the property.
|
|
@@ -245,22 +245,22 @@ export interface IPropertyShape<T = IShapeUnion> extends IShape {
|
|
|
245
245
|
maxCount?: number;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
export interface
|
|
249
|
-
documentation?:
|
|
248
|
+
export interface IApiAnyShape extends IApiShape {
|
|
249
|
+
documentation?: IApiDocumentation;
|
|
250
250
|
/**
|
|
251
251
|
* Description of how the shape should be serialized as XML.
|
|
252
252
|
*/
|
|
253
|
-
xmlSerialization:
|
|
253
|
+
xmlSerialization: IApiXmlSerializer;
|
|
254
254
|
/**
|
|
255
255
|
* Examples defined for the shape.
|
|
256
256
|
*/
|
|
257
|
-
examples:
|
|
257
|
+
examples: IApiDataExample[];
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
/**
|
|
261
261
|
* Describes an object shape.
|
|
262
262
|
*/
|
|
263
|
-
export interface
|
|
263
|
+
export interface IApiNodeShape extends IApiAnyShape {
|
|
264
264
|
minProperties?: number;
|
|
265
265
|
maxProperties?: number;
|
|
266
266
|
closed?: boolean;
|
|
@@ -268,11 +268,11 @@ export interface INodeShape extends IAnyShape {
|
|
|
268
268
|
customShapePropertyDefinitions: string[];
|
|
269
269
|
discriminator?: string;
|
|
270
270
|
discriminatorValue?: string;
|
|
271
|
-
properties:
|
|
271
|
+
properties: IApiPropertyShape[];
|
|
272
272
|
dependencies: string[];
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
export interface
|
|
275
|
+
export interface IApiXmlSerializer extends IApiDomainProperty {
|
|
276
276
|
/**
|
|
277
277
|
* Whether this property should be represented as an attribute of the parent shape.
|
|
278
278
|
*
|
|
@@ -337,10 +337,10 @@ export interface IXmlSerializer extends IDomainProperty {
|
|
|
337
337
|
* ```
|
|
338
338
|
*/
|
|
339
339
|
prefix?: string;
|
|
340
|
-
sourceMaps?:
|
|
340
|
+
sourceMaps?: IApiDocumentSourceMaps;
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
-
export interface
|
|
343
|
+
export interface IApiScalarShape extends IApiAnyShape {
|
|
344
344
|
dataType?: string;
|
|
345
345
|
pattern?: string;
|
|
346
346
|
minLength?: number;
|
|
@@ -353,7 +353,7 @@ export interface IScalarShape extends IAnyShape {
|
|
|
353
353
|
multipleOf?: number;
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
export interface
|
|
356
|
+
export interface IApiFileShape extends IApiAnyShape {
|
|
357
357
|
fileTypes?: string[];
|
|
358
358
|
pattern?: string;
|
|
359
359
|
minLength?: number;
|
|
@@ -366,49 +366,49 @@ export interface IFileShape extends IAnyShape {
|
|
|
366
366
|
multipleOf?: number;
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
-
export interface
|
|
369
|
+
export interface IApiSchemaShape extends IApiAnyShape {
|
|
370
370
|
mediaType?: string;
|
|
371
371
|
raw?: string;
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
-
export interface
|
|
374
|
+
export interface IApiUnionShape extends IApiAnyShape {
|
|
375
375
|
anyOf: IShapeUnion[];
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
-
export interface
|
|
378
|
+
export interface IApiDataArrangeShape extends IApiAnyShape {
|
|
379
379
|
minItems?: number;
|
|
380
380
|
maxItems?: number;
|
|
381
381
|
uniqueItems?: boolean;
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
-
export interface
|
|
384
|
+
export interface IApiArrayShape<T = IShapeUnion> extends IApiDataArrangeShape {
|
|
385
385
|
items?: T;
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
-
export interface
|
|
388
|
+
export interface IApiTupleShape<T = IShapeUnion> extends IApiDataArrangeShape {
|
|
389
389
|
items: T[];
|
|
390
390
|
additionalItems?: boolean;
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
-
export interface
|
|
393
|
+
export interface IApiRecursiveShape extends IApiShape {
|
|
394
394
|
fixPoint: string;
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
-
export interface
|
|
397
|
+
export interface IApiDataNode extends IApiDomainProperty {
|
|
398
398
|
name?: string;
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
-
export interface
|
|
402
|
-
properties: { [key: string]:
|
|
401
|
+
export interface IApiObjectNode extends IApiDataNode {
|
|
402
|
+
properties: { [key: string]: IApiDataNodeUnion };
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
-
export interface
|
|
405
|
+
export interface IApiScalarNode extends IApiDataNode {
|
|
406
406
|
value?: string;
|
|
407
407
|
dataType?: string;
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
-
export interface
|
|
411
|
-
members:
|
|
410
|
+
export interface IApiArrayNode extends IApiDataNode {
|
|
411
|
+
members: IApiDataNodeUnion[];
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
-
export type
|
|
414
|
+
export type IApiDataNodeUnion = IApiDataNode | IApiObjectNode | IApiScalarNode | IApiArrayNode;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import v4 from '../../lib/uuid.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { IAmfArrayNodeTypes, IAmfObjectNodeTypes, IAmfScalarNodeTypes } from '../AmfTypes.js';
|
|
3
|
+
import { IApiCustomDomainProperty } from '../definitions/Base.js';
|
|
4
4
|
import { AmfNamespace } from '../definitions/Namespace.js';
|
|
5
|
-
import {
|
|
5
|
+
import { IApiArrayNode, IApiDataNode, IApiDataNodeUnion, IApiObjectNode, IApiScalarNode } from '../definitions/Shapes.js';
|
|
6
6
|
|
|
7
7
|
export type IDataNodeInit = 'scalar' | 'object' | 'array';
|
|
8
8
|
|
|
@@ -43,7 +43,7 @@ export class AmfDataNode {
|
|
|
43
43
|
*/
|
|
44
44
|
members?: AmfDataNode[];
|
|
45
45
|
|
|
46
|
-
customDomainProperties:
|
|
46
|
+
customDomainProperties: IApiCustomDomainProperty[] = [];
|
|
47
47
|
|
|
48
48
|
static scalar(value: string, type: string): AmfDataNode {
|
|
49
49
|
const result = new AmfDataNode('scalar');
|
|
@@ -52,14 +52,14 @@ export class AmfDataNode {
|
|
|
52
52
|
return result;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
constructor(init:
|
|
55
|
+
constructor(init: IApiDataNodeUnion | IDataNodeInit) {
|
|
56
56
|
if (typeof init === 'string') {
|
|
57
57
|
if (init === 'scalar') {
|
|
58
|
-
this.types =
|
|
58
|
+
this.types = IAmfScalarNodeTypes;
|
|
59
59
|
} else if (init === 'array') {
|
|
60
|
-
this.types =
|
|
60
|
+
this.types = IAmfArrayNodeTypes;
|
|
61
61
|
} else if (init === 'object') {
|
|
62
|
-
this.types =
|
|
62
|
+
this.types = IAmfObjectNodeTypes;
|
|
63
63
|
} else {
|
|
64
64
|
throw new Error(`Invalid data node init option: ${init}`);
|
|
65
65
|
}
|
|
@@ -68,24 +68,24 @@ export class AmfDataNode {
|
|
|
68
68
|
if (!init) {
|
|
69
69
|
throw new Error(`Expected an initialization option.`);
|
|
70
70
|
}
|
|
71
|
-
const union = init as
|
|
71
|
+
const union = init as IApiDataNodeUnion;
|
|
72
72
|
const { id, types, customDomainProperties } = union;
|
|
73
73
|
this.id = id;
|
|
74
74
|
this.types = types;
|
|
75
75
|
this.customDomainProperties = customDomainProperties;
|
|
76
76
|
if (types.includes(AmfNamespace.aml.vocabularies.data.Scalar)) {
|
|
77
|
-
const typed = union as
|
|
77
|
+
const typed = union as IApiScalarNode;
|
|
78
78
|
this.value = typed.value;
|
|
79
79
|
this.dataType = typed.dataType;
|
|
80
80
|
} else if (types.includes(AmfNamespace.aml.vocabularies.data.Object)) {
|
|
81
|
-
const typed = union as
|
|
81
|
+
const typed = union as IApiObjectNode;
|
|
82
82
|
this.properties = {};
|
|
83
83
|
Object.keys(typed.properties).forEach((key) => {
|
|
84
84
|
const instance = new AmfDataNode(typed.properties[key]);
|
|
85
85
|
this.properties![key] = instance;
|
|
86
86
|
});
|
|
87
87
|
} else if (types.includes(AmfNamespace.aml.vocabularies.data.Array)) {
|
|
88
|
-
const typed = union as
|
|
88
|
+
const typed = union as IApiArrayNode;
|
|
89
89
|
this.members = [];
|
|
90
90
|
if (Array.isArray(typed.members)) {
|
|
91
91
|
typed.members.forEach((member) => {
|
|
@@ -96,9 +96,9 @@ export class AmfDataNode {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
toJSON():
|
|
99
|
+
toJSON(): IApiDataNodeUnion {
|
|
100
100
|
const { id, customDomainProperties, types, name } = this;
|
|
101
|
-
const result:
|
|
101
|
+
const result: IApiDataNode = {
|
|
102
102
|
id,
|
|
103
103
|
types,
|
|
104
104
|
customDomainProperties,
|
|
@@ -108,11 +108,11 @@ export class AmfDataNode {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
if (types.includes(AmfNamespace.aml.vocabularies.data.Scalar)) {
|
|
111
|
-
const typed = result as
|
|
111
|
+
const typed = result as IApiScalarNode;
|
|
112
112
|
typed.dataType = this.dataType;
|
|
113
113
|
typed.value = this.value;
|
|
114
114
|
} else if (types.includes(AmfNamespace.aml.vocabularies.data.Object)) {
|
|
115
|
-
const typed = result as
|
|
115
|
+
const typed = result as IApiObjectNode;
|
|
116
116
|
typed.properties = {};
|
|
117
117
|
if (this.properties) {
|
|
118
118
|
Object.keys(this.properties).forEach((key) => {
|
|
@@ -120,7 +120,7 @@ export class AmfDataNode {
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
} else if (types.includes(AmfNamespace.aml.vocabularies.data.Array)) {
|
|
123
|
-
const typed = result as
|
|
123
|
+
const typed = result as IApiArrayNode;
|
|
124
124
|
typed.members = [];
|
|
125
125
|
if (this.members) {
|
|
126
126
|
this.members.forEach((member) => {
|
|
@@ -2,7 +2,7 @@ import { Time } from '@pawel-up/data-mock';
|
|
|
2
2
|
import { AmfNamespace as ns } from "../definitions/Namespace.js";
|
|
3
3
|
import { ApiSchemaValues } from '../ApiSchemaValues.js';
|
|
4
4
|
import { JsonDataNodeGenerator } from '../data-node/JsonDataNodeGenerator.js';
|
|
5
|
-
import {
|
|
5
|
+
import { IApiAnyShape, IApiArrayShape, IApiDataExample, IApiFileShape, IApiNodeShape, IApiPropertyShape, IApiScalarNode, IApiScalarShape, IApiSchemaShape, IShapeUnion, IApiTupleShape, IApiUnionShape } from '../definitions/Shapes.js';
|
|
6
6
|
|
|
7
7
|
export interface IShapeRenderOptions {
|
|
8
8
|
/**
|
|
@@ -42,7 +42,7 @@ export abstract class ShapeBase {
|
|
|
42
42
|
this.opts = Object.freeze({ ...opts });
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
protected _scalarValue(schema:
|
|
45
|
+
protected _scalarValue(schema: IApiScalarShape): string | number | boolean {
|
|
46
46
|
const { defaultValue, examples, values, inherits, dataType } = schema;
|
|
47
47
|
// check examples
|
|
48
48
|
if (this.opts.renderExamples && examples && examples.length) {
|
|
@@ -62,7 +62,7 @@ export abstract class ShapeBase {
|
|
|
62
62
|
}
|
|
63
63
|
// check enum values
|
|
64
64
|
if (values && values.length) {
|
|
65
|
-
const typed = values[0] as
|
|
65
|
+
const typed = values[0] as IApiScalarNode;
|
|
66
66
|
if (typed.value !== undefined) {
|
|
67
67
|
return ApiSchemaValues.readTypedValue(typed.value, dataType);
|
|
68
68
|
}
|
|
@@ -70,7 +70,7 @@ export abstract class ShapeBase {
|
|
|
70
70
|
// check parents
|
|
71
71
|
if (Array.isArray(inherits) && inherits.length) {
|
|
72
72
|
for (let i = 0, len = inherits.length; i < len; i += 1) {
|
|
73
|
-
const result = this._scalarValue(inherits[i] as
|
|
73
|
+
const result = this._scalarValue(inherits[i] as IApiScalarShape);
|
|
74
74
|
if (result !== undefined) {
|
|
75
75
|
return result;
|
|
76
76
|
}
|
|
@@ -100,7 +100,7 @@ export abstract class ShapeBase {
|
|
|
100
100
|
if (i.types.includes(ns.aml.vocabularies.shapes.NilShape)) {
|
|
101
101
|
hasNil = true;
|
|
102
102
|
} else if (i.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {
|
|
103
|
-
const scalar = i as
|
|
103
|
+
const scalar = i as IApiScalarShape;
|
|
104
104
|
if (scalar.dataType === ns.w3.xmlSchema.nil) {
|
|
105
105
|
hasNil = true;
|
|
106
106
|
} else {
|
|
@@ -139,25 +139,25 @@ export abstract class ShapeBase {
|
|
|
139
139
|
* @param {ApiExample} example The example to turn into a JS object
|
|
140
140
|
* @returns {any}
|
|
141
141
|
*/
|
|
142
|
-
protected abstract _exampleToObject(example?:
|
|
142
|
+
protected abstract _exampleToObject(example?: IApiDataExample): any;
|
|
143
143
|
|
|
144
|
-
protected abstract _scalarShapeObject(schema:
|
|
144
|
+
protected abstract _scalarShapeObject(schema: IApiScalarShape): any;
|
|
145
145
|
|
|
146
|
-
protected abstract _nilShapeObject(schema:
|
|
146
|
+
protected abstract _nilShapeObject(schema: IApiScalarShape): any;
|
|
147
147
|
|
|
148
|
-
protected abstract _nodeShapeObject(schema:
|
|
148
|
+
protected abstract _nodeShapeObject(schema: IApiNodeShape): any;
|
|
149
149
|
|
|
150
|
-
protected abstract _unionShapeObject(schema:
|
|
150
|
+
protected abstract _unionShapeObject(schema: IApiUnionShape): any;
|
|
151
151
|
|
|
152
|
-
protected abstract _fileShapeObject(schema?:
|
|
152
|
+
protected abstract _fileShapeObject(schema?: IApiFileShape): any;
|
|
153
153
|
|
|
154
|
-
protected abstract _schemaShapeObject(schema?:
|
|
154
|
+
protected abstract _schemaShapeObject(schema?: IApiSchemaShape): any;
|
|
155
155
|
|
|
156
|
-
protected abstract _arrayShapeObject(schema:
|
|
156
|
+
protected abstract _arrayShapeObject(schema: IApiArrayShape): any;
|
|
157
157
|
|
|
158
|
-
protected abstract _tupleShapeObject(schema?:
|
|
158
|
+
protected abstract _tupleShapeObject(schema?: IApiTupleShape): any;
|
|
159
159
|
|
|
160
|
-
protected abstract _anyShapeObject(schema:
|
|
160
|
+
protected abstract _anyShapeObject(schema: IApiAnyShape): any;
|
|
161
161
|
|
|
162
|
-
protected abstract _propertyShapeObject(schema:
|
|
162
|
+
protected abstract _propertyShapeObject(schema: IApiPropertyShape): any;
|
|
163
163
|
}
|