@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.
- package/SECURITY.md +14 -0
- package/build/browser.d.ts +8 -1
- package/build/browser.js +7 -0
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +8 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/src/amf/AmfMixin.d.ts +56 -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 +3 -3
- 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.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/lib/timers/Timers.d.ts +9 -0
- package/build/src/lib/timers/Timers.js +13 -0
- package/build/src/lib/timers/Timers.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/data/apis/amf-helper-api/amf-helper-api.raml +1024 -0
- package/data/apis/amf-helper-api/examples/comment-example.json +42 -0
- package/data/apis/amf-helper-api/examples/commentCreateRequest-example.json +7 -0
- package/data/apis/amf-helper-api/examples/commentList-example.json +48 -0
- package/data/apis/amf-helper-api/examples/person.json +14 -0
- package/data/apis/amf-helper-api/examples/person.raml +13 -0
- package/data/apis/amf-helper-api/examples/person.xml +14 -0
- package/data/apis/amf-helper-api/libraries/comment-lib.raml +143 -0
- package/data/apis/amf-helper-api/library.raml +7 -0
- package/data/apis/amf-helper-api/schemas/person.json +104 -0
- package/data/apis/amf-helper-api/schemas/person.xsd +26 -0
- package/data/apis/amf-helper-api/traits/file.raml +33 -0
- package/data/apis/amf-helper-api/traits/pagination.raml +80 -0
- package/data/apis/amf-helper-api/traits/results.raml +19 -0
- package/data/apis/amf-helper-api/traits/visibility.raml +14 -0
- package/data/apis/amf-helper-api/types/app-person.raml +101 -0
- package/data/apis/amf-helper-api/types/dimensions.raml +24 -0
- package/data/apis/amf-helper-api/types/external-type.raml +7 -0
- package/data/apis/amf-helper-api/types/image.raml +23 -0
- package/data/apis/amf-helper-api/types/product.raml +52 -0
- package/data/apis/amf-helper-api/types/resource.raml +11 -0
- package/data/apis/amf-helper-api/types/standard-request.raml +50 -0
- package/data/apis/amf-helper-api/types/user.raml +37 -0
- package/data/apis/async-api/async-api.yaml +96 -0
- package/data/apis/expanded-api/expanded-api.raml +8 -0
- package/data/apis/flattened-api/flattened-api.raml +8 -0
- package/data/apis/multiple-servers/multiple-servers.yaml +112 -0
- package/data/model.js +5 -0
- package/data/models/amf-helper-api.json +85908 -0
- package/data/models/async-api.json +3108 -0
- package/data/models/expanded-api.json +251 -0
- package/data/models/flattened-api.json +251 -0
- package/data/models/multiple-servers.json +2753 -0
- package/package.json +1 -1
- package/src/amf/AmfMixin.ts +125 -117
- package/src/amf/AmfSerializer.ts +245 -240
- package/src/amf/AmfShapeGenerator.ts +23 -23
- 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 +42 -42
- package/src/events/amf/AmfEvents.ts +7 -7
- package/src/lib/timers/Timers.ts +14 -0
- 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/amf/AmfMixin.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
1
5
|
/**
|
|
2
6
|
@license
|
|
3
7
|
Copyright 2018 The Advanced REST client authors <arc@mulesoft.com>
|
|
@@ -11,9 +15,10 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
11
15
|
License for the specific language governing permissions and limitations under
|
|
12
16
|
the License.
|
|
13
17
|
*/
|
|
18
|
+
|
|
14
19
|
// @ts-ignore
|
|
15
20
|
import { AmfModelExpander, JsonLdOptions, JsonLd } from 'amf-json-ld-lib';
|
|
16
|
-
import {
|
|
21
|
+
import { IAmfDocument, IAmfDomainElement, IAmfEndPoint, IAmfLdValue, IAmfSecurityScheme, IAmfShape, IAmfWebApi, IAmfOperation, IAmfAsyncApi, IAmfServer, IAmfRequest } from './definitions/Amf.js';
|
|
17
22
|
import { AmfNamespace as ns } from './definitions/Namespace.js';
|
|
18
23
|
|
|
19
24
|
export const expandKey = Symbol('expandKey');
|
|
@@ -51,14 +56,15 @@ export interface ServerQueryOptions {
|
|
|
51
56
|
type Constructor<T = {}> = new (...args: any[]) => T;
|
|
52
57
|
|
|
53
58
|
export declare class AmfMixinInterface {
|
|
54
|
-
amf?:
|
|
59
|
+
amf?: IAmfDocument;
|
|
60
|
+
_amf?: IAmfDocument;
|
|
55
61
|
/**
|
|
56
62
|
* This is an abstract method to be implemented by the components.
|
|
57
63
|
* If, instead, the component uses `amf` setter you must use `super.amf` to
|
|
58
64
|
* set the value.
|
|
59
65
|
* @param amf Current AMF model. Can be undefined.
|
|
60
66
|
*/
|
|
61
|
-
_amfChanged(amf?:
|
|
67
|
+
_amfChanged(amf?: IAmfDocument): void;
|
|
62
68
|
|
|
63
69
|
/**
|
|
64
70
|
* Expands flattened AMF model
|
|
@@ -71,7 +77,7 @@ export declare class AmfMixinInterface {
|
|
|
71
77
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
72
78
|
* @returns Compact model property name or the same value if value not found in the context.
|
|
73
79
|
*/
|
|
74
|
-
_getAmfKey(property?: string, context?: Record<string, string>): string
|
|
80
|
+
_getAmfKey(property?: string, context?: Record<string, string>): string;
|
|
75
81
|
|
|
76
82
|
/**
|
|
77
83
|
* Ensures that the model is AMF object.
|
|
@@ -79,7 +85,7 @@ export declare class AmfMixinInterface {
|
|
|
79
85
|
* @param amf AMF json/ld model
|
|
80
86
|
* @returns The API spec
|
|
81
87
|
*/
|
|
82
|
-
_ensureAmfModel(amf: any):
|
|
88
|
+
_ensureAmfModel(amf: any): IAmfDocument | undefined;
|
|
83
89
|
|
|
84
90
|
/**
|
|
85
91
|
* Ensures that the value is an array.
|
|
@@ -98,7 +104,7 @@ export declare class AmfMixinInterface {
|
|
|
98
104
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
99
105
|
* @returns Value for key
|
|
100
106
|
*/
|
|
101
|
-
_getValue(model:
|
|
107
|
+
_getValue(model: IAmfDomainElement, untrustedKey: string, context?: Record<string, string>): string | number | boolean | undefined | null;
|
|
102
108
|
|
|
103
109
|
/**
|
|
104
110
|
* Gets values from a model as an array of `@value` properties.
|
|
@@ -107,7 +113,7 @@ export declare class AmfMixinInterface {
|
|
|
107
113
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
108
114
|
* @returns The value for key
|
|
109
115
|
*/
|
|
110
|
-
_getValueArray(model:
|
|
116
|
+
_getValueArray(model: IAmfDomainElement, untrustedKey: string, context?: Record<string, string>): (string | number | boolean | null)[] | undefined;
|
|
111
117
|
|
|
112
118
|
/**
|
|
113
119
|
* Reads an array from the model.
|
|
@@ -117,7 +123,7 @@ export declare class AmfMixinInterface {
|
|
|
117
123
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
118
124
|
* @returns Value for the key
|
|
119
125
|
*/
|
|
120
|
-
[getArrayItems](model?:
|
|
126
|
+
[getArrayItems](model?: IAmfDomainElement, untrustedKey?: string, context?: Record<string, string>): IAmfDomainElement[] | undefined;
|
|
121
127
|
|
|
122
128
|
/**
|
|
123
129
|
* Reads the value of the `@id` property.
|
|
@@ -125,7 +131,7 @@ export declare class AmfMixinInterface {
|
|
|
125
131
|
* @param untrustedKey Model key to search for the @id
|
|
126
132
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
127
133
|
*/
|
|
128
|
-
_getLinkValue(model:
|
|
134
|
+
_getLinkValue(model: IAmfDomainElement, untrustedKey: string, context?: Record<string, string>): string | undefined;
|
|
129
135
|
|
|
130
136
|
/**
|
|
131
137
|
* Reads the list of value for the `@id` property.
|
|
@@ -133,7 +139,7 @@ export declare class AmfMixinInterface {
|
|
|
133
139
|
* @param untrustedKey Model key to search for the @id
|
|
134
140
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
135
141
|
*/
|
|
136
|
-
_getLinkValues(model:
|
|
142
|
+
_getLinkValues(model: IAmfDomainElement, untrustedKey: string, context?: Record<string, string>): string[] | undefined;
|
|
137
143
|
|
|
138
144
|
/**
|
|
139
145
|
* Checks if a model has a type.
|
|
@@ -142,7 +148,7 @@ export declare class AmfMixinInterface {
|
|
|
142
148
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
143
149
|
* @returns True if model has a type.
|
|
144
150
|
*/
|
|
145
|
-
_hasType(model?:
|
|
151
|
+
_hasType(model?: IAmfDomainElement, type?: string, context?: Record<string, string>): boolean;
|
|
146
152
|
|
|
147
153
|
/**
|
|
148
154
|
* Checks if a shape has a property.
|
|
@@ -150,7 +156,7 @@ export declare class AmfMixinInterface {
|
|
|
150
156
|
* @param untrustedKey Property name to test
|
|
151
157
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
152
158
|
*/
|
|
153
|
-
_hasProperty(shape:
|
|
159
|
+
_hasProperty(shape: IAmfDomainElement, untrustedKey: string, context?: Record<string, string>): boolean;
|
|
154
160
|
|
|
155
161
|
/**
|
|
156
162
|
* Computes array value of a property in a model (shape).
|
|
@@ -159,7 +165,7 @@ export declare class AmfMixinInterface {
|
|
|
159
165
|
* @param untrustedKey Property name
|
|
160
166
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
161
167
|
*/
|
|
162
|
-
_computePropertyArray(shape?:
|
|
168
|
+
_computePropertyArray(shape?: IAmfDomainElement, untrustedKey?: string, context?: Record<string, string>): (string | number | boolean | null | Object)[] | undefined;
|
|
163
169
|
|
|
164
170
|
/**
|
|
165
171
|
* Computes API version from the AMF model.
|
|
@@ -167,7 +173,7 @@ export declare class AmfMixinInterface {
|
|
|
167
173
|
* @param amf
|
|
168
174
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
169
175
|
*/
|
|
170
|
-
_computeApiVersion(amf?:
|
|
176
|
+
_computeApiVersion(amf?: IAmfDocument, context?: Record<string, string>): string | undefined;
|
|
171
177
|
|
|
172
178
|
/**
|
|
173
179
|
* Computes model's `encodes` property.
|
|
@@ -176,7 +182,7 @@ export declare class AmfMixinInterface {
|
|
|
176
182
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
177
183
|
* @returns List of encodes
|
|
178
184
|
*/
|
|
179
|
-
_computeEncodes(model?:
|
|
185
|
+
_computeEncodes(model?: IAmfDocument, context?: Record<string, string>): IAmfDomainElement | undefined;
|
|
180
186
|
|
|
181
187
|
/**
|
|
182
188
|
* Computes list of declarations in the AMF api model.
|
|
@@ -185,7 +191,7 @@ export declare class AmfMixinInterface {
|
|
|
185
191
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
186
192
|
* @returns List of declarations
|
|
187
193
|
*/
|
|
188
|
-
_computeDeclares(model?:
|
|
194
|
+
_computeDeclares(model?: IAmfDocument, context?: Record<string, string>): IAmfDomainElement[] | undefined;
|
|
189
195
|
|
|
190
196
|
/**
|
|
191
197
|
* Computes list of references in the AMF api model.
|
|
@@ -194,7 +200,7 @@ export declare class AmfMixinInterface {
|
|
|
194
200
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
195
201
|
* @returns List of declarations
|
|
196
202
|
*/
|
|
197
|
-
_computeReferences(model?:
|
|
203
|
+
_computeReferences(model?: IAmfDocument, context?: Record<string, string>): IAmfDomainElement[] | undefined;
|
|
198
204
|
|
|
199
205
|
/**
|
|
200
206
|
* Computes AMF's `http://schema.org/WebAPI` model
|
|
@@ -203,7 +209,7 @@ export declare class AmfMixinInterface {
|
|
|
203
209
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
204
210
|
* @returns Web API declaration.
|
|
205
211
|
*/
|
|
206
|
-
_computeWebApi(model?:
|
|
212
|
+
_computeWebApi(model?: IAmfDocument, context?: Record<string, string>): IAmfWebApi | undefined;
|
|
207
213
|
|
|
208
214
|
/**
|
|
209
215
|
* Computes AMF's `http://schema.org/API` model
|
|
@@ -212,7 +218,7 @@ export declare class AmfMixinInterface {
|
|
|
212
218
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
213
219
|
* @returns API declaration.
|
|
214
220
|
*/
|
|
215
|
-
_computeApi(model?:
|
|
221
|
+
_computeApi(model?: IAmfDocument, context?: Record<string, string>): IAmfAsyncApi | IAmfWebApi | undefined;
|
|
216
222
|
|
|
217
223
|
/**
|
|
218
224
|
* Returns whether an AMF node is a WebAPI node
|
|
@@ -220,7 +226,7 @@ export declare class AmfMixinInterface {
|
|
|
220
226
|
* @param model AMF json/ld model for an API
|
|
221
227
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
222
228
|
*/
|
|
223
|
-
_isWebAPI(model?:
|
|
229
|
+
_isWebAPI(model?: IAmfDocument, context?: Record<string, string>): boolean;
|
|
224
230
|
|
|
225
231
|
/**
|
|
226
232
|
* Returns whether an AMF node is an AsyncAPI node
|
|
@@ -228,7 +234,7 @@ export declare class AmfMixinInterface {
|
|
|
228
234
|
* @param model AMF json/ld model for an API
|
|
229
235
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
230
236
|
*/
|
|
231
|
-
_isAsyncAPI(model?:
|
|
237
|
+
_isAsyncAPI(model?: IAmfDocument, context?: Record<string, string>): boolean;
|
|
232
238
|
|
|
233
239
|
/**
|
|
234
240
|
* Returns whether an AMF node is an API node
|
|
@@ -236,7 +242,7 @@ export declare class AmfMixinInterface {
|
|
|
236
242
|
* @param model AMF json/ld model for an API
|
|
237
243
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
238
244
|
*/
|
|
239
|
-
_isAPI(model?:
|
|
245
|
+
_isAPI(model?: IAmfDocument, context?: Record<string, string>): boolean;
|
|
240
246
|
|
|
241
247
|
/**
|
|
242
248
|
* Determines whether a partial model is valid for reading servers from
|
|
@@ -249,14 +255,14 @@ export declare class AmfMixinInterface {
|
|
|
249
255
|
* to read servers
|
|
250
256
|
* @private
|
|
251
257
|
*/
|
|
252
|
-
_isValidServerPartial(model:
|
|
258
|
+
_isValidServerPartial(model: IAmfDomainElement | IAmfDomainElement[], context?: Record<string, string>): boolean;
|
|
253
259
|
|
|
254
260
|
/**
|
|
255
261
|
* @param options Server query options
|
|
256
262
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
257
263
|
* @returns List of servers for method, if defined, or endpoint, if defined, or root level
|
|
258
264
|
*/
|
|
259
|
-
_getServers(options?: ServersQueryOptions, context?: Record<string, string>):
|
|
265
|
+
_getServers(options?: ServersQueryOptions, context?: Record<string, string>): IAmfServer[] | undefined;
|
|
260
266
|
|
|
261
267
|
/**
|
|
262
268
|
* Computes value for the `expects` property.
|
|
@@ -264,7 +270,7 @@ export declare class AmfMixinInterface {
|
|
|
264
270
|
* @param method AMF `supportedOperation` model
|
|
265
271
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
266
272
|
*/
|
|
267
|
-
_computeExpects(method?:
|
|
273
|
+
_computeExpects(method?: IAmfOperation, context?: Record<string, string>): IAmfRequest | undefined;
|
|
268
274
|
|
|
269
275
|
/**
|
|
270
276
|
* Computes list of endpoints from a WebApi model.
|
|
@@ -272,7 +278,7 @@ export declare class AmfMixinInterface {
|
|
|
272
278
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
273
279
|
* @returns An array of endpoints.
|
|
274
280
|
*/
|
|
275
|
-
_computeEndpoints(webApi?:
|
|
281
|
+
_computeEndpoints(webApi?: IAmfWebApi, context?: Record<string, string>): IAmfEndPoint[] | undefined;
|
|
276
282
|
/**
|
|
277
283
|
* Computes model for an endpoint documentation.
|
|
278
284
|
*
|
|
@@ -281,7 +287,7 @@ export declare class AmfMixinInterface {
|
|
|
281
287
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
282
288
|
* @returns An endpoint definition
|
|
283
289
|
*/
|
|
284
|
-
_computeEndpointModel(webApi?:
|
|
290
|
+
_computeEndpointModel(webApi?: IAmfWebApi, id?: string, context?: Record<string, string>): IAmfEndPoint | undefined;
|
|
285
291
|
|
|
286
292
|
/**
|
|
287
293
|
* Computes method for the method documentation.
|
|
@@ -291,7 +297,7 @@ export declare class AmfMixinInterface {
|
|
|
291
297
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
292
298
|
* @returns A method definition
|
|
293
299
|
*/
|
|
294
|
-
_computeMethodModel(webApi?:
|
|
300
|
+
_computeMethodModel(webApi?: IAmfWebApi, selected?: string, context?: Record<string, string>): IAmfOperation | undefined;
|
|
295
301
|
|
|
296
302
|
/**
|
|
297
303
|
* Computes an endpoint for a method.
|
|
@@ -300,7 +306,7 @@ export declare class AmfMixinInterface {
|
|
|
300
306
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
301
307
|
* @returns An endpoint model of undefined.
|
|
302
308
|
*/
|
|
303
|
-
_computeMethodEndpoint(webApi?:
|
|
309
|
+
_computeMethodEndpoint(webApi?: IAmfWebApi, methodId?: string, context?: Record<string, string>): IAmfEndPoint | undefined;
|
|
304
310
|
|
|
305
311
|
/**
|
|
306
312
|
* Computes a list of methods for an endpoint that contains a method with
|
|
@@ -311,7 +317,7 @@ export declare class AmfMixinInterface {
|
|
|
311
317
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
312
318
|
* @returns A list of sibling methods or undefined.
|
|
313
319
|
*/
|
|
314
|
-
__computeMethodsListForMethod(webApi?:
|
|
320
|
+
__computeMethodsListForMethod(webApi?: IAmfWebApi, methodId?: string, context?: Record<string, string>): IAmfOperation[] | undefined;
|
|
315
321
|
|
|
316
322
|
/**
|
|
317
323
|
* Computes a type documentation model.
|
|
@@ -322,7 +328,7 @@ export declare class AmfMixinInterface {
|
|
|
322
328
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
323
329
|
* @returns A type definition
|
|
324
330
|
*/
|
|
325
|
-
_computeType(declares?:
|
|
331
|
+
_computeType(declares?: IAmfDomainElement[], references?: IAmfDomainElement[], selected?: string, context?: Record<string, string>): IAmfShape | undefined;
|
|
326
332
|
|
|
327
333
|
/**
|
|
328
334
|
* Finds a type in the model declares and references.
|
|
@@ -330,7 +336,7 @@ export declare class AmfMixinInterface {
|
|
|
330
336
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
331
337
|
* @returns The AMF shape or undefined when not found.
|
|
332
338
|
*/
|
|
333
|
-
[findAmfType](domainId?: string, context?: Record<string, string>):
|
|
339
|
+
[findAmfType](domainId?: string, context?: Record<string, string>): IAmfShape | undefined;
|
|
334
340
|
|
|
335
341
|
/**
|
|
336
342
|
* Searches for an object in model's references list.
|
|
@@ -340,7 +346,7 @@ export declare class AmfMixinInterface {
|
|
|
340
346
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
341
347
|
* @returns The domain object or undefined.
|
|
342
348
|
*/
|
|
343
|
-
[findReferenceObject](domainId: string, context?: Record<string, string>):
|
|
349
|
+
[findReferenceObject](domainId: string, context?: Record<string, string>): IAmfDomainElement | undefined;
|
|
344
350
|
|
|
345
351
|
/**
|
|
346
352
|
* Computes a type model from a reference (library for example).
|
|
@@ -349,7 +355,7 @@ export declare class AmfMixinInterface {
|
|
|
349
355
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
350
356
|
* @returns Type definition or undefined if not found.
|
|
351
357
|
*/
|
|
352
|
-
_computeReferenceType(reference?:
|
|
358
|
+
_computeReferenceType(reference?: IAmfDomainElement, selected?: string, context?: Record<string, string>): IAmfShape | undefined;
|
|
353
359
|
|
|
354
360
|
/**
|
|
355
361
|
* Computes a documentation model.
|
|
@@ -358,7 +364,7 @@ export declare class AmfMixinInterface {
|
|
|
358
364
|
* @param selected Selected shape
|
|
359
365
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
360
366
|
*/
|
|
361
|
-
_computeDocument(webApi?:
|
|
367
|
+
_computeDocument(webApi?: IAmfDomainElement, selected?: string, context?: Record<string, string>): IAmfDomainElement | undefined;
|
|
362
368
|
|
|
363
369
|
/**
|
|
364
370
|
* Resolves a reference to an external fragment.
|
|
@@ -375,7 +381,7 @@ export declare class AmfMixinInterface {
|
|
|
375
381
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
376
382
|
* @returns Resolved shape for given reference, undefined otherwise
|
|
377
383
|
*/
|
|
378
|
-
_getLinkTarget(amf?:
|
|
384
|
+
_getLinkTarget(amf?: IAmfDocument, id?: string, context?: Record<string, string>): IAmfDomainElement | undefined;
|
|
379
385
|
|
|
380
386
|
/**
|
|
381
387
|
* Resolves the shape of a given reference.
|
|
@@ -385,7 +391,7 @@ export declare class AmfMixinInterface {
|
|
|
385
391
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
386
392
|
* @returns Resolved shape for given reference, undefined otherwise
|
|
387
393
|
*/
|
|
388
|
-
_obtainShapeFromReferences(references?:
|
|
394
|
+
_obtainShapeFromReferences(references?: IAmfDomainElement[], id?: string, context?: Record<string, string>): IAmfDomainElement | undefined;
|
|
389
395
|
|
|
390
396
|
/**
|
|
391
397
|
* Searches a node with a given ID in an array
|
|
@@ -394,9 +400,9 @@ export declare class AmfMixinInterface {
|
|
|
394
400
|
* @param id Id to search for
|
|
395
401
|
* @returns Node with the given ID when found, undefined otherwise
|
|
396
402
|
*/
|
|
397
|
-
_findById(array?:
|
|
403
|
+
_findById(array?: IAmfDomainElement[], id?: string): IAmfDomainElement | undefined;
|
|
398
404
|
|
|
399
|
-
_getReferenceId(amf?:
|
|
405
|
+
_getReferenceId(amf?: IAmfDocument, id?: string, context?: Record<string, string>): IAmfDomainElement | undefined;
|
|
400
406
|
|
|
401
407
|
_resolveRecursive(shape: any, context?: Record<string, string>): void;
|
|
402
408
|
|
|
@@ -435,7 +441,7 @@ export declare class AmfMixinInterface {
|
|
|
435
441
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
436
442
|
* @returns Type definition or undefined if not found.
|
|
437
443
|
*/
|
|
438
|
-
findSecurityScheme(domainId: string, context?: Record<string, string>):
|
|
444
|
+
findSecurityScheme(domainId: string, context?: Record<string, string>): IAmfSecurityScheme | undefined;
|
|
439
445
|
|
|
440
446
|
/**
|
|
441
447
|
* Computes a security model from a reference (library for example).
|
|
@@ -444,7 +450,7 @@ export declare class AmfMixinInterface {
|
|
|
444
450
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
445
451
|
* @returns Type definition or undefined if not found.
|
|
446
452
|
*/
|
|
447
|
-
[computeReferenceSecurity](reference:
|
|
453
|
+
[computeReferenceSecurity](reference: IAmfDomainElement, selected: string, context?: Record<string, string>): IAmfSecurityScheme | undefined;
|
|
448
454
|
|
|
449
455
|
/**
|
|
450
456
|
* Collects domain objects by a domain type.
|
|
@@ -452,7 +458,7 @@ export declare class AmfMixinInterface {
|
|
|
452
458
|
* @param type The domain type
|
|
453
459
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
454
460
|
*/
|
|
455
|
-
getByType(source:
|
|
461
|
+
getByType(source: IAmfDomainElement, type: string, context?: Record<string, string>): IAmfDomainElement[];
|
|
456
462
|
}
|
|
457
463
|
|
|
458
464
|
/**
|
|
@@ -460,15 +466,15 @@ export declare class AmfMixinInterface {
|
|
|
460
466
|
*/
|
|
461
467
|
export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor<AmfMixinInterface> & T => {
|
|
462
468
|
class AmfMixin extends superClass {
|
|
463
|
-
_amf?:
|
|
469
|
+
_amf?: IAmfDocument;
|
|
464
470
|
_flattenedAmf?: any;
|
|
465
471
|
__cachedKeys?: any;
|
|
466
472
|
|
|
467
|
-
get amf():
|
|
473
|
+
get amf(): IAmfDocument | undefined {
|
|
468
474
|
return this._amf;
|
|
469
475
|
}
|
|
470
476
|
|
|
471
|
-
set amf(value:
|
|
477
|
+
set amf(value: IAmfDocument | undefined) {
|
|
472
478
|
const old = this._amf;
|
|
473
479
|
if (old === value) {
|
|
474
480
|
return;
|
|
@@ -499,7 +505,9 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
499
505
|
* @param amf Current AMF model. Can be undefined.
|
|
500
506
|
*/
|
|
501
507
|
/* eslint-disable-next-line no-unused-vars */
|
|
502
|
-
_amfChanged(amf?:
|
|
508
|
+
_amfChanged(amf?: IAmfDocument): void {
|
|
509
|
+
// ...
|
|
510
|
+
}
|
|
503
511
|
|
|
504
512
|
/**
|
|
505
513
|
* Expands flattened AMF model
|
|
@@ -522,9 +530,9 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
522
530
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
523
531
|
* @returns Compact model property name or the same value if value not found in the context.
|
|
524
532
|
*/
|
|
525
|
-
_getAmfKey(property?: string, context?: Record<string, string>): string
|
|
533
|
+
_getAmfKey(property?: string, context?: Record<string, string>): string {
|
|
526
534
|
if (!property) {
|
|
527
|
-
return
|
|
535
|
+
return '';
|
|
528
536
|
}
|
|
529
537
|
let { amf } = this;
|
|
530
538
|
if (!amf && !context) {
|
|
@@ -572,7 +580,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
572
580
|
* @param amf AMF json/ld model
|
|
573
581
|
* @returns The API spec
|
|
574
582
|
*/
|
|
575
|
-
_ensureAmfModel(amf: any):
|
|
583
|
+
_ensureAmfModel(amf: any): IAmfDocument | undefined {
|
|
576
584
|
if (!amf) {
|
|
577
585
|
return undefined;
|
|
578
586
|
}
|
|
@@ -610,12 +618,12 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
610
618
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
611
619
|
* @returns Value for key
|
|
612
620
|
*/
|
|
613
|
-
_getValue(model:
|
|
621
|
+
_getValue(model: IAmfDomainElement, untrustedKey: string, context?: Record<string, string>): string | number | boolean | undefined | null {
|
|
614
622
|
const key = this._getAmfKey(untrustedKey, context);
|
|
615
623
|
if (!key) {
|
|
616
624
|
return undefined;
|
|
617
625
|
}
|
|
618
|
-
let data = model && model[key as keyof
|
|
626
|
+
let data = model && model[key as keyof IAmfDomainElement] as string | number | boolean | undefined | null;
|
|
619
627
|
if (!data) {
|
|
620
628
|
// This includes "undefined", "false", "null" and "0"
|
|
621
629
|
return data;
|
|
@@ -630,7 +638,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
630
638
|
if (['string', 'number', 'boolean', 'undefined'].includes(type)) {
|
|
631
639
|
return data;
|
|
632
640
|
}
|
|
633
|
-
return ((data as unknown) as
|
|
641
|
+
return ((data as unknown) as IAmfLdValue<any>)['@value'];
|
|
634
642
|
}
|
|
635
643
|
|
|
636
644
|
/**
|
|
@@ -640,7 +648,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
640
648
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
641
649
|
* @returns The value for key
|
|
642
650
|
*/
|
|
643
|
-
_getValueArray(model:
|
|
651
|
+
_getValueArray(model: IAmfDomainElement, untrustedKey: string, context?: Record<string, string>): (string | number | boolean | null)[] | undefined {
|
|
644
652
|
const key = this._getAmfKey(untrustedKey, context);
|
|
645
653
|
if (!key) {
|
|
646
654
|
return undefined;
|
|
@@ -660,12 +668,12 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
660
668
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
661
669
|
* @returns Value for the key
|
|
662
670
|
*/
|
|
663
|
-
[getArrayItems](model?:
|
|
671
|
+
[getArrayItems](model?: IAmfDomainElement, untrustedKey?: string, context?: Record<string, string>): IAmfDomainElement[] | undefined {
|
|
664
672
|
const k = this._getAmfKey(untrustedKey, context);
|
|
665
673
|
if (!k) {
|
|
666
674
|
return undefined;
|
|
667
675
|
}
|
|
668
|
-
const data = model && this._ensureArray((model as any)[k]) as
|
|
676
|
+
const data = model && this._ensureArray((model as any)[k]) as IAmfDomainElement[];
|
|
669
677
|
if (!Array.isArray(data)) {
|
|
670
678
|
return undefined;
|
|
671
679
|
}
|
|
@@ -678,7 +686,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
678
686
|
* @param untrustedKey Model key to search for the @id
|
|
679
687
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
680
688
|
*/
|
|
681
|
-
_getLinkValue(model:
|
|
689
|
+
_getLinkValue(model: IAmfDomainElement, untrustedKey: string, context?: Record<string, string>): string | undefined {
|
|
682
690
|
const k = this._getAmfKey(untrustedKey, context);
|
|
683
691
|
if (!k) {
|
|
684
692
|
return undefined;
|
|
@@ -702,12 +710,12 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
702
710
|
* @param untrustedKey Model key to search for the @id
|
|
703
711
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
704
712
|
*/
|
|
705
|
-
_getLinkValues(model:
|
|
713
|
+
_getLinkValues(model: IAmfDomainElement, untrustedKey: string, context?: Record<string, string>): string[] | undefined {
|
|
706
714
|
const k = this._getAmfKey(untrustedKey, context);
|
|
707
715
|
if (!k) {
|
|
708
716
|
return undefined;
|
|
709
717
|
}
|
|
710
|
-
let data = (model && (model as any)[k]) as
|
|
718
|
+
let data = (model && (model as any)[k]) as IAmfDomainElement[] | undefined;
|
|
711
719
|
if (!data) {
|
|
712
720
|
return undefined;
|
|
713
721
|
}
|
|
@@ -724,7 +732,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
724
732
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
725
733
|
* @returns True if model has a type.
|
|
726
734
|
*/
|
|
727
|
-
_hasType(model?:
|
|
735
|
+
_hasType(model?: IAmfDomainElement, type?: string, context?: Record<string, string>): boolean {
|
|
728
736
|
const types = this._ensureArray(model && model['@type']);
|
|
729
737
|
if (!types || !types.length) {
|
|
730
738
|
return false;
|
|
@@ -744,8 +752,8 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
744
752
|
* @param untrustedKey Property name to test
|
|
745
753
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
746
754
|
*/
|
|
747
|
-
_hasProperty(shape:
|
|
748
|
-
const key = this._getAmfKey(untrustedKey, context)
|
|
755
|
+
_hasProperty(shape: IAmfDomainElement, untrustedKey: string, context?: Record<string, string>): boolean {
|
|
756
|
+
const key = this._getAmfKey(untrustedKey, context) as string;
|
|
749
757
|
return !!(shape && key && key in shape);
|
|
750
758
|
}
|
|
751
759
|
|
|
@@ -756,7 +764,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
756
764
|
* @param untrustedKey Property name
|
|
757
765
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
758
766
|
*/
|
|
759
|
-
_computePropertyArray(shape?:
|
|
767
|
+
_computePropertyArray(shape?: IAmfDomainElement, untrustedKey?: string, context?: Record<string, string>): (string | number | boolean | null | Object)[] | undefined {
|
|
760
768
|
if (!shape) {
|
|
761
769
|
return undefined;
|
|
762
770
|
}
|
|
@@ -778,7 +786,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
778
786
|
* @param amf
|
|
779
787
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
780
788
|
*/
|
|
781
|
-
_computeApiVersion(amf?:
|
|
789
|
+
_computeApiVersion(amf?: IAmfDocument, context?: Record<string, string>): string | undefined {
|
|
782
790
|
const api = this._computeApi(amf);
|
|
783
791
|
if (!api) {
|
|
784
792
|
return undefined;
|
|
@@ -793,7 +801,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
793
801
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
794
802
|
* @returns List of encodes
|
|
795
803
|
*/
|
|
796
|
-
_computeEncodes(model?:
|
|
804
|
+
_computeEncodes(model?: IAmfDocument, context?: Record<string, string>): IAmfDomainElement | undefined {
|
|
797
805
|
if (!model) {
|
|
798
806
|
return undefined;
|
|
799
807
|
}
|
|
@@ -818,7 +826,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
818
826
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
819
827
|
* @returns List of declarations
|
|
820
828
|
*/
|
|
821
|
-
_computeDeclares(model?:
|
|
829
|
+
_computeDeclares(model?: IAmfDocument, context?: Record<string, string>): IAmfDomainElement[] | undefined {
|
|
822
830
|
if (!model) {
|
|
823
831
|
return undefined;
|
|
824
832
|
}
|
|
@@ -832,7 +840,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
832
840
|
if (!key) {
|
|
833
841
|
return undefined;
|
|
834
842
|
}
|
|
835
|
-
const data = this._ensureArray((model as any)[key]) as
|
|
843
|
+
const data = this._ensureArray((model as any)[key]) as IAmfDomainElement[];
|
|
836
844
|
return Array.isArray(data) ? data : undefined;
|
|
837
845
|
}
|
|
838
846
|
|
|
@@ -843,7 +851,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
843
851
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
844
852
|
* @returns List of declarations
|
|
845
853
|
*/
|
|
846
|
-
_computeReferences(model?:
|
|
854
|
+
_computeReferences(model?: IAmfDocument, context?: Record<string, string>): IAmfDomainElement[] | undefined {
|
|
847
855
|
if (!model) {
|
|
848
856
|
return undefined;
|
|
849
857
|
}
|
|
@@ -857,7 +865,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
857
865
|
if (!key) {
|
|
858
866
|
return undefined;
|
|
859
867
|
}
|
|
860
|
-
const data = this._ensureArray((model as any)[key]) as
|
|
868
|
+
const data = this._ensureArray((model as any)[key]) as IAmfDomainElement[];
|
|
861
869
|
return data instanceof Array ? data : undefined;
|
|
862
870
|
}
|
|
863
871
|
|
|
@@ -868,7 +876,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
868
876
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
869
877
|
* @returns Web API declaration.
|
|
870
878
|
*/
|
|
871
|
-
_computeWebApi(model?:
|
|
879
|
+
_computeWebApi(model?: IAmfDocument, context?: Record<string, string>): IAmfWebApi | undefined {
|
|
872
880
|
const enc = this._computeEncodes(model, context);
|
|
873
881
|
if (!enc) {
|
|
874
882
|
return undefined;
|
|
@@ -886,7 +894,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
886
894
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
887
895
|
* @returns API declaration.
|
|
888
896
|
*/
|
|
889
|
-
_computeApi(model?:
|
|
897
|
+
_computeApi(model?: IAmfDocument, context?: Record<string, string>): IAmfAsyncApi | IAmfWebApi | undefined {
|
|
890
898
|
const enc = this._computeEncodes(model, context);
|
|
891
899
|
if (!enc) {
|
|
892
900
|
return undefined;
|
|
@@ -903,7 +911,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
903
911
|
* @param model AMF json/ld model for an API
|
|
904
912
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
905
913
|
*/
|
|
906
|
-
_isWebAPI(model?:
|
|
914
|
+
_isWebAPI(model?: IAmfDocument, context?: Record<string, string>): boolean {
|
|
907
915
|
const enc = this._computeEncodes(model, context);
|
|
908
916
|
if (!enc) {
|
|
909
917
|
return false;
|
|
@@ -917,7 +925,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
917
925
|
* @param model AMF json/ld model for an API
|
|
918
926
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
919
927
|
*/
|
|
920
|
-
_isAsyncAPI(model?:
|
|
928
|
+
_isAsyncAPI(model?: IAmfDocument, context?: Record<string, string>): boolean {
|
|
921
929
|
const enc = this._computeEncodes(model, context);
|
|
922
930
|
if (!enc) {
|
|
923
931
|
return false;
|
|
@@ -931,7 +939,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
931
939
|
* @param model AMF json/ld model for an API
|
|
932
940
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
933
941
|
*/
|
|
934
|
-
_isAPI(model?:
|
|
942
|
+
_isAPI(model?: IAmfDocument, context?: Record<string, string>): boolean {
|
|
935
943
|
const enc = this._computeEncodes(model, context);
|
|
936
944
|
if (!enc) {
|
|
937
945
|
return false;
|
|
@@ -950,7 +958,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
950
958
|
* to read servers
|
|
951
959
|
* @private
|
|
952
960
|
*/
|
|
953
|
-
_isValidServerPartial(model:
|
|
961
|
+
_isValidServerPartial(model: IAmfDomainElement | IAmfDomainElement[], context?: Record<string, string>): boolean {
|
|
954
962
|
if (Array.isArray(model)) {
|
|
955
963
|
[model] = model;
|
|
956
964
|
}
|
|
@@ -974,7 +982,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
974
982
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
975
983
|
* @returns List of servers for method, if defined, or endpoint, if defined, or root level
|
|
976
984
|
*/
|
|
977
|
-
_getServers(options: ServersQueryOptions = {}, context?: Record<string, string>):
|
|
985
|
+
_getServers(options: ServersQueryOptions = {}, context?: Record<string, string>): IAmfServer[] | undefined {
|
|
978
986
|
const { endpointId, methodId } = options;
|
|
979
987
|
const { amf } = this;
|
|
980
988
|
if (!amf) {
|
|
@@ -994,18 +1002,18 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
994
1002
|
|
|
995
1003
|
const serverKey = this._getAmfKey(ns.aml.vocabularies.apiContract.server, context);
|
|
996
1004
|
|
|
997
|
-
const getRootServers = ():
|
|
998
|
-
const getEndpointServers = ():
|
|
1005
|
+
const getRootServers = (): IAmfServer[] | undefined => (this[getArrayItems](api, serverKey, context) as IAmfServer[]);
|
|
1006
|
+
const getEndpointServers = (): IAmfServer[] | undefined => {
|
|
999
1007
|
const endpoint = this._computeEndpointModel(api, endpointId, context);
|
|
1000
|
-
const servers = (this[getArrayItems](endpoint, serverKey, context) as
|
|
1008
|
+
const servers = (this[getArrayItems](endpoint, serverKey, context) as IAmfServer[]);
|
|
1001
1009
|
if (servers) {
|
|
1002
1010
|
return servers;
|
|
1003
1011
|
}
|
|
1004
1012
|
return getRootServers();
|
|
1005
1013
|
};
|
|
1006
|
-
const getMethodServers = ():
|
|
1014
|
+
const getMethodServers = (): IAmfServer[] | undefined => {
|
|
1007
1015
|
const method = this._computeMethodModel(api, methodId, context);
|
|
1008
|
-
const servers = (this[getArrayItems](method, serverKey, context)) as
|
|
1016
|
+
const servers = (this[getArrayItems](method, serverKey, context)) as IAmfServer[];
|
|
1009
1017
|
if (servers) {
|
|
1010
1018
|
return servers;
|
|
1011
1019
|
}
|
|
@@ -1026,11 +1034,11 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1026
1034
|
* @param method AMF `supportedOperation` model
|
|
1027
1035
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1028
1036
|
*/
|
|
1029
|
-
_computeExpects(method?:
|
|
1037
|
+
_computeExpects(method?: IAmfOperation, context?: Record<string, string>): IAmfRequest | undefined {
|
|
1030
1038
|
const operationKey = ns.aml.vocabularies.apiContract.Operation;
|
|
1031
1039
|
const expectsKey = ns.aml.vocabularies.apiContract.expects;
|
|
1032
1040
|
if (this._hasType(method, operationKey, context)) {
|
|
1033
|
-
const key = this._getAmfKey(expectsKey, context)
|
|
1041
|
+
const key = this._getAmfKey(expectsKey, context) as string;
|
|
1034
1042
|
const expects = this._ensureArray((method as any)[key]);
|
|
1035
1043
|
if (expects) {
|
|
1036
1044
|
return Array.isArray(expects) ? expects[0] : expects;
|
|
@@ -1045,13 +1053,13 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1045
1053
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1046
1054
|
* @returns An array of endpoints.
|
|
1047
1055
|
*/
|
|
1048
|
-
_computeEndpoints(webApi?:
|
|
1056
|
+
_computeEndpoints(webApi?: IAmfWebApi, context?: Record<string, string>): IAmfEndPoint[] | undefined {
|
|
1049
1057
|
if (!webApi) {
|
|
1050
1058
|
return [];
|
|
1051
1059
|
}
|
|
1052
1060
|
const endpointKey = ns.aml.vocabularies.apiContract.endpoint;
|
|
1053
|
-
const key = this._getAmfKey(endpointKey, context)
|
|
1054
|
-
return this._ensureArray((webApi as any)[key]) as
|
|
1061
|
+
const key = this._getAmfKey(endpointKey, context) as string;
|
|
1062
|
+
return this._ensureArray((webApi as any)[key]) as IAmfEndPoint[];
|
|
1055
1063
|
}
|
|
1056
1064
|
|
|
1057
1065
|
/**
|
|
@@ -1062,7 +1070,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1062
1070
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1063
1071
|
* @returns An endpoint definition
|
|
1064
1072
|
*/
|
|
1065
|
-
_computeEndpointModel(webApi?:
|
|
1073
|
+
_computeEndpointModel(webApi?: IAmfWebApi, id?: string, context?: Record<string, string>): IAmfEndPoint | undefined {
|
|
1066
1074
|
if (this._hasType(webApi, ns.aml.vocabularies.apiContract.EndPoint, context)) {
|
|
1067
1075
|
return webApi;
|
|
1068
1076
|
}
|
|
@@ -1081,7 +1089,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1081
1089
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1082
1090
|
* @returns A method definition
|
|
1083
1091
|
*/
|
|
1084
|
-
_computeMethodModel(webApi?:
|
|
1092
|
+
_computeMethodModel(webApi?: IAmfWebApi, selected?: string, context?: Record<string, string>): IAmfOperation | undefined {
|
|
1085
1093
|
const methods = this.__computeMethodsListForMethod(webApi, selected, context);
|
|
1086
1094
|
if (!methods) {
|
|
1087
1095
|
return undefined;
|
|
@@ -1096,7 +1104,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1096
1104
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1097
1105
|
* @returns An endpoint model of undefined.
|
|
1098
1106
|
*/
|
|
1099
|
-
_computeMethodEndpoint(webApi?:
|
|
1107
|
+
_computeMethodEndpoint(webApi?: IAmfWebApi, methodId?: string, context?: Record<string, string>): IAmfEndPoint | undefined {
|
|
1100
1108
|
if (!webApi || !methodId) {
|
|
1101
1109
|
return undefined;
|
|
1102
1110
|
}
|
|
@@ -1107,10 +1115,10 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1107
1115
|
if (!endpoints) {
|
|
1108
1116
|
return undefined;
|
|
1109
1117
|
}
|
|
1110
|
-
const opKey = this._getAmfKey(ns.aml.vocabularies.apiContract.supportedOperation, context)
|
|
1118
|
+
const opKey = this._getAmfKey(ns.aml.vocabularies.apiContract.supportedOperation, context);
|
|
1111
1119
|
for (let i = 0, len = endpoints.length; i < len; i++) {
|
|
1112
1120
|
const endpoint = endpoints[i];
|
|
1113
|
-
let methods = (endpoint as any)[opKey] as
|
|
1121
|
+
let methods = (endpoint as any)[opKey] as IAmfOperation[];
|
|
1114
1122
|
if (!methods) {
|
|
1115
1123
|
continue;
|
|
1116
1124
|
}
|
|
@@ -1135,13 +1143,13 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1135
1143
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1136
1144
|
* @returns A list of sibling methods or undefined.
|
|
1137
1145
|
*/
|
|
1138
|
-
__computeMethodsListForMethod(webApi?:
|
|
1146
|
+
__computeMethodsListForMethod(webApi?: IAmfWebApi, methodId?: string, context?: Record<string, string>): IAmfOperation[] | undefined {
|
|
1139
1147
|
const endpoint = this._computeMethodEndpoint(webApi, methodId, context);
|
|
1140
1148
|
if (!endpoint) {
|
|
1141
1149
|
return undefined;
|
|
1142
1150
|
}
|
|
1143
|
-
const opKey = this._getAmfKey(ns.aml.vocabularies.apiContract.supportedOperation, context)
|
|
1144
|
-
return this._ensureArray((endpoint as any)[opKey]) as
|
|
1151
|
+
const opKey = this._getAmfKey(ns.aml.vocabularies.apiContract.supportedOperation, context);
|
|
1152
|
+
return this._ensureArray((endpoint as any)[opKey]) as IAmfOperation[] | undefined;
|
|
1145
1153
|
}
|
|
1146
1154
|
|
|
1147
1155
|
/**
|
|
@@ -1153,7 +1161,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1153
1161
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1154
1162
|
* @returns A type definition
|
|
1155
1163
|
*/
|
|
1156
|
-
_computeType(declares?:
|
|
1164
|
+
_computeType(declares?: IAmfDomainElement[], references?: IAmfDomainElement[], selected?: string, context?: Record<string, string>): IAmfShape | undefined {
|
|
1157
1165
|
if ((!declares && !references) || !selected) {
|
|
1158
1166
|
return undefined;
|
|
1159
1167
|
}
|
|
@@ -1181,7 +1189,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1181
1189
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1182
1190
|
* @returns The AMF shape or undefined when not found.
|
|
1183
1191
|
*/
|
|
1184
|
-
[findAmfType](domainId?: string, context?: Record<string, string>):
|
|
1192
|
+
[findAmfType](domainId?: string, context?: Record<string, string>): IAmfShape | undefined {
|
|
1185
1193
|
let { amf } = this;
|
|
1186
1194
|
if (!amf || !domainId) {
|
|
1187
1195
|
return undefined;
|
|
@@ -1208,7 +1216,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1208
1216
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1209
1217
|
* @returns The domain object or undefined.
|
|
1210
1218
|
*/
|
|
1211
|
-
[findReferenceObject](domainId: string, context?: Record<string, string>):
|
|
1219
|
+
[findReferenceObject](domainId: string, context?: Record<string, string>): IAmfDomainElement | undefined {
|
|
1212
1220
|
let { amf } = this;
|
|
1213
1221
|
if (Array.isArray(amf)) {
|
|
1214
1222
|
[amf] = amf;
|
|
@@ -1222,7 +1230,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1222
1230
|
}
|
|
1223
1231
|
const compactId = domainId.replace('amf://id', '');
|
|
1224
1232
|
for (let i = 0, len = references.length; i < len; i++) {
|
|
1225
|
-
const ref = /** @type
|
|
1233
|
+
const ref = /** @type IAmfDocument */ (references[i]);
|
|
1226
1234
|
const declares = this._computeDeclares(ref, context);
|
|
1227
1235
|
if (!Array.isArray(declares)) {
|
|
1228
1236
|
continue;
|
|
@@ -1247,7 +1255,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1247
1255
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1248
1256
|
* @returns Type definition or undefined if not found.
|
|
1249
1257
|
*/
|
|
1250
|
-
_computeReferenceType(reference?:
|
|
1258
|
+
_computeReferenceType(reference?: IAmfDomainElement, selected?: string, context?: Record<string, string>): IAmfShape | undefined {
|
|
1251
1259
|
const declare = this._computeDeclares(reference, context);
|
|
1252
1260
|
if (!declare || !selected) {
|
|
1253
1261
|
return undefined;
|
|
@@ -1275,12 +1283,12 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1275
1283
|
* @param selected Selected shape
|
|
1276
1284
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1277
1285
|
*/
|
|
1278
|
-
_computeDocument(webApi?:
|
|
1286
|
+
_computeDocument(webApi?: IAmfDomainElement, selected?: string, context?: Record<string, string>): IAmfDomainElement | undefined {
|
|
1279
1287
|
if (!webApi || !selected) {
|
|
1280
1288
|
return undefined;
|
|
1281
1289
|
}
|
|
1282
|
-
const key = this._getAmfKey(ns.aml.vocabularies.core.documentation, context)
|
|
1283
|
-
const docs = this._ensureArray((webApi as any)[key]) as
|
|
1290
|
+
const key = this._getAmfKey(ns.aml.vocabularies.core.documentation, context);
|
|
1291
|
+
const docs = this._ensureArray((webApi as any)[key]) as IAmfDomainElement[];
|
|
1284
1292
|
return docs && docs.find((item) => (item as any)['@id'] as string === selected);
|
|
1285
1293
|
}
|
|
1286
1294
|
|
|
@@ -1296,8 +1304,8 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1296
1304
|
if (typeof shape !== 'object' || Array.isArray(shape) || !amf || shape.__apicResolved) {
|
|
1297
1305
|
return shape;
|
|
1298
1306
|
}
|
|
1299
|
-
let refKey = this._getAmfKey(ns.aml.vocabularies.document.linkTarget, context)
|
|
1300
|
-
let refValue = this._ensureArray(shape[refKey]) as
|
|
1307
|
+
let refKey = this._getAmfKey(ns.aml.vocabularies.document.linkTarget, context);
|
|
1308
|
+
let refValue = this._ensureArray(shape[refKey]) as IAmfDomainElement[];
|
|
1301
1309
|
let refData;
|
|
1302
1310
|
if (refValue) {
|
|
1303
1311
|
const rk = refValue[0]['@id'];
|
|
@@ -1308,8 +1316,8 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1308
1316
|
}
|
|
1309
1317
|
refData = this._getLinkTarget(amf, rk, context);
|
|
1310
1318
|
} else {
|
|
1311
|
-
refKey = this._getAmfKey(ns.aml.vocabularies.document.referenceId, context)
|
|
1312
|
-
refValue = this._ensureArray(shape[refKey]) as
|
|
1319
|
+
refKey = this._getAmfKey(ns.aml.vocabularies.document.referenceId, context);
|
|
1320
|
+
refValue = this._ensureArray(shape[refKey]) as IAmfDomainElement[];
|
|
1313
1321
|
if (refValue) {
|
|
1314
1322
|
const rk = refValue[0]['@id'];
|
|
1315
1323
|
if (rk === shape['@id']) {
|
|
@@ -1348,7 +1356,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1348
1356
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1349
1357
|
* @returns Resolved shape for given reference, undefined otherwise
|
|
1350
1358
|
*/
|
|
1351
|
-
_getLinkTarget(amf?:
|
|
1359
|
+
_getLinkTarget(amf?: IAmfDocument, id?: string, context?: Record<string, string>): IAmfDomainElement | undefined {
|
|
1352
1360
|
if (!amf || !id) {
|
|
1353
1361
|
return undefined;
|
|
1354
1362
|
}
|
|
@@ -1377,7 +1385,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1377
1385
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1378
1386
|
* @returns Resolved shape for given reference, undefined otherwise
|
|
1379
1387
|
*/
|
|
1380
|
-
_obtainShapeFromReferences(references?:
|
|
1388
|
+
_obtainShapeFromReferences(references?: IAmfDomainElement[], id?: string, context?: Record<string, string>): IAmfDomainElement | undefined {
|
|
1381
1389
|
if (!Array.isArray(references) || !references.length) {
|
|
1382
1390
|
return undefined;
|
|
1383
1391
|
}
|
|
@@ -1406,7 +1414,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1406
1414
|
* @param id Id to search for
|
|
1407
1415
|
* @returns Node with the given ID when found, undefined otherwise
|
|
1408
1416
|
*/
|
|
1409
|
-
_findById(array?:
|
|
1417
|
+
_findById(array?: IAmfDomainElement[], id?: string): IAmfDomainElement | undefined {
|
|
1410
1418
|
if (!array) return undefined;
|
|
1411
1419
|
let target;
|
|
1412
1420
|
for (let i = 0; i < array.length; i++) {
|
|
@@ -1419,7 +1427,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1419
1427
|
return target;
|
|
1420
1428
|
}
|
|
1421
1429
|
|
|
1422
|
-
_getReferenceId(amf?:
|
|
1430
|
+
_getReferenceId(amf?: IAmfDocument, id?: string, context?: Record<string, string>): IAmfDomainElement | undefined {
|
|
1423
1431
|
if (!amf || !id) {
|
|
1424
1432
|
return undefined;
|
|
1425
1433
|
}
|
|
@@ -1465,7 +1473,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1465
1473
|
const merged = { ...shapeA, ...shapeB };
|
|
1466
1474
|
const specialMerges = [
|
|
1467
1475
|
{
|
|
1468
|
-
key: this._getAmfKey(ns.aml.vocabularies.docSourceMaps.sources, context)
|
|
1476
|
+
key: this._getAmfKey(ns.aml.vocabularies.docSourceMaps.sources, context),
|
|
1469
1477
|
merger: this._mergeSourceMapsSources.bind(this)
|
|
1470
1478
|
},
|
|
1471
1479
|
];
|
|
@@ -1488,7 +1496,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1488
1496
|
* @private
|
|
1489
1497
|
*/
|
|
1490
1498
|
_mergeSourceMapsSources(shapeA: any, shapeB: any, context?: Record<string, string>): (any | {})[] {
|
|
1491
|
-
const sourcesKey = this._getAmfKey(ns.aml.vocabularies.docSourceMaps.sources, context)
|
|
1499
|
+
const sourcesKey = this._getAmfKey(ns.aml.vocabularies.docSourceMaps.sources, context);
|
|
1492
1500
|
let aSources = shapeA[sourcesKey] || {};
|
|
1493
1501
|
if (Array.isArray(aSources)) {
|
|
1494
1502
|
aSources = aSources[0];
|
|
@@ -1534,7 +1542,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1534
1542
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1535
1543
|
* @returns Type definition or undefined if not found.
|
|
1536
1544
|
*/
|
|
1537
|
-
findSecurityScheme(domainId: string, context?: Record<string, string>):
|
|
1545
|
+
findSecurityScheme(domainId: string, context?: Record<string, string>): IAmfSecurityScheme | undefined {
|
|
1538
1546
|
const { amf } = this;
|
|
1539
1547
|
const declares = this._computeDeclares(amf, context);
|
|
1540
1548
|
let result;
|
|
@@ -1567,7 +1575,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1567
1575
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1568
1576
|
* @returns Type definition or undefined if not found.
|
|
1569
1577
|
*/
|
|
1570
|
-
[computeReferenceSecurity](reference:
|
|
1578
|
+
[computeReferenceSecurity](reference: IAmfDomainElement, selected: string, context?: Record<string, string>): IAmfSecurityScheme | undefined {
|
|
1571
1579
|
const declare = this._computeDeclares(reference, context);
|
|
1572
1580
|
if (!declare) {
|
|
1573
1581
|
return undefined;
|
|
@@ -1591,17 +1599,17 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1591
1599
|
* @param type The domain type
|
|
1592
1600
|
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
1593
1601
|
*/
|
|
1594
|
-
getByType(source:
|
|
1602
|
+
getByType(source: IAmfDomainElement, type: string, context?: Record<string, string>): IAmfDomainElement[] {
|
|
1595
1603
|
if (!source) {
|
|
1596
1604
|
return [];
|
|
1597
1605
|
}
|
|
1598
|
-
let result:
|
|
1606
|
+
let result: IAmfDomainElement[] = [];
|
|
1599
1607
|
const declares = this._computeDeclares(source);
|
|
1600
1608
|
const key = this._getAmfKey(type, context);
|
|
1601
1609
|
if (declares && declares.length) {
|
|
1602
1610
|
declares.forEach((declared) => {
|
|
1603
1611
|
if (this._hasType(declared, key)) {
|
|
1604
|
-
result.push(declared as
|
|
1612
|
+
result.push(declared as IAmfDomainElement);
|
|
1605
1613
|
}
|
|
1606
1614
|
});
|
|
1607
1615
|
}
|
|
@@ -1609,7 +1617,7 @@ export const AmfMixin = <T extends Constructor<any>>(superClass: T): Constructor
|
|
|
1609
1617
|
if (Array.isArray(references) && references.length) {
|
|
1610
1618
|
for (const ref of references) {
|
|
1611
1619
|
if (this._hasType(ref, ns.aml.vocabularies.document.Module)) {
|
|
1612
|
-
const items = this.getByType(ref as
|
|
1620
|
+
const items = this.getByType(ref as IAmfDomainElement, type, context);
|
|
1613
1621
|
if (items.length) {
|
|
1614
1622
|
result = result.concat(items);
|
|
1615
1623
|
}
|