@zalosai/zalos-cli 0.2.32 → 0.2.33

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.
@@ -1,6 +1,6 @@
1
1
  import { client } from '../client.js';
2
2
  import { currentEnvironment, ENVIRONMENTS } from '../environments.js';
3
- import { ApiError } from '../utils/errors.js';
3
+ import { ApiError, ValidationError } from '../utils/errors.js';
4
4
  import { printJson } from '../utils/output.js';
5
5
  import { action, resourceId } from '../utils/product-api.js';
6
6
  function inspectedVersion(identity) {
@@ -11,6 +11,17 @@ function shellArg(value) {
11
11
  }
12
12
  function renderReport(report, environment, actionKey) {
13
13
  const { worker, actions, dependencies } = report;
14
+ if (report.node) {
15
+ const { nodeName, nodeId, workflow, language, code } = report.node;
16
+ return [
17
+ worker.name + ' / ' + environment.name,
18
+ 'Action: ' + actionKey,
19
+ 'Workflow: ' + workflow.name + ' (' + workflow.id + ') · ' + inspectedVersion(workflow),
20
+ 'Node: ' + nodeName + ' (' + nodeId + ') · ' + language,
21
+ '',
22
+ code,
23
+ ].join('\n');
24
+ }
14
25
  const lines = [
15
26
  `${worker.name} ${worker.id} ${report.teamName} / ${environment.name}`,
16
27
  `${worker.visibility} · ${worker.publicationState} · ${worker.active ? 'active' : 'inactive'} · inspected ${inspectedVersion(worker)}`,
@@ -88,10 +99,19 @@ function renderReport(report, environment, actionKey) {
88
99
  }
89
100
  async function inspectWorker(id, options) {
90
101
  const environment = currentEnvironment();
91
- const query = options.action === undefined ? undefined : { action: options.action };
102
+ if (options.node !== undefined && !options.action)
103
+ throw new ValidationError('node', '--node requires --action');
104
+ const query = options.action === undefined
105
+ ? undefined
106
+ : {
107
+ action: options.action,
108
+ ...(options.node !== undefined ? { node: options.node } : {}),
109
+ };
92
110
  const { data } = await client.get(`/workers/${resourceId(id)}/inspect`, query);
93
111
  if (data?.schemaVersion !== 1 || !data.worker)
94
112
  throw new ApiError(502, 'Invalid Worker inspection response');
113
+ if (options.node !== undefined && !data.node)
114
+ throw new ApiError(502, 'Regional API did not return the requested node source');
95
115
  if (options.json || !process.stdout.isTTY)
96
116
  printJson({ ...data, environment: environment.name });
97
117
  else
@@ -104,6 +124,7 @@ export function registerWorkerCommand(program) {
104
124
  .command('inspect <id>')
105
125
  .description('Inspect the Worker configuration and its workflow dependencies')
106
126
  .option('--action <key>', 'Inspect one exact action key')
127
+ .option('--node <id>', 'Show inline code by node ID within the action (or workflow-id/node-id)')
107
128
  .option('--json', 'Print JSON (default when stdout is piped)')
108
129
  .action((id, options) => action(() => inspectWorker(id, options)));
109
130
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zalosai/zalos-cli",
3
- "version": "0.2.32",
3
+ "version": "0.2.33",
4
4
  "description": "API-only product command-line interface for Zalos",
5
5
  "repository": {
6
6
  "type": "git",