@discomedia/utils 1.0.30 → 1.0.32

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/index.mjs CHANGED
@@ -665,7 +665,8 @@ function getMarketStatusImpl(date = new Date()) {
665
665
  const nextMarketDay = calendar.getNextMarketDay(date);
666
666
  nextStatusTime = getDayBoundaries(nextMarketDay, 'extended_hours').start;
667
667
  }
668
- const nextStatusTimeDifference = nextStatusTime.getTime() - nyDate.getTime();
668
+ // I think using nyDate here may be wrong - should use current time? i.e. date.getTime()
669
+ const nextStatusTimeDifference = nextStatusTime.getTime() - date.getTime();
669
670
  return {
670
671
  time: date,
671
672
  timeString: formatNYLocale(nyDate),
@@ -1446,7 +1447,7 @@ function pLimit(concurrency) {
1446
1447
  },
1447
1448
  map: {
1448
1449
  async value(array, function_) {
1449
- const promises = array.map(value => this(function_, value));
1450
+ const promises = array.map((value, index) => this(function_, value, index));
1450
1451
  return Promise.all(promises);
1451
1452
  },
1452
1453
  },
@@ -2392,7 +2393,7 @@ const safeJSON = (text) => {
2392
2393
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2393
2394
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
2394
2395
 
2395
- const VERSION = '5.12.2'; // x-release-please-version
2396
+ const VERSION = '5.16.0'; // x-release-please-version
2396
2397
 
2397
2398
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2398
2399
  const isRunningInBrowser = () => {
@@ -3732,6 +3733,36 @@ class CursorPage extends AbstractPage {
3732
3733
  };
3733
3734
  }
3734
3735
  }
3736
+ class ConversationCursorPage extends AbstractPage {
3737
+ constructor(client, response, body, options) {
3738
+ super(client, response, body, options);
3739
+ this.data = body.data || [];
3740
+ this.has_more = body.has_more || false;
3741
+ this.last_id = body.last_id || '';
3742
+ }
3743
+ getPaginatedItems() {
3744
+ return this.data ?? [];
3745
+ }
3746
+ hasNextPage() {
3747
+ if (this.has_more === false) {
3748
+ return false;
3749
+ }
3750
+ return super.hasNextPage();
3751
+ }
3752
+ nextPageRequestOptions() {
3753
+ const cursor = this.last_id;
3754
+ if (!cursor) {
3755
+ return null;
3756
+ }
3757
+ return {
3758
+ ...this.options,
3759
+ query: {
3760
+ ...maybeObj(this.options.query),
3761
+ after: cursor,
3762
+ },
3763
+ };
3764
+ }
3765
+ }
3735
3766
 
3736
3767
  const checkFileSupport = () => {
3737
3768
  if (typeof File === 'undefined') {
@@ -6822,6 +6853,74 @@ class Containers extends APIResource {
6822
6853
  }
6823
6854
  Containers.Files = Files$2;
6824
6855
 
6856
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6857
+ class Items extends APIResource {
6858
+ /**
6859
+ * Create items in a conversation with the given ID.
6860
+ */
6861
+ create(conversationID, params, options) {
6862
+ const { include, ...body } = params;
6863
+ return this._client.post(path `/conversations/${conversationID}/items`, {
6864
+ query: { include },
6865
+ body,
6866
+ ...options,
6867
+ });
6868
+ }
6869
+ /**
6870
+ * Get a single item from a conversation with the given IDs.
6871
+ */
6872
+ retrieve(itemID, params, options) {
6873
+ const { conversation_id, ...query } = params;
6874
+ return this._client.get(path `/conversations/${conversation_id}/items/${itemID}`, { query, ...options });
6875
+ }
6876
+ /**
6877
+ * List all items for a conversation with the given ID.
6878
+ */
6879
+ list(conversationID, query = {}, options) {
6880
+ return this._client.getAPIList(path `/conversations/${conversationID}/items`, (ConversationCursorPage), { query, ...options });
6881
+ }
6882
+ /**
6883
+ * Delete an item from a conversation with the given IDs.
6884
+ */
6885
+ delete(itemID, params, options) {
6886
+ const { conversation_id } = params;
6887
+ return this._client.delete(path `/conversations/${conversation_id}/items/${itemID}`, options);
6888
+ }
6889
+ }
6890
+
6891
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6892
+ class Conversations extends APIResource {
6893
+ constructor() {
6894
+ super(...arguments);
6895
+ this.items = new Items(this._client);
6896
+ }
6897
+ /**
6898
+ * Create a conversation.
6899
+ */
6900
+ create(body, options) {
6901
+ return this._client.post('/conversations', { body, ...options });
6902
+ }
6903
+ /**
6904
+ * Get a conversation with the given ID.
6905
+ */
6906
+ retrieve(conversationID, options) {
6907
+ return this._client.get(path `/conversations/${conversationID}`, options);
6908
+ }
6909
+ /**
6910
+ * Update a conversation's metadata with the given ID.
6911
+ */
6912
+ update(conversationID, body, options) {
6913
+ return this._client.post(path `/conversations/${conversationID}`, { body, ...options });
6914
+ }
6915
+ /**
6916
+ * Delete a conversation with the given ID.
6917
+ */
6918
+ delete(conversationID, options) {
6919
+ return this._client.delete(path `/conversations/${conversationID}`, options);
6920
+ }
6921
+ }
6922
+ Conversations.Items = Items;
6923
+
6825
6924
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
6826
6925
  class Embeddings extends APIResource {
6827
6926
  /**
@@ -6986,7 +7085,7 @@ let Files$1 = class Files extends APIResource {
6986
7085
  /**
6987
7086
  * Upload a file that can be used across various endpoints. Individual files can be
6988
7087
  * up to 512 MB, and the size of all files uploaded by one organization can be up
6989
- * to 100 GB.
7088
+ * to 1 TB.
6990
7089
  *
6991
7090
  * The Assistants API supports files up to 2 million tokens and of specific file
6992
7091
  * types. See the
@@ -8415,6 +8514,7 @@ class OpenAI {
8415
8514
  this.batches = new Batches(this);
8416
8515
  this.uploads = new Uploads(this);
8417
8516
  this.responses = new Responses(this);
8517
+ this.conversations = new Conversations(this);
8418
8518
  this.evals = new Evals(this);
8419
8519
  this.containers = new Containers(this);
8420
8520
  if (apiKey === undefined) {
@@ -8805,7 +8905,7 @@ class OpenAI {
8805
8905
  // Preserve legacy string encoding behavior for now
8806
8906
  headers.values.has('content-type')) ||
8807
8907
  // `Blob` is superset of `File`
8808
- body instanceof Blob ||
8908
+ (globalThis.Blob && body instanceof globalThis.Blob) ||
8809
8909
  // `FormData` -> `multipart/form-data`
8810
8910
  body instanceof FormData ||
8811
8911
  // `URLSearchParams` -> `application/x-www-form-urlencoded`
@@ -8860,6 +8960,7 @@ OpenAI.Beta = Beta;
8860
8960
  OpenAI.Batches = Batches;
8861
8961
  OpenAI.Uploads = Uploads;
8862
8962
  OpenAI.Responses = Responses;
8963
+ OpenAI.Conversations = Conversations;
8863
8964
  OpenAI.Evals = Evals;
8864
8965
  OpenAI.Containers = Containers;
8865
8966