@tradejs/core 2.0.21 → 3.0.0

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.
@@ -0,0 +1,132 @@
1
+ // src/aiEndpoints.ts
2
+ var AI_CUSTOM_ENDPOINT_VALUE = "__custom__";
3
+ var AI_ENDPOINT_OPTIONS = [
4
+ {
5
+ label: "OpenAI",
6
+ value: "https://api.openai.com/v1"
7
+ },
8
+ {
9
+ label: "Claude",
10
+ value: "https://api.anthropic.com/v1"
11
+ },
12
+ {
13
+ label: "OpenRouter",
14
+ value: "https://openrouter.ai/api/v1"
15
+ },
16
+ {
17
+ label: "Gemini",
18
+ value: "https://generativelanguage.googleapis.com/v1beta/openai"
19
+ },
20
+ {
21
+ label: "Together AI",
22
+ value: "https://api.together.xyz/v1"
23
+ },
24
+ {
25
+ label: "Groq",
26
+ value: "https://api.groq.com/openai/v1"
27
+ },
28
+ {
29
+ label: "DeepInfra",
30
+ value: "https://api.deepinfra.com/v1/openai"
31
+ },
32
+ {
33
+ label: "xAI",
34
+ value: "https://api.x.ai/v1"
35
+ },
36
+ {
37
+ label: "Qwen (DashScope Intl)",
38
+ value: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
39
+ },
40
+ {
41
+ label: "Qwen (DashScope CN)",
42
+ value: "https://dashscope.aliyuncs.com/compatible-mode/v1"
43
+ },
44
+ {
45
+ label: "Qwen (DashScope US)",
46
+ value: "https://dashscope-us.aliyuncs.com/compatible-mode/v1"
47
+ },
48
+ {
49
+ label: "Perplexity",
50
+ value: "https://api.perplexity.ai"
51
+ },
52
+ {
53
+ label: "Fireworks",
54
+ value: "https://api.fireworks.ai/inference/v1"
55
+ },
56
+ {
57
+ label: "SambaNova",
58
+ value: "https://api.sambanova.ai/v1"
59
+ },
60
+ {
61
+ label: "Hyperbolic",
62
+ value: "https://api.hyperbolic.xyz/v1"
63
+ },
64
+ {
65
+ label: "Kimi",
66
+ value: "https://api.moonshot.ai/v1"
67
+ },
68
+ {
69
+ label: "ProxyAPI",
70
+ value: "https://openai.api.proxyapi.ru/v1"
71
+ },
72
+ {
73
+ label: "Custom",
74
+ value: AI_CUSTOM_ENDPOINT_VALUE
75
+ }
76
+ ];
77
+ var KNOWN_AI_ENDPOINTS = new Set(
78
+ AI_ENDPOINT_OPTIONS.map((option) => option.value).filter(
79
+ (value) => value !== AI_CUSTOM_ENDPOINT_VALUE
80
+ )
81
+ );
82
+ var normalizeUrl = (value) => value.replace(/\/+$/, "");
83
+ var isIpv4Address = (value) => /^(?:\d{1,3}\.){3}\d{1,3}$/.test(value.trim());
84
+ var parseIpv4Address = (value) => value.trim().split(".").map((part) => Number(part));
85
+ var isPrivateIpv4Address = (value) => {
86
+ if (!isIpv4Address(value)) {
87
+ return false;
88
+ }
89
+ const [a, b, c, d] = parseIpv4Address(value);
90
+ if ([a, b, c, d].some(
91
+ (part) => !Number.isInteger(part) || part < 0 || part > 255
92
+ )) {
93
+ return false;
94
+ }
95
+ return a === 10 || a === 127 || a === 0 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168;
96
+ };
97
+ var isPrivateHostname = (hostname) => {
98
+ const normalized = hostname.trim().toLowerCase();
99
+ if (!normalized) {
100
+ return true;
101
+ }
102
+ return normalized === "localhost" || normalized.endsWith(".localhost") || normalized.endsWith(".local") || normalized.endsWith(".internal") || normalized.endsWith(".lan") || normalized === "::1" || normalized === "[::1]" || isPrivateIpv4Address(normalized);
103
+ };
104
+ var isValidAiEndpointUrl = (value) => {
105
+ try {
106
+ const url = new URL(value);
107
+ return url.protocol === "https:" && !isPrivateHostname(url.hostname);
108
+ } catch {
109
+ return false;
110
+ }
111
+ };
112
+ var normalizeAiEndpoint = (value) => {
113
+ if (typeof value !== "string") {
114
+ return "";
115
+ }
116
+ const trimmed = normalizeUrl(value.trim());
117
+ if (!trimmed) {
118
+ return "";
119
+ }
120
+ if (KNOWN_AI_ENDPOINTS.has(trimmed)) {
121
+ return trimmed;
122
+ }
123
+ return isValidAiEndpointUrl(trimmed) ? trimmed : "";
124
+ };
125
+ var isKnownAiEndpoint = (value) => KNOWN_AI_ENDPOINTS.has(normalizeAiEndpoint(value));
126
+
127
+ export {
128
+ AI_CUSTOM_ENDPOINT_VALUE,
129
+ AI_ENDPOINT_OPTIONS,
130
+ normalizeAiEndpoint,
131
+ isKnownAiEndpoint
132
+ };
package/dist/data.mjs CHANGED
@@ -1,12 +1,12 @@
1
+ import {
2
+ toJson
3
+ } from "./chunk-OJPHC3S2.mjs";
1
4
  import {
2
5
  cloneArrayValues,
3
6
  intervalToMs,
4
7
  isWrongData,
5
8
  mergeData
6
9
  } from "./chunk-M7QGVZ3J.mjs";
7
- import {
8
- toJson
9
- } from "./chunk-OJPHC3S2.mjs";
10
10
  export {
11
11
  cloneArrayValues,
12
12
  intervalToMs,
package/dist/grid.mjs CHANGED
@@ -1,3 +1,6 @@
1
+ import {
2
+ toJson
3
+ } from "./chunk-OJPHC3S2.mjs";
1
4
  import {
2
5
  uuid
3
6
  } from "./chunk-U3GDILUZ.mjs";
@@ -7,9 +10,6 @@ import {
7
10
  import {
8
11
  BACKTEST_DEFAULT_DAYS
9
12
  } from "./chunk-MKCQSB4H.mjs";
10
- import {
11
- toJson
12
- } from "./chunk-OJPHC3S2.mjs";
13
13
 
14
14
  // src/utils/grid.ts
15
15
  import _ from "lodash";