windmill-client 1.261.0 → 1.263.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 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: 'GET',
372
+ method: "GET",
356
373
  headers: {
357
- 'Authorization': `Bearer ${index_2.OpenAPI.TOKEN}`,
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 === 'string') {
394
+ if (typeof fileContent === "string") {
378
395
  fileContentBlob = new Blob([fileContent], {
379
- type: 'text/plain'
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
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpenAPI = void 0;
4
4
  exports.OpenAPI = {
5
5
  BASE: '/api',
6
- VERSION: '1.261.0',
6
+ VERSION: '1.263.0',
7
7
  WITH_CREDENTIALS: false,
8
8
  CREDENTIALS: 'include',
9
9
  TOKEN: undefined,
@@ -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
@@ -12,7 +12,7 @@ export declare class WorkerService {
12
12
  * @returns WorkerPing a list of workers
13
13
  * @throws ApiError
14
14
  */
15
- static listWorkers({ page, perPage, }: {
15
+ static listWorkers({ page, perPage, pingSince, }: {
16
16
  /**
17
17
  * which page to return (start at 1, default 1)
18
18
  */
@@ -21,6 +21,10 @@ export declare class WorkerService {
21
21
  * number of items to return for a given page (default 30, max 100)
22
22
  */
23
23
  perPage?: number;
24
+ /**
25
+ * number of seconds the worker must have had a last ping more recent of (default to 300)
26
+ */
27
+ pingSince?: number;
24
28
  }): CancelablePromise<Array<WorkerPing>>;
25
29
  /**
26
30
  * exists worker with tag
@@ -20,13 +20,14 @@ class WorkerService {
20
20
  * @returns WorkerPing a list of workers
21
21
  * @throws ApiError
22
22
  */
23
- static listWorkers({ page, perPage, }) {
23
+ static listWorkers({ page, perPage, pingSince, }) {
24
24
  return (0, request_1.request)(OpenAPI_1.OpenAPI, {
25
25
  method: 'GET',
26
26
  url: '/workers/list',
27
27
  query: {
28
28
  'page': page,
29
29
  'per_page': perPage,
30
+ 'ping_since': pingSince,
30
31
  },
31
32
  });
32
33
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "windmill-client",
3
3
  "description": "Windmill SDK client for browsers and Node.js",
4
- "version": "1.261.0",
4
+ "version": "1.263.0",
5
5
  "author": "Ruben Fiszel",
6
6
  "license": "Apache 2.0",
7
7
  "devDependencies": {