@api-client/core 0.9.20 → 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 (31) hide show
  1. package/build/src/models/http-actions/HttpFlows.d.ts +4 -4
  2. package/build/src/models/http-actions/LegacyTranslator.d.ts +2 -3
  3. package/build/src/models/http-actions/LegacyTranslator.js +26 -25
  4. package/build/src/models/http-actions/LegacyTranslator.js.map +1 -1
  5. package/build/src/runtime/http-runner/HttpFlowRunner.js +14 -8
  6. package/build/src/runtime/http-runner/HttpFlowRunner.js.map +1 -1
  7. package/build/src/runtime/http-runner/HttpRequestRunner.js +3 -3
  8. package/build/src/runtime/http-runner/HttpRequestRunner.js.map +1 -1
  9. package/data/models/APIC-187.json +10 -2
  10. package/data/models/APIC-188.json +10 -2
  11. package/data/models/APIC-391.json +10 -0
  12. package/data/models/APIC-483.json +10 -0
  13. package/data/models/APIC-655.json +16 -0
  14. package/data/models/APIC-689.json +16 -0
  15. package/data/models/SE-10469.json +8 -0
  16. package/data/models/SE-13092.json +24 -0
  17. package/data/models/SE-22063.json +8 -0
  18. package/data/models/amf-helper-api.json +216 -4
  19. package/data/models/arc-demo-api.json +130 -2
  20. package/data/models/example-generator-api.json +225 -9
  21. package/data/models/oas-3-api.json +66 -10
  22. package/data/models/oas-unions.json +24 -0
  23. package/data/models/petstore.json +178 -26
  24. package/data/models/raml-date.json +8 -0
  25. package/data/models/schema-api.json +24 -0
  26. package/data/models/tracked-to-linked.json +40 -0
  27. package/package.json +1 -1
  28. package/src/models/http-actions/HttpFlows.ts +4 -4
  29. package/src/models/http-actions/LegacyTranslator.ts +25 -26
  30. package/src/runtime/http-runner/HttpFlowRunner.ts +14 -10
  31. 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.20",
4
+ "version": "0.9.21",
5
5
  "license": "Apache-2.0",
6
6
  "main": "build/index.js",
7
7
  "module": "build/index.js",
@@ -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 {
@@ -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);