@discomedia/utils 1.0.57 → 1.0.59

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.
@@ -258,7 +258,7 @@ const safeJSON = (text) => {
258
258
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
259
259
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
260
260
 
261
- const VERSION = '6.17.0'; // x-release-please-version
261
+ const VERSION = '6.22.0'; // x-release-please-version
262
262
 
263
263
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
264
264
  const isRunningInBrowser = () => {
@@ -1391,6 +1391,11 @@ async function defaultParseResponse(client, props) {
1391
1391
  const mediaType = contentType?.split(';')[0]?.trim();
1392
1392
  const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
1393
1393
  if (isJSON) {
1394
+ const contentLength = response.headers.get('content-length');
1395
+ if (contentLength === '0') {
1396
+ // if there is no content we can't do anything
1397
+ return undefined;
1398
+ }
1394
1399
  const json = await response.json();
1395
1400
  return addRequestID(json, response);
1396
1401
  }
@@ -4747,7 +4752,7 @@ class Completions extends APIResource {
4747
4752
  }
4748
4753
 
4749
4754
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4750
- class Content extends APIResource {
4755
+ let Content$2 = class Content extends APIResource {
4751
4756
  /**
4752
4757
  * Retrieve Container File Content
4753
4758
  */
@@ -4759,13 +4764,13 @@ class Content extends APIResource {
4759
4764
  __binaryResponse: true,
4760
4765
  });
4761
4766
  }
4762
- }
4767
+ };
4763
4768
 
4764
4769
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4765
4770
  let Files$2 = class Files extends APIResource {
4766
4771
  constructor() {
4767
4772
  super(...arguments);
4768
- this.content = new Content(this._client);
4773
+ this.content = new Content$2(this._client);
4769
4774
  }
4770
4775
  /**
4771
4776
  * Create a Container File
@@ -4774,7 +4779,7 @@ let Files$2 = class Files extends APIResource {
4774
4779
  * a JSON request with a file ID.
4775
4780
  */
4776
4781
  create(containerID, body, options) {
4777
- return this._client.post(path `/containers/${containerID}/files`, multipartFormRequestOptions({ body, ...options }, this._client));
4782
+ return this._client.post(path `/containers/${containerID}/files`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
4778
4783
  }
4779
4784
  /**
4780
4785
  * Retrieve Container File
@@ -4803,7 +4808,7 @@ let Files$2 = class Files extends APIResource {
4803
4808
  });
4804
4809
  }
4805
4810
  };
4806
- Files$2.Content = Content;
4811
+ Files$2.Content = Content$2;
4807
4812
 
4808
4813
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4809
4814
  class Containers extends APIResource {
@@ -6091,6 +6096,114 @@ class Responses extends APIResource {
6091
6096
  Responses.InputItems = InputItems;
6092
6097
  Responses.InputTokens = InputTokens;
6093
6098
 
6099
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6100
+ let Content$1 = class Content extends APIResource {
6101
+ /**
6102
+ * Get Skill Content
6103
+ */
6104
+ retrieve(skillID, options) {
6105
+ return this._client.get(path `/skills/${skillID}/content`, {
6106
+ ...options,
6107
+ headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
6108
+ __binaryResponse: true,
6109
+ });
6110
+ }
6111
+ };
6112
+
6113
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6114
+ class Content extends APIResource {
6115
+ /**
6116
+ * Get Skill Version Content
6117
+ */
6118
+ retrieve(version, params, options) {
6119
+ const { skill_id } = params;
6120
+ return this._client.get(path `/skills/${skill_id}/versions/${version}/content`, {
6121
+ ...options,
6122
+ headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
6123
+ __binaryResponse: true,
6124
+ });
6125
+ }
6126
+ }
6127
+
6128
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6129
+ class Versions extends APIResource {
6130
+ constructor() {
6131
+ super(...arguments);
6132
+ this.content = new Content(this._client);
6133
+ }
6134
+ /**
6135
+ * Create Skill Version
6136
+ */
6137
+ create(skillID, body = {}, options) {
6138
+ return this._client.post(path `/skills/${skillID}/versions`, maybeMultipartFormRequestOptions({ body, ...options }, this._client));
6139
+ }
6140
+ /**
6141
+ * Get Skill Version
6142
+ */
6143
+ retrieve(version, params, options) {
6144
+ const { skill_id } = params;
6145
+ return this._client.get(path `/skills/${skill_id}/versions/${version}`, options);
6146
+ }
6147
+ /**
6148
+ * List Skill Versions
6149
+ */
6150
+ list(skillID, query = {}, options) {
6151
+ return this._client.getAPIList(path `/skills/${skillID}/versions`, (CursorPage), {
6152
+ query,
6153
+ ...options,
6154
+ });
6155
+ }
6156
+ /**
6157
+ * Delete Skill Version
6158
+ */
6159
+ delete(version, params, options) {
6160
+ const { skill_id } = params;
6161
+ return this._client.delete(path `/skills/${skill_id}/versions/${version}`, options);
6162
+ }
6163
+ }
6164
+ Versions.Content = Content;
6165
+
6166
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6167
+ class Skills extends APIResource {
6168
+ constructor() {
6169
+ super(...arguments);
6170
+ this.content = new Content$1(this._client);
6171
+ this.versions = new Versions(this._client);
6172
+ }
6173
+ /**
6174
+ * Create Skill
6175
+ */
6176
+ create(body = {}, options) {
6177
+ return this._client.post('/skills', maybeMultipartFormRequestOptions({ body, ...options }, this._client));
6178
+ }
6179
+ /**
6180
+ * Get Skill
6181
+ */
6182
+ retrieve(skillID, options) {
6183
+ return this._client.get(path `/skills/${skillID}`, options);
6184
+ }
6185
+ /**
6186
+ * Update Skill Default Version
6187
+ */
6188
+ update(skillID, body, options) {
6189
+ return this._client.post(path `/skills/${skillID}`, { body, ...options });
6190
+ }
6191
+ /**
6192
+ * List Skills
6193
+ */
6194
+ list(query = {}, options) {
6195
+ return this._client.getAPIList('/skills', (CursorPage), { query, ...options });
6196
+ }
6197
+ /**
6198
+ * Delete Skill
6199
+ */
6200
+ delete(skillID, options) {
6201
+ return this._client.delete(path `/skills/${skillID}`, options);
6202
+ }
6203
+ }
6204
+ Skills.Content = Content$1;
6205
+ Skills.Versions = Versions;
6206
+
6094
6207
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6095
6208
  class Parts extends APIResource {
6096
6209
  /**
@@ -6700,6 +6813,7 @@ class OpenAI {
6700
6813
  this.conversations = new Conversations(this);
6701
6814
  this.evals = new Evals(this);
6702
6815
  this.containers = new Containers(this);
6816
+ this.skills = new Skills(this);
6703
6817
  this.videos = new Videos(this);
6704
6818
  if (apiKey === undefined) {
6705
6819
  throw new OpenAIError('Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.');
@@ -6957,7 +7071,9 @@ class OpenAI {
6957
7071
  return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
6958
7072
  }
6959
7073
  getAPIList(path, Page, opts) {
6960
- return this.requestAPIList(Page, { method: 'get', path, ...opts });
7074
+ return this.requestAPIList(Page, opts && 'then' in opts ?
7075
+ opts.then((opts) => ({ method: 'get', path, ...opts }))
7076
+ : { method: 'get', path, ...opts });
6961
7077
  }
6962
7078
  requestAPIList(Page, options) {
6963
7079
  const request = this.makeRequest(options, null, undefined);
@@ -6965,9 +7081,10 @@ class OpenAI {
6965
7081
  }
6966
7082
  async fetchWithTimeout(url, init, ms, controller) {
6967
7083
  const { signal, method, ...options } = init || {};
7084
+ const abort = this._makeAbort(controller);
6968
7085
  if (signal)
6969
- signal.addEventListener('abort', () => controller.abort());
6970
- const timeout = setTimeout(() => controller.abort(), ms);
7086
+ signal.addEventListener('abort', abort, { once: true });
7087
+ const timeout = setTimeout(abort, ms);
6971
7088
  const isReadableBody = (globalThis.ReadableStream && options.body instanceof globalThis.ReadableStream) ||
6972
7089
  (typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body);
6973
7090
  const fetchOptions = {
@@ -7098,6 +7215,11 @@ class OpenAI {
7098
7215
  this.validateHeaders(headers);
7099
7216
  return headers.values;
7100
7217
  }
7218
+ _makeAbort(controller) {
7219
+ // note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
7220
+ // would capture all request options, and cause a memory leak.
7221
+ return () => controller.abort();
7222
+ }
7101
7223
  buildBody({ options: { body, headers: rawHeaders } }) {
7102
7224
  if (!body) {
7103
7225
  return { bodyHeaders: undefined, body: undefined };
@@ -7171,6 +7293,7 @@ OpenAI.Realtime = Realtime;
7171
7293
  OpenAI.Conversations = Conversations;
7172
7294
  OpenAI.Evals = Evals;
7173
7295
  OpenAI.Containers = Containers;
7296
+ OpenAI.Skills = Skills;
7174
7297
  OpenAI.Videos = Videos;
7175
7298
 
7176
7299
  // llm-openai-config.ts