windmill-client 1.876.0 → 1.880.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/dist/client.d.ts +38 -0
- package/dist/client.mjs +70 -1
- package/dist/core/OpenAPI.mjs +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +190 -2
- package/dist/index.mjs +4 -2
- package/dist/services.gen.d.ts +65 -2
- package/dist/services.gen.mjs +116 -1
- package/dist/types.gen.d.ts +460 -64
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -146,6 +146,44 @@ export declare function runScriptByHashAsync(hash_: string, args?: Record<string
|
|
|
146
146
|
* @returns Job ID of the created job
|
|
147
147
|
*/
|
|
148
148
|
export declare function runFlowAsync(path: string | null, args: Record<string, any> | null, scheduledInSeconds?: number | null, doNotTrackInParent?: boolean, tag?: string | null): Promise<string>;
|
|
149
|
+
/**
|
|
150
|
+
* Run the deployed flow at `path` with some of its steps overridden, wait for it and return
|
|
151
|
+
* its result. Meant for test scripts.
|
|
152
|
+
*
|
|
153
|
+
* Each entry of `steps` maps a step id to either:
|
|
154
|
+
* - a value: the step is skipped and returns that value, or
|
|
155
|
+
* - a function exported from the calling script's own file: the step runs that function
|
|
156
|
+
* instead of its own code, with the step's inputs as arguments (matched by name).
|
|
157
|
+
*
|
|
158
|
+
* A step inside a subflow is named by the path of step ids to it, `"sub:inner"` for step `inner`
|
|
159
|
+
* of the subflow that step `sub` calls. It applies to every call of that subflow made by the
|
|
160
|
+
* tested flow and by the subflows it overrides; a subflow left as is still calls the deployed
|
|
161
|
+
* one. Those subflows, and each one on the way to an override, run as you rather than as their
|
|
162
|
+
* on-behalf-of identity. Result caching is off for the whole test run.
|
|
163
|
+
*
|
|
164
|
+
* The flow's preprocessor does not run: `args` are what the flow receives after it. A subflow
|
|
165
|
+
* never runs its own preprocessor, in a test or not. AI agent
|
|
166
|
+
* tools cannot be overridden; override the agent step instead.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* export function fakeFetch(url: string) { return { status: 200 } }
|
|
170
|
+
* export async function main() {
|
|
171
|
+
* const result = await wmill.testFlow("f/flows/sync", { user: "a" }, {
|
|
172
|
+
* fetch_users: fakeFetch, // replaced logic
|
|
173
|
+
* send_email: "sent", // mocked result
|
|
174
|
+
* });
|
|
175
|
+
* }
|
|
176
|
+
* @param path - Flow path in Windmill
|
|
177
|
+
* @param args - Arguments to pass to the flow
|
|
178
|
+
* @param steps - Step id to mocked result, or to the function replacing the step
|
|
179
|
+
* @param verbose - Enable verbose logging
|
|
180
|
+
* @returns Flow execution result
|
|
181
|
+
*/
|
|
182
|
+
export declare function testFlow(path: string, args?: Record<string, any> | null, steps?: Record<string, any>, verbose?: boolean): Promise<any>;
|
|
183
|
+
/**
|
|
184
|
+
* Like {@link testFlow}, but returns the job id without waiting for the flow to complete.
|
|
185
|
+
*/
|
|
186
|
+
export declare function testFlowAsync(path: string, args?: Record<string, any> | null, steps?: Record<string, any>): Promise<string>;
|
|
149
187
|
/**
|
|
150
188
|
* Resolve a resource value in case the default value was picked because the input payload was undefined
|
|
151
189
|
* @param obj resource value or path of the resource under the format `$res:path`
|
package/dist/client.mjs
CHANGED
|
@@ -336,6 +336,75 @@ async function runFlowAsync(path, args, scheduledInSeconds = null, doNotTrackInP
|
|
|
336
336
|
}).then((res) => res.text());
|
|
337
337
|
}
|
|
338
338
|
/**
|
|
339
|
+
* Run the deployed flow at `path` with some of its steps overridden, wait for it and return
|
|
340
|
+
* its result. Meant for test scripts.
|
|
341
|
+
*
|
|
342
|
+
* Each entry of `steps` maps a step id to either:
|
|
343
|
+
* - a value: the step is skipped and returns that value, or
|
|
344
|
+
* - a function exported from the calling script's own file: the step runs that function
|
|
345
|
+
* instead of its own code, with the step's inputs as arguments (matched by name).
|
|
346
|
+
*
|
|
347
|
+
* A step inside a subflow is named by the path of step ids to it, `"sub:inner"` for step `inner`
|
|
348
|
+
* of the subflow that step `sub` calls. It applies to every call of that subflow made by the
|
|
349
|
+
* tested flow and by the subflows it overrides; a subflow left as is still calls the deployed
|
|
350
|
+
* one. Those subflows, and each one on the way to an override, run as you rather than as their
|
|
351
|
+
* on-behalf-of identity. Result caching is off for the whole test run.
|
|
352
|
+
*
|
|
353
|
+
* The flow's preprocessor does not run: `args` are what the flow receives after it. A subflow
|
|
354
|
+
* never runs its own preprocessor, in a test or not. AI agent
|
|
355
|
+
* tools cannot be overridden; override the agent step instead.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* export function fakeFetch(url: string) { return { status: 200 } }
|
|
359
|
+
* export async function main() {
|
|
360
|
+
* const result = await wmill.testFlow("f/flows/sync", { user: "a" }, {
|
|
361
|
+
* fetch_users: fakeFetch, // replaced logic
|
|
362
|
+
* send_email: "sent", // mocked result
|
|
363
|
+
* });
|
|
364
|
+
* }
|
|
365
|
+
* @param path - Flow path in Windmill
|
|
366
|
+
* @param args - Arguments to pass to the flow
|
|
367
|
+
* @param steps - Step id to mocked result, or to the function replacing the step
|
|
368
|
+
* @param verbose - Enable verbose logging
|
|
369
|
+
* @returns Flow execution result
|
|
370
|
+
*/
|
|
371
|
+
async function testFlow(path, args = null, steps = {}, verbose = false) {
|
|
372
|
+
const jobId = await testFlowAsync(path, args, steps);
|
|
373
|
+
return await waitJob(jobId, verbose);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Like {@link testFlow}, but returns the job id without waiting for the flow to complete.
|
|
377
|
+
*/
|
|
378
|
+
async function testFlowAsync(path, args = null, steps = {}) {
|
|
379
|
+
const stepOverrides = {};
|
|
380
|
+
let usesFunction = false;
|
|
381
|
+
for (const [id, o] of Object.entries(steps)) if (typeof o === "function") {
|
|
382
|
+
if (!o.name) throw new Error(`step \`${id}\`: the replacing function must be a named function exported from this file`);
|
|
383
|
+
stepOverrides[id] = { function: o.name };
|
|
384
|
+
usesFunction = true;
|
|
385
|
+
} else stepOverrides[id] = { return_value: o === void 0 ? null : o };
|
|
386
|
+
const body = {
|
|
387
|
+
args: args ?? {},
|
|
388
|
+
steps: stepOverrides
|
|
389
|
+
};
|
|
390
|
+
if (usesFunction) {
|
|
391
|
+
const callerJobId = getEnv("WM_JOB_ID");
|
|
392
|
+
if (!callerJobId) throw new Error("replacing a step with a function only works from a script running in Windmill");
|
|
393
|
+
body.caller_job_id = callerJobId;
|
|
394
|
+
}
|
|
395
|
+
const res = await fetch(`${OpenAPI.BASE}/w/${getWorkspace()}/jobs/run/flow_test/${path}`, {
|
|
396
|
+
method: "POST",
|
|
397
|
+
headers: {
|
|
398
|
+
"Content-Type": "application/json",
|
|
399
|
+
Authorization: `Bearer ${OpenAPI.TOKEN}`
|
|
400
|
+
},
|
|
401
|
+
body: JSON.stringify(body)
|
|
402
|
+
});
|
|
403
|
+
const text = await res.text();
|
|
404
|
+
if (!res.ok) throw new Error(`testFlow failed (${res.status}): ${text}`);
|
|
405
|
+
return text;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
339
408
|
* Resolve a resource value in case the default value was picked because the input payload was undefined
|
|
340
409
|
* @param obj resource value or path of the resource under the format `$res:path`
|
|
341
410
|
* @returns resource value
|
|
@@ -1688,4 +1757,4 @@ async function commitKafkaOffsets(triggerPath, topic, partition, offset) {
|
|
|
1688
1757
|
}
|
|
1689
1758
|
|
|
1690
1759
|
//#endregion
|
|
1691
|
-
export { SHARED_FOLDER, StepSuspend, WorkflowCtx, _workflowCtx, appendToResultStream, base64ToUint8Array, cancelJob, commitKafkaOffsets, databaseUrlFromResource, deleteS3File, denoS3LightClientSettings, getApprovalUrls, getEnv, getFlowUserState, getIdToken, getInternalState, getPresignedS3PublicUrl, getPresignedS3PublicUrls, getProgress, getResource, getResult, getResultMaybe, getResumeEndpoints, getResumeUrls, getRootJobId, getState, getStatePath, getVariable, getWorkspace, loadS3File, loadS3FileStream, parallel, requestInteractiveSlackApproval, requestInteractiveTeamsApproval, resolveDefaultResource, runFlow, runFlowAsync, runScript, runScriptAsync, runScriptByHash, runScriptByHashAsync, runScriptByPath, runScriptByPathAsync, setClient, setFlowUserState, setInternalState, setProgress, setResource, setState, setVariable, setWorkflowCtx, signS3Object, signS3Objects, sleep, step, streamResult, task, taskFlow, taskScript, uint8ArrayToBase64, usernameToEmail, waitForApproval, waitJob, workerHasInternalServer, workerIsDraining, workflow, writeS3File };
|
|
1760
|
+
export { SHARED_FOLDER, StepSuspend, WorkflowCtx, _workflowCtx, appendToResultStream, base64ToUint8Array, cancelJob, commitKafkaOffsets, databaseUrlFromResource, deleteS3File, denoS3LightClientSettings, getApprovalUrls, getEnv, getFlowUserState, getIdToken, getInternalState, getPresignedS3PublicUrl, getPresignedS3PublicUrls, getProgress, getResource, getResult, getResultMaybe, getResumeEndpoints, getResumeUrls, getRootJobId, getState, getStatePath, getVariable, getWorkspace, loadS3File, loadS3FileStream, parallel, requestInteractiveSlackApproval, requestInteractiveTeamsApproval, resolveDefaultResource, runFlow, runFlowAsync, runScript, runScriptAsync, runScriptByHash, runScriptByHashAsync, runScriptByPath, runScriptByPathAsync, setClient, setFlowUserState, setInternalState, setProgress, setResource, setState, setVariable, setWorkflowCtx, signS3Object, signS3Objects, sleep, step, streamResult, task, taskFlow, taskScript, testFlow, testFlowAsync, uint8ArrayToBase64, usernameToEmail, waitForApproval, waitJob, workerHasInternalServer, workerIsDraining, workflow, writeS3File };
|
package/dist/core/OpenAPI.mjs
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI';
|
|
|
4
4
|
export * from './services.gen';
|
|
5
5
|
export * from './types.gen';
|
|
6
6
|
export type { DenoS3LightClientSettings } from "./s3Types";
|
|
7
|
-
export { type Base64, setClient, getWorkspace, workerHasInternalServer, SHARED_FOLDER, getStatePath, getInternalState, setInternalState, getResumeEndpoints, getResult, getResultMaybe, resolveDefaultResource, databaseUrlFromResource, base64ToUint8Array, uint8ArrayToBase64, getVariable, setVariable, getResource, setResource, getResumeUrls, setState, setProgress, getProgress, workerIsDraining, getState, getIdToken, denoS3LightClientSettings, cancelJob, loadS3FileStream, loadS3File, writeS3File, deleteS3File, signS3Objects, signS3Object, getPresignedS3PublicUrls, getPresignedS3PublicUrl, task, taskScript, taskFlow, workflow, step, sleep, parallel, waitForApproval, getApprovalUrls, type TaskOptions, type TaskRetry, type Jsonified, type JsonifiedFn, WorkflowCtx, _workflowCtx, setWorkflowCtx, StepSuspend, runScript, runScriptAsync, runScriptByPath, runScriptByHash, runScriptByPathAsync, runScriptByHashAsync, type RunScriptAsyncOptions, runFlow, runFlowAsync, waitJob, getRootJobId, setFlowUserState, getFlowUserState, usernameToEmail, requestInteractiveSlackApproval, type Sql, requestInteractiveTeamsApproval, appendToResultStream, streamResult, datatable, ducklake, upsertPartition, appendPartition, type DucklakeMaterializeOptions, type SqlStatement, type DatatableSqlTemplateFunction, type SqlTemplateFunction, type S3Object, type S3ObjectRecord, type S3ObjectURI, commitKafkaOffsets } from "./client";
|
|
8
|
-
import { setClient, getVariable, setVariable, getResource, setResource, getResumeUrls, setState, setProgress, getProgress, workerIsDraining, getState, getIdToken, denoS3LightClientSettings, cancelJob, loadS3FileStream, loadS3File, writeS3File, deleteS3File, signS3Objects, signS3Object, getPresignedS3PublicUrls, getPresignedS3PublicUrl, task, taskScript, taskFlow, workflow, step, sleep, parallel, waitForApproval, getApprovalUrls, WorkflowCtx, setWorkflowCtx, StepSuspend, runScript, runScriptAsync, runScriptByPath, runScriptByHash, runScriptByPathAsync, runScriptByHashAsync, runFlow, runFlowAsync, waitJob, getRootJobId, setFlowUserState, getFlowUserState, usernameToEmail, requestInteractiveSlackApproval, requestInteractiveTeamsApproval, appendToResultStream, streamResult, datatable, ducklake, upsertPartition, appendPartition, getWorkspace, getStatePath, getInternalState, setInternalState, getResumeEndpoints, getResult, getResultMaybe, resolveDefaultResource, databaseUrlFromResource, base64ToUint8Array, uint8ArrayToBase64, parseS3Object, commitKafkaOffsets } from "./client";
|
|
7
|
+
export { type Base64, setClient, getWorkspace, workerHasInternalServer, SHARED_FOLDER, getStatePath, getInternalState, setInternalState, getResumeEndpoints, getResult, getResultMaybe, resolveDefaultResource, databaseUrlFromResource, base64ToUint8Array, uint8ArrayToBase64, getVariable, setVariable, getResource, setResource, getResumeUrls, setState, setProgress, getProgress, workerIsDraining, getState, getIdToken, denoS3LightClientSettings, cancelJob, loadS3FileStream, loadS3File, writeS3File, deleteS3File, signS3Objects, signS3Object, getPresignedS3PublicUrls, getPresignedS3PublicUrl, task, taskScript, taskFlow, workflow, step, sleep, parallel, waitForApproval, getApprovalUrls, type TaskOptions, type TaskRetry, type Jsonified, type JsonifiedFn, WorkflowCtx, _workflowCtx, setWorkflowCtx, StepSuspend, runScript, runScriptAsync, runScriptByPath, runScriptByHash, runScriptByPathAsync, runScriptByHashAsync, type RunScriptAsyncOptions, runFlow, runFlowAsync, testFlow, testFlowAsync, waitJob, getRootJobId, setFlowUserState, getFlowUserState, usernameToEmail, requestInteractiveSlackApproval, type Sql, requestInteractiveTeamsApproval, appendToResultStream, streamResult, datatable, ducklake, upsertPartition, appendPartition, type DucklakeMaterializeOptions, type SqlStatement, type DatatableSqlTemplateFunction, type SqlTemplateFunction, type S3Object, type S3ObjectRecord, type S3ObjectURI, commitKafkaOffsets } from "./client";
|
|
8
|
+
import { setClient, getVariable, setVariable, getResource, setResource, getResumeUrls, setState, setProgress, getProgress, workerIsDraining, getState, getIdToken, denoS3LightClientSettings, cancelJob, loadS3FileStream, loadS3File, writeS3File, deleteS3File, signS3Objects, signS3Object, getPresignedS3PublicUrls, getPresignedS3PublicUrl, task, taskScript, taskFlow, workflow, step, sleep, parallel, waitForApproval, getApprovalUrls, WorkflowCtx, setWorkflowCtx, StepSuspend, runScript, runScriptAsync, runScriptByPath, runScriptByHash, runScriptByPathAsync, runScriptByHashAsync, runFlow, runFlowAsync, testFlow, testFlowAsync, waitJob, getRootJobId, setFlowUserState, getFlowUserState, usernameToEmail, requestInteractiveSlackApproval, requestInteractiveTeamsApproval, appendToResultStream, streamResult, datatable, ducklake, upsertPartition, appendPartition, getWorkspace, getStatePath, getInternalState, setInternalState, getResumeEndpoints, getResult, getResultMaybe, resolveDefaultResource, databaseUrlFromResource, base64ToUint8Array, uint8ArrayToBase64, parseS3Object, commitKafkaOffsets } from "./client";
|
|
9
9
|
import { AdminService, AuditService, FlowService, GranularAclService, GroupService, JobService, ResourceService, VariableService, ScriptService, ScheduleService, SettingsService, UserService, WorkspaceService, TeamsService } from "./services.gen";
|
|
10
10
|
declare const wmill: {
|
|
11
11
|
setClient: typeof setClient;
|
|
@@ -51,6 +51,8 @@ declare const wmill: {
|
|
|
51
51
|
runScriptByHashAsync: typeof runScriptByHashAsync;
|
|
52
52
|
runFlow: typeof runFlow;
|
|
53
53
|
runFlowAsync: typeof runFlowAsync;
|
|
54
|
+
testFlow: typeof testFlow;
|
|
55
|
+
testFlowAsync: typeof testFlowAsync;
|
|
54
56
|
waitJob: typeof waitJob;
|
|
55
57
|
getRootJobId: typeof getRootJobId;
|
|
56
58
|
setFlowUserState: typeof setFlowUserState;
|
package/dist/index.js
CHANGED
|
@@ -126,7 +126,7 @@ const OpenAPI = {
|
|
|
126
126
|
PASSWORD: void 0,
|
|
127
127
|
TOKEN: getEnv$1("WM_TOKEN"),
|
|
128
128
|
USERNAME: void 0,
|
|
129
|
-
VERSION: "1.
|
|
129
|
+
VERSION: "1.880.0",
|
|
130
130
|
WITH_CREDENTIALS: !getEnv$1("WM_RAW_APP"),
|
|
131
131
|
interceptors: {
|
|
132
132
|
request: new Interceptors(),
|
|
@@ -8244,7 +8244,7 @@ var ScriptService = class {
|
|
|
8244
8244
|
* If false, show only scripts with dedicated_worker disabled.
|
|
8245
8245
|
*
|
|
8246
8246
|
* @param data.label Filter by label
|
|
8247
|
-
* @returns
|
|
8247
|
+
* @returns ListableScript All scripts
|
|
8248
8248
|
* @throws ApiError
|
|
8249
8249
|
*/
|
|
8250
8250
|
static listScripts(data) {
|
|
@@ -9988,6 +9988,28 @@ var JobService = class {
|
|
|
9988
9988
|
});
|
|
9989
9989
|
}
|
|
9990
9990
|
/**
|
|
9991
|
+
* get the approval detail of one step of a flow run
|
|
9992
|
+
* Get the approval state of an approval (suspend) step of a flow run, by the flow run id and the step id, in a single query: where the step stands, its approval settings, the approvals received and, while it waits, whether the caller can approve. Only the run's own steps are searched: for a step inside a branch or loop, pass the id of the branch's or iteration's run.
|
|
9993
|
+
*
|
|
9994
|
+
* @param data The data for the request.
|
|
9995
|
+
* @param data.workspace
|
|
9996
|
+
* @param data.jobId id of the flow run
|
|
9997
|
+
* @param data.stepId id of the approval step in the flow
|
|
9998
|
+
* @returns unknown approval step detail
|
|
9999
|
+
* @throws ApiError
|
|
10000
|
+
*/
|
|
10001
|
+
static getApprovalStepDetail(data) {
|
|
10002
|
+
return request(OpenAPI, {
|
|
10003
|
+
method: "GET",
|
|
10004
|
+
url: "/w/{workspace}/jobs/flow/approval_step_detail/{job_id}/{step_id}",
|
|
10005
|
+
path: {
|
|
10006
|
+
workspace: data.workspace,
|
|
10007
|
+
job_id: data.jobId,
|
|
10008
|
+
step_id: data.stepId
|
|
10009
|
+
}
|
|
10010
|
+
});
|
|
10011
|
+
}
|
|
10012
|
+
/**
|
|
9991
10013
|
* mint a read-only share token for a job
|
|
9992
10014
|
* Returns a stateless `{job_id}.{hmac}` token that grants an authenticated workspace member read access to this job (and its flow subtree) via a `view_token` query param or `X-View-Token` header. Only callable by a user who can already read the job.
|
|
9993
10015
|
*
|
|
@@ -10401,6 +10423,30 @@ var JobService = class {
|
|
|
10401
10423
|
});
|
|
10402
10424
|
}
|
|
10403
10425
|
/**
|
|
10426
|
+
* run a deployed flow with some steps overridden, for tests
|
|
10427
|
+
* Runs the latest deployed version of the flow as a flow preview, with each step named in `steps` either mocked (`{"return_value": ...}`) or replaced by a function of the code of `caller_job_id` (`{"function": "<name>"}`), called with the step's inputs. Needs the same rights as a flow preview.
|
|
10428
|
+
* @param data The data for the request.
|
|
10429
|
+
* @param data.workspace
|
|
10430
|
+
* @param data.path
|
|
10431
|
+
* @param data.requestBody
|
|
10432
|
+
* @param data.jobId The job id to assign to the created job. if missing, job is chosen randomly using the ULID scheme. If a job id already exists in the queue or as a completed job, the request to create one will fail (Bad Request)
|
|
10433
|
+
* @returns string job created
|
|
10434
|
+
* @throws ApiError
|
|
10435
|
+
*/
|
|
10436
|
+
static runFlowTest(data) {
|
|
10437
|
+
return request(OpenAPI, {
|
|
10438
|
+
method: "POST",
|
|
10439
|
+
url: "/w/{workspace}/jobs/run/flow_test/{path}",
|
|
10440
|
+
path: {
|
|
10441
|
+
workspace: data.workspace,
|
|
10442
|
+
path: data.path
|
|
10443
|
+
},
|
|
10444
|
+
query: { job_id: data.jobId },
|
|
10445
|
+
body: data.requestBody,
|
|
10446
|
+
mediaType: "application/json"
|
|
10447
|
+
});
|
|
10448
|
+
}
|
|
10449
|
+
/**
|
|
10404
10450
|
* run flow preview
|
|
10405
10451
|
* @param data The data for the request.
|
|
10406
10452
|
* @param data.workspace
|
|
@@ -12819,6 +12865,22 @@ var AiService = class {
|
|
|
12819
12865
|
});
|
|
12820
12866
|
}
|
|
12821
12867
|
/**
|
|
12868
|
+
* list the caller's shared AI sessions
|
|
12869
|
+
* The caller's own shares and the ones they opened by link, most recently shared or opened first, without their snapshot. Capped at 500. `session_id` is set on the caller's own shares only, `opened_at` on the others.
|
|
12870
|
+
*
|
|
12871
|
+
* @param data The data for the request.
|
|
12872
|
+
* @param data.workspace
|
|
12873
|
+
* @returns unknown the shares
|
|
12874
|
+
* @throws ApiError
|
|
12875
|
+
*/
|
|
12876
|
+
static listSharedAiSessions(data) {
|
|
12877
|
+
return request(OpenAPI, {
|
|
12878
|
+
method: "GET",
|
|
12879
|
+
url: "/w/{workspace}/ai/shared_sessions/list",
|
|
12880
|
+
path: { workspace: data.workspace }
|
|
12881
|
+
});
|
|
12882
|
+
}
|
|
12883
|
+
/**
|
|
12822
12884
|
* make a shared AI session public, or reserve it to workspace members
|
|
12823
12885
|
* @param data The data for the request.
|
|
12824
12886
|
* @param data.workspace
|
|
@@ -12860,6 +12922,26 @@ var AiService = class {
|
|
|
12860
12922
|
});
|
|
12861
12923
|
}
|
|
12862
12924
|
/**
|
|
12925
|
+
* remove a shared AI session from the caller's list
|
|
12926
|
+
* The share stays readable by link; opening it again lists it again.
|
|
12927
|
+
*
|
|
12928
|
+
* @param data The data for the request.
|
|
12929
|
+
* @param data.workspace
|
|
12930
|
+
* @param data.id
|
|
12931
|
+
* @returns string removed from the list
|
|
12932
|
+
* @throws ApiError
|
|
12933
|
+
*/
|
|
12934
|
+
static forgetOpenedAiSession(data) {
|
|
12935
|
+
return request(OpenAPI, {
|
|
12936
|
+
method: "DELETE",
|
|
12937
|
+
url: "/w/{workspace}/ai/shared_sessions/opened/{id}",
|
|
12938
|
+
path: {
|
|
12939
|
+
workspace: data.workspace,
|
|
12940
|
+
id: data.id
|
|
12941
|
+
}
|
|
12942
|
+
});
|
|
12943
|
+
}
|
|
12944
|
+
/**
|
|
12863
12945
|
* stop sharing an AI session
|
|
12864
12946
|
* @param data The data for the request.
|
|
12865
12947
|
* @param data.workspace
|
|
@@ -17024,6 +17106,39 @@ var ConfigService = class {
|
|
|
17024
17106
|
});
|
|
17025
17107
|
}
|
|
17026
17108
|
/**
|
|
17109
|
+
* Get the recorded autoscaling decisions of a worker group, and whether a recording is running
|
|
17110
|
+
* @param data The data for the request.
|
|
17111
|
+
* @param data.workerGroup
|
|
17112
|
+
* @param data.includeDecisions false returns the recording state and the decision count only
|
|
17113
|
+
* @returns AutoscalingDiagnostics The recording state and the recorded decisions, oldest first
|
|
17114
|
+
* @throws ApiError
|
|
17115
|
+
*/
|
|
17116
|
+
static getAutoscalingDiagnostics(data) {
|
|
17117
|
+
return request(OpenAPI, {
|
|
17118
|
+
method: "GET",
|
|
17119
|
+
url: "/configs/autoscaling_diagnostics/{worker_group}",
|
|
17120
|
+
path: { worker_group: data.workerGroup },
|
|
17121
|
+
query: { include_decisions: data.includeDecisions }
|
|
17122
|
+
});
|
|
17123
|
+
}
|
|
17124
|
+
/**
|
|
17125
|
+
* Start recording the autoscaling decisions of a worker group for 24 hours, or stop
|
|
17126
|
+
* @param data The data for the request.
|
|
17127
|
+
* @param data.workerGroup
|
|
17128
|
+
* @param data.requestBody
|
|
17129
|
+
* @returns string Recording started or stopped
|
|
17130
|
+
* @throws ApiError
|
|
17131
|
+
*/
|
|
17132
|
+
static setAutoscalingRecording(data) {
|
|
17133
|
+
return request(OpenAPI, {
|
|
17134
|
+
method: "POST",
|
|
17135
|
+
url: "/configs/autoscaling_recording/{worker_group}",
|
|
17136
|
+
path: { worker_group: data.workerGroup },
|
|
17137
|
+
body: data.requestBody,
|
|
17138
|
+
mediaType: "application/json"
|
|
17139
|
+
});
|
|
17140
|
+
}
|
|
17141
|
+
/**
|
|
17027
17142
|
* Run an autoscaling integration once for a worker group, without recording an autoscaling event
|
|
17028
17143
|
* @param data The data for the request.
|
|
17029
17144
|
* @param data.workerGroup
|
|
@@ -20231,6 +20346,75 @@ async function runFlowAsync(path, args, scheduledInSeconds = null, doNotTrackInP
|
|
|
20231
20346
|
}).then((res) => res.text());
|
|
20232
20347
|
}
|
|
20233
20348
|
/**
|
|
20349
|
+
* Run the deployed flow at `path` with some of its steps overridden, wait for it and return
|
|
20350
|
+
* its result. Meant for test scripts.
|
|
20351
|
+
*
|
|
20352
|
+
* Each entry of `steps` maps a step id to either:
|
|
20353
|
+
* - a value: the step is skipped and returns that value, or
|
|
20354
|
+
* - a function exported from the calling script's own file: the step runs that function
|
|
20355
|
+
* instead of its own code, with the step's inputs as arguments (matched by name).
|
|
20356
|
+
*
|
|
20357
|
+
* A step inside a subflow is named by the path of step ids to it, `"sub:inner"` for step `inner`
|
|
20358
|
+
* of the subflow that step `sub` calls. It applies to every call of that subflow made by the
|
|
20359
|
+
* tested flow and by the subflows it overrides; a subflow left as is still calls the deployed
|
|
20360
|
+
* one. Those subflows, and each one on the way to an override, run as you rather than as their
|
|
20361
|
+
* on-behalf-of identity. Result caching is off for the whole test run.
|
|
20362
|
+
*
|
|
20363
|
+
* The flow's preprocessor does not run: `args` are what the flow receives after it. A subflow
|
|
20364
|
+
* never runs its own preprocessor, in a test or not. AI agent
|
|
20365
|
+
* tools cannot be overridden; override the agent step instead.
|
|
20366
|
+
*
|
|
20367
|
+
* @example
|
|
20368
|
+
* export function fakeFetch(url: string) { return { status: 200 } }
|
|
20369
|
+
* export async function main() {
|
|
20370
|
+
* const result = await wmill.testFlow("f/flows/sync", { user: "a" }, {
|
|
20371
|
+
* fetch_users: fakeFetch, // replaced logic
|
|
20372
|
+
* send_email: "sent", // mocked result
|
|
20373
|
+
* });
|
|
20374
|
+
* }
|
|
20375
|
+
* @param path - Flow path in Windmill
|
|
20376
|
+
* @param args - Arguments to pass to the flow
|
|
20377
|
+
* @param steps - Step id to mocked result, or to the function replacing the step
|
|
20378
|
+
* @param verbose - Enable verbose logging
|
|
20379
|
+
* @returns Flow execution result
|
|
20380
|
+
*/
|
|
20381
|
+
async function testFlow(path, args = null, steps = {}, verbose = false) {
|
|
20382
|
+
const jobId = await testFlowAsync(path, args, steps);
|
|
20383
|
+
return await waitJob(jobId, verbose);
|
|
20384
|
+
}
|
|
20385
|
+
/**
|
|
20386
|
+
* Like {@link testFlow}, but returns the job id without waiting for the flow to complete.
|
|
20387
|
+
*/
|
|
20388
|
+
async function testFlowAsync(path, args = null, steps = {}) {
|
|
20389
|
+
const stepOverrides = {};
|
|
20390
|
+
let usesFunction = false;
|
|
20391
|
+
for (const [id, o] of Object.entries(steps)) if (typeof o === "function") {
|
|
20392
|
+
if (!o.name) throw new Error(`step \`${id}\`: the replacing function must be a named function exported from this file`);
|
|
20393
|
+
stepOverrides[id] = { function: o.name };
|
|
20394
|
+
usesFunction = true;
|
|
20395
|
+
} else stepOverrides[id] = { return_value: o === void 0 ? null : o };
|
|
20396
|
+
const body = {
|
|
20397
|
+
args: args ?? {},
|
|
20398
|
+
steps: stepOverrides
|
|
20399
|
+
};
|
|
20400
|
+
if (usesFunction) {
|
|
20401
|
+
const callerJobId = getEnv("WM_JOB_ID");
|
|
20402
|
+
if (!callerJobId) throw new Error("replacing a step with a function only works from a script running in Windmill");
|
|
20403
|
+
body.caller_job_id = callerJobId;
|
|
20404
|
+
}
|
|
20405
|
+
const res = await fetch(`${OpenAPI.BASE}/w/${getWorkspace()}/jobs/run/flow_test/${path}`, {
|
|
20406
|
+
method: "POST",
|
|
20407
|
+
headers: {
|
|
20408
|
+
"Content-Type": "application/json",
|
|
20409
|
+
Authorization: `Bearer ${OpenAPI.TOKEN}`
|
|
20410
|
+
},
|
|
20411
|
+
body: JSON.stringify(body)
|
|
20412
|
+
});
|
|
20413
|
+
const text = await res.text();
|
|
20414
|
+
if (!res.ok) throw new Error(`testFlow failed (${res.status}): ${text}`);
|
|
20415
|
+
return text;
|
|
20416
|
+
}
|
|
20417
|
+
/**
|
|
20234
20418
|
* Resolve a resource value in case the default value was picked because the input payload was undefined
|
|
20235
20419
|
* @param obj resource value or path of the resource under the format `$res:path`
|
|
20236
20420
|
* @returns resource value
|
|
@@ -21628,6 +21812,8 @@ const wmill = {
|
|
|
21628
21812
|
runScriptByHashAsync,
|
|
21629
21813
|
runFlow,
|
|
21630
21814
|
runFlowAsync,
|
|
21815
|
+
testFlow,
|
|
21816
|
+
testFlowAsync,
|
|
21631
21817
|
waitJob,
|
|
21632
21818
|
getRootJobId,
|
|
21633
21819
|
setFlowUserState,
|
|
@@ -21811,6 +21997,8 @@ exports.streamResult = streamResult;
|
|
|
21811
21997
|
exports.task = task;
|
|
21812
21998
|
exports.taskFlow = taskFlow;
|
|
21813
21999
|
exports.taskScript = taskScript;
|
|
22000
|
+
exports.testFlow = testFlow;
|
|
22001
|
+
exports.testFlowAsync = testFlowAsync;
|
|
21814
22002
|
exports.uint8ArrayToBase64 = uint8ArrayToBase64;
|
|
21815
22003
|
exports.upsertPartition = upsertPartition;
|
|
21816
22004
|
exports.usernameToEmail = usernameToEmail;
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { OpenAPI } from "./core/OpenAPI.mjs";
|
|
|
4
4
|
import { AdminService, AgentWorkersService, AiEvalsService, AiService, AmqpTriggerService, AppService, AssetService, AuditService, AzureTriggerService, CaptureService, ConcurrencyGroupsService, ConfigService, DataMetricService, DbtService, DocumentationService, DraftService, EmailTriggerService, FavoriteService, FlowConversationsService, FlowService, FolderService, GcpTriggerService, GitSyncService, GranularAclService, GroupService, HealthService, HelpersService, HttpTriggerService, HubPublishService, IndexSearchService, InputService, IntegrationService, JobService, KafkaTriggerService, McpOauthService, McpService, MetricsService, MqttTriggerService, NativeTriggerService, NatsTriggerService, NpmProxyService, OauthService, OidcService, OpenapiService, PathAutocompleteService, PostgresTriggerService, RawAppService, ResourceService, ScheduleService, ScriptService, ServiceLogsService, SettingService, SettingsService, SlackAgentsService, SqsTriggerService, TeamsService, TokenService, TrashService, TriggerService, UserService, VariableService, VolumeService, WebsocketTriggerService, WorkerService, WorkspaceDependenciesService, WorkspaceIntegrationService, WorkspaceService } from "./services.gen.mjs";
|
|
5
5
|
import { parseS3Object } from "./s3Types.mjs";
|
|
6
6
|
import { appendPartition, datatable, ducklake, upsertPartition } from "./sqlUtils.mjs";
|
|
7
|
-
import { SHARED_FOLDER, StepSuspend, WorkflowCtx, _workflowCtx, appendToResultStream, base64ToUint8Array, cancelJob, commitKafkaOffsets, databaseUrlFromResource, deleteS3File, denoS3LightClientSettings, getApprovalUrls, getFlowUserState, getIdToken, getInternalState, getPresignedS3PublicUrl, getPresignedS3PublicUrls, getProgress, getResource, getResult, getResultMaybe, getResumeEndpoints, getResumeUrls, getRootJobId, getState, getStatePath, getVariable, getWorkspace, loadS3File, loadS3FileStream, parallel, requestInteractiveSlackApproval, requestInteractiveTeamsApproval, resolveDefaultResource, runFlow, runFlowAsync, runScript, runScriptAsync, runScriptByHash, runScriptByHashAsync, runScriptByPath, runScriptByPathAsync, setClient, setFlowUserState, setInternalState, setProgress, setResource, setState, setVariable, setWorkflowCtx, signS3Object, signS3Objects, sleep, step, streamResult, task, taskFlow, taskScript, uint8ArrayToBase64, usernameToEmail, waitForApproval, waitJob, workerHasInternalServer, workerIsDraining, workflow, writeS3File } from "./client.mjs";
|
|
7
|
+
import { SHARED_FOLDER, StepSuspend, WorkflowCtx, _workflowCtx, appendToResultStream, base64ToUint8Array, cancelJob, commitKafkaOffsets, databaseUrlFromResource, deleteS3File, denoS3LightClientSettings, getApprovalUrls, getFlowUserState, getIdToken, getInternalState, getPresignedS3PublicUrl, getPresignedS3PublicUrls, getProgress, getResource, getResult, getResultMaybe, getResumeEndpoints, getResumeUrls, getRootJobId, getState, getStatePath, getVariable, getWorkspace, loadS3File, loadS3FileStream, parallel, requestInteractiveSlackApproval, requestInteractiveTeamsApproval, resolveDefaultResource, runFlow, runFlowAsync, runScript, runScriptAsync, runScriptByHash, runScriptByHashAsync, runScriptByPath, runScriptByPathAsync, setClient, setFlowUserState, setInternalState, setProgress, setResource, setState, setVariable, setWorkflowCtx, signS3Object, signS3Objects, sleep, step, streamResult, task, taskFlow, taskScript, testFlow, testFlowAsync, uint8ArrayToBase64, usernameToEmail, waitForApproval, waitJob, workerHasInternalServer, workerIsDraining, workflow, writeS3File } from "./client.mjs";
|
|
8
8
|
|
|
9
9
|
//#region src/index.ts
|
|
10
10
|
const wmill = {
|
|
@@ -51,6 +51,8 @@ const wmill = {
|
|
|
51
51
|
runScriptByHashAsync,
|
|
52
52
|
runFlow,
|
|
53
53
|
runFlowAsync,
|
|
54
|
+
testFlow,
|
|
55
|
+
testFlowAsync,
|
|
54
56
|
waitJob,
|
|
55
57
|
getRootJobId,
|
|
56
58
|
setFlowUserState,
|
|
@@ -96,4 +98,4 @@ const wmill = {
|
|
|
96
98
|
var src_default = wmill;
|
|
97
99
|
|
|
98
100
|
//#endregion
|
|
99
|
-
export { AdminService, AgentWorkersService, AiEvalsService, AiService, AmqpTriggerService, ApiError, AppService, AssetService, AuditService, AzureTriggerService, CancelError, CancelablePromise, CaptureService, ConcurrencyGroupsService, ConfigService, DataMetricService, DbtService, DocumentationService, DraftService, EmailTriggerService, FavoriteService, FlowConversationsService, FlowService, FolderService, GcpTriggerService, GitSyncService, GranularAclService, GroupService, HealthService, HelpersService, HttpTriggerService, HubPublishService, IndexSearchService, InputService, IntegrationService, JobService, KafkaTriggerService, McpOauthService, McpService, MetricsService, MqttTriggerService, NativeTriggerService, NatsTriggerService, NpmProxyService, OauthService, OidcService, OpenAPI, OpenapiService, PathAutocompleteService, PostgresTriggerService, RawAppService, ResourceService, SHARED_FOLDER, ScheduleService, ScriptService, ServiceLogsService, SettingService, SettingsService, SlackAgentsService, SqsTriggerService, StepSuspend, TeamsService, TokenService, TrashService, TriggerService, UserService, VariableService, VolumeService, WebsocketTriggerService, WorkerService, WorkflowCtx, WorkspaceDependenciesService, WorkspaceIntegrationService, WorkspaceService, _workflowCtx, appendPartition, appendToResultStream, base64ToUint8Array, cancelJob, commitKafkaOffsets, databaseUrlFromResource, datatable, src_default as default, deleteS3File, denoS3LightClientSettings, ducklake, getApprovalUrls, getFlowUserState, getIdToken, getInternalState, getPresignedS3PublicUrl, getPresignedS3PublicUrls, getProgress, getResource, getResult, getResultMaybe, getResumeEndpoints, getResumeUrls, getRootJobId, getState, getStatePath, getVariable, getWorkspace, loadS3File, loadS3FileStream, parallel, requestInteractiveSlackApproval, requestInteractiveTeamsApproval, resolveDefaultResource, runFlow, runFlowAsync, runScript, runScriptAsync, runScriptByHash, runScriptByHashAsync, runScriptByPath, runScriptByPathAsync, setClient, setFlowUserState, setInternalState, setProgress, setResource, setState, setVariable, setWorkflowCtx, signS3Object, signS3Objects, sleep, step, streamResult, task, taskFlow, taskScript, uint8ArrayToBase64, upsertPartition, usernameToEmail, waitForApproval, waitJob, workerHasInternalServer, workerIsDraining, workflow, writeS3File };
|
|
101
|
+
export { AdminService, AgentWorkersService, AiEvalsService, AiService, AmqpTriggerService, ApiError, AppService, AssetService, AuditService, AzureTriggerService, CancelError, CancelablePromise, CaptureService, ConcurrencyGroupsService, ConfigService, DataMetricService, DbtService, DocumentationService, DraftService, EmailTriggerService, FavoriteService, FlowConversationsService, FlowService, FolderService, GcpTriggerService, GitSyncService, GranularAclService, GroupService, HealthService, HelpersService, HttpTriggerService, HubPublishService, IndexSearchService, InputService, IntegrationService, JobService, KafkaTriggerService, McpOauthService, McpService, MetricsService, MqttTriggerService, NativeTriggerService, NatsTriggerService, NpmProxyService, OauthService, OidcService, OpenAPI, OpenapiService, PathAutocompleteService, PostgresTriggerService, RawAppService, ResourceService, SHARED_FOLDER, ScheduleService, ScriptService, ServiceLogsService, SettingService, SettingsService, SlackAgentsService, SqsTriggerService, StepSuspend, TeamsService, TokenService, TrashService, TriggerService, UserService, VariableService, VolumeService, WebsocketTriggerService, WorkerService, WorkflowCtx, WorkspaceDependenciesService, WorkspaceIntegrationService, WorkspaceService, _workflowCtx, appendPartition, appendToResultStream, base64ToUint8Array, cancelJob, commitKafkaOffsets, databaseUrlFromResource, datatable, src_default as default, deleteS3File, denoS3LightClientSettings, ducklake, getApprovalUrls, getFlowUserState, getIdToken, getInternalState, getPresignedS3PublicUrl, getPresignedS3PublicUrls, getProgress, getResource, getResult, getResultMaybe, getResumeEndpoints, getResumeUrls, getRootJobId, getState, getStatePath, getVariable, getWorkspace, loadS3File, loadS3FileStream, parallel, requestInteractiveSlackApproval, requestInteractiveTeamsApproval, resolveDefaultResource, runFlow, runFlowAsync, runScript, runScriptAsync, runScriptByHash, runScriptByHashAsync, runScriptByPath, runScriptByPathAsync, setClient, setFlowUserState, setInternalState, setProgress, setResource, setState, setVariable, setWorkflowCtx, signS3Object, signS3Objects, sleep, step, streamResult, task, taskFlow, taskScript, testFlow, testFlowAsync, uint8ArrayToBase64, upsertPartition, usernameToEmail, waitForApproval, waitJob, workerHasInternalServer, workerIsDraining, workflow, writeS3File };
|