windmill-client 1.379.4 → 1.380.1
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 +2 -0
- package/dist/client.js +47 -0
- package/dist/core/OpenAPI.js +1 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -25,11 +25,13 @@ export declare function getResource(path?: string, undefinedIfEmpty?: boolean):
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function getRootJobId(jobId?: string): Promise<string>;
|
|
27
27
|
export declare function runScript(path?: string | null, hash_?: string | null, args?: Record<string, any> | null, verbose?: boolean): Promise<any>;
|
|
28
|
+
export declare function runFlow(path?: string | null, args?: Record<string, any> | null, verbose?: boolean): Promise<any>;
|
|
28
29
|
export declare function waitJob(jobId: string, verbose?: boolean): Promise<any>;
|
|
29
30
|
export declare function getResult(jobId: string): Promise<any>;
|
|
30
31
|
export declare function getResultMaybe(jobId: string): Promise<any>;
|
|
31
32
|
export declare function task<P, T>(f: (_: P) => T): (_: P) => Promise<T>;
|
|
32
33
|
export declare function runScriptAsync(path: string | null, hash_: string | null, args: Record<string, any> | null, scheduledInSeconds?: number | null): Promise<string>;
|
|
34
|
+
export declare function runFlowAsync(path: string | null, args: Record<string, any> | null, scheduledInSeconds?: number | null): Promise<string>;
|
|
33
35
|
/**
|
|
34
36
|
* Resolve a resource value in case the default value was picked because the input payload was undefined
|
|
35
37
|
* @param obj resource value or path of the resource under the format `$res:path`
|
package/dist/client.js
CHANGED
|
@@ -15,11 +15,13 @@ exports.getWorkspace = getWorkspace;
|
|
|
15
15
|
exports.getResource = getResource;
|
|
16
16
|
exports.getRootJobId = getRootJobId;
|
|
17
17
|
exports.runScript = runScript;
|
|
18
|
+
exports.runFlow = runFlow;
|
|
18
19
|
exports.waitJob = waitJob;
|
|
19
20
|
exports.getResult = getResult;
|
|
20
21
|
exports.getResultMaybe = getResultMaybe;
|
|
21
22
|
exports.task = task;
|
|
22
23
|
exports.runScriptAsync = runScriptAsync;
|
|
24
|
+
exports.runFlowAsync = runFlowAsync;
|
|
23
25
|
exports.resolveDefaultResource = resolveDefaultResource;
|
|
24
26
|
exports.getStatePath = getStatePath;
|
|
25
27
|
exports.setResource = setResource;
|
|
@@ -140,6 +142,16 @@ function runScript() {
|
|
|
140
142
|
return yield waitJob(jobId, verbose);
|
|
141
143
|
});
|
|
142
144
|
}
|
|
145
|
+
function runFlow() {
|
|
146
|
+
return __awaiter(this, arguments, void 0, function* (path = null, args = null, verbose = false) {
|
|
147
|
+
args = args || {};
|
|
148
|
+
if (verbose) {
|
|
149
|
+
console.info(`running \`${path}\` synchronously with args:`, args);
|
|
150
|
+
}
|
|
151
|
+
const jobId = yield runFlowAsync(path, args);
|
|
152
|
+
return yield waitJob(jobId, verbose);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
143
155
|
function waitJob(jobId_1) {
|
|
144
156
|
return __awaiter(this, arguments, void 0, function* (jobId, verbose = false) {
|
|
145
157
|
while (true) {
|
|
@@ -252,6 +264,41 @@ function runScriptAsync(path_1, hash_1, args_1) {
|
|
|
252
264
|
}).then((res) => res.text());
|
|
253
265
|
});
|
|
254
266
|
}
|
|
267
|
+
function runFlowAsync(path_1, args_1) {
|
|
268
|
+
return __awaiter(this, arguments, void 0, function* (path, args, scheduledInSeconds = null) {
|
|
269
|
+
// Create a script job and return its job id.
|
|
270
|
+
args = args || {};
|
|
271
|
+
const params = {};
|
|
272
|
+
if (scheduledInSeconds) {
|
|
273
|
+
params["scheduled_in_secs"] = scheduledInSeconds;
|
|
274
|
+
}
|
|
275
|
+
let parentJobId = getEnv("WM_JOB_ID");
|
|
276
|
+
if (parentJobId !== undefined) {
|
|
277
|
+
params["parent_job"] = parentJobId;
|
|
278
|
+
}
|
|
279
|
+
let rootJobId = getEnv("WM_ROOT_FLOW_JOB_ID");
|
|
280
|
+
if (rootJobId != undefined && rootJobId != "") {
|
|
281
|
+
params["root_job"] = rootJobId;
|
|
282
|
+
}
|
|
283
|
+
let endpoint;
|
|
284
|
+
if (path) {
|
|
285
|
+
endpoint = `/w/${getWorkspace()}/jobs/run/f/${path}`;
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
throw new Error("path must be provided");
|
|
289
|
+
}
|
|
290
|
+
let url = new URL(index_2.OpenAPI.BASE + endpoint);
|
|
291
|
+
url.search = new URLSearchParams(params).toString();
|
|
292
|
+
return fetch(url, {
|
|
293
|
+
method: "POST",
|
|
294
|
+
headers: {
|
|
295
|
+
"Content-Type": "application/json",
|
|
296
|
+
Authorization: `Bearer ${index_2.OpenAPI.TOKEN}`,
|
|
297
|
+
},
|
|
298
|
+
body: JSON.stringify(args),
|
|
299
|
+
}).then((res) => res.text());
|
|
300
|
+
});
|
|
301
|
+
}
|
|
255
302
|
/**
|
|
256
303
|
* Resolve a resource value in case the default value was picked because the input payload was undefined
|
|
257
304
|
* @param obj resource value or path of the resource under the format `$res:path`
|
package/dist/core/OpenAPI.js
CHANGED