arazzo-runner 0.0.1 → 0.0.5

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/README.md CHANGED
@@ -1 +1,114 @@
1
- # arazzo-runner
1
+ # Arazzo-Runner
2
+
3
+ <p>
4
+ <a href="https://www.npmjs.com/package/arazzo-runner">
5
+ <img src="https://img.shields.io/npm/v/arazzo-runner.svg?style=flat-square">
6
+ </a>
7
+ <a href="https://github.com/JaredCE/arazzo-runner/actions/workflows/node.yml">
8
+ <img src="https://github.com/JaredCE/arazzo-runner/actions/workflows/node.yml/badge.svg">
9
+ </a>
10
+ <a href="https://www.buymeacoffee.com/jarede">
11
+ <img src="https://raw.githubusercontent.com/pachadotdev/buymeacoffee-badges/main/bmc-donate-yellow.svg">
12
+ </a>
13
+ </p>
14
+
15
+ Run your [OpenAPI Arazzo Workflow Spec](https://www.openapis.org/arazzo-specification).
16
+
17
+ ## Install
18
+
19
+ **Using npm:**
20
+
21
+ ```bash
22
+ npm install -g arazzo-runner
23
+ ```
24
+
25
+ ## Use
26
+
27
+ ```bash
28
+ # Run the CLI
29
+ arazzo-runner --arazzo ./arazzo.json --input ./input.json
30
+
31
+ # Or with short flags
32
+ arazzo-runner -a arazzo.json -i input.json
33
+
34
+ # With URL
35
+ arazzo-runner -a https://example.com/arazzo.json -i ./input.json
36
+
37
+ # Show help
38
+ arazzo-runner --help
39
+
40
+ # Show version
41
+ arazzo-runner --version
42
+ ```
43
+
44
+ ### Input file
45
+
46
+ The input file is where you keep your variables that you wish to use within your workflow and should be a json file structured like:
47
+
48
+ ```json
49
+ {
50
+ "worflowId1": {
51
+ "name": "Jared"
52
+ }
53
+ }
54
+ ```
55
+
56
+ The file should contain objects for each workflow, by workflowId, with the variables matching up to the inputs that you defined in your workflow inputs schema.
57
+
58
+ This file is likely to be comitted to your repository, so you should not store secrets in the file, instead you might use something like [jq](https://jqlang.org/) that can take repository variables and insert them into your input file:
59
+
60
+ ```bash
61
+ jq --arg password "$secret_password" '.workflowId1.password = $password' input.json
62
+ ```
63
+
64
+ Obviously, if you have a lot of secret variables that need adding as inputs, then you might need to write a script that can alter the `input.json` file for you within your CI/CD runner.
65
+
66
+ ## Logging And Reporting
67
+
68
+ ### Logging
69
+
70
+ Logging is currently pretty verbose, with an example Log looking like:
71
+
72
+ ```bash
73
+ Running Workflows
74
+ Running Workflow: createUser
75
+ Running Step: createAUser
76
+ Getting Source Description for: users-openAPI
77
+ Making a POST to http://petstore.swagger.io/v2/user
78
+ http://petstore.swagger.io/v2/user responded with a: 200
79
+ ==================================================================================
80
+ Checking: $statusCode == 200
81
+ ✅ $statusCode == 200 passed
82
+ ==================================================================================
83
+ ✅ All criteria checks passed
84
+ Running onSuccess Rules
85
+ ✅ Step createAUser completed
86
+ ✅ Workflow createUser completed
87
+ ✅ All Workflows run
88
+ ```
89
+
90
+ ### Reporting
91
+
92
+ Work on Reporting still needs completeing.
93
+
94
+ ## Still unsupported
95
+
96
+ ### OpenAPI Params
97
+
98
+ OpenAPI parameter types with style and explode are not quite supported yet
99
+
100
+ ### OpenAPI Servers on various levels
101
+
102
+ This pulls from the top level servers object of an OpenAPI Document. Server variables do not work either.
103
+
104
+ ### JSONPath and XPath criteria objects
105
+
106
+ Criteria Objects set as type JSON Path or XPath do not work
107
+
108
+ ### Non application/json Responses
109
+
110
+ Responses that do not conform to application/json do not work
111
+
112
+ ### Non application/json Requests
113
+
114
+ Requests that do not conform to application/json do not work
package/cli.js ADDED
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { parseArgs } = require("node:util");
5
+ const path = require("node:path");
6
+ const fs = require("node:fs");
7
+
8
+ const Runner = require("./src/Runner");
9
+
10
+ // Parse command line arguments
11
+ const options = {
12
+ arazzo: {
13
+ type: "string",
14
+ short: "a",
15
+ },
16
+ input: {
17
+ type: "string",
18
+ short: "i",
19
+ },
20
+ help: {
21
+ type: "boolean",
22
+ short: "h",
23
+ },
24
+ version: {
25
+ type: "boolean",
26
+ short: "v",
27
+ },
28
+ };
29
+
30
+ function showHelp() {
31
+ console.log(`
32
+ Arazzo Runner - Execute Arazzo workflow specifications
33
+
34
+ USAGE:
35
+ arazzo-runner --arazzo <file|url> --input <file>
36
+ arazzo-runner -a <file|url> -i <file>
37
+
38
+ OPTIONS:
39
+ -a, --arazzo <file|url> Path or URL to Arazzo Document file (required)
40
+ -i, --input <file> Path to input JSON file (required)
41
+ -h, --help Show this help message
42
+ -v, --version Show version number
43
+
44
+ EXAMPLES:
45
+ # Run with local files
46
+ arazzo-runner --arazzo ./arazzo.json --input ./input.json
47
+
48
+ # Run with URL
49
+ arazzo-runner -a https://example.com/arazzo.json -i ./input.json
50
+
51
+ # Short form
52
+ arazzo-runner -a arazzo.json -i input.json
53
+ `);
54
+ }
55
+
56
+ function showVersion() {
57
+ const packageJson = require("./package.json");
58
+ console.log(`v${packageJson.version}`);
59
+ }
60
+
61
+ function isUrl(str) {
62
+ try {
63
+ new URL(str);
64
+ return true;
65
+ } catch {
66
+ return false;
67
+ }
68
+ }
69
+
70
+ function validateArazzoPath(arazzoPath) {
71
+ if (isUrl(arazzoPath)) {
72
+ return arazzoPath;
73
+ }
74
+
75
+ const resolvedPath = path.resolve(arazzoPath);
76
+
77
+ if (!fs.existsSync(resolvedPath)) {
78
+ console.error(`Error: Arazzo file not found: ${arazzoPath}`);
79
+ process.exit(1);
80
+ }
81
+
82
+ return resolvedPath;
83
+ }
84
+
85
+ function validateInputPath(inputPath) {
86
+ const resolvedPath = path.resolve(inputPath);
87
+
88
+ if (!fs.existsSync(resolvedPath)) {
89
+ console.error(`Error: Input file not found: ${inputPath}`);
90
+ process.exit(1);
91
+ }
92
+
93
+ return resolvedPath;
94
+ }
95
+
96
+ async function main() {
97
+ let values;
98
+
99
+ try {
100
+ ({ values } = parseArgs({ options, allowPositionals: false }));
101
+ } catch (err) {
102
+ console.error(`Error: ${err.message}`);
103
+ console.log("Use --help for usage information");
104
+ process.exit(1);
105
+ }
106
+
107
+ // Handle help
108
+ if (values.help) {
109
+ showHelp();
110
+ process.exit(0);
111
+ }
112
+
113
+ // Handle version
114
+ if (values.version) {
115
+ showVersion();
116
+ process.exit(0);
117
+ }
118
+
119
+ // Validate required arguments
120
+ if (!values.arazzo) {
121
+ console.error("Error: --arazzo argument is required");
122
+ console.log("Use --help for usage information");
123
+ process.exit(1);
124
+ }
125
+
126
+ if (!values.input) {
127
+ console.error("Error: --input argument is required");
128
+ console.log("Use --help for usage information");
129
+ process.exit(1);
130
+ }
131
+
132
+ // Validate paths
133
+ const arazzoPath = validateArazzoPath(values.arazzo);
134
+ const inputPath = validateInputPath(values.input);
135
+
136
+ console.log(`Starting Arazzo Runner...`);
137
+ console.log(`Arazzo: ${arazzoPath}`);
138
+ console.log(`Input: ${inputPath}`);
139
+ console.log("");
140
+
141
+ try {
142
+ const runner = new Runner();
143
+ await runner.runArazzo(arazzoPath, inputPath);
144
+
145
+ console.log("");
146
+ console.log("✓ Arazzo execution completed successfully");
147
+ process.exit(0);
148
+ } catch (err) {
149
+ console.error("");
150
+ console.error("✗ Arazzo execution failed:");
151
+ console.error(err.message);
152
+
153
+ if (process.env.DEBUG) {
154
+ console.error("");
155
+ console.error("Stack trace:");
156
+ console.error(err.stack);
157
+ }
158
+
159
+ process.exit(1);
160
+ }
161
+ }
162
+
163
+ main();
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ const Runner = require("./src/Runner");
2
+
3
+ module.exports = Runner;
package/package.json CHANGED
@@ -1,10 +1,16 @@
1
1
  {
2
2
  "name": "arazzo-runner",
3
- "version": "0.0.1",
3
+ "version": "0.0.5",
4
4
  "description": "A runner to run through Arazzo Document workflows",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "mocha --config './test/.mocharc.js'",
8
+ "test-coverage": "nyc mocha --config './test/.mocharc.js'",
9
+ "prepare": "husky",
10
+ "start": "node cli.js"
11
+ },
12
+ "bin": {
13
+ "arazzo-runner": "cli.js"
8
14
  },
9
15
  "repository": {
10
16
  "type": "git",
@@ -20,5 +26,23 @@
20
26
  "bugs": {
21
27
  "url": "https://github.com/JaredCE/Arazzo-Runner/issues"
22
28
  },
23
- "homepage": "https://github.com/JaredCE/Arazzo-Runner#readme"
29
+ "homepage": "https://github.com/JaredCE/Arazzo-Runner#readme",
30
+ "devDependencies": {
31
+ "chai": "^6.2.2",
32
+ "husky": "^9.1.7",
33
+ "mocha": "^11.7.5",
34
+ "nock": "^14.0.10",
35
+ "nyc": "^17.1.0",
36
+ "sinon": "^21.0.1"
37
+ },
38
+ "dependencies": {
39
+ "@redocly/openapi-core": "^2.14.5",
40
+ "@swaggerexpert/arazzo-runtime-expression": "^1.0.1",
41
+ "@swaggerexpert/json-pointer": "^2.10.2",
42
+ "ajv": "^8.17.1",
43
+ "jsonpath": "^1.1.1",
44
+ "openapi-params": "^0.0.4",
45
+ "stream-chain": "^3.4.0",
46
+ "stream-json": "^1.9.1"
47
+ }
24
48
  }