windmill-client 1.261.0 → 1.262.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 +6 -0
- package/dist/client.js +25 -8
- package/dist/core/OpenAPI.js +1 -1
- package/dist/services/JobService.d.ts +9 -0
- package/dist/services/JobService.js +15 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ export declare function getWorkspace(): string;
|
|
|
18
18
|
* @returns resource value
|
|
19
19
|
*/
|
|
20
20
|
export declare function getResource(path?: string, undefinedIfEmpty?: boolean): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Get a resource value by path
|
|
23
|
+
* @param jobId job id to get the root job id from (default to current job)
|
|
24
|
+
* @returns root job id
|
|
25
|
+
*/
|
|
26
|
+
export declare function getRootJobId(jobId?: string): Promise<string>;
|
|
21
27
|
/**
|
|
22
28
|
* Resolve a resource value in case the default value was picked because the input payload was undefined
|
|
23
29
|
* @param obj resource value or path of the resource under the format `$res:path`
|
package/dist/client.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.uint8ArrayToBase64 = exports.base64ToUint8Array = exports.getIdToken = exports.getResumeEndpoints = exports.getResumeUrls = exports.writeS3File = exports.loadS3FileStream = exports.loadS3File = exports.denoS3LightClientSettings = exports.databaseUrlFromResource = exports.setVariable = exports.getVariable = exports.getState = exports.getInternalState = exports.setState = exports.setInternalState = exports.setResource = exports.getStatePath = exports.resolveDefaultResource = exports.getResource = exports.getWorkspace = exports.setClient = exports.SHARED_FOLDER = exports.WorkspaceService = exports.UserService = exports.SettingsService = exports.ScheduleService = exports.ScriptService = exports.VariableService = exports.ResourceService = exports.JobService = exports.GroupService = exports.GranularAclService = exports.FlowService = exports.AuditService = exports.AdminService = void 0;
|
|
12
|
+
exports.uint8ArrayToBase64 = exports.base64ToUint8Array = exports.getIdToken = exports.getResumeEndpoints = exports.getResumeUrls = exports.writeS3File = exports.loadS3FileStream = exports.loadS3File = exports.denoS3LightClientSettings = exports.databaseUrlFromResource = exports.setVariable = exports.getVariable = exports.getState = exports.getInternalState = exports.setState = exports.setInternalState = exports.setResource = exports.getStatePath = exports.resolveDefaultResource = exports.getRootJobId = exports.getResource = exports.getWorkspace = exports.setClient = exports.SHARED_FOLDER = exports.WorkspaceService = exports.UserService = exports.SettingsService = exports.ScheduleService = exports.ScriptService = exports.VariableService = exports.ResourceService = exports.JobService = exports.GroupService = exports.GranularAclService = exports.FlowService = exports.AuditService = exports.AdminService = void 0;
|
|
13
13
|
const index_1 = require("./index");
|
|
14
14
|
const index_2 = require("./index");
|
|
15
15
|
var index_3 = require("./index");
|
|
@@ -88,6 +88,23 @@ function getResource(path, undefinedIfEmpty) {
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
exports.getResource = getResource;
|
|
91
|
+
/**
|
|
92
|
+
* Get a resource value by path
|
|
93
|
+
* @param jobId job id to get the root job id from (default to current job)
|
|
94
|
+
* @returns root job id
|
|
95
|
+
*/
|
|
96
|
+
function getRootJobId(jobId) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
!clientSet && setClient();
|
|
99
|
+
const workspace = getWorkspace();
|
|
100
|
+
jobId = jobId !== null && jobId !== void 0 ? jobId : getEnv("WM_JOB_ID");
|
|
101
|
+
if (jobId === undefined) {
|
|
102
|
+
throw Error("Job ID not set");
|
|
103
|
+
}
|
|
104
|
+
return yield index_1.JobService.getRootJobId({ workspace, id: jobId });
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
exports.getRootJobId = getRootJobId;
|
|
91
108
|
/**
|
|
92
109
|
* Resolve a resource value in case the default value was picked because the input payload was undefined
|
|
93
110
|
* @param obj resource value or path of the resource under the format `$res:path`
|
|
@@ -319,12 +336,12 @@ function loadS3File(s3object, s3ResourcePath) {
|
|
|
319
336
|
chunks.push(chunk);
|
|
320
337
|
}
|
|
321
338
|
let fileContentLength = 0;
|
|
322
|
-
chunks.forEach(item => {
|
|
339
|
+
chunks.forEach((item) => {
|
|
323
340
|
fileContentLength += item.length;
|
|
324
341
|
});
|
|
325
342
|
let fileContent = new Uint8Array(fileContentLength);
|
|
326
343
|
let offset = 0;
|
|
327
|
-
chunks.forEach(chunk => {
|
|
344
|
+
chunks.forEach((chunk) => {
|
|
328
345
|
fileContent.set(chunk, offset);
|
|
329
346
|
offset += chunk.length;
|
|
330
347
|
});
|
|
@@ -352,9 +369,9 @@ function loadS3FileStream(s3object, s3ResourcePath) {
|
|
|
352
369
|
const queryParams = new URLSearchParams(params);
|
|
353
370
|
// We use raw fetch here b/c OpenAPI generated client doesn't handle Blobs nicely
|
|
354
371
|
const fileContentBlob = yield fetch(`${index_2.OpenAPI.BASE}/w/${getWorkspace()}/job_helpers/download_s3_file?${queryParams}`, {
|
|
355
|
-
method:
|
|
372
|
+
method: "GET",
|
|
356
373
|
headers: {
|
|
357
|
-
|
|
374
|
+
Authorization: `Bearer ${index_2.OpenAPI.TOKEN}`,
|
|
358
375
|
},
|
|
359
376
|
});
|
|
360
377
|
return fileContentBlob.blob();
|
|
@@ -374,9 +391,9 @@ function writeS3File(s3object, fileContent, s3ResourcePath) {
|
|
|
374
391
|
return __awaiter(this, void 0, void 0, function* () {
|
|
375
392
|
!clientSet && setClient();
|
|
376
393
|
let fileContentBlob;
|
|
377
|
-
if (typeof fileContent ===
|
|
394
|
+
if (typeof fileContent === "string") {
|
|
378
395
|
fileContentBlob = new Blob([fileContent], {
|
|
379
|
-
type:
|
|
396
|
+
type: "text/plain",
|
|
380
397
|
});
|
|
381
398
|
}
|
|
382
399
|
else {
|
|
@@ -390,7 +407,7 @@ function writeS3File(s3object, fileContent, s3ResourcePath) {
|
|
|
390
407
|
requestBody: fileContentBlob,
|
|
391
408
|
});
|
|
392
409
|
return {
|
|
393
|
-
s3: response.file_key
|
|
410
|
+
s3: response.file_key,
|
|
394
411
|
};
|
|
395
412
|
});
|
|
396
413
|
}
|
package/dist/core/OpenAPI.js
CHANGED
|
@@ -697,6 +697,15 @@ export declare class JobService {
|
|
|
697
697
|
workspace: string;
|
|
698
698
|
id: string;
|
|
699
699
|
}): CancelablePromise<Job>;
|
|
700
|
+
/**
|
|
701
|
+
* get root job id
|
|
702
|
+
* @returns string get root job id
|
|
703
|
+
* @throws ApiError
|
|
704
|
+
*/
|
|
705
|
+
static getRootJobId({ workspace, id, }: {
|
|
706
|
+
workspace: string;
|
|
707
|
+
id: string;
|
|
708
|
+
}): CancelablePromise<string>;
|
|
700
709
|
/**
|
|
701
710
|
* get job logs
|
|
702
711
|
* @returns string job details
|
|
@@ -465,6 +465,21 @@ class JobService {
|
|
|
465
465
|
},
|
|
466
466
|
});
|
|
467
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* get root job id
|
|
470
|
+
* @returns string get root job id
|
|
471
|
+
* @throws ApiError
|
|
472
|
+
*/
|
|
473
|
+
static getRootJobId({ workspace, id, }) {
|
|
474
|
+
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
475
|
+
method: 'GET',
|
|
476
|
+
url: '/w/{workspace}/jobs_u/get_root_job_id/{id}',
|
|
477
|
+
path: {
|
|
478
|
+
'workspace': workspace,
|
|
479
|
+
'id': id,
|
|
480
|
+
},
|
|
481
|
+
});
|
|
482
|
+
}
|
|
468
483
|
/**
|
|
469
484
|
* get job logs
|
|
470
485
|
* @returns string job details
|