@jacebenson/jsn 5.5.1 → 5.5.2-dev.174.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 +30 -2
- package/package.json +1 -1
- package/src/app.js +15 -2
- package/src/auth/mfa.js +85 -0
- package/src/cli-adapter.js +18 -4
- package/src/cli.js +26 -8
- package/src/commands/_generic.js +10 -2
- package/src/commands/_ticket.js +12 -4
- package/src/commands/approvals.js +1 -0
- package/src/commands/auth.js +15 -8
- package/src/commands/cases.js +1 -1
- package/src/commands/cmdb.js +1 -1
- package/src/commands/discover.js +1 -0
- package/src/commands/docs/client.js +17 -7
- package/src/commands/docs/community.js +4 -4
- package/src/commands/docs/db.js +26 -11
- package/src/commands/docs/docs.js +30 -13
- package/src/commands/docs/embed.js +2 -2
- package/src/commands/docs/index-worker.js +1 -1
- package/src/commands/docs/index.js +4 -3
- package/src/commands/docs/ingest.js +4 -4
- package/src/commands/docs/install.js +19 -17
- package/src/commands/docs/local.js +6 -4
- package/src/commands/docs/refresh.js +3 -3
- package/src/commands/docs/releases.js +27 -0
- package/src/commands/docs/search.js +3 -3
- package/src/commands/docs/serve.js +3 -3
- package/src/commands/docs/server.js +13 -10
- package/src/commands/docs/service-snapshot.js +3 -3
- package/src/commands/docs/snapshot.js +32 -11
- package/src/commands/docs/sync-service.js +8 -6
- package/src/commands/docs/sync.js +24 -15
- package/src/commands/flows.js +70 -5
- package/src/commands/knowledge.js +1 -0
- package/src/commands/records.js +12 -3
- package/src/commands/setup.js +20 -8
- package/src/commands/tickets.js +11 -3
- package/src/errors.js +23 -1
- package/src/flow-create.js +1237 -57
- package/src/flow-inspection.js +26 -2
- package/src/help.js +95 -21
- package/src/helpers.js +20 -1
- package/src/output.js +19 -5
- package/src/prompts.js +9 -0
- package/src/record-command-profiles.js +8 -4
- package/src/record-profiles.js +1 -0
- package/src/records-engine.js +2 -1
- package/src/sdk.js +157 -15
- package/src/setup-preferences.js +3 -3
- package/src/table-read-params.js +9 -0
- package/src/welcome.js +34 -36
package/src/flow-inspection.js
CHANGED
|
@@ -4,7 +4,7 @@ import { getStringField } from './helpers.js';
|
|
|
4
4
|
* Inspect a flow through the narrow remote adapter and render its deep view.
|
|
5
5
|
* The adapter only needs inspectFlow and inspectCustomAction.
|
|
6
6
|
*/
|
|
7
|
-
export async function inspectFlow({ adapter, identifier, instanceURL = '', depth = 2 }) {
|
|
7
|
+
export async function inspectFlow({ adapter, identifier, instanceURL = '', depth = 2, includePayload = false }) {
|
|
8
8
|
if (!adapter || typeof adapter.inspectFlow !== 'function') {
|
|
9
9
|
throw new TypeError('flow inspection adapter must provide inspectFlow');
|
|
10
10
|
}
|
|
@@ -19,7 +19,31 @@ export async function inspectFlow({ adapter, identifier, instanceURL = '', depth
|
|
|
19
19
|
catalogLookupCache: new Map(),
|
|
20
20
|
};
|
|
21
21
|
const formatted = await formatFlowInspection(inspection, ctx);
|
|
22
|
-
|
|
22
|
+
const shaped = includePayload ? inspection : omitRawPayload(inspection);
|
|
23
|
+
const result = { ...shaped };
|
|
24
|
+
// Same convention as `catalogitems show`: the rendered view is a styled-mode
|
|
25
|
+
// side channel, so it must not appear in the JSON envelope. Attached
|
|
26
|
+
// enumerably it shipped the whole ASCII tree (4.9KB on one flow) next to the
|
|
27
|
+
// fields it renders, on top of an already oversized payload.
|
|
28
|
+
Object.defineProperty(result, '_formatted', { value: formatted, enumerable: false, configurable: true });
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The raw ProcessFlow document is both the bulk of a `flows show` response and
|
|
34
|
+
* a duplicate of it: actionInstances, flowLogicInstances and subFlowInstances
|
|
35
|
+
* are copied out of the payload onto the inspection, so every step serializes
|
|
36
|
+
* twice. Measured on a 10-step flow: 536KB of payload inside 1.06MB of data,
|
|
37
|
+
* with all three arrays byte-identical at both levels. The styled view is
|
|
38
|
+
* rendered from the payload before this runs, and `--raw-payload` keeps it for
|
|
39
|
+
* the rare caller that needs the provider document itself.
|
|
40
|
+
*/
|
|
41
|
+
function omitRawPayload(inspection) {
|
|
42
|
+
if (!inspection || typeof inspection !== 'object' || Array.isArray(inspection)) return inspection;
|
|
43
|
+
if (!Object.prototype.hasOwnProperty.call(inspection, 'payload')) return inspection;
|
|
44
|
+
const copy = { ...inspection };
|
|
45
|
+
delete copy.payload;
|
|
46
|
+
return copy;
|
|
23
47
|
}
|
|
24
48
|
|
|
25
49
|
function normalizeInspection(value) {
|
package/src/help.js
CHANGED
|
@@ -10,20 +10,49 @@
|
|
|
10
10
|
// (`approvals`, `cmdb`, `docs`, `perf`, `platform`, … were missing from the
|
|
11
11
|
// hand-written list while being fully registered).
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const COMMON_COMMANDS = [
|
|
14
|
+
'incidents', 'requests', 'tasks', 'changes', 'approvals', 'knowledge', 'records', 'setup', 'discover',
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const CONCISE_FLAGS = ['instance', 'profile', 'json'];
|
|
18
|
+
|
|
19
|
+
const CONCISE_EXAMPLES = [
|
|
20
|
+
'jsn incidents list --query "active=true" --limit 5',
|
|
21
|
+
'jsn records list --table incident --limit 5 --json',
|
|
22
|
+
'jsn discover catalog',
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const CONCISE_MORE = [
|
|
26
|
+
{ label: 'jsn <command> <action> --help', description: 'Options for one command or action' },
|
|
27
|
+
{ label: 'jsn discover <word>', description: 'Find commands by task words' },
|
|
28
|
+
{ label: 'jsn discover --table <table>', description: 'Find commands configured for a table' },
|
|
29
|
+
{ label: 'jsn --all-commands --help', description: 'Every registered command and global flag' },
|
|
30
|
+
{ label: 'jsn --json', description: 'Registered command surface as JSON' },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
function renderGroup(name, commands, width = helpWidth()) {
|
|
14
34
|
const lines = [`\n${name}`];
|
|
15
35
|
lines.push('─'.repeat(50));
|
|
36
|
+
let rows = [];
|
|
37
|
+
const flush = () => {
|
|
38
|
+
if (!rows.length) return;
|
|
39
|
+
lines.push(renderRows(rows, { width, indent: 2 }));
|
|
40
|
+
rows = [];
|
|
41
|
+
};
|
|
16
42
|
for (const cmd of commands) {
|
|
17
43
|
if (cmd.divider) {
|
|
44
|
+
flush();
|
|
18
45
|
lines.push('');
|
|
19
46
|
lines.push(` ${cmd.divider}`);
|
|
20
47
|
continue;
|
|
21
48
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
49
|
+
rows.push({
|
|
50
|
+
label: cmd.name,
|
|
51
|
+
description: cmd.desc,
|
|
52
|
+
note: cmd.alias ? `(${cmd.alias})` : '',
|
|
53
|
+
});
|
|
26
54
|
}
|
|
55
|
+
flush();
|
|
27
56
|
return lines.join('\n');
|
|
28
57
|
}
|
|
29
58
|
|
|
@@ -186,20 +215,57 @@ function rowsFor(hint, byName, used, config) {
|
|
|
186
215
|
return rows;
|
|
187
216
|
}
|
|
188
217
|
|
|
189
|
-
function renderFlags(options) {
|
|
218
|
+
function renderFlags(options, { full = false, width = helpWidth() } = {}) {
|
|
190
219
|
// Derived from the registered global options, so a new global flag cannot be
|
|
191
|
-
// missing from
|
|
192
|
-
|
|
193
|
-
|
|
220
|
+
// missing from the full reference (--get and --csv were, along with the csv
|
|
221
|
+
// format choice). The concise page shows only the flags needed to point a
|
|
222
|
+
// command at an instance and choose machine output.
|
|
223
|
+
const rows = [];
|
|
224
|
+
const specs = full
|
|
225
|
+
? options
|
|
226
|
+
: CONCISE_FLAGS.map((name) => options.find((spec) => spec.name === name)).filter(Boolean);
|
|
227
|
+
for (const spec of specs) {
|
|
194
228
|
if (spec.name === 'help') continue;
|
|
195
|
-
const alias = spec.alias.length ?
|
|
229
|
+
const alias = spec.alias.map(name => `${name.length === 1 ? '-' : '--'}${name}`).join(', ');
|
|
230
|
+
const label = `${alias ? `${alias}, ` : ''}--${spec.name}`;
|
|
196
231
|
const suffix = spec.name === 'format' && spec.choices.length
|
|
197
|
-
? `
|
|
198
|
-
: `
|
|
199
|
-
|
|
232
|
+
? `[string: ${spec.choices.join(', ')}]`
|
|
233
|
+
: `[${spec.type}]`;
|
|
234
|
+
rows.push({ label, description: spec.description, note: suffix });
|
|
200
235
|
}
|
|
201
|
-
|
|
202
|
-
return `\nFLAGS\n${
|
|
236
|
+
rows.push({ label: '--help', description: 'Show help', note: '[boolean]' });
|
|
237
|
+
return `\nFLAGS\n${renderRows(rows, { width, indent: 2 })}`;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The ordinary root page: common task commands, a few flags, runnable
|
|
242
|
+
* examples, and pointers to the exhaustive reference and local discovery.
|
|
243
|
+
*/
|
|
244
|
+
function renderConciseHelp(config, registry, width) {
|
|
245
|
+
const commands = Array.isArray(registry?.commands) ? registry.commands : [];
|
|
246
|
+
const byName = new Map(commands.map((command) => [command.name, command]));
|
|
247
|
+
const common = COMMON_COMMANDS
|
|
248
|
+
.map((name) => byName.get(name))
|
|
249
|
+
.filter((command) => command && !isCapabilityHidden(command.name, config))
|
|
250
|
+
.map((command) => ({
|
|
251
|
+
name: command.name,
|
|
252
|
+
desc: command.summary || command.description || '',
|
|
253
|
+
}));
|
|
254
|
+
|
|
255
|
+
return [
|
|
256
|
+
'Usage: jsn <command> [options]',
|
|
257
|
+
'',
|
|
258
|
+
'Command-line interface for ServiceNow',
|
|
259
|
+
renderGroup('COMMON COMMANDS', common, width),
|
|
260
|
+
'',
|
|
261
|
+
'EXAMPLES',
|
|
262
|
+
...CONCISE_EXAMPLES.map((example) => ` ${example}`),
|
|
263
|
+
renderFlags(Array.isArray(registry?.options) ? registry.options : [], { width }),
|
|
264
|
+
'',
|
|
265
|
+
'MORE',
|
|
266
|
+
renderRows(CONCISE_MORE, { width, indent: 2 }),
|
|
267
|
+
'',
|
|
268
|
+
].join('\n');
|
|
203
269
|
}
|
|
204
270
|
|
|
205
271
|
export function renderTips() {
|
|
@@ -211,7 +277,7 @@ TIPS
|
|
|
211
277
|
Cross-table task searches and custom tables: "jsn records list --help"
|
|
212
278
|
Specialized commands offer configured columns, lookup, and table-specific views; inspect discovery results for details
|
|
213
279
|
Raw endpoints when needed: "jsn rest --help"; examples and intent guidance: "jsn discover --help"
|
|
214
|
-
Use "jsn <command> --help" for
|
|
280
|
+
Use "jsn <command> <action> --help" for options on one command or action
|
|
215
281
|
"jsn --json" prints the registered command surface as JSON for scripts and agents
|
|
216
282
|
|
|
217
283
|
LEARN MORE
|
|
@@ -222,14 +288,22 @@ LEARN MORE
|
|
|
222
288
|
}
|
|
223
289
|
|
|
224
290
|
/**
|
|
225
|
-
* Render
|
|
291
|
+
* Render root help.
|
|
292
|
+
*
|
|
293
|
+
* The ordinary page is a concise task directory. `full: true` (used by
|
|
294
|
+
* `--all-commands --help`) renders the exhaustive grouped reference: every
|
|
295
|
+
* visible registered command and every registered global option, plus the
|
|
296
|
+
* tips and picker details that would crowd the short page.
|
|
226
297
|
*
|
|
227
298
|
* @param {object} config — profile config (capability-conditioned hiding)
|
|
228
299
|
* @param {{commands: Array, options: Array}} [registry] — from
|
|
229
300
|
* `cli.commandRegistry()`. Without it only the hint tables render, which is
|
|
230
301
|
* the fallback for callers that have no registry (unit tests).
|
|
302
|
+
* @param {{full?: boolean, width?: number}} [opts]
|
|
231
303
|
*/
|
|
232
|
-
export function renderHelp(config, registry = null) {
|
|
304
|
+
export function renderHelp(config, registry = null, { full = false, width = helpWidth() } = {}) {
|
|
305
|
+
if (!full) return renderConciseHelp(config, registry, width);
|
|
306
|
+
|
|
233
307
|
const commands = Array.isArray(registry?.commands) ? registry.commands : [];
|
|
234
308
|
const byName = new Map(commands.map((command) => [command.name, command]));
|
|
235
309
|
const used = new Set();
|
|
@@ -237,14 +311,14 @@ export function renderHelp(config, registry = null) {
|
|
|
237
311
|
const sections = Object.entries(COMMAND_GROUPS)
|
|
238
312
|
.map(([name, hint]) => [name, rowsFor(hint, byName, used, config)])
|
|
239
313
|
.filter(([, rows]) => rows.some((row) => !row.divider))
|
|
240
|
-
.map(([name, rows]) => renderGroup(name, rows));
|
|
314
|
+
.map(([name, rows]) => renderGroup(name, rows, width));
|
|
241
315
|
|
|
242
316
|
// Anything registered that the hint tables don't place. This is the safety
|
|
243
317
|
// net that keeps help complete as commands are added at the root.
|
|
244
318
|
const unplaced = commands
|
|
245
319
|
.filter((command) => !used.has(command.name) && !isCapabilityHidden(command.name, config))
|
|
246
320
|
.map((command) => ({ name: command.name, alias: command.aliases[0] || '', desc: command.description || '' }));
|
|
247
|
-
if (unplaced.length) sections.push(renderGroup('MORE', unplaced));
|
|
321
|
+
if (unplaced.length) sections.push(renderGroup('MORE', unplaced, width));
|
|
248
322
|
|
|
249
323
|
return [
|
|
250
324
|
'Usage: jsn <command> [options]',
|
|
@@ -253,7 +327,7 @@ export function renderHelp(config, registry = null) {
|
|
|
253
327
|
'',
|
|
254
328
|
...sections,
|
|
255
329
|
'',
|
|
256
|
-
renderFlags(Array.isArray(registry?.options) ? registry.options : []),
|
|
330
|
+
renderFlags(Array.isArray(registry?.options) ? registry.options : [], { full: true, width }),
|
|
257
331
|
renderTips(),
|
|
258
332
|
'',
|
|
259
333
|
].join('\n');
|
package/src/helpers.js
CHANGED
|
@@ -5,7 +5,7 @@ import readline from 'node:readline';
|
|
|
5
5
|
import { paginatedSearch } from './paginated-search.js';
|
|
6
6
|
import { isTTY, FormatAuto } from './output.js';
|
|
7
7
|
import { getActiveProfile } from './config.js';
|
|
8
|
-
import { errConfirmationRequired } from './errors.js';
|
|
8
|
+
import { errConfirmationRequired, isTerminalAuthError } from './errors.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Detect whether a human is actually available to answer interactive
|
|
@@ -298,6 +298,22 @@ export function formatRecordForDisplay(record, columns) {
|
|
|
298
298
|
return result;
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
+
/**
|
|
302
|
+
* Identify requested columns that ServiceNow omitted from every returned row
|
|
303
|
+
* (because the field does not exist on the table or is blocked by ACLs).
|
|
304
|
+
* An existing empty column is still present as a key (`col in row === true`).
|
|
305
|
+
*
|
|
306
|
+
* @param {Array<object>} records — raw records from ServiceNow Table API
|
|
307
|
+
* @param {string[]} columns — requested column names
|
|
308
|
+
* @returns {string[]} columns absent from all returned records
|
|
309
|
+
*/
|
|
310
|
+
export function findOmittedColumns(records, columns) {
|
|
311
|
+
if (!Array.isArray(records) || records.length === 0 || !Array.isArray(columns) || columns.includes('*')) {
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
return columns.filter(col => col && col !== '*' && !records.some(r => r && typeof r === 'object' && col in r));
|
|
315
|
+
}
|
|
316
|
+
|
|
301
317
|
export function truncateString(str, maxLen) {
|
|
302
318
|
if (!str || str.length <= maxLen) return str;
|
|
303
319
|
return str.slice(0, maxLen - 3) + '...';
|
|
@@ -404,6 +420,7 @@ export async function interactiveList({ app, table, singular, columns, limit = 5
|
|
|
404
420
|
try {
|
|
405
421
|
totalCount = await app.sdk.aggregateCount(table, query || '');
|
|
406
422
|
} catch (err) {
|
|
423
|
+
if (isTerminalAuthError(err)) throw err;
|
|
407
424
|
countError = err;
|
|
408
425
|
}
|
|
409
426
|
if (totalCount === 0) return null; // measured empty
|
|
@@ -419,6 +436,7 @@ export async function interactiveList({ app, table, singular, columns, limit = 5
|
|
|
419
436
|
if (!Array.isArray(probe)) throw new Error('list returned a non-array result');
|
|
420
437
|
if (probe.length === 0) return null; // the list itself confirms empty
|
|
421
438
|
} catch (err) {
|
|
439
|
+
if (isTerminalAuthError(err)) throw err;
|
|
422
440
|
// Both the count and the list failed — surface the failure instead of
|
|
423
441
|
// reporting an empty result nobody measured.
|
|
424
442
|
throw new Error(
|
|
@@ -451,6 +469,7 @@ export async function interactiveList({ app, table, singular, columns, limit = 5
|
|
|
451
469
|
value: formatValue ? formatValue(r) : r,
|
|
452
470
|
}));
|
|
453
471
|
} catch (err) {
|
|
472
|
+
if (isTerminalAuthError(err)) throw err;
|
|
454
473
|
console.error('serverSource error:', err.message || err);
|
|
455
474
|
return [];
|
|
456
475
|
}
|
package/src/output.js
CHANGED
|
@@ -94,6 +94,8 @@ export class OutputWriter {
|
|
|
94
94
|
this.format = opts.format || FormatAuto;
|
|
95
95
|
this.writer = opts.writer || process.stdout;
|
|
96
96
|
this.jqFilter = opts.jqFilter || '';
|
|
97
|
+
this.verbose = opts.verbose === true;
|
|
98
|
+
this.raw = opts.raw === true;
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
getFormat() {
|
|
@@ -135,7 +137,9 @@ export class OutputWriter {
|
|
|
135
137
|
const envelope = { ok: true, data, summary: opts.summary || '', breadcrumbs: opts.breadcrumbs || [] };
|
|
136
138
|
const value = resolvePath(envelope, this.jqFilter);
|
|
137
139
|
if (value === undefined) throw errExtractionNotFound(this.jqFilter);
|
|
138
|
-
this.
|
|
140
|
+
const indent = this.verbose && !this.raw ? 2 : undefined;
|
|
141
|
+
const text = this.raw && typeof value === 'string' ? value : JSON.stringify(value, null, indent);
|
|
142
|
+
this.writer.write(text + '\n');
|
|
139
143
|
return;
|
|
140
144
|
}
|
|
141
145
|
|
|
@@ -173,7 +177,7 @@ export class OutputWriter {
|
|
|
173
177
|
switch (format) {
|
|
174
178
|
case FormatJSON:
|
|
175
179
|
case FormatQuiet:
|
|
176
|
-
this.writer.write(JSON.stringify(resp, null, 2) + '\n');
|
|
180
|
+
this.writer.write(JSON.stringify(resp, null, this.verbose ? 2 : undefined) + '\n');
|
|
177
181
|
break;
|
|
178
182
|
case FormatMarkdown:
|
|
179
183
|
this.writer.write(`**Error (${e.code})**: ${e.message}\n`);
|
|
@@ -184,7 +188,7 @@ export class OutputWriter {
|
|
|
184
188
|
this.writer.write(colorRed(`Error (${e.code}): ${e.message}\n`));
|
|
185
189
|
if (e.hint) this.writer.write(colorYellow(`Hint: ${e.hint}\n`));
|
|
186
190
|
} else {
|
|
187
|
-
this.writer.write(JSON.stringify(resp, null, 2) + '\n');
|
|
191
|
+
this.writer.write(JSON.stringify(resp, null, this.verbose ? 2 : undefined) + '\n');
|
|
188
192
|
}
|
|
189
193
|
}
|
|
190
194
|
}
|
|
@@ -217,11 +221,15 @@ export class OutputWriter {
|
|
|
217
221
|
}
|
|
218
222
|
|
|
219
223
|
writeJSON(data, opts) {
|
|
220
|
-
const resp = { ok: true, data
|
|
224
|
+
const resp = { ok: true, data };
|
|
225
|
+
if (this.verbose) {
|
|
226
|
+
resp.summary = opts.summary || '';
|
|
227
|
+
resp.breadcrumbs = opts.breadcrumbs || [];
|
|
228
|
+
}
|
|
221
229
|
if (opts.notice) resp.notice = opts.notice;
|
|
222
230
|
if (opts.context) resp.context = opts.context;
|
|
223
231
|
if (opts.meta) resp.meta = opts.meta;
|
|
224
|
-
this.writer.write(JSON.stringify(resp, null, 2) + '\n');
|
|
232
|
+
this.writer.write(JSON.stringify(resp, null, this.verbose ? 2 : undefined) + '\n');
|
|
225
233
|
}
|
|
226
234
|
|
|
227
235
|
writeQuiet(data) {
|
|
@@ -356,6 +364,12 @@ export class OutputWriter {
|
|
|
356
364
|
this.writeFormattedRecord(data, tableName);
|
|
357
365
|
}
|
|
358
366
|
|
|
367
|
+
if (Array.isArray(data.warnings) && data.warnings.length > 0 && !data._formatted) {
|
|
368
|
+
for (const w of data.warnings) {
|
|
369
|
+
this.writer.write(colorYellow(`⚠ ${w}\n`));
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
359
373
|
if (Array.isArray(data.records) && data.records.length > 0) {
|
|
360
374
|
// A _formatted visual (e.g. cmdb relationship tree) replaces the
|
|
361
375
|
// flat table in styled mode — showing both is noise.
|
package/src/prompts.js
CHANGED
|
@@ -30,6 +30,15 @@ export function cancellablePrompt(prompt) {
|
|
|
30
30
|
|
|
31
31
|
export const input = lazyPrompt('input');
|
|
32
32
|
export const password = lazyPrompt('password');
|
|
33
|
+
|
|
34
|
+
// Use the shared Escape contract and a masked prompt; codes stay ephemeral.
|
|
35
|
+
export async function mfaCode(config = {}, context = {}) {
|
|
36
|
+
return password({
|
|
37
|
+
...config, mask: '*',
|
|
38
|
+
validate: answer => /^\d{6}$/.test(String(answer ?? '').replace(/[\s-]/g, ''))
|
|
39
|
+
|| 'Enter the 6-digit code from your authenticator app.',
|
|
40
|
+
}, context);
|
|
41
|
+
}
|
|
33
42
|
export const select = lazyPrompt('select');
|
|
34
43
|
export const search = lazyPrompt('search');
|
|
35
44
|
export const confirm = lazyPrompt('confirm');
|
|
@@ -59,10 +59,14 @@ export default {
|
|
|
59
59
|
options: { singular: 'catalog UI policy', scopeValidation: true } },
|
|
60
60
|
tables: { table: 'sys_db_object', aliases: ['table', 't'], columns: ['name', 'label', 'super_class', 'create_access_controls'],
|
|
61
61
|
options: { singular: 'table', scopeValidation: true, showFields: ['name', 'label', 'super_class', 'create_access_controls', 'sys_scope', 'sys_created_on', 'sys_updated_on', 'sys_created_by', 'sys_updated_by', 'is_extendable'] } },
|
|
62
|
-
incidents: { table: 'incident', aliases: ['incident', 'inc'], columns: ['number', 'short_description', 'priority', 'state', 'assigned_to'], kind: 'ticket'
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
incidents: { table: 'incident', aliases: ['incident', 'inc'], columns: ['number', 'short_description', 'priority', 'state', 'assigned_to'], kind: 'ticket',
|
|
63
|
+
summary: 'List, show, create, or update incidents' },
|
|
64
|
+
changes: { table: 'change_request', aliases: ['change_request', 'chg'], columns: ['number', 'short_description', 'risk', 'state', 'assigned_to'], kind: 'ticket',
|
|
65
|
+
summary: 'Work with change requests' },
|
|
66
|
+
requests: { table: 'sc_req_item', aliases: ['sc_req_item', 'req'], columns: ['number', 'cat_item', 'short_description', 'stage', 'assigned_to'], kind: 'ticket',
|
|
67
|
+
summary: 'Work with requested items' },
|
|
68
|
+
tasks: { table: 'sc_task', aliases: ['sc_task', 'task'], columns: ['number', 'short_description', 'state', 'assigned_to'], kind: 'ticket',
|
|
69
|
+
summary: 'Work with catalog tasks' },
|
|
66
70
|
uipolicies: { table: 'sys_ui_policy', aliases: ['uipolicy', 'up'], columns: ['short_description', 'table', 'sys_class_name', 'active'],
|
|
67
71
|
identifierField: 'short_description', options: { singular: 'UI policy', scopeValidation: true },
|
|
68
72
|
relationships: { essential: [{ name: 'actions', table: 'sys_ui_policy_action', foreignKey: 'ui_policy', limit: 100, orderBy: 'order',
|
package/src/record-profiles.js
CHANGED
|
@@ -83,6 +83,7 @@ export function buildRecordProfile(definition, wrap, hooks = {}) {
|
|
|
83
83
|
? buildTicketCommands(profile.table, profile.name, profile.aliases.find(alias => alias !== profile.table), profile.columns, {}, null, wrap, options)
|
|
84
84
|
: buildDevCmd(profile.name, profile.table, profile.aliases, profile.columns, wrap, options);
|
|
85
85
|
command.aliases = [...profile.aliases];
|
|
86
|
+
command.summary = profile.summary || '';
|
|
86
87
|
command.recordProfile = profile;
|
|
87
88
|
command.discovery.benefits.push(
|
|
88
89
|
`Reference output: ${profile.output.references}; list projection: ${profile.output.listProjection}`,
|
package/src/records-engine.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Policy (confirmation, scope, payload and output shape) stays with callers.
|
|
3
3
|
import { resolveRecord, unwrapSysId } from './resolve-record.js';
|
|
4
4
|
import { errUsage } from './errors.js';
|
|
5
|
+
import { tableReadParams } from './table-read-params.js';
|
|
5
6
|
|
|
6
7
|
export function displayValue(mode, fallback = 'all') {
|
|
7
8
|
if (mode === undefined) return fallback;
|
|
@@ -20,7 +21,7 @@ export function recordListParams({ limit, offset, query, fields, displayValue: r
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export function listRecords(sdk, { table, params, displayValues, ...options }) {
|
|
23
|
-
const query =
|
|
24
|
+
const query = tableReadParams(params || recordListParams(options), sdk);
|
|
24
25
|
if (displayValues !== undefined) query.set('sysparm_display_value', displayValue(displayValues));
|
|
25
26
|
return sdk.list(table, query);
|
|
26
27
|
}
|