@api-client/core 0.9.19 → 0.9.21

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 (54) hide show
  1. package/build/src/models/CertificateFile.d.ts +1 -1
  2. package/build/src/models/CertificateFile.js +3 -1
  3. package/build/src/models/CertificateFile.js.map +1 -1
  4. package/build/src/models/Folder.d.ts +1 -1
  5. package/build/src/models/Folder.js +3 -2
  6. package/build/src/models/Folder.js.map +1 -1
  7. package/build/src/models/Project.d.ts +1 -1
  8. package/build/src/models/Project.js +3 -1
  9. package/build/src/models/Project.js.map +1 -1
  10. package/build/src/models/Space.js +2 -1
  11. package/build/src/models/Space.js.map +1 -1
  12. package/build/src/models/data/DataFile.d.ts +1 -1
  13. package/build/src/models/data/DataFile.js +3 -1
  14. package/build/src/models/data/DataFile.js.map +1 -1
  15. package/build/src/models/http-actions/HttpFlows.d.ts +4 -4
  16. package/build/src/models/http-actions/LegacyTranslator.d.ts +2 -3
  17. package/build/src/models/http-actions/LegacyTranslator.js +26 -25
  18. package/build/src/models/http-actions/LegacyTranslator.js.map +1 -1
  19. package/build/src/models/store/File.d.ts +9 -1
  20. package/build/src/models/store/File.js +9 -2
  21. package/build/src/models/store/File.js.map +1 -1
  22. package/build/src/runtime/http-runner/HttpFlowRunner.js +14 -8
  23. package/build/src/runtime/http-runner/HttpFlowRunner.js.map +1 -1
  24. package/build/src/runtime/http-runner/HttpRequestRunner.js +3 -3
  25. package/build/src/runtime/http-runner/HttpRequestRunner.js.map +1 -1
  26. package/data/models/APIC-187.json +10 -2
  27. package/data/models/APIC-188.json +10 -2
  28. package/data/models/APIC-391.json +10 -0
  29. package/data/models/APIC-483.json +10 -0
  30. package/data/models/APIC-655.json +16 -0
  31. package/data/models/APIC-689.json +16 -0
  32. package/data/models/SE-10469.json +8 -0
  33. package/data/models/SE-13092.json +24 -0
  34. package/data/models/SE-22063.json +8 -0
  35. package/data/models/amf-helper-api.json +216 -4
  36. package/data/models/arc-demo-api.json +130 -2
  37. package/data/models/example-generator-api.json +216 -0
  38. package/data/models/oas-3-api.json +66 -10
  39. package/data/models/oas-unions.json +24 -0
  40. package/data/models/petstore.json +178 -26
  41. package/data/models/raml-date.json +8 -0
  42. package/data/models/schema-api.json +24 -0
  43. package/data/models/tracked-to-linked.json +40 -0
  44. package/package.json +1 -1
  45. package/src/models/CertificateFile.ts +3 -1
  46. package/src/models/Folder.ts +3 -2
  47. package/src/models/Project.ts +3 -1
  48. package/src/models/Space.ts +2 -1
  49. package/src/models/data/DataFile.ts +3 -1
  50. package/src/models/http-actions/HttpFlows.ts +4 -4
  51. package/src/models/http-actions/LegacyTranslator.ts +25 -26
  52. package/src/models/store/File.ts +13 -2
  53. package/src/runtime/http-runner/HttpFlowRunner.ts +14 -10
  54. package/src/runtime/http-runner/HttpRequestRunner.ts +3 -3
@@ -362,6 +362,11 @@
362
362
  "@type": [
363
363
  "sourcemaps:SourceMap"
364
364
  ],
365
+ "sourcemaps:lexical": [
366
+ {
367
+ "@id": "#26/source-map/lexical/element_0"
368
+ }
369
+ ],
365
370
  "sourcemaps:virtual-element": [
366
371
  {
367
372
  "@id": "#26/source-map/virtual-element/element_0"
@@ -395,6 +400,11 @@
395
400
  "@type": [
396
401
  "sourcemaps:SourceMap"
397
402
  ],
403
+ "sourcemaps:lexical": [
404
+ {
405
+ "@id": "#38/source-map/lexical/element_0"
406
+ }
407
+ ],
398
408
  "sourcemaps:virtual-element": [
399
409
  {
400
410
  "@id": "#38/source-map/virtual-element/element_0"
@@ -428,6 +438,11 @@
428
438
  "@type": [
429
439
  "sourcemaps:SourceMap"
430
440
  ],
441
+ "sourcemaps:lexical": [
442
+ {
443
+ "@id": "#40/source-map/lexical/element_0"
444
+ }
445
+ ],
431
446
  "sourcemaps:virtual-element": [
432
447
  {
433
448
  "@id": "#40/source-map/virtual-element/element_0"
@@ -461,6 +476,11 @@
461
476
  "@type": [
462
477
  "sourcemaps:SourceMap"
463
478
  ],
479
+ "sourcemaps:lexical": [
480
+ {
481
+ "@id": "#42/source-map/lexical/element_0"
482
+ }
483
+ ],
464
484
  "sourcemaps:virtual-element": [
465
485
  {
466
486
  "@id": "#42/source-map/virtual-element/element_0"
@@ -508,6 +528,11 @@
508
528
  ]
509
529
  },
510
530
  {
531
+ "@id": "#26/source-map/lexical/element_0",
532
+ "sourcemaps:element": "amf://id#26",
533
+ "sourcemaps:value": "[(11,9)-(15,0)]"
534
+ },
535
+ {
511
536
  "@id": "#26/source-map/virtual-element/element_0",
512
537
  "sourcemaps:element": "amf://id#26",
513
538
  "sourcemaps:value": "true"
@@ -554,6 +579,11 @@
554
579
  ]
555
580
  },
556
581
  {
582
+ "@id": "#38/source-map/lexical/element_0",
583
+ "sourcemaps:element": "amf://id#38",
584
+ "sourcemaps:value": "[(16,9)-(20,0)]"
585
+ },
586
+ {
557
587
  "@id": "#38/source-map/virtual-element/element_0",
558
588
  "sourcemaps:element": "amf://id#38",
559
589
  "sourcemaps:value": "true"
@@ -570,6 +600,11 @@
570
600
  ]
571
601
  },
572
602
  {
603
+ "@id": "#40/source-map/lexical/element_0",
604
+ "sourcemaps:element": "amf://id#40",
605
+ "sourcemaps:value": "[(21,9)-(25,0)]"
606
+ },
607
+ {
573
608
  "@id": "#40/source-map/virtual-element/element_0",
574
609
  "sourcemaps:element": "amf://id#40",
575
610
  "sourcemaps:value": "true"
@@ -586,6 +621,11 @@
586
621
  ]
587
622
  },
588
623
  {
624
+ "@id": "#42/source-map/lexical/element_0",
625
+ "sourcemaps:element": "amf://id#42",
626
+ "sourcemaps:value": "[(26,9)-(28,47)]"
627
+ },
628
+ {
589
629
  "@id": "#42/source-map/virtual-element/element_0",
590
630
  "sourcemaps:element": "amf://id#42",
591
631
  "sourcemaps:value": "true"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api-client/core",
3
3
  "description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
4
- "version": "0.9.19",
4
+ "version": "0.9.21",
5
5
  "license": "Apache-2.0",
6
6
  "main": "build/index.js",
7
7
  "module": "build/index.js",
@@ -12,10 +12,11 @@ export interface ICertificateFile extends IFile {
12
12
  export class CertificateFile extends File {
13
13
  override kind = Kind;
14
14
 
15
- static fromCertificate(certificate: ICertificate | Certificate, owner = DefaultOwner): CertificateFile {
15
+ static fromCertificate(certificate: ICertificate | Certificate, space: string, owner = DefaultOwner): CertificateFile {
16
16
  const init: ICertificateFile = {
17
17
  kind: Kind,
18
18
  key: certificate.key,
19
+ space,
19
20
  info: Thing.fromName(certificate.name).toJSON(),
20
21
  lastModified: { user: owner, time: 0, byMe: false },
21
22
  owner,
@@ -37,6 +38,7 @@ export class CertificateFile extends File {
37
38
  init = {
38
39
  kind: Kind,
39
40
  key: v4(),
41
+ space: '',
40
42
  info: Thing.fromName('').toJSON(),
41
43
  owner: DefaultOwner,
42
44
  parents: [],
@@ -28,8 +28,8 @@ export class Folder extends File {
28
28
  * @param name The name to set.
29
29
  * @param owner The user id that is the owner of the space.
30
30
  */
31
- static override fromName(name: string, owner = DefaultOwner): Folder {
32
- return super.fromName(name, owner, Kind) as Folder;
31
+ static override fromName(name: string, space: string, owner = DefaultOwner): Folder {
32
+ return super.fromName(name, space, owner, Kind) as Folder;
33
33
  }
34
34
 
35
35
  /**
@@ -46,6 +46,7 @@ export class Folder extends File {
46
46
  init = {
47
47
  kind: Kind,
48
48
  key: v4(),
49
+ space: '',
49
50
  info: Thing.fromName('').toJSON(),
50
51
  owner: DefaultOwner,
51
52
  parents: [],
@@ -20,7 +20,7 @@ export interface IProject extends IFile {
20
20
  export class Project extends File {
21
21
  override kind = Kind;
22
22
 
23
- static fromProject(project: HttpProject | IHttpProject, owner = DefaultOwner): Project {
23
+ static fromProject(project: HttpProject | IHttpProject, space: string, owner = DefaultOwner): Project {
24
24
  let final: IHttpProject;
25
25
  if (typeof (project as HttpProject).toJSON === 'function') {
26
26
  final = (project as HttpProject).toJSON();
@@ -30,6 +30,7 @@ export class Project extends File {
30
30
  const init: IProject = {
31
31
  kind: Kind,
32
32
  key: project.key,
33
+ space,
33
34
  info: { ...final.info },
34
35
  lastModified: { user: owner, time: 0, byMe: false },
35
36
  owner,
@@ -51,6 +52,7 @@ export class Project extends File {
51
52
  init = {
52
53
  kind: Kind,
53
54
  key: v4(),
55
+ space: '',
54
56
  info: Thing.fromName('').toJSON(),
55
57
  owner: DefaultOwner,
56
58
  parents: [],
@@ -24,7 +24,7 @@ export class Space extends File {
24
24
  override kind = Kind;
25
25
 
26
26
  static override fromName(name: string, owner = DefaultOwner): Space {
27
- return super.fromName(name, owner, Kind) as Space;
27
+ return super.fromName(name, '', owner, Kind) as Space;
28
28
  }
29
29
 
30
30
  constructor(input?: string | ISpace) {
@@ -38,6 +38,7 @@ export class Space extends File {
38
38
  init = {
39
39
  kind: Kind,
40
40
  key: v4(),
41
+ space: '',
41
42
  info: Thing.fromName('').toJSON(),
42
43
  owner: DefaultOwner,
43
44
  parents: [],
@@ -21,7 +21,7 @@ export class DataFile extends File {
21
21
  * @param input The data namespace instance or schema.
22
22
  * @param owner Optional owner to set.
23
23
  */
24
- static fromDataNamespace(input: DataNamespace | IDataNamespace, owner = DefaultOwner): DataFile {
24
+ static fromDataNamespace(input: DataNamespace | IDataNamespace, space: string, owner = DefaultOwner): DataFile {
25
25
  let final: IDataNamespace;
26
26
  if (typeof (input as DataNamespace).toJSON === 'function') {
27
27
  final = (input as DataNamespace).toJSON();
@@ -31,6 +31,7 @@ export class DataFile extends File {
31
31
  const init: IDataFile = {
32
32
  kind: Kind,
33
33
  key: final.key,
34
+ space,
34
35
  info: { ...final.info },
35
36
  lastModified: { user: owner, time: 0, byMe: false },
36
37
  owner,
@@ -52,6 +53,7 @@ export class DataFile extends File {
52
53
  init = {
53
54
  kind: Kind,
54
55
  key: v4(),
56
+ space: '',
55
57
  info: Thing.fromName('').toJSON(),
56
58
  owner: DefaultOwner,
57
59
  parents: [],
@@ -51,6 +51,10 @@ export interface IHttpFlow {
51
51
  * The ordered list of actions to execute.
52
52
  */
53
53
  actions: IHttpAction[];
54
+ /**
55
+ * A condition to check before running the flow.
56
+ */
57
+ condition?: IHttpCondition;
54
58
  }
55
59
 
56
60
  /**
@@ -66,10 +70,6 @@ export interface IHttpAction {
66
70
  * The description of the action
67
71
  */
68
72
  description?: string;
69
- /**
70
- * A condition to check before performing the action.
71
- */
72
- condition?: IHttpCondition;
73
73
  /**
74
74
  * The list of steps to perform. This is an ordered list of action tasks.
75
75
  * Each step is described by the `kind` property which tells the runner what action to perform.
@@ -24,45 +24,44 @@ export class LegacyTranslator {
24
24
  const result: IHttpFlow[] = [];
25
25
 
26
26
  if (Array.isArray(request) && request.length) {
27
- const flow: IHttpFlow = {
28
- trigger: 'request',
29
- actions: this._translateRunnables(request),
30
- };
31
- result.push(flow);
27
+ request.forEach((runnable, index) => {
28
+ const flow = this._runnableIntoFlow(runnable, 'request');
29
+ flow.description = `Translated flow ${index + 1}`;
30
+ result.push(flow);
31
+ });
32
32
  }
33
33
 
34
34
  if (Array.isArray(response) && response.length) {
35
- const flow: IHttpFlow = {
36
- trigger: 'response',
37
- actions: this._translateRunnables(response),
38
- };
39
- result.push(flow);
35
+ response.forEach((runnable, index) => {
36
+ const flow = this._runnableIntoFlow(runnable, 'response');
37
+ flow.description = `Translated flow ${index + 1}`;
38
+ result.push(flow);
39
+ });
40
40
  }
41
41
  return result;
42
42
  }
43
43
 
44
- protected static _translateRunnables(runnables: LegacyRunnable[]): IHttpAction[] {
45
- const result: IHttpAction[] = [];
46
- runnables.forEach((runnable) => {
47
- const actions = this._translateRunnable(runnable);
48
- actions.forEach(item => result.push(item));
49
- });
50
- return result;
51
- }
52
-
53
- protected static _translateRunnable(runnable: LegacyRunnable): IHttpAction[] {
54
- const result: IHttpAction[] = [];
44
+ protected static _runnableIntoFlow(runnable: LegacyRunnable, trigger: 'request' | 'response'): IHttpFlow {
45
+ const flow: IHttpFlow = {
46
+ trigger,
47
+ actions: [],
48
+ };
55
49
  const { actions, condition } = runnable;
56
- actions.forEach((action) => {
50
+ if (condition) {
51
+ flow.condition = this._translateCondition(condition);
52
+ }
53
+ actions.forEach((action, index) => {
57
54
  const current: IHttpAction = {
58
55
  steps: this._translateAction(action),
59
56
  };
60
- if (condition) {
61
- current.condition = this._translateCondition(condition);
57
+ if (action.name) {
58
+ current.description = action.name;
59
+ } else {
60
+ current.description = `Translated action ${index + 1}`;
62
61
  }
63
- result.push(current);
62
+ flow.actions.push(current);
64
63
  });
65
- return result;
64
+ return flow;
66
65
  }
67
66
 
68
67
  protected static _translateCondition(runnable: LegacyCondition): IHttpCondition | undefined {
@@ -52,6 +52,10 @@ export interface IStoredFile {
52
52
  * The identifier of the entity
53
53
  */
54
54
  key: string;
55
+ /**
56
+ * The parent space of the file.
57
+ */
58
+ space: string;
55
59
  /**
56
60
  * The file's meta info.
57
61
  */
@@ -141,6 +145,10 @@ export class StoredFile {
141
145
  * The identifier of the entity
142
146
  */
143
147
  key = '';
148
+ /**
149
+ * The parent space of the file.
150
+ */
151
+ space = '';
144
152
  /**
145
153
  * The name of the environment.
146
154
  */
@@ -232,8 +240,9 @@ export class StoredFile {
232
240
  iconColor?: string;
233
241
 
234
242
  new(init: IStoredFile): void {
235
- const { key = v4(), info, kind, parents=[], permissionIds=[], deleted, deletedInfo, owner = DefaultOwner, lastModified, labels, iconColor } = init;
243
+ const { key = v4(), info, kind, parents=[], permissionIds=[], deleted, deletedInfo, owner = DefaultOwner, lastModified, labels, iconColor, space } = init;
236
244
  this.key = key;
245
+ this.space = space;
237
246
  this.kind = kind;
238
247
  if (info) {
239
248
  this.info = new Thing(info);
@@ -267,6 +276,7 @@ export class StoredFile {
267
276
  const { owner = DefaultOwner } = this;
268
277
  const result: IStoredFile = {
269
278
  key: this.key,
279
+ space: this.space,
270
280
  kind: this.kind,
271
281
  info: this.info.toJSON(),
272
282
  parents: [...this.parents],
@@ -511,12 +521,13 @@ export class File extends StoredFile {
511
521
  * @param name The name to set.
512
522
  * @param owner The user id that is the owner of the space.
513
523
  */
514
- static fromName(name: string, owner = DefaultOwner, kind = ''): File {
524
+ static fromName(name: string, space: string, owner = DefaultOwner, kind = ''): File {
515
525
  const key = v4();
516
526
  const definition = new File();
517
527
  definition.new({
518
528
  key,
519
529
  kind,
530
+ space,
520
531
  info: Thing.fromName(name).toJSON(),
521
532
  owner,
522
533
  parents: [],
@@ -41,7 +41,18 @@ export class HttpFlowRunner {
41
41
  return;
42
42
  }
43
43
  for (const flow of flows) {
44
- for (const action of flow.actions) {
44
+ const { condition, actions } = flow;
45
+ if (condition) {
46
+ try {
47
+ const meet = await this._satisfied(condition, request);
48
+ if (!meet) {
49
+ continue;
50
+ }
51
+ } catch (_) {
52
+ continue;
53
+ }
54
+ }
55
+ for (const action of actions) {
45
56
  await this._runAction(action, request);
46
57
  }
47
58
  }
@@ -59,17 +70,10 @@ export class HttpFlowRunner {
59
70
  }
60
71
 
61
72
  async _runAction(action: IHttpAction, request: IHttpRequest | ISentRequest, response?: IResponse | IErrorResponse): Promise<void> {
62
- const { steps, condition } = action;
73
+ const { steps } = action;
63
74
  if (!Array.isArray(steps) || !steps.length) {
64
75
  return;
65
76
  }
66
- if (condition) {
67
- const meet = await this._satisfied(condition, request, response);
68
- if (!meet) {
69
- return;
70
- }
71
- }
72
-
73
77
  // this keeps a value from the last step to be passed to the next step.
74
78
  let lastResult: FlowValue;
75
79
  for (const step of steps) {
@@ -231,7 +235,7 @@ export class HttpFlowRunner {
231
235
  async _runDeleteCookieStep(step: IDeleteCookieStep, request: IHttpRequest | ISentRequest): Promise<FlowValue> {
232
236
  const instance = new DeleteCookieStep(step);
233
237
  const { cookies } = this;
234
- if (instance.enabled === false || !instance.checkValidity() || !cookies ) {
238
+ if (instance.enabled === false || !instance.checkValidity() || !cookies) {
235
239
  return undefined;
236
240
  }
237
241
  let url: string;
@@ -234,11 +234,11 @@ export class HttpRequestRunner {
234
234
  continue;
235
235
  }
236
236
  const copy = { ...flow } as IHttpFlow;
237
+ if (copy.condition) {
238
+ copy.condition = await variablesProcessor.evaluateVariablesWithContext(copy.condition, variables);
239
+ }
237
240
  const actions = copy.actions.map(async (action) => {
238
241
  const actionCopy = { ...action };
239
- if (actionCopy.condition) {
240
- actionCopy.condition = await variablesProcessor.evaluateVariablesWithContext(actionCopy.condition, variables);
241
- }
242
242
  if (Array.isArray(actionCopy.steps) && actionCopy.steps.length) {
243
243
  const stepsPromises = actionCopy.steps.map((step) => variablesProcessor.evaluateVariablesWithContext(step, variables));
244
244
  actionCopy.steps = await Promise.all(stepsPromises);