@jacebenson/jsn 5.5.7 → 5.5.8-dev.220.1
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 +16 -1
- package/package.json +5 -6
- package/skills/servicenow/SKILL.md +9 -1
- package/src/app.js +4 -79
- package/src/auth/credential-store.js +33 -8
- package/src/auth/windows-credential-store.js +85 -0
- package/src/auth/windows-credential-store.ps1 +163 -0
- package/src/bounded-reads.js +13 -0
- package/src/capabilities.js +8 -3
- package/src/cli-adapter.js +26 -3
- package/src/cli.js +13 -14
- package/src/command-families.js +68 -0
- package/src/commands/_generic.js +1 -0
- package/src/commands/_ticket.js +1 -1
- package/src/commands/actions.js +9 -4
- package/src/commands/approvals.js +1 -1
- package/src/commands/atf.js +1 -1
- package/src/commands/attachments.js +1 -1
- package/src/commands/auth.js +21 -2
- package/src/commands/codesearch.js +11 -2
- package/src/commands/compare.js +22 -0
- package/src/commands/customizations.js +3 -4
- package/src/commands/decisiontables.js +4 -0
- package/src/commands/docs/docs.js +5 -5
- package/src/commands/domains.js +1 -1
- package/src/commands/eval.js +11 -5
- package/src/commands/flows.js +24 -7
- package/src/commands/groupmembers.js +1 -1
- package/src/commands/grouproles.js +1 -1
- package/src/commands/groups.js +1 -1
- package/src/commands/midservers.js +4 -11
- package/src/commands/perf.js +2 -3
- package/src/commands/plugins.js +9 -0
- package/src/commands/records.js +12 -2
- package/src/commands/scopes.js +1 -1
- package/src/commands/scrapi.js +2 -2
- package/src/commands/setup.js +4 -34
- package/src/commands/skipped-updates.js +2 -3
- package/src/commands/store.js +4 -1
- package/src/commands/subscriptions.js +47 -0
- package/src/commands/tickets.js +1 -1
- package/src/commands/users.js +1 -1
- package/src/commands/workflows.js +3 -5
- package/src/config.js +1 -0
- package/src/context.js +8 -56
- package/src/docs-links.js +28 -0
- package/src/flow-create.js +9 -0
- package/src/help.js +4 -0
- package/src/helpers.js +17 -24
- package/src/instance-inventory.js +184 -0
- package/src/intended-context.js +68 -0
- package/src/mutation-context.js +69 -46
- package/src/output.js +1 -1
- package/src/paginated-search.js +146 -178
- package/src/picker-ui.js +20 -0
- package/src/prompt-engine.js +176 -0
- package/src/prompts.js +293 -43
- package/src/records/inspect.js +30 -16
- package/src/records-engine.js +2 -2
- package/src/schedule-cache.js +96 -0
- package/src/schedules/itom-2026-04-09.json +121 -0
- package/src/schedules/public-inventory.json +6224 -0
- package/src/sdk-batch.js +2 -1
- package/src/sdk.js +42 -16
- package/src/setup-preferences.js +2 -2
- package/src/subscriptions.js +176 -0
package/src/cli.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { flowsCmd, workflowsCmd, midserversCmd, subscriptionsCmd, customizationsCmd, skippedUpdatesCmd, docsCmd, perfCmd } from './command-families.js';
|
|
1
2
|
import { visibleCommandRegistry } from './command-audience.js';
|
|
2
3
|
// Root CLI using the local yargs-compatible adapter
|
|
3
4
|
|
|
@@ -11,8 +12,7 @@ import { resolveSession, applySession } from './session.js';
|
|
|
11
12
|
import { renderHelp, renderTips } from './help.js';
|
|
12
13
|
import { isMutationCommand, refreshMutationCommands } from './mutations.js';
|
|
13
14
|
import { maybeShowHome } from './welcome.js';
|
|
14
|
-
import {
|
|
15
|
-
import { isLocalPreview, noInstanceCommands, dailyCheckSkipCommands, skipsContextHeader } from './capabilities.js';
|
|
15
|
+
import { isLocalPreview, noInstanceCommands, dailyCheckSkipCommands } from './capabilities.js';
|
|
16
16
|
import { guardExit, exitWithError, AppError, CodeUsage } from './errors.js';
|
|
17
17
|
import { formatCommandList } from './helpers.js';
|
|
18
18
|
|
|
@@ -44,7 +44,6 @@ import { versionCmd } from './commands/version.js';
|
|
|
44
44
|
import { upgradeCmd } from './commands/upgrade.js';
|
|
45
45
|
import { skillCmd, checkSkill } from './commands/skill.js';
|
|
46
46
|
import { getVersion, checkLatest, getReleaseChannel, getInstallCommand } from './commands/version.js';
|
|
47
|
-
import { docsCmd } from './commands/docs/docs.js';
|
|
48
47
|
|
|
49
48
|
// Table and platform commands registered at root level for progressive disclosure
|
|
50
49
|
import {
|
|
@@ -64,8 +63,6 @@ import {
|
|
|
64
63
|
uimacrosCmd, uxlistsCmd, uxapplicabilityCmd,
|
|
65
64
|
} from './commands/_simple.js';
|
|
66
65
|
import { decisiontablesCmd } from './commands/decisiontables.js';
|
|
67
|
-
import { flowsCmd } from './commands/flows.js';
|
|
68
|
-
import { workflowsCmd } from './commands/workflows.js';
|
|
69
66
|
import { formsCmd } from './commands/forms.js';
|
|
70
67
|
import { listsCmd } from './commands/lists.js';
|
|
71
68
|
import { updateSetsCmd } from './commands/updatesets.js';
|
|
@@ -79,10 +76,9 @@ import { b4rulesCmd } from './commands/b4rules.js';
|
|
|
79
76
|
import { atfCmd } from './commands/atf.js';
|
|
80
77
|
import { scanCmd } from './commands/scan.js';
|
|
81
78
|
import { storeCmd } from './commands/store.js';
|
|
79
|
+
import { pluginsCmd } from './commands/plugins.js';
|
|
80
|
+
import { compareCmd } from './commands/compare.js';
|
|
82
81
|
import { approvalsCmd } from './commands/approvals.js';
|
|
83
|
-
import { perfCmd } from './commands/perf.js';
|
|
84
|
-
import { customizationsCmd } from './commands/customizations.js';
|
|
85
|
-
import { midserversCmd } from './commands/midservers.js';
|
|
86
82
|
import { diffCmd } from './commands/diff.js';
|
|
87
83
|
import { graphqlCmd } from './commands/graphql.js';
|
|
88
84
|
|
|
@@ -155,6 +151,9 @@ export function buildCLI() {
|
|
|
155
151
|
.options({
|
|
156
152
|
'all-commands': { type: 'boolean', describe: 'Show the full command list, including admin and developer tools' },
|
|
157
153
|
|
|
154
|
+
'expect-scope': { type: 'string', description: 'Intended customization scope, exact scope/name or sys_id' },
|
|
155
|
+
'expect-update-set': { type: 'string', description: 'Intended in-progress capture set, exact name or sys_id' },
|
|
156
|
+
'expect-domain': { type: 'string', description: 'Intended domain; refuses writes when effective domain cannot be proven' },
|
|
158
157
|
force: {
|
|
159
158
|
type: 'boolean',
|
|
160
159
|
description: 'Approve Global + Default mutation context only after user approval; delete commands also use this for their separate confirmation',
|
|
@@ -351,10 +350,7 @@ export function buildCLI() {
|
|
|
351
350
|
}
|
|
352
351
|
}
|
|
353
352
|
|
|
354
|
-
//
|
|
355
|
-
if (!skipsContextHeader(argv)) {
|
|
356
|
-
await argv.app.printContextHeader(argv);
|
|
357
|
-
}
|
|
353
|
+
// Reads never probe or print runtime context. Writes use the guard result.
|
|
358
354
|
})
|
|
359
355
|
// CONFIGURATION
|
|
360
356
|
.command(setupCmd(wrap))
|
|
@@ -444,6 +440,9 @@ export function buildCLI() {
|
|
|
444
440
|
.command(atfCmd(wrap))
|
|
445
441
|
.command(scanCmd(wrap))
|
|
446
442
|
.command(storeCmd(wrap))
|
|
443
|
+
.command(pluginsCmd(wrap))
|
|
444
|
+
.command(compareCmd(wrap))
|
|
445
|
+
.command(subscriptionsCmd(wrap))
|
|
447
446
|
.command(approvalsCmd(wrap))
|
|
448
447
|
.command(skippedUpdatesCmd(wrap))
|
|
449
448
|
.command(perfCmd(wrap))
|
|
@@ -548,7 +547,7 @@ export function buildCLI() {
|
|
|
548
547
|
const welcome = maybeShowHome({ argv: formatArgv, requestedFormat, cfg: config });
|
|
549
548
|
if (!welcome) {
|
|
550
549
|
const registry = visibleCommandRegistry(
|
|
551
|
-
cliInstance.commandRegistry({ summaries: true }), config, formatArgv);
|
|
550
|
+
cliInstance.commandRegistry({ summaries: true, shallow: true }), config, formatArgv);
|
|
552
551
|
process.stdout.write(renderHelp(config, registry, { full: formatArgv?.allCommands === true }) + '\n');
|
|
553
552
|
}
|
|
554
553
|
process.exit(0);
|
|
@@ -574,7 +573,7 @@ export function buildCLI() {
|
|
|
574
573
|
const options = cliInstance.parseGlobalOptions(process.argv.slice(2));
|
|
575
574
|
const config = loadConfig(options);
|
|
576
575
|
const registry = visibleCommandRegistry(
|
|
577
|
-
cliInstance.commandRegistry({ summaries: true }), config, options);
|
|
576
|
+
cliInstance.commandRegistry({ summaries: true, shallow: true }), config, options);
|
|
578
577
|
return renderHelp(config, registry, { full: options?.allCommands === true });
|
|
579
578
|
};
|
|
580
579
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Lightweight family identity and safety declarations. Implementations reuse these
|
|
2
|
+
// objects: aliases, root help and mutation policy never depend on loading a handler.
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { declareCapabilities } from './capabilities.js';
|
|
5
|
+
|
|
6
|
+
// Node >=24 supports synchronous require(ESM). These implementation graphs must
|
|
7
|
+
// remain synchronous (no top-level await); this preserves the synchronous adapter
|
|
8
|
+
// and complete-discovery API without pre-parsing argv or a generated catalog.
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
|
|
11
|
+
export const flowsCmdDefinition = {
|
|
12
|
+
command: 'flows [subcommand]',
|
|
13
|
+
aliases: ['flow'],
|
|
14
|
+
describe: 'Manage Flow Designer flows',
|
|
15
|
+
};
|
|
16
|
+
declareCapabilities('flows', { transactionScopeOption: 'scope', mutationContextExemptSubcommands: ['test', 'unlock'], mutationSubcommands: ['clone', 'copy', 'create', 'update', 'edit', 'delete', 'publish', 'test', 'unlock'] });
|
|
17
|
+
export const flowsCmd = wrap => ({ ...flowsCmdDefinition, load: () => require('./commands/flows.js').flowsCmd(wrap) });
|
|
18
|
+
|
|
19
|
+
export const workflowsCmdDefinition = {
|
|
20
|
+
command: 'workflows [subcommand]',
|
|
21
|
+
aliases: ['workflow'],
|
|
22
|
+
describe: 'Inspect legacy Workflow Editor workflows (read-only)',
|
|
23
|
+
};
|
|
24
|
+
declareCapabilities('workflows', { mutationSubcommands: [] });
|
|
25
|
+
export const workflowsCmd = wrap => ({ ...workflowsCmdDefinition, load: () => require('./commands/workflows.js').workflowsCmd(wrap) });
|
|
26
|
+
|
|
27
|
+
export const midserversCmdDefinition = {
|
|
28
|
+
command: 'midservers [subcommand]',
|
|
29
|
+
aliases: ['midserver', 'mid'],
|
|
30
|
+
describe: 'Manage ServiceNow MID Servers and run commands through them',
|
|
31
|
+
};
|
|
32
|
+
declareCapabilities('midservers', { mutationContext: 'operational', mutationSubcommands: ['add', 'remove', 'execute', 'start', 'stop', 'validate'] });
|
|
33
|
+
export const midserversCmd = wrap => ({ ...midserversCmdDefinition, load: () => require('./commands/midservers.js').midserversCmd(wrap) });
|
|
34
|
+
|
|
35
|
+
export const subscriptionsCmdDefinition = {
|
|
36
|
+
command: 'subscriptions [subcommand]', describe: 'Inspect local metering schedules and compare illustrative ITOM populations',
|
|
37
|
+
};
|
|
38
|
+
declareCapabilities('subscriptions', { noInstance: true, skipDailyChecks: true, mutationSubcommands: [] });
|
|
39
|
+
export const subscriptionsCmd = wrap => ({ ...subscriptionsCmdDefinition, load: () => require('./commands/subscriptions.js').subscriptionsCmd(wrap) });
|
|
40
|
+
|
|
41
|
+
export const customizationsCmdDefinition = {
|
|
42
|
+
command: 'customizations [subcommand]',
|
|
43
|
+
describe: 'Capture and compare read-only customization evidence locally',
|
|
44
|
+
};
|
|
45
|
+
declareCapabilities('customizations', { noInstance: true, skipDailyChecks: true, mutationSubcommands: [] });
|
|
46
|
+
export const customizationsCmd = wrap => ({ ...customizationsCmdDefinition, load: () => require('./commands/customizations.js').customizationsCmd(wrap) });
|
|
47
|
+
|
|
48
|
+
export const skippedUpdatesCmdDefinition = {
|
|
49
|
+
command: 'skipped-updates', describe: 'Review and process existing unresolved skipped updates across all upgrade history',
|
|
50
|
+
};
|
|
51
|
+
declareCapabilities('skipped-updates', { mutationSubcommands: ['process'] });
|
|
52
|
+
export const skippedUpdatesCmd = wrap => ({ ...skippedUpdatesCmdDefinition, load: () => require('./commands/skipped-updates.js').skippedUpdatesCmd(wrap) });
|
|
53
|
+
|
|
54
|
+
export const docsCmdDefinition = {
|
|
55
|
+
command: 'docs [query..]',
|
|
56
|
+
defaultPositionals: true,
|
|
57
|
+
describe: 'Search ServiceNow documentation (hosted by default; configure your service in setup)',
|
|
58
|
+
};
|
|
59
|
+
declareCapabilities('docs', { noInstance: true, skipDailyChecks: true });
|
|
60
|
+
export const docsCmd = wrap => ({ ...docsCmdDefinition, load: () => require('./commands/docs/docs.js').docsCmd(wrap) });
|
|
61
|
+
|
|
62
|
+
export const perfCmdDefinition = {
|
|
63
|
+
command: 'perf [subcommand]',
|
|
64
|
+
aliases: ['performance'],
|
|
65
|
+
describe: 'Capture and compare read-only ServiceNow performance summaries',
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const perfCmd = wrap => ({ ...perfCmdDefinition, load: () => require('./commands/perf.js').perfCmd(wrap) });
|
package/src/commands/_generic.js
CHANGED
|
@@ -99,6 +99,7 @@ export function buildDevCmd(name, table, aliases, defaultColumns, wrap, opts = {
|
|
|
99
99
|
const readOnly = opts.readOnly || false;
|
|
100
100
|
// Capability declaration: the readOnly flag drives the mutation registry.
|
|
101
101
|
declareCapabilities(name, {
|
|
102
|
+
mutationContext: 'table', table,
|
|
102
103
|
mutationSubcommands: readOnly ? [] : ['create', 'update', 'delete'],
|
|
103
104
|
});
|
|
104
105
|
const scopeValidation = opts.scopeValidation || false;
|
package/src/commands/_ticket.js
CHANGED
|
@@ -11,7 +11,7 @@ import { declareCapabilities } from '../capabilities.js';
|
|
|
11
11
|
export function buildTicketCommands(table, displayName, alias, defaultColumns, stateMap, iconFn, wrap, opts = {}) {
|
|
12
12
|
// Ticket-style CRUD: list/show are reads; create/update/delete mutate.
|
|
13
13
|
// Root-level command only.
|
|
14
|
-
declareCapabilities(displayName, { mutationSubcommands: ['create', 'update', 'delete'] });
|
|
14
|
+
declareCapabilities(displayName, { mutationContext: 'operational', mutationSubcommands: ['create', 'update', 'delete'] });
|
|
15
15
|
return {
|
|
16
16
|
command: `${displayName} [subcommand]`,
|
|
17
17
|
aliases: [table, alias],
|
package/src/commands/actions.js
CHANGED
|
@@ -4,6 +4,7 @@ import { resolveRecord, unwrapSysId } from '../resolve-record.js';
|
|
|
4
4
|
import { declareCapabilities } from '../capabilities.js';
|
|
5
5
|
import { ACTION_TABLE, actionScope } from '../processflow-actions.js';
|
|
6
6
|
import { errUsage } from '../errors.js';
|
|
7
|
+
import { assertMutationScope } from '../intended-context.js';
|
|
7
8
|
import { cancelled, pickDesignerRecord, designerScope, guidedActionCreate, guidedActionEdit, guidedActionTestInputs, interactiveDesigner, hasDefinitionData, confirmDesignerMutation } from '../flow-designer-interactive.js';
|
|
8
9
|
|
|
9
10
|
const ACTION_COMMANDS = [
|
|
@@ -87,7 +88,7 @@ export const actionsCmd = wrap => {
|
|
|
87
88
|
{ action: 'list', cmd: 'jsn actions list', description: 'Back to actions' },
|
|
88
89
|
],
|
|
89
90
|
});
|
|
90
|
-
declareCapabilities('actions', { mutationSubcommands: ['create', 'update', 'edit', 'delete', 'test'] });
|
|
91
|
+
declareCapabilities('actions', { transactionScopeOption: 'scope', mutationContextExemptSubcommands: ['test'], mutationSubcommands: ['create', 'update', 'edit', 'delete', 'test'] });
|
|
91
92
|
// Retain the common wrap and output controller; domain failures get a
|
|
92
93
|
// structured error envelope and nonzero exit, never a success-shaped dispatch.
|
|
93
94
|
const run = handler => wrap(async (argv, app) => {
|
|
@@ -110,6 +111,7 @@ export const actionsCmd = wrap => {
|
|
|
110
111
|
const guided = !hasDefinitionData(argv) ? await guidedActionCreate(argv, app) : undefined;
|
|
111
112
|
const definition = guided?.definition ?? parseDataArg(argv);
|
|
112
113
|
const scope = guided?.scope ?? await designerScope(argv, app);
|
|
114
|
+
assertMutationScope(app.mutationContext, scope, 'Action creation');
|
|
113
115
|
const result = await app.sdk.createProcessFlowAction(scope, definition);
|
|
114
116
|
app.ok(result, { summary: `Created and verified action ${result.sys_id}` });
|
|
115
117
|
}),
|
|
@@ -152,9 +154,11 @@ export const actionsCmd = wrap => {
|
|
|
152
154
|
if (!hasDefinitionData(argv) && !interactiveDesigner(argv, app)) throw errUsage('Provide --data-file or --data for the full action definition in noninteractive mode');
|
|
153
155
|
const id = await actionID(argv, app);
|
|
154
156
|
if (id === undefined) return;
|
|
157
|
+
const scope = await actionScope(app.sdk, id, app.mutationContext?.application_id ?? argv.scope);
|
|
158
|
+
assertMutationScope(app.mutationContext, scope, 'Action target');
|
|
155
159
|
const definition = hasDefinitionData(argv) ? parseDataArg(argv)
|
|
156
|
-
: await guidedActionEdit(argv, app, await app.sdk.getProcessFlowAction(id,
|
|
157
|
-
const result = await app.sdk.updateProcessFlowAction(id,
|
|
160
|
+
: await guidedActionEdit(argv, app, await app.sdk.getProcessFlowAction(id, scope));
|
|
161
|
+
const result = await app.sdk.updateProcessFlowAction(id, scope, definition);
|
|
158
162
|
app.ok(result, { summary: `Saved and verified action ${id}` });
|
|
159
163
|
}),
|
|
160
164
|
})
|
|
@@ -216,7 +220,8 @@ export const actionsCmd = wrap => {
|
|
|
216
220
|
handler: run(async (argv, app) => {
|
|
217
221
|
const id = await actionID(argv, app);
|
|
218
222
|
if (id === undefined) return;
|
|
219
|
-
await actionScope(app.sdk, id, argv.scope);
|
|
223
|
+
const scope = await actionScope(app.sdk, id, app.mutationContext?.application_id ?? argv.scope);
|
|
224
|
+
assertMutationScope(app.mutationContext, scope, 'Action target');
|
|
220
225
|
await confirmDesignerMutation(argv, app, `Delete action '${id}'`);
|
|
221
226
|
await app.sdk.delete(ACTION_TABLE, id);
|
|
222
227
|
// Verify the exact target is absent. Do not interpret a 403 as deletion.
|
|
@@ -25,7 +25,7 @@ import { errUsage, errNotFound } from '../errors.js';
|
|
|
25
25
|
import { declareCapabilities } from '../capabilities.js';
|
|
26
26
|
|
|
27
27
|
// approve/reject/submit change approval state on records.
|
|
28
|
-
declareCapabilities('approvals', { mutationSubcommands: ['approve', 'reject', 'submit'] });
|
|
28
|
+
declareCapabilities('approvals', { mutationContext: 'operational', mutationSubcommands: ['approve', 'reject', 'submit'] });
|
|
29
29
|
|
|
30
30
|
// Raw sysapproval_approver.state values (verified live).
|
|
31
31
|
const APPROVAL_STATES = [
|
package/src/commands/atf.js
CHANGED
|
@@ -27,7 +27,7 @@ import { errUsage, errNotFound } from '../errors.js';
|
|
|
27
27
|
import { declareCapabilities } from '../capabilities.js';
|
|
28
28
|
|
|
29
29
|
// run/run-suite schedule tests that act on records (top-level only).
|
|
30
|
-
declareCapabilities('atf', { mutationSubcommands: ['run', 'run-suite'] });
|
|
30
|
+
declareCapabilities('atf', { mutationContext: 'operational', mutationSubcommands: ['run', 'run-suite'] });
|
|
31
31
|
|
|
32
32
|
// sn_cicd progress statuses (now-sdk poller.ts)
|
|
33
33
|
const PROGRESS_PENDING = '0';
|
|
@@ -4,7 +4,7 @@ import { confirmDelete, getStringField } from '../helpers.js';
|
|
|
4
4
|
import { errUsage } from '../errors.js';
|
|
5
5
|
import { declareCapabilities } from '../capabilities.js';
|
|
6
6
|
|
|
7
|
-
declareCapabilities('attachments', { mutationSubcommands: ['upload', 'add'] });
|
|
7
|
+
declareCapabilities('attachments', { mutationContext: 'operational', mutationSubcommands: ['upload', 'add'] });
|
|
8
8
|
const identifier = value => {
|
|
9
9
|
if (typeof value !== 'string' || !/^[A-Za-z0-9_-]+$/.test(value)) throw errUsage('Supply a safe record or attachment sys_id.');
|
|
10
10
|
return value;
|
package/src/commands/auth.js
CHANGED
|
@@ -894,6 +894,8 @@ Examples:
|
|
|
894
894
|
}
|
|
895
895
|
|
|
896
896
|
export async function showAuthStatus(argv, app) {
|
|
897
|
+
if (argv.context && !argv.profile) argv = { ...argv, profile: app.session?.profileName || app.config.activeProfile || app.config.defaultProfile };
|
|
898
|
+
if (argv.context && !app.config.profiles?.[argv.profile]) throw errUsage('Select a configured profile for auth status --context.');
|
|
897
899
|
const configuredDefault = app.config.profiles?.[app.config.defaultProfile];
|
|
898
900
|
const defaultInstance = configuredDefault?.instance_url || app.config.instanceURL || '';
|
|
899
901
|
|
|
@@ -923,6 +925,7 @@ export async function showAuthStatus(argv, app) {
|
|
|
923
925
|
let verified = null;
|
|
924
926
|
let verifiedAt = null;
|
|
925
927
|
let probe;
|
|
928
|
+
let runtimeContext = argv.context ? { verified: false, status: 'not_attempted' } : undefined;
|
|
926
929
|
if (argv.local) {
|
|
927
930
|
probe = { status: 'not_attempted', code: 'not_requested', classification: 'not_checked' };
|
|
928
931
|
} else if (!instance) {
|
|
@@ -942,8 +945,17 @@ export async function showAuthStatus(argv, app) {
|
|
|
942
945
|
if (probe.status === 'succeeded' && user?.user_name) {
|
|
943
946
|
verified = true;
|
|
944
947
|
verifiedAt = user.user_name;
|
|
948
|
+
if (argv.context) {
|
|
949
|
+
try {
|
|
950
|
+
const { readWriteContext } = await import('../intended-context.js');
|
|
951
|
+
runtimeContext = { ...await readWriteContext(sdk), verified: true };
|
|
952
|
+
runtimeContext.domain.requested = profile.domain || null;
|
|
953
|
+
if (runtimeContext.user.user_name !== user.user_name) throw new Error('Context account mismatch');
|
|
954
|
+
} catch { runtimeContext = { verified: false, status: 'unavailable' }; }
|
|
955
|
+
}
|
|
945
956
|
if (profile.username && profile.username !== user.user_name) {
|
|
946
957
|
verified = false;
|
|
958
|
+
if (runtimeContext) runtimeContext = { verified: false, status: 'account_mismatch' };
|
|
947
959
|
probe = {
|
|
948
960
|
status: 'failed', code: 'account_mismatch', classification: 'account_mismatch',
|
|
949
961
|
message: 'The session account does not match the configured profile account.',
|
|
@@ -966,6 +978,7 @@ export async function showAuthStatus(argv, app) {
|
|
|
966
978
|
|
|
967
979
|
profiles.push({
|
|
968
980
|
name,
|
|
981
|
+
...(runtimeContext ? { context: runtimeContext } : {}),
|
|
969
982
|
instance,
|
|
970
983
|
username: profile.username || undefined,
|
|
971
984
|
active: name === (app.session?.profileName || app.config.activeProfile || app.config.defaultProfile),
|
|
@@ -1000,8 +1013,12 @@ export async function showAuthStatus(argv, app) {
|
|
|
1000
1013
|
const summary = `${profiles.length} ${profiles.length === 1 ? 'profile' : 'profiles'}`;
|
|
1001
1014
|
// Ship the styled view as _formatted (see renderAuthStatus); the
|
|
1002
1015
|
// OutputWriter prints it verbatim and suppresses the summary.
|
|
1003
|
-
result._formatted = renderAuthStatus(result, summary, { details: argv.details === true });
|
|
1004
|
-
if (
|
|
1016
|
+
result._formatted = renderAuthStatus(result, summary, { details: argv.details === true || argv.context === true });
|
|
1017
|
+
if (argv.context) result._formatted += profiles.map(p => {
|
|
1018
|
+
const c = p.context;
|
|
1019
|
+
return `\n${p.name}: ${c?.verified ? `user ${c.user.user_name}; scope ${c.scope}; update set ${c.update_set.name} (${c.update_set.sys_id}); domain unverified${c.domain.requested ? `, requested ${c.domain.requested}` : ''}` : `context ${c?.status || 'unavailable'}`}`;
|
|
1020
|
+
}).join('');
|
|
1021
|
+
if (!argv.details && !argv.context) {
|
|
1005
1022
|
delete result.default_instance;
|
|
1006
1023
|
result.profiles = profiles.map(({ instance: _instance, username: _username, verified_as: _verifiedAs, ...visible }) => visible);
|
|
1007
1024
|
}
|
|
@@ -1207,6 +1224,8 @@ export function authCmd(wrap) {
|
|
|
1207
1224
|
describe: 'Show authentication status (use --details for users and instance URLs)',
|
|
1208
1225
|
builder: sub => sub.option('local', {
|
|
1209
1226
|
type: 'boolean', describe: 'Show saved credential state without contacting any instance',
|
|
1227
|
+
}).option('context', {
|
|
1228
|
+
type: 'boolean', describe: 'Full context for selected/default profile, including live user, scope, capture set and domain verification limits; --local makes no requests',
|
|
1210
1229
|
}).option('details', {
|
|
1211
1230
|
type: 'boolean', describe: 'Include users and instance URLs in status output',
|
|
1212
1231
|
}),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// GraphQL read-only queries; no sn_codesearch engine or Flow downloads.
|
|
2
2
|
import { searchGraphQL } from '../codesearch-graphql.js';
|
|
3
|
+
import { docLink } from '../docs-links.js';
|
|
3
4
|
|
|
4
5
|
export function renderCodeSearch(data) {
|
|
5
6
|
const out = [`${data.recordCount} record(s), ${data.fieldCount} field(s), ${data.matchCount} match(es) — ${data.status}`];
|
|
@@ -35,13 +36,21 @@ export function codesearchCmd(wrap) {
|
|
|
35
36
|
.option('all-scopes', { type: 'boolean', default: true, describe: 'Search all scopes; false requires --scope' })
|
|
36
37
|
.option('page-size', { type: 'number', default: 250, describe: 'GraphQL page window size (max 1000)' })
|
|
37
38
|
.option('max-pages', { type: 'number', default: 20, describe: 'Maximum pages per table (max 1000)' })
|
|
38
|
-
.option('max-requests', { type: 'number', default: 1000, describe: 'Data-call budget including configuration, excluding SDK auth/bootstrap (max 10000)' })
|
|
39
|
+
.option('max-requests', { type: 'number', default: 1000, describe: 'Data-call budget including configuration, excluding SDK auth/bootstrap (max 10000)' })
|
|
40
|
+
.epilogue(`Code search is literal and read-only. Flow internals use "jsn flows search <term>".
|
|
41
|
+
Examples:
|
|
42
|
+
jsn codesearch search GlideAjax --limit 5
|
|
43
|
+
jsn codesearch search approval --scope x_my_app --limit 5
|
|
44
|
+
|
|
45
|
+
Full reference and coverage limits: ${docLink('codesearch')}`),
|
|
39
46
|
handler: wrap(async (argv, app) => {
|
|
40
47
|
const data = await searchGraphQL(app, argv);
|
|
41
48
|
Object.defineProperty(data, '_formatted', { value: renderCodeSearch(data), enumerable: false });
|
|
42
49
|
app.ok(data, { summary: `${data.recordCount} record(s), ${data.fieldCount} field(s), ${data.matchCount} match(es) — ${data.status}` });
|
|
43
50
|
}),
|
|
44
|
-
}).demandCommand(1, 'Specify a subcommand: search')
|
|
51
|
+
}).demandCommand(1, 'Specify a subcommand: search')
|
|
52
|
+
.epilogue(`Code search is literal and read-only. Flow internals use "jsn flows search <term>".
|
|
53
|
+
Documentation: ${docLink('codesearch')}`),
|
|
45
54
|
handler: () => {},
|
|
46
55
|
};
|
|
47
56
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { declareCapabilities } from '../capabilities.js';
|
|
2
|
+
import { inventoryCompareCommand, compareInstanceInventory } from '../instance-inventory.js';
|
|
3
|
+
|
|
4
|
+
declareCapabilities('compare', { skipContextHeader: true });
|
|
5
|
+
export const compareCmd = wrap => ({
|
|
6
|
+
...inventoryCompareCommand(wrap, 'plugins'),
|
|
7
|
+
command: 'compare',
|
|
8
|
+
describe: 'Compare plugins AND Store apps; report how to align --target to desired --source (read-only)',
|
|
9
|
+
handler: wrap(async (argv, app) => {
|
|
10
|
+
const plugins = await compareInstanceInventory(argv, app, 'plugins', false);
|
|
11
|
+
const store = await compareInstanceInventory(argv, app, 'store', false);
|
|
12
|
+
const data = {
|
|
13
|
+
source: plugins.source, target: plugins.target, complete: plugins.complete && store.complete,
|
|
14
|
+
inventories: { plugins, store },
|
|
15
|
+
counts: Object.fromEntries(Object.keys(plugins.counts).map(key => [key, plugins.counts[key] + store.counts[key]])),
|
|
16
|
+
caveat: 'Distinct plugin and Store inventories can overlap. Counts are unique within each inventory, not a deduplicated product count. Recommendations are review guidance, never executable remediation.',
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(data, '_formatted', { value: `${plugins._formatted}\n\n${store._formatted}\n\n${data.caveat}`, enumerable: false });
|
|
19
|
+
app.ok(data, { summary: 'Align target to source: plugins and Store applications' });
|
|
20
|
+
if (!data.complete) process.exitCode = 1;
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { customizationsCmdDefinition } from '../command-families.js';
|
|
2
2
|
import { errUsageHint, errUsage } from '../errors.js';
|
|
3
3
|
import { canUsePicker } from '../helpers.js';
|
|
4
4
|
import { paginatedSearch } from '../paginated-search.js';
|
|
@@ -7,7 +7,7 @@ import { buildActionableReport, writeCustomizationHtml } from '../customizations
|
|
|
7
7
|
import { customizationGuidance, formatCustomizationGuidance } from '../customization-guidance.js';
|
|
8
8
|
|
|
9
9
|
// Only capture needs an instance. Saved reports never need network access.
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
const listHint = { action: 'list', cmd: 'jsn customizations list', description: 'Browse saved customization captures' };
|
|
12
12
|
const showHint = id => ({ action: 'show', cmd: `jsn customizations show ${id}`, description: 'Review this saved capture' });
|
|
13
13
|
const compareHint = id => ({ action: 'compare', cmd: `jsn customizations compare ${id} OTHER_RUN_ID`, description: 'Compare captured metadata and evidence' });
|
|
@@ -30,8 +30,7 @@ function show(app, report, options = {}) {
|
|
|
30
30
|
}
|
|
31
31
|
export function customizationsCmd(wrap) {
|
|
32
32
|
return {
|
|
33
|
-
|
|
34
|
-
describe: 'Capture and compare read-only customization evidence locally',
|
|
33
|
+
...customizationsCmdDefinition,
|
|
35
34
|
builder: y => y
|
|
36
35
|
.command({ command: 'capture', describe: 'Capture bounded read-only metadata and historical upgrade evidence',
|
|
37
36
|
builder: b => b.option('label', { type: 'string', describe: 'Label for this capture' })
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
+
import { assertMutationScope } from '../intended-context.js';
|
|
2
3
|
import { getStringField, formatRecordForDisplay, interactiveList, assertSafeExactMatch, confirmDelete } from '../helpers.js';
|
|
3
4
|
import { resolveRecord, unwrapSysId, isSysId } from '../resolve-record.js';
|
|
4
5
|
import { inspectDecisionTable } from '../decision-table-inspection.js';
|
|
@@ -19,6 +20,7 @@ export const decisiontablesCmd = (wrap) => {
|
|
|
19
20
|
.option('data', { type: 'string', describe: 'Complete decision-table JSON payload' })
|
|
20
21
|
.option('data-file', { type: 'string', describe: 'Read complete decision-table JSON payload from a file' });
|
|
21
22
|
const resolveExecutionScope = async (app) => {
|
|
23
|
+
if (app.mutationContext?.verified) return app.mutationContext.application_id;
|
|
22
24
|
const scope = app.context?.scope;
|
|
23
25
|
if (!scope) return 'global';
|
|
24
26
|
const scopeSysId = await app.sdk.resolveScope(scope);
|
|
@@ -32,6 +34,7 @@ export const decisiontablesCmd = (wrap) => {
|
|
|
32
34
|
const records = await app.sdk.list('sys_decision', params);
|
|
33
35
|
if (records.length === 0) throw new Error(`Decision table not found in active scope: ${identifier}`);
|
|
34
36
|
if (records.length > 1) throw new Error(`Decision table ${field} is ambiguous in active scope: ${identifier}`);
|
|
37
|
+
assertMutationScope(app.mutationContext, records[0].sys_scope, 'Decision table target');
|
|
35
38
|
return records[0];
|
|
36
39
|
};
|
|
37
40
|
const resolveDecisionTableForUpdate = async (app, identifier, scopeSysId) => {
|
|
@@ -42,6 +45,7 @@ export const decisiontablesCmd = (wrap) => {
|
|
|
42
45
|
const records = await app.sdk.list('sys_decision', params);
|
|
43
46
|
if (records.length === 0) throw new Error(`Decision table not found${scopeSysId === 'global' ? '' : ' in active scope'}: ${identifier}`);
|
|
44
47
|
if (records.length > 1) throw new Error(`Decision table ${field} is ambiguous: ${identifier}`);
|
|
48
|
+
assertMutationScope(app.mutationContext, records[0].sys_scope, 'Decision table target');
|
|
45
49
|
const id = unwrapSysId(records[0]);
|
|
46
50
|
if (!isSysId(id)) throw new Error(`Decision table returned an invalid identifier: ${identifier}`);
|
|
47
51
|
return id;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { docsCmdDefinition } from '../../command-families.js';
|
|
1
2
|
// Documentation search always uses the same API, hosted or self-hosted.
|
|
2
3
|
import { searchHostedDocs, getHostedDoc, getHostedDocsStatus, configuredDocsService } from './client.js';
|
|
3
4
|
import { documentationService } from './local.js';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
+
import { docLink } from '../../docs-links.js';
|
|
6
7
|
import { AppError } from '../../errors.js';
|
|
7
8
|
import { resolveDocsRelease } from './db.js';
|
|
8
9
|
import { listDocsReleases } from './releases.js';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
|
|
11
12
|
|
|
12
13
|
function presented(data, text) {
|
|
13
14
|
return Object.defineProperty(data, '_formatted', { value: text, enumerable: false });
|
|
@@ -57,11 +58,10 @@ export function docsCmd(wrapHandler) {
|
|
|
57
58
|
return handler(argv, app);
|
|
58
59
|
});
|
|
59
60
|
return {
|
|
60
|
-
|
|
61
|
-
defaultPositionals: true,
|
|
62
|
-
describe: 'Search ServiceNow documentation (hosted by default; configure your service in setup)',
|
|
61
|
+
...docsCmdDefinition,
|
|
63
62
|
builder: y => y
|
|
64
63
|
.usage('Usage: jsn docs "search terms" [options]')
|
|
64
|
+
.epilogue(`Documentation for this command: ${docLink('docs')}`)
|
|
65
65
|
.positional('query', { type: 'string', describe: 'Search words (up to 200 characters)' })
|
|
66
66
|
.option('release', { type: 'string', describe: 'Documentation family (docs.release config, otherwise australia)' })
|
|
67
67
|
|
package/src/commands/domains.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getStringField, interactiveList, assertSafeExactMatch } from '../helper
|
|
|
6
6
|
import { declareCapabilities } from '../capabilities.js';
|
|
7
7
|
|
|
8
8
|
// `domains set` writes the chosen domain into the profile config.
|
|
9
|
-
declareCapabilities('domains', { mutationSubcommands: ['set', 'session-set', 'session-reset'] });
|
|
9
|
+
declareCapabilities('domains', { mutationContext: 'operational', mutationSubcommands: ['set', 'session-set', 'session-reset'] });
|
|
10
10
|
|
|
11
11
|
const DETAIL_FIELDS = 'sys_id,name,parent,sys_domain_path,description,active,sys_created_on,sys_updated_on';
|
|
12
12
|
|
package/src/commands/eval.js
CHANGED
|
@@ -5,7 +5,7 @@ import { runRepl } from '../eval-repl.js';
|
|
|
5
5
|
|
|
6
6
|
// The whole command is a mutation surface (runs arbitrary server-side JS) —
|
|
7
7
|
// declared as `['']` so the root `jsn eval` command are gated.
|
|
8
|
-
declareCapabilities('eval', { mutationSubcommands: [''] });
|
|
8
|
+
declareCapabilities('eval', { transactionScopeOption: 'scope', mutationSubcommands: [''] });
|
|
9
9
|
|
|
10
10
|
export function evalCmd(wrap) {
|
|
11
11
|
return {
|
|
@@ -13,11 +13,17 @@ export function evalCmd(wrap) {
|
|
|
13
13
|
describe: 'Execute background scripts on the instance (--repl for interactive mode)',
|
|
14
14
|
builder: (yargs) => {
|
|
15
15
|
return yargs
|
|
16
|
+
.middleware(argv => {
|
|
17
|
+
if (!argv.repl) return;
|
|
18
|
+
const conflicts = ['script', 'file', 'stdin'].filter(key => argv[key]).map(key => `--${key}`);
|
|
19
|
+
if (conflicts.length) throw new Error(`--repl cannot be combined with ${conflicts.join(', ')}`);
|
|
20
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) throw new Error('--repl needs an interactive terminal. Use --script, --file or --stdin for scripts and agents.');
|
|
21
|
+
})
|
|
16
22
|
.option('script', { alias: 's', type: 'string', describe: 'JavaScript code to execute (single-quote the script, double quotes inside: --script \'gs.log("Hello")\')' })
|
|
17
23
|
.option('file', { alias: 'f', type: 'string', describe: 'Read script from file (avoids shell quoting issues)' })
|
|
18
24
|
.option('stdin', { type: 'boolean', describe: 'Read script from stdin (pipe-friendly, e.g. cat script.js | jsn eval --stdin)' })
|
|
19
25
|
.option('repl', { type: 'boolean', default: false, describe: 'Interactive mode: type a script, submit with .exec (requires a terminal)' })
|
|
20
|
-
.option('scope', { alias: null, type: 'string', describe: 'Scope name or sys_id to run the script under (default:
|
|
26
|
+
.option('scope', { alias: null, type: 'string', describe: 'Scope name or sys_id to run the script under (default: verified intended scope)' })
|
|
21
27
|
// Script-mode flags (issue #177) — map to the Script Background form checkboxes
|
|
22
28
|
.option('rollback', { type: 'boolean', default: true, describe: 'Record rollback context (--no-rollback to skip)' })
|
|
23
29
|
.option('sandbox', { type: 'boolean', default: false, describe: 'Sandbox mode (KittyScript evaluator, single expression only — no DB writes)' })
|
|
@@ -26,12 +32,12 @@ export function evalCmd(wrap) {
|
|
|
26
32
|
},
|
|
27
33
|
handler: wrap(async (argv, app) => {
|
|
28
34
|
let script;
|
|
29
|
-
let scopeSysId = null;
|
|
35
|
+
let scopeSysId = app.mutationContext?.application_id || null;
|
|
30
36
|
|
|
31
37
|
// Resolve execution scope: explicit --scope wins; otherwise use the
|
|
32
38
|
// active scope from apps.current_app (same source as the banner);
|
|
33
39
|
// fall back to global only when no active scope exists.
|
|
34
|
-
let scope = argv.scope || '';
|
|
40
|
+
let scope = app.mutationContext?.scope || argv.scope || '';
|
|
35
41
|
if (!scope) {
|
|
36
42
|
try {
|
|
37
43
|
const user = await getCurrentUser(app.sdk);
|
|
@@ -46,7 +52,7 @@ export function evalCmd(wrap) {
|
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
54
|
|
|
49
|
-
if (scope) {
|
|
55
|
+
if (scope && !scopeSysId) {
|
|
50
56
|
scopeSysId = await app.sdk.resolveScope(scope);
|
|
51
57
|
if (!scopeSysId) {
|
|
52
58
|
throw new Error(`Scope not found: ${scope}`);
|