@usearazzo/runner 1.0.1-alpha.24 → 1.0.1-alpha.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usearazzo/runner",
3
- "version": "1.0.1-alpha.24",
3
+ "version": "1.0.1-alpha.26",
4
4
  "description": "Runner for Arazzo Workflows.",
5
5
  "keywords": [
6
6
  "arazzo",
@@ -73,8 +73,8 @@
73
73
  "@swaggerexpert/json-pointer": "^3.0.2",
74
74
  "@swaggerexpert/jsonpath": "^4.0.5",
75
75
  "@swaggerexpert/media-types": "^1.0.2",
76
- "@usearazzo/parser": "1.0.1-alpha.24",
77
- "@usearazzo/resolver": "1.0.1-alpha.24",
76
+ "@usearazzo/parser": "1.0.1-alpha.26",
77
+ "@usearazzo/resolver": "1.0.1-alpha.26",
78
78
  "@xmldom/xmldom": "^0.9.12",
79
79
  "fontoxpath": "^3.34.0",
80
80
  "ramda": "^0.32.0",
@@ -94,5 +94,5 @@
94
94
  "devDependencies": {
95
95
  "swagger-client": "^3.38.4"
96
96
  },
97
- "gitHead": "ba457d4dfc1a0a0ccd91e38ad9b33b08d07dc3f0"
97
+ "gitHead": "8bacf6bf0e5d1e4c44a81583c5f1719bbbefaf97"
98
98
  }
@@ -6,11 +6,19 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _apidomCore = require("@speclynx/apidom-core");
9
+ var _apidomDatamodel = require("@speclynx/apidom-datamodel");
10
+ var _apidomJsonPointer = require("@speclynx/apidom-json-pointer");
9
11
  var _APIDocument = _interopRequireDefault(require("./APIDocument.cjs"));
12
+ /**
13
+ * A workflow of an Arazzo document, as listed by
14
+ * {@link ArazzoDocument.listWorkflows}.
15
+ * @public
16
+ */
17
+
10
18
  /**
11
19
  * An Arazzo document held by the document registry: the parse result together
12
20
  * with the indexes the provider built over it — a container, not a logic
13
- * bearer. The methods below are thin reads of the source description index.
21
+ * bearer. The methods below are thin reads of those indexes.
14
22
  * @public
15
23
  */
16
24
  class ArazzoDocument extends _APIDocument.default {
@@ -46,6 +54,31 @@ class ArazzoDocument extends _APIDocument.default {
46
54
  return doc.type === 'arazzo';
47
55
  }
48
56
 
57
+ /**
58
+ * The workflows of this document that can be addressed by `workflowId`, in
59
+ * document order. A duplicated `workflowId` is listed once, for its first
60
+ * workflow. Reads this document only: source descriptions are neither loaded
61
+ * nor listed.
62
+ */
63
+ listWorkflows() {
64
+ return [...this.workflowIndex].map(([workflowId, jsonPointer]) => {
65
+ const {
66
+ summary,
67
+ description
68
+ } = (0, _apidomJsonPointer.evaluate)(this.parseResult.api, jsonPointer);
69
+ return {
70
+ workflowId,
71
+ jsonPointer,
72
+ ...((0, _apidomDatamodel.isStringElement)(summary) && {
73
+ summary: (0, _apidomCore.toValue)(summary)
74
+ }),
75
+ ...((0, _apidomDatamodel.isStringElement)(description) && {
76
+ description: (0, _apidomCore.toValue)(description)
77
+ })
78
+ };
79
+ });
80
+ }
81
+
49
82
  /**
50
83
  * Resolves a source description name to its canonical URI — precomputed by
51
84
  * the provider, resolved against this document's base URI.
@@ -1,9 +1,16 @@
1
1
  import { toValue } from '@speclynx/apidom-core';
2
+ import { isStringElement } from '@speclynx/apidom-datamodel';
3
+ import { evaluate } from '@speclynx/apidom-json-pointer';
2
4
  import APIDocument from "./APIDocument.mjs";
5
+ /**
6
+ * A workflow of an Arazzo document, as listed by
7
+ * {@link ArazzoDocument.listWorkflows}.
8
+ * @public
9
+ */
3
10
  /**
4
11
  * An Arazzo document held by the document registry: the parse result together
5
12
  * with the indexes the provider built over it — a container, not a logic
6
- * bearer. The methods below are thin reads of the source description index.
13
+ * bearer. The methods below are thin reads of those indexes.
7
14
  * @public
8
15
  */
9
16
  class ArazzoDocument extends APIDocument {
@@ -39,6 +46,31 @@ class ArazzoDocument extends APIDocument {
39
46
  return doc.type === 'arazzo';
40
47
  }
41
48
 
49
+ /**
50
+ * The workflows of this document that can be addressed by `workflowId`, in
51
+ * document order. A duplicated `workflowId` is listed once, for its first
52
+ * workflow. Reads this document only: source descriptions are neither loaded
53
+ * nor listed.
54
+ */
55
+ listWorkflows() {
56
+ return [...this.workflowIndex].map(([workflowId, jsonPointer]) => {
57
+ const {
58
+ summary,
59
+ description
60
+ } = evaluate(this.parseResult.api, jsonPointer);
61
+ return {
62
+ workflowId,
63
+ jsonPointer,
64
+ ...(isStringElement(summary) && {
65
+ summary: toValue(summary)
66
+ }),
67
+ ...(isStringElement(description) && {
68
+ description: toValue(description)
69
+ })
70
+ };
71
+ });
72
+ }
73
+
42
74
  /**
43
75
  * Resolves a source description name to its canonical URI — precomputed by
44
76
  * the provider, resolved against this document's base URI.
@@ -99,7 +99,8 @@ class ArazzoDocumentRegistryProvider extends _DocumentRegistryProvider.default {
99
99
  * A source description's canonical URI is resolved here too — against the
100
100
  * document's base URI, into the exact form the document registry keys on —
101
101
  * so every consumer works with a ready-to-use, non-relative URI. The first
102
- * element of a duplicated source description name wins.
102
+ * element of a duplicated source description name wins, and so does the
103
+ * first workflow of a duplicated workflowId.
103
104
  */
104
105
  #buildIndexes(uri, parseResult) {
105
106
  const workflowIndex = new _ArazzoWorkflowIndex.default();
@@ -111,6 +112,7 @@ class ArazzoDocumentRegistryProvider extends _DocumentRegistryProvider.default {
111
112
  const workflowId = (0, _apidomCore.toValue)(workflow.workflowId);
112
113
  if (typeof workflowId !== 'string') return path.skip();
113
114
  if (workflowId === '') return path.skip();
115
+ if (workflowIndex.has(workflowId)) return path.skip();
114
116
  const workflowPointer = path.formatPath('jsonpointer');
115
117
  workflowIndex.set(workflowId, workflowPointer);
116
118
 
@@ -91,7 +91,8 @@ class ArazzoDocumentRegistryProvider extends DocumentRegistryProvider {
91
91
  * A source description's canonical URI is resolved here too — against the
92
92
  * document's base URI, into the exact form the document registry keys on —
93
93
  * so every consumer works with a ready-to-use, non-relative URI. The first
94
- * element of a duplicated source description name wins.
94
+ * element of a duplicated source description name wins, and so does the
95
+ * first workflow of a duplicated workflowId.
95
96
  */
96
97
  #buildIndexes(uri, parseResult) {
97
98
  const workflowIndex = new ArazzoWorkflowIndex();
@@ -103,6 +104,7 @@ class ArazzoDocumentRegistryProvider extends DocumentRegistryProvider {
103
104
  const workflowId = toValue(workflow.workflowId);
104
105
  if (typeof workflowId !== 'string') return path.skip();
105
106
  if (workflowId === '') return path.skip();
107
+ if (workflowIndex.has(workflowId)) return path.skip();
106
108
  const workflowPointer = path.formatPath('jsonpointer');
107
109
  workflowIndex.set(workflowId, workflowPointer);
108
110
 
@@ -44,6 +44,7 @@ const providerOptionsOverride = exports.providerOptionsOverride = {
44
44
  * Provides OpenAPIDocument instances for the DocumentRegistry.
45
45
  *
46
46
  * Parses, dereferences, and builds an OperationIndex for OpenAPI documents.
47
+ * The first operation of a duplicated operationId wins.
47
48
  * @public
48
49
  */
49
50
  class OpenAPIDocumentRegistryProvider extends _DocumentRegistryProvider.default {
@@ -95,6 +96,7 @@ class OpenAPIDocumentRegistryProvider extends _DocumentRegistryProvider.default
95
96
  const operationId = (0, _apidomCore.toValue)(operation.operationId);
96
97
  if (typeof operationId !== 'string') return path.skip();
97
98
  if (operationId === '') return path.skip();
99
+ if (index.has(operationId)) return path.skip();
98
100
  index.set(operationId, path.formatPath('jsonpointer'));
99
101
  path.skip();
100
102
  }
@@ -36,6 +36,7 @@ export const providerOptionsOverride = {
36
36
  * Provides OpenAPIDocument instances for the DocumentRegistry.
37
37
  *
38
38
  * Parses, dereferences, and builds an OperationIndex for OpenAPI documents.
39
+ * The first operation of a duplicated operationId wins.
39
40
  * @public
40
41
  */
41
42
  class OpenAPIDocumentRegistryProvider extends DocumentRegistryProvider {
@@ -87,6 +88,7 @@ class OpenAPIDocumentRegistryProvider extends DocumentRegistryProvider {
87
88
  const operationId = toValue(operation.operationId);
88
89
  if (typeof operationId !== 'string') return path.skip();
89
90
  if (operationId === '') return path.skip();
91
+ if (index.has(operationId)) return path.skip();
90
92
  index.set(operationId, path.formatPath('jsonpointer'));
91
93
  path.skip();
92
94
  }
package/types/runner.d.ts CHANGED
@@ -97,7 +97,7 @@ export declare abstract class APIDocument {
97
97
  /**
98
98
  * An Arazzo document held by the document registry: the parse result together
99
99
  * with the indexes the provider built over it — a container, not a logic
100
- * bearer. The methods below are thin reads of the source description index.
100
+ * bearer. The methods below are thin reads of those indexes.
101
101
  * @public
102
102
  */
103
103
  export declare class ArazzoDocument extends APIDocument {
@@ -123,6 +123,13 @@ export declare class ArazzoDocument extends APIDocument {
123
123
  * Type guard for ArazzoDocument.
124
124
  */
125
125
  static is(doc: APIDocument): doc is ArazzoDocument;
126
+ /**
127
+ * The workflows of this document that can be addressed by `workflowId`, in
128
+ * document order. A duplicated `workflowId` is listed once, for its first
129
+ * workflow. Reads this document only: source descriptions are neither loaded
130
+ * nor listed.
131
+ */
132
+ listWorkflows(): WorkflowDescriptor[];
126
133
  /**
127
134
  * Resolves a source description name to its canonical URI — precomputed by
128
135
  * the provider, resolved against this document's base URI.
@@ -1079,6 +1086,7 @@ export declare interface OpenAPIDocumentAssemblerOptions {
1079
1086
  * Provides OpenAPIDocument instances for the DocumentRegistry.
1080
1087
  *
1081
1088
  * Parses, dereferences, and builds an OperationIndex for OpenAPI documents.
1089
+ * The first operation of a duplicated operationId wins.
1082
1090
  * @public
1083
1091
  */
1084
1092
  export declare class OpenAPIDocumentRegistryProvider extends DocumentRegistryProvider {
@@ -2402,6 +2410,31 @@ export declare class UnmatchedProviderError extends ArazzoRunnerError {
2402
2410
  readonly uri?: string;
2403
2411
  }
2404
2412
 
2413
+ /**
2414
+ * A workflow of an Arazzo document, as listed by
2415
+ * {@link ArazzoDocument.listWorkflows}.
2416
+ * @public
2417
+ */
2418
+ export declare interface WorkflowDescriptor {
2419
+ /**
2420
+ * The id `ArazzoRunner.execute` takes to run the workflow.
2421
+ */
2422
+ workflowId: WorkflowId;
2423
+ /**
2424
+ * JSON Pointer to the workflow within the document.
2425
+ */
2426
+ jsonPointer: JSONPointer;
2427
+ /**
2428
+ * Present only when the workflow has a string `summary`.
2429
+ */
2430
+ summary?: string;
2431
+ /**
2432
+ * Present only when the workflow has a string `description`, as written
2433
+ * (CommonMark).
2434
+ */
2435
+ description?: string;
2436
+ }
2437
+
2405
2438
  /**
2406
2439
  * Per-call options for {@link WorkflowExecutor.execute}.
2407
2440
  * @public