@knocklabs/cli 0.1.3 → 0.1.4
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 +13 -9
- package/dist/commands/workflow/run.js +6 -8
- package/dist/lib/api-v1.js +4 -2
- package/dist/lib/helpers/flag.js +19 -1
- package/dist/lib/helpers/json.js +9 -0
- package/dist/lib/marshal/workflow/generator.js +1 -0
- package/dist/lib/marshal/workflow/helpers.js +14 -1
- package/dist/lib/marshal/workflow/types.js +1 -0
- package/oclif.manifest.json +6 -7
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ $ npm install -g @knocklabs/cli
|
|
|
16
16
|
$ knock COMMAND
|
|
17
17
|
running command...
|
|
18
18
|
$ knock (--version)
|
|
19
|
-
@knocklabs/cli/0.1.
|
|
19
|
+
@knocklabs/cli/0.1.4 linux-x64 node-v18.16.1
|
|
20
20
|
$ knock --help [COMMAND]
|
|
21
21
|
USAGE
|
|
22
22
|
$ knock COMMAND
|
|
@@ -70,7 +70,7 @@ FLAGS
|
|
|
70
70
|
--service-token=<value> (required) The service token to authenticate with.
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
_See code: [dist/commands/commit/index.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
73
|
+
_See code: [dist/commands/commit/index.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.4/dist/commands/commit/index.ts)_
|
|
74
74
|
|
|
75
75
|
## `knock commit promote`
|
|
76
76
|
|
|
@@ -104,7 +104,7 @@ DESCRIPTION
|
|
|
104
104
|
Display help for knock.
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.
|
|
107
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.11/src/commands/help.ts)_
|
|
108
108
|
|
|
109
109
|
## `knock plugins`
|
|
110
110
|
|
|
@@ -112,11 +112,14 @@ List installed plugins.
|
|
|
112
112
|
|
|
113
113
|
```
|
|
114
114
|
USAGE
|
|
115
|
-
$ knock plugins [--core]
|
|
115
|
+
$ knock plugins [--json] [--core]
|
|
116
116
|
|
|
117
117
|
FLAGS
|
|
118
118
|
--core Show core plugins.
|
|
119
119
|
|
|
120
|
+
GLOBAL FLAGS
|
|
121
|
+
--json Format output as json.
|
|
122
|
+
|
|
120
123
|
DESCRIPTION
|
|
121
124
|
List installed plugins.
|
|
122
125
|
|
|
@@ -124,7 +127,7 @@ EXAMPLES
|
|
|
124
127
|
$ knock plugins
|
|
125
128
|
```
|
|
126
129
|
|
|
127
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.
|
|
130
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.6/src/commands/plugins/index.ts)_
|
|
128
131
|
|
|
129
132
|
## `knock plugins:install PLUGIN...`
|
|
130
133
|
|
|
@@ -469,7 +472,7 @@ GLOBAL FLAGS
|
|
|
469
472
|
--json Format output as json.
|
|
470
473
|
```
|
|
471
474
|
|
|
472
|
-
_See code: [dist/commands/whoami.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
475
|
+
_See code: [dist/commands/whoami.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.4/dist/commands/whoami.ts)_
|
|
473
476
|
|
|
474
477
|
## `knock workflow activate WORKFLOWKEY`
|
|
475
478
|
|
|
@@ -574,7 +577,7 @@ FLAGS
|
|
|
574
577
|
|
|
575
578
|
## `knock workflow run WORKFLOWKEY`
|
|
576
579
|
|
|
577
|
-
Test run a workflow using the latest version from Knock
|
|
580
|
+
Test run a workflow using the latest version from Knock.
|
|
578
581
|
|
|
579
582
|
```
|
|
580
583
|
USAGE
|
|
@@ -582,10 +585,11 @@ USAGE
|
|
|
582
585
|
<value>] [--tenant <value>] [--data <value>]
|
|
583
586
|
|
|
584
587
|
FLAGS
|
|
585
|
-
--actor=<value> An actor id for the workflow run.
|
|
588
|
+
--actor=<value> An actor id, or a JSON string of an actor object reference for the workflow run.
|
|
586
589
|
--data=<value> A JSON string of the data for this workflow
|
|
587
590
|
--environment=<value> [default: development] The environment in which to run the workflow
|
|
588
|
-
--recipients=<value
|
|
591
|
+
--recipients=<value> (required) One or more recipient user ids separated by comma, or a JSON string containing one
|
|
592
|
+
or more recipient object references for this workflow run.
|
|
589
593
|
--service-token=<value> (required) The service token to authenticate with.
|
|
590
594
|
--tenant=<value> A tenant id for the workflow run.
|
|
591
595
|
```
|
|
@@ -23,26 +23,24 @@ class WorkflowRun extends _baseCommand.default {
|
|
|
23
23
|
action: "‣ Running"
|
|
24
24
|
});
|
|
25
25
|
this.log(`‣ Successfully ran \`${args.workflowKey}\` workflow in \`${flags.environment}\` environment`);
|
|
26
|
-
this.log((0, _string.indentString)(`Workflow run id: ${resp.data.workflow_run_id}
|
|
26
|
+
this.log((0, _string.indentString)(`Workflow run id: ${resp.data.workflow_run_id}`, 4));
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
WorkflowRun.summary = "Test run a workflow using the latest version from Knock
|
|
29
|
+
WorkflowRun.summary = "Test run a workflow using the latest version from Knock.";
|
|
30
30
|
WorkflowRun.flags = {
|
|
31
31
|
environment: _core.Flags.string({
|
|
32
32
|
default: "development",
|
|
33
33
|
summary: "The environment in which to run the workflow"
|
|
34
34
|
}),
|
|
35
|
-
recipients:
|
|
35
|
+
recipients: (0, _flag.maybeJsonStrAsList)({
|
|
36
36
|
required: true,
|
|
37
37
|
aliases: [
|
|
38
38
|
"recipient"
|
|
39
39
|
],
|
|
40
|
-
summary: "One or more recipient ids for this workflow run
|
|
41
|
-
multiple: true,
|
|
42
|
-
delimiter: ","
|
|
40
|
+
summary: "One or more recipient user ids separated by comma, or a JSON string containing one or more recipient object references for this workflow run."
|
|
43
41
|
}),
|
|
44
|
-
actor:
|
|
45
|
-
summary: "An actor id for the workflow run."
|
|
42
|
+
actor: (0, _flag.maybeJsonStr)({
|
|
43
|
+
summary: "An actor id, or a JSON string of an actor object reference for the workflow run."
|
|
46
44
|
}),
|
|
47
45
|
tenant: _core.Flags.string({
|
|
48
46
|
summary: "A tenant id for the workflow run."
|
package/dist/lib/api-v1.js
CHANGED
|
@@ -81,13 +81,15 @@ class ApiV1 {
|
|
|
81
81
|
}
|
|
82
82
|
async runWorkflow({ args , flags }) {
|
|
83
83
|
const params = (0, _object.prune)({
|
|
84
|
-
environment: flags.environment
|
|
84
|
+
environment: flags.environment
|
|
85
|
+
});
|
|
86
|
+
const data = (0, _object.prune)({
|
|
85
87
|
recipients: flags.recipients,
|
|
86
88
|
tenant: flags.tenant,
|
|
87
89
|
data: flags.data,
|
|
88
90
|
actor: flags.actor
|
|
89
91
|
});
|
|
90
|
-
return this.put(`/workflows/${args.workflowKey}/run`,
|
|
92
|
+
return this.put(`/workflows/${args.workflowKey}/run`, data, {
|
|
91
93
|
params
|
|
92
94
|
});
|
|
93
95
|
}
|
package/dist/lib/helpers/flag.js
CHANGED
|
@@ -11,11 +11,14 @@ function _export(target, all) {
|
|
|
11
11
|
_export(exports, {
|
|
12
12
|
booleanStr: ()=>booleanStr,
|
|
13
13
|
dirPath: ()=>dirPath,
|
|
14
|
-
jsonStr: ()=>jsonStr
|
|
14
|
+
jsonStr: ()=>jsonStr,
|
|
15
|
+
maybeJsonStr: ()=>maybeJsonStr,
|
|
16
|
+
maybeJsonStrAsList: ()=>maybeJsonStrAsList
|
|
15
17
|
});
|
|
16
18
|
const _nodePath = /*#__PURE__*/ _interopRequireWildcard(require("node:path"));
|
|
17
19
|
const _core = require("@oclif/core");
|
|
18
20
|
const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
|
|
21
|
+
const _json = require("./json");
|
|
19
22
|
function _getRequireWildcardCache(nodeInterop) {
|
|
20
23
|
if (typeof WeakMap !== "function") return null;
|
|
21
24
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -85,3 +88,18 @@ const jsonStr = _core.Flags.custom({
|
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
});
|
|
91
|
+
const maybeJsonStr = _core.Flags.custom({
|
|
92
|
+
parse: async (input)=>{
|
|
93
|
+
return (0, _json.tryJsonParse)(input);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
const maybeJsonStrAsList = _core.Flags.custom({
|
|
97
|
+
parse: async (input)=>{
|
|
98
|
+
const data = (0, _json.tryJsonParse)(input);
|
|
99
|
+
if (typeof data === "string") return data.split(",");
|
|
100
|
+
if (Array.isArray(data)) return data;
|
|
101
|
+
return [
|
|
102
|
+
data
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
});
|
package/dist/lib/helpers/json.js
CHANGED
|
@@ -11,6 +11,7 @@ function _export(target, all) {
|
|
|
11
11
|
_export(exports, {
|
|
12
12
|
DOUBLE_SPACES: ()=>DOUBLE_SPACES,
|
|
13
13
|
parseJson: ()=>parseJson,
|
|
14
|
+
tryJsonParse: ()=>tryJsonParse,
|
|
14
15
|
readJson: ()=>readJson
|
|
15
16
|
});
|
|
16
17
|
const _jsonlint = /*#__PURE__*/ _interopRequireWildcard(require("@prantlf/jsonlint"));
|
|
@@ -71,6 +72,14 @@ const parseJson = (json)=>{
|
|
|
71
72
|
errors
|
|
72
73
|
];
|
|
73
74
|
};
|
|
75
|
+
const tryJsonParse = (maybeJson)=>{
|
|
76
|
+
try {
|
|
77
|
+
const data = JSON.parse(maybeJson);
|
|
78
|
+
return data;
|
|
79
|
+
} catch {
|
|
80
|
+
return maybeJson;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
74
83
|
const readJson = async (filePath)=>{
|
|
75
84
|
const json = await _fsExtra.readFile(filePath, "utf8");
|
|
76
85
|
return parseJson(json);
|
|
@@ -106,14 +106,26 @@ const formatCategories = (workflow, opts = {})=>{
|
|
|
106
106
|
};
|
|
107
107
|
const batchStepSummaryLines = (step)=>{
|
|
108
108
|
if (step.type !== _types.StepType.Batch) return [];
|
|
109
|
-
const { batch_key , batch_window: duration , batch_until_field_path: field_path , batch_order } = step.settings;
|
|
109
|
+
const { batch_key , batch_window_type , batch_window: duration , batch_window_extension_limit , batch_until_field_path: field_path , batch_order } = step.settings;
|
|
110
110
|
return [
|
|
111
111
|
batch_key && `Batch key: ${batch_key}`,
|
|
112
112
|
duration && `Batch window: ${duration.value} ${duration.unit}`,
|
|
113
113
|
field_path && `Batch window: "${field_path}"`,
|
|
114
|
+
`Batch window type: ${batch_window_type}`,
|
|
115
|
+
batch_window_extension_limit && `Batch window extension limit: ${batch_window_extension_limit.value} ${batch_window_extension_limit.unit}`,
|
|
114
116
|
`Batch order: ${batch_order}`
|
|
115
117
|
];
|
|
116
118
|
};
|
|
119
|
+
const throttleStepSummaryLines = (step)=>{
|
|
120
|
+
if (step.type !== _types.StepType.Throttle) return [];
|
|
121
|
+
const { throttle_key , throttle_window: duration , throttle_window_field_path: field_path , throttle_limit } = step.settings;
|
|
122
|
+
return [
|
|
123
|
+
throttle_key && `Throttle key: ${throttle_key}`,
|
|
124
|
+
duration && `Throttle window: ${duration.value} ${duration.unit}`,
|
|
125
|
+
field_path && `Throttle window: "${field_path}"`,
|
|
126
|
+
`Throttle limit: ${throttle_limit}`
|
|
127
|
+
];
|
|
128
|
+
};
|
|
117
129
|
const delayStepSummaryLines = (step)=>{
|
|
118
130
|
if (step.type !== _types.StepType.Delay) return [];
|
|
119
131
|
const { delay_for: duration , delay_until_field_path: field_path } = step.settings;
|
|
@@ -145,6 +157,7 @@ const formatStepSummary = (step)=>{
|
|
|
145
157
|
...batchStepSummaryLines(step),
|
|
146
158
|
...delayStepSummaryLines(step),
|
|
147
159
|
...httpFetchStepSummaryLines(step),
|
|
160
|
+
...throttleStepSummaryLines(step),
|
|
148
161
|
// Extra line between step rows to make it easier on the eye.
|
|
149
162
|
" "
|
|
150
163
|
].filter((x)=>x);
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
2
|
+
"version": "0.1.4",
|
|
3
3
|
"commands": {
|
|
4
4
|
"knock": {
|
|
5
5
|
"id": "knock",
|
|
@@ -840,7 +840,7 @@
|
|
|
840
840
|
},
|
|
841
841
|
"workflow:run": {
|
|
842
842
|
"id": "workflow:run",
|
|
843
|
-
"summary": "Test run a workflow using the latest version from Knock
|
|
843
|
+
"summary": "Test run a workflow using the latest version from Knock.",
|
|
844
844
|
"strict": true,
|
|
845
845
|
"pluginName": "@knocklabs/cli",
|
|
846
846
|
"pluginAlias": "@knocklabs/cli",
|
|
@@ -871,18 +871,17 @@
|
|
|
871
871
|
"recipients": {
|
|
872
872
|
"name": "recipients",
|
|
873
873
|
"type": "option",
|
|
874
|
-
"summary": "One or more recipient ids for this workflow run
|
|
874
|
+
"summary": "One or more recipient user ids separated by comma, or a JSON string containing one or more recipient object references for this workflow run.",
|
|
875
875
|
"required": true,
|
|
876
|
-
"multiple":
|
|
876
|
+
"multiple": false,
|
|
877
877
|
"aliases": [
|
|
878
878
|
"recipient"
|
|
879
|
-
]
|
|
880
|
-
"delimiter": ","
|
|
879
|
+
]
|
|
881
880
|
},
|
|
882
881
|
"actor": {
|
|
883
882
|
"name": "actor",
|
|
884
883
|
"type": "option",
|
|
885
|
-
"summary": "An actor id for the workflow run.",
|
|
884
|
+
"summary": "An actor id, or a JSON string of an actor object reference for the workflow run.",
|
|
886
885
|
"multiple": false
|
|
887
886
|
},
|
|
888
887
|
"tenant": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knocklabs/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Knock CLI",
|
|
5
5
|
"author": "@knocklabs",
|
|
6
6
|
"bin": {
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
"date-fns": "^2.30.0",
|
|
26
26
|
"enquirer": "^2.3.6",
|
|
27
27
|
"fs-extra": "^11.1.1",
|
|
28
|
-
"liquidjs": "^10.
|
|
28
|
+
"liquidjs": "^10.8.3",
|
|
29
29
|
"locale-codes": "^1.3.1",
|
|
30
30
|
"lodash": "^4.17.21",
|
|
31
|
-
"yup": "^1.
|
|
31
|
+
"yup": "^1.2.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@oclif/test": "^2.3.
|
|
34
|
+
"@oclif/test": "^2.3.23",
|
|
35
35
|
"@swc/cli": "^0.1.62",
|
|
36
36
|
"@swc/core": "^1.3.37",
|
|
37
37
|
"@swc/helpers": "^0.4.14",
|
|
38
38
|
"@types/chai": "^4",
|
|
39
39
|
"@types/fs-extra": "^11.0.1",
|
|
40
40
|
"@types/mocha": "^10.0.1",
|
|
41
|
-
"@types/node": "^20.
|
|
41
|
+
"@types/node": "^20.4.1",
|
|
42
42
|
"chai": "^4",
|
|
43
43
|
"eslint": "^7.32.0",
|
|
44
44
|
"eslint-config-oclif": "^4",
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
"oclif": "^3",
|
|
52
52
|
"prettier": "2.8.8",
|
|
53
53
|
"shx": "^0.3.4",
|
|
54
|
-
"sinon": "^15.
|
|
54
|
+
"sinon": "^15.2.0",
|
|
55
55
|
"ts-node": "^10.9.1",
|
|
56
56
|
"tsconfig-paths": "^4.2.0",
|
|
57
|
-
"tslib": "^2.5.
|
|
58
|
-
"typescript": "^5.
|
|
57
|
+
"tslib": "^2.5.3",
|
|
58
|
+
"typescript": "^5.1.3"
|
|
59
59
|
},
|
|
60
60
|
"oclif": {
|
|
61
61
|
"bin": "knock",
|