@chrt-inc/typescript-sdk 0.0.187 → 0.0.189

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/README.md CHANGED
@@ -166,3 +166,393 @@ a proof of concept, but know that we will not be able to merge it as-is. We sugg
166
166
  an issue first to discuss with us!
167
167
 
168
168
  On the other hand, contributions to the README are always very welcome!
169
+
170
+ ## Binary Response
171
+
172
+ You can consume binary data from endpoints using the `BinaryResponse` type which lets you choose how to consume the data:
173
+
174
+ ```typescript
175
+ const response = await client.milestones.images.getByMetadataId(...);
176
+ const stream: ReadableStream<Uint8Array> = response.stream();
177
+ // const arrayBuffer: ArrayBuffer = await response.arrayBuffer();
178
+ // const blob: Blob = response.blob();
179
+ // const bytes: Uint8Array = response.bytes();
180
+ // You can only use the response body once, so you must choose one of the above methods.
181
+ // If you want to check if the response body has been used, you can use the following property.
182
+ const bodyUsed = response.bodyUsed;
183
+ ```
184
+
185
+ <details>
186
+ <summary>Save binary response to a file</summary>
187
+
188
+ <blockquote>
189
+ <details>
190
+ <summary>Node.js</summary>
191
+
192
+ <blockquote>
193
+ <details>
194
+ <summary>ReadableStream (most-efficient)</summary>
195
+
196
+ ```ts
197
+ import { createWriteStream } from 'fs';
198
+ import { Readable } from 'stream';
199
+ import { pipeline } from 'stream/promises';
200
+
201
+ const response = await client.milestones.images.getByMetadataId(...);
202
+
203
+ const stream = response.stream();
204
+ const nodeStream = Readable.fromWeb(stream);
205
+ const writeStream = createWriteStream('path/to/file');
206
+
207
+ await pipeline(nodeStream, writeStream);
208
+ ```
209
+
210
+ </details>
211
+ </blockquote>
212
+
213
+ <blockquote>
214
+ <details>
215
+ <summary>ArrayBuffer</summary>
216
+
217
+ ```ts
218
+ import { writeFile } from 'fs/promises';
219
+
220
+ const response = await client.milestones.images.getByMetadataId(...);
221
+
222
+ const arrayBuffer = await response.arrayBuffer();
223
+ await writeFile('path/to/file', Buffer.from(arrayBuffer));
224
+ ```
225
+
226
+ </details>
227
+ </blockquote>
228
+
229
+ <blockquote>
230
+ <details>
231
+ <summary>Blob</summary>
232
+
233
+ ```ts
234
+ import { writeFile } from 'fs/promises';
235
+
236
+ const response = await client.milestones.images.getByMetadataId(...);
237
+
238
+ const blob = await response.blob();
239
+ const arrayBuffer = await blob.arrayBuffer();
240
+ await writeFile('output.bin', Buffer.from(arrayBuffer));
241
+ ```
242
+
243
+ </details>
244
+ </blockquote>
245
+
246
+ <blockquote>
247
+ <details>
248
+ <summary>Bytes (UIntArray8)</summary>
249
+
250
+ ```ts
251
+ import { writeFile } from 'fs/promises';
252
+
253
+ const response = await client.milestones.images.getByMetadataId(...);
254
+
255
+ const bytes = await response.bytes();
256
+ await writeFile('path/to/file', bytes);
257
+ ```
258
+
259
+ </details>
260
+ </blockquote>
261
+
262
+ </details>
263
+ </blockquote>
264
+
265
+ <blockquote>
266
+ <details>
267
+ <summary>Bun</summary>
268
+
269
+ <blockquote>
270
+ <details>
271
+ <summary>ReadableStream (most-efficient)</summary>
272
+
273
+ ```ts
274
+ const response = await client.milestones.images.getByMetadataId(...);
275
+
276
+ const stream = response.stream();
277
+ await Bun.write('path/to/file', stream);
278
+ ```
279
+
280
+ </details>
281
+ </blockquote>
282
+
283
+ <blockquote>
284
+ <details>
285
+ <summary>ArrayBuffer</summary>
286
+
287
+ ```ts
288
+ const response = await client.milestones.images.getByMetadataId(...);
289
+
290
+ const arrayBuffer = await response.arrayBuffer();
291
+ await Bun.write('path/to/file', arrayBuffer);
292
+ ```
293
+
294
+ </details>
295
+ </blockquote>
296
+
297
+ <blockquote>
298
+ <details>
299
+ <summary>Blob</summary>
300
+
301
+ ```ts
302
+ const response = await client.milestones.images.getByMetadataId(...);
303
+
304
+ const blob = await response.blob();
305
+ await Bun.write('path/to/file', blob);
306
+ ```
307
+
308
+ </details>
309
+ </blockquote>
310
+
311
+ <blockquote>
312
+ <details>
313
+ <summary>Bytes (UIntArray8)</summary>
314
+
315
+ ```ts
316
+ const response = await client.milestones.images.getByMetadataId(...);
317
+
318
+ const bytes = await response.bytes();
319
+ await Bun.write('path/to/file', bytes);
320
+ ```
321
+
322
+ </details>
323
+ </blockquote>
324
+
325
+ </details>
326
+ </blockquote>
327
+
328
+ <blockquote>
329
+ <details>
330
+ <summary>Deno</summary>
331
+
332
+ <blockquote>
333
+ <details>
334
+ <summary>ReadableStream (most-efficient)</summary>
335
+
336
+ ```ts
337
+ const response = await client.milestones.images.getByMetadataId(...);
338
+
339
+ const stream = response.stream();
340
+ const file = await Deno.open('path/to/file', { write: true, create: true });
341
+ await stream.pipeTo(file.writable);
342
+ ```
343
+
344
+ </details>
345
+ </blockquote>
346
+
347
+ <blockquote>
348
+ <details>
349
+ <summary>ArrayBuffer</summary>
350
+
351
+ ```ts
352
+ const response = await client.milestones.images.getByMetadataId(...);
353
+
354
+ const arrayBuffer = await response.arrayBuffer();
355
+ await Deno.writeFile('path/to/file', new Uint8Array(arrayBuffer));
356
+ ```
357
+
358
+ </details>
359
+ </blockquote>
360
+
361
+ <blockquote>
362
+ <details>
363
+ <summary>Blob</summary>
364
+
365
+ ```ts
366
+ const response = await client.milestones.images.getByMetadataId(...);
367
+
368
+ const blob = await response.blob();
369
+ const arrayBuffer = await blob.arrayBuffer();
370
+ await Deno.writeFile('path/to/file', new Uint8Array(arrayBuffer));
371
+ ```
372
+
373
+ </details>
374
+ </blockquote>
375
+
376
+ <blockquote>
377
+ <details>
378
+ <summary>Bytes (UIntArray8)</summary>
379
+
380
+ ```ts
381
+ const response = await client.milestones.images.getByMetadataId(...);
382
+
383
+ const bytes = await response.bytes();
384
+ await Deno.writeFile('path/to/file', bytes);
385
+ ```
386
+
387
+ </details>
388
+ </blockquote>
389
+
390
+ </details>
391
+ </blockquote>
392
+
393
+ <blockquote>
394
+ <details>
395
+ <summary>Browser</summary>
396
+
397
+ <blockquote>
398
+ <details>
399
+ <summary>Blob (most-efficient)</summary>
400
+
401
+ ```ts
402
+ const response = await client.milestones.images.getByMetadataId(...);
403
+
404
+ const blob = await response.blob();
405
+ const url = URL.createObjectURL(blob);
406
+
407
+ // trigger download
408
+ const a = document.createElement('a');
409
+ a.href = url;
410
+ a.download = 'filename';
411
+ a.click();
412
+ URL.revokeObjectURL(url);
413
+ ```
414
+
415
+ </details>
416
+ </blockquote>
417
+
418
+ <blockquote>
419
+ <details>
420
+ <summary>ReadableStream</summary>
421
+
422
+ ```ts
423
+ const response = await client.milestones.images.getByMetadataId(...);
424
+
425
+ const stream = response.stream();
426
+ const reader = stream.getReader();
427
+ const chunks = [];
428
+
429
+ while (true) {
430
+ const { done, value } = await reader.read();
431
+ if (done) break;
432
+ chunks.push(value);
433
+ }
434
+
435
+ const blob = new Blob(chunks);
436
+ const url = URL.createObjectURL(blob);
437
+
438
+ // trigger download
439
+ const a = document.createElement('a');
440
+ a.href = url;
441
+ a.download = 'filename';
442
+ a.click();
443
+ URL.revokeObjectURL(url);
444
+ ```
445
+
446
+ </details>
447
+ </blockquote>
448
+
449
+ <blockquote>
450
+ <details>
451
+ <summary>ArrayBuffer</summary>
452
+
453
+ ```ts
454
+ const response = await client.milestones.images.getByMetadataId(...);
455
+
456
+ const arrayBuffer = await response.arrayBuffer();
457
+ const blob = new Blob([arrayBuffer]);
458
+ const url = URL.createObjectURL(blob);
459
+
460
+ // trigger download
461
+ const a = document.createElement('a');
462
+ a.href = url;
463
+ a.download = 'filename';
464
+ a.click();
465
+ URL.revokeObjectURL(url);
466
+ ```
467
+
468
+ </details>
469
+ </blockquote>
470
+
471
+ <blockquote>
472
+ <details>
473
+ <summary>Bytes (UIntArray8)</summary>
474
+
475
+ ```ts
476
+ const response = await client.milestones.images.getByMetadataId(...);
477
+
478
+ const bytes = await response.bytes();
479
+ const blob = new Blob([bytes]);
480
+ const url = URL.createObjectURL(blob);
481
+
482
+ // trigger download
483
+ const a = document.createElement('a');
484
+ a.href = url;
485
+ a.download = 'filename';
486
+ a.click();
487
+ URL.revokeObjectURL(url);
488
+ ```
489
+
490
+ </details>
491
+ </blockquote>
492
+
493
+ </details>
494
+ </blockquote>
495
+
496
+ </details>
497
+ </blockquote>
498
+
499
+ <details>
500
+ <summary>Convert binary response to text</summary>
501
+
502
+ <blockquote>
503
+ <details>
504
+ <summary>ReadableStream</summary>
505
+
506
+ ```ts
507
+ const response = await client.milestones.images.getByMetadataId(...);
508
+
509
+ const stream = response.stream();
510
+ const text = await new Response(stream).text();
511
+ ```
512
+
513
+ </details>
514
+ </blockquote>
515
+
516
+ <blockquote>
517
+ <details>
518
+ <summary>ArrayBuffer</summary>
519
+
520
+ ```ts
521
+ const response = await client.milestones.images.getByMetadataId(...);
522
+
523
+ const arrayBuffer = await response.arrayBuffer();
524
+ const text = new TextDecoder().decode(arrayBuffer);
525
+ ```
526
+
527
+ </details>
528
+ </blockquote>
529
+
530
+ <blockquote>
531
+ <details>
532
+ <summary>Blob</summary>
533
+
534
+ ```ts
535
+ const response = await client.milestones.images.getByMetadataId(...);
536
+
537
+ const blob = await response.blob();
538
+ const text = await blob.text();
539
+ ```
540
+
541
+ </details>
542
+ </blockquote>
543
+
544
+ <blockquote>
545
+ <details>
546
+ <summary>Bytes (UIntArray8)</summary>
547
+
548
+ ```ts
549
+ const response = await client.milestones.images.getByMetadataId(...);
550
+
551
+ const bytes = await response.bytes();
552
+ const text = new TextDecoder().decode(bytes);
553
+ ```
554
+
555
+ </details>
556
+ </blockquote>
557
+
558
+ </details>
@@ -63,8 +63,8 @@ class ChrtClient {
63
63
  this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
64
64
  "X-Fern-Language": "JavaScript",
65
65
  "X-Fern-SDK-Name": "@chrt-inc/typescript-sdk",
66
- "X-Fern-SDK-Version": "0.0.187",
67
- "User-Agent": "@chrt-inc/typescript-sdk/0.0.187",
66
+ "X-Fern-SDK-Version": "0.0.189",
67
+ "User-Agent": "@chrt-inc/typescript-sdk/0.0.189",
68
68
  "X-Fern-Runtime": core.RUNTIME.type,
69
69
  "X-Fern-Runtime-Version": core.RUNTIME.version,
70
70
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -59,16 +59,9 @@ export declare class Images {
59
59
  private __deleteByMetadataId;
60
60
  /**
61
61
  * Streams a milestone image file from S3 storage.
62
- *
63
- * @param {string} milestoneS3ObjectMetadataId
64
- * @param {Images.RequestOptions} requestOptions - Request-specific configuration.
65
- *
66
62
  * @throws {@link Chrt.UnprocessableEntityError}
67
- *
68
- * @example
69
- * await client.milestones.images.getByMetadataId("milestone_s3_object_metadata_id")
70
63
  */
71
- getByMetadataId(milestoneS3ObjectMetadataId: string, requestOptions?: Images.RequestOptions): core.HttpResponsePromise<unknown>;
64
+ getByMetadataId(milestoneS3ObjectMetadataId: string, requestOptions?: Images.RequestOptions): core.HttpResponsePromise<core.BinaryResponse>;
72
65
  private __getByMetadataId;
73
66
  protected _getAuthorizationHeader(): Promise<string | undefined>;
74
67
  }
@@ -185,14 +185,7 @@ class Images {
185
185
  }
186
186
  /**
187
187
  * Streams a milestone image file from S3 storage.
188
- *
189
- * @param {string} milestoneS3ObjectMetadataId
190
- * @param {Images.RequestOptions} requestOptions - Request-specific configuration.
191
- *
192
188
  * @throws {@link Chrt.UnprocessableEntityError}
193
- *
194
- * @example
195
- * await client.milestones.images.getByMetadataId("milestone_s3_object_metadata_id")
196
189
  */
197
190
  getByMetadataId(milestoneS3ObjectMetadataId, requestOptions) {
198
191
  return core.HttpResponsePromise.fromPromise(this.__getByMetadataId(milestoneS3ObjectMetadataId, requestOptions));
@@ -204,6 +197,7 @@ class Images {
204
197
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ChrtEnvironment.Local, `oort/milestones/images/${encodeURIComponent(milestoneS3ObjectMetadataId)}`),
205
198
  method: "GET",
206
199
  headers: (0, headers_js_1.mergeHeaders)((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
200
+ responseType: "binary-response",
207
201
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
208
202
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
209
203
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.0.187";
1
+ export declare const SDK_VERSION = "0.0.189";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.0.187";
4
+ exports.SDK_VERSION = "0.0.189";
@@ -27,8 +27,8 @@ export class ChrtClient {
27
27
  this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
28
28
  "X-Fern-Language": "JavaScript",
29
29
  "X-Fern-SDK-Name": "@chrt-inc/typescript-sdk",
30
- "X-Fern-SDK-Version": "0.0.187",
31
- "User-Agent": "@chrt-inc/typescript-sdk/0.0.187",
30
+ "X-Fern-SDK-Version": "0.0.189",
31
+ "User-Agent": "@chrt-inc/typescript-sdk/0.0.189",
32
32
  "X-Fern-Runtime": core.RUNTIME.type,
33
33
  "X-Fern-Runtime-Version": core.RUNTIME.version,
34
34
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -59,16 +59,9 @@ export declare class Images {
59
59
  private __deleteByMetadataId;
60
60
  /**
61
61
  * Streams a milestone image file from S3 storage.
62
- *
63
- * @param {string} milestoneS3ObjectMetadataId
64
- * @param {Images.RequestOptions} requestOptions - Request-specific configuration.
65
- *
66
62
  * @throws {@link Chrt.UnprocessableEntityError}
67
- *
68
- * @example
69
- * await client.milestones.images.getByMetadataId("milestone_s3_object_metadata_id")
70
63
  */
71
- getByMetadataId(milestoneS3ObjectMetadataId: string, requestOptions?: Images.RequestOptions): core.HttpResponsePromise<unknown>;
64
+ getByMetadataId(milestoneS3ObjectMetadataId: string, requestOptions?: Images.RequestOptions): core.HttpResponsePromise<core.BinaryResponse>;
72
65
  private __getByMetadataId;
73
66
  protected _getAuthorizationHeader(): Promise<string | undefined>;
74
67
  }
@@ -149,14 +149,7 @@ export class Images {
149
149
  }
150
150
  /**
151
151
  * Streams a milestone image file from S3 storage.
152
- *
153
- * @param {string} milestoneS3ObjectMetadataId
154
- * @param {Images.RequestOptions} requestOptions - Request-specific configuration.
155
- *
156
152
  * @throws {@link Chrt.UnprocessableEntityError}
157
- *
158
- * @example
159
- * await client.milestones.images.getByMetadataId("milestone_s3_object_metadata_id")
160
153
  */
161
154
  getByMetadataId(milestoneS3ObjectMetadataId, requestOptions) {
162
155
  return core.HttpResponsePromise.fromPromise(this.__getByMetadataId(milestoneS3ObjectMetadataId, requestOptions));
@@ -168,6 +161,7 @@ export class Images {
168
161
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ChrtEnvironment.Local, `oort/milestones/images/${encodeURIComponent(milestoneS3ObjectMetadataId)}`),
169
162
  method: "GET",
170
163
  headers: mergeHeaders((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
164
+ responseType: "binary-response",
171
165
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
172
166
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
173
167
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.0.187";
1
+ export declare const SDK_VERSION = "0.0.189";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.0.187";
1
+ export const SDK_VERSION = "0.0.189";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrt-inc/typescript-sdk",
3
- "version": "0.0.187",
3
+ "version": "0.0.189",
4
4
  "private": false,
5
5
  "repository": "github:chrt-inc/typescript-sdk",
6
6
  "type": "commonjs",
package/reference.md CHANGED
@@ -5379,69 +5379,6 @@ await client.milestones.images.deleteByMetadataId("milestone_s3_object_metadata_
5379
5379
  </dl>
5380
5380
  </details>
5381
5381
 
5382
- <details><summary><code>client.milestones.images.<a href="/src/api/resources/milestones/resources/images/client/Client.ts">getByMetadataId</a>(milestoneS3ObjectMetadataId) -> unknown</code></summary>
5383
- <dl>
5384
- <dd>
5385
-
5386
- #### 📝 Description
5387
-
5388
- <dl>
5389
- <dd>
5390
-
5391
- <dl>
5392
- <dd>
5393
-
5394
- Streams a milestone image file from S3 storage.
5395
-
5396
- </dd>
5397
- </dl>
5398
- </dd>
5399
- </dl>
5400
-
5401
- #### 🔌 Usage
5402
-
5403
- <dl>
5404
- <dd>
5405
-
5406
- <dl>
5407
- <dd>
5408
-
5409
- ```typescript
5410
- await client.milestones.images.getByMetadataId("milestone_s3_object_metadata_id");
5411
- ```
5412
-
5413
- </dd>
5414
- </dl>
5415
- </dd>
5416
- </dl>
5417
-
5418
- #### ⚙️ Parameters
5419
-
5420
- <dl>
5421
- <dd>
5422
-
5423
- <dl>
5424
- <dd>
5425
-
5426
- **milestoneS3ObjectMetadataId:** `string`
5427
-
5428
- </dd>
5429
- </dl>
5430
-
5431
- <dl>
5432
- <dd>
5433
-
5434
- **requestOptions:** `Images.RequestOptions`
5435
-
5436
- </dd>
5437
- </dl>
5438
- </dd>
5439
- </dl>
5440
-
5441
- </dd>
5442
- </dl>
5443
- </details>
5444
-
5445
5382
  ## Milestones Blurhash
5446
5383
 
5447
5384
  <details><summary><code>client.milestones.blurhash.<a href="/src/api/resources/milestones/resources/blurhash/client/Client.ts">getByMetadataId</a>(milestoneS3ObjectMetadataId) -> string</code></summary>