@sonisoft/now-sdk-ext-cli 5.1.0 → 5.3.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,27 @@
1
+ import { Command } from '@oclif/core';
2
+ /**
3
+ * Reports what this invocation is permitted to do, and which layer decided.
4
+ *
5
+ * Exists because precedence bugs are otherwise invisible: a user sees "refused" with no
6
+ * way to tell whether the environment denied it, a flag denied it, or nothing granted
7
+ * it — and the fix is completely different in each case.
8
+ *
9
+ * Extends plain `Command`, not `AuthenticatedCommand`: answering "what may I do" must
10
+ * not require working credentials. Someone diagnosing a refusal should not have to get
11
+ * past auth first.
12
+ */
13
+ export default class PolicyStatus extends Command {
14
+ static description: string;
15
+ static enableJsonFlag: boolean;
16
+ static examples: string[];
17
+ static flags: {
18
+ 'deny-execute': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
19
+ 'deny-write': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
20
+ 'read-only': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
21
+ };
22
+ run(): Promise<{
23
+ permitted: Record<string, unknown>;
24
+ source: string;
25
+ }>;
26
+ }
27
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/policy/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAQ,MAAM,aAAa,CAAA;AAK1C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAC/C,MAAM,CAAC,WAAW,SAIG;IACvB,MAAM,CAAC,cAAc,UAAO;IAC5B,MAAM,CAAC,QAAQ,WAIZ;IACH,MAAM,CAAC,KAAK;;;;MAIT;IAEY,GAAG,IAAI,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAC;CA2ClF"}
@@ -0,0 +1,67 @@
1
+ import { Command, Flags } from '@oclif/core';
2
+ import { checkRequirement, currentLayers, DENY_ENV } from '@sonisoft/now-sdk-ext-core';
3
+ import { installCliPolicy } from '../../common/policy.js';
4
+ /**
5
+ * Reports what this invocation is permitted to do, and which layer decided.
6
+ *
7
+ * Exists because precedence bugs are otherwise invisible: a user sees "refused" with no
8
+ * way to tell whether the environment denied it, a flag denied it, or nothing granted
9
+ * it — and the fix is completely different in each case.
10
+ *
11
+ * Extends plain `Command`, not `AuthenticatedCommand`: answering "what may I do" must
12
+ * not require working credentials. Someone diagnosing a refusal should not have to get
13
+ * past auth first.
14
+ */
15
+ export default class PolicyStatus extends Command {
16
+ static description = 'Show what this invocation is permitted to change on the instance, and why.\n\n' +
17
+ 'Changes are permitted by default. NEX_POLICY_DENY, set in the environment, ' +
18
+ 'outranks every command-line flag — that is the only layer an agent driving this ' +
19
+ 'CLI cannot reach.';
20
+ static enableJsonFlag = true;
21
+ static examples = [
22
+ '<%= config.bin %> <%= command.id %>',
23
+ '<%= config.bin %> <%= command.id %> --read-only',
24
+ 'NEX_POLICY_DENY=all <%= config.bin %> <%= command.id %>',
25
+ ];
26
+ static flags = {
27
+ 'deny-execute': Flags.boolean({ description: 'Evaluate as if --deny-execute were passed.' }),
28
+ 'deny-write': Flags.boolean({ description: 'Evaluate as if --deny-write were passed.' }),
29
+ 'read-only': Flags.boolean({ description: 'Evaluate as if --read-only were passed.' }),
30
+ };
31
+ async run() {
32
+ const { flags } = await this.parse(PolicyStatus);
33
+ const warnings = [];
34
+ installCliPolicy(flags, (m) => warnings.push(m));
35
+ const verbs = ['write', 'execute'];
36
+ const permitted = {};
37
+ for (const verb of verbs) {
38
+ const decision = checkRequirement({ target: 'instance', verbs: [verb] });
39
+ permitted[verb] = { allowed: decision.allowed, decidedBy: decision.decidingLayer };
40
+ }
41
+ const envSet = Boolean(process.env[DENY_ENV]);
42
+ const result = { permitted, source: envSet ? `${DENY_ENV} is set` : 'no environment lockdown' };
43
+ if (!this.jsonEnabled()) {
44
+ this.log('Instance changes');
45
+ for (const verb of verbs) {
46
+ const entry = permitted[verb];
47
+ const mark = entry.allowed ? 'permitted' : 'REFUSED ';
48
+ this.log(` ${verb.padEnd(8)} ${mark} (${entry.decidedBy})`);
49
+ }
50
+ this.log('');
51
+ this.log('Reads are never gated.');
52
+ this.log(envSet
53
+ ? `${DENY_ENV} is set in the environment and outranks every flag.`
54
+ : `${DENY_ENV} is not set. Set it in your shell profile or container ` +
55
+ `environment to deny changes in a way a command-line flag cannot undo.`);
56
+ // Ordered, because the order IS the behaviour.
57
+ this.log('');
58
+ this.log('Layers, highest priority first:');
59
+ for (const layer of currentLayers())
60
+ this.log(` ${layer.name}`);
61
+ for (const warning of warnings)
62
+ this.warn(warning);
63
+ }
64
+ return result;
65
+ }
66
+ }
67
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/policy/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAC,gBAAgB,EAAE,aAAa,EAAE,QAAQ,EAAY,MAAM,4BAA4B,CAAA;AAE/F,OAAO,EAAC,gBAAgB,EAAmB,MAAM,wBAAwB,CAAA;AAEzE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAC/C,MAAM,CAAC,WAAW,GAChB,gFAAgF;QAChF,6EAA6E;QAC7E,kFAAkF;QAClF,mBAAmB,CAAA;IACvB,MAAM,CAAC,cAAc,GAAG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C,CAAC,CAAC,yBAAyB,EAAC,CAAA;QAE7F,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;YAC5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAA0C,CAAA;gBACtE,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAA;gBACtD,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,MAAM,KAAK,CAAC,SAAS,GAAG,CAAC,CAAA;YAC/D,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YACZ,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;YAClC,IAAI,CAAC,GAAG,CACN,MAAM;gBACJ,CAAC,CAAC,GAAG,QAAQ,qDAAqD;gBAClE,CAAC,CAAC,GAAG,QAAQ,yDAAyD;oBACpE,uEAAuE,CAC5E,CAAA;YAED,+CAA+C;YAC/C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YACZ,IAAI,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAA;YAC3C,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE;gBAAE,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;YAEhE,KAAK,MAAM,OAAO,IAAI,QAAQ;gBAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACpD,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC"}
@@ -6,9 +6,12 @@ export declare abstract class AuthenticatedCommand<T extends typeof Command> ext
6
6
  static baseFlags: {
7
7
  auth: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
8
8
  'cred-store': Interfaces.BooleanFlag<boolean>;
9
+ 'deny-execute': Interfaces.BooleanFlag<boolean>;
10
+ 'deny-write': Interfaces.BooleanFlag<boolean>;
9
11
  'log-dir': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
10
12
  'log-file': Interfaces.BooleanFlag<boolean>;
11
13
  'log-level': Interfaces.OptionFlag<"info" | "debug" | "warn" | "error" | "trace", Interfaces.CustomOptions>;
14
+ 'read-only': Interfaces.BooleanFlag<boolean>;
12
15
  };
13
16
  static enableJsonFlag: boolean;
14
17
  protected _logger: Logger;
@@ -1 +1 @@
1
- {"version":3,"file":"authenticated-command.d.ts","sourceRoot":"","sources":["../../src/common/authenticated-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAS,UAAU,EAAE,MAAM,aAAa,CAAA;AAExD,OAAO,EAA+B,MAAM,EAAE,kBAAkB,EAA8B,MAAM,4BAA4B,CAAC;AAMjI,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,OAAO,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAA;AAC7H,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAE/E,8BAAsB,oBAAoB,CAAC,CAAC,SAAS,OAAO,OAAO,CAAE,SAAQ,OAAO;IAElF,MAAM,CAAC,SAAS;;;;;;MAkCf;IAEC,MAAM,CAAC,cAAc,UAAO;IAChC,SAAS,CAAC,OAAO,EAAG,MAAM,CAAC;IACvB,SAAS,CAAC,IAAI,EAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,KAAK,EAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/B,SAAS,CAAC,QAAQ,EAAE,kB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,KAAK,EAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/B,SAAS,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IAEnC,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,MAAM,CAAC,MAAM,EAAE,MAAM,EAE/B;cAEa,KAAK,CAAC,GAAG,EAAE,KAAK,GAAG;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,GAAG,CAAC;cA8BrD,OAAO,CAAC,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;IAO9C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiFlC;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAIvB;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ;CA0BjB"}
@@ -1,7 +1,8 @@
1
1
  import { Command, Flags } from '@oclif/core';
2
2
  import { getCredentials } from "@servicenow/sdk-cli/dist/auth/index.js";
3
- import { configureLogging, flushLogs, ServiceNowInstance } from '@sonisoft/now-sdk-ext-core';
3
+ import { configureLogging, flushLogs, isPolicyRefusal, ServiceNowInstance } from '@sonisoft/now-sdk-ext-core';
4
4
  import { LogFactory } from '../util/log-factory.js';
5
+ import { installCliPolicy } from './policy.js';
5
6
  export class AuthenticatedCommand extends Command {
6
7
  // // define flags that can be inherited by any command that extends BaseCommand
7
8
  static baseFlags = {
@@ -16,6 +17,26 @@ export class AuthenticatedCommand extends Command {
16
17
  helpGroup: 'GLOBAL',
17
18
  required: false,
18
19
  }),
20
+ // Changes are PERMITTED by default; these take permission away.
21
+ //
22
+ // Deliberately deny-direction rather than `--allow-write`. With a permissive
23
+ // default an allow-flag would grant nothing it did not already have, and it could
24
+ // not override NEX_POLICY_DENY either, so it would ship as a no-op. If the default
25
+ // ever flips to deny, the allow flags arrive in that same change.
26
+ //
27
+ // These are agent-reachable, which is fine: an agent can only ever RESTRICT itself
28
+ // with them. The layer an agent cannot reach is NEX_POLICY_DENY, which outranks
29
+ // every flag — that is what makes pointing nex at production meaningful.
30
+ 'deny-execute': Flags.boolean({
31
+ description: 'Refuse background scripts, flow runs and ATF runs for this invocation.',
32
+ helpGroup: 'GLOBAL',
33
+ required: false,
34
+ }),
35
+ 'deny-write': Flags.boolean({
36
+ description: 'Refuse any change to instance data for this invocation.',
37
+ helpGroup: 'GLOBAL',
38
+ required: false,
39
+ }),
19
40
  'log-dir': Flags.string({
20
41
  description: 'Directory to write log files to. Implies --log-file.',
21
42
  helpGroup: 'GLOBAL',
@@ -37,6 +58,12 @@ export class AuthenticatedCommand extends Command {
37
58
  options: ['debug', 'warn', 'error', 'info', 'trace'],
38
59
  summary: 'Specify level for logging.',
39
60
  })(),
61
+ 'read-only': Flags.boolean({
62
+ description: 'Refuse every change to the instance — equivalent to ' +
63
+ '--deny-write --deny-execute. Reads are unaffected.',
64
+ helpGroup: 'GLOBAL',
65
+ required: false,
66
+ }),
40
67
  };
41
68
  // add the --json flag
42
69
  static enableJsonFlag = true;
@@ -52,6 +79,19 @@ export class AuthenticatedCommand extends Command {
52
79
  this._logger = logger;
53
80
  }
54
81
  async catch(err) {
82
+ // A refusal is a decision, not a crash. Render it as the CLI's own error with
83
+ // remediation, rather than letting a stack trace reach the user for something they
84
+ // asked for by passing a flag. Handled first, before the generic path below.
85
+ if (isPolicyRefusal(err)) {
86
+ this.authLogger?.warn("Refused by policy.", { message: err.message });
87
+ await flushLogs();
88
+ this.error(err.message, {
89
+ suggestions: [
90
+ 'Reads are unaffected — only changes to the instance were refused.',
91
+ 'Run `nex policy status` to see what is permitted and which layer decided.',
92
+ ],
93
+ });
94
+ }
55
95
  // authLogger is assigned partway through init(), so anything that throws
56
96
  // before that point — a missing required flag, for instance — arrived here
57
97
  // with it still undefined and produced "Cannot read properties of undefined
@@ -102,6 +142,14 @@ export class AuthenticatedCommand extends Command {
102
142
  });
103
143
  this.logger = LogFactory.createLogger(this.ctor.name);
104
144
  this.authLogger = LogFactory.createLogger("AuthenticatedCommand");
145
+ // Install the permission ladder before anything can issue a request. Core's gate
146
+ // is inert until this runs, so ordering matters: after logging (so a malformed
147
+ // NEX_POLICY_DENY has somewhere to warn) and before the first credential fetch.
148
+ //
149
+ // Note there is no per-command classification. The gate sits at the HTTP layer and
150
+ // decides per REQUEST, so `update-set current` reading or writing depending on
151
+ // --set, and `script-sync sync` going both ways, need no special handling here.
152
+ installCliPolicy(this.flags, (message) => this.authLogger.warn(message));
105
153
  // const wrapper:CredentialWrapper = new CredentialWrapper();
106
154
  // const credential:Creds = await (flags.auth ? wrapper.getStoredCredentialsByAlias(flags.auth) : wrapper.getStoredCredentialsByAlias( 'fluent-default'));
107
155
  // const credentialArgs = {"_": "get-credentials", auth: flags.auth || "fluent-default"};
@@ -1 +1 @@
1
- {"version":3,"file":"authenticated-command.js","sourceRoot":"","sources":["../../src/common/authenticated-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAc,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAU,kBAAkB,EAA8B,MAAM,4BAA4B,CAAC;AAEjI,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOpD,MAAM,OAAgB,oBAA+C,SAAQ,OAAO;IACpF,kFAAkF;IAChF,MAAM,CAAC,SAAS,GAAG;QACjB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC;QACrF,yEAAyE;QACzE,6EAA6E;QAC7E,2EAA2E;QAC3E,6BAA6B;QAC7B,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;YAC1B,WAAW,EAAE,0EAA0E;gBACrF,gGAAgG;YAClG,SAAS,EAAE,QAAQ;YACnB,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,SAAS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;YACjB,UAAU;SACX,CAAA;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACK,eAAe;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,aAAa,IAAI,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAA;IACnF,CAAC;IAED;;;;;;;OAOG;IACK,QAAQ,CAAC,KAAa,EAAE,KAAe;QAC7C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,GAAG,CAAC;QAChE,MAAM,WAAW,GAAG;YAClB,gDAAgD;YAChD,oDAAoD;SACrD,CAAC;QAEF,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,yEAAyE;YACzE,4EAA4E;YAC5E,4EAA4E;YAC5E,0CAA0C;YAC1C,WAAW,CAAC,OAAO,CACjB,uFAAuF;gBACvF,0FAA0F;gBAC1F,8CAA8C,CAC/C,CAAC;QACJ,CAAC;QAED,6EAA6E;QAC7E,MAAM,WAAW,GAAI,KAA4C,EAAE,WAAW,CAAC;QAC/E,IAAI,WAAW;YAAE,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAElD,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mCAAmC,KAAK,IAAI,CAAC;QACrG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAC,WAAW,EAAC,CAAC,CAAC;IACpC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { type PolicyLayer, Verb } from '@sonisoft/now-sdk-ext-core';
2
+ /**
3
+ * Builds and installs the permission ladder for one `nex` invocation.
4
+ *
5
+ * Changes are PERMITTED by default. This is not the strongest posture available — an
6
+ * agent that decides to run `nex bulk delete` still just does it — but it is the one
7
+ * that does not break every existing script and CI job, and the machinery is arranged
8
+ * so flipping is a one-line change (see DEFAULT_ALLOW below).
9
+ *
10
+ * What it does buy today: `NEX_POLICY_DENY`, set somewhere the agent cannot write,
11
+ * outranks every flag. That is the difference between "the agent probably will not
12
+ * write to prod" and "the agent cannot".
13
+ */
14
+ export interface PolicyFlags {
15
+ 'deny-execute'?: boolean;
16
+ 'deny-write'?: boolean;
17
+ 'read-only'?: boolean;
18
+ }
19
+ /** The verbs a set of flags takes away. */
20
+ export declare function deniedByFlags(flags: PolicyFlags): Verb[];
21
+ /**
22
+ * Assembles the ladder, highest priority first.
23
+ *
24
+ * Order is the whole design. `NEX_POLICY_DENY` sits above the flags so a flag cannot
25
+ * grant past it; the permissive default sits at the bottom so anything above it can
26
+ * take permission away.
27
+ */
28
+ export declare function buildLayers(flags: PolicyFlags, warn: (message: string) => void): PolicyLayer[];
29
+ /** Installs the policy for this process. Call once, from init(), before any request. */
30
+ export declare function installCliPolicy(flags: PolicyFlags, warn: (message: string) => void): void;
31
+ export { ALLOW_ENV, DENY_ENV } from '@sonisoft/now-sdk-ext-core';
32
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/common/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,WAAW,EAEhB,IAAI,EACL,MAAM,4BAA4B,CAAA;AAEnC;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,WAAW;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,2CAA2C;AAC3C,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,EAAE,CAUxD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,WAAW,EAAE,CAuB9F;AAwBD,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAG1F;AAID,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,4BAA4B,CAAA"}
@@ -0,0 +1,68 @@
1
+ import { allowFromEnvironment, DENY_ENV, denyFromEnvironment, denyLayer, grantLayer, installPolicy, setRemediationWriter, } from '@sonisoft/now-sdk-ext-core';
2
+ /** The verbs a set of flags takes away. */
3
+ export function deniedByFlags(flags) {
4
+ const denied = new Set();
5
+ if (flags['read-only']) {
6
+ denied.add('write');
7
+ denied.add('execute');
8
+ }
9
+ if (flags['deny-write'])
10
+ denied.add('write');
11
+ if (flags['deny-execute'])
12
+ denied.add('execute');
13
+ return [...denied];
14
+ }
15
+ /**
16
+ * Assembles the ladder, highest priority first.
17
+ *
18
+ * Order is the whole design. `NEX_POLICY_DENY` sits above the flags so a flag cannot
19
+ * grant past it; the permissive default sits at the bottom so anything above it can
20
+ * take permission away.
21
+ */
22
+ export function buildLayers(flags, warn) {
23
+ const layers = [];
24
+ // 0. Operator lockdown. The only rung an agent cannot reach — and only when set
25
+ // somewhere it cannot write. A project-local .mcp.json or a committed .env is
26
+ // still editable by anything with file access; a shell profile is not.
27
+ const envDeny = denyFromEnvironment(process.env, warn);
28
+ if (envDeny)
29
+ layers.push(envDeny);
30
+ // 1. Per-invocation denials. Agent-reachable, but they only ever restrict.
31
+ const flagDenied = deniedByFlags(flags);
32
+ if (flagDenied.length > 0)
33
+ layers.push(denyLayer('command-line flag', flagDenied));
34
+ // 2. Grants from the environment. Inert while the default is permissive; kept in
35
+ // place so the ladder does not have to be rebuilt when the default flips.
36
+ const envAllow = allowFromEnvironment(process.env, warn);
37
+ if (envAllow)
38
+ layers.push(envAllow);
39
+ // 3. THE DEFAULT. Delete this one layer to make `nex` deny-by-default; everything
40
+ // above keeps working unchanged.
41
+ layers.push(grantLayer('default (changes permitted)', ['write', 'execute']));
42
+ return layers;
43
+ }
44
+ /**
45
+ * Explains a refusal in terms of what the user can actually do about it.
46
+ *
47
+ * Names the deciding layer, because "refused" without "by what" is unactionable — and
48
+ * the fix differs completely: unset an environment variable, or drop a flag.
49
+ */
50
+ function remediation(verbs, missing, layer) {
51
+ const what = missing === 'execute' ? 'running scripts or flows' : 'changing instance data';
52
+ if (layer.startsWith(DENY_ENV)) {
53
+ return `Refused: ${what} is denied by ${DENY_ENV}. ` +
54
+ `This is set in the environment, not on the command line — unset it there to allow this.`;
55
+ }
56
+ if (layer === 'command-line flag') {
57
+ return `Refused: ${what} is denied by a flag on this command. ` +
58
+ `Remove --read-only / --deny-${missing} to allow it.`;
59
+ }
60
+ return `Refused: ${what} is not permitted (${layer}).`;
61
+ }
62
+ /** Installs the policy for this process. Call once, from init(), before any request. */
63
+ export function installCliPolicy(flags, warn) {
64
+ installPolicy(buildLayers(flags, warn));
65
+ setRemediationWriter(remediation);
66
+ }
67
+ export { ALLOW_ENV, DENY_ENV } from '@sonisoft/now-sdk-ext-core';
68
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/common/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EACpB,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,UAAU,EACV,aAAa,EAEb,oBAAoB,GAErB,MAAM,4BAA4B,CAAA;AAqBnC,2CAA2C;AAC3C,MAAM,UAAU,aAAa,CAAC,KAAkB;IAC9C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAQ,CAAA;IAC9B,IAAI,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACnB,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACvB,CAAC;IAED,IAAI,KAAK,CAAC,YAAY,CAAC;QAAE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,QAAQ,CAAC,EAAE,CAAC;QAC/B,OAAO,YAAY,IAAI,iBAAiB,QAAQ,IAAI;YAClD,yFAAyF,CAAA;IAC7F,CAAC;IAED,IAAI,KAAK,KAAK,mBAAmB,EAAE,CAAC;QAClC,OAAO,YAAY,IAAI,wCAAwC;YAC7D,+BAA+B,OAAO,eAAe,CAAA;IACzD,CAAC;IAED,OAAO,YAAY,IAAI,sBAAsB,KAAK,IAAI,CAAA;AACxD,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,gBAAgB,CAAC,KAAkB,EAAE,IAA+B;IAClF,aAAa,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;IACvC,oBAAoB,CAAC,WAAW,CAAC,CAAA;AACnC,CAAC;AAID,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,4BAA4B,CAAA"}
@@ -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,OAA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