windmill-client 1.253.2 → 1.253.7

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
@@ -1,4 +1,4 @@
1
- import { DenoS3LightClientSettings } from "./s3Types";
1
+ import { DenoS3LightClientSettings, type S3Object } from "./s3Types";
2
2
  export { AdminService, AuditService, FlowService, GranularAclService, GroupService, JobService, ResourceService, VariableService, ScriptService, ScheduleService, SettingsService, UserService, WorkspaceService, } from "./index";
3
3
  export type Sql = string;
4
4
  export type Email = string;
@@ -68,6 +68,27 @@ export declare function getVariable(path: string): Promise<string>;
68
68
  export declare function setVariable(path: string, value: string, isSecretIfNotExist?: boolean, descriptionIfNotExist?: string): Promise<void>;
69
69
  export declare function databaseUrlFromResource(path: string): Promise<string>;
70
70
  export declare function denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<DenoS3LightClientSettings>;
71
+ /**
72
+ * Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
73
+ *
74
+ * ```typescript
75
+ * let fileContentStream = await wmill.loadS3File(inputFile)
76
+ * // if the file is a raw text file, it can be decoded and printed directly:
77
+ * const text = new TextDecoder().decode(fileContentStream)
78
+ * console.log(text);
79
+ * ```
80
+ */
81
+ export declare function loadS3File(s3object: S3Object, s3ResourcePath: string | undefined): Promise<Uint8Array | undefined>;
82
+ /**
83
+ * Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
84
+ *
85
+ * ```typescript
86
+ * const s3object = await writeS3File(s3Object, "Hello Windmill!")
87
+ * const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
88
+ * console.log(fileContentAsUtf8Str)
89
+ * ```
90
+ */
91
+ export declare function writeS3File(s3object: S3Object | undefined, fileContent: string | ReadableStream<Uint8Array>, fileExpiration: Date | undefined, s3ResourcePath: string | undefined): Promise<S3Object>;
71
92
  /**
72
93
  * Get URLs needed for resuming a flow after this step
73
94
  * @param approver approver name
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.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.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;
13
13
  const index_1 = require("./index");
14
14
  const index_2 = require("./index");
15
15
  var index_3 = require("./index");
@@ -291,23 +291,153 @@ function denoS3LightClientSettings(s3_resource_path) {
291
291
  });
292
292
  }
293
293
  exports.denoS3LightClientSettings = denoS3LightClientSettings;
294
- // export async function loadS3File(
295
- // s3object: S3Object,
296
- // s3ResourcePath: string | undefined
297
- // ): Promise<Response> {
298
- // const settings = await denoS3LightClientSettings(s3ResourcePath);
299
- // const s3 = new S3Client(settings);
300
- // return await s3.getObject(s3object.s3);
301
- // }
302
- // export async function writeS3File(
303
- // s3object: S3Object,
304
- // fileContent: ReadableStream<Uint8Array> | Uint8Array | string,
305
- // s3ResourcePath: string | undefined
306
- // ): Promise<Response> {
307
- // const settings = await denoS3LightClientSettings(s3ResourcePath);
308
- // const s3 = new S3Client(settings);
309
- // return await s3.putObject(s3object.s3, fileContent);
310
- // }
294
+ /**
295
+ * Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
296
+ *
297
+ * ```typescript
298
+ * let fileContentStream = await wmill.loadS3File(inputFile)
299
+ * // if the file is a raw text file, it can be decoded and printed directly:
300
+ * const text = new TextDecoder().decode(fileContentStream)
301
+ * console.log(text);
302
+ * ```
303
+ */
304
+ function loadS3File(s3object, s3ResourcePath) {
305
+ return __awaiter(this, void 0, void 0, function* () {
306
+ !clientSet && setClient();
307
+ let part_number = 0;
308
+ let file_total_size = undefined;
309
+ let fetch = function (controller) {
310
+ return __awaiter(this, void 0, void 0, function* () {
311
+ // console.log("fetching part", part_number)
312
+ if (part_number === undefined || part_number === null) {
313
+ // console.log("finished, closing")
314
+ controller.close();
315
+ return;
316
+ }
317
+ let part_response = yield index_1.HelpersService.multipartFileDownload({
318
+ workspace: getWorkspace(),
319
+ requestBody: {
320
+ file_key: s3object.s3,
321
+ part_number: part_number,
322
+ file_size: file_total_size,
323
+ s3_resource_path: s3ResourcePath,
324
+ }
325
+ });
326
+ if (part_response.part_content.length > 0) {
327
+ // console.log("enqueueing part", part_number, part_response.part_content.length)
328
+ let chunk = new Uint8Array(part_response.part_content.length);
329
+ part_response.part_content.forEach((value, index) => {
330
+ chunk[index] = value;
331
+ });
332
+ controller.enqueue(chunk);
333
+ }
334
+ part_number = part_response.next_part_number;
335
+ file_total_size = part_response.file_size;
336
+ });
337
+ };
338
+ let fileContentStream = new ReadableStream({
339
+ pull(controller) {
340
+ return __awaiter(this, void 0, void 0, function* () {
341
+ yield fetch(controller);
342
+ });
343
+ }
344
+ });
345
+ // For now we read all the stream in here. In the future return the stream and let the users consume it as they wish
346
+ const reader = fileContentStream.getReader();
347
+ const chunks = [];
348
+ while (true) {
349
+ const { value: chunk, done } = yield reader.read();
350
+ if (done) {
351
+ break;
352
+ }
353
+ chunks.push(chunk);
354
+ }
355
+ let fileContentLength = 0;
356
+ chunks.forEach(item => {
357
+ fileContentLength += item.length;
358
+ });
359
+ let fileContent = new Uint8Array(fileContentLength);
360
+ let offset = 0;
361
+ chunks.forEach(chunk => {
362
+ fileContent.set(chunk, offset);
363
+ offset += chunk.length;
364
+ });
365
+ return fileContent;
366
+ });
367
+ }
368
+ exports.loadS3File = loadS3File;
369
+ /**
370
+ * Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
371
+ *
372
+ * ```typescript
373
+ * const s3object = await writeS3File(s3Object, "Hello Windmill!")
374
+ * const fileContentAsUtf8Str = (await s3object.toArray()).toString('utf-8')
375
+ * console.log(fileContentAsUtf8Str)
376
+ * ```
377
+ */
378
+ function writeS3File(s3object, fileContent, fileExpiration, s3ResourcePath) {
379
+ return __awaiter(this, void 0, void 0, function* () {
380
+ !clientSet && setClient();
381
+ let fileContentStream;
382
+ if (typeof fileContent === 'string') {
383
+ fileContentStream = new Blob([fileContent], {
384
+ type: 'text/plain'
385
+ }).stream();
386
+ }
387
+ else {
388
+ fileContentStream = fileContent;
389
+ }
390
+ let path = s3object === null || s3object === void 0 ? void 0 : s3object.s3;
391
+ let upload_id = undefined;
392
+ let parts = [];
393
+ const reader = fileContentStream.getReader();
394
+ let { value: chunk, done: readerDone } = yield reader.read();
395
+ if (chunk === undefined || readerDone) {
396
+ throw Error('Error reading stream, no data read');
397
+ }
398
+ while (true) {
399
+ let { value: chunk_2, done: readerDone } = yield reader.read();
400
+ if (!readerDone && chunk_2 !== undefined && chunk.length <= 5 * 1024 * 1024) {
401
+ // AWS enforces part to be bigger than 5MB, so we accumulate bytes until we reach that limit before triggering the request to the BE
402
+ chunk = new Uint8Array([...chunk, ...chunk_2]);
403
+ continue;
404
+ }
405
+ try {
406
+ let response = yield index_1.HelpersService.multipartFileUpload({
407
+ workspace: getWorkspace(),
408
+ requestBody: {
409
+ file_key: path,
410
+ file_extension: undefined,
411
+ part_content: Array.from(chunk),
412
+ upload_id: upload_id,
413
+ parts: parts,
414
+ is_final: readerDone,
415
+ cancel_upload: false,
416
+ s3_resource_path: s3ResourcePath,
417
+ file_expiration: fileExpiration === null || fileExpiration === void 0 ? void 0 : fileExpiration.toString(),
418
+ }
419
+ });
420
+ path = response.file_key;
421
+ upload_id = response.upload_id;
422
+ parts = response.parts;
423
+ if (response.is_done) {
424
+ break;
425
+ }
426
+ if (chunk_2 === undefined) {
427
+ throw Error('File upload is not finished, yet there is no more data to stream. This is unexpected');
428
+ }
429
+ chunk = chunk_2;
430
+ }
431
+ catch (e) {
432
+ throw Error(`Unexpected error uploading data to S3 ${e}`);
433
+ }
434
+ }
435
+ return {
436
+ s3: path
437
+ };
438
+ });
439
+ }
440
+ exports.writeS3File = writeS3File;
311
441
  /**
312
442
  * Get URLs needed for resuming a flow after this step
313
443
  * @param approver approver name
@@ -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.253.2',
6
+ VERSION: '1.253.7',
7
7
  WITH_CREDENTIALS: false,
8
8
  CREDENTIALS: 'include',
9
9
  TOKEN: undefined,
@@ -192,7 +192,6 @@ const sendRequest = (config, options, url, body, formData, headers, onCancel) =>
192
192
  method: options.method,
193
193
  signal: controller.signal,
194
194
  };
195
- request.referrerPolicy = "no-referrer";
196
195
  if (config.WITH_CREDENTIALS) {
197
196
  request.credentials = config.CREDENTIALS;
198
197
  }
package/dist/index.d.ts CHANGED
@@ -175,4 +175,4 @@ export { VariableService } from './services/VariableService';
175
175
  export { WorkerService } from './services/WorkerService';
176
176
  export { WorkspaceService } from './services/WorkspaceService';
177
177
  export type { S3Object, DenoS3LightClientSettings } from "./s3Types";
178
- export { setClient, getVariable, setVariable, getResource, setResource, getResumeUrls, setState, getState, getIdToken, denoS3LightClientSettings } from "./client";
178
+ export { setClient, getVariable, setVariable, getResource, setResource, getResumeUrls, setState, getState, getIdToken, denoS3LightClientSettings, loadS3File, writeS3File } from "./client";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserService = exports.SettingsService = exports.SettingService = exports.ScriptService = exports.ScheduleService = exports.ResourceService = exports.RawAppService = exports.OidcService = exports.OauthService = exports.MetricsService = exports.JobService = exports.IntegrationService = exports.InputService = exports.HelpersService = exports.GroupService = exports.GranularAclService = exports.FolderService = exports.FlowService = exports.FavoriteService = exports.DraftService = exports.ConfigService = exports.ConcurrencyGroupsService = exports.CaptureService = exports.AuditService = exports.AppService = exports.AdminService = exports.WindmillFilePreview = exports.Script = exports.RunnableType = exports.RawScriptForDependencies = exports.RawScript = exports.QueuedJob = exports.Preview = exports.Policy = exports.NewScript = exports.MainArgSignature = exports.ListableApp = exports.LargeFileStorage = exports.Job = exports.Http = exports.GlobalUserInfo = exports.FlowStatusModule = exports.CompletedJob = exports.AuditLog = exports.AppWithLastVersion = exports.ActionKind = exports.OpenAPI = exports.CancelError = exports.CancelablePromise = exports.ApiError = void 0;
4
- exports.denoS3LightClientSettings = exports.getIdToken = exports.getState = exports.setState = exports.getResumeUrls = exports.setResource = exports.getResource = exports.setVariable = exports.getVariable = exports.setClient = exports.WorkspaceService = exports.WorkerService = exports.VariableService = void 0;
4
+ exports.writeS3File = exports.loadS3File = exports.denoS3LightClientSettings = exports.getIdToken = exports.getState = exports.setState = exports.getResumeUrls = exports.setResource = exports.getResource = exports.setVariable = exports.getVariable = exports.setClient = exports.WorkspaceService = exports.WorkerService = exports.VariableService = void 0;
5
5
  /* generated using openapi-typescript-codegen -- do no edit */
6
6
  /* istanbul ignore file */
7
7
  /* tslint:disable */
@@ -122,3 +122,5 @@ Object.defineProperty(exports, "setState", { enumerable: true, get: function ()
122
122
  Object.defineProperty(exports, "getState", { enumerable: true, get: function () { return client_1.getState; } });
123
123
  Object.defineProperty(exports, "getIdToken", { enumerable: true, get: function () { return client_1.getIdToken; } });
124
124
  Object.defineProperty(exports, "denoS3LightClientSettings", { enumerable: true, get: function () { return client_1.denoS3LightClientSettings; } });
125
+ Object.defineProperty(exports, "loadS3File", { enumerable: true, get: function () { return client_1.loadS3File; } });
126
+ Object.defineProperty(exports, "writeS3File", { enumerable: true, get: function () { return client_1.writeS3File; } });
@@ -1,6 +1,7 @@
1
1
  export type LargeFileStorage = {
2
2
  type?: LargeFileStorage.type;
3
3
  s3_resource_path?: string;
4
+ public_resource?: boolean;
4
5
  };
5
6
  export declare namespace LargeFileStorage {
6
7
  enum type {
@@ -123,6 +123,7 @@ export declare class HelpersService {
123
123
  }): CancelablePromise<{
124
124
  next_marker?: string;
125
125
  windmill_large_files: Array<WindmillLargeFile>;
126
+ restricted_access?: boolean;
126
127
  }>;
127
128
  /**
128
129
  * Load metadata of the file
@@ -148,6 +149,20 @@ export declare class HelpersService {
148
149
  readBytesFrom?: number;
149
150
  readBytesLength?: number;
150
151
  }): CancelablePromise<WindmillFilePreview>;
152
+ /**
153
+ * Load a preview of a parquet file
154
+ * @returns any Parquet Preview
155
+ * @throws ApiError
156
+ */
157
+ static loadParquetPreview({ workspace, path, offset, limit, sortCol, sortDesc, search, }: {
158
+ workspace: string;
159
+ path: string;
160
+ offset?: number;
161
+ limit?: number;
162
+ sortCol?: string;
163
+ sortDesc?: boolean;
164
+ search?: string;
165
+ }): CancelablePromise<any>;
151
166
  /**
152
167
  * Generate a unique URL to download the file
153
168
  * @returns any Download URL
@@ -197,6 +212,7 @@ export declare class HelpersService {
197
212
  is_final: boolean;
198
213
  cancel_upload: boolean;
199
214
  s3_resource_path?: string;
215
+ file_expiration?: string;
200
216
  };
201
217
  }): CancelablePromise<{
202
218
  upload_id: string;
@@ -204,4 +220,25 @@ export declare class HelpersService {
204
220
  is_done: boolean;
205
221
  file_key: string;
206
222
  }>;
223
+ /**
224
+ * Download file to S3 bucket
225
+ * @returns any Chunk of the downloaded file
226
+ * @throws ApiError
227
+ */
228
+ static multipartFileDownload({ workspace, requestBody, }: {
229
+ workspace: string;
230
+ /**
231
+ * Query args for a multipart file upload to S3
232
+ */
233
+ requestBody: {
234
+ file_key: string;
235
+ part_number: number;
236
+ file_size?: number;
237
+ s3_resource_path?: string;
238
+ };
239
+ }): CancelablePromise<{
240
+ file_size?: number;
241
+ part_content: Array<number>;
242
+ next_part_number?: number;
243
+ }>;
207
244
  }
@@ -156,6 +156,28 @@ class HelpersService {
156
156
  },
157
157
  });
158
158
  }
159
+ /**
160
+ * Load a preview of a parquet file
161
+ * @returns any Parquet Preview
162
+ * @throws ApiError
163
+ */
164
+ static loadParquetPreview({ workspace, path, offset, limit, sortCol, sortDesc, search, }) {
165
+ return (0, request_1.request)(OpenAPI_1.OpenAPI, {
166
+ method: 'GET',
167
+ url: '/w/{workspace}/job_helpers/load_parquet_preview/{path}',
168
+ path: {
169
+ 'workspace': workspace,
170
+ 'path': path,
171
+ },
172
+ query: {
173
+ 'offset': offset,
174
+ 'limit': limit,
175
+ 'sort_col': sortCol,
176
+ 'sort_desc': sortDesc,
177
+ 'search': search,
178
+ },
179
+ });
180
+ }
159
181
  /**
160
182
  * Generate a unique URL to download the file
161
183
  * @returns any Download URL
@@ -224,5 +246,21 @@ class HelpersService {
224
246
  mediaType: 'application/json',
225
247
  });
226
248
  }
249
+ /**
250
+ * Download file to S3 bucket
251
+ * @returns any Chunk of the downloaded file
252
+ * @throws ApiError
253
+ */
254
+ static multipartFileDownload({ workspace, requestBody, }) {
255
+ return (0, request_1.request)(OpenAPI_1.OpenAPI, {
256
+ method: 'POST',
257
+ url: '/w/{workspace}/job_helpers/multipart_download_s3_file',
258
+ path: {
259
+ 'workspace': workspace,
260
+ },
261
+ body: requestBody,
262
+ mediaType: 'application/json',
263
+ });
264
+ }
227
265
  }
228
266
  exports.HelpersService = HelpersService;
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.253.2",
4
+ "version": "1.253.7",
5
5
  "author": "Ruben Fiszel",
6
6
  "license": "Apache 2.0",
7
7
  "devDependencies": {