@sw-tsdk/plugin-connector 0.1.1-next.25 → 1.0.1-next.49

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
@@ -4,7 +4,7 @@ Integration Task CLI Plugin
4
4
 
5
5
  [![Version](https://img.shields.io/npm/v/@tsdk/plugin-task)](https://npmjs.org/package/@tsdk/plugin-task)
6
6
  [![Downloads/week](https://img.shields.io/npm/dw/@tsdk/plugin-task)](https://npmjs.org/package/@tsdk/plugin-task)
7
- [![License](https://img.shields.io/npm/l/@tsdk/plugin-task)](https://github.com/swimlane/turbine-developer-kit/blob/main/packages/cli/package.json)
7
+ [![License](https://img.shields.io/npm/l/@tsdk/plugin-task)](https://github.com/swimlane/turbine-sdk/blob/main/packages/cli/package.json)
8
8
  <!-- toc -->
9
9
  * [Usage](#usage)
10
10
  * [Commands](#commands)
@@ -16,7 +16,7 @@ $ npm install -g @sw-tsdk/plugin-connector
16
16
  $ sw-tsdk-connector COMMAND
17
17
  running command...
18
18
  $ sw-tsdk-connector (--version)
19
- @sw-tsdk/plugin-connector/0.1.1-next.25+33cda6d linux-x64 node-v16.17.0
19
+ @sw-tsdk/plugin-connector/1.0.1-next.49+c40df32 linux-x64 node-v16.17.1
20
20
  $ sw-tsdk-connector --help [COMMAND]
21
21
  USAGE
22
22
  $ sw-tsdk-connector COMMAND
@@ -26,9 +26,10 @@ USAGE
26
26
  # Commands
27
27
  <!-- commands -->
28
28
  * [`sw-tsdk-connector action:add`](#sw-tsdk-connector-actionadd)
29
+ * [`sw-tsdk-connector action:generate:data`](#sw-tsdk-connector-actiongeneratedata)
29
30
  * [`sw-tsdk-connector action:input`](#sw-tsdk-connector-actioninput)
30
31
  * [`sw-tsdk-connector action:output`](#sw-tsdk-connector-actionoutput)
31
- * [`sw-tsdk-connector action:run`](#sw-tsdk-connector-actionrun)
32
+ * [`sw-tsdk-connector action:run:local`](#sw-tsdk-connector-actionrunlocal)
32
33
  * [`sw-tsdk-connector asset:add`](#sw-tsdk-connector-assetadd)
33
34
  * [`sw-tsdk-connector connector:build`](#sw-tsdk-connector-connectorbuild)
34
35
  * [`sw-tsdk-connector connector:create`](#sw-tsdk-connector-connectorcreate)
@@ -57,7 +58,32 @@ DESCRIPTION
57
58
  Update a connector action.
58
59
  ```
59
60
 
60
- _See code: [lib/commands/action/add.js](https://github.com/swimlane/turbine-sdk/blob/v0.1.1-next.25+33cda6d/lib/commands/action/add.js)_
61
+ _See code: [lib/commands/action/add.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/action/add.js)_
62
+
63
+ ## `sw-tsdk-connector action:generate:data`
64
+
65
+ Use to test a task in an integration
66
+
67
+ ```
68
+ USAGE
69
+ $ sw-tsdk-connector action:generate:data [-h] [-a <value>] [--asset <value>] [--inputs <value>] [-d <value>]
70
+ [--include-optional] [--force]
71
+
72
+ FLAGS
73
+ -a, --action=<value> action to generate data
74
+ -d, --directory=<value> [default: ./] current directory to mount
75
+ -h, --help Show CLI help.
76
+ --asset=<value> Filename for asset, defaults to the task name under the data folder. ie: data/asset_name.json
77
+ --force overwrites current files
78
+ --include-optional used to only generate required properties
79
+ --inputs=<value> Filename for JSON inputs, defaults to the task name under the data folder. ie:
80
+ data/my_task.json
81
+
82
+ DESCRIPTION
83
+ Use to test a task in an integration
84
+ ```
85
+
86
+ _See code: [lib/commands/action/generate/data.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/action/generate/data.js)_
61
87
 
62
88
  ## `sw-tsdk-connector action:input`
63
89
 
@@ -82,7 +108,7 @@ DESCRIPTION
82
108
  Update action input schema.
83
109
  ```
84
110
 
85
- _See code: [lib/commands/action/input.js](https://github.com/swimlane/turbine-sdk/blob/v0.1.1-next.25+33cda6d/lib/commands/action/input.js)_
111
+ _See code: [lib/commands/action/input.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/action/input.js)_
86
112
 
87
113
  ## `sw-tsdk-connector action:output`
88
114
 
@@ -106,38 +132,35 @@ DESCRIPTION
106
132
  Update a connector action.
107
133
  ```
108
134
 
109
- _See code: [lib/commands/action/output.js](https://github.com/swimlane/turbine-sdk/blob/v0.1.1-next.25+33cda6d/lib/commands/action/output.js)_
135
+ _See code: [lib/commands/action/output.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/action/output.js)_
110
136
 
111
- ## `sw-tsdk-connector action:run`
137
+ ## `sw-tsdk-connector action:run:local`
112
138
 
113
139
  Runs a connector action. (Defaults to current image version in local repository).
114
140
 
115
141
  ```
116
142
  USAGE
117
- $ sw-tsdk-connector action:run [-a <value>] [-d <value>] [--input-path <value>] [--output-path <value>]
118
- [--error-path <value>] [--asset-path <value>] [-i <value> | --build | --latest] [--template
119
- python_3.7|node_18|python_310_definition] [-f ] [-h]
143
+ $ sw-tsdk-connector action:run:local [-a <value>] [-d <value>] [--input-path <value>] [--output-path <value>]
144
+ [--error-path <value>] [--asset-path <value>] [--template python_3.7_swimlane|node_18|python_310_definition] [-f]
145
+ [-h]
120
146
 
121
147
  FLAGS
122
148
  -a, --action=<value> Action name to run
123
149
  -d, --directory=<value> [default: ./] Root directory of the repository.
124
150
  -f, --force-rebuild forces nocache on the image build
125
151
  -h, --help Show CLI help.
126
- -i, --image=<value> The connector image to run.
127
152
  --asset-path=<value> File to asset data JSON file, defaults to /data/asset.json
128
- --build Builds image and runs it.
129
153
  --error-path=<value> File to write the errors to, defaults to /data/<action>_error.json
130
154
  --input-path=<value> File to input data JSON file, defaults to /data/<action>.json
131
- --latest Use the latest release image from quay.
132
155
  --output-path=<value> File to write the outputs to, defaults to /data/<action>_output.json
133
156
  --template=<option> [default: python_310_definition] connector template
134
- <options: python_3.7|node_18|python_310_definition>
157
+ <options: python_3.7_swimlane|node_18|python_310_definition>
135
158
 
136
159
  DESCRIPTION
137
160
  Runs a connector action. (Defaults to current image version in local repository).
138
161
  ```
139
162
 
140
- _See code: [lib/commands/action/run.js](https://github.com/swimlane/turbine-sdk/blob/v0.1.1-next.25+33cda6d/lib/commands/action/run.js)_
163
+ _See code: [lib/commands/action/run/local.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/action/run/local.js)_
141
164
 
142
165
  ## `sw-tsdk-connector asset:add`
143
166
 
@@ -157,7 +180,7 @@ DESCRIPTION
157
180
  Update a connector action.
158
181
  ```
159
182
 
160
- _See code: [lib/commands/asset/add.js](https://github.com/swimlane/turbine-sdk/blob/v0.1.1-next.25+33cda6d/lib/commands/asset/add.js)_
183
+ _See code: [lib/commands/asset/add.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/asset/add.js)_
161
184
 
162
185
  ## `sw-tsdk-connector connector:build`
163
186
 
@@ -166,21 +189,24 @@ Builds a local docker image of the connector.
166
189
  ```
167
190
  USAGE
168
191
  $ sw-tsdk-connector connector:build --template python_3.7_swimlane|node_18|python_310_definition [-d <value>]
169
- [--save] [-f] [-h]
192
+ [--save] [-f] [--signing-password <value>] [--key-name <value>] [--registry <value>] [-h]
170
193
 
171
194
  FLAGS
172
- -d, --directory=<value> [default: ./] root directory of the repository.
173
- -f, --force-rebuild forces nocache on the image build
174
- -h, --help Show CLI help.
175
- --save saves docker image as tar in local directory.
176
- --template=<option> (required) [default: python_310_definition] connector language
177
- <options: python_3.7_swimlane|node_18|python_310_definition>
195
+ -d, --directory=<value> [default: ./] root directory of the repository.
196
+ -f, --force-rebuild forces nocache on the image build
197
+ -h, --help Show CLI help.
198
+ --key-name=<value> name used for the key (default: username)
199
+ --registry=<value> [default: localhost:5000] registry to use for signing
200
+ --save saves a signed docker image as tar in local directory.
201
+ --signing-password=<value> password used for the private key
202
+ --template=<option> (required) [default: python_310_definition] connector language
203
+ <options: python_3.7_swimlane|node_18|python_310_definition>
178
204
 
179
205
  DESCRIPTION
180
206
  Builds a local docker image of the connector.
181
207
  ```
182
208
 
183
- _See code: [lib/commands/connector/build.js](https://github.com/swimlane/turbine-sdk/blob/v0.1.1-next.25+33cda6d/lib/commands/connector/build.js)_
209
+ _See code: [lib/commands/connector/build.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/connector/build.js)_
184
210
 
185
211
  ## `sw-tsdk-connector connector:create`
186
212
 
@@ -212,7 +238,7 @@ DESCRIPTION
212
238
  Scaffold a new connector
213
239
  ```
214
240
 
215
- _See code: [lib/commands/connector/create.js](https://github.com/swimlane/turbine-sdk/blob/v0.1.1-next.25+33cda6d/lib/commands/connector/create.js)_
241
+ _See code: [lib/commands/connector/create.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/connector/create.js)_
216
242
 
217
243
  ## `sw-tsdk-connector connector:create-source`
218
244
 
@@ -230,7 +256,7 @@ DESCRIPTION
230
256
  Generates 11x source from 10x
231
257
  ```
232
258
 
233
- _See code: [lib/commands/connector/create-source.js](https://github.com/swimlane/turbine-sdk/blob/v0.1.1-next.25+33cda6d/lib/commands/connector/create-source.js)_
259
+ _See code: [lib/commands/connector/create-source.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/connector/create-source.js)_
234
260
 
235
261
  ## `sw-tsdk-connector connector:logo`
236
262
 
@@ -249,7 +275,7 @@ DESCRIPTION
249
275
  Update a connector.
250
276
  ```
251
277
 
252
- _See code: [lib/commands/connector/logo.js](https://github.com/swimlane/turbine-sdk/blob/v0.1.1-next.25+33cda6d/lib/commands/connector/logo.js)_
278
+ _See code: [lib/commands/connector/logo.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/connector/logo.js)_
253
279
 
254
280
  ## `sw-tsdk-connector connector:save`
255
281
 
@@ -270,7 +296,7 @@ DESCRIPTION
270
296
  Save a docker image locally as .tar.gz
271
297
  ```
272
298
 
273
- _See code: [lib/commands/connector/save.js](https://github.com/swimlane/turbine-sdk/blob/v0.1.1-next.25+33cda6d/lib/commands/connector/save.js)_
299
+ _See code: [lib/commands/connector/save.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/connector/save.js)_
274
300
 
275
301
  ## `sw-tsdk-connector connector:sign`
276
302
 
@@ -286,7 +312,7 @@ FLAGS
286
312
  -h, --help Show CLI help.
287
313
  --image=<value> (required) image name to sign
288
314
  --key-name=<value> (required) name used for the key (default: username)
289
- --registry=<value> [default: localhost:50000] registry to use for signing
315
+ --registry=<value> [default: localhost:5000] registry to use for signing
290
316
  --save saves docker image as tar in local directory.
291
317
  --signing-password=<value> password used for the private key
292
318
 
@@ -294,7 +320,7 @@ DESCRIPTION
294
320
  Builds a local docker image of the connector.
295
321
  ```
296
322
 
297
- _See code: [lib/commands/connector/sign.js](https://github.com/swimlane/turbine-sdk/blob/v0.1.1-next.25+33cda6d/lib/commands/connector/sign.js)_
323
+ _See code: [lib/commands/connector/sign.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/connector/sign.js)_
298
324
 
299
325
  ## `sw-tsdk-connector connector:update`
300
326
 
@@ -314,7 +340,7 @@ DESCRIPTION
314
340
  Update a connector.
315
341
  ```
316
342
 
317
- _See code: [lib/commands/connector/update.js](https://github.com/swimlane/turbine-sdk/blob/v0.1.1-next.25+33cda6d/lib/commands/connector/update.js)_
343
+ _See code: [lib/commands/connector/update.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/connector/update.js)_
318
344
 
319
345
  ## `sw-tsdk-connector connector:validate`
320
346
 
@@ -325,7 +351,7 @@ USAGE
325
351
  $ sw-tsdk-connector connector:validate -c <value> [-h] [-i <value>] [--key <value> --signed] [-s] [-d <value>]
326
352
 
327
353
  FLAGS
328
- -c, --connector=<value> (required) connector to validate (relative to directory)
354
+ -c, --connector=<value> (required) [default: connector] connector to validate (relative to directory)
329
355
  -d, --directory=<value> [default: ./] current directory to mount
330
356
  -h, --help Show CLI help.
331
357
  -i, --image=<value> image to use
@@ -337,5 +363,5 @@ DESCRIPTION
337
363
  Use to validate an integration
338
364
  ```
339
365
 
340
- _See code: [lib/commands/connector/validate.js](https://github.com/swimlane/turbine-sdk/blob/v0.1.1-next.25+33cda6d/lib/commands/connector/validate.js)_
366
+ _See code: [lib/commands/connector/validate.js](https://github.com/swimlane/turbine-sdk/blob/v1.0.1-next.49+c40df32/lib/commands/connector/validate.js)_
341
367
  <!-- commandsstop -->
@@ -45,7 +45,7 @@ class Add extends core_2.Base {
45
45
  const action = {
46
46
  schema: 'action/1',
47
47
  title: answers.title,
48
- name: (0, snake_case_1.snakeCase)(answers.title),
48
+ name: (0, snake_case_1.snakeCase)(answers.title.toLocaleLowerCase()),
49
49
  description: answers.description,
50
50
  inputs: {
51
51
  type: 'object',
@@ -1 +1 @@
1
- {"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/commands/action/add.ts"],"names":[],"mappings":";;;;AAAA,8BAA8B;AAC9B,sCAAwC;AACxC,wCAAkC;AAClC,yCAAuC;AACvC,uCAAkC;AAClC,wEAAkC;AAClC,8DAA0B;AAC1B,2CAAoC;AAEpC,kDAAgE;AAEhE,gEAA+B;AAE/B,qCAAqC;AACrC,MAAa,GAAI,SAAQ,WAAI;IAqB3B,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,GACN,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAEzB,IAAI,EACF,SAAS,GACV,GAAG,KAAK,CAAA;QAET,MAAM,EACJ,QAAQ,GACT,GAAG,KAAK,CAAA;QAET,SAAS,GAAG,IAAA,mBAAO,EAAC,SAAS,IAAI,sBAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QAC/C,MAAM,eAAe,GAAQ,CAAC;gBAC5B,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,gCAAgC;aAC1C;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,IAAI,EAA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Q,IAAI,EAAE;oBAChC,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB,CAAA;gBACD,MAAK;SACN;QAED,MAAM,UAAU,GAAG,IAAA,gBAAI,EACrB,SAAS,EACT,WAAW,EACX,QAAQ,EACR,SAAS,EACT,GAAG,MAAM,CAAC,IAAI,OAAO,CAAC,CAAA;QACxB,MAAM,IAAA,oBAAS,EAAC,UAAU,EAAE,iBAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;QAC9C,YAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;;AA/FH,kBAgGC;AA/FQ,eAAW,GAAG,4BAA4B,CAAA;AAE1C,SAAK,mCACP,WAAI,CAAC,KAAK,KACb,SAAS,EAAE,YAAK,CAAC,MAAM,CAAC;QACtB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,mCAAmC;QAChD,OAAO,EAAE,IAAI;KACd,CAAC,EACF,QAAQ,EAAE,YAAK,CAAC,MAAM,CAAC;QACrB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,6BAA6B;QAC1C,OAAO,EAAE,uBAAuB;QAChC,OAAO,EAAE,CAAC,SAAS,EAAE,uBAAuB,EAAE,qBAAqB,CAAC;KACrE,CAAC,EACF,IAAI,EAAE,YAAK,CAAC,IAAI,CAAC;QACf,IAAI,EAAE,GAAG;KACV,CAAC,IACH"}
@@ -0,0 +1,17 @@
1
+ import { Base } from '@sw-tsdk/core';
2
+ export declare class Data extends Base {
3
+ static description: string;
4
+ static flags: {
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
+ action: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
7
+ asset: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
8
+ inputs: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
9
+ directory: import("@oclif/core/lib/interfaces").OptionFlag<string>;
10
+ 'include-optional': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
+ };
13
+ run(): Promise<void>;
14
+ private checkDirectoryAccess;
15
+ private static buildJsonFile;
16
+ private static createJsonFromSchema;
17
+ }
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Data = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@oclif/core");
6
+ const core_2 = require("@sw-tsdk/core");
7
+ const fs_extra_1 = require("fs-extra");
8
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
9
+ const node_fs_1 = require("node:fs");
10
+ const node_path_1 = require("node:path");
11
+ const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
12
+ const connector_1 = require("@sw-tsdk/connector");
13
+ const common_1 = require("../../../common");
14
+ const json_schema_faker_1 = require("json-schema-faker");
15
+ const node_crypto_1 = require("node:crypto");
16
+ // noinspection JSUnusedGlobalSymbols
17
+ class Data extends core_2.Base {
18
+ async run() {
19
+ const { flags } = await this.parse(Data);
20
+ const { asset, 'include-optional': includeOptional, force, } = flags;
21
+ let { directory, action, inputs } = flags;
22
+ directory = (0, node_path_1.resolve)(directory || process.cwd());
23
+ await this.checkDirectoryAccess(directory);
24
+ if (!action) {
25
+ action = await (0, common_1.chooseAction)(directory);
26
+ inputs = `data/${action}.json`;
27
+ }
28
+ if (action.endsWith('.yaml')) {
29
+ action = action.slice(0, Math.max(0, action.length - 5));
30
+ }
31
+ if (!inputs) {
32
+ inputs = `data/${action}.json`;
33
+ }
34
+ core_1.CliUx.ux.log(`Starting run: ${action}...`);
35
+ const manifests = await (0, connector_1.allManifests)(directory);
36
+ const assetManifests = manifests.assetManifests;
37
+ let assetName = assetManifests.length === 1 ? assetManifests[0].name : '';
38
+ if (assetManifests.length > 1) {
39
+ assetName = await (0, common_1.chooseAsset)(directory);
40
+ }
41
+ const actions = manifests.actionManifests;
42
+ if (!actions.some((x) => x.name === action)) {
43
+ this.error(`Invalid action: ${action}`);
44
+ return;
45
+ }
46
+ const assetPath = asset || (0, node_path_1.join)('data', `${assetName || 'asset'}.json`);
47
+ await Data.buildJsonFile(directory, manifests, assetName, assetPath, { includeOptional, force });
48
+ await Data.buildJsonFile(directory, manifests, action, inputs, { includeOptional, force });
49
+ }
50
+ async checkDirectoryAccess(directory) {
51
+ directory = (0, node_path_1.resolve)(directory || process.cwd());
52
+ try {
53
+ await node_fs_1.promises.access(directory);
54
+ }
55
+ catch (_a) {
56
+ this.error(`Could not access ${directory}`);
57
+ }
58
+ }
59
+ static async buildJsonFile(directory, manifests, name, generatedFile, options) {
60
+ if (!name) {
61
+ return;
62
+ }
63
+ const filePath = (0, node_path_1.resolve)((0, node_path_1.join)(directory, generatedFile));
64
+ if (!options.force && await (0, core_2.fileExists)(filePath)) {
65
+ const answer = await inquirer_1.default.prompt([
66
+ {
67
+ type: 'confirm',
68
+ message: `Would you like to overwrite ${generatedFile}?`,
69
+ name: 'exists',
70
+ },
71
+ ]);
72
+ if (!answer.exists) {
73
+ return;
74
+ }
75
+ }
76
+ core_1.CliUx.ux.action.start(`Generating ${name}.json...`);
77
+ const contentPath = manifests.findPath(name);
78
+ if (!contentPath) {
79
+ core_1.CliUx.ux.error(`Could not find ${name}.`);
80
+ }
81
+ const content = await (0, fs_extra_1.readFile)(contentPath, 'utf8');
82
+ const json = js_yaml_1.default.load(content);
83
+ const { inputs } = json;
84
+ const values = this.createJsonFromSchema(inputs, options);
85
+ await node_fs_1.promises.mkdir((0, node_path_1.dirname)(generatedFile), { recursive: true });
86
+ await (0, fs_extra_1.writeJson)(filePath, values, { spaces: 2, EOL: '\n' });
87
+ core_1.CliUx.ux.action.stop();
88
+ }
89
+ static createJsonFromSchema(data, options) {
90
+ json_schema_faker_1.JSONSchemaFaker.format('password', value => {
91
+ const newValue = value.default || value.examples ? value.examples[0] : null;
92
+ if (newValue) {
93
+ return newValue;
94
+ }
95
+ switch (value.format) {
96
+ case 'password':
97
+ return (0, node_crypto_1.randomUUID)();
98
+ }
99
+ });
100
+ json_schema_faker_1.JSONSchemaFaker.option('useExamplesValue', true);
101
+ json_schema_faker_1.JSONSchemaFaker.option('useDefaultValue', true);
102
+ if (!(options === null || options === void 0 ? void 0 : options.includeOptional)) {
103
+ json_schema_faker_1.JSONSchemaFaker.option('requiredOnly', true);
104
+ }
105
+ json_schema_faker_1.JSONSchemaFaker.option('pruneProperties', ['meta']);
106
+ const values = json_schema_faker_1.JSONSchemaFaker.generate(data);
107
+ return values;
108
+ }
109
+ }
110
+ exports.Data = Data;
111
+ Data.description = 'Use to test a task in an integration';
112
+ Data.flags = Object.assign(Object.assign({}, core_2.Base.flags), { help: core_1.Flags.help({ char: 'h' }), action: core_1.Flags.string({ char: 'a', description: 'action to generate data' }), asset: core_1.Flags.string({
113
+ description: 'Filename for asset, defaults to the task name under the data folder. ie: data/asset_name.json',
114
+ }), inputs: core_1.Flags.string({
115
+ description: 'Filename for JSON inputs, defaults to the task name under the data folder. ie: data/my_task.json',
116
+ }), directory: core_1.Flags.string({
117
+ char: 'd',
118
+ description: 'current directory to mount',
119
+ default: './',
120
+ }), 'include-optional': core_1.Flags.boolean({
121
+ description: 'used to only generate required properties',
122
+ }), force: core_1.Flags.boolean({
123
+ description: 'overwrites current files',
124
+ }) });
125
+ //# sourceMappingURL=data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.js","sourceRoot":"","sources":["../../../../src/commands/action/generate/data.ts"],"names":[],"mappings":";;;;AAAA,sCAAwC;AACxC,wCAGsB;AACtB,uCAA4C;AAC5C,gEAA+B;AAC/B,qCAAgC;AAChC,yCAAgD;AAChD,8DAA0B;AAC1B,kDAA0D;AAE1D,4CAAyD;AACzD,yDAAiD;AACjD,6CAAsC;AAEtC,qCAAqC;AACrC,MAAa,IAAK,SAAQ,WAAI;IA2B5B,KAAK,CAAC,GAAG;QACP,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,C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BAA4B;QACzC,OAAO,EAAE,IAAI;KACd,CAAC,EACF,kBAAkB,EAAE,YAAK,CAAC,OAAO,CAAC;QAChC,WAAW,EAAE,2CAA2C;KACzD,CAAC,EACF,KAAK,EAAE,YAAK,CAAC,OAAO,CAAC;QACnB,WAAW,EAAE,0BAA0B;KACxC,CAAC,IACF"}
@@ -0,0 +1,24 @@
1
+ import { Base } from '@sw-tsdk/core';
2
+ export declare class Image extends Base {
3
+ static description: string;
4
+ static hidden: boolean;
5
+ static flags: {
6
+ action: import("@oclif/core/lib/interfaces").OptionFlag<string>;
7
+ directory: import("@oclif/core/lib/interfaces").OptionFlag<string>;
8
+ 'input-path': import("@oclif/core/lib/interfaces").OptionFlag<string>;
9
+ 'output-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
10
+ 'error-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
11
+ 'asset-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
12
+ repository: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
13
+ version: import("@oclif/core/lib/interfaces").OptionFlag<string>;
14
+ platform: import("@oclif/core/lib/interfaces").OptionFlag<string>;
15
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
16
+ };
17
+ private docker;
18
+ private containerName;
19
+ run(): Promise<void>;
20
+ catch(error: Error & {
21
+ exitCode?: number;
22
+ }): Promise<void>;
23
+ cleanup(): Promise<void>;
24
+ }
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Image = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@oclif/core");
6
+ const core_2 = require("@sw-tsdk/core");
7
+ const node_path_1 = require("node:path");
8
+ const fs_extra_1 = require("fs-extra");
9
+ const docker_1 = require("@sw-tsdk/docker");
10
+ const node_process_1 = tslib_1.__importDefault(require("node:process"));
11
+ const slug_1 = tslib_1.__importDefault(require("slug"));
12
+ const docker_reference_1 = require("@swimlane/docker-reference");
13
+ const connector_1 = require("@sw-tsdk/connector");
14
+ // noinspection JSUnusedGlobalSymbols
15
+ class Image extends core_2.Base {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.docker = new docker_1.Docker();
19
+ }
20
+ async run() {
21
+ const { flags, } = await this.parse(Image);
22
+ let { directory, } = flags;
23
+ const { action, repository, version, } = flags;
24
+ directory = (0, node_path_1.resolve)(directory || node_process_1.default.cwd());
25
+ // ensure directory path
26
+ try {
27
+ await fs_extra_1.promises.access(directory);
28
+ }
29
+ catch (_a) {
30
+ this.error(`Could not access ${directory}`);
31
+ }
32
+ const inputPath = flags['input-path'] || (0, node_path_1.join)(directory, 'data', `${action}.json`);
33
+ const outputPath = flags['output-path'] || (0, node_path_1.join)(directory, 'data', `${action}_output.json`);
34
+ const errorPath = flags['error-path'] || (0, node_path_1.join)(directory, 'data', `${action}_error.txt`);
35
+ const assetPath = flags['asset-path'] || (0, node_path_1.join)(directory, 'data', 'asset.json');
36
+ if (!await (0, core_2.fileExists)(inputPath)) {
37
+ core_1.CliUx.ux.error(`Missing test data ${inputPath}`);
38
+ }
39
+ const asset = await (0, core_2.fileExists)(assetPath) ? await (0, fs_extra_1.readJson)(assetPath) : {};
40
+ // merge inputs and asset as 11.x sends it.
41
+ const inputs = JSON.stringify(Object.assign(await (0, fs_extra_1.readJson)(inputPath), asset));
42
+ // check that docker is running
43
+ core_1.CliUx.ux.action.start('Checking for docker...');
44
+ await this.docker.ping();
45
+ core_1.CliUx.ux.action.stop();
46
+ // Can run latest from quay, image provided, or default to the last built.
47
+ const image = `${repository}:${version}`;
48
+ core_1.CliUx.ux.action.start(`Pulling image ${image}...`);
49
+ await this.docker.pullImage(image);
50
+ await this.docker.pullImage('halverneus/static-file-server:latest');
51
+ core_1.CliUx.ux.action.stop();
52
+ await (0, fs_extra_1.ensureDir)((0, node_path_1.join)(directory, 'data', 'files'));
53
+ await fs_extra_1.promises.writeFile(outputPath, '{}');
54
+ await fs_extra_1.promises.writeFile(errorPath, '');
55
+ const containerReference = (0, docker_reference_1.parseQualifiedName)(image);
56
+ this.containerName = (0, slug_1.default)(containerReference.repository);
57
+ const cleanup = this.cleanup;
58
+ node_process_1.default.on('SIGINT', async function () {
59
+ await cleanup();
60
+ });
61
+ const environmentVars = Object.entries({
62
+ INPUTS: inputs,
63
+ IPC_API_URI: 'http://localhost:8080',
64
+ IPC_API_TOKEN: '',
65
+ }).map(([key, value]) => `${key}=${value !== null && value !== void 0 ? value : ''}`);
66
+ const createOptions = {
67
+ Env: environmentVars,
68
+ name: this.containerName,
69
+ AttachStdout: true,
70
+ AttachStderr: true,
71
+ Cmd: [action],
72
+ HostConfig: {
73
+ AutoRemove: true,
74
+ },
75
+ };
76
+ core_1.CliUx.ux.action.start('Executing...');
77
+ const outputFile = new connector_1.ContainerStdoutActionOutputTransform((0, fs_extra_1.createWriteStream)(outputPath));
78
+ const errorFile = await (0, fs_extra_1.createWriteStream)(errorPath);
79
+ const success = await this.docker.runImage(image, createOptions, outputFile, errorFile);
80
+ core_1.CliUx.ux.action.stop();
81
+ if (!success) {
82
+ core_1.Errors.exit(-1);
83
+ }
84
+ }
85
+ async catch(error) {
86
+ await this.cleanup();
87
+ throw error;
88
+ }
89
+ async cleanup() {
90
+ core_1.CliUx.ux.action.start('Removing stale containers...');
91
+ try {
92
+ await this.docker.deleteContainer('IPC_API');
93
+ }
94
+ catch (_a) { }
95
+ try {
96
+ await this.docker.deleteContainer(this.containerName);
97
+ }
98
+ catch (_b) { }
99
+ core_1.CliUx.ux.action.stop();
100
+ }
101
+ }
102
+ exports.Image = Image;
103
+ Image.description = 'Runs a connector action. (Defaults to current image version in local repository).';
104
+ Image.hidden = true;
105
+ Image.flags = Object.assign(Object.assign({}, core_2.Base.flags), { action: core_1.Flags.string({
106
+ char: 'a',
107
+ description: 'Action name to run',
108
+ required: true,
109
+ }), directory: core_1.Flags.string({
110
+ char: 'd',
111
+ description: 'Root directory of the repository.',
112
+ default: './',
113
+ }), 'input-path': core_1.Flags.string({
114
+ description: 'File to input data JSON file',
115
+ required: true,
116
+ }), 'output-path': core_1.Flags.string({
117
+ description: 'File to write the outputs to, defaults to /data/<action>_output.json',
118
+ }), 'error-path': core_1.Flags.string({
119
+ description: 'File to write the errors to, defaults to /data/<action>_error.json',
120
+ }), 'asset-path': core_1.Flags.string({
121
+ description: 'File to asset data JSON file, defaults to /data/asset.json',
122
+ }), repository: core_1.Flags.string({
123
+ char: 'r',
124
+ description: 'The connector image repository to run.',
125
+ }), version: core_1.Flags.string({
126
+ description: 'Use the latest release image from quay.',
127
+ default: 'latest',
128
+ }), platform: core_1.Flags.string({
129
+ hidden: true,
130
+ default: 'linux/amd64',
131
+ }), help: core_1.Flags.help({
132
+ char: 'h',
133
+ }) });
134
+ //# sourceMappingURL=image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.js","sourceRoot":"","sources":["../../../../src/commands/action/run/image.ts"],"names":[],"mappings":";;;;AAAA,sCAAgD;AAChD,wCAA8C;AAC9C,yCAAuC;AACvC,uCAAyE;AACzE,4CAAqD;AACrD,wEAAkC;AAClC,wDAAuB;AACvB,iEAA6D;AAC7D,kDAAuE;AAEvE,qCAAqC;AACrC,MAAa,KAAM,SAAQ,WAAI;IAA/B;;QA6CU,WAAM,GAAW,IAAI,eAAM,EAAE,CAAA;IAkHvC,CAAC;IA/GC,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,GACN,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAE3B,IAAI,EACF,SAAS,GACV,GAAG,KAAK,CAAA;QAET,MAAM,EACJ,MAAM,EACN,UAAU,EACV,OAAO,GACR,GAAG,KAAK,CAAA;QAET,SAAS,GAAG,IAAA,mBAAO,EAAC,SAAS,IAAI,sBAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QAE/C,wBAAwB;QACxB,IAAI;YACF,MAAM,mBAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;SACjC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FAAmF,CAAA;AACjG,YAAM,GAAG,IAAI,CAAA;AACb,WAAK,mCACP,WAAI,CAAC,KAAK,KACb,MAAM,EAAE,YAAK,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,oBAAoB;QACjC,QAAQ,EAAE,IAAI;KACf,CAAC,EACF,SAAS,EAAE,YAAK,CAAC,MAAM,CAAC;QACtB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,mCAAmC;QAChD,OAAO,EAAE,IAAI;KACd,CAAC,EACF,YAAY,EAAE,YAAK,CAAC,MAAM,CAAC;QACzB,WAAW,EAAE,8BAA8B;QAC3C,QAAQ,EAAE,IAAI;KACf,CAAC,EACF,aAAa,EAAE,YAAK,CAAC,MAAM,CAAC;QAC1B,WAAW,EAAE,sEAAsE;KACpF,CAAC,EACF,YAAY,EAAE,YAAK,CAAC,MAAM,CAAC;QACzB,WAAW,EAAE,oEAAoE;KAClF,CAAC,EACF,YAAY,EAAE,YAAK,CAAC,MAAM,CAAC;QACzB,WAAW,EAAE,4DAA4D;KAC1E,CAAC,EACF,UAAU,EAAE,YAAK,CAAC,MAAM,CAAC;QACvB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,wCAAwC;KACtD,CAAC,EACF,OAAO,EAAE,YAAK,CAAC,MAAM,CAAC;QACpB,WAAW,EAAE,yCAAyC;QACtD,OAAO,EAAE,QAAQ;KAClB,CAAC,EACF,QAAQ,EAAE,YAAK,CAAC,MAAM,CAAC;QACrB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,aAAa;KACvB,CAAC,EACF,IAAI,EAAE,YAAK,CAAC,IAAI,CAAC;QACf,IAAI,EAAE,GAAG;KACV,CAAC,IACH"}
@@ -1,5 +1,5 @@
1
1
  import { Base } from '@sw-tsdk/core';
2
- export declare class Run extends Base {
2
+ export declare class Local extends Base {
3
3
  static description: string;
4
4
  static flags: {
5
5
  action: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
@@ -8,9 +8,6 @@ export declare class Run extends Base {
8
8
  'output-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
9
9
  'error-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
10
10
  'asset-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
11
- image: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
12
- latest: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
- build: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
11
  template: import("@oclif/core/lib/interfaces").OptionFlag<string>;
15
12
  'compile-override': import("@oclif/core/lib/interfaces").OptionFlag<string>;
16
13
  'runner-override': import("@oclif/core/lib/interfaces").OptionFlag<string>;
@@ -19,5 +16,11 @@ export declare class Run extends Base {
19
16
  platform: import("@oclif/core/lib/interfaces").OptionFlag<string>;
20
17
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
21
18
  };
19
+ private docker;
20
+ private containerName;
22
21
  run(): Promise<void>;
22
+ catch(error: Error & {
23
+ exitCode?: number;
24
+ }): Promise<void>;
25
+ cleanup(): Promise<void>;
23
26
  }