@api-client/core 0.6.13 → 0.6.16
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/Thing.d.ts +17 -0
- package/build/src/models/Thing.js +19 -1
- package/build/src/models/Thing.js.map +1 -1
- 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 +76 -4
- package/build/src/models/data/DataEntity.js +136 -9
- 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 +6 -0
- package/build/src/models/data/DataNamespace.js +11 -1
- package/build/src/models/data/DataNamespace.js.map +1 -1
- package/build/src/models/data/DataProperty.d.ts +131 -36
- package/build/src/models/data/DataProperty.js +200 -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/Thing.ts +25 -1
- 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 +170 -13
- package/src/models/data/DataFile.ts +3 -0
- package/src/models/data/DataModel.ts +1 -1
- package/src/models/data/DataNamespace.ts +16 -1
- package/src/models/data/DataProperty.ts +250 -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
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { ExampleTypes, modelTypeToAmfDataType } from "./AmfTypes.js";
|
|
2
|
+
import { AmfNamespace } from "./definitions/Namespace.js";
|
|
3
|
+
import { anyShape, arrayShape, fileShape, nodeShape, propertyShape, recursiveShape, scalarShape, unionShape } from "./definitions/Shapes.js";
|
|
4
|
+
import { AmfDataNode } from "./models/AmfDataNode.js";
|
|
5
|
+
import v4 from '../lib/uuid.js';
|
|
6
|
+
/**
|
|
7
|
+
* Serializes Data shapes (DataEntity, DataProperty, DataAssociation) to AMF-related shapes.
|
|
8
|
+
*/
|
|
9
|
+
export class AmfShapeGenerator {
|
|
10
|
+
/**
|
|
11
|
+
* Serializes the Entity to the AMF node shape.
|
|
12
|
+
*
|
|
13
|
+
* @param input The Property to serialize.
|
|
14
|
+
* @param generatedEntities The list keys of already generated entities. This prohibits recursive shape generation.
|
|
15
|
+
*/
|
|
16
|
+
entity(input, generatedEntities = []) {
|
|
17
|
+
// const adapted = input.readAdapted();
|
|
18
|
+
if (generatedEntities.includes(input.key)) {
|
|
19
|
+
// create a recursive shape.
|
|
20
|
+
return this._recursiveShape(input);
|
|
21
|
+
}
|
|
22
|
+
generatedEntities.push(input.key);
|
|
23
|
+
const result = nodeShape(input.key);
|
|
24
|
+
result.id = input.key;
|
|
25
|
+
this._updateBaseProperties(input, result);
|
|
26
|
+
result.properties = [];
|
|
27
|
+
input.properties.forEach((item) => {
|
|
28
|
+
// TODO: find adapted property in the adapted schema
|
|
29
|
+
// and check whether the property is disabled.
|
|
30
|
+
// we check whether the property is hidden.
|
|
31
|
+
// This is not happening when calling the `property()` because this method
|
|
32
|
+
// always returns the AMF shape.
|
|
33
|
+
const adapted = item.readAdapted();
|
|
34
|
+
if (adapted && adapted.hidden) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const shape = this.property(item);
|
|
38
|
+
result.properties.push(shape);
|
|
39
|
+
});
|
|
40
|
+
input.associations.forEach((assoc) => {
|
|
41
|
+
const prop = this.associationProperty(assoc, generatedEntities);
|
|
42
|
+
result.properties.push(prop);
|
|
43
|
+
});
|
|
44
|
+
input.getComputedParents().forEach((parent) => {
|
|
45
|
+
const shape = this.entity(parent, generatedEntities);
|
|
46
|
+
result.inherits.push(shape);
|
|
47
|
+
});
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Serializes an Entity Property to the AMF property shape.
|
|
52
|
+
*
|
|
53
|
+
* @param input The Property to serialize.
|
|
54
|
+
*/
|
|
55
|
+
property(input) {
|
|
56
|
+
const { required, key } = input;
|
|
57
|
+
const result = propertyShape(key);
|
|
58
|
+
result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`;
|
|
59
|
+
if (required) {
|
|
60
|
+
result.minCount = 1;
|
|
61
|
+
}
|
|
62
|
+
result.range = this._readPropertyRange(input);
|
|
63
|
+
// for example, Example generator needs to know the name of the property
|
|
64
|
+
// as it does not look into the "range" object.
|
|
65
|
+
this._updateBaseProperties(input, result);
|
|
66
|
+
// sync the name of the property shape with the range, in case it was changed by the bindings
|
|
67
|
+
if (result.range.name) {
|
|
68
|
+
result.name = result.range.name;
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Serializes an Entity property to the AMF property shape with association targets as defined in the schema configuration.
|
|
74
|
+
*
|
|
75
|
+
* @param input The Property to serialize.
|
|
76
|
+
*/
|
|
77
|
+
associationProperty(input, generatedEntities = []) {
|
|
78
|
+
const { required, key } = input;
|
|
79
|
+
const result = propertyShape(key);
|
|
80
|
+
result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`;
|
|
81
|
+
if (required) {
|
|
82
|
+
result.minCount = 1;
|
|
83
|
+
}
|
|
84
|
+
result.range = this.associationShape(input, generatedEntities);
|
|
85
|
+
this._updateBaseProperties(input, result);
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Generates a shape for an association. Most likely you want to use the `associationProperty()` method instead.
|
|
90
|
+
*
|
|
91
|
+
* @param input The data association instance.
|
|
92
|
+
* @returns The range value for the PropertyShape.
|
|
93
|
+
*/
|
|
94
|
+
associationShape(input, generatedEntities = []) {
|
|
95
|
+
const adapted = input.readAdapted();
|
|
96
|
+
let schema = adapted && adapted.schema;
|
|
97
|
+
if (schema && schema.linked) {
|
|
98
|
+
// This is a link to the schema. In an API that would be the id
|
|
99
|
+
// of a resource to request the data from.
|
|
100
|
+
const range = scalarShape(input.key);
|
|
101
|
+
range.id = `link-${input.key}`,
|
|
102
|
+
range.dataType = modelTypeToAmfDataType('string');
|
|
103
|
+
return range;
|
|
104
|
+
}
|
|
105
|
+
const items = this.associationUnion(input, generatedEntities);
|
|
106
|
+
if (!items) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const unionType = schema && schema.unionType || 'anyOf';
|
|
110
|
+
if (Array.isArray(items)) {
|
|
111
|
+
const range = unionShape(input.key);
|
|
112
|
+
this._updateBaseProperties(input, range);
|
|
113
|
+
range.anyOf = [];
|
|
114
|
+
if (unionType === 'anyOf') {
|
|
115
|
+
range.anyOf = items;
|
|
116
|
+
}
|
|
117
|
+
else if (unionType === 'allOf') {
|
|
118
|
+
range.and = items;
|
|
119
|
+
}
|
|
120
|
+
else if (unionType === 'oneOf') {
|
|
121
|
+
range.xone = items;
|
|
122
|
+
}
|
|
123
|
+
else { // not.
|
|
124
|
+
range.not = items[0]; // ?
|
|
125
|
+
}
|
|
126
|
+
if (input.multiple) {
|
|
127
|
+
return this.refactorShapeToArray(input.key, range);
|
|
128
|
+
}
|
|
129
|
+
return range;
|
|
130
|
+
}
|
|
131
|
+
if (unionType === 'not') {
|
|
132
|
+
const wrapper = anyShape(input.key);
|
|
133
|
+
wrapper.id = `not-shape-${input.key}`;
|
|
134
|
+
wrapper.not = items;
|
|
135
|
+
return wrapper;
|
|
136
|
+
}
|
|
137
|
+
if (input.multiple) {
|
|
138
|
+
return this.refactorShapeToArray(input.key, items);
|
|
139
|
+
}
|
|
140
|
+
return items;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Generates a shape list for an union. Most likely you want to use the `associationProperty()` method instead.
|
|
144
|
+
*
|
|
145
|
+
* @param input The data association instance.
|
|
146
|
+
* @returns The range value for the PropertyShape.
|
|
147
|
+
*/
|
|
148
|
+
associationUnion(input, generatedEntities = []) {
|
|
149
|
+
const targets = input.getTargets().map(i => this.entity(i, generatedEntities));
|
|
150
|
+
if (!targets.length) {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
if (targets.length > 1) {
|
|
154
|
+
return targets;
|
|
155
|
+
}
|
|
156
|
+
return targets[0];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The DataProperty may have both the `schema` and the `bindings`. For AMF shape we read `schema` for
|
|
160
|
+
* default value, examples, and enum values. We also look for the `web` bindings for more detailed definition of a shape.
|
|
161
|
+
*
|
|
162
|
+
* @param input
|
|
163
|
+
* @returns
|
|
164
|
+
*/
|
|
165
|
+
_readPropertyRange(input) {
|
|
166
|
+
const adapted = input.readAdapted();
|
|
167
|
+
let bindings;
|
|
168
|
+
let schema;
|
|
169
|
+
if (adapted) {
|
|
170
|
+
if (adapted.schema) {
|
|
171
|
+
schema = adapted.schema;
|
|
172
|
+
}
|
|
173
|
+
const findResult = adapted.bindings.find(b => b.type === 'web');
|
|
174
|
+
if (findResult) {
|
|
175
|
+
bindings = findResult.schema;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return this._createAmfSchema(input, schema, bindings);
|
|
179
|
+
}
|
|
180
|
+
_createAmfSchema(input, schema, bindings) {
|
|
181
|
+
const { multiple, type } = input;
|
|
182
|
+
if (multiple) {
|
|
183
|
+
return this._generateArrayShape(input, schema, bindings);
|
|
184
|
+
}
|
|
185
|
+
if (type === 'binary' && !(bindings && bindings.format === 'binary')) {
|
|
186
|
+
return this._generateFileShape(input, schema, bindings);
|
|
187
|
+
}
|
|
188
|
+
return this._generateScalarShape(input, schema, bindings);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Normally this would be part of generating a scalar schema but the the property is an array this
|
|
192
|
+
* is generated on the array and not on the range.
|
|
193
|
+
*
|
|
194
|
+
* @param result The scalar or array shape.
|
|
195
|
+
* @param schema The adapted property schema
|
|
196
|
+
* @param type The data type of the parent property as set on the `range`
|
|
197
|
+
* @param isArray Whether the DataProperty is multiple
|
|
198
|
+
*/
|
|
199
|
+
_setShapeSchema(result, schema, type, isArray) {
|
|
200
|
+
if (schema.defaultValue) {
|
|
201
|
+
const dt = AmfDataNode.scalar(schema.defaultValue, type);
|
|
202
|
+
result.defaultValue = dt.toJSON();
|
|
203
|
+
}
|
|
204
|
+
if (Array.isArray(schema.enum)) {
|
|
205
|
+
result.values = schema.enum.map(i => AmfDataNode.scalar(i, type).toJSON());
|
|
206
|
+
}
|
|
207
|
+
if (Array.isArray(schema.examples)) {
|
|
208
|
+
if (isArray) {
|
|
209
|
+
result.examples = this._generateArrayExamples(schema.examples, type);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
result.examples = this._generateExamples(schema.examples, type);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
_generateArrayShape(input, schema, bindings) {
|
|
217
|
+
const result = arrayShape(input.key);
|
|
218
|
+
const { type } = input;
|
|
219
|
+
if (type === 'binary') {
|
|
220
|
+
// we do not pass schema to the range generator as we set schema's properties on the array shape.
|
|
221
|
+
result.items = this._generateFileShape(input, undefined, bindings);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
result.items = this._generateScalarShape(input, undefined, bindings);
|
|
225
|
+
}
|
|
226
|
+
if (schema) {
|
|
227
|
+
const type = result.items.dataType;
|
|
228
|
+
this._setShapeSchema(result, schema, type, input.multiple);
|
|
229
|
+
}
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
232
|
+
_generateScalarShape(input, schema, bindings) {
|
|
233
|
+
const result = scalarShape(input.key);
|
|
234
|
+
this._updateBaseProperties(input, result);
|
|
235
|
+
if (bindings) {
|
|
236
|
+
if (bindings.dataType) {
|
|
237
|
+
result.dataType = bindings.dataType;
|
|
238
|
+
}
|
|
239
|
+
this._fillScalarShapeCommonProperties(result, input, bindings);
|
|
240
|
+
}
|
|
241
|
+
if (!result.dataType) {
|
|
242
|
+
result.dataType = modelTypeToAmfDataType(input.type, bindings);
|
|
243
|
+
}
|
|
244
|
+
if (schema) {
|
|
245
|
+
this._setShapeSchema(result, schema, result.dataType, input.multiple);
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
_generateExamples(examples, type) {
|
|
250
|
+
return examples.map((current) => {
|
|
251
|
+
const value = AmfDataNode.scalar(current, type).toJSON();
|
|
252
|
+
const item = {
|
|
253
|
+
id: v4(),
|
|
254
|
+
customDomainProperties: [],
|
|
255
|
+
strict: true,
|
|
256
|
+
types: ExampleTypes,
|
|
257
|
+
structuredValue: value,
|
|
258
|
+
};
|
|
259
|
+
return item;
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
_generateArrayExamples(examples, type) {
|
|
263
|
+
const item = {
|
|
264
|
+
id: v4(),
|
|
265
|
+
customDomainProperties: [],
|
|
266
|
+
strict: true,
|
|
267
|
+
types: ExampleTypes,
|
|
268
|
+
};
|
|
269
|
+
const value = new AmfDataNode('array');
|
|
270
|
+
examples.forEach((item) => {
|
|
271
|
+
const member = AmfDataNode.scalar(item, type);
|
|
272
|
+
value.addMember(member);
|
|
273
|
+
});
|
|
274
|
+
item.structuredValue = value.toJSON();
|
|
275
|
+
return [item];
|
|
276
|
+
}
|
|
277
|
+
_generateFileShape(input, schema, bindings) {
|
|
278
|
+
if (bindings && bindings.dataType === AmfNamespace.w3.xmlSchema.base64Binary) {
|
|
279
|
+
// this is a binary format of a string shape
|
|
280
|
+
}
|
|
281
|
+
const result = fileShape(input.key);
|
|
282
|
+
this._updateBaseProperties(input, result);
|
|
283
|
+
if (bindings) {
|
|
284
|
+
if (Array.isArray(bindings.fileTypes)) {
|
|
285
|
+
result.fileTypes = bindings.fileTypes;
|
|
286
|
+
}
|
|
287
|
+
this._fillScalarShapeCommonProperties(result, input, bindings);
|
|
288
|
+
}
|
|
289
|
+
return result;
|
|
290
|
+
}
|
|
291
|
+
_fillScalarShapeCommonProperties(result, input, bindings) {
|
|
292
|
+
if (bindings.name) {
|
|
293
|
+
result.name = bindings.name;
|
|
294
|
+
}
|
|
295
|
+
if (bindings.xml) {
|
|
296
|
+
result.xmlSerialization = bindings.xml;
|
|
297
|
+
}
|
|
298
|
+
if (bindings.pattern) {
|
|
299
|
+
result.pattern = bindings.pattern;
|
|
300
|
+
}
|
|
301
|
+
if (typeof bindings.minLength === 'number') {
|
|
302
|
+
result.minLength = bindings.minLength;
|
|
303
|
+
}
|
|
304
|
+
if (typeof bindings.maxLength === 'number') {
|
|
305
|
+
result.maxLength = bindings.maxLength;
|
|
306
|
+
}
|
|
307
|
+
if (typeof bindings.minimum === 'number') {
|
|
308
|
+
result.minimum = bindings.minimum;
|
|
309
|
+
}
|
|
310
|
+
if (typeof bindings.maximum === 'number') {
|
|
311
|
+
result.maximum = bindings.maximum;
|
|
312
|
+
}
|
|
313
|
+
if (typeof bindings.multipleOf === 'number') {
|
|
314
|
+
result.multipleOf = bindings.multipleOf;
|
|
315
|
+
}
|
|
316
|
+
if (typeof bindings.exclusiveMinimum === 'boolean') {
|
|
317
|
+
result.exclusiveMinimum = bindings.exclusiveMinimum;
|
|
318
|
+
}
|
|
319
|
+
if (typeof bindings.exclusiveMaximum === 'boolean') {
|
|
320
|
+
result.exclusiveMaximum = bindings.exclusiveMaximum;
|
|
321
|
+
}
|
|
322
|
+
if (bindings.format) {
|
|
323
|
+
result.format = bindings.format;
|
|
324
|
+
}
|
|
325
|
+
if (typeof input.readOnly === 'boolean') {
|
|
326
|
+
result.readOnly = input.readOnly;
|
|
327
|
+
}
|
|
328
|
+
if (typeof input.writeOnly === 'boolean') {
|
|
329
|
+
result.writeOnly = input.writeOnly;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
_updateBaseProperties(input, target) {
|
|
333
|
+
const adopted = input.readAdapted();
|
|
334
|
+
if (adopted && adopted.info.name) {
|
|
335
|
+
target.name = adopted.info.name;
|
|
336
|
+
}
|
|
337
|
+
else if (input.info.name) {
|
|
338
|
+
target.name = input.info.name;
|
|
339
|
+
}
|
|
340
|
+
if (adopted && adopted.info.displayName) {
|
|
341
|
+
target.displayName = adopted.info.displayName;
|
|
342
|
+
}
|
|
343
|
+
else if (input.info.displayName) {
|
|
344
|
+
target.displayName = input.info.displayName;
|
|
345
|
+
}
|
|
346
|
+
if (adopted && adopted.info.description) {
|
|
347
|
+
target.description = adopted.info.description;
|
|
348
|
+
}
|
|
349
|
+
else if (input.info.description) {
|
|
350
|
+
target.description = input.info.description;
|
|
351
|
+
}
|
|
352
|
+
if (adopted && adopted.deprecated) {
|
|
353
|
+
target.deprecated = adopted.deprecated;
|
|
354
|
+
}
|
|
355
|
+
else if (input.deprecated) {
|
|
356
|
+
target.deprecated = input.deprecated;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
_recursiveShape(input) {
|
|
360
|
+
return recursiveShape(input.key, input.key);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Translates generated schema from an array shape to the shape defined in the `items` of the array.
|
|
364
|
+
*
|
|
365
|
+
* @param array The source array.
|
|
366
|
+
* @returns The definition of the `items` of the array.
|
|
367
|
+
*/
|
|
368
|
+
refactorArrayToShape(array) {
|
|
369
|
+
const { items } = array;
|
|
370
|
+
return items;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Translates the shape to an array shape. This happens when data model property is changed from 'multiple' to not-multiple and back.
|
|
374
|
+
*
|
|
375
|
+
* @param id The key of the parameter or an association
|
|
376
|
+
* @param shape The shape to wrap as an array.
|
|
377
|
+
* @returns Array shape.
|
|
378
|
+
*/
|
|
379
|
+
refactorShapeToArray(id, shape) {
|
|
380
|
+
const result = arrayShape(id);
|
|
381
|
+
result.items = shape;
|
|
382
|
+
return result;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
//# sourceMappingURL=AmfShapeGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AmfShapeGenerator.js","sourceRoot":"","sources":["../../../src/amf/AmfShapeGenerator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAoI,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC/Q,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEhC;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,KAAiB,EAAE,oBAA8B,EAAE;QACxD,uCAAuC;QACvC,IAAI,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;YACzC,4BAA4B;YAC5B,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;SACpC;QACD,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAA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AAoB,CAAC,EAAU,EAAE,KAAkB;QACjD,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;QAC9B,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DataPropertyType } from "../models/data/DataProperty.js";
|
|
2
|
+
import { IPropertyWebBindings } from "../models/data/Bindings.js";
|
|
3
|
+
export declare const ScalarTypes: string[];
|
|
4
|
+
export declare const ArrayTypes: string[];
|
|
5
|
+
export declare const NodeTypes: string[];
|
|
6
|
+
export declare const PropertyTypes: string[];
|
|
7
|
+
export declare const NilTypes: string[];
|
|
8
|
+
export declare const UnionTypes: string[];
|
|
9
|
+
export declare const FileTypes: string[];
|
|
10
|
+
export declare const AnyTypes: string[];
|
|
11
|
+
export declare const SchemaTypes: string[];
|
|
12
|
+
export declare const TupleTypes: string[];
|
|
13
|
+
export declare const RecursiveTypes: string[];
|
|
14
|
+
export declare const XmlSerializationTypes: string[];
|
|
15
|
+
export declare const ScalarNodeTypes: string[];
|
|
16
|
+
export declare const ArrayNodeTypes: string[];
|
|
17
|
+
export declare const ObjectNodeTypes: string[];
|
|
18
|
+
export declare const ExampleTypes: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Translates the DataProperty type to an AMF data type.
|
|
21
|
+
* @param type The property data type
|
|
22
|
+
* @returns AMF shape dataType
|
|
23
|
+
*/
|
|
24
|
+
export declare function modelTypeToAmfDataType(type: DataPropertyType, bindings?: IPropertyWebBindings): string;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { AmfNamespace } from "./definitions/Namespace.js";
|
|
2
|
+
export const ScalarTypes = [
|
|
3
|
+
AmfNamespace.aml.vocabularies.shapes.ScalarShape,
|
|
4
|
+
AmfNamespace.aml.vocabularies.shapes.AnyShape,
|
|
5
|
+
AmfNamespace.w3.shacl.Shape,
|
|
6
|
+
AmfNamespace.aml.vocabularies.shapes.Shape,
|
|
7
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
8
|
+
];
|
|
9
|
+
export const ArrayTypes = [
|
|
10
|
+
AmfNamespace.aml.vocabularies.shapes.ArrayShape,
|
|
11
|
+
AmfNamespace.aml.vocabularies.shapes.AnyShape,
|
|
12
|
+
AmfNamespace.w3.shacl.Shape,
|
|
13
|
+
AmfNamespace.aml.vocabularies.shapes.Shape,
|
|
14
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
15
|
+
];
|
|
16
|
+
export const NodeTypes = [
|
|
17
|
+
AmfNamespace.w3.shacl.NodeShape,
|
|
18
|
+
AmfNamespace.aml.vocabularies.shapes.AnyShape,
|
|
19
|
+
AmfNamespace.w3.shacl.Shape,
|
|
20
|
+
AmfNamespace.aml.vocabularies.shapes.Shape,
|
|
21
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
22
|
+
];
|
|
23
|
+
export const PropertyTypes = [
|
|
24
|
+
AmfNamespace.w3.shacl.PropertyShape,
|
|
25
|
+
AmfNamespace.w3.shacl.Shape,
|
|
26
|
+
AmfNamespace.aml.vocabularies.shapes.Shape,
|
|
27
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
28
|
+
];
|
|
29
|
+
export const NilTypes = [
|
|
30
|
+
AmfNamespace.aml.vocabularies.shapes.NilShape,
|
|
31
|
+
AmfNamespace.w3.shacl.Shape,
|
|
32
|
+
AmfNamespace.aml.vocabularies.shapes.Shape,
|
|
33
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
34
|
+
];
|
|
35
|
+
export const UnionTypes = [
|
|
36
|
+
AmfNamespace.aml.vocabularies.shapes.UnionShape,
|
|
37
|
+
AmfNamespace.aml.vocabularies.shapes.AnyShape,
|
|
38
|
+
AmfNamespace.w3.shacl.Shape,
|
|
39
|
+
AmfNamespace.aml.vocabularies.shapes.Shape,
|
|
40
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
41
|
+
];
|
|
42
|
+
export const FileTypes = [
|
|
43
|
+
AmfNamespace.aml.vocabularies.shapes.FileShape,
|
|
44
|
+
AmfNamespace.aml.vocabularies.shapes.AnyShape,
|
|
45
|
+
AmfNamespace.w3.shacl.Shape,
|
|
46
|
+
AmfNamespace.aml.vocabularies.shapes.Shape,
|
|
47
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
48
|
+
];
|
|
49
|
+
export const AnyTypes = [
|
|
50
|
+
AmfNamespace.aml.vocabularies.shapes.AnyShape,
|
|
51
|
+
AmfNamespace.w3.shacl.Shape,
|
|
52
|
+
AmfNamespace.aml.vocabularies.shapes.Shape,
|
|
53
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
54
|
+
];
|
|
55
|
+
export const SchemaTypes = [
|
|
56
|
+
AmfNamespace.aml.vocabularies.shapes.SchemaShape,
|
|
57
|
+
AmfNamespace.aml.vocabularies.shapes.AnyShape,
|
|
58
|
+
AmfNamespace.w3.shacl.Shape,
|
|
59
|
+
AmfNamespace.aml.vocabularies.shapes.Shape,
|
|
60
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
61
|
+
];
|
|
62
|
+
export const TupleTypes = [
|
|
63
|
+
AmfNamespace.aml.vocabularies.shapes.TupleShape,
|
|
64
|
+
AmfNamespace.aml.vocabularies.shapes.ArrayShape,
|
|
65
|
+
AmfNamespace.aml.vocabularies.shapes.AnyShape,
|
|
66
|
+
AmfNamespace.w3.shacl.Shape,
|
|
67
|
+
AmfNamespace.aml.vocabularies.shapes.Shape,
|
|
68
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
69
|
+
];
|
|
70
|
+
export const RecursiveTypes = [
|
|
71
|
+
AmfNamespace.aml.vocabularies.shapes.RecursiveShape,
|
|
72
|
+
AmfNamespace.w3.shacl.Shape,
|
|
73
|
+
AmfNamespace.aml.vocabularies.shapes.Shape,
|
|
74
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
75
|
+
];
|
|
76
|
+
export const XmlSerializationTypes = [
|
|
77
|
+
AmfNamespace.aml.vocabularies.shapes.XMLSerializer,
|
|
78
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
79
|
+
];
|
|
80
|
+
export const ScalarNodeTypes = [
|
|
81
|
+
AmfNamespace.aml.vocabularies.data.Scalar,
|
|
82
|
+
AmfNamespace.aml.vocabularies.data.Node,
|
|
83
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
84
|
+
];
|
|
85
|
+
export const ArrayNodeTypes = [
|
|
86
|
+
AmfNamespace.aml.vocabularies.data.Array,
|
|
87
|
+
AmfNamespace.w3.rdfSchema.Seq,
|
|
88
|
+
AmfNamespace.aml.vocabularies.data.Node,
|
|
89
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
90
|
+
];
|
|
91
|
+
export const ObjectNodeTypes = [
|
|
92
|
+
AmfNamespace.aml.vocabularies.data.Object,
|
|
93
|
+
AmfNamespace.aml.vocabularies.data.Node,
|
|
94
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
95
|
+
];
|
|
96
|
+
export const ExampleTypes = [
|
|
97
|
+
AmfNamespace.aml.vocabularies.apiContract.Example,
|
|
98
|
+
AmfNamespace.aml.vocabularies.document.DomainElement,
|
|
99
|
+
];
|
|
100
|
+
/**
|
|
101
|
+
* Translates the DataProperty type to an AMF data type.
|
|
102
|
+
* @param type The property data type
|
|
103
|
+
* @returns AMF shape dataType
|
|
104
|
+
*/
|
|
105
|
+
export function modelTypeToAmfDataType(type, bindings) {
|
|
106
|
+
switch (type) {
|
|
107
|
+
case 'boolean': return AmfNamespace.aml.vocabularies.shapes.boolean;
|
|
108
|
+
case 'nil': return AmfNamespace.aml.vocabularies.shapes.nil;
|
|
109
|
+
case 'date': return AmfNamespace.w3.xmlSchema.date;
|
|
110
|
+
case 'datetime': return AmfNamespace.w3.xmlSchema.dateTime;
|
|
111
|
+
case 'time': return AmfNamespace.aml.vocabularies.shapes.dateTimeOnly;
|
|
112
|
+
case 'number': return AmfNamespace.w3.xmlSchema.number;
|
|
113
|
+
case 'integer': return AmfNamespace.w3.xmlSchema.integer;
|
|
114
|
+
case 'any': return AmfNamespace.aml.vocabularies.shapes.AnyShape;
|
|
115
|
+
default:
|
|
116
|
+
if (bindings && bindings.format === 'binary') {
|
|
117
|
+
return AmfNamespace.w3.xmlSchema.base64Binary;
|
|
118
|
+
}
|
|
119
|
+
return AmfNamespace.w3.xmlSchema.string;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=AmfTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AmfTypes.js","sourceRoot":"","sources":["../../../src/amf/AmfTypes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW;IAChD,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ;IAC7C,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK;IAC3B,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK;IAC1C,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,aAAa;CACrD,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU;IAC/C,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ;IAC7C,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK;IAC3B,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK;IAC1C,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,aAAa;CACrD,CAAC;AACF,MAAM,CA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AAE,CAAC,SAAS,CAAC,MAAM,CAAC;KAC3C;AACH,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IDataExample, IDataNode, IShapeUnion } from "./definitions/Shapes.js";
|
|
2
|
+
/**
|
|
3
|
+
* A class that processes AMF's Example object to read the example value
|
|
4
|
+
* or to generate the example for the given media type.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ApiExampleGenerator {
|
|
7
|
+
/**
|
|
8
|
+
* Reads or generates an example.
|
|
9
|
+
* When the `mime` is set then it tries to "guess" whether the mime type corresponds to the value.
|
|
10
|
+
* If it doesn't then it generates the example from the structured value, when possible.
|
|
11
|
+
* @param example The structured value of the example
|
|
12
|
+
* @param mime The optional mime type of the example. When not set it won't generate example from the structured value.
|
|
13
|
+
* @param shape The optional shape containing this example to use with the XML examples which needs wrapping into an element.
|
|
14
|
+
* @returns The read or generated example.
|
|
15
|
+
*/
|
|
16
|
+
read(example: IDataExample, mime?: string, shape?: IShapeUnion): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Employs some basic heuristics to determine whether the given mime type patches the content.
|
|
19
|
+
* @param mime The mime type for the value.
|
|
20
|
+
* @param value The value.
|
|
21
|
+
* @returns True when the value matches the mime type.
|
|
22
|
+
*/
|
|
23
|
+
mimeMatches(mime: string, value?: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Generates the example for the given structured value and the media type.
|
|
26
|
+
* @param mime The mime type for the value.
|
|
27
|
+
* @param structuredValue The structuredValue of the example.
|
|
28
|
+
* @param shape The optional shape containing this example to use with the XML examples which needs wrapping into an element.
|
|
29
|
+
* @returns The generated example or null if couldn't process the data.
|
|
30
|
+
*/
|
|
31
|
+
fromStructuredValue(mime: string, structuredValue: IDataNode, shape?: IShapeUnion): string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Wraps the generated XML example into an element according to the `shape` properties.
|
|
34
|
+
*/
|
|
35
|
+
wrapXmlValue(value?: string, shape?: IShapeUnion): string | undefined;
|
|
36
|
+
}
|