@sonisoft/now-sdk-ext-cli 5.3.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +187 -74
- package/dist/commands/transaction/kill.d.ts +12 -0
- package/dist/commands/transaction/kill.d.ts.map +1 -0
- package/dist/commands/transaction/kill.js +48 -0
- package/dist/commands/transaction/kill.js.map +1 -0
- package/dist/commands/transaction/list.d.ts +20 -0
- package/dist/commands/transaction/list.d.ts.map +1 -0
- package/dist/commands/transaction/list.js +64 -0
- package/dist/commands/transaction/list.js.map +1 -0
- package/dist/services/transaction-display.service.d.ts +5 -0
- package/dist/services/transaction-display.service.d.ts.map +1 -0
- package/dist/services/transaction-display.service.js +33 -0
- package/dist/services/transaction-display.service.js.map +1 -0
- package/oclif.manifest.json +1019 -758
- package/package.json +4 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type KillTransactionResult } from '@sonisoft/now-sdk-ext-core';
|
|
2
|
+
import { AuthenticatedCommand } from '../../common/authenticated-command.js';
|
|
3
|
+
export default class TransactionKill extends AuthenticatedCommand<typeof TransactionKill> {
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
confirm: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
8
|
+
'transaction-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<KillTransactionResult>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=kill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kill.d.ts","sourceRoot":"","sources":["../../../src/commands/transaction/kill.ts"],"names":[],"mappings":"AACA,OAAO,EAA6C,KAAK,qBAAqB,EAAC,MAAM,4BAA4B,CAAA;AAEjH,OAAO,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAA;AAE1E,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,oBAAoB,CAAC,OAAO,eAAe,CAAC;IACvF,MAAM,CAAC,WAAW,SAGuC;IACzD,MAAM,CAAC,QAAQ,WAGd;IACD,MAAM,CAAC,KAAK;;;MAOX;IAEY,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC;CA8BnD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { ClusterTransactionManager, isPolicyRefusal } from '@sonisoft/now-sdk-ext-core';
|
|
3
|
+
import { AuthenticatedCommand } from '../../common/authenticated-command.js';
|
|
4
|
+
export default class TransactionKill extends AuthenticatedCommand {
|
|
5
|
+
static description = 'Submit a request to terminate one active transaction. Platform acceptance does not mean immediate removal.\n\n' +
|
|
6
|
+
'Only pass an identifier you deliberately selected from `nex transaction list`. ' +
|
|
7
|
+
"Killing another user's transaction aborts their work.";
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> <%= command.id %> --transaction-id 8f9a1234567890abcdef1234567890c1 --confirm --auth dev',
|
|
10
|
+
'<%= config.bin %> <%= command.id %> --transaction-id 8f9a1234567890abcdef1234567890c1 --confirm --json --auth dev',
|
|
11
|
+
];
|
|
12
|
+
static flags = {
|
|
13
|
+
confirm: Flags.boolean({ description: 'Confirm submission of the kill request.' }),
|
|
14
|
+
'transaction-id': Flags.string({
|
|
15
|
+
char: 't',
|
|
16
|
+
description: 'Exact 32-character hexadecimal sys_id from `nex transaction list`.',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
async run() {
|
|
21
|
+
const { flags } = await this.parse(TransactionKill);
|
|
22
|
+
const transactionId = flags['transaction-id'].trim();
|
|
23
|
+
if (!/^[0-9a-f]{32}$/i.test(transactionId)) {
|
|
24
|
+
this.error('--transaction-id must be exactly 32 hexadecimal characters.');
|
|
25
|
+
}
|
|
26
|
+
if (!flags.confirm) {
|
|
27
|
+
this.error('Refusing to submit a transaction kill request without --confirm.', {
|
|
28
|
+
suggestions: ['Deliberately select an identifier, then rerun this command with --confirm.'],
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const result = await new ClusterTransactionManager(this.instance).killTransaction(transactionId);
|
|
33
|
+
this._logger.info('Transaction kill request accepted.', { sysId: result.sysId });
|
|
34
|
+
if (!this.jsonEnabled()) {
|
|
35
|
+
this.log(`Kill request accepted by the platform for transaction ${result.sysId}.`);
|
|
36
|
+
this.log('The transaction may take a moment to clear. Run `nex transaction list` again to confirm.');
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
this._logger.error('Transaction kill request failed.', error);
|
|
42
|
+
if (isPolicyRefusal(error))
|
|
43
|
+
throw error;
|
|
44
|
+
this.error(error, { suggestions: ['Verify the selected transaction identifier and instance permissions.'] });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=kill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kill.js","sourceRoot":"","sources":["../../../src/commands/transaction/kill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,yBAAyB,EAAE,eAAe,EAA6B,MAAM,4BAA4B,CAAA;AAEjH,OAAO,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAA;AAE1E,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,oBAA4C;IACvF,MAAM,CAAC,WAAW,GAChB,gHAAgH;QAChH,iFAAiF;QACjF,uDAAuD,CAAA;IACzD,MAAM,CAAC,QAAQ,GAAG;QAChB,4GAA4G;QAC5G,mHAAmH;KACpH,CAAA;IACD,MAAM,CAAC,KAAK,GAAG;QACb,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,EAAC,WAAW,EAA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,CAAC,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAA;YACvC,IAAI,CAAC,KAAK,CAAC,KAAc,EAAE,EAAC,WAAW,EAAE,CAAC,sEAAsE,CAAC,EAAC,CAAC,CAAA;QACrH,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ClusterTransaction } from '@sonisoft/now-sdk-ext-core';
|
|
2
|
+
import { AuthenticatedCommand } from '../../common/authenticated-command.js';
|
|
3
|
+
type TransactionListResult = {
|
|
4
|
+
count: number;
|
|
5
|
+
transactions: ClusterTransaction[];
|
|
6
|
+
};
|
|
7
|
+
export default class TransactionList extends AuthenticatedCommand<typeof TransactionList> {
|
|
8
|
+
static description: string;
|
|
9
|
+
static examples: string[];
|
|
10
|
+
static flags: {
|
|
11
|
+
limit: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
+
'poll-interval-ms': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
|
+
query: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
|
+
'timeout-ms': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<TransactionListResult>;
|
|
17
|
+
private validateFlags;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/transaction/list.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAA;AAG1E,KAAK,qBAAqB,GAAG;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,kBAAkB,EAAE,CAAA;CAAC,CAAA;AAEhF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,oBAAoB,CAAC,OAAO,eAAe,CAAC;IACvF,MAAM,CAAC,WAAW,SAA2E;IAC7F,MAAM,CAAC,QAAQ,WAKd;IACD,MAAM,CAAC,KAAK;;;;;MAKX;IAEY,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAkClD,OAAO,CAAC,aAAa;CAatB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { ClusterTransactionManager, isPolicyRefusal, } from '@sonisoft/now-sdk-ext-core';
|
|
3
|
+
import { AuthenticatedCommand } from '../../common/authenticated-command.js';
|
|
4
|
+
import { TransactionDisplayService } from '../../services/transaction-display.service.js';
|
|
5
|
+
export default class TransactionList extends AuthenticatedCommand {
|
|
6
|
+
static description = 'List active transactions from all responding ServiceNow cluster nodes.';
|
|
7
|
+
static examples = [
|
|
8
|
+
'<%= config.bin %> <%= command.id %> --auth dev',
|
|
9
|
+
'<%= config.bin %> <%= command.id %> --json --auth dev',
|
|
10
|
+
'<%= config.bin %> <%= command.id %> --query "user=admin" --limit 50 --auth dev',
|
|
11
|
+
'<%= config.bin %> <%= command.id %> --timeout-ms 120000 --poll-interval-ms 2000 --auth dev',
|
|
12
|
+
];
|
|
13
|
+
static flags = {
|
|
14
|
+
limit: Flags.integer({ char: 'l', description: 'Maximum transactions to return. Core default: 1000.' }),
|
|
15
|
+
'poll-interval-ms': Flags.integer({ description: 'Interval between collection status polls. Core default: 1000.' }),
|
|
16
|
+
query: Flags.string({ char: 'q', description: 'Encoded query used to filter transactions. Core default: none.' }),
|
|
17
|
+
'timeout-ms': Flags.integer({ description: 'Collection timeout in milliseconds. Core default: 60000.' }),
|
|
18
|
+
};
|
|
19
|
+
async run() {
|
|
20
|
+
const { flags } = await this.parse(TransactionList);
|
|
21
|
+
this.validateFlags(flags);
|
|
22
|
+
const controller = new AbortController();
|
|
23
|
+
const onSigint = () => controller.abort();
|
|
24
|
+
process.once('SIGINT', onSigint);
|
|
25
|
+
try {
|
|
26
|
+
const options = {
|
|
27
|
+
signal: controller.signal,
|
|
28
|
+
...(flags['poll-interval-ms'] === undefined ? {} : { pollIntervalMs: flags['poll-interval-ms'] }),
|
|
29
|
+
...(flags['timeout-ms'] === undefined ? {} : { timeoutMs: flags['timeout-ms'] }),
|
|
30
|
+
...(flags.limit === undefined ? {} : { limit: flags.limit }),
|
|
31
|
+
...(flags.query === undefined ? {} : { query: flags.query }),
|
|
32
|
+
};
|
|
33
|
+
const transactions = await new ClusterTransactionManager(this.instance).getTransactions(options);
|
|
34
|
+
this._logger.info('Active transaction collection completed.', { count: transactions.length });
|
|
35
|
+
if (!this.jsonEnabled()) {
|
|
36
|
+
const display = new TransactionDisplayService();
|
|
37
|
+
for (const line of display.formatTransactions(transactions))
|
|
38
|
+
this.log(line);
|
|
39
|
+
}
|
|
40
|
+
return { count: transactions.length, transactions };
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
this._logger.error('Active transaction collection failed.', error);
|
|
44
|
+
if (isPolicyRefusal(error))
|
|
45
|
+
throw error;
|
|
46
|
+
this.error(error, { suggestions: ['Check authentication and collection timeout settings, then try again.'] });
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
process.off('SIGINT', onSigint);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
validateFlags(flags) {
|
|
53
|
+
if (flags['poll-interval-ms'] !== undefined && (!Number.isFinite(flags['poll-interval-ms']) || flags['poll-interval-ms'] < 0)) {
|
|
54
|
+
this.error('--poll-interval-ms must be a non-negative integer.');
|
|
55
|
+
}
|
|
56
|
+
if (flags['timeout-ms'] !== undefined && (!Number.isFinite(flags['timeout-ms']) || flags['timeout-ms'] < 0)) {
|
|
57
|
+
this.error('--timeout-ms must be a non-negative integer.');
|
|
58
|
+
}
|
|
59
|
+
if (flags.limit !== undefined && (!Number.isInteger(flags.limit) || flags.limit <= 0)) {
|
|
60
|
+
this.error('--limit must be a positive integer.');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/transaction/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAEL,yBAAyB,EAEzB,eAAe,GAChB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAA;AAC1E,OAAO,EAAC,yBAAyB,EAAC,MAAM,+CAA+C,CAAA;AAIvF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,oBAA4C;IACvF,MAAM,CAAC,WAAW,GAAG,wEAAwE,CAAA;IAC7F,MAAM,CAAC,QAAQ,GAAG;QAChB,gDAAgD;QAChD,uDAAuD;QACvD,gFAAgF;QAChF,4FAA4F;KAC7F,CAAA;IACD,MAAM,CAAC,KAAK,GAAG;QACb,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,qDAAqD,EAAC,CAAC;QACrG,kBAAkB,EAAE,KAAK,CAAC,OAAO,CAAC,EAAC,WAAW,EAAE,+DAA+D,EAAC,CAAC;QACjH,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,gEAAgE,EAAC,CAAC;QAC/G,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,EAAC,WAAW,EAAE,0DAA0D,EAAC,CAAC;KACvG,CAAA;IAEM,KAAK,CAAC,GAAG;QACd,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI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CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC;YACtF,IAAI,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACnD,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-display.service.d.ts","sourceRoot":"","sources":["../../src/services/transaction-display.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,4BAA4B,CAAA;AAsBlE,qBAAa,yBAAyB;IACpC,kBAAkB,CAAC,YAAY,EAAE,kBAAkB,EAAE,GAAG,MAAM,EAAE;CAejE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const columns = [
|
|
2
|
+
{ header: 'SYS_ID', key: 'sys_id', width: 32 },
|
|
3
|
+
{ header: 'NODE', key: 'node_id', width: 20 },
|
|
4
|
+
{ header: 'USER', key: 'user', width: 16 },
|
|
5
|
+
{ header: 'AGE', key: 'age', width: 10 },
|
|
6
|
+
{ header: 'STATE', key: 'state', width: 12 },
|
|
7
|
+
{ header: 'TYPE', key: 'type', width: 14 },
|
|
8
|
+
{ header: 'THREAD', key: 'thread', width: 24 },
|
|
9
|
+
];
|
|
10
|
+
function clean(value) {
|
|
11
|
+
return String(value ?? '').replaceAll(/\s+/g, ' ').trim();
|
|
12
|
+
}
|
|
13
|
+
function fit(value, width, truncate = true) {
|
|
14
|
+
const text = clean(value);
|
|
15
|
+
const fitted = truncate && text.length > width ? `${text.slice(0, width - 1)}…` : text;
|
|
16
|
+
return fitted.padEnd(width);
|
|
17
|
+
}
|
|
18
|
+
export class TransactionDisplayService {
|
|
19
|
+
formatTransactions(transactions) {
|
|
20
|
+
if (transactions.length === 0)
|
|
21
|
+
return ['No active transactions found.'];
|
|
22
|
+
const lines = [
|
|
23
|
+
`${transactions.length} active transaction${transactions.length === 1 ? '' : 's'} found.`,
|
|
24
|
+
`${columns.map(({ header, width }) => fit(header, width, false)).join(' ')} URL`,
|
|
25
|
+
];
|
|
26
|
+
for (const transaction of transactions) {
|
|
27
|
+
const cells = columns.map(({ key, width }) => fit(transaction[key], width, key !== 'sys_id'));
|
|
28
|
+
lines.push(`${cells.join(' ')} ${clean(transaction.url)}`);
|
|
29
|
+
}
|
|
30
|
+
return lines;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=transaction-display.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-display.service.js","sourceRoot":"","sources":["../../src/services/transaction-display.service.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG;IACd,EAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAC;IAC5C,EAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAC;IAC3C,EAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAC;IACxC,EAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAC;IACtC,EAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAC;IAC1C,EAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAC;IACxC,EAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAC;CACpC,CAAA;AAEV,SAAS,KAAK,CAAC,KAAc;IAC3B,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;AAC3D,CAAC;AAED,SAAS,GAAG,CAAC,KAAc,EAAE,KAAa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