@discomedia/utils 1.0.6 → 1.0.7
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/README.md +95 -3
- package/dist/index-frontend.cjs +16027 -0
- package/dist/index-frontend.cjs.map +1 -0
- package/dist/index-frontend.mjs +16023 -0
- package/dist/index-frontend.mjs.map +1 -0
- package/dist/index.cjs +529 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +529 -10
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +7 -1
- package/dist/test.js +6426 -582
- package/dist/test.js.map +1 -1
- package/dist/types/alpaca-market-data-api.d.ts +1 -0
- package/dist/types/alpaca-market-data-api.d.ts.map +1 -1
- package/dist/types/alpaca-trading-api.d.ts.map +1 -1
- package/dist/types/index-frontend.d.ts +15 -0
- package/dist/types/index-frontend.d.ts.map +1 -0
- package/dist/types/old-test.d.ts +2 -0
- package/dist/types/old-test.d.ts.map +1 -0
- package/dist/types-frontend/alpaca-market-data-api.d.ts +372 -0
- package/dist/types-frontend/alpaca-market-data-api.d.ts.map +1 -0
- package/dist/types-frontend/alpaca-trading-api.d.ts +315 -0
- package/dist/types-frontend/alpaca-trading-api.d.ts.map +1 -0
- package/dist/types-frontend/format-tools.d.ts +46 -0
- package/dist/types-frontend/format-tools.d.ts.map +1 -0
- package/dist/types-frontend/index-frontend.d.ts +15 -0
- package/dist/types-frontend/index-frontend.d.ts.map +1 -0
- package/dist/types-frontend/index.d.ts +125 -0
- package/dist/types-frontend/index.d.ts.map +1 -0
- package/dist/types-frontend/json-tools.d.ts +33 -0
- package/dist/types-frontend/json-tools.d.ts.map +1 -0
- package/dist/types-frontend/llm-config.d.ts +36 -0
- package/dist/types-frontend/llm-config.d.ts.map +1 -0
- package/dist/types-frontend/llm-deepseek.d.ts +12 -0
- package/dist/types-frontend/llm-deepseek.d.ts.map +1 -0
- package/dist/types-frontend/llm-images.d.ts +49 -0
- package/dist/types-frontend/llm-images.d.ts.map +1 -0
- package/dist/types-frontend/llm-openai.d.ts +64 -0
- package/dist/types-frontend/llm-openai.d.ts.map +1 -0
- package/dist/types-frontend/llm-utils.d.ts +16 -0
- package/dist/types-frontend/llm-utils.d.ts.map +1 -0
- package/dist/types-frontend/logging.d.ts +12 -0
- package/dist/types-frontend/logging.d.ts.map +1 -0
- package/dist/types-frontend/market-hours.d.ts +24 -0
- package/dist/types-frontend/market-hours.d.ts.map +1 -0
- package/dist/types-frontend/market-time.d.ts +254 -0
- package/dist/types-frontend/market-time.d.ts.map +1 -0
- package/dist/types-frontend/misc-utils.d.ts +49 -0
- package/dist/types-frontend/misc-utils.d.ts.map +1 -0
- package/dist/types-frontend/old-test.d.ts +2 -0
- package/dist/types-frontend/old-test.d.ts.map +1 -0
- package/dist/types-frontend/polygon-indices.d.ts +85 -0
- package/dist/types-frontend/polygon-indices.d.ts.map +1 -0
- package/dist/types-frontend/polygon.d.ts +126 -0
- package/dist/types-frontend/polygon.d.ts.map +1 -0
- package/dist/types-frontend/technical-analysis.d.ts +90 -0
- package/dist/types-frontend/technical-analysis.d.ts.map +1 -0
- package/dist/types-frontend/test.d.ts +2 -0
- package/dist/types-frontend/test.d.ts.map +1 -0
- package/dist/types-frontend/testing/market-time-refactor-test.d.ts +1 -0
- package/dist/types-frontend/testing/market-time-refactor-test.d.ts.map +1 -0
- package/dist/types-frontend/types/alpaca-types.d.ts +962 -0
- package/dist/types-frontend/types/alpaca-types.d.ts.map +1 -0
- package/dist/types-frontend/types/index.d.ts +7 -0
- package/dist/types-frontend/types/index.d.ts.map +1 -0
- package/dist/types-frontend/types/llm-types.d.ts +82 -0
- package/dist/types-frontend/types/llm-types.d.ts.map +1 -0
- package/dist/types-frontend/types/logging-types.d.ts +10 -0
- package/dist/types-frontend/types/logging-types.d.ts.map +1 -0
- package/dist/types-frontend/types/market-time-types.d.ts +59 -0
- package/dist/types-frontend/types/market-time-types.d.ts.map +1 -0
- package/dist/types-frontend/types/polygon-indices-types.d.ts +190 -0
- package/dist/types-frontend/types/polygon-indices-types.d.ts.map +1 -0
- package/dist/types-frontend/types/polygon-types.d.ts +204 -0
- package/dist/types-frontend/types/polygon-types.d.ts.map +1 -0
- package/dist/types-frontend/types/ta-types.d.ts +89 -0
- package/dist/types-frontend/types/ta-types.d.ts.map +1 -0
- package/package.json +7 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ImageGenerationOptions } from './types';
|
|
2
|
+
import { ImageModel, ImagesResponse } from 'openai/resources/images';
|
|
3
|
+
/**
|
|
4
|
+
* Enhanced ImagesResponse that includes cost calculation
|
|
5
|
+
*/
|
|
6
|
+
export interface ImageResponseWithUsage extends ImagesResponse {
|
|
7
|
+
usage?: ImagesResponse['usage'] & {
|
|
8
|
+
provider: string;
|
|
9
|
+
model: ImageModel;
|
|
10
|
+
cost: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Makes a call to the OpenAI Images API to generate images based on a text prompt.
|
|
15
|
+
*
|
|
16
|
+
* This function provides access to OpenAI's image generation capabilities with support for:
|
|
17
|
+
* - Different output formats (JPEG, PNG, WebP)
|
|
18
|
+
* - Various image sizes and quality settings
|
|
19
|
+
* - Multiple image generation in a single call
|
|
20
|
+
* - Base64 encoded image data return
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Basic image generation
|
|
24
|
+
* const response = await makeImagesCall('A beautiful sunset over mountains');
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Custom options
|
|
28
|
+
* const response = await makeImagesCall('A birthday cake', {
|
|
29
|
+
* size: '1024x1024',
|
|
30
|
+
* outputFormat: 'png',
|
|
31
|
+
* quality: 'high',
|
|
32
|
+
* count: 2
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* @param prompt - The text prompt describing the image to generate
|
|
36
|
+
* @param options - Configuration options for image generation. Includes:
|
|
37
|
+
* - size: Image dimensions (uses OpenAI's size options)
|
|
38
|
+
* - outputFormat: Image format ('jpeg', 'png', 'webp') - defaults to 'webp'
|
|
39
|
+
* - compression: Compression level (number) - defaults to 50
|
|
40
|
+
* - quality: Quality setting (uses OpenAI's quality options) - defaults to 'high'
|
|
41
|
+
* - count: Number of images to generate - defaults to 1
|
|
42
|
+
* - background: Background setting for transparency support
|
|
43
|
+
* - moderation: Content moderation level
|
|
44
|
+
* - apiKey: OpenAI API key (optional, falls back to environment variable)
|
|
45
|
+
* @returns Promise<ImageResponseWithUsage> - The image generation response with cost information
|
|
46
|
+
* @throws Error if the API call fails or invalid parameters are provided
|
|
47
|
+
*/
|
|
48
|
+
export declare function makeImagesCall(prompt: string, options?: ImageGenerationOptions): Promise<ImageResponseWithUsage>;
|
|
49
|
+
//# sourceMappingURL=llm-images.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-images.d.ts","sourceRoot":"","sources":["../../src/llm-images.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,OAAO,EAAuB,UAAU,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE1F;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG;QAChC,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,UAAU,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,sBAAsB,CAAC,CAmFjC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Tool } from 'openai/resources/responses/responses';
|
|
2
|
+
import { LLMResponse, LLMOptions, OpenAIModel } from './types';
|
|
3
|
+
import { ResponseCreateParamsNonStreaming } from 'openai/resources/responses/responses';
|
|
4
|
+
export declare const DEFAULT_OPTIONS: LLMOptions;
|
|
5
|
+
/**
|
|
6
|
+
* Checks if the given model supports the temperature parameter. Reasoning models (o1*, o3*, o4*) do not support temperature.
|
|
7
|
+
* @param model The model to check.
|
|
8
|
+
* @returns True if the model supports the temperature parameter, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare function supportsTemperature(model: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Checks if the given model is a reasoning model. Reasoning models have different tool choice constraints.
|
|
13
|
+
* @param model The model to check.
|
|
14
|
+
* @returns True if the model is a reasoning model, false otherwise.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isReasoningModel(model: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Makes a call to OpenAI's Responses API for more advanced use cases with built-in tools.
|
|
19
|
+
*
|
|
20
|
+
* This function provides access to the Responses API which supports:
|
|
21
|
+
* - Built-in tools (web search, file search, computer use, code interpreter, image generation)
|
|
22
|
+
* - Background processing
|
|
23
|
+
* - Conversation state management
|
|
24
|
+
* - Reasoning support for o-series models
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Basic text response
|
|
28
|
+
* const response = await makeResponsesAPICall('What is the weather like?');
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // With web search tool
|
|
32
|
+
* const response = await makeResponsesAPICall('Latest news about AI', {
|
|
33
|
+
* tools: [{ type: 'web_search_preview' }]
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* @param input - The input content. Can be:
|
|
37
|
+
* - A string for simple text prompts
|
|
38
|
+
* - An array of input items for complex/multi-modal content
|
|
39
|
+
* @param options - Configuration options for the Responses API
|
|
40
|
+
* @returns Promise<LLMResponse<T>> - The response in the same format as makeLLMCall
|
|
41
|
+
* @throws Error if the API call fails
|
|
42
|
+
*/
|
|
43
|
+
export declare const makeResponsesAPICall: <T = any>(input: string | ResponseCreateParamsNonStreaming["input"], options?: Omit<ResponseCreateParamsNonStreaming, "input" | "model"> & {
|
|
44
|
+
apiKey?: string;
|
|
45
|
+
model?: string;
|
|
46
|
+
}) => Promise<LLMResponse<T>>;
|
|
47
|
+
/**
|
|
48
|
+
* Makes a call to the OpenAI Responses API for advanced use cases with built-in tools.
|
|
49
|
+
*
|
|
50
|
+
* @param input The text prompt to send to the model (e.g., "What's in this image?")
|
|
51
|
+
* @param options The options for the Responses API call, including optional image data.
|
|
52
|
+
* @return A promise that resolves to the response from the Responses API.
|
|
53
|
+
*/
|
|
54
|
+
export declare function makeLLMCall<T = any>(input: string, options?: {
|
|
55
|
+
apiKey?: string;
|
|
56
|
+
model?: OpenAIModel;
|
|
57
|
+
responseFormat?: 'text' | 'json';
|
|
58
|
+
tools?: Tool[];
|
|
59
|
+
useCodeInterpreter?: boolean;
|
|
60
|
+
useWebSearch?: boolean;
|
|
61
|
+
imageBase64?: string;
|
|
62
|
+
imageDetail?: 'low' | 'high' | 'auto';
|
|
63
|
+
}): Promise<LLMResponse<T>>;
|
|
64
|
+
//# sourceMappingURL=llm-openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-openai.d.ts","sourceRoot":"","sources":["../../src/llm-openai.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAiB,MAAM,sCAAsC,CAAC;AAK3E,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAwB,MAAM,SAAS,CAAC;AACrF,OAAO,EACL,gCAAgC,EAOjC,MAAM,sCAAsC,CAAC;AAE9C,eAAO,MAAM,eAAe,EAAE,UAG7B,CAAC;AAkBF;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAI1D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGvD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,oBAAoB,GAAU,CAAC,GAAG,GAAG,EAChD,OAAO,MAAM,GAAG,gCAAgC,CAAC,OAAO,CAAC,EACzD,UAAS,IAAI,CAAC,gCAAgC,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CACX,KACL,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CA0HxB,CAAC;AAGF;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,CAAC,GAAG,GAAG,EACvC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;CAClC,GACL,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CA6EzB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OpenAIResponseFormat } from './types';
|
|
2
|
+
export declare function normalizeModelName(model: string): string;
|
|
3
|
+
export declare const CODE_BLOCK_TYPES: string[];
|
|
4
|
+
/**
|
|
5
|
+
* Tries to parse JSON from the given content string according to the specified
|
|
6
|
+
* response format. If the response format is 'json' or a JSON schema object, it
|
|
7
|
+
* will attempt to parse the content using multiple strategies. If any of the
|
|
8
|
+
* strategies succeed, it will return the parsed JSON object. If all of them fail,
|
|
9
|
+
* it will throw an error.
|
|
10
|
+
*
|
|
11
|
+
* @param content The content string to parse
|
|
12
|
+
* @param responseFormat The desired format of the response
|
|
13
|
+
* @returns The parsed JSON object or null if it fails
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseResponse<T>(content: string, responseFormat: OpenAIResponseFormat): Promise<T | null>;
|
|
16
|
+
//# sourceMappingURL=llm-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-utils.d.ts","sourceRoot":"","sources":["../../src/llm-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAG/C,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,eAAO,MAAM,gBAAgB,UAAsF,CAAC;AAElH;;;;;;;;;;GAUG;AACL,wBAAsB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,oBAAoB,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CA+E/G"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LogOptions } from './types/logging-types';
|
|
2
|
+
/**
|
|
3
|
+
* Logs a message to the console.
|
|
4
|
+
* @param message The message to log.
|
|
5
|
+
* @param options Optional options.
|
|
6
|
+
* @param options.source The source of the message.
|
|
7
|
+
* @param options.type The type of message to log.
|
|
8
|
+
* @param options.symbol The trading symbol associated with this log.
|
|
9
|
+
* @param options.account The account associated with this log.
|
|
10
|
+
*/
|
|
11
|
+
export declare function log(message: string, options?: LogOptions): void;
|
|
12
|
+
//# sourceMappingURL=logging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/logging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,UAA4C,GAAG,IAAI,CAoBhG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface HolidayDetails {
|
|
2
|
+
date: string;
|
|
3
|
+
}
|
|
4
|
+
export interface MarketHolidaysForYear {
|
|
5
|
+
[holidayName: string]: HolidayDetails;
|
|
6
|
+
}
|
|
7
|
+
export interface MarketHolidays {
|
|
8
|
+
[year: number]: MarketHolidaysForYear;
|
|
9
|
+
}
|
|
10
|
+
export interface EarlyCloseDetails {
|
|
11
|
+
date: string;
|
|
12
|
+
time: string;
|
|
13
|
+
optionsTime: string;
|
|
14
|
+
notes: string;
|
|
15
|
+
}
|
|
16
|
+
export interface EarlyClosesForYear {
|
|
17
|
+
[date: string]: EarlyCloseDetails;
|
|
18
|
+
}
|
|
19
|
+
export interface MarketEarlyCloses {
|
|
20
|
+
[year: number]: EarlyClosesForYear;
|
|
21
|
+
}
|
|
22
|
+
export declare const marketHolidays: MarketHolidays;
|
|
23
|
+
export declare const marketEarlyCloses: MarketEarlyCloses;
|
|
24
|
+
//# sourceMappingURL=market-hours.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"market-hours.d.ts","sourceRoot":"","sources":["../../src/market-hours.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAAC;CACvC;AAED,MAAM,WAAW,cAAc;IAC7B,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAAC;CACvC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAAC;CACnC;AAED,MAAM,WAAW,iBAAiB;IAChC,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAAC;CACpC;AAED,eAAO,MAAM,cAAc,EAAE,cAsC5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,iBAsE/B,CAAC"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { Period, IntradayReporting, PeriodDates, MarketTimeParams, OutputFormat, MarketOpenCloseResult, MarketStatus, MarketTimesConfig } from './types/market-time-types';
|
|
2
|
+
/**
|
|
3
|
+
* Market configuration constants
|
|
4
|
+
*/
|
|
5
|
+
export declare const MARKET_CONFIG: {
|
|
6
|
+
readonly TIMEZONE: "America/New_York";
|
|
7
|
+
readonly TIMES: {
|
|
8
|
+
readonly EXTENDED_START: {
|
|
9
|
+
readonly hour: 4;
|
|
10
|
+
readonly minute: 0;
|
|
11
|
+
};
|
|
12
|
+
readonly MARKET_OPEN: {
|
|
13
|
+
readonly hour: 9;
|
|
14
|
+
readonly minute: 30;
|
|
15
|
+
};
|
|
16
|
+
readonly EARLY_MARKET_END: {
|
|
17
|
+
readonly hour: 10;
|
|
18
|
+
readonly minute: 0;
|
|
19
|
+
};
|
|
20
|
+
readonly MARKET_CLOSE: {
|
|
21
|
+
readonly hour: 16;
|
|
22
|
+
readonly minute: 0;
|
|
23
|
+
};
|
|
24
|
+
readonly EARLY_CLOSE: {
|
|
25
|
+
readonly hour: 13;
|
|
26
|
+
readonly minute: 0;
|
|
27
|
+
};
|
|
28
|
+
readonly EXTENDED_END: {
|
|
29
|
+
readonly hour: 20;
|
|
30
|
+
readonly minute: 0;
|
|
31
|
+
};
|
|
32
|
+
readonly EARLY_EXTENDED_END: {
|
|
33
|
+
readonly hour: 17;
|
|
34
|
+
readonly minute: 0;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Service for handling market calendar operations (holidays, early closes, market days)
|
|
40
|
+
*/
|
|
41
|
+
export declare class MarketCalendar {
|
|
42
|
+
private timezone;
|
|
43
|
+
constructor(timezone?: string);
|
|
44
|
+
/**
|
|
45
|
+
* Check if a date is a weekend
|
|
46
|
+
*/
|
|
47
|
+
isWeekend(date: Date): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Check if a date is a market holiday
|
|
50
|
+
*/
|
|
51
|
+
isHoliday(date: Date): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Check if a date is an early close day
|
|
54
|
+
*/
|
|
55
|
+
isEarlyCloseDay(date: Date): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Get the early close time for a date (in minutes from midnight)
|
|
58
|
+
*/
|
|
59
|
+
getEarlyCloseTime(date: Date): number | null;
|
|
60
|
+
/**
|
|
61
|
+
* Check if a date is a market day (not weekend or holiday)
|
|
62
|
+
*/
|
|
63
|
+
isMarketDay(date: Date): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Get the next market day from a given date
|
|
66
|
+
*/
|
|
67
|
+
getNextMarketDay(date: Date): Date;
|
|
68
|
+
/**
|
|
69
|
+
* Get the previous market day from a given date
|
|
70
|
+
*/
|
|
71
|
+
getPreviousMarketDay(date: Date): Date;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Service for formatting time outputs
|
|
75
|
+
*/
|
|
76
|
+
export declare class TimeFormatter {
|
|
77
|
+
private timezone;
|
|
78
|
+
constructor(timezone?: string);
|
|
79
|
+
/**
|
|
80
|
+
* Format a date based on the output format
|
|
81
|
+
*/
|
|
82
|
+
formatDate(date: Date, outputFormat?: OutputFormat): string | number;
|
|
83
|
+
/**
|
|
84
|
+
* Get New York timezone offset
|
|
85
|
+
*/
|
|
86
|
+
getNYTimeZone(date?: Date): '-04:00' | '-05:00';
|
|
87
|
+
/**
|
|
88
|
+
* Get trading date in YYYY-MM-DD format
|
|
89
|
+
*/
|
|
90
|
+
getTradingDate(time: string | number | Date): string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Service for core market time calculations
|
|
94
|
+
*/
|
|
95
|
+
export declare class MarketTimeCalculator {
|
|
96
|
+
private calendar;
|
|
97
|
+
private formatter;
|
|
98
|
+
private timezone;
|
|
99
|
+
constructor(timezone?: string);
|
|
100
|
+
/**
|
|
101
|
+
* Get market open/close times for a date
|
|
102
|
+
*/
|
|
103
|
+
getMarketTimes(date: Date): MarketOpenCloseResult;
|
|
104
|
+
/**
|
|
105
|
+
* Check if a time is within market hours based on intraday reporting mode
|
|
106
|
+
*/
|
|
107
|
+
isWithinMarketHours(date: Date, intradayReporting?: IntradayReporting): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Get the last full trading date
|
|
110
|
+
*/
|
|
111
|
+
getLastFullTradingDate(currentDate?: Date): Date;
|
|
112
|
+
/**
|
|
113
|
+
* Get day boundaries based on intraday reporting mode
|
|
114
|
+
*/
|
|
115
|
+
getDayBoundaries(date: Date, intradayReporting?: IntradayReporting): {
|
|
116
|
+
start: Date;
|
|
117
|
+
end: Date;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Service for calculating time periods
|
|
122
|
+
*/
|
|
123
|
+
export declare class PeriodCalculator {
|
|
124
|
+
private calendar;
|
|
125
|
+
private timeCalculator;
|
|
126
|
+
private formatter;
|
|
127
|
+
constructor(timezone?: string);
|
|
128
|
+
/**
|
|
129
|
+
* Calculate the start date for a given period
|
|
130
|
+
*/
|
|
131
|
+
calculatePeriodStartDate(endDate: Date, period: Period): Date;
|
|
132
|
+
/**
|
|
133
|
+
* Get period dates for market time calculations
|
|
134
|
+
*/
|
|
135
|
+
getMarketTimePeriod(params: MarketTimeParams): PeriodDates;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Service for determining market status
|
|
139
|
+
*/
|
|
140
|
+
export declare class MarketStatusService {
|
|
141
|
+
private calendar;
|
|
142
|
+
private timeCalculator;
|
|
143
|
+
private timezone;
|
|
144
|
+
constructor(timezone?: string);
|
|
145
|
+
/**
|
|
146
|
+
* Get current market status
|
|
147
|
+
*/
|
|
148
|
+
getMarketStatus(date?: Date): MarketStatus;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Get market open/close times for a given date
|
|
152
|
+
*/
|
|
153
|
+
export declare function getMarketOpenClose(options?: {
|
|
154
|
+
date?: Date;
|
|
155
|
+
}): MarketOpenCloseResult;
|
|
156
|
+
/**
|
|
157
|
+
* Get start and end dates for a given market time period
|
|
158
|
+
*/
|
|
159
|
+
export declare function getStartAndEndDates(params?: MarketTimeParams): {
|
|
160
|
+
start: Date;
|
|
161
|
+
end: Date;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Get the last full trading date
|
|
165
|
+
*/
|
|
166
|
+
export declare function getLastFullTradingDate(currentDate?: Date): {
|
|
167
|
+
date: Date;
|
|
168
|
+
YYYYMMDD: string;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Get the next market day
|
|
172
|
+
*/
|
|
173
|
+
export declare function getNextMarketDay({ referenceDate }?: {
|
|
174
|
+
referenceDate?: Date;
|
|
175
|
+
}): {
|
|
176
|
+
date: Date;
|
|
177
|
+
yyyymmdd: string;
|
|
178
|
+
dateISOString: string;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Get trading date in YYYY-MM-DD format
|
|
182
|
+
*/
|
|
183
|
+
export declare function getTradingDate(time: string | number | Date): string;
|
|
184
|
+
/**
|
|
185
|
+
* Get New York timezone offset
|
|
186
|
+
*/
|
|
187
|
+
export declare function getNYTimeZone(date?: Date): '-04:00' | '-05:00';
|
|
188
|
+
/**
|
|
189
|
+
* Get current market status
|
|
190
|
+
*/
|
|
191
|
+
export declare function getMarketStatus(options?: {
|
|
192
|
+
date?: Date;
|
|
193
|
+
}): MarketStatus;
|
|
194
|
+
/**
|
|
195
|
+
* Check if a date is a market day
|
|
196
|
+
*/
|
|
197
|
+
export declare function isMarketDay(date: Date): boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Check if a date is within market hours
|
|
200
|
+
*/
|
|
201
|
+
export declare function isWithinMarketHours(date: Date, intradayReporting?: IntradayReporting): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Function to find complete trading date periods, starting at the beginning of one trading date and ending at the last.
|
|
204
|
+
* By default, it gets the last trading date, returning the beginning and end. But we can also a) define the end date
|
|
205
|
+
* on which to look (which is the end market date, e.g. for 8 july 2025 we'd return an end of 16:00 NY time on that date),
|
|
206
|
+
* and to go back x days before, e.g. 7 would just subtract raw 7 days, giving us 4-5 trading days (depending on holidays).
|
|
207
|
+
* @param options.endDate - The end date to use, defaults to today
|
|
208
|
+
* @param options.days - The number of days to go back, defaults to 1
|
|
209
|
+
* @returns The start and end dates with proper market open/close times
|
|
210
|
+
*/
|
|
211
|
+
export declare function getTradingStartAndEndDates(options?: {
|
|
212
|
+
endDate?: Date;
|
|
213
|
+
days?: number;
|
|
214
|
+
}): {
|
|
215
|
+
startDate: Date;
|
|
216
|
+
endDate: Date;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Create a market time utility instance with custom timezone
|
|
220
|
+
*/
|
|
221
|
+
export declare function createMarketTimeUtil(timezone?: string, intradayReporting?: IntradayReporting): {
|
|
222
|
+
isMarketDay: (date: Date) => boolean;
|
|
223
|
+
isWithinMarketHours: (date: Date) => boolean;
|
|
224
|
+
getLastFullTradingDate: (date?: Date) => Date;
|
|
225
|
+
getNextMarketDay: (date: Date) => Date;
|
|
226
|
+
getMarketOpenClose: (options?: {
|
|
227
|
+
date?: Date;
|
|
228
|
+
}) => MarketOpenCloseResult;
|
|
229
|
+
getMarketTimePeriod: (params: MarketTimeParams) => PeriodDates;
|
|
230
|
+
getMarketStatus: (date?: Date) => MarketStatus;
|
|
231
|
+
isEarlyCloseDay: (date: Date) => boolean;
|
|
232
|
+
getEarlyCloseTime: (date: Date) => number | null;
|
|
233
|
+
};
|
|
234
|
+
export declare class MarketTimeUtil {
|
|
235
|
+
private calculator;
|
|
236
|
+
private calendar;
|
|
237
|
+
private formatter;
|
|
238
|
+
private periodCalc;
|
|
239
|
+
private statusService;
|
|
240
|
+
private intradayReporting;
|
|
241
|
+
constructor(timezone?: string, intradayReporting?: IntradayReporting);
|
|
242
|
+
isMarketDay(date: Date): boolean;
|
|
243
|
+
isWithinMarketHours(date: Date): boolean;
|
|
244
|
+
getLastFullTradingDate(date?: Date): Date;
|
|
245
|
+
getNextMarketDay(date: Date): Date;
|
|
246
|
+
getMarketOpenClose(options?: {
|
|
247
|
+
date?: Date;
|
|
248
|
+
}): MarketOpenCloseResult;
|
|
249
|
+
getMarketTimePeriod(params: MarketTimeParams): PeriodDates;
|
|
250
|
+
isEarlyCloseDay(date: Date): boolean;
|
|
251
|
+
getEarlyCloseTime(date: Date): number | null;
|
|
252
|
+
}
|
|
253
|
+
export declare const MARKET_TIMES: MarketTimesConfig;
|
|
254
|
+
//# sourceMappingURL=market-time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"market-time.d.ts","sourceRoot":"","sources":["../../src/market-time.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAQnC;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAWhB,CAAC;AAGX;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAS;gBAEb,QAAQ,GAAE,MAA+B;IAIrD;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAK9B;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAU9B;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAOpC;;OAEG;IACH,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI;IAY5C;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAIhC;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,IAAI,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B,CAAC,MAAM,EAAE,gBAAgB,GAAG,WAAW;IAI1D,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAIpC,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI;CAG7C;AAGD,eAAO,MAAM,YAAY,EAAE,iBA0B1B,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
declare const LOG_TYPES: readonly ["info", "warn", "error", "debug", "trace"];
|
|
2
|
+
type LogType = (typeof LOG_TYPES)[number];
|
|
3
|
+
/**
|
|
4
|
+
* Debug logging utility that respects environment debug flags.
|
|
5
|
+
* Logs messages to the console based on the specified log level.
|
|
6
|
+
*
|
|
7
|
+
* @param message - The message to log.
|
|
8
|
+
* @param data - Optional data to log alongside the message. This can be any type of data.
|
|
9
|
+
* @param type - Log level. One of: 'info' | 'warn' | 'error' | 'debug' | 'trace'. Defaults to 'info'.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* logIfDebug("User login failed", { userId: 123 }, "error");
|
|
13
|
+
* logIfDebug("Cache miss", undefined, "warn");
|
|
14
|
+
* logIfDebug("Processing request", { requestId: "abc" }, "debug");
|
|
15
|
+
*/
|
|
16
|
+
export declare const logIfDebug: (message: string, data?: unknown, type?: LogType) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Hides (masks) the value of any query parameter that is "apiKey" (case-insensitive),
|
|
19
|
+
* replacing the middle part with **** and keeping only the first 2 and last 2 characters.
|
|
20
|
+
*
|
|
21
|
+
* @param url - The URL containing the query parameters.
|
|
22
|
+
* @returns The URL with the masked API key.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* hideApiKeyFromurl("https://xxx.com/s/23/fdsa/?apiKey=12341239856677");
|
|
26
|
+
* // Returns "https://xxx.com/s/23/fdsa/?apiKey=12****77"
|
|
27
|
+
*/
|
|
28
|
+
export declare function hideApiKeyFromurl(url: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Fetches a resource with intelligent retry logic for handling transient errors.
|
|
31
|
+
* Features enhanced error logging, rate limit detection, and adaptive backoff.
|
|
32
|
+
*
|
|
33
|
+
* @param url - The URL to fetch.
|
|
34
|
+
* @param options - Optional fetch options.
|
|
35
|
+
* @param retries - The number of retry attempts. Defaults to 3.
|
|
36
|
+
* @param initialBackoff - The initial backoff time in milliseconds. Defaults to 1000.
|
|
37
|
+
* @returns A promise that resolves to the response.
|
|
38
|
+
*
|
|
39
|
+
* @throws Will throw an error if the fetch fails after the specified number of retries.
|
|
40
|
+
*/
|
|
41
|
+
export declare function fetchWithRetry(url: string, options?: RequestInit, retries?: number, initialBackoff?: number): Promise<Response>;
|
|
42
|
+
/**
|
|
43
|
+
* Validates a Polygon.io API key by making a test request.
|
|
44
|
+
* @param apiKey - The API key to validate.
|
|
45
|
+
* @returns Promise that resolves to true if valid, false otherwise.
|
|
46
|
+
*/
|
|
47
|
+
export declare function validatePolygonApiKey(apiKey: string): Promise<boolean>;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=misc-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc-utils.d.ts","sourceRoot":"","sources":["../../src/misc-utils.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,SAAS,sDAAuD,CAAC;AAEvE,KAAK,OAAO,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,OAAO,OAAO,EAAE,OAAM,OAAgB,SAqBjF,CAAC;AAqBF;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiBrD;AAyCD;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,EACzB,OAAO,GAAE,MAAU,EACnB,cAAc,GAAE,MAAa,GAC5B,OAAO,CAAC,QAAQ,CAAC,CA2FnB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAe5E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"old-test.d.ts","sourceRoot":"","sources":["../../src/old-test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Polygon Indices API Implementation
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions to interact with the Polygon.io Indices API.
|
|
5
|
+
*/
|
|
6
|
+
import { PolygonIndicesAggregatesParams, PolygonIndicesAggregatesResponse, PolygonIndicesPrevCloseResponse, PolygonIndicesDailyOpenCloseResponse, PolygonIndicesSnapshotParams, PolygonIndicesSnapshotResponse } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Fetches aggregate bars for an index over a given date range in custom time window sizes.
|
|
9
|
+
*
|
|
10
|
+
* @param {PolygonIndicesAggregatesParams} params - Parameters for the aggregates request
|
|
11
|
+
* @param {Object} [options] - Optional parameters
|
|
12
|
+
* @param {string} [options.apiKey] - API key to use for the request
|
|
13
|
+
* @returns {Promise<PolygonIndicesAggregatesResponse>} The aggregates response
|
|
14
|
+
*/
|
|
15
|
+
export declare const fetchIndicesAggregates: (params: PolygonIndicesAggregatesParams, options?: {
|
|
16
|
+
apiKey?: string;
|
|
17
|
+
}) => Promise<PolygonIndicesAggregatesResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the previous day's open, high, low, and close (OHLC) for the specified index.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} indicesTicker - The ticker symbol of the index
|
|
22
|
+
* @param {Object} [options] - Optional parameters
|
|
23
|
+
* @param {string} [options.apiKey] - API key to use for the request
|
|
24
|
+
* @returns {Promise<PolygonIndicesPrevCloseResponse>} The previous close response
|
|
25
|
+
*/
|
|
26
|
+
export declare const fetchIndicesPreviousClose: (indicesTicker: string, options?: {
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
}) => Promise<PolygonIndicesPrevCloseResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the open, close and afterhours values of an index symbol on a certain date.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} indicesTicker - The ticker symbol of the index
|
|
33
|
+
* @param {string} date - The date in YYYY-MM-DD format
|
|
34
|
+
* @param {Object} [options] - Optional parameters
|
|
35
|
+
* @param {string} [options.apiKey] - API key to use for the request
|
|
36
|
+
* @returns {Promise<PolygonIndicesDailyOpenCloseResponse>} The daily open/close response
|
|
37
|
+
*/
|
|
38
|
+
export declare const fetchIndicesDailyOpenClose: (indicesTicker: string, date: string, options?: {
|
|
39
|
+
apiKey?: string;
|
|
40
|
+
}) => Promise<PolygonIndicesDailyOpenCloseResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Gets a snapshot of indices data for specified tickers.
|
|
43
|
+
*
|
|
44
|
+
* @param {PolygonIndicesSnapshotParams} [params] - Parameters for the snapshot request
|
|
45
|
+
* @param {Object} [options] - Optional parameters
|
|
46
|
+
* @param {string} [options.apiKey] - API key to use for the request
|
|
47
|
+
* @returns {Promise<PolygonIndicesSnapshotResponse>} The indices snapshot response
|
|
48
|
+
*/
|
|
49
|
+
export declare const fetchIndicesSnapshot: (params?: PolygonIndicesSnapshotParams, options?: {
|
|
50
|
+
apiKey?: string;
|
|
51
|
+
}) => Promise<PolygonIndicesSnapshotResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Gets snapshots for assets of all types, including indices.
|
|
54
|
+
*
|
|
55
|
+
* @param {string[]} tickers - Array of tickers to fetch snapshots for
|
|
56
|
+
* @param {Object} [options] - Optional parameters
|
|
57
|
+
* @param {string} [options.apiKey] - API key to use for the request
|
|
58
|
+
* @param {string} [options.type] - Filter by asset type
|
|
59
|
+
* @param {string} [options.order] - Order results
|
|
60
|
+
* @param {number} [options.limit] - Limit the number of results
|
|
61
|
+
* @param {string} [options.sort] - Sort field
|
|
62
|
+
* @returns {Promise<any>} The universal snapshot response
|
|
63
|
+
*/
|
|
64
|
+
export declare const fetchUniversalSnapshot: (tickers: string[], options?: {
|
|
65
|
+
apiKey?: string;
|
|
66
|
+
type?: string;
|
|
67
|
+
order?: string;
|
|
68
|
+
limit?: number;
|
|
69
|
+
sort?: string;
|
|
70
|
+
}) => Promise<any>;
|
|
71
|
+
/**
|
|
72
|
+
* Converts Polygon Indices bar data to a more standardized format
|
|
73
|
+
*
|
|
74
|
+
* @param {PolygonIndicesAggregatesResponse} data - The raw aggregates response
|
|
75
|
+
* @returns {Array<{date: string, open: number, high: number, low: number, close: number, timestamp: number}>} Formatted bar data
|
|
76
|
+
*/
|
|
77
|
+
export declare const formatIndicesBarData: (data: PolygonIndicesAggregatesResponse) => Array<{
|
|
78
|
+
date: string;
|
|
79
|
+
open: number;
|
|
80
|
+
high: number;
|
|
81
|
+
low: number;
|
|
82
|
+
close: number;
|
|
83
|
+
timestamp: number;
|
|
84
|
+
}>;
|
|
85
|
+
//# sourceMappingURL=polygon-indices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polygon-indices.d.ts","sourceRoot":"","sources":["../../src/polygon-indices.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,8BAA8B,EAC9B,gCAAgC,EAChC,+BAA+B,EAC/B,oCAAoC,EACpC,4BAA4B,EAC5B,8BAA8B,EAE/B,MAAM,SAAS,CAAC;AAyBjB;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,8BAA8B,EACtC,UAAU;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAC5B,OAAO,CAAC,gCAAgC,CAuC1C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,GACpC,eAAe,MAAM,EACrB,UAAU;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAC5B,OAAO,CAAC,+BAA+B,CAyBzC,C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