@discomedia/utils 1.0.34 → 1.0.36
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-frontend.cjs +90 -18
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +90 -18
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +107 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +107 -18
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +4 -4
- package/dist/test.js +107 -18
- package/dist/test.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/market-time.d.ts +14 -0
- package/dist/types/market-time.d.ts.map +1 -1
- package/dist/types-frontend/index.d.ts +1 -0
- package/dist/types-frontend/index.d.ts.map +1 -1
- package/dist/types-frontend/market-time.d.ts +14 -0
- package/dist/types-frontend/market-time.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -774,6 +774,22 @@ function getNYTimeZone(date) {
|
|
|
774
774
|
const offset = getNYOffset(date || new Date());
|
|
775
775
|
return offset === -4 ? '-04:00' : '-05:00';
|
|
776
776
|
}
|
|
777
|
+
/**
|
|
778
|
+
* Converts any date to the market time zone (America/New_York, Eastern Time).
|
|
779
|
+
* Returns a new Date object representing the same moment in time but adjusted to NY/Eastern timezone.
|
|
780
|
+
* Automatically handles daylight saving time transitions (EST/EDT).
|
|
781
|
+
*
|
|
782
|
+
* @param date - Date object to convert to market time zone
|
|
783
|
+
* @returns Date object in NY/Eastern time zone
|
|
784
|
+
* @example
|
|
785
|
+
* ```typescript
|
|
786
|
+
* const utcDate = new Date('2024-01-15T15:30:00Z'); // 3:30 PM UTC
|
|
787
|
+
* const nyDate = convertDateToMarketTimeZone(utcDate); // 10:30 AM EST (winter) or 11:30 AM EDT (summer)
|
|
788
|
+
* ```
|
|
789
|
+
*/
|
|
790
|
+
function convertDateToMarketTimeZone(date) {
|
|
791
|
+
return toNYTime(date);
|
|
792
|
+
}
|
|
777
793
|
/**
|
|
778
794
|
* Returns the current market status for a given date.
|
|
779
795
|
* @param options - { date?: Date }
|
|
@@ -2395,7 +2411,7 @@ const safeJSON = (text) => {
|
|
|
2395
2411
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2396
2412
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
2397
2413
|
|
|
2398
|
-
const VERSION = '5.
|
|
2414
|
+
const VERSION = '5.23.1'; // x-release-please-version
|
|
2399
2415
|
|
|
2400
2416
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2401
2417
|
const isRunningInBrowser = () => {
|
|
@@ -5798,15 +5814,18 @@ class TranscriptionSessions extends APIResource {
|
|
|
5798
5814
|
}
|
|
5799
5815
|
|
|
5800
5816
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5801
|
-
|
|
5817
|
+
/**
|
|
5818
|
+
* @deprecated Realtime has now launched and is generally available. The old beta API is now deprecated.
|
|
5819
|
+
*/
|
|
5820
|
+
let Realtime$1 = class Realtime extends APIResource {
|
|
5802
5821
|
constructor() {
|
|
5803
5822
|
super(...arguments);
|
|
5804
5823
|
this.sessions = new Sessions(this._client);
|
|
5805
5824
|
this.transcriptionSessions = new TranscriptionSessions(this._client);
|
|
5806
5825
|
}
|
|
5807
|
-
}
|
|
5808
|
-
Realtime.Sessions = Sessions;
|
|
5809
|
-
Realtime.TranscriptionSessions = TranscriptionSessions;
|
|
5826
|
+
};
|
|
5827
|
+
Realtime$1.Sessions = Sessions;
|
|
5828
|
+
Realtime$1.TranscriptionSessions = TranscriptionSessions;
|
|
5810
5829
|
|
|
5811
5830
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5812
5831
|
/**
|
|
@@ -6744,12 +6763,12 @@ Threads.Messages = Messages;
|
|
|
6744
6763
|
class Beta extends APIResource {
|
|
6745
6764
|
constructor() {
|
|
6746
6765
|
super(...arguments);
|
|
6747
|
-
this.realtime = new Realtime(this._client);
|
|
6766
|
+
this.realtime = new Realtime$1(this._client);
|
|
6748
6767
|
this.assistants = new Assistants(this._client);
|
|
6749
6768
|
this.threads = new Threads(this._client);
|
|
6750
6769
|
}
|
|
6751
6770
|
}
|
|
6752
|
-
Beta.Realtime = Realtime;
|
|
6771
|
+
Beta.Realtime = Realtime$1;
|
|
6753
6772
|
Beta.Assistants = Assistants;
|
|
6754
6773
|
Beta.Threads = Threads;
|
|
6755
6774
|
|
|
@@ -6899,23 +6918,23 @@ class Conversations extends APIResource {
|
|
|
6899
6918
|
/**
|
|
6900
6919
|
* Create a conversation.
|
|
6901
6920
|
*/
|
|
6902
|
-
create(body, options) {
|
|
6921
|
+
create(body = {}, options) {
|
|
6903
6922
|
return this._client.post('/conversations', { body, ...options });
|
|
6904
6923
|
}
|
|
6905
6924
|
/**
|
|
6906
|
-
* Get a conversation
|
|
6925
|
+
* Get a conversation
|
|
6907
6926
|
*/
|
|
6908
6927
|
retrieve(conversationID, options) {
|
|
6909
6928
|
return this._client.get(path `/conversations/${conversationID}`, options);
|
|
6910
6929
|
}
|
|
6911
6930
|
/**
|
|
6912
|
-
* Update a conversation
|
|
6931
|
+
* Update a conversation
|
|
6913
6932
|
*/
|
|
6914
6933
|
update(conversationID, body, options) {
|
|
6915
6934
|
return this._client.post(path `/conversations/${conversationID}`, { body, ...options });
|
|
6916
6935
|
}
|
|
6917
6936
|
/**
|
|
6918
|
-
* Delete a conversation
|
|
6937
|
+
* Delete a conversation. Items in the conversation will not be deleted.
|
|
6919
6938
|
*/
|
|
6920
6939
|
delete(conversationID, options) {
|
|
6921
6940
|
return this._client.delete(path `/conversations/${conversationID}`, options);
|
|
@@ -7510,6 +7529,25 @@ class Moderations extends APIResource {
|
|
|
7510
7529
|
}
|
|
7511
7530
|
}
|
|
7512
7531
|
|
|
7532
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
7533
|
+
class ClientSecrets extends APIResource {
|
|
7534
|
+
/**
|
|
7535
|
+
* Create a Realtime client secret with an associated session configuration.
|
|
7536
|
+
*/
|
|
7537
|
+
create(body, options) {
|
|
7538
|
+
return this._client.post('/realtime/client_secrets', { body, ...options });
|
|
7539
|
+
}
|
|
7540
|
+
}
|
|
7541
|
+
|
|
7542
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
7543
|
+
class Realtime extends APIResource {
|
|
7544
|
+
constructor() {
|
|
7545
|
+
super(...arguments);
|
|
7546
|
+
this.clientSecrets = new ClientSecrets(this._client);
|
|
7547
|
+
}
|
|
7548
|
+
}
|
|
7549
|
+
Realtime.ClientSecrets = ClientSecrets;
|
|
7550
|
+
|
|
7513
7551
|
function maybeParseResponse(response, params) {
|
|
7514
7552
|
if (!params || !hasAutoParseableInput(params)) {
|
|
7515
7553
|
return {
|
|
@@ -7760,8 +7798,16 @@ class ResponseStream extends EventStream {
|
|
|
7760
7798
|
if (!output) {
|
|
7761
7799
|
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
7762
7800
|
}
|
|
7763
|
-
|
|
7764
|
-
|
|
7801
|
+
const type = output.type;
|
|
7802
|
+
const part = event.part;
|
|
7803
|
+
if (type === 'message' && part.type !== 'reasoning_text') {
|
|
7804
|
+
output.content.push(part);
|
|
7805
|
+
}
|
|
7806
|
+
else if (type === 'reasoning' && part.type === 'reasoning_text') {
|
|
7807
|
+
if (!output.content) {
|
|
7808
|
+
output.content = [];
|
|
7809
|
+
}
|
|
7810
|
+
output.content.push(part);
|
|
7765
7811
|
}
|
|
7766
7812
|
break;
|
|
7767
7813
|
}
|
|
@@ -7792,6 +7838,23 @@ class ResponseStream extends EventStream {
|
|
|
7792
7838
|
}
|
|
7793
7839
|
break;
|
|
7794
7840
|
}
|
|
7841
|
+
case 'response.reasoning_text.delta': {
|
|
7842
|
+
const output = snapshot.output[event.output_index];
|
|
7843
|
+
if (!output) {
|
|
7844
|
+
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
7845
|
+
}
|
|
7846
|
+
if (output.type === 'reasoning') {
|
|
7847
|
+
const content = output.content?.[event.content_index];
|
|
7848
|
+
if (!content) {
|
|
7849
|
+
throw new OpenAIError(`missing content at index ${event.content_index}`);
|
|
7850
|
+
}
|
|
7851
|
+
if (content.type !== 'reasoning_text') {
|
|
7852
|
+
throw new OpenAIError(`expected content to be 'reasoning_text', got ${content.type}`);
|
|
7853
|
+
}
|
|
7854
|
+
content.text += event.delta;
|
|
7855
|
+
}
|
|
7856
|
+
break;
|
|
7857
|
+
}
|
|
7795
7858
|
case 'response.completed': {
|
|
7796
7859
|
__classPrivateFieldSet(this, _ResponseStream_currentResponseSnapshot, event.response);
|
|
7797
7860
|
break;
|
|
@@ -8516,11 +8579,12 @@ class OpenAI {
|
|
|
8516
8579
|
this.batches = new Batches(this);
|
|
8517
8580
|
this.uploads = new Uploads(this);
|
|
8518
8581
|
this.responses = new Responses(this);
|
|
8582
|
+
this.realtime = new Realtime(this);
|
|
8519
8583
|
this.conversations = new Conversations(this);
|
|
8520
8584
|
this.evals = new Evals(this);
|
|
8521
8585
|
this.containers = new Containers(this);
|
|
8522
8586
|
if (apiKey === undefined) {
|
|
8523
|
-
throw new OpenAIError(
|
|
8587
|
+
throw new OpenAIError('Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.');
|
|
8524
8588
|
}
|
|
8525
8589
|
const options = {
|
|
8526
8590
|
apiKey,
|
|
@@ -8548,7 +8612,7 @@ class OpenAI {
|
|
|
8548
8612
|
this.fetch = options.fetch ?? getDefaultFetch();
|
|
8549
8613
|
__classPrivateFieldSet(this, _OpenAI_encoder, FallbackEncoder);
|
|
8550
8614
|
this._options = options;
|
|
8551
|
-
this.apiKey = apiKey;
|
|
8615
|
+
this.apiKey = typeof apiKey === 'string' ? apiKey : 'Missing Key';
|
|
8552
8616
|
this.organization = organization;
|
|
8553
8617
|
this.project = project;
|
|
8554
8618
|
this.webhookSecret = webhookSecret;
|
|
@@ -8595,6 +8659,27 @@ class OpenAI {
|
|
|
8595
8659
|
makeStatusError(status, error, message, headers) {
|
|
8596
8660
|
return APIError.generate(status, error, message, headers);
|
|
8597
8661
|
}
|
|
8662
|
+
async _callApiKey() {
|
|
8663
|
+
const apiKey = this._options.apiKey;
|
|
8664
|
+
if (typeof apiKey !== 'function')
|
|
8665
|
+
return false;
|
|
8666
|
+
let token;
|
|
8667
|
+
try {
|
|
8668
|
+
token = await apiKey();
|
|
8669
|
+
}
|
|
8670
|
+
catch (err) {
|
|
8671
|
+
if (err instanceof OpenAIError)
|
|
8672
|
+
throw err;
|
|
8673
|
+
throw new OpenAIError(`Failed to get token from 'apiKey' function: ${err.message}`,
|
|
8674
|
+
// @ts-ignore
|
|
8675
|
+
{ cause: err });
|
|
8676
|
+
}
|
|
8677
|
+
if (typeof token !== 'string' || !token) {
|
|
8678
|
+
throw new OpenAIError(`Expected 'apiKey' function argument to return a string but it returned ${token}`);
|
|
8679
|
+
}
|
|
8680
|
+
this.apiKey = token;
|
|
8681
|
+
return true;
|
|
8682
|
+
}
|
|
8598
8683
|
buildURL(path, query, defaultBaseURL) {
|
|
8599
8684
|
const baseURL = (!__classPrivateFieldGet(this, _OpenAI_instances, "m", _OpenAI_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL;
|
|
8600
8685
|
const url = isAbsoluteURL(path) ?
|
|
@@ -8612,7 +8697,9 @@ class OpenAI {
|
|
|
8612
8697
|
/**
|
|
8613
8698
|
* Used as a callback for mutating the given `FinalRequestOptions` object.
|
|
8614
8699
|
*/
|
|
8615
|
-
async prepareOptions(options) {
|
|
8700
|
+
async prepareOptions(options) {
|
|
8701
|
+
await this._callApiKey();
|
|
8702
|
+
}
|
|
8616
8703
|
/**
|
|
8617
8704
|
* Used as a callback for mutating the given `RequestInit` object.
|
|
8618
8705
|
*
|
|
@@ -8671,7 +8758,7 @@ class OpenAI {
|
|
|
8671
8758
|
const controller = new AbortController();
|
|
8672
8759
|
const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
|
|
8673
8760
|
const headersTime = Date.now();
|
|
8674
|
-
if (response instanceof Error) {
|
|
8761
|
+
if (response instanceof globalThis.Error) {
|
|
8675
8762
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
8676
8763
|
if (options.signal?.aborted) {
|
|
8677
8764
|
throw new APIUserAbortError();
|
|
@@ -8962,6 +9049,7 @@ OpenAI.Beta = Beta;
|
|
|
8962
9049
|
OpenAI.Batches = Batches;
|
|
8963
9050
|
OpenAI.Uploads = Uploads;
|
|
8964
9051
|
OpenAI.Responses = Responses;
|
|
9052
|
+
OpenAI.Realtime = Realtime;
|
|
8965
9053
|
OpenAI.Conversations = Conversations;
|
|
8966
9054
|
OpenAI.Evals = Evals;
|
|
8967
9055
|
OpenAI.Containers = Containers;
|
|
@@ -15773,7 +15861,7 @@ var config = {};
|
|
|
15773
15861
|
|
|
15774
15862
|
var main = {exports: {}};
|
|
15775
15863
|
|
|
15776
|
-
var version = "17.2.
|
|
15864
|
+
var version = "17.2.2";
|
|
15777
15865
|
var require$$4 = {
|
|
15778
15866
|
version: version};
|
|
15779
15867
|
|
|
@@ -18909,6 +18997,7 @@ const disco = {
|
|
|
18909
18997
|
calculateFibonacciLevels: calculateFibonacciLevels,
|
|
18910
18998
|
},
|
|
18911
18999
|
time: {
|
|
19000
|
+
convertDateToMarketTimeZone: convertDateToMarketTimeZone,
|
|
18912
19001
|
getStartAndEndDates: getStartAndEndDates,
|
|
18913
19002
|
getMarketOpenClose: getMarketOpenClose,
|
|
18914
19003
|
getLastFullTradingDate: getLastFullTradingDate,
|