windmill-client 1.254.1 → 1.255.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,13 +72,35 @@ 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 fileContentStream = await wmill.loadS3File(inputFile)
75
+ * let fileContent = await wmill.loadS3File(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);
79
79
  * ```
80
80
  */
81
81
  export declare function loadS3File(s3object: S3Object, s3ResourcePath: string | undefined): Promise<Uint8Array | undefined>;
82
+ /**
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
+ *
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);
101
+ * ```
102
+ */
103
+ export declare function loadS3FileStream(s3object: S3Object, s3ResourcePath: string | undefined): Promise<ReadableStream | undefined>;
82
104
  /**
83
105
  * Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
84
106
  *
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.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.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");
@@ -295,13 +295,65 @@ 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 fileContentStream = await wmill.loadS3File(inputFile)
298
+ * let fileContent = await wmill.loadS3File(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);
302
302
  * ```
303
303
  */
304
304
  function loadS3File(s3object, s3ResourcePath) {
305
+ return __awaiter(this, void 0, void 0, function* () {
306
+ !clientSet && setClient();
307
+ const fileContentStream = yield loadS3FileStream(s3object, s3ResourcePath);
308
+ if (fileContentStream === undefined) {
309
+ return undefined;
310
+ }
311
+ // we read the stream until completion and put the content in an Uint8Array
312
+ const reader = fileContentStream.getReader();
313
+ const chunks = [];
314
+ while (true) {
315
+ const { value: chunk, done } = yield reader.read();
316
+ if (done) {
317
+ break;
318
+ }
319
+ chunks.push(chunk);
320
+ }
321
+ let fileContentLength = 0;
322
+ chunks.forEach(item => {
323
+ fileContentLength += item.length;
324
+ });
325
+ let fileContent = new Uint8Array(fileContentLength);
326
+ let offset = 0;
327
+ chunks.forEach(chunk => {
328
+ fileContent.set(chunk, offset);
329
+ offset += chunk.length;
330
+ });
331
+ return fileContent;
332
+ });
333
+ }
334
+ exports.loadS3File = loadS3File;
335
+ /**
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
+ *
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);
354
+ * ```
355
+ */
356
+ function loadS3FileStream(s3object, s3ResourcePath) {
305
357
  return __awaiter(this, void 0, void 0, function* () {
306
358
  !clientSet && setClient();
307
359
  let part_number = 0;
@@ -342,30 +394,10 @@ function loadS3File(s3object, s3ResourcePath) {
342
394
  });
343
395
  }
344
396
  });
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;
397
+ return fileContentStream;
366
398
  });
367
399
  }
368
- exports.loadS3File = loadS3File;
400
+ exports.loadS3FileStream = loadS3FileStream;
369
401
  /**
370
402
  * Persist a file to the S3 bucket. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
371
403
  *
@@ -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.254.1',
6
+ VERSION: '1.255.0',
7
7
  WITH_CREDENTIALS: false,
8
8
  CREDENTIALS: 'include',
9
9
  TOKEN: undefined,
@@ -192,6 +192,7 @@ 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";
195
196
  if (config.WITH_CREDENTIALS) {
196
197
  request.credentials = config.CREDENTIALS;
197
198
  }
@@ -7,6 +7,7 @@ export type Preview = {
7
7
  tag?: string;
8
8
  kind?: Preview.kind;
9
9
  dedicated_worker?: boolean;
10
+ lock?: string;
10
11
  };
11
12
  export declare namespace Preview {
12
13
  enum language {
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.254.1",
4
+ "version": "1.255.0",
5
5
  "author": "Ruben Fiszel",
6
6
  "license": "Apache 2.0",
7
7
  "devDependencies": {