windmill-client 1.286.1 → 1.287.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 +1 -1
- package/dist/client.js +7 -7
- package/dist/core/OpenAPI.js +1 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ 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 waitJob(jobId: string, verbose?: boolean
|
|
28
|
+
export declare function waitJob(jobId: string, verbose?: boolean): Promise<any>;
|
|
29
29
|
export declare function getResult(jobId: string): Promise<any>;
|
|
30
30
|
export declare function getResultMaybe(jobId: string): Promise<any>;
|
|
31
31
|
export declare function task<P, T>(f: (_: P) => T): (_: P) => Promise<T>;
|
package/dist/client.js
CHANGED
|
@@ -116,11 +116,11 @@ function runScript(path = null, hash_ = null, args = null, verbose = false) {
|
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
exports.runScript = runScript;
|
|
119
|
-
function waitJob(jobId, verbose = false
|
|
119
|
+
function waitJob(jobId, verbose = false) {
|
|
120
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
121
|
while (true) {
|
|
122
122
|
// Implement your HTTP request logic here to get job result
|
|
123
|
-
const resultRes = yield
|
|
123
|
+
const resultRes = yield getResultMaybe(jobId);
|
|
124
124
|
const started = resultRes.started;
|
|
125
125
|
const completed = resultRes.completed;
|
|
126
126
|
const success = resultRes.success;
|
|
@@ -130,14 +130,11 @@ function waitJob(jobId, verbose = false, assertResultIsNotNull = false) {
|
|
|
130
130
|
if (completed) {
|
|
131
131
|
const result = resultRes.result;
|
|
132
132
|
if (success) {
|
|
133
|
-
if (result === null && assertResultIsNotNull) {
|
|
134
|
-
throw new Error("Result was null");
|
|
135
|
-
}
|
|
136
133
|
return result;
|
|
137
134
|
}
|
|
138
135
|
else {
|
|
139
136
|
const error = result.error;
|
|
140
|
-
throw new Error(`Job ${jobId} was not successful: ${error}`);
|
|
137
|
+
throw new Error(`Job ${jobId} was not successful: ${JSON.stringify(error)}`);
|
|
141
138
|
}
|
|
142
139
|
}
|
|
143
140
|
if (verbose) {
|
|
@@ -190,7 +187,10 @@ function task(f) {
|
|
|
190
187
|
body: JSON.stringify({ args }),
|
|
191
188
|
});
|
|
192
189
|
let jobId = yield req.text();
|
|
193
|
-
|
|
190
|
+
console.log(`Started task ${f.name} as job ${jobId}`);
|
|
191
|
+
let r = yield waitJob(jobId);
|
|
192
|
+
console.log(`Task ${f.name} (${jobId}) completed`);
|
|
193
|
+
return r;
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
exports.task = task;
|
package/dist/core/OpenAPI.js
CHANGED