windmill-client 1.258.4 → 1.259.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
@@ -72,7 +72,7 @@ export declare function denoS3LightClientSettings(s3_resource_path: string | und
72
72
  * Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
73
73
  *
74
74
  * ```typescript
75
- * let fileContent = await wmill.loadS3File(inputFile)
75
+ * let fileContent = await wmill.loadS3FileContent(inputFile)
76
76
  * // if the file is a raw text file, it can be decoded and printed directly:
77
77
  * const text = new TextDecoder().decode(fileContentStream)
78
78
  * console.log(text);
@@ -83,24 +83,12 @@ export declare function loadS3File(s3object: S3Object, s3ResourcePath: string |
83
83
  * Load the content of a file stored in S3 as a stream. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
84
84
  *
85
85
  * ```typescript
86
- * let fileContentStream = await wmill.loadS3FileStream(inputFile)
87
- * // Use a read to read the stream:
88
- * const chunks: Uint8Array[] = [];
89
- * const reader = fileContentStream.getReader()
90
- * while (true) {
91
- * const {value, done} = await reader.read();
92
- * if (done) {
93
- * break;
94
- * }
95
- * chunks.push(chunk);
96
- * }
97
- * // then the chunks can be concatenated into a single Uint8Array and if the
98
- * // file is a raw text file, it can be decoded and printed directly:
99
- * const text = new TextDecoder().decode(fileContent)
100
- * console.log(text);
86
+ * let fileContentBlob = await wmill.loadS3FileStream(inputFile)
87
+ * // if the content is plain text, the blob can be read directly:
88
+ * console.log(await fileContentBlob.text());
101
89
  * ```
102
90
  */
103
- export declare function loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined): Promise<ReadableStream | undefined>;
91
+ export declare function loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined): Promise<Blob | undefined>;
104
92
  /**
105
93
  * Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
106
94
  *
@@ -110,7 +98,7 @@ export declare function loadS3FileStream(s3object: S3Object, s3ResourcePath: str
110
98
  * console.log(fileContentAsUtf8Str)
111
99
  * ```
112
100
  */
113
- export declare function writeS3File(s3object: S3Object | undefined, fileContent: string | ReadableStream<Uint8Array>, fileExpiration: Date | undefined, s3ResourcePath: string | undefined): Promise<S3Object>;
101
+ export declare function writeS3File(s3object: S3Object | undefined, fileContent: string | Blob, s3ResourcePath: string | undefined): Promise<S3Object>;
114
102
  /**
115
103
  * Get URLs needed for resuming a flow after this step
116
104
  * @param approver approver name
package/dist/client.js CHANGED
@@ -295,7 +295,7 @@ exports.denoS3LightClientSettings = denoS3LightClientSettings;
295
295
  * Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
296
296
  *
297
297
  * ```typescript
298
- * let fileContent = await wmill.loadS3File(inputFile)
298
+ * let fileContent = await wmill.loadS3FileContent(inputFile)
299
299
  * // if the file is a raw text file, it can be decoded and printed directly:
300
300
  * const text = new TextDecoder().decode(fileContentStream)
301
301
  * console.log(text);
@@ -304,12 +304,12 @@ exports.denoS3LightClientSettings = denoS3LightClientSettings;
304
304
  function loadS3File(s3object, s3ResourcePath) {
305
305
  return __awaiter(this, void 0, void 0, function* () {
306
306
  !clientSet && setClient();
307
- const fileContentStream = yield loadS3FileStream(s3object, s3ResourcePath);
308
- if (fileContentStream === undefined) {
307
+ const fileContentBlob = yield loadS3FileStream(s3object, s3ResourcePath);
308
+ if (fileContentBlob === undefined) {
309
309
  return undefined;
310
310
  }
311
311
  // we read the stream until completion and put the content in an Uint8Array
312
- const reader = fileContentStream.getReader();
312
+ const reader = fileContentBlob.stream().getReader();
313
313
  const chunks = [];
314
314
  while (true) {
315
315
  const { value: chunk, done } = yield reader.read();
@@ -336,65 +336,28 @@ exports.loadS3File = loadS3File;
336
336
  * Load the content of a file stored in S3 as a stream. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
337
337
  *
338
338
  * ```typescript
339
- * let fileContentStream = await wmill.loadS3FileStream(inputFile)
340
- * // Use a read to read the stream:
341
- * const chunks: Uint8Array[] = [];
342
- * const reader = fileContentStream.getReader()
343
- * while (true) {
344
- * const {value, done} = await reader.read();
345
- * if (done) {
346
- * break;
347
- * }
348
- * chunks.push(chunk);
349
- * }
350
- * // then the chunks can be concatenated into a single Uint8Array and if the
351
- * // file is a raw text file, it can be decoded and printed directly:
352
- * const text = new TextDecoder().decode(fileContent)
353
- * console.log(text);
339
+ * let fileContentBlob = await wmill.loadS3FileStream(inputFile)
340
+ * // if the content is plain text, the blob can be read directly:
341
+ * console.log(await fileContentBlob.text());
354
342
  * ```
355
343
  */
356
344
  function loadS3FileStream(s3object, s3ResourcePath) {
357
345
  return __awaiter(this, void 0, void 0, function* () {
358
346
  !clientSet && setClient();
359
- let part_number = 0;
360
- let file_total_size = undefined;
361
- let fetch = function (controller) {
362
- return __awaiter(this, void 0, void 0, function* () {
363
- // console.log("fetching part", part_number)
364
- if (part_number === undefined || part_number === null) {
365
- // console.log("finished, closing")
366
- controller.close();
367
- return;
368
- }
369
- let part_response = yield index_1.HelpersService.multipartFileDownload({
370
- workspace: getWorkspace(),
371
- requestBody: {
372
- file_key: s3object.s3,
373
- part_number: part_number,
374
- file_size: file_total_size,
375
- s3_resource_path: s3ResourcePath,
376
- }
377
- });
378
- if (part_response.part_content.length > 0) {
379
- // console.log("enqueueing part", part_number, part_response.part_content.length)
380
- let chunk = new Uint8Array(part_response.part_content.length);
381
- part_response.part_content.forEach((value, index) => {
382
- chunk[index] = value;
383
- });
384
- controller.enqueue(chunk);
385
- }
386
- part_number = part_response.next_part_number;
387
- file_total_size = part_response.file_size;
388
- });
389
- };
390
- let fileContentStream = new ReadableStream({
391
- pull(controller) {
392
- return __awaiter(this, void 0, void 0, function* () {
393
- yield fetch(controller);
394
- });
395
- }
347
+ let params = {};
348
+ params["file_key"] = s3object.s3;
349
+ if (s3ResourcePath !== undefined) {
350
+ params["s3_resource_path"] = s3ResourcePath;
351
+ }
352
+ const queryParams = new URLSearchParams(params);
353
+ // We use raw fetch here b/c OpenAPI generated client doesn't handle Blobs nicely
354
+ const fileContentBlob = yield fetch(`${index_2.OpenAPI.BASE}/w/${getWorkspace()}/job_helpers/download_s3_file?${queryParams}`, {
355
+ method: 'GET',
356
+ headers: {
357
+ 'Authorization': `Bearer ${index_2.OpenAPI.TOKEN}`,
358
+ },
396
359
  });
397
- return fileContentStream;
360
+ return fileContentBlob.blob();
398
361
  });
399
362
  }
400
363
  exports.loadS3FileStream = loadS3FileStream;
@@ -407,65 +370,27 @@ exports.loadS3FileStream = loadS3FileStream;
407
370
  * console.log(fileContentAsUtf8Str)
408
371
  * ```
409
372
  */
410
- function writeS3File(s3object, fileContent, fileExpiration, s3ResourcePath) {
373
+ function writeS3File(s3object, fileContent, s3ResourcePath) {
411
374
  return __awaiter(this, void 0, void 0, function* () {
412
375
  !clientSet && setClient();
413
- let fileContentStream;
376
+ let fileContentBlob;
414
377
  if (typeof fileContent === 'string') {
415
- fileContentStream = new Blob([fileContent], {
378
+ fileContentBlob = new Blob([fileContent], {
416
379
  type: 'text/plain'
417
- }).stream();
380
+ });
418
381
  }
419
382
  else {
420
- fileContentStream = fileContent;
421
- }
422
- let path = s3object === null || s3object === void 0 ? void 0 : s3object.s3;
423
- let upload_id = undefined;
424
- let parts = [];
425
- const reader = fileContentStream.getReader();
426
- let { value: chunk, done: readerDone } = yield reader.read();
427
- if (chunk === undefined || readerDone) {
428
- throw Error('Error reading stream, no data read');
429
- }
430
- while (true) {
431
- let { value: chunk_2, done: readerDone } = yield reader.read();
432
- if (!readerDone && chunk_2 !== undefined && chunk.length <= 5 * 1024 * 1024) {
433
- // AWS enforces part to be bigger than 5MB, so we accumulate bytes until we reach that limit before triggering the request to the BE
434
- chunk = new Uint8Array([...chunk, ...chunk_2]);
435
- continue;
436
- }
437
- try {
438
- let response = yield index_1.HelpersService.multipartFileUpload({
439
- workspace: getWorkspace(),
440
- requestBody: {
441
- file_key: path,
442
- file_extension: undefined,
443
- part_content: Array.from(chunk),
444
- upload_id: upload_id,
445
- parts: parts,
446
- is_final: readerDone,
447
- cancel_upload: false,
448
- s3_resource_path: s3ResourcePath,
449
- file_expiration: fileExpiration === null || fileExpiration === void 0 ? void 0 : fileExpiration.toString(),
450
- }
451
- });
452
- path = response.file_key;
453
- upload_id = response.upload_id;
454
- parts = response.parts;
455
- if (response.is_done) {
456
- break;
457
- }
458
- if (chunk_2 === undefined) {
459
- throw Error('File upload is not finished, yet there is no more data to stream. This is unexpected');
460
- }
461
- chunk = chunk_2;
462
- }
463
- catch (e) {
464
- throw Error(`Unexpected error uploading data to S3 ${e}`);
465
- }
383
+ fileContentBlob = fileContent;
466
384
  }
385
+ const response = yield index_1.HelpersService.fileUpload({
386
+ workspace: getWorkspace(),
387
+ fileKey: s3object === null || s3object === void 0 ? void 0 : s3object.s3,
388
+ fileExtension: undefined,
389
+ s3ResourcePath: s3ResourcePath,
390
+ requestBody: fileContentBlob,
391
+ });
467
392
  return {
468
- s3: path
393
+ s3: response.file_key
469
394
  };
470
395
  });
471
396
  }
@@ -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.258.4',
6
+ VERSION: '1.259.0',
7
7
  WITH_CREDENTIALS: false,
8
8
  CREDENTIALS: 'include',
9
9
  TOKEN: undefined,
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, loadS3File, writeS3File } from "./client";
178
+ export { setClient, getVariable, setVariable, getResource, setResource, getResumeUrls, setState, getState, getIdToken, denoS3LightClientSettings, loadS3FileStream, 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.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;
4
+ exports.writeS3File = exports.loadS3File = exports.loadS3FileStream = 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,5 +122,6 @@ 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, "loadS3FileStream", { enumerable: true, get: function () { return client_1.loadS3FileStream; } });
125
126
  Object.defineProperty(exports, "loadS3File", { enumerable: true, get: function () { return client_1.loadS3File; } });
126
127
  Object.defineProperty(exports, "writeS3File", { enumerable: true, get: function () { return client_1.writeS3File; } });
@@ -1,6 +1,5 @@
1
1
  import type { PolarsClientKwargs } from '../models/PolarsClientKwargs';
2
2
  import type { S3Resource } from '../models/S3Resource';
3
- import type { UploadFilePart } from '../models/UploadFilePart';
4
3
  import type { WindmillFileMetadata } from '../models/WindmillFileMetadata';
5
4
  import type { WindmillFilePreview } from '../models/WindmillFilePreview';
6
5
  import type { WindmillLargeFile } from '../models/WindmillLargeFile';
@@ -116,10 +115,11 @@ export declare class HelpersService {
116
115
  * @returns any List of file keys
117
116
  * @throws ApiError
118
117
  */
119
- static listStoredFiles({ workspace, maxKeys, marker, }: {
118
+ static listStoredFiles({ workspace, maxKeys, marker, prefix, }: {
120
119
  workspace: string;
121
120
  maxKeys: number;
122
121
  marker?: string;
122
+ prefix?: string;
123
123
  }): CancelablePromise<{
124
124
  next_marker?: string;
125
125
  windmill_large_files: Array<WindmillLargeFile>;
@@ -164,17 +164,6 @@ export declare class HelpersService {
164
164
  searchCol?: string;
165
165
  searchTerm?: string;
166
166
  }): CancelablePromise<any>;
167
- /**
168
- * Generate a unique URL to download the file
169
- * @returns any Download URL
170
- * @throws ApiError
171
- */
172
- static generateDownloadUrl({ workspace, fileKey, }: {
173
- workspace: string;
174
- fileKey: string;
175
- }): CancelablePromise<{
176
- download_url: string;
177
- }>;
178
167
  /**
179
168
  * Permanently delete file from S3
180
169
  * @returns any Confirmation
@@ -195,51 +184,30 @@ export declare class HelpersService {
195
184
  destFileKey: string;
196
185
  }): CancelablePromise<any>;
197
186
  /**
198
- * Upload file to S3 bucket using multipart upload
199
- * @returns any Chunk upload status
187
+ * Upload file to S3 bucket
188
+ * @returns any File upload status
200
189
  * @throws ApiError
201
190
  */
202
- static multipartFileUpload({ workspace, requestBody, }: {
191
+ static fileUpload({ workspace, requestBody, fileKey, fileExtension, s3ResourcePath, }: {
203
192
  workspace: string;
204
193
  /**
205
- * Query args for a multipart file upload to S3
194
+ * File content
206
195
  */
207
- requestBody: {
208
- file_key?: string;
209
- file_extension?: string;
210
- part_content: Array<number>;
211
- upload_id?: string;
212
- parts: Array<UploadFilePart>;
213
- is_final: boolean;
214
- cancel_upload: boolean;
215
- s3_resource_path?: string;
216
- file_expiration?: string;
217
- };
196
+ requestBody: Blob;
197
+ fileKey?: string;
198
+ fileExtension?: string;
199
+ s3ResourcePath?: string;
218
200
  }): CancelablePromise<{
219
- upload_id: string;
220
- parts: Array<UploadFilePart>;
221
- is_done: boolean;
222
201
  file_key: string;
223
202
  }>;
224
203
  /**
225
204
  * Download file to S3 bucket
226
- * @returns any Chunk of the downloaded file
205
+ * @returns binary Chunk of the downloaded file
227
206
  * @throws ApiError
228
207
  */
229
- static multipartFileDownload({ workspace, requestBody, }: {
208
+ static fileDownload({ workspace, fileKey, s3ResourcePath, }: {
230
209
  workspace: string;
231
- /**
232
- * Query args for a multipart file upload to S3
233
- */
234
- requestBody: {
235
- file_key: string;
236
- part_number: number;
237
- file_size?: number;
238
- s3_resource_path?: string;
239
- };
240
- }): CancelablePromise<{
241
- file_size?: number;
242
- part_content: Array<number>;
243
- next_part_number?: number;
244
- }>;
210
+ fileKey: string;
211
+ s3ResourcePath?: string;
212
+ }): CancelablePromise<Blob>;
245
213
  }
@@ -103,7 +103,7 @@ class HelpersService {
103
103
  * @returns any List of file keys
104
104
  * @throws ApiError
105
105
  */
106
- static listStoredFiles({ workspace, maxKeys, marker, }) {
106
+ static listStoredFiles({ workspace, maxKeys, marker, prefix, }) {
107
107
  return (0, request_1.request)(OpenAPI_1.OpenAPI, {
108
108
  method: 'GET',
109
109
  url: '/w/{workspace}/job_helpers/list_stored_files',
@@ -113,6 +113,7 @@ class HelpersService {
113
113
  query: {
114
114
  'max_keys': maxKeys,
115
115
  'marker': marker,
116
+ 'prefix': prefix,
116
117
  },
117
118
  });
118
119
  }
@@ -179,23 +180,6 @@ class HelpersService {
179
180
  },
180
181
  });
181
182
  }
182
- /**
183
- * Generate a unique URL to download the file
184
- * @returns any Download URL
185
- * @throws ApiError
186
- */
187
- static generateDownloadUrl({ workspace, fileKey, }) {
188
- return (0, request_1.request)(OpenAPI_1.OpenAPI, {
189
- method: 'GET',
190
- url: '/w/{workspace}/job_helpers/generate_download_url',
191
- path: {
192
- 'workspace': workspace,
193
- },
194
- query: {
195
- 'file_key': fileKey,
196
- },
197
- });
198
- }
199
183
  /**
200
184
  * Permanently delete file from S3
201
185
  * @returns any Confirmation
@@ -232,35 +216,42 @@ class HelpersService {
232
216
  });
233
217
  }
234
218
  /**
235
- * Upload file to S3 bucket using multipart upload
236
- * @returns any Chunk upload status
219
+ * Upload file to S3 bucket
220
+ * @returns any File upload status
237
221
  * @throws ApiError
238
222
  */
239
- static multipartFileUpload({ workspace, requestBody, }) {
223
+ static fileUpload({ workspace, requestBody, fileKey, fileExtension, s3ResourcePath, }) {
240
224
  return (0, request_1.request)(OpenAPI_1.OpenAPI, {
241
225
  method: 'POST',
242
- url: '/w/{workspace}/job_helpers/multipart_upload_s3_file',
226
+ url: '/w/{workspace}/job_helpers/upload_s3_file',
243
227
  path: {
244
228
  'workspace': workspace,
245
229
  },
230
+ query: {
231
+ 'file_key': fileKey,
232
+ 'file_extension': fileExtension,
233
+ 's3_resource_path': s3ResourcePath,
234
+ },
246
235
  body: requestBody,
247
- mediaType: 'application/json',
236
+ mediaType: 'application/octet-stream',
248
237
  });
249
238
  }
250
239
  /**
251
240
  * Download file to S3 bucket
252
- * @returns any Chunk of the downloaded file
241
+ * @returns binary Chunk of the downloaded file
253
242
  * @throws ApiError
254
243
  */
255
- static multipartFileDownload({ workspace, requestBody, }) {
244
+ static fileDownload({ workspace, fileKey, s3ResourcePath, }) {
256
245
  return (0, request_1.request)(OpenAPI_1.OpenAPI, {
257
- method: 'POST',
258
- url: '/w/{workspace}/job_helpers/multipart_download_s3_file',
246
+ method: 'GET',
247
+ url: '/w/{workspace}/job_helpers/download_s3_file',
259
248
  path: {
260
249
  'workspace': workspace,
261
250
  },
262
- body: requestBody,
263
- mediaType: 'application/json',
251
+ query: {
252
+ 'file_key': fileKey,
253
+ 's3_resource_path': s3ResourcePath,
254
+ },
264
255
  });
265
256
  }
266
257
  }
@@ -178,6 +178,7 @@ export declare class WorkspaceService {
178
178
  slack_command_script?: string;
179
179
  auto_invite_domain?: string;
180
180
  auto_invite_operator?: boolean;
181
+ auto_add?: boolean;
181
182
  plan?: string;
182
183
  customer_id?: string;
183
184
  webhook?: string;
@@ -277,6 +278,7 @@ export declare class WorkspaceService {
277
278
  requestBody: {
278
279
  operator?: boolean;
279
280
  invite_all?: boolean;
281
+ auto_add?: boolean;
280
282
  };
281
283
  }): CancelablePromise<string>;
282
284
  /**
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.258.4",
4
+ "version": "1.259.0",
5
5
  "author": "Ruben Fiszel",
6
6
  "license": "Apache 2.0",
7
7
  "devDependencies": {