@teamkeel/testing-runtime 0.463.1 → 0.464.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/package.json +1 -1
- package/src/FlowExecutor.mjs +35 -2
- package/src/index.d.ts +35 -0
package/package.json
CHANGED
package/src/FlowExecutor.mjs
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import jwt from "jsonwebtoken";
|
|
2
2
|
import { parseInputs, parseOutputs, reviver } from "./parsing.mjs";
|
|
3
3
|
|
|
4
|
+
// Interval (ms) between flow-run status polls in untilFinished/untilAwaitingInput.
|
|
5
|
+
// A lower interval means less dead wait per flow assertion (at the cost of a few
|
|
6
|
+
// more cheap status requests); overridable via env for tuning. In a test suite with
|
|
7
|
+
// many flow assertions the previous 50ms floor added up to meaningful wall-clock.
|
|
8
|
+
const FLOW_POLL_INTERVAL_MS =
|
|
9
|
+
Number(process.env.KEEL_FLOW_POLL_INTERVAL_MS) || 10;
|
|
10
|
+
|
|
4
11
|
export class FlowExecutor {
|
|
5
12
|
constructor(props) {
|
|
6
13
|
this._flowUrl =
|
|
@@ -105,6 +112,28 @@ export class FlowExecutor {
|
|
|
105
112
|
};
|
|
106
113
|
}
|
|
107
114
|
|
|
115
|
+
async listSignedLinks(options = {}) {
|
|
116
|
+
let url = this._flowUrl + "/share";
|
|
117
|
+
if (options.status !== undefined && options.status !== null) {
|
|
118
|
+
const queryString = new URLSearchParams({
|
|
119
|
+
status: options.status,
|
|
120
|
+
}).toString();
|
|
121
|
+
url = `${url}?${queryString}`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return fetch(url, {
|
|
125
|
+
method: "GET",
|
|
126
|
+
headers: this.headers(),
|
|
127
|
+
}).then(handleResponse);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async revokeSignedLink(linkId) {
|
|
131
|
+
return fetch(this._flowUrl + "/share/" + encodeURIComponent(linkId), {
|
|
132
|
+
method: "DELETE",
|
|
133
|
+
headers: this.headers(),
|
|
134
|
+
}).then(handleResponse);
|
|
135
|
+
}
|
|
136
|
+
|
|
108
137
|
async cancel(id) {
|
|
109
138
|
return fetch(this._flowUrl + "/" + encodeURIComponent(id) + "/cancel", {
|
|
110
139
|
method: "POST",
|
|
@@ -172,7 +201,9 @@ export class FlowExecutor {
|
|
|
172
201
|
return flow;
|
|
173
202
|
}
|
|
174
203
|
|
|
175
|
-
await new Promise((resolve) =>
|
|
204
|
+
await new Promise((resolve) =>
|
|
205
|
+
setTimeout(resolve, FLOW_POLL_INTERVAL_MS)
|
|
206
|
+
);
|
|
176
207
|
}
|
|
177
208
|
}
|
|
178
209
|
|
|
@@ -204,7 +235,9 @@ export class FlowExecutor {
|
|
|
204
235
|
);
|
|
205
236
|
}
|
|
206
237
|
|
|
207
|
-
await new Promise((resolve) =>
|
|
238
|
+
await new Promise((resolve) =>
|
|
239
|
+
setTimeout(resolve, FLOW_POLL_INTERVAL_MS)
|
|
240
|
+
);
|
|
208
241
|
}
|
|
209
242
|
}
|
|
210
243
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -151,6 +151,10 @@ declare class FlowExecutor<Input = {}> {
|
|
|
151
151
|
expiresAt: Date | null;
|
|
152
152
|
flow: { name: string; runId: string | null };
|
|
153
153
|
}>;
|
|
154
|
+
listSignedLinks(options?: {
|
|
155
|
+
status?: "active" | "revoked" | "expired";
|
|
156
|
+
}): Promise<{ signedLinks: SignedLinkRecord[] }>;
|
|
157
|
+
revokeSignedLink(linkId: string): Promise<SignedLinkRecord>;
|
|
154
158
|
get(id: string): Promise<FlowRun<Input>>;
|
|
155
159
|
cancel(id: string): Promise<FlowRun<Input>>;
|
|
156
160
|
back(id: string): Promise<FlowRun<Input>>;
|
|
@@ -171,6 +175,36 @@ declare class FlowExecutor<Input = {}> {
|
|
|
171
175
|
untilFinished(id: string, timeout?: number): Promise<FlowRun<Input>>;
|
|
172
176
|
}
|
|
173
177
|
|
|
178
|
+
// A persisted shareable signed link for a flow. The shareable url is exposed so the link can be
|
|
179
|
+
// re-shared; the raw token/hash is never exposed. url is absent for links minted before the token
|
|
180
|
+
// was persisted.
|
|
181
|
+
export interface SignedLinkRecord {
|
|
182
|
+
id: string;
|
|
183
|
+
flowName: string;
|
|
184
|
+
inputs: Record<string, any> | null;
|
|
185
|
+
reusable: boolean;
|
|
186
|
+
createdBy: string | null;
|
|
187
|
+
expiresAt: Date | null;
|
|
188
|
+
usedCount: number;
|
|
189
|
+
revokedAt: Date | null;
|
|
190
|
+
createdAt: Date;
|
|
191
|
+
updatedAt: Date;
|
|
192
|
+
status: "active" | "revoked" | "expired";
|
|
193
|
+
url?: string;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Live progress snapshot reported by a step while it runs
|
|
197
|
+
export interface StepProgress {
|
|
198
|
+
message?: string;
|
|
199
|
+
current?: number;
|
|
200
|
+
total?: number;
|
|
201
|
+
unit?: string;
|
|
202
|
+
counter?: "count" | "percent" | "none";
|
|
203
|
+
logs?: string[];
|
|
204
|
+
data?: Record<string, unknown>;
|
|
205
|
+
updatedAt: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
174
208
|
// Step Definition
|
|
175
209
|
export interface FlowStep {
|
|
176
210
|
id: string;
|
|
@@ -186,6 +220,7 @@ export interface FlowStep {
|
|
|
186
220
|
createdAt: string;
|
|
187
221
|
updatedAt: string;
|
|
188
222
|
ui: UIConfig | null;
|
|
223
|
+
progress: StepProgress | null;
|
|
189
224
|
}
|
|
190
225
|
|
|
191
226
|
// Flow Run Definition
|