@sonisoft/now-sdk-ext-cli 5.2.0 → 5.4.0

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.
@@ -0,0 +1,31 @@
1
+ import { AuthenticatedCommand } from '../../common/authenticated-command.js';
2
+ export declare class FlowDefinition extends AuthenticatedCommand<typeof FlowDefinition> {
3
+ static args: {};
4
+ static description: string;
5
+ static examples: {
6
+ description: string;
7
+ command: string;
8
+ }[];
9
+ static flags: {
10
+ 'sys-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
+ type: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<"action" | "flow" | "subflow", import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
+ scope: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
13
+ json: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
14
+ };
15
+ run(): Promise<void>;
16
+ /**
17
+ * Fail with the reason core classified, plus the remediation that goes with it.
18
+ *
19
+ * Only the failure classification and the message core produced are logged —
20
+ * never the response body.
21
+ */
22
+ private _failDefinition;
23
+ /**
24
+ * Call the one core method that matches the requested type.
25
+ *
26
+ * Each type maps to exactly one design-time read. Nothing here executes,
27
+ * tests, publishes or creates a context.
28
+ */
29
+ private _retrieve;
30
+ }
31
+ //# sourceMappingURL=definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/commands/flow/definition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAkD5E,qBAAa,cAAe,SAAQ,oBAAoB,CAAC,OAAO,cAAc,CAAC;IAE7E,MAAM,CAAC,IAAI,KAAK;IAChB,MAAM,CAAC,WAAW,SAa4C;IAC9D,MAAM,CAAC,QAAQ;;;QAqBd;IACD,MAAM,CAAC,KAAK;;;;;MAwBX;IAEK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B1B;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAevB;;;;;OAKG;YACW,SAAS;CA6BxB"}
@@ -0,0 +1,166 @@
1
+ /* eslint-disable perfectionist/sort-objects */
2
+ import { Flags } from '@oclif/core';
3
+ import { FlowManager } from '@sonisoft/now-sdk-ext-core';
4
+ import { AuthenticatedCommand } from '../../common/authenticated-command.js';
5
+ import { FlowDisplayService } from '../../services/flow-display.service.js';
6
+ /**
7
+ * Remediation per machine-readable failure reason. Core classifies the failure;
8
+ * the CLI is the only layer that knows which flag would have avoided it.
9
+ */
10
+ const REMEDIATION = {
11
+ api_error: [
12
+ 'ServiceNow answered with an error. Re-run with --log-level debug to see the request detail.',
13
+ 'If the artifact lives in a scoped application, pass --scope with its scope sys_id or name.',
14
+ ],
15
+ invalid_identifier: [
16
+ 'Pass the 32-character sys_id of the artifact, not its name.',
17
+ 'The sys_id is in the sys_id= parameter of the Workflow Studio URL, or in the record list.',
18
+ ],
19
+ malformed_response: [
20
+ 'The instance returned a body this version does not recognise.',
21
+ 'Check that Flow Designer is active on the instance and that the family version is supported.',
22
+ ],
23
+ not_found: [
24
+ 'Confirm the sys_id exists on this instance — and that --auth points at the instance you meant.',
25
+ 'A deleted or not-yet-deployed artifact reports the same way as a wrong sys_id.',
26
+ ],
27
+ permission_denied: [
28
+ 'The authenticated user needs read access to Flow Designer design-time records.',
29
+ 'Retry with an account holding the flow_designer (or admin) role.',
30
+ ],
31
+ request_failed: [
32
+ 'The request did not complete. Check connectivity and the instance URL for this alias.',
33
+ 'Run "nex auth doctor" to confirm the credential resolves.',
34
+ ],
35
+ type_mismatch: [
36
+ 'The sys_id exists but is a different artifact type than the one requested.',
37
+ 'Retry with the matching --type: flow, subflow, or action.',
38
+ ],
39
+ };
40
+ export class FlowDefinition extends AuthenticatedCommand {
41
+ static args = {};
42
+ static description = 'Retrieve the read-only design-time definition of a flow, subflow, or action.\n\n' +
43
+ 'Returns what the artifact IS, not what a run of it did: triggers, actions, ' +
44
+ 'nested subflows, flow logic, inputs and outputs as Workflow Studio stores ' +
45
+ 'them. Nothing is executed, published or modified, and no flow context is ' +
46
+ 'created or required.\n\n' +
47
+ 'This is the design-time counterpart to `flow details`, which describes one ' +
48
+ 'past execution and needs a context sys_id.\n\n' +
49
+ 'The type is never inferred from the sys_id: --type selects the artifact ' +
50
+ 'that is asked for, and a sys_id of a different type fails with a ' +
51
+ 'type_mismatch rather than being relabelled.\n\n' +
52
+ 'With --json, stdout carries exactly one JSON document — the complete typed ' +
53
+ 'result including the untouched ServiceNow payload — so it can be piped or ' +
54
+ 'redirected. Without it, a short summary is printed; definition bodies, ' +
55
+ 'step scripts and input values are never printed or logged.';
56
+ static examples = [
57
+ {
58
+ description: 'Summarise a flow definition',
59
+ command: '<%= config.bin %> <%= command.id %> --sys-id 887dda5583237210fdb8f7b6feaad32c --auth dev',
60
+ },
61
+ {
62
+ description: 'Retrieve a subflow definition',
63
+ command: '<%= config.bin %> <%= command.id %> -i 887dda5583237210fdb8f7b6feaad32c --type subflow --auth dev',
64
+ },
65
+ {
66
+ description: 'Retrieve a custom action definition with its ordered steps',
67
+ command: '<%= config.bin %> <%= command.id %> -i 887dda5583237210fdb8f7b6feaad32c --type action --auth dev',
68
+ },
69
+ {
70
+ description: 'Redirect the full JSON definition to a file',
71
+ command: '<%= config.bin %> <%= command.id %> -i 887dda5583237210fdb8f7b6feaad32c --json --auth dev > flow.json',
72
+ },
73
+ {
74
+ description: 'Pipe the JSON definition into another tool',
75
+ command: '<%= config.bin %> <%= command.id %> -i 887dda5583237210fdb8f7b6feaad32c --type action --json --auth dev | jq .summary.steps',
76
+ },
77
+ ];
78
+ static flags = {
79
+ 'sys-id': Flags.string({
80
+ char: 'i',
81
+ description: 'sys_id of the flow, subflow, or action to retrieve',
82
+ required: true,
83
+ }),
84
+ 'type': Flags.option({
85
+ char: 't',
86
+ description: 'Artifact type to retrieve. Must match what the sys_id actually is.',
87
+ required: false,
88
+ default: 'flow',
89
+ options: ['flow', 'subflow', 'action'],
90
+ })(),
91
+ 'scope': Flags.string({
92
+ description: 'Scope sys_id or name for the transaction scope parameter. ' +
93
+ "Optional — ServiceNow resolves the artifact's own scope when omitted.",
94
+ required: false,
95
+ }),
96
+ 'json': Flags.boolean({
97
+ char: 'j',
98
+ description: 'Output the complete typed result as JSON',
99
+ required: false,
100
+ default: false,
101
+ }),
102
+ };
103
+ async run() {
104
+ const { flags } = await this.parse(FlowDefinition);
105
+ const displayService = new FlowDisplayService();
106
+ const artifact = flags.type;
107
+ const sysId = flags['sys-id'];
108
+ // Progress goes through this.log, which oclif suppresses under --json — that
109
+ // is what keeps stdout to a single JSON document for piping.
110
+ this.log(`Retrieving ${artifact} definition: ${sysId}`);
111
+ const outcome = await this._retrieve(artifact, sysId, flags.scope);
112
+ if (!outcome.result.success) {
113
+ this._failDefinition(artifact, sysId, outcome.result);
114
+ }
115
+ const lines = outcome.artifact === 'action'
116
+ ? displayService.formatActionDefinitionResult(outcome.result, flags.json)
117
+ : displayService.formatArtifactDefinitionResult(outcome.result, flags.json);
118
+ for (const line of lines) {
119
+ flags.json ? console.log(line) : this.log(line);
120
+ }
121
+ }
122
+ /**
123
+ * Fail with the reason core classified, plus the remediation that goes with it.
124
+ *
125
+ * Only the failure classification and the message core produced are logged —
126
+ * never the response body.
127
+ */
128
+ _failDefinition(artifact, sysId, result) {
129
+ const reason = result.failureReason ?? 'request_failed';
130
+ const detail = result.errorMessage ?? `ServiceNow did not return a ${artifact} definition.`;
131
+ this._logger.error('Design-time definition retrieval failed.', { artifact, failureReason: reason, sysId });
132
+ this.error(`Could not retrieve the ${artifact} definition for ${sysId} [${reason}]: ${detail}`, {
133
+ suggestions: REMEDIATION[reason] ?? REMEDIATION.request_failed,
134
+ });
135
+ }
136
+ /**
137
+ * Call the one core method that matches the requested type.
138
+ *
139
+ * Each type maps to exactly one design-time read. Nothing here executes,
140
+ * tests, publishes or creates a context.
141
+ */
142
+ async _retrieve(artifact, sysId, scope) {
143
+ // No scope in the constructor: the design-time routes take the transaction
144
+ // scope as a request option, not through a background script.
145
+ const flowManager = new FlowManager(this.instance);
146
+ const options = scope ? { scope } : undefined;
147
+ try {
148
+ switch (artifact) {
149
+ case 'action': {
150
+ return { artifact, result: await flowManager.getActionDefinition(sysId, options) };
151
+ }
152
+ case 'subflow': {
153
+ return { artifact, result: await flowManager.getSubflowDefinition(sysId, options) };
154
+ }
155
+ default: {
156
+ return { artifact, result: await flowManager.getFlowDesignDefinition(sysId, options) };
157
+ }
158
+ }
159
+ }
160
+ catch (error) {
161
+ this._logger.error('Error retrieving flow design-time definition.', error);
162
+ return this.error(error);
163
+ }
164
+ }
165
+ }
166
+ //# sourceMappingURL=definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/commands/flow/definition.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAA+E,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAErI,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAA;AAc3E;;;GAGG;AACH,MAAM,WAAW,GAA6B;IAC5C,SAAS,EAAE;QACT,6FAA6F;QAC7F,4FAA4F;KAC7F;IACD,kBAAkB,EAAE;QAClB,6DAA6D;QAC7D,2FAA2F;KAC5F;IACD,kBAAkB,EAAE;QAClB,+DAA+D;QAC/D,8FAA8F;KAC/F;IACD,SAAS,EAAE;QACT,gGAAgG;QAChG,gFAAgF;KACjF;IACD,iBAAiB,EAAE;QACjB,gFAAgF;QAChF,kEAAkE;KACnE;IACD,cAAc,EAAE;QACd,uFAAuF;QACvF,2DAA2D;KAC5D;IACD,aAAa,EAAE;QACb,4EAA4E;QAC5E,2DAA2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AAE,MAAM,EAAE,MAAM,WAAW,CAAC,uBAAuB,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;gBACzF,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,+CAA+C,EAAE,KAAc,CAAC,CAAC;YACpF,OAAO,IAAI,CAAC,KAAK,CAAC,KAAc,CAAC,CAAC;QACpC,CAAC;IACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type KillTransactionResult } from '@sonisoft/now-sdk-ext-core';
2
+ import { AuthenticatedCommand } from '../../common/authenticated-command.js';
3
+ export default class TransactionKill extends AuthenticatedCommand<typeof TransactionKill> {
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ confirm: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
8
+ 'transaction-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
+ };
10
+ run(): Promise<KillTransactionResult>;
11
+ }
12
+ //# sourceMappingURL=kill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kill.d.ts","sourceRoot":"","sources":["../../../src/commands/transaction/kill.ts"],"names":[],"mappings":"AACA,OAAO,EAA6C,KAAK,qBAAqB,EAAC,MAAM,4BAA4B,CAAA;AAEjH,OAAO,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAA;AAE1E,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,oBAAoB,CAAC,OAAO,eAAe,CAAC;IACvF,MAAM,CAAC,WAAW,SAGuC;IACzD,MAAM,CAAC,QAAQ,WAGd;IACD,MAAM,CAAC,KAAK;;;MAOX;IAEY,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC;CA8BnD"}
@@ -0,0 +1,48 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { ClusterTransactionManager, isPolicyRefusal } from '@sonisoft/now-sdk-ext-core';
3
+ import { AuthenticatedCommand } from '../../common/authenticated-command.js';
4
+ export default class TransactionKill extends AuthenticatedCommand {
5
+ static description = 'Submit a request to terminate one active transaction. Platform acceptance does not mean immediate removal.\n\n' +
6
+ 'Only pass an identifier you deliberately selected from `nex transaction list`. ' +
7
+ "Killing another user's transaction aborts their work.";
8
+ static examples = [
9
+ '<%= config.bin %> <%= command.id %> --transaction-id 8f9a1234567890abcdef1234567890c1 --confirm --auth dev',
10
+ '<%= config.bin %> <%= command.id %> --transaction-id 8f9a1234567890abcdef1234567890c1 --confirm --json --auth dev',
11
+ ];
12
+ static flags = {
13
+ confirm: Flags.boolean({ description: 'Confirm submission of the kill request.' }),
14
+ 'transaction-id': Flags.string({
15
+ char: 't',
16
+ description: 'Exact 32-character hexadecimal sys_id from `nex transaction list`.',
17
+ required: true,
18
+ }),
19
+ };
20
+ async run() {
21
+ const { flags } = await this.parse(TransactionKill);
22
+ const transactionId = flags['transaction-id'].trim();
23
+ if (!/^[0-9a-f]{32}$/i.test(transactionId)) {
24
+ this.error('--transaction-id must be exactly 32 hexadecimal characters.');
25
+ }
26
+ if (!flags.confirm) {
27
+ this.error('Refusing to submit a transaction kill request without --confirm.', {
28
+ suggestions: ['Deliberately select an identifier, then rerun this command with --confirm.'],
29
+ });
30
+ }
31
+ try {
32
+ const result = await new ClusterTransactionManager(this.instance).killTransaction(transactionId);
33
+ this._logger.info('Transaction kill request accepted.', { sysId: result.sysId });
34
+ if (!this.jsonEnabled()) {
35
+ this.log(`Kill request accepted by the platform for transaction ${result.sysId}.`);
36
+ this.log('The transaction may take a moment to clear. Run `nex transaction list` again to confirm.');
37
+ }
38
+ return result;
39
+ }
40
+ catch (error) {
41
+ this._logger.error('Transaction kill request failed.', error);
42
+ if (isPolicyRefusal(error))
43
+ throw error;
44
+ this.error(error, { suggestions: ['Verify the selected transaction identifier and instance permissions.'] });
45
+ }
46
+ }
47
+ }
48
+ //# sourceMappingURL=kill.js.map
@@ -0,0 +1 @@
1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,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,aAAa,CAAC,CAAA;YAChG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oCAAoC,EAAE,EAAC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAC,CAAC,CAAA;YAE9E,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,IAAI,CAAC,GAAG,CAAC,yDAAyD,MAAM,CAAC,KAAK,GAAG,CAAC,CAAA;gBAClF,IAAI,CAAC,GAAG,CAAC,0FAA0F,CAAC,CAAA;YACtG,CAAC;YAED,OAAO,MAAM,CAAA;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAc,CAAC,CAAA;YACtE,IAAI,eAAe,CAAC,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAA;YACvC,IAAI,CAAC,KAAK,CAAC,KAAc,EAAE,EAAC,WAAW,EAAE,CAAC,sEAAsE,CAAC,EAAC,CAAC,CAAA;QACrH,CAAC;IACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { type ClusterTransaction } from '@sonisoft/now-sdk-ext-core';
2
+ import { AuthenticatedCommand } from '../../common/authenticated-command.js';
3
+ type TransactionListResult = {
4
+ count: number;
5
+ transactions: ClusterTransaction[];
6
+ };
7
+ export default class TransactionList extends AuthenticatedCommand<typeof TransactionList> {
8
+ static description: string;
9
+ static examples: string[];
10
+ static flags: {
11
+ limit: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
+ 'poll-interval-ms': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
13
+ query: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
14
+ 'timeout-ms': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
15
+ };
16
+ run(): Promise<TransactionListResult>;
17
+ private validateFlags;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/transaction/list.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAA;AAG1E,KAAK,qBAAqB,GAAG;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,kBAAkB,EAAE,CAAA;CAAC,CAAA;AAEhF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,oBAAoB,CAAC,OAAO,eAAe,CAAC;IACvF,MAAM,CAAC,WAAW,SAA2E;IAC7F,MAAM,CAAC,QAAQ,WAKd;IACD,MAAM,CAAC,KAAK;;;;;MAKX;IAEY,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAkClD,OAAO,CAAC,aAAa;CAatB"}
@@ -0,0 +1,64 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { ClusterTransactionManager, isPolicyRefusal, } from '@sonisoft/now-sdk-ext-core';
3
+ import { AuthenticatedCommand } from '../../common/authenticated-command.js';
4
+ import { TransactionDisplayService } from '../../services/transaction-display.service.js';
5
+ export default class TransactionList extends AuthenticatedCommand {
6
+ static description = 'List active transactions from all responding ServiceNow cluster nodes.';
7
+ static examples = [
8
+ '<%= config.bin %> <%= command.id %> --auth dev',
9
+ '<%= config.bin %> <%= command.id %> --json --auth dev',
10
+ '<%= config.bin %> <%= command.id %> --query "user=admin" --limit 50 --auth dev',
11
+ '<%= config.bin %> <%= command.id %> --timeout-ms 120000 --poll-interval-ms 2000 --auth dev',
12
+ ];
13
+ static flags = {
14
+ limit: Flags.integer({ char: 'l', description: 'Maximum transactions to return. Core default: 1000.' }),
15
+ 'poll-interval-ms': Flags.integer({ description: 'Interval between collection status polls. Core default: 1000.' }),
16
+ query: Flags.string({ char: 'q', description: 'Encoded query used to filter transactions. Core default: none.' }),
17
+ 'timeout-ms': Flags.integer({ description: 'Collection timeout in milliseconds. Core default: 60000.' }),
18
+ };
19
+ async run() {
20
+ const { flags } = await this.parse(TransactionList);
21
+ this.validateFlags(flags);
22
+ const controller = new AbortController();
23
+ const onSigint = () => controller.abort();
24
+ process.once('SIGINT', onSigint);
25
+ try {
26
+ const options = {
27
+ signal: controller.signal,
28
+ ...(flags['poll-interval-ms'] === undefined ? {} : { pollIntervalMs: flags['poll-interval-ms'] }),
29
+ ...(flags['timeout-ms'] === undefined ? {} : { timeoutMs: flags['timeout-ms'] }),
30
+ ...(flags.limit === undefined ? {} : { limit: flags.limit }),
31
+ ...(flags.query === undefined ? {} : { query: flags.query }),
32
+ };
33
+ const transactions = await new ClusterTransactionManager(this.instance).getTransactions(options);
34
+ this._logger.info('Active transaction collection completed.', { count: transactions.length });
35
+ if (!this.jsonEnabled()) {
36
+ const display = new TransactionDisplayService();
37
+ for (const line of display.formatTransactions(transactions))
38
+ this.log(line);
39
+ }
40
+ return { count: transactions.length, transactions };
41
+ }
42
+ catch (error) {
43
+ this._logger.error('Active transaction collection failed.', error);
44
+ if (isPolicyRefusal(error))
45
+ throw error;
46
+ this.error(error, { suggestions: ['Check authentication and collection timeout settings, then try again.'] });
47
+ }
48
+ finally {
49
+ process.off('SIGINT', onSigint);
50
+ }
51
+ }
52
+ validateFlags(flags) {
53
+ if (flags['poll-interval-ms'] !== undefined && (!Number.isFinite(flags['poll-interval-ms']) || flags['poll-interval-ms'] < 0)) {
54
+ this.error('--poll-interval-ms must be a non-negative integer.');
55
+ }
56
+ if (flags['timeout-ms'] !== undefined && (!Number.isFinite(flags['timeout-ms']) || flags['timeout-ms'] < 0)) {
57
+ this.error('--timeout-ms must be a non-negative integer.');
58
+ }
59
+ if (flags.limit !== undefined && (!Number.isInteger(flags.limit) || flags.limit <= 0)) {
60
+ this.error('--limit must be a positive integer.');
61
+ }
62
+ }
63
+ }
64
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/transaction/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAEL,yBAAyB,EAEzB,eAAe,GAChB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAA;AAC1E,OAAO,EAAC,yBAAyB,EAAC,MAAM,+CAA+C,CAAA;AAIvF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,oBAA4C;IACvF,MAAM,CAAC,WAAW,GAAG,wEAAwE,CAAA;IAC7F,MAAM,CAAC,QAAQ,GAAG;QAChB,gDAAgD;QAChD,uDAAuD;QACvD,gFAAgF;QAChF,4FAA4F;KAC7F,CAAA;IACD,MAAM,CAAC,KAAK,GAAG;QACb,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,qDAAqD,EAAC,CAAC;QACrG,kBAAkB,EAAE,KAAK,CAAC,OAAO,CAAC,EAAC,WAAW,EAAE,+DAA+D,EAAC,CAAC;QACjH,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,gEAAgE,EAAC,CAAC;QAC/G,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,EAAC,WAAW,EAAE,0DAA0D,EAAC,CAAC;KACvG,CAAA;IAEM,KAAK,CAAC,GAAG;QACd,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAA;QACjD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QAEzB,MAAM,UAAU,GAAG,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AC,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACnD,CAAC;IACH,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { FlowContextDetailsResult, FlowLogResult } from '@sonisoft/now-sdk-ext-core';
1
+ import type { ActionDefinitionResult, FlowArtifactDefinitionResult, FlowContextDetailsResult, FlowLogResult } from '@sonisoft/now-sdk-ext-core';
2
2
  export interface FlowCopyResult {
3
3
  success: boolean;
4
4
  newFlowSysId?: string;
@@ -14,6 +14,24 @@ export interface FlowTestResult {
14
14
  errorMessage?: string;
15
15
  }
16
16
  export declare class FlowDisplayService {
17
+ /** Widest description the one-line summary will print before eliding. */
18
+ private static readonly DESCRIPTION_MAX_LENGTH;
19
+ /**
20
+ * Render an action design-time definition: metadata plus ordered steps.
21
+ *
22
+ * As with a flow definition, only the summary projection is printed — the raw
23
+ * `metadata`/`steps` payloads stay on the JSON path.
24
+ */
25
+ formatActionDefinitionResult(result: ActionDefinitionResult, jsonOutput: boolean): string[];
26
+ /**
27
+ * Render a flow or subflow design-time definition.
28
+ *
29
+ * The JSON form is the whole typed core result, opaque `definition` payload
30
+ * included, so it can be piped or redirected straight into a file. The text
31
+ * form deliberately renders only the summary projection: the definition body
32
+ * carries step scripts and input values, which do not belong on a terminal.
33
+ */
34
+ formatArtifactDefinitionResult(result: FlowArtifactDefinitionResult, jsonOutput: boolean): string[];
17
35
  formatCopyResult(result: FlowCopyResult, jsonOutput: boolean): string[];
18
36
  formatCancelResult(result: any, jsonOutput: boolean): string[];
19
37
  formatErrorResult(result: any, jsonOutput: boolean): string[];
@@ -24,7 +42,18 @@ export declare class FlowDisplayService {
24
42
  formatTestResult(result: FlowTestResult, jsonOutput: boolean): string[];
25
43
  formatDetailsResult(result: FlowContextDetailsResult, jsonOutput: boolean): string[];
26
44
  formatLogsResult(result: FlowLogResult, jsonOutput: boolean): string[];
45
+ private _artifactLabel;
27
46
  private _mapLogLevel;
28
47
  private _stateIcon;
48
+ /**
49
+ * Reduce a design-time description to one summary line.
50
+ *
51
+ * Workflow Studio stores the description as authored, which for a shipped
52
+ * subflow is frequently a block of HTML hundreds of characters long. Printing
53
+ * it verbatim buries the counts underneath it, so the tags come out, the
54
+ * whitespace collapses, and anything past the cutoff is elided. The full text
55
+ * is never lost \u2014 it is on the `--json` path, untouched.
56
+ */
57
+ private _summaryDescription;
29
58
  }
30
59
  //# sourceMappingURL=flow-display.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flow-display.service.d.ts","sourceRoot":"","sources":["../../src/services/flow-display.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAEzF,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,kBAAkB;IAC7B,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,EAAE;IAoCvE,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,EAAE;IAoB9D,iBAAiB,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,EAAE;IAwB7D,qBAAqB,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,EAAE;IA6CjE,mBAAmB,CAAC,MAA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+ /** Widest description the one-line summary will print before eliding. */
3
+ static DESCRIPTION_MAX_LENGTH = 160;
4
+ /**
5
+ * Render an action design-time definition: metadata plus ordered steps.
6
+ *
7
+ * As with a flow definition, only the summary projection is printed — the raw
8
+ * `metadata`/`steps` payloads stay on the JSON path.
9
+ */
10
+ formatActionDefinitionResult(result, jsonOutput) {
11
+ if (jsonOutput) {
12
+ return [JSON.stringify(result, null, 2)];
13
+ }
14
+ const lines = [];
15
+ const icon = result.success ? '\u2714' : '\u2718';
16
+ lines.push(`\n${icon} Action Definition — ${result.sysId}`);
17
+ lines.push(" " + "\u2500".repeat(60));
18
+ lines.push(` Type: ${result.artifactType ?? 'action'}`);
19
+ const { summary } = result;
20
+ if (summary) {
21
+ lines.push(` Name: ${summary.name}`);
22
+ lines.push(` Internal Name: ${summary.internalName}`);
23
+ lines.push(` State: ${summary.state}`);
24
+ lines.push(` Active: ${summary.active}`);
25
+ lines.push(` Scope: ${summary.scopeName || summary.scope}`);
26
+ const description = summary.description ? this._summaryDescription(summary.description) : '';
27
+ if (description) {
28
+ lines.push(` Description: ${description}`);
29
+ }
30
+ lines.push("");
31
+ lines.push(" Contents:");
32
+ lines.push(` Inputs: ${summary.inputCount}`);
33
+ lines.push(` Outputs: ${summary.outputCount}`);
34
+ lines.push(` Steps: ${summary.stepCount}`);
35
+ if (summary.steps.length > 0) {
36
+ lines.push("");
37
+ lines.push(" Steps:");
38
+ for (const step of summary.steps) {
39
+ lines.push(` ${step.order}. ${step.label} [${step.stepTypeName}]`);
40
+ }
41
+ }
42
+ }
43
+ else if (result.success) {
44
+ lines.push("");
45
+ lines.push(" No summary was reported. Re-run with --json for the full definition.");
46
+ }
47
+ if (result.errorMessage) {
48
+ lines.push("");
49
+ lines.push(` Error: ${result.errorMessage}${result.failureReason ? ` (${result.failureReason})` : ''}`);
50
+ }
51
+ lines.push(" " + "\u2500".repeat(60));
52
+ return lines;
53
+ }
54
+ /**
55
+ * Render a flow or subflow design-time definition.
56
+ *
57
+ * The JSON form is the whole typed core result, opaque `definition` payload
58
+ * included, so it can be piped or redirected straight into a file. The text
59
+ * form deliberately renders only the summary projection: the definition body
60
+ * carries step scripts and input values, which do not belong on a terminal.
61
+ */
62
+ formatArtifactDefinitionResult(result, jsonOutput) {
63
+ if (jsonOutput) {
64
+ return [JSON.stringify(result, null, 2)];
65
+ }
66
+ const lines = [];
67
+ const icon = result.success ? '\u2714' : '\u2718';
68
+ // artifactType is what ServiceNow reported, never what was asked for.
69
+ const label = this._artifactLabel(result.artifactType ?? result.reportedType);
70
+ lines.push(`\n${icon} ${label} Definition — ${result.sysId}`);
71
+ lines.push(" " + "\u2500".repeat(60));
72
+ lines.push(` Type: ${result.artifactType ?? result.reportedType ?? 'unknown'}`);
73
+ const { summary } = result;
74
+ if (summary) {
75
+ lines.push(` Name: ${summary.name}`);
76
+ lines.push(` Internal Name: ${summary.internalName}`);
77
+ lines.push(` Status: ${summary.status}`);
78
+ lines.push(` Active: ${summary.active}`);
79
+ lines.push(` Scope: ${summary.scopeName || summary.scope}`);
80
+ const description = summary.description ? this._summaryDescription(summary.description) : '';
81
+ if (description) {
82
+ lines.push(` Description: ${description}`);
83
+ }
84
+ lines.push("");
85
+ lines.push(" Contents:");
86
+ lines.push(` Triggers: ${summary.triggerCount}`);
87
+ lines.push(` Actions: ${summary.actionCount}`);
88
+ lines.push(` Subflows: ${summary.subflowCount}`);
89
+ lines.push(` Flow Logic: ${summary.flowLogicCount}`);
90
+ lines.push(` Inputs: ${summary.inputCount}`);
91
+ lines.push(` Outputs: ${summary.outputCount}`);
92
+ }
93
+ else if (result.success) {
94
+ lines.push("");
95
+ lines.push(" No summary was reported. Re-run with --json for the full definition.");
96
+ }
97
+ if (result.errorMessage) {
98
+ lines.push("");
99
+ lines.push(` Error: ${result.errorMessage}${result.failureReason ? ` (${result.failureReason})` : ''}`);
100
+ }
101
+ lines.push(" " + "\u2500".repeat(60));
102
+ return lines;
103
+ }
2
104
  formatCopyResult(result, jsonOutput) {
3
105
  if (jsonOutput) {
4
106
  return [JSON.stringify(result, null, 2)];
@@ -304,6 +406,19 @@ export class FlowDisplayService {
304
406
  lines.push(" " + "\u2500".repeat(60));
305
407
  return lines;
306
408
  }
409
+ _artifactLabel(artifactType) {
410
+ switch (artifactType) {
411
+ case 'flow': {
412
+ return 'Flow';
413
+ }
414
+ case 'subflow': {
415
+ return 'Subflow';
416
+ }
417
+ default: {
418
+ return 'Flow Artifact';
419
+ }
420
+ }
421
+ }
307
422
  _mapLogLevel(level) {
308
423
  switch (level) {
309
424
  case '-1': {
@@ -348,5 +463,24 @@ export class FlowDisplayService {
348
463
  }
349
464
  }
350
465
  }
466
+ /**
467
+ * Reduce a design-time description to one summary line.
468
+ *
469
+ * Workflow Studio stores the description as authored, which for a shipped
470
+ * subflow is frequently a block of HTML hundreds of characters long. Printing
471
+ * it verbatim buries the counts underneath it, so the tags come out, the
472
+ * whitespace collapses, and anything past the cutoff is elided. The full text
473
+ * is never lost \u2014 it is on the `--json` path, untouched.
474
+ */
475
+ _summaryDescription(description) {
476
+ const flattened = description
477
+ .replaceAll(/<[^>]*>/g, ' ')
478
+ .replaceAll('&nbsp;', ' ')
479
+ .replaceAll(/\s+/g, ' ')
480
+ .trim();
481
+ return flattened.length > FlowDisplayService.DESCRIPTION_MAX_LENGTH
482
+ ? `${flattened.slice(0, FlowDisplayService.DESCRIPTION_MAX_LENGTH).trimEnd()}\u2026`
483
+ : flattened;
484
+ }
351
485
  }
352
486
  //# sourceMappingURL=flow-display.service.js.map