@discomedia/utils 1.0.59 → 1.0.61

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.
Files changed (45) hide show
  1. package/README.md +0 -2
  2. package/dist/index-frontend.cjs +215 -43
  3. package/dist/index-frontend.cjs.map +1 -1
  4. package/dist/index-frontend.mjs +215 -43
  5. package/dist/index-frontend.mjs.map +1 -1
  6. package/dist/index.cjs +215 -1421
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.mjs +215 -1421
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/package.json +4 -4
  11. package/dist/test.js +215 -268
  12. package/dist/test.js.map +1 -1
  13. package/dist/types/index.d.ts +0 -82
  14. package/dist/types/index.d.ts.map +1 -1
  15. package/dist/types/misc-utils.d.ts +0 -6
  16. package/dist/types/misc-utils.d.ts.map +1 -1
  17. package/dist/types/types/index.d.ts +0 -2
  18. package/dist/types/types/index.d.ts.map +1 -1
  19. package/dist/types-frontend/index.d.ts +0 -82
  20. package/dist/types-frontend/index.d.ts.map +1 -1
  21. package/dist/types-frontend/misc-utils.d.ts +0 -6
  22. package/dist/types-frontend/misc-utils.d.ts.map +1 -1
  23. package/dist/types-frontend/types/index.d.ts +0 -2
  24. package/dist/types-frontend/types/index.d.ts.map +1 -1
  25. package/package.json +4 -4
  26. package/dist/types/polygon-indices.d.ts +0 -85
  27. package/dist/types/polygon-indices.d.ts.map +0 -1
  28. package/dist/types/polygon.d.ts +0 -126
  29. package/dist/types/polygon.d.ts.map +0 -1
  30. package/dist/types/technical-analysis.d.ts +0 -90
  31. package/dist/types/technical-analysis.d.ts.map +0 -1
  32. package/dist/types/types/polygon-indices-types.d.ts +0 -190
  33. package/dist/types/types/polygon-indices-types.d.ts.map +0 -1
  34. package/dist/types/types/polygon-types.d.ts +0 -204
  35. package/dist/types/types/polygon-types.d.ts.map +0 -1
  36. package/dist/types-frontend/polygon-indices.d.ts +0 -85
  37. package/dist/types-frontend/polygon-indices.d.ts.map +0 -1
  38. package/dist/types-frontend/polygon.d.ts +0 -126
  39. package/dist/types-frontend/polygon.d.ts.map +0 -1
  40. package/dist/types-frontend/technical-analysis.d.ts +0 -90
  41. package/dist/types-frontend/technical-analysis.d.ts.map +0 -1
  42. package/dist/types-frontend/types/polygon-indices-types.d.ts +0 -190
  43. package/dist/types-frontend/types/polygon-indices-types.d.ts.map +0 -1
  44. package/dist/types-frontend/types/polygon-types.d.ts +0 -204
  45. package/dist/types-frontend/types/polygon-types.d.ts.map +0 -1
package/dist/test.js CHANGED
@@ -381,231 +381,6 @@ function getTradingDate(time) {
381
381
  return `${nyDate.getUTCFullYear()}-${String(nyDate.getUTCMonth() + 1).padStart(2, '0')}-${String(nyDate.getUTCDate()).padStart(2, '0')}`;
382
382
  }
383
383
 
384
- /*
385
- How it works:
386
- `this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
387
- */
388
-
389
- class Node {
390
- value;
391
- next;
392
-
393
- constructor(value) {
394
- this.value = value;
395
- }
396
- }
397
-
398
- class Queue {
399
- #head;
400
- #tail;
401
- #size;
402
-
403
- constructor() {
404
- this.clear();
405
- }
406
-
407
- enqueue(value) {
408
- const node = new Node(value);
409
-
410
- if (this.#head) {
411
- this.#tail.next = node;
412
- this.#tail = node;
413
- } else {
414
- this.#head = node;
415
- this.#tail = node;
416
- }
417
-
418
- this.#size++;
419
- }
420
-
421
- dequeue() {
422
- const current = this.#head;
423
- if (!current) {
424
- return;
425
- }
426
-
427
- this.#head = this.#head.next;
428
- this.#size--;
429
- return current.value;
430
- }
431
-
432
- peek() {
433
- if (!this.#head) {
434
- return;
435
- }
436
-
437
- return this.#head.value;
438
-
439
- // TODO: Node.js 18.
440
- // return this.#head?.value;
441
- }
442
-
443
- clear() {
444
- this.#head = undefined;
445
- this.#tail = undefined;
446
- this.#size = 0;
447
- }
448
-
449
- get size() {
450
- return this.#size;
451
- }
452
-
453
- * [Symbol.iterator]() {
454
- let current = this.#head;
455
-
456
- while (current) {
457
- yield current.value;
458
- current = current.next;
459
- }
460
- }
461
-
462
- * drain() {
463
- while (this.#head) {
464
- yield this.dequeue();
465
- }
466
- }
467
- }
468
-
469
- function pLimit(concurrency) {
470
- let rejectOnClear = false;
471
-
472
- if (typeof concurrency === 'object') {
473
- ({concurrency, rejectOnClear = false} = concurrency);
474
- }
475
-
476
- validateConcurrency(concurrency);
477
-
478
- if (typeof rejectOnClear !== 'boolean') {
479
- throw new TypeError('Expected `rejectOnClear` to be a boolean');
480
- }
481
-
482
- const queue = new Queue();
483
- let activeCount = 0;
484
-
485
- const resumeNext = () => {
486
- // Process the next queued function if we're under the concurrency limit
487
- if (activeCount < concurrency && queue.size > 0) {
488
- activeCount++;
489
- queue.dequeue().run();
490
- }
491
- };
492
-
493
- const next = () => {
494
- activeCount--;
495
- resumeNext();
496
- };
497
-
498
- const run = async (function_, resolve, arguments_) => {
499
- // Execute the function and capture the result promise
500
- const result = (async () => function_(...arguments_))();
501
-
502
- // Resolve immediately with the promise (don't wait for completion)
503
- resolve(result);
504
-
505
- // Wait for the function to complete (success or failure)
506
- // We catch errors here to prevent unhandled rejections,
507
- // but the original promise rejection is preserved for the caller
508
- try {
509
- await result;
510
- } catch {}
511
-
512
- // Decrement active count and process next queued function
513
- next();
514
- };
515
-
516
- const enqueue = (function_, resolve, reject, arguments_) => {
517
- const queueItem = {reject};
518
-
519
- // Queue the internal resolve function instead of the run function
520
- // to preserve the asynchronous execution context.
521
- new Promise(internalResolve => { // eslint-disable-line promise/param-names
522
- queueItem.run = internalResolve;
523
- queue.enqueue(queueItem);
524
- }).then(run.bind(undefined, function_, resolve, arguments_)); // eslint-disable-line promise/prefer-await-to-then
525
-
526
- // Start processing immediately if we haven't reached the concurrency limit
527
- if (activeCount < concurrency) {
528
- resumeNext();
529
- }
530
- };
531
-
532
- const generator = (function_, ...arguments_) => new Promise((resolve, reject) => {
533
- enqueue(function_, resolve, reject, arguments_);
534
- });
535
-
536
- Object.defineProperties(generator, {
537
- activeCount: {
538
- get: () => activeCount,
539
- },
540
- pendingCount: {
541
- get: () => queue.size,
542
- },
543
- clearQueue: {
544
- value() {
545
- if (!rejectOnClear) {
546
- queue.clear();
547
- return;
548
- }
549
-
550
- const abortError = AbortSignal.abort().reason;
551
-
552
- while (queue.size > 0) {
553
- queue.dequeue().reject(abortError);
554
- }
555
- },
556
- },
557
- concurrency: {
558
- get: () => concurrency,
559
-
560
- set(newConcurrency) {
561
- validateConcurrency(newConcurrency);
562
- concurrency = newConcurrency;
563
-
564
- queueMicrotask(() => {
565
- // eslint-disable-next-line no-unmodified-loop-condition
566
- while (activeCount < concurrency && queue.size > 0) {
567
- resumeNext();
568
- }
569
- });
570
- },
571
- },
572
- map: {
573
- async value(iterable, function_) {
574
- const promises = Array.from(iterable, (value, index) => this(function_, value, index));
575
- return Promise.all(promises);
576
- },
577
- },
578
- });
579
-
580
- return generator;
581
- }
582
-
583
- function validateConcurrency(concurrency) {
584
- if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
585
- throw new TypeError('Expected `concurrency` to be a number from 1 and up');
586
- }
587
- }
588
-
589
- /**********************************************************************************
590
- * Polygon.io calls
591
- **********************************************************************************/
592
- // Constants from environment variables
593
- process.env.POLYGON_API_KEY;
594
- // Define concurrency limits per API
595
- const POLYGON_CONCURRENCY_LIMIT = 100;
596
- pLimit(POLYGON_CONCURRENCY_LIMIT);
597
-
598
- /**
599
- * Polygon Indices API Implementation
600
- *
601
- * This module provides functions to interact with the Polygon.io Indices API.
602
- */
603
- // Constants from environment variables
604
- const { ALPACA_INDICES_API_KEY } = process.env;
605
- // Define concurrency limits for API
606
- const POLYGON_INDICES_CONCURRENCY_LIMIT = 5;
607
- pLimit(POLYGON_INDICES_CONCURRENCY_LIMIT);
608
-
609
384
  function __classPrivateFieldSet(receiver, state, value, kind, f) {
610
385
  if (typeof state === "function" ? receiver !== state || true : !state.has(receiver))
611
386
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
@@ -837,7 +612,7 @@ const safeJSON = (text) => {
837
612
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
838
613
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
839
614
 
840
- const VERSION = '6.22.0'; // x-release-please-version
615
+ const VERSION = '6.27.0'; // x-release-please-version
841
616
 
842
617
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
843
618
  const isRunningInBrowser = () => {
@@ -1457,6 +1232,11 @@ function stringify(object, opts = {}) {
1457
1232
  return joined.length > 0 ? prefix + joined : '';
1458
1233
  }
1459
1234
 
1235
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1236
+ function stringifyQuery(query) {
1237
+ return stringify(query, { arrayFormat: 'brackets' });
1238
+ }
1239
+
1460
1240
  function concatBytes(buffers) {
1461
1241
  let length = 0;
1462
1242
  for (const buffer of buffers) {
@@ -1675,7 +1455,7 @@ class Stream {
1675
1455
  this.controller = controller;
1676
1456
  __classPrivateFieldSet(this, _Stream_client, client);
1677
1457
  }
1678
- static fromSSEResponse(response, controller, client) {
1458
+ static fromSSEResponse(response, controller, client, synthesizeEventData) {
1679
1459
  let consumed = false;
1680
1460
  const logger = client ? loggerFor(client) : console;
1681
1461
  async function* iterator() {
@@ -1705,7 +1485,7 @@ class Stream {
1705
1485
  if (data && data.error) {
1706
1486
  throw new APIError(undefined, data.error, undefined, response.headers);
1707
1487
  }
1708
- yield data;
1488
+ yield synthesizeEventData ? { event: sse.event, data } : data;
1709
1489
  }
1710
1490
  else {
1711
1491
  let data;
@@ -1955,9 +1735,9 @@ async function defaultParseResponse(client, props) {
1955
1735
  // Note: there is an invariant here that isn't represented in the type system
1956
1736
  // that if you set `stream: true` the response type must also be `Stream<T>`
1957
1737
  if (props.options.__streamClass) {
1958
- return props.options.__streamClass.fromSSEResponse(response, props.controller, client);
1738
+ return props.options.__streamClass.fromSSEResponse(response, props.controller, client, props.options.__synthesizeEventData);
1959
1739
  }
1960
- return Stream.fromSSEResponse(response, props.controller, client);
1740
+ return Stream.fromSSEResponse(response, props.controller, client, props.options.__synthesizeEventData);
1961
1741
  }
1962
1742
  // fetch refuses to read the body when the status code is 204.
1963
1743
  if (response.status === 204) {
@@ -2510,6 +2290,9 @@ const createPathTagFunction = (pathEncoder = encodeURIPath) => function path(sta
2510
2290
  const path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
2511
2291
 
2512
2292
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2293
+ /**
2294
+ * Given a list of messages comprising a conversation, the model will return a response.
2295
+ */
2513
2296
  let Messages$1 = class Messages extends APIResource {
2514
2297
  /**
2515
2298
  * Get the messages in a stored chat completion. Only Chat Completions that have
@@ -3872,6 +3655,9 @@ class ChatCompletionStreamingRunner extends ChatCompletionStream {
3872
3655
  }
3873
3656
 
3874
3657
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3658
+ /**
3659
+ * Given a list of messages comprising a conversation, the model will return a response.
3660
+ */
3875
3661
  let Completions$1 = class Completions extends APIResource {
3876
3662
  constructor() {
3877
3663
  super(...arguments);
@@ -4042,10 +3828,15 @@ const buildHeaders = (newHeaders) => {
4042
3828
  };
4043
3829
 
4044
3830
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3831
+ /**
3832
+ * Turn audio into text or text into audio.
3833
+ */
4045
3834
  class Speech extends APIResource {
4046
3835
  /**
4047
3836
  * Generates audio from the input text.
4048
3837
  *
3838
+ * Returns the audio file content, or a stream of audio events.
3839
+ *
4049
3840
  * @example
4050
3841
  * ```ts
4051
3842
  * const speech = await client.audio.speech.create({
@@ -4069,6 +3860,9 @@ class Speech extends APIResource {
4069
3860
  }
4070
3861
 
4071
3862
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3863
+ /**
3864
+ * Turn audio into text or text into audio.
3865
+ */
4072
3866
  class Transcriptions extends APIResource {
4073
3867
  create(body, options) {
4074
3868
  return this._client.post('/audio/transcriptions', multipartFormRequestOptions({
@@ -4081,6 +3875,9 @@ class Transcriptions extends APIResource {
4081
3875
  }
4082
3876
 
4083
3877
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3878
+ /**
3879
+ * Turn audio into text or text into audio.
3880
+ */
4084
3881
  class Translations extends APIResource {
4085
3882
  create(body, options) {
4086
3883
  return this._client.post('/audio/translations', multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }, this._client));
@@ -4101,6 +3898,9 @@ Audio.Translations = Translations;
4101
3898
  Audio.Speech = Speech;
4102
3899
 
4103
3900
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3901
+ /**
3902
+ * Create large batches of API requests to run asynchronously.
3903
+ */
4104
3904
  class Batches extends APIResource {
4105
3905
  /**
4106
3906
  * Creates and executes a batch from an uploaded file of requests
@@ -4131,6 +3931,9 @@ class Batches extends APIResource {
4131
3931
  }
4132
3932
 
4133
3933
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3934
+ /**
3935
+ * Build Assistants that can call models and use tools.
3936
+ */
4134
3937
  class Assistants extends APIResource {
4135
3938
  /**
4136
3939
  * Create an assistant with a model and instructions.
@@ -4261,7 +4064,7 @@ Realtime$1.TranscriptionSessions = TranscriptionSessions;
4261
4064
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4262
4065
  class Sessions extends APIResource {
4263
4066
  /**
4264
- * Create a ChatKit session
4067
+ * Create a ChatKit session.
4265
4068
  *
4266
4069
  * @example
4267
4070
  * ```ts
@@ -4280,7 +4083,9 @@ class Sessions extends APIResource {
4280
4083
  });
4281
4084
  }
4282
4085
  /**
4283
- * Cancel a ChatKit session
4086
+ * Cancel an active ChatKit session and return its most recent metadata.
4087
+ *
4088
+ * Cancelling prevents new requests from using the issued client secret.
4284
4089
  *
4285
4090
  * @example
4286
4091
  * ```ts
@@ -4299,7 +4104,7 @@ class Sessions extends APIResource {
4299
4104
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4300
4105
  let Threads$1 = class Threads extends APIResource {
4301
4106
  /**
4302
- * Retrieve a ChatKit thread
4107
+ * Retrieve a ChatKit thread by its identifier.
4303
4108
  *
4304
4109
  * @example
4305
4110
  * ```ts
@@ -4314,7 +4119,7 @@ let Threads$1 = class Threads extends APIResource {
4314
4119
  });
4315
4120
  }
4316
4121
  /**
4317
- * List ChatKit threads
4122
+ * List ChatKit threads with optional pagination and user filters.
4318
4123
  *
4319
4124
  * @example
4320
4125
  * ```ts
@@ -4332,7 +4137,7 @@ let Threads$1 = class Threads extends APIResource {
4332
4137
  });
4333
4138
  }
4334
4139
  /**
4335
- * Delete a ChatKit thread
4140
+ * Delete a ChatKit thread along with its items and stored attachments.
4336
4141
  *
4337
4142
  * @example
4338
4143
  * ```ts
@@ -4348,7 +4153,7 @@ let Threads$1 = class Threads extends APIResource {
4348
4153
  });
4349
4154
  }
4350
4155
  /**
4351
- * List ChatKit thread items
4156
+ * List items that belong to a ChatKit thread.
4352
4157
  *
4353
4158
  * @example
4354
4159
  * ```ts
@@ -4378,6 +4183,8 @@ ChatKit.Threads = Threads$1;
4378
4183
 
4379
4184
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4380
4185
  /**
4186
+ * Build Assistants that can call models and use tools.
4187
+ *
4381
4188
  * @deprecated The Assistants API is deprecated in favor of the Responses API
4382
4189
  */
4383
4190
  class Messages extends APIResource {
@@ -4446,6 +4253,8 @@ class Messages extends APIResource {
4446
4253
 
4447
4254
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4448
4255
  /**
4256
+ * Build Assistants that can call models and use tools.
4257
+ *
4449
4258
  * @deprecated The Assistants API is deprecated in favor of the Responses API
4450
4259
  */
4451
4260
  class Steps extends APIResource {
@@ -5058,6 +4867,8 @@ _a$1 = AssistantStream, _AssistantStream_addEvent = function _AssistantStream_ad
5058
4867
 
5059
4868
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5060
4869
  /**
4870
+ * Build Assistants that can call models and use tools.
4871
+ *
5061
4872
  * @deprecated The Assistants API is deprecated in favor of the Responses API
5062
4873
  */
5063
4874
  let Runs$1 = class Runs extends APIResource {
@@ -5073,6 +4884,7 @@ let Runs$1 = class Runs extends APIResource {
5073
4884
  ...options,
5074
4885
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5075
4886
  stream: params.stream ?? false,
4887
+ __synthesizeEventData: true,
5076
4888
  });
5077
4889
  }
5078
4890
  /**
@@ -5203,6 +5015,7 @@ let Runs$1 = class Runs extends APIResource {
5203
5015
  ...options,
5204
5016
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5205
5017
  stream: params.stream ?? false,
5018
+ __synthesizeEventData: true,
5206
5019
  });
5207
5020
  }
5208
5021
  /**
@@ -5227,6 +5040,8 @@ Runs$1.Steps = Steps;
5227
5040
 
5228
5041
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5229
5042
  /**
5043
+ * Build Assistants that can call models and use tools.
5044
+ *
5230
5045
  * @deprecated The Assistants API is deprecated in favor of the Responses API
5231
5046
  */
5232
5047
  class Threads extends APIResource {
@@ -5287,6 +5102,7 @@ class Threads extends APIResource {
5287
5102
  ...options,
5288
5103
  headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
5289
5104
  stream: body.stream ?? false,
5105
+ __synthesizeEventData: true,
5290
5106
  });
5291
5107
  }
5292
5108
  /**
@@ -5324,6 +5140,9 @@ Beta.Assistants = Assistants;
5324
5140
  Beta.Threads = Threads;
5325
5141
 
5326
5142
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5143
+ /**
5144
+ * Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.
5145
+ */
5327
5146
  class Completions extends APIResource {
5328
5147
  create(body, options) {
5329
5148
  return this._client.post('/completions', { body, ...options, stream: body.stream ?? false });
@@ -5426,6 +5245,9 @@ class Containers extends APIResource {
5426
5245
  Containers.Files = Files$2;
5427
5246
 
5428
5247
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5248
+ /**
5249
+ * Manage conversations and conversation items.
5250
+ */
5429
5251
  class Items extends APIResource {
5430
5252
  /**
5431
5253
  * Create items in a conversation with the given ID.
@@ -5461,6 +5283,9 @@ class Items extends APIResource {
5461
5283
  }
5462
5284
 
5463
5285
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5286
+ /**
5287
+ * Manage conversations and conversation items.
5288
+ */
5464
5289
  class Conversations extends APIResource {
5465
5290
  constructor() {
5466
5291
  super(...arguments);
@@ -5494,6 +5319,9 @@ class Conversations extends APIResource {
5494
5319
  Conversations.Items = Items;
5495
5320
 
5496
5321
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5322
+ /**
5323
+ * Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
5324
+ */
5497
5325
  class Embeddings extends APIResource {
5498
5326
  /**
5499
5327
  * Creates an embedding vector representing the input text.
@@ -5544,6 +5372,9 @@ class Embeddings extends APIResource {
5544
5372
  }
5545
5373
 
5546
5374
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5375
+ /**
5376
+ * Manage and run evals in the OpenAI platform.
5377
+ */
5547
5378
  class OutputItems extends APIResource {
5548
5379
  /**
5549
5380
  * Get an evaluation run output item by ID.
@@ -5562,6 +5393,9 @@ class OutputItems extends APIResource {
5562
5393
  }
5563
5394
 
5564
5395
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5396
+ /**
5397
+ * Manage and run evals in the OpenAI platform.
5398
+ */
5565
5399
  class Runs extends APIResource {
5566
5400
  constructor() {
5567
5401
  super(...arguments);
@@ -5609,6 +5443,9 @@ class Runs extends APIResource {
5609
5443
  Runs.OutputItems = OutputItems;
5610
5444
 
5611
5445
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5446
+ /**
5447
+ * Manage and run evals in the OpenAI platform.
5448
+ */
5612
5449
  class Evals extends APIResource {
5613
5450
  constructor() {
5614
5451
  super(...arguments);
@@ -5653,6 +5490,9 @@ class Evals extends APIResource {
5653
5490
  Evals.Runs = Runs;
5654
5491
 
5655
5492
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5493
+ /**
5494
+ * Files are used to upload documents that can be used with features like Assistants and Fine-tuning.
5495
+ */
5656
5496
  let Files$1 = class Files extends APIResource {
5657
5497
  /**
5658
5498
  * Upload a file that can be used across various endpoints. Individual files can be
@@ -5732,6 +5572,9 @@ class Methods extends APIResource {
5732
5572
  }
5733
5573
 
5734
5574
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5575
+ /**
5576
+ * Manage fine-tuning jobs to tailor a model to your specific training data.
5577
+ */
5735
5578
  let Graders$1 = class Graders extends APIResource {
5736
5579
  /**
5737
5580
  * Run a grader.
@@ -5785,6 +5628,9 @@ class Alpha extends APIResource {
5785
5628
  Alpha.Graders = Graders$1;
5786
5629
 
5787
5630
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5631
+ /**
5632
+ * Manage fine-tuning jobs to tailor a model to your specific training data.
5633
+ */
5788
5634
  class Permissions extends APIResource {
5789
5635
  /**
5790
5636
  * **NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys).
@@ -5812,13 +5658,7 @@ class Permissions extends APIResource {
5812
5658
  * Organization owners can use this endpoint to view all permissions for a
5813
5659
  * fine-tuned model checkpoint.
5814
5660
  *
5815
- * @example
5816
- * ```ts
5817
- * const permission =
5818
- * await client.fineTuning.checkpoints.permissions.retrieve(
5819
- * 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
5820
- * );
5821
- * ```
5661
+ * @deprecated Retrieve is deprecated. Please swap to the paginated list method instead.
5822
5662
  */
5823
5663
  retrieve(fineTunedModelCheckpoint, query = {}, options) {
5824
5664
  return this._client.get(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, {
@@ -5826,6 +5666,25 @@ class Permissions extends APIResource {
5826
5666
  ...options,
5827
5667
  });
5828
5668
  }
5669
+ /**
5670
+ * **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
5671
+ *
5672
+ * Organization owners can use this endpoint to view all permissions for a
5673
+ * fine-tuned model checkpoint.
5674
+ *
5675
+ * @example
5676
+ * ```ts
5677
+ * // Automatically fetches more pages as needed.
5678
+ * for await (const permissionListResponse of client.fineTuning.checkpoints.permissions.list(
5679
+ * 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
5680
+ * )) {
5681
+ * // ...
5682
+ * }
5683
+ * ```
5684
+ */
5685
+ list(fineTunedModelCheckpoint, query = {}, options) {
5686
+ return this._client.getAPIList(path `/fine_tuning/checkpoints/${fineTunedModelCheckpoint}/permissions`, (ConversationCursorPage), { query, ...options });
5687
+ }
5829
5688
  /**
5830
5689
  * **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
5831
5690
  *
@@ -5860,6 +5719,9 @@ let Checkpoints$1 = class Checkpoints extends APIResource {
5860
5719
  Checkpoints$1.Permissions = Permissions;
5861
5720
 
5862
5721
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5722
+ /**
5723
+ * Manage fine-tuning jobs to tailor a model to your specific training data.
5724
+ */
5863
5725
  class Checkpoints extends APIResource {
5864
5726
  /**
5865
5727
  * List checkpoints for a fine-tuning job.
@@ -5880,6 +5742,9 @@ class Checkpoints extends APIResource {
5880
5742
  }
5881
5743
 
5882
5744
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5745
+ /**
5746
+ * Manage fine-tuning jobs to tailor a model to your specific training data.
5747
+ */
5883
5748
  class Jobs extends APIResource {
5884
5749
  constructor() {
5885
5750
  super(...arguments);
@@ -6021,6 +5886,9 @@ class Graders extends APIResource {
6021
5886
  Graders.GraderModels = GraderModels;
6022
5887
 
6023
5888
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5889
+ /**
5890
+ * Given a prompt and/or an input image, the model will generate a new image.
5891
+ */
6024
5892
  class Images extends APIResource {
6025
5893
  /**
6026
5894
  * Creates a variation of a given image. This endpoint only supports `dall-e-2`.
@@ -6044,6 +5912,9 @@ class Images extends APIResource {
6044
5912
  }
6045
5913
 
6046
5914
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5915
+ /**
5916
+ * List and describe the various models available in the API.
5917
+ */
6047
5918
  class Models extends APIResource {
6048
5919
  /**
6049
5920
  * Retrieves a model instance, providing basic information about the model such as
@@ -6069,6 +5940,9 @@ class Models extends APIResource {
6069
5940
  }
6070
5941
 
6071
5942
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
5943
+ /**
5944
+ * Given text and/or image inputs, classifies if those inputs are potentially harmful.
5945
+ */
6072
5946
  class Moderations extends APIResource {
6073
5947
  /**
6074
5948
  * Classifies if text and/or image inputs are potentially harmful. Learn more in
@@ -6152,6 +6026,20 @@ class ClientSecrets extends APIResource {
6152
6026
  /**
6153
6027
  * Create a Realtime client secret with an associated session configuration.
6154
6028
  *
6029
+ * Client secrets are short-lived tokens that can be passed to a client app, such
6030
+ * as a web frontend or mobile client, which grants access to the Realtime API
6031
+ * without leaking your main API key. You can configure a custom TTL for each
6032
+ * client secret.
6033
+ *
6034
+ * You can also attach session configuration options to the client secret, which
6035
+ * will be applied to any sessions created using that client secret, but these can
6036
+ * also be overridden by the client connection.
6037
+ *
6038
+ * [Learn more about authentication with client secrets over WebRTC](https://platform.openai.com/docs/guides/realtime-webrtc).
6039
+ *
6040
+ * Returns the created client secret and the effective session object. The client
6041
+ * secret is a string that looks like `ek_1234`.
6042
+ *
6155
6043
  * @example
6156
6044
  * ```ts
6157
6045
  * const clientSecret =
@@ -6577,7 +6465,10 @@ class InputItems extends APIResource {
6577
6465
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6578
6466
  class InputTokens extends APIResource {
6579
6467
  /**
6580
- * Get input token counts
6468
+ * Returns input token counts of the request.
6469
+ *
6470
+ * Returns an object with `object` set to `response.input_tokens` and an
6471
+ * `input_tokens` count.
6581
6472
  *
6582
6473
  * @example
6583
6474
  * ```ts
@@ -6659,12 +6550,17 @@ class Responses extends APIResource {
6659
6550
  return this._client.post(path `/responses/${responseID}/cancel`, options);
6660
6551
  }
6661
6552
  /**
6662
- * Compact conversation
6553
+ * Compact a conversation. Returns a compacted response object.
6554
+ *
6555
+ * Learn when and how to compact long-running conversations in the
6556
+ * [conversation state guide](https://platform.openai.com/docs/guides/conversation-state#managing-the-context-window).
6557
+ * For ZDR-compatible compaction details, see
6558
+ * [Compaction (advanced)](https://platform.openai.com/docs/guides/conversation-state#compaction-advanced).
6663
6559
  *
6664
6560
  * @example
6665
6561
  * ```ts
6666
6562
  * const compactedResponse = await client.responses.compact({
6667
- * model: 'gpt-5.2',
6563
+ * model: 'gpt-5.4',
6668
6564
  * });
6669
6565
  * ```
6670
6566
  */
@@ -6678,7 +6574,7 @@ Responses.InputTokens = InputTokens;
6678
6574
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6679
6575
  let Content$1 = class Content extends APIResource {
6680
6576
  /**
6681
- * Get Skill Content
6577
+ * Download a skill zip bundle by its ID.
6682
6578
  */
6683
6579
  retrieve(skillID, options) {
6684
6580
  return this._client.get(path `/skills/${skillID}/content`, {
@@ -6692,7 +6588,7 @@ let Content$1 = class Content extends APIResource {
6692
6588
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6693
6589
  class Content extends APIResource {
6694
6590
  /**
6695
- * Get Skill Version Content
6591
+ * Download a skill version zip bundle.
6696
6592
  */
6697
6593
  retrieve(version, params, options) {
6698
6594
  const { skill_id } = params;
@@ -6711,20 +6607,20 @@ class Versions extends APIResource {
6711
6607
  this.content = new Content(this._client);
6712
6608
  }
6713
6609
  /**
6714
- * Create Skill Version
6610
+ * Create a new immutable skill version.
6715
6611
  */
6716
6612
  create(skillID, body = {}, options) {
6717
6613
  return this._client.post(path `/skills/${skillID}/versions`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
6718
6614
  }
6719
6615
  /**
6720
- * Get Skill Version
6616
+ * Get a specific skill version.
6721
6617
  */
6722
6618
  retrieve(version, params, options) {
6723
6619
  const { skill_id } = params;
6724
6620
  return this._client.get(path `/skills/${skill_id}/versions/${version}`, options);
6725
6621
  }
6726
6622
  /**
6727
- * List Skill Versions
6623
+ * List skill versions for a skill.
6728
6624
  */
6729
6625
  list(skillID, query = {}, options) {
6730
6626
  return this._client.getAPIList(path `/skills/${skillID}/versions`, (CursorPage), {
@@ -6733,7 +6629,7 @@ class Versions extends APIResource {
6733
6629
  });
6734
6630
  }
6735
6631
  /**
6736
- * Delete Skill Version
6632
+ * Delete a skill version.
6737
6633
  */
6738
6634
  delete(version, params, options) {
6739
6635
  const { skill_id } = params;
@@ -6750,31 +6646,31 @@ class Skills extends APIResource {
6750
6646
  this.versions = new Versions(this._client);
6751
6647
  }
6752
6648
  /**
6753
- * Create Skill
6649
+ * Create a new skill.
6754
6650
  */
6755
6651
  create(body = {}, options) {
6756
6652
  return this._client.post('/skills', maybeMultipartFormRequestOptions({ body, ...options }, this._client));
6757
6653
  }
6758
6654
  /**
6759
- * Get Skill
6655
+ * Get a skill by its ID.
6760
6656
  */
6761
6657
  retrieve(skillID, options) {
6762
6658
  return this._client.get(path `/skills/${skillID}`, options);
6763
6659
  }
6764
6660
  /**
6765
- * Update Skill Default Version
6661
+ * Update the default version pointer for a skill.
6766
6662
  */
6767
6663
  update(skillID, body, options) {
6768
6664
  return this._client.post(path `/skills/${skillID}`, { body, ...options });
6769
6665
  }
6770
6666
  /**
6771
- * List Skills
6667
+ * List all skills for the current project.
6772
6668
  */
6773
6669
  list(query = {}, options) {
6774
6670
  return this._client.getAPIList('/skills', (CursorPage), { query, ...options });
6775
6671
  }
6776
6672
  /**
6777
- * Delete Skill
6673
+ * Delete a skill by its ID.
6778
6674
  */
6779
6675
  delete(skillID, options) {
6780
6676
  return this._client.delete(path `/skills/${skillID}`, options);
@@ -6784,6 +6680,9 @@ Skills.Content = Content$1;
6784
6680
  Skills.Versions = Versions;
6785
6681
 
6786
6682
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6683
+ /**
6684
+ * Use Uploads to upload large files in multiple parts.
6685
+ */
6787
6686
  class Parts extends APIResource {
6788
6687
  /**
6789
6688
  * Adds a
@@ -6804,6 +6703,9 @@ class Parts extends APIResource {
6804
6703
  }
6805
6704
 
6806
6705
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6706
+ /**
6707
+ * Use Uploads to upload large files in multiple parts.
6708
+ */
6807
6709
  class Uploads extends APIResource {
6808
6710
  constructor() {
6809
6711
  super(...arguments);
@@ -6829,12 +6731,16 @@ class Uploads extends APIResource {
6829
6731
  * For guidance on the proper filename extensions for each purpose, please follow
6830
6732
  * the documentation on
6831
6733
  * [creating a File](https://platform.openai.com/docs/api-reference/files/create).
6734
+ *
6735
+ * Returns the Upload object with status `pending`.
6832
6736
  */
6833
6737
  create(body, options) {
6834
6738
  return this._client.post('/uploads', { body, ...options });
6835
6739
  }
6836
6740
  /**
6837
6741
  * Cancels the Upload. No Parts may be added after an Upload is cancelled.
6742
+ *
6743
+ * Returns the Upload object with status `cancelled`.
6838
6744
  */
6839
6745
  cancel(uploadID, options) {
6840
6746
  return this._client.post(path `/uploads/${uploadID}/cancel`, options);
@@ -6852,7 +6758,9 @@ class Uploads extends APIResource {
6852
6758
  *
6853
6759
  * The number of bytes uploaded upon completion must match the number of bytes
6854
6760
  * initially specified when creating the Upload object. No Parts may be added after
6855
- * an Upload is completed.
6761
+ * an Upload is completed. Returns the Upload object with status `completed`,
6762
+ * including an additional `file` property containing the created usable File
6763
+ * object.
6856
6764
  */
6857
6765
  complete(uploadID, body, options) {
6858
6766
  return this._client.post(path `/uploads/${uploadID}/complete`, { body, ...options });
@@ -7212,31 +7120,33 @@ VectorStores.FileBatches = FileBatches;
7212
7120
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
7213
7121
  class Videos extends APIResource {
7214
7122
  /**
7215
- * Create a video
7123
+ * Create a new video generation job from a prompt and optional reference assets.
7216
7124
  */
7217
7125
  create(body, options) {
7218
7126
  return this._client.post('/videos', maybeMultipartFormRequestOptions({ body, ...options }, this._client));
7219
7127
  }
7220
7128
  /**
7221
- * Retrieve a video
7129
+ * Fetch the latest metadata for a generated video.
7222
7130
  */
7223
7131
  retrieve(videoID, options) {
7224
7132
  return this._client.get(path `/videos/${videoID}`, options);
7225
7133
  }
7226
7134
  /**
7227
- * List videos
7135
+ * List recently generated videos for the current project.
7228
7136
  */
7229
7137
  list(query = {}, options) {
7230
7138
  return this._client.getAPIList('/videos', (ConversationCursorPage), { query, ...options });
7231
7139
  }
7232
7140
  /**
7233
- * Delete a video
7141
+ * Permanently delete a completed or failed video and its stored assets.
7234
7142
  */
7235
7143
  delete(videoID, options) {
7236
7144
  return this._client.delete(path `/videos/${videoID}`, options);
7237
7145
  }
7238
7146
  /**
7239
- * Download video content
7147
+ * Download the generated video bytes or a derived preview asset.
7148
+ *
7149
+ * Streams the rendered video content for the specified video job.
7240
7150
  */
7241
7151
  downloadContent(videoID, query = {}, options) {
7242
7152
  return this._client.get(path `/videos/${videoID}/content`, {
@@ -7247,7 +7157,7 @@ class Videos extends APIResource {
7247
7157
  });
7248
7158
  }
7249
7159
  /**
7250
- * Create a video remix
7160
+ * Create a remix of a completed video using a refreshed prompt.
7251
7161
  */
7252
7162
  remix(videoID, body, options) {
7253
7163
  return this._client.post(path `/videos/${videoID}/remix`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
@@ -7372,24 +7282,54 @@ class OpenAI {
7372
7282
  constructor({ baseURL = readEnv('OPENAI_BASE_URL'), apiKey = readEnv('OPENAI_API_KEY'), organization = readEnv('OPENAI_ORG_ID') ?? null, project = readEnv('OPENAI_PROJECT_ID') ?? null, webhookSecret = readEnv('OPENAI_WEBHOOK_SECRET') ?? null, ...opts } = {}) {
7373
7283
  _OpenAI_instances.add(this);
7374
7284
  _OpenAI_encoder.set(this, void 0);
7285
+ /**
7286
+ * Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.
7287
+ */
7375
7288
  this.completions = new Completions(this);
7376
7289
  this.chat = new Chat(this);
7290
+ /**
7291
+ * Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
7292
+ */
7377
7293
  this.embeddings = new Embeddings(this);
7294
+ /**
7295
+ * Files are used to upload documents that can be used with features like Assistants and Fine-tuning.
7296
+ */
7378
7297
  this.files = new Files$1(this);
7298
+ /**
7299
+ * Given a prompt and/or an input image, the model will generate a new image.
7300
+ */
7379
7301
  this.images = new Images(this);
7380
7302
  this.audio = new Audio(this);
7303
+ /**
7304
+ * Given text and/or image inputs, classifies if those inputs are potentially harmful.
7305
+ */
7381
7306
  this.moderations = new Moderations(this);
7307
+ /**
7308
+ * List and describe the various models available in the API.
7309
+ */
7382
7310
  this.models = new Models(this);
7383
7311
  this.fineTuning = new FineTuning(this);
7384
7312
  this.graders = new Graders(this);
7385
7313
  this.vectorStores = new VectorStores(this);
7386
7314
  this.webhooks = new Webhooks(this);
7387
7315
  this.beta = new Beta(this);
7316
+ /**
7317
+ * Create large batches of API requests to run asynchronously.
7318
+ */
7388
7319
  this.batches = new Batches(this);
7320
+ /**
7321
+ * Use Uploads to upload large files in multiple parts.
7322
+ */
7389
7323
  this.uploads = new Uploads(this);
7390
7324
  this.responses = new Responses(this);
7391
7325
  this.realtime = new Realtime(this);
7326
+ /**
7327
+ * Manage conversations and conversation items.
7328
+ */
7392
7329
  this.conversations = new Conversations(this);
7330
+ /**
7331
+ * Manage and run evals in the OpenAI platform.
7332
+ */
7393
7333
  this.evals = new Evals(this);
7394
7334
  this.containers = new Containers(this);
7395
7335
  this.skills = new Skills(this);
@@ -7459,7 +7399,7 @@ class OpenAI {
7459
7399
  return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
7460
7400
  }
7461
7401
  stringifyQuery(query) {
7462
- return stringify(query, { arrayFormat: 'brackets' });
7402
+ return stringifyQuery(query);
7463
7403
  }
7464
7404
  getUserAgent() {
7465
7405
  return `${this.constructor.name}/JS ${VERSION}`;
@@ -7728,9 +7668,9 @@ class OpenAI {
7728
7668
  timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
7729
7669
  }
7730
7670
  }
7731
- // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
7732
- // just do what it says, but otherwise calculate a default
7733
- if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
7671
+ // If the API asks us to wait a certain amount of time, just do what it
7672
+ // says, but otherwise calculate a default
7673
+ if (timeoutMillis === undefined) {
7734
7674
  const maxRetries = options.maxRetries ?? this.maxRetries;
7735
7675
  timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
7736
7676
  }
@@ -7827,6 +7767,13 @@ class OpenAI {
7827
7767
  (Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
7828
7768
  return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
7829
7769
  }
7770
+ else if (typeof body === 'object' &&
7771
+ headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
7772
+ return {
7773
+ bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
7774
+ body: this.stringifyQuery(body),
7775
+ };
7776
+ }
7830
7777
  else {
7831
7778
  return __classPrivateFieldGet(this, _OpenAI_encoder, "f").call(this, { body, headers });
7832
7779
  }