@discomedia/utils 1.0.16 → 1.0.18

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.
@@ -249,7 +249,7 @@ const safeJSON = (text) => {
249
249
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
250
250
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
251
251
 
252
- const VERSION = '5.9.0'; // x-release-please-version
252
+ const VERSION = '5.10.1'; // x-release-please-version
253
253
 
254
254
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
255
255
  const isRunningInBrowser = () => {
@@ -1106,6 +1106,8 @@ class Stream {
1106
1106
  }
1107
1107
  if (sse.event === null ||
1108
1108
  sse.event.startsWith('response.') ||
1109
+ sse.event.startsWith('image_edit.') ||
1110
+ sse.event.startsWith('image_generation.') ||
1109
1111
  sse.event.startsWith('transcript.')) {
1110
1112
  let data;
1111
1113
  try {
@@ -5209,34 +5211,11 @@ class Images extends APIResource {
5209
5211
  createVariation(body, options) {
5210
5212
  return this._client.post('/images/variations', multipartFormRequestOptions({ body, ...options }, this._client));
5211
5213
  }
5212
- /**
5213
- * Creates an edited or extended image given one or more source images and a
5214
- * prompt. This endpoint only supports `gpt-image-1` and `dall-e-2`.
5215
- *
5216
- * @example
5217
- * ```ts
5218
- * const imagesResponse = await client.images.edit({
5219
- * image: fs.createReadStream('path/to/file'),
5220
- * prompt: 'A cute baby sea otter wearing a beret',
5221
- * });
5222
- * ```
5223
- */
5224
5214
  edit(body, options) {
5225
- return this._client.post('/images/edits', multipartFormRequestOptions({ body, ...options }, this._client));
5215
+ return this._client.post('/images/edits', multipartFormRequestOptions({ body, ...options, stream: body.stream ?? false }, this._client));
5226
5216
  }
5227
- /**
5228
- * Creates an image given a prompt.
5229
- * [Learn more](https://platform.openai.com/docs/guides/images).
5230
- *
5231
- * @example
5232
- * ```ts
5233
- * const imagesResponse = await client.images.generate({
5234
- * prompt: 'A cute baby sea otter',
5235
- * });
5236
- * ```
5237
- */
5238
5217
  generate(body, options) {
5239
- return this._client.post('/images/generations', { body, ...options });
5218
+ return this._client.post('/images/generations', { body, ...options, stream: body.stream ?? false });
5240
5219
  }
5241
5220
  }
5242
5221
 
@@ -13739,16 +13718,24 @@ class MarketTimeCalculator {
13739
13718
  /**
13740
13719
  * Get the last full trading date
13741
13720
  */
13742
- getLastFullTradingDate(currentDate = new Date()) {
13721
+ getLastFullTradingDate(currentDate = new Date(), extendedHours = true) {
13743
13722
  const nowET = toZonedTime(currentDate, this.timezone);
13744
- // If today is a market day and we're after extended hours close, return today
13745
13723
  if (this.calendar.isMarketDay(nowET)) {
13746
13724
  const timeInMinutes = nowET.getHours() * 60 + nowET.getMinutes();
13747
- let extendedEndMinutes = MARKET_CONFIG.TIMES.EXTENDED_END.hour * 60 + MARKET_CONFIG.TIMES.EXTENDED_END.minute;
13748
- if (this.calendar.isEarlyCloseDay(nowET)) {
13749
- extendedEndMinutes = MARKET_CONFIG.TIMES.EARLY_EXTENDED_END.hour * 60 + MARKET_CONFIG.TIMES.EARLY_EXTENDED_END.minute;
13725
+ let endMinutes;
13726
+ if (extendedHours) {
13727
+ endMinutes = MARKET_CONFIG.TIMES.EXTENDED_END.hour * 60 + MARKET_CONFIG.TIMES.EXTENDED_END.minute;
13728
+ if (this.calendar.isEarlyCloseDay(nowET)) {
13729
+ endMinutes = MARKET_CONFIG.TIMES.EARLY_EXTENDED_END.hour * 60 + MARKET_CONFIG.TIMES.EARLY_EXTENDED_END.minute;
13730
+ }
13731
+ }
13732
+ else {
13733
+ endMinutes = MARKET_CONFIG.TIMES.MARKET_CLOSE.hour * 60 + MARKET_CONFIG.TIMES.MARKET_CLOSE.minute;
13734
+ if (this.calendar.isEarlyCloseDay(nowET)) {
13735
+ endMinutes = MARKET_CONFIG.TIMES.EARLY_CLOSE.hour * 60 + MARKET_CONFIG.TIMES.EARLY_CLOSE.minute;
13736
+ }
13750
13737
  }
13751
- if (timeInMinutes >= extendedEndMinutes) {
13738
+ if (timeInMinutes >= endMinutes) {
13752
13739
  return fromZonedTime(set(nowET, { hours: 0, minutes: 0, seconds: 0, milliseconds: 0 }), this.timezone);
13753
13740
  }
13754
13741
  }