@knocklabs/cli 0.1.0 → 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.
Files changed (35) hide show
  1. package/README.md +142 -61
  2. package/dist/commands/commit/index.js +6 -3
  3. package/dist/commands/commit/promote.js +5 -2
  4. package/dist/commands/knock.js +102 -0
  5. package/dist/commands/ping.js +0 -4
  6. package/dist/commands/translation/get.js +13 -9
  7. package/dist/commands/translation/list.js +7 -3
  8. package/dist/commands/translation/pull.js +18 -9
  9. package/dist/commands/translation/push.js +10 -6
  10. package/dist/commands/translation/validate.js +11 -7
  11. package/dist/commands/whoami.js +3 -0
  12. package/dist/commands/workflow/activate.js +19 -8
  13. package/dist/commands/workflow/get.js +14 -10
  14. package/dist/commands/workflow/list.js +7 -3
  15. package/dist/commands/workflow/new.js +4 -5
  16. package/dist/commands/workflow/pull.js +17 -9
  17. package/dist/commands/workflow/push.js +9 -6
  18. package/dist/commands/workflow/run.js +56 -0
  19. package/dist/commands/workflow/validate.js +9 -6
  20. package/dist/lib/api-v1.js +14 -0
  21. package/dist/lib/base-command.js +8 -4
  22. package/dist/lib/helpers/flag.js +30 -1
  23. package/dist/lib/helpers/json.js +9 -0
  24. package/dist/lib/helpers/page.js +7 -2
  25. package/dist/lib/helpers/request.js +1 -1
  26. package/dist/lib/helpers/ux.js +2 -2
  27. package/dist/lib/marshal/translation/helpers.js +11 -5
  28. package/dist/lib/marshal/translation/reader.js +1 -1
  29. package/dist/lib/marshal/workflow/generator.js +1 -0
  30. package/dist/lib/marshal/workflow/helpers.js +19 -6
  31. package/dist/lib/marshal/workflow/reader.js +1 -1
  32. package/dist/lib/marshal/workflow/types.js +1 -0
  33. package/dist/lib/run-context/helpers.js +2 -2
  34. package/oclif.manifest.json +169 -25
  35. package/package.json +23 -17
@@ -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);
@@ -159,18 +172,18 @@ const ensureValidCommandTarget = async (props, runContext)=>{
159
172
  // If the target resource is a different type than the current resource dir
160
173
  // type, error out.
161
174
  if (resourceDirCtx && resourceDirCtx.type !== "workflow") {
162
- return _core.CliUx.ux.error(`Cannot run ${commandId} inside a ${resourceDirCtx.type} directory`);
175
+ return _core.ux.error(`Cannot run ${commandId} inside a ${resourceDirCtx.type} directory`);
163
176
  }
164
177
  // Cannot accept both workflow key arg and --all flag.
165
178
  if (flags.all && args.workflowKey) {
166
- return _core.CliUx.ux.error(`workflowKey arg \`${args.workflowKey}\` cannot also be provided when using --all`);
179
+ return _core.ux.error(`workflowKey arg \`${args.workflowKey}\` cannot also be provided when using --all`);
167
180
  }
168
181
  // --all flag is given, which means no workflow key arg.
169
182
  if (flags.all) {
170
183
  // If --all flag used inside a workflow directory, then require a workflows
171
184
  // dir path.
172
185
  if (resourceDirCtx && !flags["workflows-dir"]) {
173
- return _core.CliUx.ux.error("Missing required flag workflows-dir");
186
+ return _core.ux.error("Missing required flag workflows-dir");
174
187
  }
175
188
  // Targeting all workflow dirs in the workflows index dir.
176
189
  // TODO: Default to the knock project config first if present before cwd.
@@ -187,7 +200,7 @@ const ensureValidCommandTarget = async (props, runContext)=>{
187
200
  // Workflow key arg is given, which means no --all flag.
188
201
  if (args.workflowKey) {
189
202
  if (resourceDirCtx && resourceDirCtx.key !== args.workflowKey) {
190
- return _core.CliUx.ux.error(`Cannot run ${commandId} \`${args.workflowKey}\` inside another workflow directory:\n${resourceDirCtx.key}`);
203
+ return _core.ux.error(`Cannot run ${commandId} \`${args.workflowKey}\` inside another workflow directory:\n${resourceDirCtx.key}`);
191
204
  }
192
205
  const targetDirPath = resourceDirCtx ? resourceDirCtx.abspath : _nodePath.resolve(runCwd, args.workflowKey);
193
206
  const workflowDirCtx = {
@@ -209,5 +222,5 @@ const ensureValidCommandTarget = async (props, runContext)=>{
209
222
  context: resourceDirCtx
210
223
  };
211
224
  }
212
- return _core.CliUx.ux.error("Missing 1 required arg:\nworkflowKey");
225
+ return _core.ux.error("Missing 1 required arg:\nworkflowKey");
213
226
  };
@@ -278,7 +278,7 @@ const readAllForCommandTarget = async (target, opts = {})=>{
278
278
  const { type: targetType , context: targetCtx } = target;
279
279
  if (!targetCtx.exists) {
280
280
  const subject = targetType === "workflowDir" ? "a workflow directory at" : "workflow directories in";
281
- return _core.CliUx.ux.error(`Cannot locate ${subject} \`${targetCtx.abspath}\``);
281
+ return _core.ux.error(`Cannot locate ${subject} \`${targetCtx.abspath}\``);
282
282
  }
283
283
  switch(targetType){
284
284
  case "workflowDir":
@@ -12,4 +12,5 @@ var StepType;
12
12
  StepType["Batch"] = "batch";
13
13
  StepType["Delay"] = "delay";
14
14
  StepType["HttpFetch"] = "http_fetch";
15
+ StepType["Throttle"] = "throttle";
15
16
  })(StepType || (StepType = {}));
@@ -11,7 +11,7 @@ const ensureResourceDirForTarget = (resourceDirCtx, target)=>{
11
11
  // If the target resource is a different type than the current resource dir
12
12
  // type, error out.
13
13
  if (resourceDirCtx.type !== target.type) {
14
- return _core.CliUx.ux.error(`Cannot run ${target.commandId} inside a ${resourceDirCtx.type} directory`);
14
+ return _core.ux.error(`Cannot run ${target.commandId} inside a ${resourceDirCtx.type} directory`);
15
15
  }
16
16
  // If the resource key was not provided with the command, then infer from the
17
17
  // current resource directory context.
@@ -23,5 +23,5 @@ const ensureResourceDirForTarget = (resourceDirCtx, target)=>{
23
23
  if (target.key === resourceDirCtx.key) {
24
24
  return resourceDirCtx;
25
25
  }
26
- return _core.CliUx.ux.error(`Cannot run ${target.commandId} \`${target.key}\` inside another ${resourceDirCtx.type} directory:\n${resourceDirCtx.key}`);
26
+ return _core.ux.error(`Cannot run ${target.commandId} \`${target.key}\` inside another ${resourceDirCtx.type} directory:\n${resourceDirCtx.key}`);
27
27
  };