@jacebenson/jsn 5.5.11-dev.240.1 → 5.5.11-dev.242.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 +25 -0
- package/package.json +1 -1
- package/src/access-analyzer.js +92 -0
- package/src/cli-adapter.js +8 -1
- package/src/cli.js +2 -1
- package/src/command-families.js +7 -0
- package/src/commands/access-analyzer.js +37 -0
- package/src/flow-create.js +13 -4
- package/src/flow-triggers.js +65 -0
- package/src/help.js +2 -1
package/README.md
CHANGED
|
@@ -28,6 +28,31 @@ jsn --help
|
|
|
28
28
|
|
|
29
29
|
Instance reads use your selected profile; add `--profile <name>` to choose another. Documentation search needs no ServiceNow connection and uses the hosted service by default. Use `jsn <command> --help` for options or `jsn --all-commands --help` for the full reference.
|
|
30
30
|
|
|
31
|
+
## Saved Access Analyzer evidence
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
jsn access-analyzer list --limit 20 --profile <name>
|
|
35
|
+
jsn access-analyzer show <request-id> --json
|
|
36
|
+
jsn access-analyzer explain <result-id> --format styled
|
|
37
|
+
jsn access-analyzer show <request-id> --get data.request.user.value
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
These commands read saved `sn_access_analyzer_request`,
|
|
41
|
+
`sn_access_analyzer_access_result`, and `sn_access_analyzer_debug_log` records.
|
|
42
|
+
They never evaluate access or save an analysis. The Access Analyzer application
|
|
43
|
+
and read permissions on its tables are required; denied or unavailable table
|
|
44
|
+
reads fail rather than appearing as empty evidence. ACL-filtered empty reads
|
|
45
|
+
cannot prove access or absence of saved data.
|
|
46
|
+
|
|
47
|
+
IDs must be exact 32-character hexadecimal sys_ids. Each command supports
|
|
48
|
+
`--limit` (1–200) and `--offset` (default 0). JSON includes `pagination.has_more`
|
|
49
|
+
and `next_offset` from one-row lookahead, not a total count. `show` preserves
|
|
50
|
+
per-operation execution IDs; these are not shared run IDs and do not imply
|
|
51
|
+
that outcomes belong to the request's last run. `explain` orders checks by log sequence then sys_id.
|
|
52
|
+
Raw reference values and display labels are retained in JSON; joins use raw IDs.
|
|
53
|
+
Passed, Blocked, Skipped and Undefined remain distinct. A record-availability
|
|
54
|
+
failure with Business Rule evidence is not automatically an ACL failure.
|
|
55
|
+
|
|
31
56
|
## Choose output
|
|
32
57
|
|
|
33
58
|
Use the default terminal view for people, `--csv` or `--tsv` for flat rows, and `--json` when scripts need pagination, context, or errors. CSV/TSV do not fetch more pages or preserve both reference IDs and labels. Pagination notices go to stderr only when more results are explicitly known; silence does not prove completeness. JSON retains reference objects only if the command has not already flattened them. See [output details](https://jsn.jace.pro/docs/output/).
|
package/package.json
CHANGED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { errNotFound, errUsage } from './errors.js';
|
|
2
|
+
|
|
3
|
+
const REQUEST = 'sn_access_analyzer_request';
|
|
4
|
+
const RESULT = 'sn_access_analyzer_access_result';
|
|
5
|
+
const LOG = 'sn_access_analyzer_debug_log';
|
|
6
|
+
const fields = {
|
|
7
|
+
[REQUEST]: 'sys_id,analyze_by,analyzed_by,user,group,role,resource_type,target_table,target_record,target_field,target_ui_page,target_rest_endpoint,target_rest_endpoint_method,target_client_callable_script_include,operations,short_description,last_run,evaluated_using',
|
|
8
|
+
[RESULT]: 'sys_id,access_analyzer_request,analyzed_by,operation,overall_access,security_data_filter_result,acl_result,accesshandler_result,datafiltration_result,execution_time,execution_id,insights,read_only_field,script_execution,current_resource,current_resource_type,record_available',
|
|
9
|
+
[LOG]: 'sys_id,access_analyzer_request,access_result,type,path,status,roles,roles_result,condition_result,script_result,security_attribute,decision_type,record_ref,log_table_name,log_sequence,log_time,app,applies_to,is_acl_customized,script_execution,applies_to_condition_result,controlled_by_references_result,empty',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// Display labels are presentation only. Never use them as reference join keys.
|
|
13
|
+
export const rawAccessValue = value => value && typeof value === 'object' ? String(value.value ?? '') : String(value ?? '');
|
|
14
|
+
const text = value => value && typeof value === 'object' ? String(value.display_value ?? value.value ?? '') : String(value ?? '');
|
|
15
|
+
function validateId(id) {
|
|
16
|
+
if (typeof id !== 'string' || !/^[0-9a-f]{32}$/i.test(id)) throw errUsage('Provide a 32-character hexadecimal sys_id.');
|
|
17
|
+
}
|
|
18
|
+
function bounds(limit, offset) {
|
|
19
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 200) throw errUsage('--limit must be an integer from 1 to 200.');
|
|
20
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset > Number.MAX_SAFE_INTEGER - 201) throw errUsage('--offset must be a nonnegative safe integer.');
|
|
21
|
+
}
|
|
22
|
+
async function read(sdk, table, query, limit, offset = 0) {
|
|
23
|
+
const params = new URLSearchParams({ sysparm_query: query, sysparm_fields: fields[table], sysparm_limit: String(limit), sysparm_offset: String(offset), sysparm_display_value: 'all' });
|
|
24
|
+
const rows = await sdk.listStrict(table, params);
|
|
25
|
+
if (!Array.isArray(rows) || rows.some(row => !row || typeof row !== 'object' || Array.isArray(row))) {
|
|
26
|
+
throw Object.assign(new Error(`Malformed table response for ${table}`), { code: 'malformed_response' });
|
|
27
|
+
}
|
|
28
|
+
return rows;
|
|
29
|
+
}
|
|
30
|
+
async function one(sdk, table, id) {
|
|
31
|
+
const rows = await read(sdk, table, `sys_id=${id}`, 1);
|
|
32
|
+
if (!rows.length) throw errNotFound(`Saved Access Analyzer record ${id} was not found or is not readable.`);
|
|
33
|
+
if (rawAccessValue(rows[0].sys_id) !== id) throw new Error('Access Analyzer returned a different record identity.');
|
|
34
|
+
return rows[0];
|
|
35
|
+
}
|
|
36
|
+
async function page(sdk, table, query, limit, offset) {
|
|
37
|
+
const rows = await read(sdk, table, query, limit + 1, offset);
|
|
38
|
+
const hasMore = rows.length > limit;
|
|
39
|
+
return { records: rows.slice(0, limit), count: Math.min(rows.length, limit), pagination: { limit, offset, has_more: hasMore, next_offset: hasMore ? offset + limit : null } };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function listAccessAnalyses(sdk, { limit = 20, offset = 0 } = {}) {
|
|
43
|
+
bounds(limit, offset);
|
|
44
|
+
return page(sdk, REQUEST, 'ORDERBYDESClast_run^ORDERBYsys_id', limit, offset);
|
|
45
|
+
}
|
|
46
|
+
export async function showAccessAnalysis(sdk, id, { limit = 50, offset = 0 } = {}) {
|
|
47
|
+
validateId(id);
|
|
48
|
+
bounds(limit, offset);
|
|
49
|
+
const request = await one(sdk, REQUEST, id);
|
|
50
|
+
const results = await page(sdk, RESULT, `access_analyzer_request=${rawAccessValue(request.sys_id)}^ORDERBYexecution_id^ORDERBYoperation^ORDERBYsys_id`, limit, offset);
|
|
51
|
+
assertAssociation(results.records, 'access_analyzer_request', rawAccessValue(request.sys_id));
|
|
52
|
+
// execution_id identifies an operation result, not a shared analysis run.
|
|
53
|
+
return { request, ...results };
|
|
54
|
+
}
|
|
55
|
+
export async function explainAccessResult(sdk, id, { limit = 50, offset = 0 } = {}) {
|
|
56
|
+
validateId(id);
|
|
57
|
+
bounds(limit, offset);
|
|
58
|
+
const result = await one(sdk, RESULT, id);
|
|
59
|
+
const checks = await page(sdk, LOG, `access_result=${rawAccessValue(result.sys_id)}^ORDERBYlog_sequence^ORDERBYsys_id`, limit, offset);
|
|
60
|
+
assertAssociation(checks.records, 'access_result', rawAccessValue(result.sys_id));
|
|
61
|
+
const notes = ['Saved evidence only; this command does not run an access evaluation.'];
|
|
62
|
+
if (['false', 'no'].includes(rawAccessValue(result.record_available).toLowerCase())) notes.push('The target record was unavailable. Business Rule/query filtering evidence is not itself an ACL failure.');
|
|
63
|
+
return { result, ...checks, notes };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function assertAssociation(rows, field, id) {
|
|
67
|
+
if (rows.some(row => rawAccessValue(row[field]) !== id)) throw new Error(`Access Analyzer returned a mismatched ${field} association.`);
|
|
68
|
+
}
|
|
69
|
+
function requestLine(row) {
|
|
70
|
+
const identity = ['analyze_by', 'analyzed_by', 'user', 'group', 'role'].map(key => text(row[key])).filter(Boolean).join(' / ') || '(identity unavailable)';
|
|
71
|
+
const target = ['resource_type', 'target_table', 'target_record', 'target_field', 'target_ui_page', 'target_rest_endpoint', 'target_rest_endpoint_method', 'target_client_callable_script_include'].map(key => text(row[key])).filter(value => value && value !== 'undefined').join(' / ') || '(target unavailable)';
|
|
72
|
+
return `${rawAccessValue(row.sys_id)} | ${identity}\n Target: ${target}\n Last run: ${text(row.last_run) || '(unavailable)'}`;
|
|
73
|
+
}
|
|
74
|
+
function outcome(row) {
|
|
75
|
+
return `${rawAccessValue(row.sys_id)} | ${text(row.operation) || '(operation unavailable)'}: ${text(row.overall_access) || '(undefined)'} | execution ${text(row.execution_id) || '(unavailable)'}\n ACL: ${text(row.acl_result) || '(undefined)'}; security data filter: ${text(row.security_data_filter_result) || '(undefined)'}; access handler: ${text(row.accesshandler_result) || '(undefined)'}; data filtration: ${text(row.datafiltration_result) || '(undefined)'}`;
|
|
76
|
+
}
|
|
77
|
+
export function formatAccessAnalysis(data, mode) {
|
|
78
|
+
const lines = ['Saved Access Analyzer evidence (read-only)'];
|
|
79
|
+
if (mode === 'list') lines.push(...data.records.map(requestLine));
|
|
80
|
+
if (mode === 'show') lines.push(requestLine(data.request), ...data.records.map(outcome));
|
|
81
|
+
if (mode === 'explain') {
|
|
82
|
+
lines.push(outcome(data.result), ...data.notes);
|
|
83
|
+
for (const row of data.records) {
|
|
84
|
+
lines.push(`${text(row.log_sequence)}. ${text(row.type)} ${text(row.path)}: ${text(row.status) || '(undefined)'} [${rawAccessValue(row.sys_id)}]`);
|
|
85
|
+
lines.push(` Referenced rule: ${text(row.record_ref) || '(unavailable)'}; table: ${text(row.log_table_name) || '(unavailable)'}; sys_id: ${rawAccessValue(row.record_ref) || '(unavailable)'}`);
|
|
86
|
+
lines.push(` Roles: ${text(row.roles)} (${text(row.roles_result) || '(undefined)'}); condition: ${text(row.condition_result) || '(undefined)'}; script: ${text(row.script_result) || '(undefined)'}; security attribute: ${text(row.security_attribute) || '(undefined)'}; decision: ${text(row.decision_type) || '(undefined)'}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (!data.count) lines.push('No readable saved rows on this page. Empty results do not prove access or absence of ACL-filtered records.');
|
|
90
|
+
lines.push(`Page: ${data.count} rows, offset ${data.pagination.offset}${data.pagination.has_more ? `; more available, next offset ${data.pagination.next_offset}` : '; no further readable rows'}.`);
|
|
91
|
+
return lines.join('\n');
|
|
92
|
+
}
|
package/src/cli-adapter.js
CHANGED
|
@@ -105,7 +105,7 @@ class CommandNode {
|
|
|
105
105
|
positional(name, config = {}) { node.positionals.set(name, { ...config, name }); return this; },
|
|
106
106
|
demandCommand(count, message) { node.demand = { count, message }; return this; },
|
|
107
107
|
middleware(fn) { node.middlewares.push(...(Array.isArray(fn) ? fn : [fn])); return this; },
|
|
108
|
-
strict() { return this; },
|
|
108
|
+
strict() { node.strict = true; return this; },
|
|
109
109
|
check() { return this; },
|
|
110
110
|
usage(value) { node.usageText = value; return this; },
|
|
111
111
|
epilogue(value) { node.epilogueText = value; return this; },
|
|
@@ -256,6 +256,10 @@ export class LocalCLI {
|
|
|
256
256
|
catch (err) { this._fail(err.message, err); return { values: {}, positionals: [] }; }
|
|
257
257
|
const argv = { _: path.map((n) => n.name) };
|
|
258
258
|
for (const [key, value] of Object.entries(parsed.values)) {
|
|
259
|
+
if (opts.validate !== false && path.some(node => node.strict) && !Object.hasOwn(defs, key)) {
|
|
260
|
+
this._fail(`Unknown option: --${key}`);
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
259
263
|
if (opts.validate !== false && key === 'q' && !options.has('q')) {
|
|
260
264
|
this._fail('Option -q (--query) is not supported by this command.');
|
|
261
265
|
return null;
|
|
@@ -537,6 +541,9 @@ export class LocalCLI {
|
|
|
537
541
|
}
|
|
538
542
|
for (const spec of specs) if (spec.demandOption && argv[spec.name] === undefined) return this._fail(`Missing required argument: --${spec.name}`);
|
|
539
543
|
for (const pos of positions) if (pos.required && argv[pos.name] === undefined) return this._fail(`Missing required argument: ${pos.name}`);
|
|
544
|
+
if (path.some(commandNode => commandNode.strict) && positionalIndex < parsed.positionals.length) {
|
|
545
|
+
return this._fail(`Unexpected argument: ${parsed.positionals[positionalIndex]}`);
|
|
546
|
+
}
|
|
540
547
|
for (const middleware of this.middlewares) await middleware(argv);
|
|
541
548
|
for (const commandNode of path) for (const middleware of commandNode.middlewares) await middleware(argv);
|
|
542
549
|
if (node.definition.handler) await node.definition.handler(argv);
|
package/src/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flowsCmd, workflowsCmd, midserversCmd, subscriptionsCmd, customizationsCmd, skippedUpdatesCmd, docsCmd, perfCmd } from './command-families.js';
|
|
1
|
+
import { accessAnalyzerCmd, flowsCmd, workflowsCmd, midserversCmd, subscriptionsCmd, customizationsCmd, skippedUpdatesCmd, docsCmd, perfCmd } from './command-families.js';
|
|
2
2
|
import { visibleCommandRegistry } from './command-audience.js';
|
|
3
3
|
// Root CLI using the local yargs-compatible adapter
|
|
4
4
|
|
|
@@ -380,6 +380,7 @@ export function buildCLI() {
|
|
|
380
380
|
// AUTOMATION — Async
|
|
381
381
|
.command(flowsCmd(wrap))
|
|
382
382
|
.command(workflowsCmd(wrap))
|
|
383
|
+
.command(accessAnalyzerCmd(wrap))
|
|
383
384
|
.command(actionsCmd(wrap))
|
|
384
385
|
.command(scriptactionsCmd(wrap))
|
|
385
386
|
.command(scheduledjobsCmd(wrap))
|
package/src/command-families.js
CHANGED
|
@@ -8,6 +8,13 @@ import { declareCapabilities } from './capabilities.js';
|
|
|
8
8
|
// and complete-discovery API without pre-parsing argv or a generated catalog.
|
|
9
9
|
const require = createRequire(import.meta.url);
|
|
10
10
|
|
|
11
|
+
export const accessAnalyzerCmdDefinition = {
|
|
12
|
+
command: 'access-analyzer [subcommand]',
|
|
13
|
+
describe: 'Inspect saved Access Analyzer requests, outcomes and checks (read-only)',
|
|
14
|
+
};
|
|
15
|
+
declareCapabilities('access-analyzer', { queryTable: 'sn_access_analyzer_request', mutationSubcommands: [] });
|
|
16
|
+
export const accessAnalyzerCmd = wrap => ({ ...accessAnalyzerCmdDefinition, load: () => require('./commands/access-analyzer.js').accessAnalyzerCmd(wrap) });
|
|
17
|
+
|
|
11
18
|
export const flowsCmdDefinition = {
|
|
12
19
|
command: 'flows [subcommand]',
|
|
13
20
|
aliases: ['flow'],
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { accessAnalyzerCmdDefinition } from '../command-families.js';
|
|
2
|
+
import { errUsage } from '../errors.js';
|
|
3
|
+
import { listAccessAnalyses, showAccessAnalysis, explainAccessResult, formatAccessAnalysis } from '../access-analyzer.js';
|
|
4
|
+
|
|
5
|
+
export function accessAnalyzerCmd(wrap) {
|
|
6
|
+
const commands = [
|
|
7
|
+
['list', 'List saved access analyses, identities, targets and last runs', listAccessAnalyses],
|
|
8
|
+
['show <request-id>', 'Show saved operation outcomes for a request sys_id', showAccessAnalysis],
|
|
9
|
+
['explain <result-id>', 'Explain ordered saved checks for an operation result sys_id', explainAccessResult],
|
|
10
|
+
];
|
|
11
|
+
return {
|
|
12
|
+
...accessAnalyzerCmdDefinition,
|
|
13
|
+
builder: y => {
|
|
14
|
+
y = y.strict().middleware(argv => {
|
|
15
|
+
if (argv.subcommand) throw errUsage(`Unknown access-analyzer subcommand: ${argv.subcommand}`);
|
|
16
|
+
});
|
|
17
|
+
for (const [command, describe, read] of commands) {
|
|
18
|
+
const mode = command.split(' ')[0];
|
|
19
|
+
y = y.command({ command, describe,
|
|
20
|
+
builder: sub => {
|
|
21
|
+
if (mode !== 'list') sub = sub.positional(`${mode === 'show' ? 'request' : 'result'}-id`, { type: 'string', describe: 'Exact 32-character hexadecimal sys_id' });
|
|
22
|
+
return sub.option('limit', { type: 'number', default: mode === 'list' ? 20 : 50, describe: 'Page size (1–200)' })
|
|
23
|
+
.option('offset', { type: 'number', default: 0, describe: 'Nonnegative page offset' });
|
|
24
|
+
},
|
|
25
|
+
handler: wrap(async (argv, app) => {
|
|
26
|
+
app.requireInstance();
|
|
27
|
+
const options = { limit: argv.limit, offset: argv.offset };
|
|
28
|
+
const data = mode === 'list' ? await read(app.sdk, options) : await read(app.sdk, argv[mode === 'show' ? 'request-id' : 'result-id'], options);
|
|
29
|
+
Object.defineProperty(data, '_formatted', { value: formatAccessAnalysis(data, mode), enumerable: false });
|
|
30
|
+
app.ok(data, { summary: `${data.count} saved ${mode === 'list' ? 'analysis request(s)' : mode === 'show' ? 'operation result(s)' : 'check(s)'}${data.pagination.has_more ? ', more available' : ''}` });
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return y;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
package/src/flow-create.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
conditionInputFor,
|
|
13
13
|
readTableDescriptor,
|
|
14
14
|
readTriggerInputDefinitions,
|
|
15
|
+
readTriggerOutputDefinitions,
|
|
15
16
|
tableInputFor,
|
|
16
17
|
flowDesignParameter,
|
|
17
18
|
triggerFamily,
|
|
@@ -1937,10 +1938,19 @@ export async function createFlowFromManifest(sdk, instance, inputManifest, optio
|
|
|
1937
1938
|
for (const match of String(value).matchAll(/\{\{([^}]+)\}\}/g)) pills.push({ name: match[1], uiUniqueIdentifier, inputName });
|
|
1938
1939
|
};
|
|
1939
1940
|
const orderedManifest = { ...manifest, actions: manifest.actions.map((a, index) => ({ ...a, order: a.order ?? index + 1, inputs: a.inputs || {} })) };
|
|
1941
|
+
// The trigger definition is needed before the actions are planned: a manifest
|
|
1942
|
+
// that feeds a trigger output into an action input has to resolve that pill
|
|
1943
|
+
// even though the trigger instance is not inserted until the patch below.
|
|
1944
|
+
const triggerDefinition = await resolveTriggerDefinition(sdk, manifest.trigger.type);
|
|
1945
|
+
const pendingTrigger = {
|
|
1946
|
+
name: triggerDefinition.name,
|
|
1947
|
+
trigger: true,
|
|
1948
|
+
outputs: await readTriggerOutputDefinitions(sdk, triggerDefinition.sysId),
|
|
1949
|
+
};
|
|
1940
1950
|
await planManifestSteps({ manifest: orderedManifest, beforeDefinition: {}, existingActions: [], existingOrders: new Set(), actionUiMap: new Map(), logicUiMap: new Map(), pendingSteps, idFactory, sdk, instance, scope, flowId: '', actionInserts: actionInstances, actionUpdates: [], flowLogicInserts, actionTargets: new Map(), changedActionInputs: new Map(), changes: [], collectPills });
|
|
1941
1951
|
if (manifest.errorHandling !== undefined) await planErrorHandling({ sdk, instance, scope, flowId: '', beforeDefinition: {}, existingActions: [], actionInserts: actionInstances, actionUpdates: [], flowLogicInserts, flowLogicUpdates: [], changes: [], idFactory, actionUiMap: new Map(), pendingSteps, changedActionInputs: new Map(), collectPills, errorHandlingInput: manifest.errorHandling });
|
|
1942
1952
|
for (const pill of pills) {
|
|
1943
|
-
const binding = resolvePillBinding({}, pill.name, '', [], pendingSteps);
|
|
1953
|
+
const binding = resolvePillBinding({}, pill.name, '', [], [...pendingSteps, pendingTrigger]);
|
|
1944
1954
|
const previous = labelCacheInserts.find(e => e.name === pill.name);
|
|
1945
1955
|
if (previous) {
|
|
1946
1956
|
if (!previous.usedInstances.some(i => i.uiUniqueIdentifier === pill.uiUniqueIdentifier && i.inputName === pill.inputName)) previous.usedInstances.push({ uiUniqueIdentifier: pill.uiUniqueIdentifier, inputName: pill.inputName });
|
|
@@ -1971,8 +1981,7 @@ export async function createFlowFromManifest(sdk, instance, inputManifest, optio
|
|
|
1971
1981
|
// comes back empty), so the trigger is inserted by the same snFlowDesigner
|
|
1972
1982
|
// patch as the actions. There is nothing to read back from the parent apart
|
|
1973
1983
|
// from the flow identity.
|
|
1974
|
-
const
|
|
1975
|
-
const trigger = await buildCreateTrigger(sdk, flowId, manifest, definition, options);
|
|
1984
|
+
const trigger = await buildCreateTrigger(sdk, flowId, manifest, triggerDefinition, options);
|
|
1976
1985
|
|
|
1977
1986
|
for (const action of actionInstances) action.flowSysId = flowId;
|
|
1978
1987
|
for (const logic of flowLogicInserts) logic.flowSysId = flowId;
|
|
@@ -2110,7 +2119,7 @@ export function resolvePillBinding(definition, pillName, flowId, cache, pending
|
|
|
2110
2119
|
const candidates = [
|
|
2111
2120
|
...findArray(definition, 'triggerInstances').map(step => ({ ...step, trigger: true })),
|
|
2112
2121
|
...findExistingActions(definition).map(step => ({ ...step, trigger: false })),
|
|
2113
|
-
...pending.map(step => ({ ...step, trigger:
|
|
2122
|
+
...pending.map(step => ({ ...step, trigger: step.trigger === true })),
|
|
2114
2123
|
...(findArray(definition, 'flowLogicInstances') || []).filter(fl => String(fl.definitionId) === '35d60003e6022010a5e40cdd1254dd23' || String(fl.definitionId) === '35d60003e6022010a5e40cdd1254dd21').map(fl => ({
|
|
2115
2124
|
name: String(fl.definitionId) === '35d60003e6022010a5e40cdd1254dd23' ? 'Error Handler' : 'Catch',
|
|
2116
2125
|
order: stringValue(fl.order),
|
package/src/flow-triggers.js
CHANGED
|
@@ -194,6 +194,71 @@ export async function readTriggerInputDefinitions(sdk, definitionId) {
|
|
|
194
194
|
.filter(input => input.name);
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
export const TRIGGER_OUTPUT_TABLE = 'sys_hub_trigger_output';
|
|
198
|
+
export const TRIGGER_OUTPUT_NAME_PREFIX = 'var__m_sys_hub_trigger_output_';
|
|
199
|
+
|
|
200
|
+
// sys_hub_trigger_output.internal_type carries a human label ("String (Full
|
|
201
|
+
// UTF-8)", "Table Name"), while the flow graph stores the machine type in
|
|
202
|
+
// triggerInstances[].outputs[].parameter.type. Read live: the Inbound Email
|
|
203
|
+
// trigger's Body Text output is internal_type "String (Full UTF-8)" and its
|
|
204
|
+
// instance output is "string_full_utf8".
|
|
205
|
+
const OUTPUT_TYPE_BY_INTERNAL = new Map([
|
|
206
|
+
['string', 'string'],
|
|
207
|
+
['string (full utf-8)', 'string_full_utf8'],
|
|
208
|
+
['reference', 'reference'],
|
|
209
|
+
['table name', 'table_name'],
|
|
210
|
+
['document id', 'document_id'],
|
|
211
|
+
['date/time', 'glide_date_time'],
|
|
212
|
+
['date', 'glide_date'],
|
|
213
|
+
['integer', 'integer'],
|
|
214
|
+
['decimal', 'decimal'],
|
|
215
|
+
['floating point number', 'float'],
|
|
216
|
+
['true/false', 'boolean'],
|
|
217
|
+
['choice', 'choice'],
|
|
218
|
+
['glide list', 'glide_list'],
|
|
219
|
+
['glide duration', 'glide_duration'],
|
|
220
|
+
['html', 'html'],
|
|
221
|
+
['url', 'url'],
|
|
222
|
+
['email', 'email'],
|
|
223
|
+
['array.object', 'array.object'],
|
|
224
|
+
['json', 'json'],
|
|
225
|
+
]);
|
|
226
|
+
|
|
227
|
+
export function flowOutputType(internalType) {
|
|
228
|
+
const key = String(text(internalType) || '').trim().toLowerCase();
|
|
229
|
+
return OUTPUT_TYPE_BY_INTERNAL.get(key) || key.replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, '');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* The outputs a trigger definition declares, straight from
|
|
234
|
+
* sys_hub_trigger_output. Flow Designer derives a trigger instance's data pills
|
|
235
|
+
* from these, so a manifest that references `{{<trigger>_1.<output>}}` needs
|
|
236
|
+
* them before the trigger instance exists.
|
|
237
|
+
*/
|
|
238
|
+
export async function readTriggerOutputDefinitions(sdk, definitionId) {
|
|
239
|
+
if (!isSysId(definitionId)) throw new Error(`Trigger definition id must be an exact sys_id, got "${definitionId}"`);
|
|
240
|
+
const rows = await sdk.list(TRIGGER_OUTPUT_TABLE, new URLSearchParams({
|
|
241
|
+
sysparm_query: `name=${TRIGGER_OUTPUT_NAME_PREFIX}${definitionId}^ORDERBYorder`,
|
|
242
|
+
sysparm_limit: '200',
|
|
243
|
+
sysparm_display_value: 'all',
|
|
244
|
+
sysparm_fields: 'sys_id,element,label,column_label,internal_type,order,max_length,reference',
|
|
245
|
+
}));
|
|
246
|
+
return rows
|
|
247
|
+
.map(row => {
|
|
248
|
+
const name = text(row.element);
|
|
249
|
+
const parameter = {
|
|
250
|
+
id: text(row.sys_id),
|
|
251
|
+
name,
|
|
252
|
+
label: displayValue(row.label) || displayValue(row.column_label) || name,
|
|
253
|
+
type: flowOutputType(row.internal_type),
|
|
254
|
+
maxsize: numeric(row.max_length),
|
|
255
|
+
reference: text(row.reference) ? displayValue(row.reference) : '',
|
|
256
|
+
};
|
|
257
|
+
return { id: parameter.id, name, label: parameter.label, type: parameter.type, order: numeric(row.order), reference: parameter.reference, parameter };
|
|
258
|
+
})
|
|
259
|
+
.filter(output => output.name);
|
|
260
|
+
}
|
|
261
|
+
|
|
197
262
|
function normalizeTriggerInput(row) {
|
|
198
263
|
const parameter = {
|
|
199
264
|
id: text(row.sys_id),
|
package/src/help.js
CHANGED
|
@@ -93,6 +93,7 @@ const AUTOMATION_COMMANDS = [
|
|
|
93
93
|
];
|
|
94
94
|
|
|
95
95
|
const ACCESS_COMMANDS = [
|
|
96
|
+
{ name: 'access-analyzer', desc: 'Saved access analysis evidence (read-only)' },
|
|
96
97
|
{ name: 'acls', alias: 'acl', desc: 'Access controls' },
|
|
97
98
|
{ name: 'b4rules', alias: 'b4r', desc: 'Before-query business rules (see also Automation)' },
|
|
98
99
|
{ name: 'roles', alias: 'role', desc: 'Roles' },
|
|
@@ -277,7 +278,7 @@ function renderConciseHelp(config, registry, width) {
|
|
|
277
278
|
`\nCOMMON COMMANDS\n${renderRows(common.map((command) => ({ label: command.name, description: command.desc })), { width, indent: 2 })}`,
|
|
278
279
|
'',
|
|
279
280
|
'ALL COMMANDS BY GROUP',
|
|
280
|
-
...wrapText('
|
|
281
|
+
...wrapText('jsn --all-commands --help for details', { width }),
|
|
281
282
|
renderRows(groups, { width, indent: 2 }),
|
|
282
283
|
'',
|
|
283
284
|
'EXAMPLES',
|