@api-client/core 0.7.12 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/SECURITY.md +14 -0
  2. package/build/browser.d.ts +8 -1
  3. package/build/browser.js +7 -0
  4. package/build/browser.js.map +1 -1
  5. package/build/index.d.ts +8 -1
  6. package/build/index.js +7 -0
  7. package/build/index.js.map +1 -1
  8. package/build/src/amf/AmfMixin.d.ts +56 -42
  9. package/build/src/amf/AmfMixin.js +9 -3
  10. package/build/src/amf/AmfMixin.js.map +1 -1
  11. package/build/src/amf/AmfSerializer.d.ts +72 -72
  12. package/build/src/amf/AmfSerializer.js +9 -4
  13. package/build/src/amf/AmfSerializer.js.map +1 -1
  14. package/build/src/amf/AmfShapeGenerator.d.ts +17 -17
  15. package/build/src/amf/AmfShapeGenerator.js +3 -3
  16. package/build/src/amf/AmfShapeGenerator.js.map +1 -1
  17. package/build/src/amf/AmfTypes.d.ts +16 -16
  18. package/build/src/amf/AmfTypes.js +16 -16
  19. package/build/src/amf/AmfTypes.js.map +1 -1
  20. package/build/src/amf/ApiExampleGenerator.d.ts +3 -3
  21. package/build/src/amf/ApiExampleGenerator.js.map +1 -1
  22. package/build/src/amf/ApiMonacoSchemaGenerator.d.ts +6 -6
  23. package/build/src/amf/ApiMonacoSchemaGenerator.js.map +1 -1
  24. package/build/src/amf/ApiSchemaGenerator.d.ts +2 -2
  25. package/build/src/amf/ApiSchemaGenerator.js.map +1 -1
  26. package/build/src/amf/ApiSchemaValues.d.ts +12 -12
  27. package/build/src/amf/ApiSchemaValues.js.map +1 -1
  28. package/build/src/amf/Parsing.d.ts +5 -5
  29. package/build/src/amf/Utils.d.ts +6 -6
  30. package/build/src/amf/Utils.js.map +1 -1
  31. package/build/src/amf/data-node/DataNodeBase.d.ts +5 -5
  32. package/build/src/amf/data-node/DataNodeBase.js.map +1 -1
  33. package/build/src/amf/data-node/JsonDataNodeGenerator.d.ts +2 -2
  34. package/build/src/amf/data-node/JsonDataNodeGenerator.js.map +1 -1
  35. package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.d.ts +2 -2
  36. package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.js.map +1 -1
  37. package/build/src/amf/data-node/XmlDataNodeGenerator.d.ts +2 -2
  38. package/build/src/amf/data-node/XmlDataNodeGenerator.js.map +1 -1
  39. package/build/src/amf/definitions/Amf.d.ts +339 -339
  40. package/build/src/amf/definitions/Api.d.ts +158 -158
  41. package/build/src/amf/definitions/Base.d.ts +5 -5
  42. package/build/src/amf/definitions/Shapes.d.ts +46 -46
  43. package/build/src/amf/definitions/Shapes.js +11 -11
  44. package/build/src/amf/definitions/Shapes.js.map +1 -1
  45. package/build/src/amf/models/AmfDataNode.d.ts +5 -5
  46. package/build/src/amf/models/AmfDataNode.js +4 -4
  47. package/build/src/amf/models/AmfDataNode.js.map +1 -1
  48. package/build/src/amf/shape/ShapeBase.d.ts +13 -13
  49. package/build/src/amf/shape/ShapeBase.js.map +1 -1
  50. package/build/src/amf/shape/ShapeJsonSchemaGenerator.d.ts +13 -13
  51. package/build/src/amf/shape/ShapeJsonSchemaGenerator.js.map +1 -1
  52. package/build/src/amf/shape/ShapeXmlSchemaGenerator.d.ts +16 -16
  53. package/build/src/amf/shape/ShapeXmlSchemaGenerator.js.map +1 -1
  54. package/build/src/events/amf/AmfEvents.d.ts +4 -4
  55. package/build/src/events/amf/AmfEvents.js.map +1 -1
  56. package/build/src/lib/timers/Timers.d.ts +9 -0
  57. package/build/src/lib/timers/Timers.js +13 -0
  58. package/build/src/lib/timers/Timers.js.map +1 -1
  59. package/build/src/models/data/Bindings.d.ts +2 -2
  60. package/build/src/models/data/DataAssociation.d.ts +4 -4
  61. package/build/src/models/data/DataAssociation.js.map +1 -1
  62. package/build/src/models/data/DataEntity.d.ts +2 -2
  63. package/build/src/models/data/DataProperty.d.ts +2 -2
  64. package/data/apis/amf-helper-api/amf-helper-api.raml +1024 -0
  65. package/data/apis/amf-helper-api/examples/comment-example.json +42 -0
  66. package/data/apis/amf-helper-api/examples/commentCreateRequest-example.json +7 -0
  67. package/data/apis/amf-helper-api/examples/commentList-example.json +48 -0
  68. package/data/apis/amf-helper-api/examples/person.json +14 -0
  69. package/data/apis/amf-helper-api/examples/person.raml +13 -0
  70. package/data/apis/amf-helper-api/examples/person.xml +14 -0
  71. package/data/apis/amf-helper-api/libraries/comment-lib.raml +143 -0
  72. package/data/apis/amf-helper-api/library.raml +7 -0
  73. package/data/apis/amf-helper-api/schemas/person.json +104 -0
  74. package/data/apis/amf-helper-api/schemas/person.xsd +26 -0
  75. package/data/apis/amf-helper-api/traits/file.raml +33 -0
  76. package/data/apis/amf-helper-api/traits/pagination.raml +80 -0
  77. package/data/apis/amf-helper-api/traits/results.raml +19 -0
  78. package/data/apis/amf-helper-api/traits/visibility.raml +14 -0
  79. package/data/apis/amf-helper-api/types/app-person.raml +101 -0
  80. package/data/apis/amf-helper-api/types/dimensions.raml +24 -0
  81. package/data/apis/amf-helper-api/types/external-type.raml +7 -0
  82. package/data/apis/amf-helper-api/types/image.raml +23 -0
  83. package/data/apis/amf-helper-api/types/product.raml +52 -0
  84. package/data/apis/amf-helper-api/types/resource.raml +11 -0
  85. package/data/apis/amf-helper-api/types/standard-request.raml +50 -0
  86. package/data/apis/amf-helper-api/types/user.raml +37 -0
  87. package/data/apis/async-api/async-api.yaml +96 -0
  88. package/data/apis/expanded-api/expanded-api.raml +8 -0
  89. package/data/apis/flattened-api/flattened-api.raml +8 -0
  90. package/data/apis/multiple-servers/multiple-servers.yaml +112 -0
  91. package/data/model.js +5 -0
  92. package/data/models/amf-helper-api.json +85908 -0
  93. package/data/models/async-api.json +3108 -0
  94. package/data/models/expanded-api.json +251 -0
  95. package/data/models/flattened-api.json +251 -0
  96. package/data/models/multiple-servers.json +2753 -0
  97. package/package.json +1 -1
  98. package/src/amf/AmfMixin.ts +125 -117
  99. package/src/amf/AmfSerializer.ts +245 -240
  100. package/src/amf/AmfShapeGenerator.ts +23 -23
  101. package/src/amf/AmfTypes.ts +16 -16
  102. package/src/amf/ApiExampleGenerator.ts +4 -4
  103. package/src/amf/ApiMonacoSchemaGenerator.ts +11 -11
  104. package/src/amf/ApiSchemaGenerator.ts +3 -3
  105. package/src/amf/ApiSchemaValues.ts +21 -21
  106. package/src/amf/Parsing.ts +5 -5
  107. package/src/amf/Utils.ts +15 -15
  108. package/src/amf/data-node/DataNodeBase.ts +8 -8
  109. package/src/amf/data-node/JsonDataNodeGenerator.ts +2 -2
  110. package/src/amf/data-node/UrlEncodedDataNodeGenerator.ts +2 -2
  111. package/src/amf/data-node/XmlDataNodeGenerator.ts +2 -2
  112. package/src/amf/definitions/Amf.ts +315 -314
  113. package/src/amf/definitions/Api.ts +158 -157
  114. package/src/amf/definitions/Base.ts +5 -5
  115. package/src/amf/definitions/Shapes.ts +60 -60
  116. package/src/amf/models/AmfDataNode.ts +17 -17
  117. package/src/amf/shape/ShapeBase.ts +16 -16
  118. package/src/amf/shape/ShapeJsonSchemaGenerator.ts +27 -27
  119. package/src/amf/shape/ShapeXmlSchemaGenerator.ts +42 -42
  120. package/src/events/amf/AmfEvents.ts +7 -7
  121. package/src/lib/timers/Timers.ts +14 -0
  122. package/src/models/data/Bindings.ts +2 -2
  123. package/src/models/data/DataAssociation.ts +4 -4
  124. package/src/models/data/DataEntity.ts +2 -2
  125. package/src/models/data/DataProperty.ts +2 -2
@@ -1,7 +1,7 @@
1
1
  import { AmfNamespace as ns } from "../definitions/Namespace.js";
2
2
  import { ShapeBase } from './ShapeBase.js';
3
3
  import { JsonDataNodeGenerator } from '../data-node/JsonDataNodeGenerator.js';
4
- import { IAnyShape, IArrayShape, IDataExample, IDataNodeUnion, INodeShape, IPropertyShape, IScalarShape, IShapeUnion, ITupleShape, IUnionShape } from "../definitions/Shapes.js";
4
+ import { IApiAnyShape, IApiArrayShape, IApiDataExample, IApiDataNodeUnion, IApiNodeShape, IApiPropertyShape, IApiScalarShape, IShapeUnion, IApiTupleShape, IApiUnionShape } from "../definitions/Shapes.js";
5
5
 
6
6
  export class ShapeJsonSchemaGenerator extends ShapeBase {
7
7
  /**
@@ -23,13 +23,13 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
23
23
  toObject(schema: IShapeUnion): any {
24
24
  const { types } = schema;
25
25
  if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {
26
- return this._scalarShapeObject(schema as IScalarShape);
26
+ return this._scalarShapeObject(schema as IApiScalarShape);
27
27
  }
28
28
  if (types.includes(ns.w3.shacl.NodeShape)) {
29
- return this._nodeShapeObject(schema as INodeShape);
29
+ return this._nodeShapeObject(schema as IApiNodeShape);
30
30
  }
31
31
  if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) {
32
- return this._unionShapeObject(schema as IUnionShape);
32
+ return this._unionShapeObject(schema as IApiUnionShape);
33
33
  }
34
34
  if (types.includes(ns.aml.vocabularies.shapes.FileShape)) {
35
35
  return this._fileShapeObject();
@@ -38,12 +38,12 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
38
38
  return this._schemaShapeObject();
39
39
  }
40
40
  if (types.includes(ns.aml.vocabularies.shapes.TupleShape)) {
41
- return this._tupleShapeObject(schema as ITupleShape);
41
+ return this._tupleShapeObject(schema as IApiTupleShape);
42
42
  }
43
43
  if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) || types.includes(ns.aml.vocabularies.shapes.MatrixShape)) {
44
- return this._arrayShapeObject(schema as IArrayShape);
44
+ return this._arrayShapeObject(schema as IApiArrayShape);
45
45
  }
46
- return this._anyShapeObject(schema as IAnyShape);
46
+ return this._anyShapeObject(schema as IApiAnyShape);
47
47
  }
48
48
 
49
49
  /**
@@ -53,7 +53,7 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
53
53
  return JSON.stringify(value, null, 2);
54
54
  }
55
55
 
56
- protected _scalarShapeObject(schema: IScalarShape): any|undefined {
56
+ protected _scalarShapeObject(schema: IApiScalarShape): any|undefined {
57
57
  return this._scalarValue(schema);
58
58
  }
59
59
 
@@ -61,12 +61,12 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
61
61
  return undefined;
62
62
  }
63
63
 
64
- protected _nodeShapeObject(schema: INodeShape): any {
64
+ protected _nodeShapeObject(schema: IApiNodeShape): any {
65
65
  const { inherits } = schema;
66
66
  let { examples=[] } = schema;
67
67
  if (Array.isArray(inherits) && inherits.length) {
68
68
  inherits.forEach((parent) => {
69
- const anyParent = parent as IAnyShape;
69
+ const anyParent = parent as IApiAnyShape;
70
70
  if (Array.isArray(anyParent.examples) && anyParent.examples.length) {
71
71
  examples = examples.concat(anyParent.examples);
72
72
  }
@@ -99,7 +99,7 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
99
99
  return result;
100
100
  }
101
101
 
102
- protected _unionShapeObject(schema: IUnionShape): any {
102
+ protected _unionShapeObject(schema: IApiUnionShape): any {
103
103
  if (schema.and && schema.and.length) {
104
104
  return this._allOfUnion(schema);
105
105
  }
@@ -110,15 +110,15 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
110
110
  return this._anyOfUnion(schema);
111
111
  }
112
112
 
113
- protected _anyOfUnion(schema: IUnionShape): any {
113
+ protected _anyOfUnion(schema: IApiUnionShape): any {
114
114
  let { anyOf=[], examples=[] } = schema;
115
115
  if (Array.isArray(schema.inherits) && schema.inherits) {
116
116
  schema.inherits.forEach((parent) => {
117
- const anyParent = parent as IAnyShape;
117
+ const anyParent = parent as IApiAnyShape;
118
118
  if (Array.isArray(anyParent.examples) && anyParent.examples.length) {
119
119
  examples = examples.concat(anyParent.examples);
120
120
  }
121
- const typed = parent as IUnionShape;
121
+ const typed = parent as IApiUnionShape;
122
122
  if (Array.isArray(typed.anyOf) && typed.anyOf.length) {
123
123
  anyOf = anyOf.concat(typed.anyOf);
124
124
  }
@@ -154,11 +154,11 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
154
154
  return undefined;
155
155
  }
156
156
 
157
- protected _oneOfUnion(schema: IUnionShape): any {
157
+ protected _oneOfUnion(schema: IApiUnionShape): any {
158
158
  let { xone=[], examples=[] } = schema;
159
159
  if (Array.isArray(schema.inherits) && schema.inherits) {
160
160
  schema.inherits.forEach((parent) => {
161
- const anyParent = parent as IAnyShape;
161
+ const anyParent = parent as IApiAnyShape;
162
162
  if (Array.isArray(anyParent.examples) && anyParent.examples.length) {
163
163
  examples = examples.concat(anyParent.examples);
164
164
  }
@@ -191,11 +191,11 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
191
191
  /**
192
192
  * Combines all properties from both all shapes in the union
193
193
  */
194
- protected _allOfUnion(schema: IUnionShape): any {
194
+ protected _allOfUnion(schema: IApiUnionShape): any {
195
195
  let { examples=[], and=[] } = schema;
196
196
  if (Array.isArray(schema.inherits) && schema.inherits) {
197
197
  schema.inherits.forEach((parent) => {
198
- const anyParent = parent as IAnyShape;
198
+ const anyParent = parent as IApiAnyShape;
199
199
  if (Array.isArray(anyParent.examples) && anyParent.examples.length) {
200
200
  examples = examples.concat(anyParent.examples);
201
201
  }
@@ -222,7 +222,7 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
222
222
  * @param union The list of unions in the shape
223
223
  * @param defaultValue The definition of a default value.
224
224
  */
225
- protected _unionDefaultValue(union: IShapeUnion[], defaultValue: IDataNodeUnion): any | undefined {
225
+ protected _unionDefaultValue(union: IShapeUnion[], defaultValue: IApiDataNodeUnion): any | undefined {
226
226
  const gen = new JsonDataNodeGenerator();
227
227
  const result = gen.generate(defaultValue);
228
228
  let hasNumber = false;
@@ -235,7 +235,7 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
235
235
  if (!i.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {
236
236
  return;
237
237
  }
238
- const scalar = i as IScalarShape;
238
+ const scalar = i as IApiScalarShape;
239
239
  if (!hasBoolean) {
240
240
  hasBoolean = scalar.dataType === ns.w3.xmlSchema.boolean;
241
241
  }
@@ -277,12 +277,12 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
277
277
  return result;
278
278
  }
279
279
 
280
- protected _arrayShapeObject(schema: IArrayShape): any[] {
280
+ protected _arrayShapeObject(schema: IApiArrayShape): any[] {
281
281
  const { items } = schema;
282
282
  const defaultValue = schema.defaultValue || items && items.defaultValue;
283
283
 
284
284
  let { examples=[] } = schema;
285
- const anyItems = items as IAnyShape;
285
+ const anyItems = items as IApiAnyShape;
286
286
  if (Array.isArray(anyItems.examples)) {
287
287
  examples = examples.concat(anyItems.examples);
288
288
  }
@@ -314,7 +314,7 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
314
314
  return [];
315
315
  }
316
316
 
317
- protected _tupleShapeObject(schema: ITupleShape): any {
317
+ protected _tupleShapeObject(schema: IApiTupleShape): any {
318
318
  const { items, examples } = schema;
319
319
  if (this.opts.renderExamples && examples && examples.length) {
320
320
  const example = examples.find((item) => !!item.structuredValue);
@@ -343,7 +343,7 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
343
343
  return [];
344
344
  }
345
345
 
346
- protected _anyShapeObject(schema: IAnyShape): any {
346
+ protected _anyShapeObject(schema: IApiAnyShape): any {
347
347
  const { and=[], xone=[], or=[] } = schema;
348
348
  if (and.length) {
349
349
  let result: any = {};
@@ -379,7 +379,7 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
379
379
  /**
380
380
  * @returns The value for the property or undefined when cannot generate the value.
381
381
  */
382
- protected _propertyShapeObject(schema: IPropertyShape): any | undefined {
382
+ protected _propertyShapeObject(schema: IApiPropertyShape): any | undefined {
383
383
  const { minCount=0 } = schema;
384
384
  if (minCount === 0 && !this.opts.renderOptional) {
385
385
  return undefined;
@@ -398,7 +398,7 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
398
398
  // return ApiSchemaValues.readTypedValue(value, /** @type IScalarShape */ (range).dataType);
399
399
  // }
400
400
  // }
401
- const anyRange = range as IAnyShape;
401
+ const anyRange = range as IApiAnyShape;
402
402
  return this._scalarShapeObject(anyRange);
403
403
  }
404
404
  return this.toObject(range);
@@ -407,7 +407,7 @@ export class ShapeJsonSchemaGenerator extends ShapeBase {
407
407
  /**
408
408
  * @param example The example to turn into a JS object
409
409
  */
410
- protected _exampleToObject(example?: IDataExample): any {
410
+ protected _exampleToObject(example?: IApiDataExample): any {
411
411
  if (example && example.structuredValue) {
412
412
  const jsonGenerator = new JsonDataNodeGenerator();
413
413
  return jsonGenerator.processNode(example.structuredValue);
@@ -3,7 +3,7 @@ import { AmfNamespace as ns } from "../definitions/Namespace.js";
3
3
  import { ShapeBase } from './ShapeBase.js';
4
4
  import { XmlDataNodeGenerator } from '../data-node/XmlDataNodeGenerator.js';
5
5
  import { collectNodeProperties, formatXmlValue, getUnionMember } from '../Utils.js';
6
- import { IAnyShape, IArrayShape, IDataExample, IDataNodeUnion, INodeShape, IPropertyShape, IScalarShape, IShapeUnion, IUnionShape } from "../definitions/Shapes.js";
6
+ import { IApiAnyShape, IApiArrayShape, IApiDataExample, IApiDataNodeUnion, IApiNodeShape, IApiPropertyShape, IApiScalarShape, IShapeUnion, IApiUnionShape } from "../definitions/Shapes.js";
7
7
 
8
8
  interface IProcessNodeOptions {
9
9
  forceName?: string;
@@ -27,7 +27,7 @@ interface ICollectExamplesOptions {
27
27
  export const normalizeXmlTagName = (name: string): string => name.replace(/[^a-zA-Z0-9-_.]/g, '');
28
28
  const UNKNOWN_TYPE = 'unknown-type';
29
29
 
30
- export function shapeToXmlTagName(shape: IAnyShape): string {
30
+ export function shapeToXmlTagName(shape: IApiAnyShape): string {
31
31
  const { name, inherits=[], xmlSerialization } = shape;
32
32
  let label: string | undefined = xmlSerialization && xmlSerialization.name ? xmlSerialization.name : name || UNKNOWN_TYPE;
33
33
  if (label === 'schema' && inherits.length) {
@@ -56,13 +56,13 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
56
56
  processNode(schema: IShapeUnion, options: IProcessNodeOptions = {}): string {
57
57
  const { types } = schema;
58
58
  if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {
59
- return this._scalarShapeObject(schema as IScalarShape, options);
59
+ return this._scalarShapeObject(schema as IApiScalarShape, options);
60
60
  }
61
61
  if (types.includes(ns.w3.shacl.NodeShape)) {
62
- return this._nodeShapeObject(schema as INodeShape, options);
62
+ return this._nodeShapeObject(schema as IApiNodeShape, options);
63
63
  }
64
64
  if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) {
65
- return this._unionShapeObject(schema as IUnionShape);
65
+ return this._unionShapeObject(schema as IApiUnionShape);
66
66
  }
67
67
  if (types.includes(ns.aml.vocabularies.shapes.FileShape)) {
68
68
  return this._fileShapeObject();
@@ -74,9 +74,9 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
74
74
  return this._tupleShapeObject();
75
75
  }
76
76
  if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) || types.includes(ns.aml.vocabularies.shapes.MatrixShape)) {
77
- return this._arrayShapeObject(schema as IArrayShape, options);
77
+ return this._arrayShapeObject(schema as IApiArrayShape, options);
78
78
  }
79
- return this._anyShapeObject(schema as IAnyShape);
79
+ return this._anyShapeObject(schema as IApiAnyShape);
80
80
  }
81
81
 
82
82
  /**
@@ -94,12 +94,12 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
94
94
  return getUnionMember(anyOf, selectedUnions);
95
95
  }
96
96
 
97
- protected _collectProperties(schema: INodeShape): IPropertyShape[] {
97
+ protected _collectProperties(schema: IApiNodeShape): IApiPropertyShape[] {
98
98
  const { selectedUnions } = this.opts;
99
99
  return collectNodeProperties(schema, selectedUnions);
100
100
  }
101
101
 
102
- protected _nodeShapeObject(schema: INodeShape, options: IProcessNodeOptions={}): string {
102
+ protected _nodeShapeObject(schema: IApiNodeShape, options: IProcessNodeOptions={}): string {
103
103
  const label = options.forceName || shapeToXmlTagName(schema);
104
104
  const parts = [];
105
105
  const currentIndent = (options.indent || 0);
@@ -118,7 +118,7 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
118
118
  if (minCount === 0 && !this.opts.renderOptional || !range) {
119
119
  return;
120
120
  }
121
- const anyRange = range as IAnyShape;
121
+ const anyRange = range as IApiAnyShape;
122
122
  if (anyRange.xmlSerialization) {
123
123
  // Adds to the parent attributes list.
124
124
  // When a non-scalar shape has `attribute` serialization this is an API spec error.
@@ -151,7 +151,7 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
151
151
  return parts.join('\n');
152
152
  }
153
153
 
154
- protected _scalarShapeObject(schema: IScalarShape, options: IProcessNodeOptions={}): any {
154
+ protected _scalarShapeObject(schema: IApiScalarShape, options: IProcessNodeOptions={}): any {
155
155
  const { xmlSerialization, defaultValue } = schema;
156
156
  let content;
157
157
  if (defaultValue) {
@@ -186,7 +186,7 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
186
186
  return parts.join('');
187
187
  }
188
188
 
189
- protected _nilShapeObject(schema: IScalarShape, options: IProcessNodeOptions={}): any|undefined {
189
+ protected _nilShapeObject(schema: IApiScalarShape, options: IProcessNodeOptions={}): any|undefined {
190
190
  const { xmlSerialization } = schema;
191
191
  const content = '';
192
192
  let label = options.forceName || shapeToXmlTagName(schema);
@@ -218,27 +218,27 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
218
218
  /**
219
219
  * @returns The value for the property or undefined when cannot generate the value.
220
220
  */
221
- protected _propertyShapeObject(schema: IPropertyShape, options: IProcessNodeOptions = {}): string|undefined {
221
+ protected _propertyShapeObject(schema: IApiPropertyShape, options: IProcessNodeOptions = {}): string|undefined {
222
222
  const { range, minCount=0 } = schema;
223
223
  if (minCount === 0 && !this.opts.renderOptional || !range) {
224
224
  return undefined;
225
225
  }
226
226
  const { types } = range;
227
- const name = shapeToXmlTagName(schema as IAnyShape);
227
+ const name = shapeToXmlTagName(schema as IApiAnyShape);
228
228
  if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {
229
- return this._scalarShapeObject(range as IScalarShape, { ...options });
229
+ return this._scalarShapeObject(range as IApiScalarShape, { ...options });
230
230
  }
231
231
  if (types.includes(ns.aml.vocabularies.shapes.NilShape)) {
232
- return this._nilShapeObject(range as IScalarShape, { ...options, forceName: name });
232
+ return this._nilShapeObject(range as IApiScalarShape, { ...options, forceName: name });
233
233
  }
234
234
  if (types.includes(ns.aml.vocabularies.shapes.RecursiveShape)) {
235
235
  return undefined;
236
236
  }
237
237
  if (types.includes(ns.w3.shacl.NodeShape)) {
238
- return this._nodePropertyObject(schema as IPropertyShape<INodeShape>, options);
238
+ return this._nodePropertyObject(schema as IApiPropertyShape<IApiNodeShape>, options);
239
239
  }
240
240
  if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) || types.includes(ns.aml.vocabularies.shapes.MatrixShape)) {
241
- return this._nodePropertyArray(schema as IPropertyShape<IArrayShape>, options);
241
+ return this._nodePropertyArray(schema as IApiPropertyShape<IApiArrayShape>, options);
242
242
  }
243
243
  return this.processNode(range, { ...options, forceName: name });
244
244
  }
@@ -248,17 +248,17 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
248
248
  return undefined;
249
249
  }
250
250
  const { isWrapped, nodeName, tagFill='', indent = 0 } = opts;
251
- let { examples=[] } = (schema as IAnyShape);
251
+ let { examples=[] } = (schema as IApiAnyShape);
252
252
  const { inherits } = schema;
253
253
  if (Array.isArray(inherits) && inherits.length) {
254
254
  inherits.forEach((parent) => {
255
255
  let node = parent;
256
256
  if (node.types.includes(ns.aml.vocabularies.shapes.UnionShape)) {
257
- const union = node as IUnionShape;
257
+ const union = node as IApiUnionShape;
258
258
  const { anyOf=[] } = union;
259
259
  node = this._readCurrentUnion(anyOf);
260
260
  }
261
- const anyShape = node as IAnyShape;
261
+ const anyShape = node as IApiAnyShape;
262
262
  if (Array.isArray(anyShape.examples) && anyShape.examples.length) {
263
263
  examples = examples.concat(anyShape.examples);
264
264
  }
@@ -292,13 +292,13 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
292
292
  return new Array(indent * 2 + offset).fill(' ').join('');
293
293
  }
294
294
 
295
- protected _nodePropertyObject(schema: IPropertyShape<INodeShape>, options: IProcessNodeOptions = {}): string {
295
+ protected _nodePropertyObject(schema: IApiPropertyShape<IApiNodeShape>, options: IProcessNodeOptions = {}): string {
296
296
  const parts: string[] = [];
297
297
  const name = normalizeXmlTagName(String(schema.name));
298
298
  const { indent=0 } = options;
299
299
  const baseTabs = this._createTabs(indent);
300
300
  let value: string;
301
- const range = schema.range as INodeShape;
301
+ const range = schema.range as IApiNodeShape;
302
302
  const exampleValue = this._collectExamples(range, {
303
303
  tagFill: baseTabs,
304
304
  indent: indent + 1,
@@ -316,7 +316,7 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
316
316
  if (minCount === 0 && !this.opts.renderOptional) {
317
317
  return;
318
318
  }
319
- const anyRange = range as IAnyShape;
319
+ const anyRange = range as IApiAnyShape;
320
320
 
321
321
  if (anyRange.xmlSerialization) {
322
322
  const { prefix, attribute } = anyRange.xmlSerialization;
@@ -350,8 +350,8 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
350
350
  return parts.join('\n');
351
351
  }
352
352
 
353
- protected _nodePropertyArray(schema: IPropertyShape<IArrayShape>, options: IProcessNodeOptions = {}): string {
354
- const range = schema.range as IArrayShape;
353
+ protected _nodePropertyArray(schema: IApiPropertyShape<IApiArrayShape>, options: IProcessNodeOptions = {}): string {
354
+ const range = schema.range as IApiArrayShape;
355
355
  const parts: string[] = [];
356
356
  let name: string;
357
357
  if (range.xmlSerialization && range.xmlSerialization.name) {
@@ -375,7 +375,7 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
375
375
  return parts.join('\n');
376
376
  }
377
377
 
378
- protected _arrayShapeObject(schema: IArrayShape, options: IProcessNodeOptions={}): string {
378
+ protected _arrayShapeObject(schema: IApiArrayShape, options: IProcessNodeOptions={}): string {
379
379
  const { items } = schema;
380
380
  const isScalarItems = !!items && items.types.includes(ns.aml.vocabularies.shapes.ScalarShape);
381
381
  // the name is either from the XML serialization info, or the parent property.
@@ -605,8 +605,8 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
605
605
  * @param schema The array schema
606
606
  * @param options Processing options.
607
607
  */
608
- protected _scalarItems(schema: IArrayShape<IScalarShape>, options: IProcessNodeOptions={}): string {
609
- const items = schema.items as IScalarShape;
608
+ protected _scalarItems(schema: IApiArrayShape<IApiScalarShape>, options: IProcessNodeOptions={}): string {
609
+ const items = schema.items as IApiScalarShape;
610
610
  const currentIndent = (options.indent || 0);
611
611
  const tagFill = new Array(currentIndent * 2).fill(' ').join('');
612
612
 
@@ -661,8 +661,8 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
661
661
  * @param schema The array shape with item that is NodeShape.
662
662
  * @param options Rendering options.
663
663
  */
664
- protected _nodeItems(schema: IArrayShape<INodeShape>, options: IProcessNodeOptions={}): string {
665
- const items = schema.items as INodeShape;
664
+ protected _nodeItems(schema: IApiArrayShape<IApiNodeShape>, options: IProcessNodeOptions={}): string {
665
+ const items = schema.items as IApiNodeShape;
666
666
  const currentIndent = (options.indent || 0);
667
667
  const tagFill = new Array(currentIndent * 2).fill(' ').join('');
668
668
  const isWrapped = schema.xmlSerialization && !!schema.xmlSerialization.wrapped;
@@ -729,7 +729,7 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
729
729
  /**
730
730
  * @param example The example to turn into a JS object
731
731
  */
732
- protected _exampleToObject(example?: IDataExample): any {
732
+ protected _exampleToObject(example?: IApiDataExample): any {
733
733
  if (example && example.structuredValue) {
734
734
  const generator = new XmlDataNodeGenerator();
735
735
  return generator.generate(example.structuredValue);
@@ -737,15 +737,15 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
737
737
  return undefined;
738
738
  }
739
739
 
740
- protected _unionShapeObject(schema: IUnionShape, options: IProcessNodeOptions={}): any {
740
+ protected _unionShapeObject(schema: IApiUnionShape, options: IProcessNodeOptions={}): any {
741
741
  let { anyOf=[], examples=[] } = schema;
742
742
  if (Array.isArray(schema.inherits) && schema.inherits) {
743
743
  schema.inherits.forEach((parent) => {
744
- const anyParent = parent as IAnyShape;
744
+ const anyParent = parent as IApiAnyShape;
745
745
  if (Array.isArray(anyParent.examples) && anyParent.examples.length) {
746
746
  examples = examples.concat(anyParent.examples);
747
747
  }
748
- const typed = parent as IUnionShape;
748
+ const typed = parent as IApiUnionShape;
749
749
  if (Array.isArray(typed.anyOf) && typed.anyOf.length) {
750
750
  anyOf = anyOf.concat(typed.anyOf);
751
751
  }
@@ -787,10 +787,10 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
787
787
  * @param schema The schema with unions
788
788
  * @param defaultValue The definition of a default value.
789
789
  */
790
- protected _unionDefaultValue(schema: IShapeUnion, defaultValue: IDataNodeUnion, options: IProcessNodeOptions = {}): any|undefined {
790
+ protected _unionDefaultValue(schema: IShapeUnion, defaultValue: IApiDataNodeUnion, options: IProcessNodeOptions = {}): any|undefined {
791
791
  const gen = new XmlDataNodeGenerator();
792
792
  const value = gen.generate(defaultValue);
793
- const anySchema = schema as IAnyShape;
793
+ const anySchema = schema as IApiAnyShape;
794
794
  const label = shapeToXmlTagName(anySchema);
795
795
  const currentIndent = (options.indent || 0);
796
796
  const rootFill = new Array(currentIndent*2).fill(' ').join('');
@@ -815,23 +815,23 @@ export class ShapeXmlSchemaGenerator extends ShapeBase {
815
815
  return undefined;
816
816
  }
817
817
 
818
- protected _anyShapeObject(schema: IAnyShape): string {
818
+ protected _anyShapeObject(schema: IApiAnyShape): string {
819
819
  const { and=[], xone=[], or=[] } = schema;
820
820
  if (and.length) {
821
821
  // we combine all properties together under `schema` with changed properties
822
- const copy = JsonCore.clone(schema) as INodeShape;
822
+ const copy = JsonCore.clone(schema) as IApiNodeShape;
823
823
  copy.and = [];
824
824
  copy.properties = [];
825
825
  and.forEach((item) => {
826
826
  const { types } = item;
827
827
  if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {
828
- const typed = item as IScalarShape;
828
+ const typed = item as IApiScalarShape;
829
829
  copy.properties.push(typed);
830
830
  } else if (types.includes(ns.w3.shacl.NodeShape)) {
831
- const typed = item as INodeShape;
831
+ const typed = item as IApiNodeShape;
832
832
  typed.properties.forEach(i => copy.properties.push(i));
833
833
  } else if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) || types.includes(ns.aml.vocabularies.shapes.MatrixShape)) {
834
- const typed = item as IArrayShape;
834
+ const typed = item as IApiArrayShape;
835
835
  if (typed.items) {
836
836
  copy.properties.push(typed.items)
837
837
  }
@@ -1,4 +1,4 @@
1
- import { ApiParseResult, AmfServiceProcessingOptions } from "../../amf/Parsing.js";
1
+ import { IApiParseResult, IAmfServiceProcessingOptions } from "../../amf/Parsing.js";
2
2
  import { ContextEvent } from "../BaseEvents.js";
3
3
  import { AmfEventTypes } from './AmfEventTypes.js'
4
4
 
@@ -12,12 +12,12 @@ export class AmfEvents {
12
12
  * @param packaging Default to `zip`.
13
13
  * @returns Promise resolved to the AMF json-ld model.
14
14
  */
15
- static async processApiLink(url: string, mainFile?: string, md5?: string, packaging?: string, target: EventTarget = window): Promise<ApiParseResult> {
15
+ static async processApiLink(url: string, mainFile?: string, md5?: string, packaging?: string, target: EventTarget = window): Promise<IApiParseResult> {
16
16
  const e = new ContextEvent(AmfEventTypes.processApiLink, {
17
17
  url, mainFile, md5, packaging,
18
18
  });
19
19
  target.dispatchEvent(e);
20
- return (e.detail.result as unknown) as Promise<ApiParseResult>;
20
+ return (e.detail.result as unknown) as Promise<IApiParseResult>;
21
21
  }
22
22
 
23
23
  /**
@@ -26,12 +26,12 @@ export class AmfEvents {
26
26
  * @param opts Processing options
27
27
  * @returns Promise resolved to the AMF json-ld model
28
28
  */
29
- static async processBuffer(buffer: Buffer, opts?: AmfServiceProcessingOptions, target: EventTarget = window): Promise<ApiParseResult> {
29
+ static async processBuffer(buffer: Buffer, opts?: IAmfServiceProcessingOptions, target: EventTarget = window): Promise<IApiParseResult> {
30
30
  const e = new ContextEvent(AmfEventTypes.processBuffer, {
31
31
  buffer, opts,
32
32
  });
33
33
  target.dispatchEvent(e);
34
- return (e.detail.result as unknown) as Promise<ApiParseResult>;
34
+ return (e.detail.result as unknown) as Promise<IApiParseResult>;
35
35
  }
36
36
 
37
37
  /**
@@ -42,12 +42,12 @@ export class AmfEvents {
42
42
  * @param file File to process.
43
43
  * @returns Promise resolved to the AMF json-ld model
44
44
  */
45
- static async processApiFile(file: File | Blob, target: EventTarget = window): Promise<ApiParseResult> {
45
+ static async processApiFile(file: File | Blob, target: EventTarget = window): Promise<IApiParseResult> {
46
46
  const e = new ContextEvent(AmfEventTypes.processApiFile, {
47
47
  file,
48
48
  });
49
49
  target.dispatchEvent(e);
50
- return (e.detail.result as unknown) as Promise<ApiParseResult>;
50
+ return (e.detail.result as unknown) as Promise<IApiParseResult>;
51
51
  }
52
52
 
53
53
  /**
@@ -7,3 +7,17 @@ export function sleep(timeout = 0): Promise<void> {
7
7
  setTimeout(() => resolve(), timeout);
8
8
  });
9
9
  }
10
+
11
+ /**
12
+ * Resolves after requestAnimationFrame.
13
+ *
14
+ * @example
15
+ * await nextFrame();
16
+ *
17
+ * @returns Promise that resolved after requestAnimationFrame
18
+ */
19
+ export function nextFrame(): Promise<void> {
20
+ return new Promise(resolve => {
21
+ requestAnimationFrame(() => resolve());
22
+ });
23
+ }
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable import/export */
2
- import { IXmlSerializer } from "../../amf/definitions/Shapes.js";
2
+ import { IApiXmlSerializer } from "../../amf/definitions/Shapes.js";
3
3
 
4
4
  /**
5
5
  * A general schema definition for a property. This is propagated to all bindings (when they support these properties).
@@ -76,7 +76,7 @@ export interface IPropertyWebBindings {
76
76
  /**
77
77
  * The XML encoding instructions.
78
78
  */
79
- xml?: IXmlSerializer;
79
+ xml?: IApiXmlSerializer;
80
80
  /**
81
81
  * Only valid for the `file` property type.
82
82
  * The list of file mime types.
@@ -1,6 +1,6 @@
1
1
  import { Core as JsonCore } from '@api-client/json';
2
2
  import { AmfShapeGenerator } from '../../amf/AmfShapeGenerator.js';
3
- import { IAssociationShape, IPropertyShape } from '../../amf/definitions/Shapes.js';
3
+ import { IApiAssociationShape, IApiPropertyShape } from '../../amf/definitions/Shapes.js';
4
4
  import v4 from '../../lib/uuid.js';
5
5
  import { IThing, Thing } from "../Thing.js";
6
6
  import { DataEntity, IDataEntity } from './DataEntity.js';
@@ -57,7 +57,7 @@ export interface IDataAssociation {
57
57
  * Note, schema can only occur on an adapted property. Has no effect on the "main"
58
58
  * property.
59
59
  */
60
- schema?: IAssociationShape;
60
+ schema?: IApiAssociationShape;
61
61
  /**
62
62
  * The key of the association that is adapted by this association.
63
63
  * Adapted associations can manipulate the shape of the schema for the association.
@@ -121,7 +121,7 @@ export class DataAssociation {
121
121
  * Note, schema can only occur on an adapted property. Has no effect on the "main"
122
122
  * property.
123
123
  */
124
- schema?: IAssociationShape;
124
+ schema?: IApiAssociationShape;
125
125
 
126
126
  /**
127
127
  * The key of the association that is adapted by this association.
@@ -355,7 +355,7 @@ export class DataAssociation {
355
355
  *
356
356
  * @returns AMF property shape definition.
357
357
  */
358
- toApiShape(): IPropertyShape {
358
+ toApiShape(): IApiPropertyShape {
359
359
  const serializer = new AmfShapeGenerator();
360
360
  return serializer.associationProperty(this);
361
361
  }
@@ -5,7 +5,7 @@ import { DataProperty, DataPropertyType } from "./DataProperty.js";
5
5
  import { DataAssociation } from "./DataAssociation.js";
6
6
  import { IBreadcrumb } from "../store/Breadcrumb.js";
7
7
  import { DataModel } from "./DataModel.js";
8
- import { INodeShape, IShapeUnion } from "../../amf/definitions/Shapes.js";
8
+ import { IApiNodeShape, IShapeUnion } from "../../amf/definitions/Shapes.js";
9
9
  import { AmfShapeGenerator } from "../../amf/AmfShapeGenerator.js";
10
10
  import { ApiSchemaGenerator } from "../../amf/ApiSchemaGenerator.js";
11
11
  import { IShapeRenderOptions } from "../../amf/shape/ShapeBase.js";
@@ -72,7 +72,7 @@ export interface IDataEntity {
72
72
  *
73
73
  * - can only occur on an adapted property. Has no effect on the "main" property.
74
74
  */
75
- schema?: INodeShape;
75
+ schema?: IApiNodeShape;
76
76
 
77
77
  /**
78
78
  * The key of the entity that is adapted by this entity.
@@ -2,7 +2,7 @@ import { Core as JsonCore } from '@api-client/json';
2
2
  import { IThing, Thing } from "../Thing.js";
3
3
  import v4 from '../../lib/uuid.js';
4
4
  import { DataNamespace } from "./DataNamespace.js";
5
- import { IPropertyShape } from "../../amf/definitions/Shapes.js";
5
+ import { IApiPropertyShape } from "../../amf/definitions/Shapes.js";
6
6
  import { AmfShapeGenerator } from '../../amf/AmfShapeGenerator.js';
7
7
  import { IPropertyBindings, IPropertySchema } from './Bindings.js';
8
8
 
@@ -478,7 +478,7 @@ export class DataProperty {
478
478
  *
479
479
  * @returns AMF property shape definition.
480
480
  */
481
- toApiShape(): IPropertyShape {
481
+ toApiShape(): IApiPropertyShape {
482
482
  const serializer = new AmfShapeGenerator();
483
483
  return serializer.property(this);
484
484
  }