@sonisoft/now-sdk-ext-core 6.15.1 → 6.16.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 +3 -0
- package/dist/comm/http/RequestHandler.d.ts +7 -0
- package/dist/comm/http/RequestHandler.js +19 -5
- package/dist/comm/http/RequestHandler.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/sn/flow/FlowDebugError.d.ts +11 -0
- package/dist/sn/flow/FlowDebugError.js +39 -0
- package/dist/sn/flow/FlowDebugError.js.map +1 -0
- package/dist/sn/flow/FlowDebugModels.d.ts +241 -0
- package/dist/sn/flow/FlowDebugModels.js +8 -0
- package/dist/sn/flow/FlowDebugModels.js.map +1 -0
- package/dist/sn/flow/FlowDebugger.d.ts +162 -0
- package/dist/sn/flow/FlowDebugger.js +822 -0
- package/dist/sn/flow/FlowDebugger.js.map +1 -0
- package/dist/sn/flow/FlowManager.js +3 -0
- package/dist/sn/flow/FlowManager.js.map +1 -1
- package/dist/sn/flow/FlowModels.d.ts +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { ServiceNowInstance } from '../ServiceNowInstance.js';
|
|
2
|
+
import type { FlowDebugBreakpoint, FlowDebugCancelResult, FlowDebugCommand, FlowDebugListOptions, FlowDebugLocation, FlowDebugRunToOptions, FlowDebugRunToResult, FlowDebugSession, FlowDebugSessionSummary, FlowDebugSnapshot, FlowDebugStartOptions, FlowDebugStepRef, FlowDebugWaitOptions } from './FlowDebugModels.js';
|
|
3
|
+
/**
|
|
4
|
+
* Drives the Workflow Studio flow debugger (**Test ▸ Debug**) over REST.
|
|
5
|
+
*
|
|
6
|
+
* A debug run executes the flow or subflow for real, so its actions create and change records,
|
|
7
|
+
* and it holds a flow context open while paused. Every run must be ended: by running it to the
|
|
8
|
+
* end, or with {@link cancel}. {@link withSession}, and {@link runTo} by default, cancel the run
|
|
9
|
+
* for you; `runTo` with `after: 'resume'` or `'stay'` leaves it running or paused.
|
|
10
|
+
*
|
|
11
|
+
* The APIs are Workflow Studio's own (`/api/now/processflow/debug/…`), not a published REST
|
|
12
|
+
* contract. They work with the ordinary OAuth credential; no UI session is needed.
|
|
13
|
+
*
|
|
14
|
+
* Starting a run and sending a step command need execute permission under an installed policy;
|
|
15
|
+
* breakpoint changes and cancel need write, so a run stays cancellable under `--deny-execute`.
|
|
16
|
+
*
|
|
17
|
+
* Every method takes the **root** context id that {@link start} returns. When step into enters a
|
|
18
|
+
* subflow, the subflow runs in a child context of its own; commands, breakpoints and snapshots
|
|
19
|
+
* then apply to that child, and the snapshot's `chain` shows the path to it.
|
|
20
|
+
*/
|
|
21
|
+
export declare class FlowDebugger {
|
|
22
|
+
private readonly _logger;
|
|
23
|
+
private readonly _request;
|
|
24
|
+
private readonly _flows;
|
|
25
|
+
/** allowed-breakpoints never changes for a context, so it is read once. */
|
|
26
|
+
private readonly _allowed;
|
|
27
|
+
/**
|
|
28
|
+
* Poll schedule while waiting for a run to settle. `waitingSettleMs`: right after step into a
|
|
29
|
+
* subflow the parent is WAITING before its child context exists, so WAITING only counts as
|
|
30
|
+
* settled once it has lasted this long.
|
|
31
|
+
*/
|
|
32
|
+
protected _poll: {
|
|
33
|
+
firstMs: number;
|
|
34
|
+
maxMs: number;
|
|
35
|
+
factor: number;
|
|
36
|
+
waitingSettleMs: number;
|
|
37
|
+
};
|
|
38
|
+
constructor(instance: ServiceNowInstance);
|
|
39
|
+
/**
|
|
40
|
+
* Start a debug run and wait for it to first pause.
|
|
41
|
+
*
|
|
42
|
+
* The flow's current draft is what runs, as in Workflow Studio. Inputs are checked against a
|
|
43
|
+
* subflow's declared inputs before anything is sent. If the run cannot be set up after it
|
|
44
|
+
* started, it is cancelled again before the error is thrown, and the error carries its
|
|
45
|
+
* `contextId` and whether the cancel worked.
|
|
46
|
+
*
|
|
47
|
+
* Under an installed policy, a run is only started when a cancel would also be permitted:
|
|
48
|
+
* starting needs execute, and breakpoints and cancel need write.
|
|
49
|
+
*
|
|
50
|
+
* A run normally pauses before its first step. One that fails or finishes first is returned
|
|
51
|
+
* as it ended; check `snapshot.state`.
|
|
52
|
+
*/
|
|
53
|
+
start(options: FlowDebugStartOptions): Promise<FlowDebugSession>;
|
|
54
|
+
/**
|
|
55
|
+
* Classify a failed start call. Its request is marked sensitive, so only the status survives;
|
|
56
|
+
* a 400 or 404 is checked against a harmless debugger read to tell an instance without the
|
|
57
|
+
* debugger from a start it refused.
|
|
58
|
+
*/
|
|
59
|
+
private startFailure;
|
|
60
|
+
/** The run as it is now, without moving it. */
|
|
61
|
+
inspect(contextId: string): Promise<FlowDebugSnapshot>;
|
|
62
|
+
/** Where the active context (the root, or the child subflow it is paused in) can stop. */
|
|
63
|
+
locations(contextId: string): Promise<FlowDebugLocation[]>;
|
|
64
|
+
/** Breakpoints the active context holds. */
|
|
65
|
+
getBreakpoints(contextId: string): Promise<FlowDebugBreakpoint[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Replace the active context's breakpoints with these steps, and read them back.
|
|
68
|
+
*
|
|
69
|
+
* Steps are resolved against the debugger's own list of locations, never sent as given: the
|
|
70
|
+
* debugger accepts any element id on a valid line, so a guessed pair would be "verified" and
|
|
71
|
+
* stop somewhere else.
|
|
72
|
+
*/
|
|
73
|
+
setBreakpoints(contextId: string, steps: FlowDebugStepRef[]): Promise<FlowDebugBreakpoint[]>;
|
|
74
|
+
/** Remove every breakpoint from the active context. */
|
|
75
|
+
clearBreakpoints(contextId: string): Promise<void>;
|
|
76
|
+
/** Run the paused step; stop at the next one. */
|
|
77
|
+
stepOver(contextId: string, options?: FlowDebugWaitOptions): Promise<FlowDebugSnapshot>;
|
|
78
|
+
/** Like step over, but a subflow call is entered and paused in, in a child context. */
|
|
79
|
+
stepInto(contextId: string, options?: FlowDebugWaitOptions): Promise<FlowDebugSnapshot>;
|
|
80
|
+
/** Run the rest of the active context; at the top level, that is the rest of the run. */
|
|
81
|
+
stepOut(contextId: string, options?: FlowDebugWaitOptions): Promise<FlowDebugSnapshot>;
|
|
82
|
+
/** Run to the next breakpoint, or to the end. */
|
|
83
|
+
resume(contextId: string, options?: FlowDebugWaitOptions): Promise<FlowDebugSnapshot>;
|
|
84
|
+
/** Run to the end, ignoring breakpoints. */
|
|
85
|
+
skipAll(contextId: string, options?: FlowDebugWaitOptions): Promise<FlowDebugSnapshot>;
|
|
86
|
+
/**
|
|
87
|
+
* Send one debugger command to the paused context and wait for the run to settle: paused
|
|
88
|
+
* again, ended, waiting, or still executing when the wait times out (`timedOut`).
|
|
89
|
+
*/
|
|
90
|
+
command(contextId: string, command: FlowDebugCommand, options?: FlowDebugWaitOptions): Promise<FlowDebugSnapshot>;
|
|
91
|
+
/**
|
|
92
|
+
* End the run. Cancelling the root also ends any child subflow context. The state is read
|
|
93
|
+
* back, because the debugger answers "cancelled flow" whatever it did. Safe to repeat.
|
|
94
|
+
*
|
|
95
|
+
* @throws FlowDebugError `not_a_debug_session` for a context the debugger did not start, so
|
|
96
|
+
* this can never cancel someone's real flow run.
|
|
97
|
+
*/
|
|
98
|
+
cancel(contextId: string): Promise<FlowDebugCancelResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Start, run to the first of the breakpoints, and report the run there. By default the run is
|
|
101
|
+
* then cancelled, so one call leaves nothing open.
|
|
102
|
+
*/
|
|
103
|
+
runTo(options: FlowDebugRunToOptions): Promise<FlowDebugRunToResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Start a run, hand it to `work`, and cancel it afterwards unless it has ended.
|
|
106
|
+
*
|
|
107
|
+
* If `work` throws, the run is cancelled and `work`'s error is rethrown. If `work` succeeds but
|
|
108
|
+
* the final cancel fails, the cancel's error is thrown instead of the result: a run that may
|
|
109
|
+
* still be open matters more than the result.
|
|
110
|
+
*/
|
|
111
|
+
withSession<T>(options: FlowDebugStartOptions, work: (session: FlowDebugSession) => Promise<T>): Promise<T>;
|
|
112
|
+
/** Debug runs that are still open (paused, waiting or executing), newest first. */
|
|
113
|
+
listSessions(options?: FlowDebugListOptions): Promise<FlowDebugSessionSummary[]>;
|
|
114
|
+
private resolveFlow;
|
|
115
|
+
private definition;
|
|
116
|
+
/**
|
|
117
|
+
* The `outputMap` the start call takes. For a subflow, names are checked against its declared
|
|
118
|
+
* inputs, and a JavaScript array for an `array.*` input becomes `{children: [...]}`, the shape
|
|
119
|
+
* Workflow Studio sends; a plain array reaches the flow as an empty list.
|
|
120
|
+
*/
|
|
121
|
+
private outputMap;
|
|
122
|
+
/** Read the root and follow it into the child subflow context a step into left paused. */
|
|
123
|
+
private observe;
|
|
124
|
+
/** Poll until the run differs from `previous` and is no longer executing, or the time runs out. */
|
|
125
|
+
private waitFor;
|
|
126
|
+
private snapshot;
|
|
127
|
+
private state;
|
|
128
|
+
private values;
|
|
129
|
+
/** The run's flow snapshot, indexed by instance id and by uiUniqueIdentifier. */
|
|
130
|
+
private instances;
|
|
131
|
+
private locationsOf;
|
|
132
|
+
private readBreakpoints;
|
|
133
|
+
private match;
|
|
134
|
+
private requireDebug;
|
|
135
|
+
private requireOpen;
|
|
136
|
+
private postCancel;
|
|
137
|
+
/** Wait (about 10 seconds at most) for a cancelled context to reach an end state. */
|
|
138
|
+
private settleCancel;
|
|
139
|
+
/** Child subflow contexts of `parent` that are still open: a paused one first, then newest first. */
|
|
140
|
+
private openChildren;
|
|
141
|
+
/**
|
|
142
|
+
* Every open context below `root`, at any depth up to MAX_DEPTH. Ended contexts are walked
|
|
143
|
+
* through too: a cancel can end a middle context and leave the one below it paused.
|
|
144
|
+
*/
|
|
145
|
+
private openDescendants;
|
|
146
|
+
/** The root of a subflow context's chain; a root is its own. */
|
|
147
|
+
private rootOf;
|
|
148
|
+
private read;
|
|
149
|
+
private debugCall;
|
|
150
|
+
private call;
|
|
151
|
+
private table;
|
|
152
|
+
/**
|
|
153
|
+
* Turn a failed call into a FlowDebugError. Policy refusals, session errors and anything that
|
|
154
|
+
* is not an HTTP failure pass through untouched.
|
|
155
|
+
*/
|
|
156
|
+
private translate;
|
|
157
|
+
private id;
|
|
158
|
+
private refs;
|
|
159
|
+
private timeout;
|
|
160
|
+
/** Overridable in tests. */
|
|
161
|
+
protected sleep(ms: number): Promise<void>;
|
|
162
|
+
}
|