@sonisoft/now-sdk-ext-core 3.3.0 → 3.5.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.
@@ -1,7 +1,7 @@
1
1
  import { HttpResponse } from './HttpResponse.js';
2
2
  import { Logger } from '../../util/Logger.js';
3
3
  import { makeRequest } from "@servicenow/sdk-cli-core/dist/http/index.js";
4
- import { DOMParser } from 'xmldom';
4
+ import { DOMParser } from '@xmldom/xmldom';
5
5
  //axios.defaults.withCredentials = true;
6
6
  export class RequestHandler {
7
7
  _logger = new Logger("RequestHandler");
@@ -1 +1 @@
1
- {"version":3,"file":"RequestHandler.js","sourceRoot":"","sources":["../../../src/comm/http/RequestHandler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK9C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAqB,MAAM,6CAA6C,CAAC;AAE7F,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,wCAAwC;AAExC,MAAM,OAAO,cAAc;IAEvB,OAAO,GAAU,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC9C,yCAAyC;IACzC,2BAA2B;IAC3B,QAAQ,CAAW;IAEnB,YAAY,CAAc;IAC1B,YAAY,CAAwB;IAEpC,QAAQ,CAAM;IAEd;;;OAGG;IACH,YAAmB,WAAkC;QACjD,sDAAsD;QACvD,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAE/B,gDAAgD;QAChD,2DAA2D;QAC3D,oCAAoC;QACpC,mCAAmC;QACnC,6BAA6B;QAC7B,2EAA2E;QAC3E,QAAQ;QAER,6CAA6C;IAEhD,CAAC;IAIK,UAAU,CAAC,OAAY;QAC1B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAED,mFAAmF;IAEnF,6CAA6C;IAC7C,4FAA4F;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58
  export * from './sn/discovery/DiscoveryModels.js';
59
59
  export * from './sn/discovery/InstanceDiscovery.js';
60
+ export * from './sn/flow/FlowManager.js';
61
+ export * from './sn/flow/FlowModels.js';
60
62
  export * from './sn/health/HealthModels.js';
61
63
  export * from './sn/health/InstanceHealth.js';
62
64
  export * from './sn/knowledge/KnowledgeManager.js';
package/dist/index.js CHANGED
@@ -57,6 +57,8 @@ export * from './sn/codesearch/CodeSearch.js';
57
57
  export * from './sn/codesearch/CodeSearchModels.js';
58
58
  export * from './sn/discovery/DiscoveryModels.js';
59
59
  export * from './sn/discovery/InstanceDiscovery.js';
60
+ export * from './sn/flow/FlowManager.js';
61
+ export * from './sn/flow/FlowModels.js';
60
62
  export * from './sn/health/HealthModels.js';
61
63
  export * from './sn/health/InstanceHealth.js';
62
64
  export * from './sn/knowledge/KnowledgeManager.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AACtD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,0CAA0C,CAAC;AACzD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B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5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,86 @@
1
+ import { ServiceNowInstance } from "../ServiceNowInstance.js";
2
+ import { BackgroundScriptExecutionResult } from "../BackgroundScriptExecutor.js";
3
+ import { ExecuteFlowOptions, ExecuteFlowByNameOptions, ExecuteSubflowOptions, ExecuteActionOptions, FlowExecutionResult, FlowScriptResultEnvelope, FlowContextStatusResult, FlowOutputsResult, FlowErrorResult, FlowCancelResult, FlowSendMessageResult, FlowPublishResult } from './FlowModels.js';
4
+ /**
5
+ * Provides operations for executing ServiceNow Flow Designer flows,
6
+ * subflows, and actions remotely via BackgroundScriptExecutor.
7
+ *
8
+ * Uses the sn_fd.FlowAPI.getRunner() (ScriptableFlowRunner) API
9
+ * on the server side to execute and capture results.
10
+ */
11
+ export declare class FlowManager {
12
+ private _logger;
13
+ private _bgExecutor;
14
+ private _instance;
15
+ private _defaultScope;
16
+ /**
17
+ * @param instance ServiceNow instance connection
18
+ * @param scope Default scope for script execution (default: "global")
19
+ */
20
+ constructor(instance: ServiceNowInstance, scope?: string);
21
+ /** Execute any flow object (flow, subflow, or action). */
22
+ execute(options: ExecuteFlowOptions): Promise<FlowExecutionResult>;
23
+ /** Execute a flow by scoped name. */
24
+ executeFlow(options: ExecuteFlowByNameOptions): Promise<FlowExecutionResult>;
25
+ /** Execute a subflow by scoped name. */
26
+ executeSubflow(options: ExecuteSubflowOptions): Promise<FlowExecutionResult>;
27
+ /** Execute an action by scoped name. */
28
+ executeAction(options: ExecuteActionOptions): Promise<FlowExecutionResult>;
29
+ /** Query the status of a flow context by its sys_id. */
30
+ getFlowContextStatus(contextId: string): Promise<FlowContextStatusResult>;
31
+ /** Retrieve outputs from a completed flow/subflow/action by context ID. */
32
+ getFlowOutputs(contextId: string): Promise<FlowOutputsResult>;
33
+ /** Retrieve error messages from a flow/subflow/action by context ID. */
34
+ getFlowError(contextId: string): Promise<FlowErrorResult>;
35
+ /** Cancel a running or paused flow/subflow/action. */
36
+ cancelFlow(contextId: string, reason?: string): Promise<FlowCancelResult>;
37
+ /** Send a message to a paused flow to resume it (for Wait for Message actions). */
38
+ sendFlowMessage(contextId: string, message: string, payload?: string): Promise<FlowSendMessageResult>;
39
+ /**
40
+ * Publish a flow so it can be executed.
41
+ * Flows deployed via the ServiceNow SDK land in an unpublished/draft state
42
+ * and must be published before they can be run.
43
+ *
44
+ * @param flowIdentifier Either a sys_id (32-char hex) or scoped_name (e.g. "x_myapp.my_flow")
45
+ * @param scope Optional scope context for BackgroundScriptExecutor
46
+ * @returns FlowPublishResult with success/failure status
47
+ */
48
+ publishFlow(flowIdentifier: string, scope?: string): Promise<FlowPublishResult>;
49
+ /**
50
+ * Resolve a flow identifier (sys_id or scoped_name) to both sys_id and name
51
+ * by querying the sys_hub_flow table.
52
+ */
53
+ private _resolveFlowIdentifier;
54
+ /** Build the ServiceNow server-side script string. */
55
+ _buildFlowScript(options: ExecuteFlowOptions): string;
56
+ /** Serialize inputs for embedding in the generated script. */
57
+ _serializeInputs(inputs: Record<string, unknown>): string;
58
+ /**
59
+ * Decode HTML entities and strip HTML tags from a string.
60
+ * ServiceNow's background script output encodes quotes as &quot;
61
+ * and appends <BR/> tags that must be removed before JSON parsing.
62
+ */
63
+ _decodeHtmlEntities(str: string): string;
64
+ /** Try to parse a line containing the result marker into a FlowScriptResultEnvelope. */
65
+ private _tryParseEnvelopeFromLine;
66
+ /** Extract the JSON envelope from script output lines. */
67
+ _extractResultEnvelope(bgResult: BackgroundScriptExecutionResult): FlowScriptResultEnvelope | null;
68
+ /** Parse BackgroundScriptExecutionResult into FlowExecutionResult. */
69
+ _parseFlowResult(bgResult: BackgroundScriptExecutionResult, options: ExecuteFlowOptions): FlowExecutionResult;
70
+ /** Validate that a context ID is non-empty. */
71
+ private _validateContextId;
72
+ /** Escape a string for embedding in a generated SN script single-quoted string. */
73
+ private _escapeForScript;
74
+ /** Build script to query sys_flow_context status. */
75
+ _buildContextStatusScript(contextId: string): string;
76
+ /** Build script to retrieve flow outputs via FlowAPI.getOutputs(). */
77
+ _buildGetOutputsScript(contextId: string): string;
78
+ /** Build script to retrieve flow error via FlowAPI.getErrorMessage(). */
79
+ _buildGetErrorScript(contextId: string): string;
80
+ /** Build script to cancel a flow via FlowAPI.cancel(). */
81
+ _buildCancelScript(contextId: string, reason: string): string;
82
+ /** Build script to publish a flow via FlowAPI.publish(). */
83
+ private _buildPublishScript;
84
+ /** Build script to send a message to a paused flow via FlowAPI.sendMessage(). */
85
+ _buildSendMessageScript(contextId: string, message: string, payload: string): string;
86
+ }
@@ -0,0 +1,687 @@
1
+ import { BackgroundScriptExecutor } from "../BackgroundScriptExecutor.js";
2
+ import { Logger } from "../../util/Logger.js";
3
+ import { TableAPIRequest } from '../../comm/http/TableAPIRequest.js';
4
+ const RESULT_MARKER = '___FLOW_EXEC_RESULT___';
5
+ const VALID_TYPES = ['flow', 'subflow', 'action'];
6
+ /**
7
+ * Provides operations for executing ServiceNow Flow Designer flows,
8
+ * subflows, and actions remotely via BackgroundScriptExecutor.
9
+ *
10
+ * Uses the sn_fd.FlowAPI.getRunner() (ScriptableFlowRunner) API
11
+ * on the server side to execute and capture results.
12
+ */
13
+ export class FlowManager {
14
+ _logger = new Logger("FlowManager");
15
+ _bgExecutor;
16
+ _instance;
17
+ _defaultScope;
18
+ /**
19
+ * @param instance ServiceNow instance connection
20
+ * @param scope Default scope for script execution (default: "global")
21
+ */
22
+ constructor(instance, scope = 'global') {
23
+ this._instance = instance;
24
+ this._defaultScope = scope;
25
+ this._bgExecutor = new BackgroundScriptExecutor(instance, scope);
26
+ }
27
+ // ================================================================
28
+ // Public API
29
+ // ================================================================
30
+ /** Execute any flow object (flow, subflow, or action). */
31
+ async execute(options) {
32
+ if (!options.scopedName || options.scopedName.trim().length === 0) {
33
+ throw new Error('Flow scoped name is required (e.g. "global.my_flow")');
34
+ }
35
+ if (!options.type) {
36
+ throw new Error('Flow object type is required ("flow", "subflow", or "action")');
37
+ }
38
+ if (!VALID_TYPES.includes(options.type)) {
39
+ throw new Error(`Invalid flow object type "${options.type}". Must be one of: ${VALID_TYPES.join(', ')}`);
40
+ }
41
+ this._logger.info(`Executing ${options.type}: ${options.scopedName}`);
42
+ const script = this._buildFlowScript(options);
43
+ const scope = options.scope || this._defaultScope;
44
+ try {
45
+ const bgResult = await this._bgExecutor.executeScript(script, scope, this._instance);
46
+ const flowResult = this._parseFlowResult(bgResult, options);
47
+ this._logger.info(`${options.type} execution complete: ${flowResult.success ? 'SUCCESS' : 'FAILED'}`);
48
+ return flowResult;
49
+ }
50
+ catch (error) {
51
+ const err = error;
52
+ this._logger.error(`Error executing ${options.type} "${options.scopedName}": ${err.message}`);
53
+ return {
54
+ success: false,
55
+ flowObjectName: options.scopedName,
56
+ flowObjectType: options.type,
57
+ errorMessage: `Script execution error: ${err.message}`,
58
+ rawScriptResult: null
59
+ };
60
+ }
61
+ }
62
+ /** Execute a flow by scoped name. */
63
+ async executeFlow(options) {
64
+ return this.execute({ ...options, type: 'flow' });
65
+ }
66
+ /** Execute a subflow by scoped name. */
67
+ async executeSubflow(options) {
68
+ return this.execute({ ...options, type: 'subflow' });
69
+ }
70
+ /** Execute an action by scoped name. */
71
+ async executeAction(options) {
72
+ return this.execute({ ...options, type: 'action' });
73
+ }
74
+ // ================================================================
75
+ // Flow Context Lifecycle API
76
+ // ================================================================
77
+ /** Query the status of a flow context by its sys_id. */
78
+ async getFlowContextStatus(contextId) {
79
+ this._validateContextId(contextId);
80
+ this._logger.info(`Getting context status: ${contextId}`);
81
+ const script = this._buildContextStatusScript(contextId);
82
+ try {
83
+ const bgResult = await this._bgExecutor.executeScript(script, this._defaultScope, this._instance);
84
+ const envelope = this._extractResultEnvelope(bgResult);
85
+ if (envelope) {
86
+ return {
87
+ success: envelope.success,
88
+ contextId,
89
+ found: envelope.found ?? false,
90
+ state: envelope.state ?? undefined,
91
+ name: envelope.name ?? undefined,
92
+ started: envelope.started ?? undefined,
93
+ ended: envelope.ended ?? undefined,
94
+ errorMessage: envelope.errorMessage ?? undefined,
95
+ rawScriptResult: bgResult
96
+ };
97
+ }
98
+ return {
99
+ success: false, contextId, found: false,
100
+ errorMessage: 'Could not parse context status result from script output.',
101
+ rawScriptResult: bgResult
102
+ };
103
+ }
104
+ catch (error) {
105
+ const err = error;
106
+ return {
107
+ success: false, contextId, found: false,
108
+ errorMessage: `Script execution error: ${err.message}`,
109
+ rawScriptResult: null
110
+ };
111
+ }
112
+ }
113
+ /** Retrieve outputs from a completed flow/subflow/action by context ID. */
114
+ async getFlowOutputs(contextId) {
115
+ this._validateContextId(contextId);
116
+ this._logger.info(`Getting outputs for context: ${contextId}`);
117
+ const script = this._buildGetOutputsScript(contextId);
118
+ try {
119
+ const bgResult = await this._bgExecutor.executeScript(script, this._defaultScope, this._instance);
120
+ const envelope = this._extractResultEnvelope(bgResult);
121
+ if (envelope) {
122
+ return {
123
+ success: envelope.success,
124
+ contextId,
125
+ outputs: envelope.outputs ?? undefined,
126
+ errorMessage: envelope.errorMessage ?? undefined,
127
+ rawScriptResult: bgResult
128
+ };
129
+ }
130
+ return {
131
+ success: false, contextId,
132
+ errorMessage: 'Could not parse outputs result from script output.',
133
+ rawScriptResult: bgResult
134
+ };
135
+ }
136
+ catch (error) {
137
+ const err = error;
138
+ return {
139
+ success: false, contextId,
140
+ errorMessage: `Script execution error: ${err.message}`,
141
+ rawScriptResult: null
142
+ };
143
+ }
144
+ }
145
+ /** Retrieve error messages from a flow/subflow/action by context ID. */
146
+ async getFlowError(contextId) {
147
+ this._validateContextId(contextId);
148
+ this._logger.info(`Getting error for context: ${contextId}`);
149
+ const script = this._buildGetErrorScript(contextId);
150
+ try {
151
+ const bgResult = await this._bgExecutor.executeScript(script, this._defaultScope, this._instance);
152
+ const envelope = this._extractResultEnvelope(bgResult);
153
+ if (envelope) {
154
+ return {
155
+ success: envelope.success,
156
+ contextId,
157
+ flowErrorMessage: envelope.flowErrorMessage ?? undefined,
158
+ errorMessage: envelope.errorMessage ?? undefined,
159
+ rawScriptResult: bgResult
160
+ };
161
+ }
162
+ return {
163
+ success: false, contextId,
164
+ errorMessage: 'Could not parse error result from script output.',
165
+ rawScriptResult: bgResult
166
+ };
167
+ }
168
+ catch (error) {
169
+ const err = error;
170
+ return {
171
+ success: false, contextId,
172
+ errorMessage: `Script execution error: ${err.message}`,
173
+ rawScriptResult: null
174
+ };
175
+ }
176
+ }
177
+ /** Cancel a running or paused flow/subflow/action. */
178
+ async cancelFlow(contextId, reason) {
179
+ this._validateContextId(contextId);
180
+ this._logger.info(`Cancelling context: ${contextId}`);
181
+ const script = this._buildCancelScript(contextId, reason || 'Cancelled via FlowManager');
182
+ try {
183
+ const bgResult = await this._bgExecutor.executeScript(script, this._defaultScope, this._instance);
184
+ const envelope = this._extractResultEnvelope(bgResult);
185
+ if (envelope) {
186
+ return {
187
+ success: envelope.success,
188
+ contextId,
189
+ errorMessage: envelope.errorMessage ?? undefined,
190
+ rawScriptResult: bgResult
191
+ };
192
+ }
193
+ return {
194
+ success: false, contextId,
195
+ errorMessage: 'Could not parse cancel result from script output.',
196
+ rawScriptResult: bgResult
197
+ };
198
+ }
199
+ catch (error) {
200
+ const err = error;
201
+ return {
202
+ success: false, contextId,
203
+ errorMessage: `Script execution error: ${err.message}`,
204
+ rawScriptResult: null
205
+ };
206
+ }
207
+ }
208
+ /** Send a message to a paused flow to resume it (for Wait for Message actions). */
209
+ async sendFlowMessage(contextId, message, payload) {
210
+ this._validateContextId(contextId);
211
+ if (!message || message.trim().length === 0) {
212
+ throw new Error('Message is required');
213
+ }
214
+ this._logger.info(`Sending message to context: ${contextId}`);
215
+ const script = this._buildSendMessageScript(contextId, message, payload || '');
216
+ try {
217
+ const bgResult = await this._bgExecutor.executeScript(script, this._defaultScope, this._instance);
218
+ const envelope = this._extractResultEnvelope(bgResult);
219
+ if (envelope) {
220
+ return {
221
+ success: envelope.success,
222
+ contextId,
223
+ errorMessage: envelope.errorMessage ?? undefined,
224
+ rawScriptResult: bgResult
225
+ };
226
+ }
227
+ return {
228
+ success: false, contextId,
229
+ errorMessage: 'Could not parse send message result from script output.',
230
+ rawScriptResult: bgResult
231
+ };
232
+ }
233
+ catch (error) {
234
+ const err = error;
235
+ return {
236
+ success: false, contextId,
237
+ errorMessage: `Script execution error: ${err.message}`,
238
+ rawScriptResult: null
239
+ };
240
+ }
241
+ }
242
+ // ================================================================
243
+ // Flow Publishing API
244
+ // ================================================================
245
+ /**
246
+ * Publish a flow so it can be executed.
247
+ * Flows deployed via the ServiceNow SDK land in an unpublished/draft state
248
+ * and must be published before they can be run.
249
+ *
250
+ * @param flowIdentifier Either a sys_id (32-char hex) or scoped_name (e.g. "x_myapp.my_flow")
251
+ * @param scope Optional scope context for BackgroundScriptExecutor
252
+ * @returns FlowPublishResult with success/failure status
253
+ */
254
+ async publishFlow(flowIdentifier, scope) {
255
+ if (!flowIdentifier || flowIdentifier.trim().length === 0) {
256
+ throw new Error('Flow identifier is required (sys_id or scoped_name)');
257
+ }
258
+ this._logger.info(`Publishing flow: ${flowIdentifier}`);
259
+ let resolved;
260
+ try {
261
+ resolved = await this._resolveFlowIdentifier(flowIdentifier);
262
+ }
263
+ catch (error) {
264
+ const err = error;
265
+ return {
266
+ success: false,
267
+ flowName: flowIdentifier,
268
+ flowSysId: '',
269
+ errorMessage: err.message
270
+ };
271
+ }
272
+ const script = this._buildPublishScript(resolved.sysId);
273
+ const execScope = scope || this._defaultScope;
274
+ try {
275
+ const bgResult = await this._bgExecutor.executeScript(script, execScope, this._instance);
276
+ const envelope = this._extractResultEnvelope(bgResult);
277
+ if (envelope) {
278
+ return {
279
+ success: envelope.success,
280
+ flowName: resolved.name,
281
+ flowSysId: resolved.sysId,
282
+ errorMessage: envelope.errorMessage ?? undefined,
283
+ rawScriptResult: bgResult
284
+ };
285
+ }
286
+ return {
287
+ success: false,
288
+ flowName: resolved.name,
289
+ flowSysId: resolved.sysId,
290
+ errorMessage: 'Could not parse publish result from script output.',
291
+ rawScriptResult: bgResult
292
+ };
293
+ }
294
+ catch (error) {
295
+ const err = error;
296
+ return {
297
+ success: false,
298
+ flowName: resolved.name,
299
+ flowSysId: resolved.sysId,
300
+ errorMessage: `Script execution error: ${err.message}`
301
+ };
302
+ }
303
+ }
304
+ /**
305
+ * Resolve a flow identifier (sys_id or scoped_name) to both sys_id and name
306
+ * by querying the sys_hub_flow table.
307
+ */
308
+ async _resolveFlowIdentifier(identifier) {
309
+ const trimmed = identifier.trim();
310
+ const isSysId = /^[0-9a-f]{32}$/i.test(trimmed);
311
+ // Validate scoped name format to prevent query injection via ^ or other GlideRecord operators
312
+ if (!isSysId && !/^[a-zA-Z0-9_]+\.[a-zA-Z0-9_]+$/.test(trimmed)) {
313
+ throw new Error(`Invalid flow identifier format: "${trimmed}". Expected a 32-char hex sys_id or scoped name (e.g. "global.my_flow").`);
314
+ }
315
+ const tableRequest = new TableAPIRequest(this._instance);
316
+ const queryField = isSysId ? 'sys_id' : 'internal_name';
317
+ const response = await tableRequest.get('sys_hub_flow', {
318
+ sysparm_query: `${queryField}=${trimmed}`,
319
+ sysparm_fields: 'sys_id,internal_name,name',
320
+ sysparm_limit: '1'
321
+ });
322
+ // TableAPIRequest may return the result array under data.result (Axios-style)
323
+ // or bodyObject.result (RequestHandler-style) depending on the HTTP layer used.
324
+ const records = response?.data?.result ?? response?.bodyObject?.result;
325
+ if (!records || records.length === 0) {
326
+ throw new Error(`Flow not found: no sys_hub_flow record matches ${queryField}="${trimmed}"`);
327
+ }
328
+ const record = records[0];
329
+ return {
330
+ sysId: record.sys_id,
331
+ name: record.internal_name || record.name || trimmed
332
+ };
333
+ }
334
+ // ================================================================
335
+ // Internal Methods
336
+ // ================================================================
337
+ /** Build the ServiceNow server-side script string. */
338
+ _buildFlowScript(options) {
339
+ const mode = options.mode || 'foreground';
340
+ const modeMethod = mode === 'background' ? 'inBackground' : 'inForeground';
341
+ const inputsJson = options.inputs ? this._serializeInputs(options.inputs) : '{}';
342
+ const scopedName = options.scopedName.replace(/'/g, "\\'");
343
+ const type = options.type;
344
+ let optionalChain = '';
345
+ if (options.timeout !== undefined && options.timeout !== null) {
346
+ optionalChain += `\n .timeout(${options.timeout})`;
347
+ }
348
+ if (options.quick === true) {
349
+ optionalChain += `\n .quick()`;
350
+ }
351
+ const hasInputs = options.inputs && Object.keys(options.inputs).length > 0;
352
+ const inputsChain = hasInputs ? `\n .withInputs(inputs)` : '';
353
+ return `(function() {
354
+ var __RESULT_MARKER = '${RESULT_MARKER}';
355
+ try {
356
+ var inputs = ${inputsJson};
357
+
358
+ var result = sn_fd.FlowAPI.getRunner()
359
+ .${type}('${scopedName}')
360
+ .${modeMethod}()${optionalChain}${inputsChain}
361
+ .run();
362
+
363
+ var envelope = {
364
+ __flowResult: true,
365
+ success: true,
366
+ flowObjectName: '' + result.getFlowObjectName(),
367
+ flowObjectType: '' + result.getFlowObjectType(),
368
+ contextId: result.getContextId() ? '' + result.getContextId() : null,
369
+ executionDate: result.getDate() ? '' + result.getDate() : null,
370
+ domainId: result.getDomainId() ? '' + result.getDomainId() : null,
371
+ outputs: null,
372
+ debugOutput: '' + result.debug(),
373
+ errorMessage: null
374
+ };
375
+
376
+ try {
377
+ var rawOutputs = result.getOutputs();
378
+ if (rawOutputs) {
379
+ var outputObj = {};
380
+ for (var key in rawOutputs) {
381
+ if (rawOutputs.hasOwnProperty(key)) {
382
+ outputObj[key] = '' + rawOutputs[key];
383
+ }
384
+ }
385
+ envelope.outputs = outputObj;
386
+ }
387
+ } catch (outErr) {
388
+ envelope.outputs = null;
389
+ }
390
+
391
+ gs.info(__RESULT_MARKER + JSON.stringify(envelope));
392
+ } catch (ex) {
393
+ var errorEnvelope = {
394
+ __flowResult: true,
395
+ success: false,
396
+ flowObjectName: '${scopedName}',
397
+ flowObjectType: '${type}',
398
+ contextId: null,
399
+ executionDate: null,
400
+ domainId: null,
401
+ outputs: null,
402
+ debugOutput: '',
403
+ errorMessage: '' + (ex.getMessage ? ex.getMessage() : ex)
404
+ };
405
+ gs.info(__RESULT_MARKER + JSON.stringify(errorEnvelope));
406
+ }
407
+ })();`;
408
+ }
409
+ /** Serialize inputs for embedding in the generated script. */
410
+ _serializeInputs(inputs) {
411
+ const cleanInputs = {};
412
+ for (const [key, value] of Object.entries(inputs)) {
413
+ if (value !== undefined) {
414
+ cleanInputs[key] = value;
415
+ }
416
+ }
417
+ return JSON.stringify(cleanInputs);
418
+ }
419
+ /**
420
+ * Decode HTML entities and strip HTML tags from a string.
421
+ * ServiceNow's background script output encodes quotes as &quot;
422
+ * and appends <BR/> tags that must be removed before JSON parsing.
423
+ */
424
+ _decodeHtmlEntities(str) {
425
+ return str
426
+ .replace(/<BR\s*\/?>/gi, '')
427
+ .replace(/&quot;/g, '"')
428
+ .replace(/&amp;/g, '&')
429
+ .replace(/&lt;/g, '<')
430
+ .replace(/&gt;/g, '>')
431
+ .replace(/&#39;/g, "'")
432
+ .replace(/&apos;/g, "'")
433
+ .trim();
434
+ }
435
+ /** Try to parse a line containing the result marker into a FlowScriptResultEnvelope. */
436
+ _tryParseEnvelopeFromLine(line) {
437
+ if (!line || !line.includes(RESULT_MARKER)) {
438
+ return null;
439
+ }
440
+ const afterMarker = line.substring(line.indexOf(RESULT_MARKER) + RESULT_MARKER.length);
441
+ const jsonStr = this._decodeHtmlEntities(afterMarker);
442
+ try {
443
+ const parsed = JSON.parse(jsonStr);
444
+ if (parsed && parsed.__flowResult === true) {
445
+ return parsed;
446
+ }
447
+ }
448
+ catch {
449
+ this._logger.warn(`Failed to parse flow result JSON: ${jsonStr.substring(0, 200)}`);
450
+ }
451
+ return null;
452
+ }
453
+ /** Extract the JSON envelope from script output lines. */
454
+ _extractResultEnvelope(bgResult) {
455
+ // Search through scriptResults for our marker line
456
+ if (bgResult.scriptResults && bgResult.scriptResults.length > 0) {
457
+ for (const outputLine of bgResult.scriptResults) {
458
+ const envelope = this._tryParseEnvelopeFromLine(outputLine.line);
459
+ if (envelope)
460
+ return envelope;
461
+ }
462
+ }
463
+ // Fallback: search through consoleResult string array
464
+ if (bgResult.consoleResult && bgResult.consoleResult.length > 0) {
465
+ for (const line of bgResult.consoleResult) {
466
+ const envelope = this._tryParseEnvelopeFromLine(line);
467
+ if (envelope)
468
+ return envelope;
469
+ }
470
+ }
471
+ return null;
472
+ }
473
+ /** Parse BackgroundScriptExecutionResult into FlowExecutionResult. */
474
+ _parseFlowResult(bgResult, options) {
475
+ const envelope = this._extractResultEnvelope(bgResult);
476
+ if (envelope) {
477
+ return {
478
+ success: envelope.success,
479
+ flowObjectName: envelope.flowObjectName || options.scopedName,
480
+ flowObjectType: envelope.flowObjectType || options.type,
481
+ contextId: envelope.contextId || undefined,
482
+ executionDate: envelope.executionDate || undefined,
483
+ domainId: envelope.domainId || undefined,
484
+ outputs: envelope.outputs || undefined,
485
+ debugOutput: envelope.debugOutput || undefined,
486
+ errorMessage: envelope.errorMessage || undefined,
487
+ rawScriptResult: bgResult
488
+ };
489
+ }
490
+ this._logger.warn('Could not extract flow result envelope from script output');
491
+ return {
492
+ success: false,
493
+ flowObjectName: options.scopedName,
494
+ flowObjectType: options.type,
495
+ errorMessage: 'Could not parse flow execution result from script output. ' +
496
+ 'The script may have failed before producing output.',
497
+ rawScriptResult: bgResult
498
+ };
499
+ }
500
+ // ================================================================
501
+ // Lifecycle Script Builders
502
+ // ================================================================
503
+ /** Validate that a context ID is non-empty. */
504
+ _validateContextId(contextId) {
505
+ if (!contextId || contextId.trim().length === 0) {
506
+ throw new Error('Context ID is required');
507
+ }
508
+ }
509
+ /** Escape a string for embedding in a generated SN script single-quoted string. */
510
+ _escapeForScript(str) {
511
+ return str.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
512
+ }
513
+ /** Build script to query sys_flow_context status. */
514
+ _buildContextStatusScript(contextId) {
515
+ const escapedId = this._escapeForScript(contextId);
516
+ return `(function() {
517
+ var __RESULT_MARKER = '${RESULT_MARKER}';
518
+ try {
519
+ var gr = new GlideRecord('sys_flow_context');
520
+ if (gr.get('${escapedId}')) {
521
+ gs.info(__RESULT_MARKER + JSON.stringify({
522
+ __flowResult: true,
523
+ success: true,
524
+ contextId: '${escapedId}',
525
+ found: true,
526
+ state: '' + gr.getValue('state'),
527
+ name: '' + gr.getValue('name'),
528
+ started: gr.getValue('started') ? '' + gr.getValue('started') : null,
529
+ ended: gr.getValue('ended') ? '' + gr.getValue('ended') : null,
530
+ errorMessage: null
531
+ }));
532
+ } else {
533
+ gs.info(__RESULT_MARKER + JSON.stringify({
534
+ __flowResult: true,
535
+ success: true,
536
+ contextId: '${escapedId}',
537
+ found: false,
538
+ state: null,
539
+ name: null,
540
+ started: null,
541
+ ended: null,
542
+ errorMessage: null
543
+ }));
544
+ }
545
+ } catch (ex) {
546
+ gs.info(__RESULT_MARKER + JSON.stringify({
547
+ __flowResult: true,
548
+ success: false,
549
+ contextId: '${escapedId}',
550
+ found: false,
551
+ errorMessage: '' + (ex.getMessage ? ex.getMessage() : ex)
552
+ }));
553
+ }
554
+ })();`;
555
+ }
556
+ /** Build script to retrieve flow outputs via FlowAPI.getOutputs(). */
557
+ _buildGetOutputsScript(contextId) {
558
+ const escapedId = this._escapeForScript(contextId);
559
+ return `(function() {
560
+ var __RESULT_MARKER = '${RESULT_MARKER}';
561
+ try {
562
+ var outputs = sn_fd.FlowAPI.getOutputs('${escapedId}');
563
+ var outputObj = {};
564
+ if (outputs) {
565
+ for (var key in outputs) {
566
+ if (outputs.hasOwnProperty(key)) {
567
+ outputObj[key] = '' + outputs[key];
568
+ }
569
+ }
570
+ }
571
+ gs.info(__RESULT_MARKER + JSON.stringify({
572
+ __flowResult: true,
573
+ success: true,
574
+ contextId: '${escapedId}',
575
+ outputs: outputObj,
576
+ errorMessage: null
577
+ }));
578
+ } catch (ex) {
579
+ gs.info(__RESULT_MARKER + JSON.stringify({
580
+ __flowResult: true,
581
+ success: false,
582
+ contextId: '${escapedId}',
583
+ outputs: null,
584
+ errorMessage: '' + (ex.getMessage ? ex.getMessage() : ex)
585
+ }));
586
+ }
587
+ })();`;
588
+ }
589
+ /** Build script to retrieve flow error via FlowAPI.getErrorMessage(). */
590
+ _buildGetErrorScript(contextId) {
591
+ const escapedId = this._escapeForScript(contextId);
592
+ return `(function() {
593
+ var __RESULT_MARKER = '${RESULT_MARKER}';
594
+ try {
595
+ var errorMsg = sn_fd.FlowAPI.getErrorMessage('${escapedId}');
596
+ gs.info(__RESULT_MARKER + JSON.stringify({
597
+ __flowResult: true,
598
+ success: true,
599
+ contextId: '${escapedId}',
600
+ flowErrorMessage: errorMsg ? '' + errorMsg : null,
601
+ errorMessage: null
602
+ }));
603
+ } catch (ex) {
604
+ gs.info(__RESULT_MARKER + JSON.stringify({
605
+ __flowResult: true,
606
+ success: false,
607
+ contextId: '${escapedId}',
608
+ flowErrorMessage: null,
609
+ errorMessage: '' + (ex.getMessage ? ex.getMessage() : ex)
610
+ }));
611
+ }
612
+ })();`;
613
+ }
614
+ /** Build script to cancel a flow via FlowAPI.cancel(). */
615
+ _buildCancelScript(contextId, reason) {
616
+ const escapedId = this._escapeForScript(contextId);
617
+ const escapedReason = this._escapeForScript(reason);
618
+ return `(function() {
619
+ var __RESULT_MARKER = '${RESULT_MARKER}';
620
+ try {
621
+ sn_fd.FlowAPI.cancel('${escapedId}', '${escapedReason}');
622
+ gs.info(__RESULT_MARKER + JSON.stringify({
623
+ __flowResult: true,
624
+ success: true,
625
+ contextId: '${escapedId}',
626
+ errorMessage: null
627
+ }));
628
+ } catch (ex) {
629
+ gs.info(__RESULT_MARKER + JSON.stringify({
630
+ __flowResult: true,
631
+ success: false,
632
+ contextId: '${escapedId}',
633
+ errorMessage: '' + (ex.getMessage ? ex.getMessage() : ex)
634
+ }));
635
+ }
636
+ })();`;
637
+ }
638
+ /** Build script to publish a flow via FlowAPI.publish(). */
639
+ _buildPublishScript(flowSysId) {
640
+ const escapedId = this._escapeForScript(flowSysId);
641
+ return `(function() {
642
+ var __RESULT_MARKER = '${RESULT_MARKER}';
643
+ try {
644
+ sn_fd.FlowAPI.publish('${escapedId}');
645
+ gs.info(__RESULT_MARKER + JSON.stringify({
646
+ __flowResult: true,
647
+ success: true,
648
+ flowSysId: '${escapedId}',
649
+ errorMessage: null
650
+ }));
651
+ } catch (ex) {
652
+ gs.info(__RESULT_MARKER + JSON.stringify({
653
+ __flowResult: true,
654
+ success: false,
655
+ flowSysId: '${escapedId}',
656
+ errorMessage: '' + (ex.getMessage ? ex.getMessage() : ex)
657
+ }));
658
+ }
659
+ })();`;
660
+ }
661
+ /** Build script to send a message to a paused flow via FlowAPI.sendMessage(). */
662
+ _buildSendMessageScript(contextId, message, payload) {
663
+ const escapedId = this._escapeForScript(contextId);
664
+ const escapedMessage = this._escapeForScript(message);
665
+ const escapedPayload = this._escapeForScript(payload);
666
+ return `(function() {
667
+ var __RESULT_MARKER = '${RESULT_MARKER}';
668
+ try {
669
+ sn_fd.FlowAPI.sendMessage('${escapedId}', '${escapedMessage}', '${escapedPayload}');
670
+ gs.info(__RESULT_MARKER + JSON.stringify({
671
+ __flowResult: true,
672
+ success: true,
673
+ contextId: '${escapedId}',
674
+ errorMessage: null
675
+ }));
676
+ } catch (ex) {
677
+ gs.info(__RESULT_MARKER + JSON.stringify({
678
+ __flowResult: true,
679
+ success: false,
680
+ contextId: '${escapedId}',
681
+ errorMessage: '' + (ex.getMessage ? ex.getMessage() : ex)
682
+ }));
683
+ }
684
+ })();`;
685
+ }
686
+ }
687
+ //# sourceMappingURL=FlowManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowManager.js","sourceRoot":"","sources":["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C,MAAM,CAAC,CAAC;QACpD,OAAO;6BACc,aAAa;;gCAEV,SAAS,OAAO,aAAa;;;;0BAInC,SAAS;;;;;;;0BAOT,SAAS;;;;MAI7B,CAAC;IACH,CAAC;IAED,4DAA4D;IACpD,mBAAmB,CAAC,SAAiB;QACzC,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACnD,OAAO;6BACc,aAAa;;iCAET,SAAS;;;;0BAIhB,SAAS;;;;;;;0BAOT,SAAS;;;;MAI7B,CAAC;IACH,CAAC;IAED,iFAAiF;IACjF,uBAAuB,CAAC,SAAiB,EAAE,OAAe,EAAE,OAAe;QACvE,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACnD,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACtD,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACtD,OAAO;6BACc,aAAa;;qCAEL,SAAS,OAAO,cAAc,OAAO,cAAc;;;;0BAI9D,SAAS;;;;;;;0BAOT,SAAS;;;;MAI7B,CAAC;IACH,CAAC;CACJ"}
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Models for Flow Designer execution operations.
3
+ * Supports executing flows, subflows, and actions via BackgroundScriptExecutor
4
+ * using the sn_fd.FlowAPI.getRunner() (ScriptableFlowRunner) API.
5
+ */
6
+ /** Type of Flow Designer object to execute. */
7
+ export type FlowObjectType = 'flow' | 'subflow' | 'action';
8
+ /** Execution mode: synchronous (foreground) or asynchronous (background). */
9
+ export type FlowExecutionMode = 'foreground' | 'background';
10
+ /** Options for executing a Flow Designer object (flow, subflow, or action). */
11
+ export interface ExecuteFlowOptions {
12
+ /** Scoped name of the flow/subflow/action, e.g. "global.my_flow" */
13
+ scopedName: string;
14
+ /** Type of object to execute */
15
+ type: FlowObjectType;
16
+ /** Input name-value pairs to pass to the flow/subflow/action */
17
+ inputs?: Record<string, unknown>;
18
+ /**
19
+ * Execution mode: 'foreground' (sync) or 'background' (async).
20
+ * Default: 'foreground'
21
+ */
22
+ mode?: FlowExecutionMode;
23
+ /** Timeout in milliseconds (optional, SN default is 30s) */
24
+ timeout?: number;
25
+ /**
26
+ * Quick mode: skip execution detail records for better performance.
27
+ * Default: false
28
+ */
29
+ quick?: boolean;
30
+ /**
31
+ * Scope context for BackgroundScriptExecutor.
32
+ * Can be a scope name ("global", "x_myapp_custom") or a 32-character sys_id.
33
+ * Default: uses the FlowManager's default scope.
34
+ */
35
+ scope?: string;
36
+ }
37
+ /** Convenience options for executing a flow (type is implied). */
38
+ export interface ExecuteFlowByNameOptions extends Omit<ExecuteFlowOptions, 'type'> {
39
+ }
40
+ /** Convenience options for executing a subflow (type is implied). */
41
+ export interface ExecuteSubflowOptions extends Omit<ExecuteFlowOptions, 'type'> {
42
+ }
43
+ /** Convenience options for executing an action (type is implied). */
44
+ export interface ExecuteActionOptions extends Omit<ExecuteFlowOptions, 'type'> {
45
+ }
46
+ /** Structured result from executing a flow/subflow/action. */
47
+ export interface FlowExecutionResult {
48
+ /** Whether the execution completed without error */
49
+ success: boolean;
50
+ /** The scoped name of the executed flow object, e.g. "global.my_flow" */
51
+ flowObjectName: string;
52
+ /** Type of flow object that was executed */
53
+ flowObjectType: FlowObjectType;
54
+ /** sys_id of the execution context record (if not quick mode) */
55
+ contextId?: string;
56
+ /** Execution date/time as a string from the SN server */
57
+ executionDate?: string;
58
+ /** Domain sys_id (for domain-separated instances) */
59
+ domainId?: string;
60
+ /** Output name-value pairs returned by the flow/subflow/action */
61
+ outputs?: Record<string, unknown>;
62
+ /** Raw debug() output from ScriptableFlowRunnerResult */
63
+ debugOutput?: string;
64
+ /** Error message if execution failed */
65
+ errorMessage?: string;
66
+ /** The raw BackgroundScriptExecutionResult for advanced inspection */
67
+ rawScriptResult?: unknown;
68
+ }
69
+ /**
70
+ * JSON envelope structure used for communication between
71
+ * the generated SN server-side script and the FlowManager parser.
72
+ * @internal
73
+ */
74
+ export interface FlowScriptResultEnvelope {
75
+ __flowResult: true;
76
+ success: boolean;
77
+ flowObjectName: string;
78
+ flowObjectType: string;
79
+ contextId: string | null;
80
+ executionDate: string | null;
81
+ domainId: string | null;
82
+ outputs: Record<string, unknown> | null;
83
+ debugOutput: string;
84
+ errorMessage: string | null;
85
+ }
86
+ /** Known states of a flow context record in sys_flow_context. */
87
+ export type FlowContextState = 'QUEUED' | 'IN_PROGRESS' | 'WAITING' | 'COMPLETE' | 'CANCELLED' | 'ERROR' | string;
88
+ /** Result from querying a flow context's status. */
89
+ export interface FlowContextStatusResult {
90
+ success: boolean;
91
+ contextId: string;
92
+ found: boolean;
93
+ state?: FlowContextState;
94
+ name?: string;
95
+ started?: string;
96
+ ended?: string;
97
+ errorMessage?: string;
98
+ rawScriptResult?: unknown;
99
+ }
100
+ /** Result from retrieving outputs of a completed flow context. */
101
+ export interface FlowOutputsResult {
102
+ success: boolean;
103
+ contextId: string;
104
+ outputs?: Record<string, unknown>;
105
+ errorMessage?: string;
106
+ rawScriptResult?: unknown;
107
+ }
108
+ /** Result from retrieving error messages of a flow context. */
109
+ export interface FlowErrorResult {
110
+ success: boolean;
111
+ contextId: string;
112
+ flowErrorMessage?: string;
113
+ errorMessage?: string;
114
+ rawScriptResult?: unknown;
115
+ }
116
+ /** Result from cancelling a flow context. */
117
+ export interface FlowCancelResult {
118
+ success: boolean;
119
+ contextId: string;
120
+ errorMessage?: string;
121
+ rawScriptResult?: unknown;
122
+ }
123
+ /** Result from sending a message to a paused flow. */
124
+ export interface FlowSendMessageResult {
125
+ success: boolean;
126
+ contextId: string;
127
+ errorMessage?: string;
128
+ rawScriptResult?: unknown;
129
+ }
130
+ /** Result from publishing a flow. */
131
+ export interface FlowPublishResult {
132
+ /** Whether the publish operation completed without error */
133
+ success: boolean;
134
+ /** Display name or scoped name of the flow */
135
+ flowName: string;
136
+ /** sys_id of the published flow */
137
+ flowSysId: string;
138
+ /** Error message if publish failed */
139
+ errorMessage?: string;
140
+ /** The raw BackgroundScriptExecutionResult for advanced inspection */
141
+ rawScriptResult?: unknown;
142
+ }
143
+ /**
144
+ * Resolved flow identifier containing both sys_id and name.
145
+ * @internal Used by FlowManager._resolveFlowIdentifier()
146
+ */
147
+ export interface ResolvedFlowIdentifier {
148
+ sysId: string;
149
+ name: string;
150
+ }
151
+ /**
152
+ * JSON envelope for lifecycle operations (status, outputs, errors, cancel, message).
153
+ * @internal
154
+ */
155
+ export interface FlowLifecycleEnvelope {
156
+ __flowResult: true;
157
+ success: boolean;
158
+ contextId: string;
159
+ errorMessage: string | null;
160
+ found?: boolean;
161
+ state?: string | null;
162
+ name?: string | null;
163
+ started?: string | null;
164
+ ended?: string | null;
165
+ outputs?: Record<string, unknown> | null;
166
+ flowErrorMessage?: string | null;
167
+ }
168
+ /**
169
+ * JSON envelope emitted by the publish script.
170
+ * Uses flowSysId (not contextId) since publish operates on a flow record, not an execution context.
171
+ * @internal
172
+ */
173
+ export interface FlowPublishEnvelope {
174
+ __flowResult: true;
175
+ success: boolean;
176
+ flowSysId: string;
177
+ errorMessage: string | null;
178
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Models for Flow Designer execution operations.
3
+ * Supports executing flows, subflows, and actions via BackgroundScriptExecutor
4
+ * using the sn_fd.FlowAPI.getRunner() (ScriptableFlowRunner) API.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=FlowModels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowModels.js","sourceRoot":"","sources":["../../../src/sn/flow/FlowModels.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonisoft/now-sdk-ext-core",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "Comprehensive TypeScript library extending ServiceNow SDK with application management, ATF testing, real-time log monitoring, AMB event subscriptions, and automation tools",
5
5
  "keywords": [
6
6
  "servicenow",
@@ -38,7 +38,7 @@
38
38
  "semantic-release": "semantic-release",
39
39
  "test": "node --experimental-vm-modules node_modules/.bin/jest --forceExit --coverage --collectCoverage --coverageDirectory=\"./coverage\" --ci --reporters=default --reporters=jest-junit --watchAll=false --testPathIgnorePatterns=\"/integration/\"",
40
40
  "test:unit": "node --experimental-vm-modules node_modules/.bin/jest --forceExit --coverage --collectCoverage --coverageDirectory=\"./coverage\" --ci --reporters=default --reporters=jest-junit --watchAll=false --testPathIgnorePatterns=\"/integration/\"",
41
- "test:integration": "node --experimental-vm-modules node_modules/.bin/jest --forceExit --testPathPattern=\"/integration/\" --watchAll=false --testTimeout=120000",
41
+ "test:integration": "node --experimental-vm-modules node_modules/.bin/jest --forceExit --testPathPatterns=\"/integration/\" --watchAll=false --testTimeout=120000",
42
42
  "test:all": "node --experimental-vm-modules node_modules/.bin/jest --forceExit --coverage --collectCoverage --coverageDirectory=\"./coverage\" --ci --reporters=default --reporters=jest-junit --watchAll=false",
43
43
  "watch-debug": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-sass\" \"npm run watch-ts\" \"npm run serve-debug\"",
44
44
  "watch-test": "npm run test:unit -- --watchAll",
@@ -65,62 +65,62 @@
65
65
  "@ts-morph/common": "^0.24.0",
66
66
  "@types/mock-fs": "^4.13.4",
67
67
  "@types/node-gzip": "^1.1.3",
68
- "async": "3.2.5",
69
- "axios": "^1.7.2",
68
+ "async": "3.2.6",
69
+ "axios": "^1.8.0",
70
70
  "bcrypt-nodejs": "0.0.3",
71
71
  "bluebird": "3.7.2",
72
- "body-parser": "1.20.2",
73
- "cometd": "^8.0.4",
72
+ "body-parser": "^1.20.4",
73
+ "cometd": "^9.0.0",
74
74
  "cometd-nodejs-client": "^2.0.0",
75
- "compression": "1.7.4",
75
+ "compression": "^1.8.0",
76
76
  "crypto": "^1.0.1",
77
77
  "crypto-js": "4.2.0",
78
78
  "dotenv": "16.4.5",
79
- "errorhandler": "1.5.1",
80
- "fast-xml-parser": "^4.4.1",
79
+ "errorhandler": "1.5.2",
80
+ "fast-xml-parser": "^4.5.4",
81
81
  "fs-extra": "*",
82
82
  "get-installed-path": "^4.0.8",
83
83
  "jsdom": "^24.1.1",
84
84
  "json5": "^2.2.3",
85
- "lodash": "^4.17.21",
85
+ "lodash": "^4.17.23",
86
86
  "lusca": "1.7.0",
87
87
  "node-fetch": "^3.3.2",
88
88
  "node-gzip": "1.1.2",
89
- "qs": "^6.12.2",
90
- "ts-morph": "^23.0.0",
89
+ "qs": "^6.15.0",
90
+ "ts-morph": "^27.0.2",
91
91
  "typed-config": "^1.0.0",
92
92
  "winston": "3.14.2",
93
93
  "ws": "^8.18.0",
94
94
  "xml2js": "^0.6.2",
95
- "xmldom": "^0.6.0",
95
+ "@xmldom/xmldom": "^0.8.10",
96
96
  "zod": "^3.23.8"
97
97
  },
98
98
  "devDependencies": {
99
99
  "@eslint/js": "^9.10.0",
100
100
  "@semantic-release/git": "^10.0.1",
101
- "@semantic-release/gitlab": "^13.2.9",
102
- "@semantic-release/npm": "^12.0.1",
103
- "@types/async": "3.2.24",
101
+ "@semantic-release/github": "^11.0.1",
102
+ "@semantic-release/npm": "^13.0.0",
103
+ "@types/async": "3.2.25",
104
104
  "@types/bcrypt-nodejs": "0.0.31",
105
105
  "@types/bluebird": "3.5.42",
106
106
  "@types/body-parser": "1.19.5",
107
107
  "@types/chai": "4.3.17",
108
- "@types/compression": "1.7.5",
108
+ "@types/compression": "1.8.1",
109
109
  "@types/crypto-js": "^4.2.2",
110
110
  "@types/errorhandler": "1.5.3",
111
111
  "@types/eslint": "9.6.0",
112
112
  "@types/eslint__js": "^8.42.3",
113
113
  "@types/fs-extra": "^11.0.4",
114
- "@types/jest": "^29.5.14",
114
+ "@types/jest": "^30.0.0",
115
115
  "@types/jquery": "3.5.30",
116
116
  "@types/lodash": "^4.17.7",
117
117
  "@types/lusca": "1.7.5",
118
118
  "@types/node": "^22.3",
119
- "@types/request": "2.48.12",
119
+ "@types/request": "2.48.13",
120
120
  "@types/request-promise": "4.1.51",
121
- "@types/shelljs": "0.8.15",
122
- "@types/supertest": "6.0.2",
123
- "@types/uuid": "^10.0.0",
121
+ "@types/shelljs": "0.10.0",
122
+ "@types/supertest": "7.2.0",
123
+ "@types/uuid": "^11.0.0",
124
124
  "@types/winston": "2.4.4",
125
125
  "@types/ws": "^8.5.12",
126
126
  "chai": "5.1.1",
@@ -128,19 +128,19 @@
128
128
  "conventional-changelog-conventionalcommits": "^9.1.0",
129
129
  "create-ts-index": "^1.14.0",
130
130
  "ctix": "^2.6.4",
131
- "diff": "^5.1.0",
131
+ "diff": "^8.0.3",
132
132
  "eslint": "^8.57.0",
133
133
  "glob": "^11.0.0",
134
134
  "globals": "^15.9.0",
135
- "jest": "^29.7.0",
135
+ "jest": "^30.2.0",
136
136
  "jest-junit": "^16.0.0",
137
137
  "mock-fs": "^5.2.0",
138
138
  "nodemon": "^3.1.4",
139
139
  "prettier": "^3.3.3",
140
140
  "rimraf": "^6.0.0",
141
141
  "semantic-release": "^24.1.0",
142
- "shelljs": "0.8.5",
143
- "supertest": "7.0.0",
142
+ "shelljs": "0.10.0",
143
+ "supertest": "7.2.2",
144
144
  "ts-jest": "^29.2.4",
145
145
  "ts-jest-mocker": "^1.0.0",
146
146
  "ts-node": "^10.9.2",
@@ -150,6 +150,16 @@
150
150
  "typescript-eslint": "^8.5.0",
151
151
  "typescript-transform-paths": "^3.5.0"
152
152
  },
153
+ "overrides": {
154
+ "fast-xml-parser": "^4.5.4",
155
+ "tar": "^7.5.10",
156
+ "serialize-javascript": "^7.0.3",
157
+ "rollup": "^4.59.0",
158
+ "tough-cookie": "^4.1.4",
159
+ "ajv": "^6.14.0",
160
+ "libxmljs2": "^0.37.0",
161
+ "lodash": "^4.17.23"
162
+ },
153
163
  "engines": {
154
164
  "node": ">=18.0.0"
155
165
  }