@jango-blockchained/hoox-shared 1.0.8
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 +27 -0
- package/dist/analytics.d.ts +22 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +34 -0
- package/dist/api-client.d.ts +34 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +124 -0
- package/dist/colors.d.ts +34 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +42 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +91 -0
- package/dist/d1/index.d.ts +5 -0
- package/dist/d1/index.d.ts.map +1 -0
- package/dist/d1/index.js +316 -0
- package/dist/d1/repository.d.ts +77 -0
- package/dist/d1/repository.d.ts.map +1 -0
- package/dist/d1/schemas.d.ts +85 -0
- package/dist/d1/schemas.d.ts.map +1 -0
- package/dist/errors.d.ts +39 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +106 -0
- package/dist/exchange-client.d.ts +84 -0
- package/dist/exchange-client.d.ts.map +1 -0
- package/dist/exchange-client.js +104 -0
- package/dist/format-time.d.ts +24 -0
- package/dist/format-time.d.ts.map +1 -0
- package/dist/format-time.js +57 -0
- package/dist/formatters.d.ts +32 -0
- package/dist/formatters.d.ts.map +1 -0
- package/dist/formatters.js +155 -0
- package/dist/health.d.ts +19 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/health.js +117 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2581 -0
- package/dist/kvKeys.d.ts +72 -0
- package/dist/kvKeys.d.ts.map +1 -0
- package/dist/kvKeys.js +107 -0
- package/dist/kvUtils.d.ts +26 -0
- package/dist/kvUtils.d.ts.map +1 -0
- package/dist/kvUtils.js +127 -0
- package/dist/legal.d.ts +11 -0
- package/dist/legal.d.ts.map +1 -0
- package/dist/legal.js +40 -0
- package/dist/middleware/auth.d.ts +59 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/cors.d.ts +28 -0
- package/dist/middleware/cors.d.ts.map +1 -0
- package/dist/middleware/index.d.ts +10 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +375 -0
- package/dist/middleware/logger.d.ts +16 -0
- package/dist/middleware/logger.d.ts.map +1 -0
- package/dist/middleware/rate-limit.d.ts +24 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/middleware/security-headers.d.ts +39 -0
- package/dist/middleware/security-headers.d.ts.map +1 -0
- package/dist/middleware/validate.d.ts +21 -0
- package/dist/middleware/validate.d.ts.map +1 -0
- package/dist/router.d.ts +11 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +123 -0
- package/dist/schemas/index.d.ts +4 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +656 -0
- package/dist/schemas/registry.d.ts +8 -0
- package/dist/schemas/registry.d.ts.map +1 -0
- package/dist/schemas/types.d.ts +79 -0
- package/dist/schemas/types.d.ts.map +1 -0
- package/dist/schemas/validators.d.ts +35 -0
- package/dist/schemas/validators.d.ts.map +1 -0
- package/dist/service-bindings.d.ts +32 -0
- package/dist/service-bindings.d.ts.map +1 -0
- package/dist/service-bindings.js +31 -0
- package/dist/session.d.ts +46 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +79 -0
- package/dist/sse.d.ts +26 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +91 -0
- package/dist/stores/config-store.d.ts +87 -0
- package/dist/stores/config-store.d.ts.map +1 -0
- package/dist/stores/config-store.js +132 -0
- package/dist/stores/service-store.d.ts +206 -0
- package/dist/stores/service-store.d.ts.map +1 -0
- package/dist/stores/service-store.js +359 -0
- package/dist/stores/ui-store.d.ts +63 -0
- package/dist/stores/ui-store.d.ts.map +1 -0
- package/dist/stores/ui-store.js +62 -0
- package/dist/types/errors.d.ts +16 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +1 -0
- package/dist/types/router.d.ts +22 -0
- package/dist/types/router.d.ts.map +1 -0
- package/dist/types/router.js +1 -0
- package/dist/types.d.ts +317 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +70 -0
- package/dist/wizard/engine.d.ts +42 -0
- package/dist/wizard/engine.d.ts.map +1 -0
- package/dist/wizard/index.d.ts +7 -0
- package/dist/wizard/index.d.ts.map +1 -0
- package/dist/wizard/index.js +519 -0
- package/dist/wizard/persistence.d.ts +14 -0
- package/dist/wizard/persistence.d.ts.map +1 -0
- package/dist/wizard/presets.d.ts +34 -0
- package/dist/wizard/presets.d.ts.map +1 -0
- package/dist/wizard/provisioner.d.ts +11 -0
- package/dist/wizard/provisioner.d.ts.map +1 -0
- package/dist/wizard/types.d.ts +72 -0
- package/dist/wizard/types.d.ts.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export type ExchangeName = "binance" | "mexc" | "bybit";
|
|
2
|
+
export interface ExchangeConfig {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
apiSecret: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
testnet?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface TradeParams {
|
|
9
|
+
symbol: string;
|
|
10
|
+
side: "long" | "short";
|
|
11
|
+
orderType?: string;
|
|
12
|
+
quantity: number;
|
|
13
|
+
price?: number;
|
|
14
|
+
reduceOnly?: boolean;
|
|
15
|
+
leverage?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface OrderResponse {
|
|
18
|
+
orderId: string;
|
|
19
|
+
symbol: string;
|
|
20
|
+
status: string;
|
|
21
|
+
executedQty?: string;
|
|
22
|
+
price?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface Position {
|
|
25
|
+
symbol: string;
|
|
26
|
+
side: "long" | "short";
|
|
27
|
+
quantity: number;
|
|
28
|
+
entryPrice: number;
|
|
29
|
+
unrealizedPnl?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generic exchange provider interface.
|
|
33
|
+
* Workers implement this to provide exchange-specific client creation and credential validation.
|
|
34
|
+
*
|
|
35
|
+
* @typeParam TClient - The exchange client type (e.g., IExchangeClient)
|
|
36
|
+
* @typeParam TEnv - The worker's environment/bindings type (e.g., Env)
|
|
37
|
+
*/
|
|
38
|
+
export interface IExchangeProvider<TClient, TEnv> {
|
|
39
|
+
readonly name: string;
|
|
40
|
+
createClient(env: TEnv): TClient;
|
|
41
|
+
hasCredentials(env: TEnv): boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Generic exchange router that maps exchange names to providers.
|
|
45
|
+
* Workers extend or compose this to add worker-specific routing logic.
|
|
46
|
+
*
|
|
47
|
+
* @typeParam TClient - The exchange client type
|
|
48
|
+
* @typeParam TEnv - The worker's environment type
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const router = new ExchangeRouter<IExchangeClient, Env>();
|
|
53
|
+
* router.registerProvider(new BinanceProvider());
|
|
54
|
+
* const { client } = router.route("binance", env);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare class ExchangeRouter<TClient, TEnv> {
|
|
58
|
+
private readonly providers;
|
|
59
|
+
registerProvider(provider: IExchangeProvider<TClient, TEnv>): void;
|
|
60
|
+
route(exchange: string, env: TEnv): {
|
|
61
|
+
exchange: string;
|
|
62
|
+
client: TClient;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export declare abstract class BaseExchangeClient {
|
|
66
|
+
protected readonly apiKey: string;
|
|
67
|
+
protected readonly apiSecret: string;
|
|
68
|
+
protected readonly baseUrl: string;
|
|
69
|
+
protected readonly isTestnet: boolean;
|
|
70
|
+
constructor(config: ExchangeConfig);
|
|
71
|
+
protected abstract getDefaultBaseUrl(): string;
|
|
72
|
+
protected abstract generateSignature(params: Record<string, string | number | boolean>): Promise<string>;
|
|
73
|
+
protected abstract buildHeaders(method: string, path: string, params?: Record<string, string | number | boolean>): Headers;
|
|
74
|
+
protected fetch<T>(method: string, path: string, params?: Record<string, string | number | boolean>): Promise<T>;
|
|
75
|
+
abstract setLeverage(symbol: string, leverage: number): Promise<void>;
|
|
76
|
+
abstract executeTrade(params: TradeParams): Promise<OrderResponse>;
|
|
77
|
+
abstract getAccountInfo(): Promise<Record<string, unknown>>;
|
|
78
|
+
abstract getPositions(symbol?: string): Promise<Position[]>;
|
|
79
|
+
openLong(symbol: string, quantity: number, price?: number, orderType?: string): Promise<OrderResponse>;
|
|
80
|
+
openShort(symbol: string, quantity: number, price?: number, orderType?: string): Promise<OrderResponse>;
|
|
81
|
+
closeLong(symbol: string, quantity: number): Promise<OrderResponse>;
|
|
82
|
+
closeShort(symbol: string, quantity: number): Promise<OrderResponse>;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=exchange-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exchange-client.d.ts","sourceRoot":"","sources":["../src/exchange-client.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAA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AAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,aAAa,CAAC;CAQ1B"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
+
|
|
18
|
+
// src/exchange-client.ts
|
|
19
|
+
class ExchangeRouter {
|
|
20
|
+
providers = new Map;
|
|
21
|
+
registerProvider(provider) {
|
|
22
|
+
this.providers.set(provider.name.toLowerCase(), provider);
|
|
23
|
+
}
|
|
24
|
+
route(exchange, env) {
|
|
25
|
+
const key = exchange.toLowerCase();
|
|
26
|
+
const provider = this.providers.get(key);
|
|
27
|
+
if (!provider) {
|
|
28
|
+
throw new Error(`Unsupported exchange: ${exchange}`);
|
|
29
|
+
}
|
|
30
|
+
if (!provider.hasCredentials(env)) {
|
|
31
|
+
throw new Error(`API secret bindings not configured or accessible for ${exchange}`);
|
|
32
|
+
}
|
|
33
|
+
return { exchange: key, client: provider.createClient(env) };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
class BaseExchangeClient {
|
|
38
|
+
apiKey;
|
|
39
|
+
apiSecret;
|
|
40
|
+
baseUrl;
|
|
41
|
+
isTestnet;
|
|
42
|
+
constructor(config) {
|
|
43
|
+
if (!config.apiKey || !config.apiSecret) {
|
|
44
|
+
throw new Error("API key and secret are required.");
|
|
45
|
+
}
|
|
46
|
+
this.apiKey = config.apiKey;
|
|
47
|
+
this.apiSecret = config.apiSecret;
|
|
48
|
+
this.baseUrl = config.baseUrl || this.getDefaultBaseUrl();
|
|
49
|
+
this.isTestnet = config.testnet || false;
|
|
50
|
+
}
|
|
51
|
+
async fetch(method, path, params) {
|
|
52
|
+
const url = `${this.baseUrl}${path}`;
|
|
53
|
+
const headers = this.buildHeaders(method, path, params);
|
|
54
|
+
const body = params ? new URLSearchParams(params).toString() : undefined;
|
|
55
|
+
const response = await fetch(url, {
|
|
56
|
+
method,
|
|
57
|
+
headers,
|
|
58
|
+
body: method !== "GET" ? body : undefined
|
|
59
|
+
});
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
const error = await response.text();
|
|
62
|
+
throw new Error(`Exchange API error: ${response.status} - ${error}`);
|
|
63
|
+
}
|
|
64
|
+
return response.json();
|
|
65
|
+
}
|
|
66
|
+
async openLong(symbol, quantity, price, orderType = "MARKET") {
|
|
67
|
+
return this.executeTrade({
|
|
68
|
+
symbol,
|
|
69
|
+
side: "long",
|
|
70
|
+
orderType,
|
|
71
|
+
quantity,
|
|
72
|
+
price
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
async openShort(symbol, quantity, price, orderType = "MARKET") {
|
|
76
|
+
return this.executeTrade({
|
|
77
|
+
symbol,
|
|
78
|
+
side: "short",
|
|
79
|
+
orderType,
|
|
80
|
+
quantity,
|
|
81
|
+
price
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async closeLong(symbol, quantity) {
|
|
85
|
+
return this.executeTrade({
|
|
86
|
+
symbol,
|
|
87
|
+
side: "long",
|
|
88
|
+
quantity,
|
|
89
|
+
reduceOnly: true
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async closeShort(symbol, quantity) {
|
|
93
|
+
return this.executeTrade({
|
|
94
|
+
symbol,
|
|
95
|
+
side: "short",
|
|
96
|
+
quantity,
|
|
97
|
+
reduceOnly: true
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
ExchangeRouter,
|
|
103
|
+
BaseExchangeClient
|
|
104
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relative time formatter — converts a timestamp (ms) into a human-readable
|
|
3
|
+
* "time ago" string. Used by the StatusBar stale-data indicator and toast
|
|
4
|
+
* notifications for reconnection downtime.
|
|
5
|
+
*
|
|
6
|
+
* Format: "< 1m ago", "2m ago", "1h ago", "3d ago", "> 30d ago"
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Format a timestamp as a relative "X ago" string.
|
|
10
|
+
*
|
|
11
|
+
* @param timestampMs Unix timestamp in milliseconds
|
|
12
|
+
* @param nowMs Optional "now" reference (defaults to Date.now())
|
|
13
|
+
* @returns Relative time string (e.g. "5m ago")
|
|
14
|
+
*/
|
|
15
|
+
export declare function formatRelativeTime(timestampMs: number, nowMs?: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Format a duration in milliseconds as a compact human-readable string.
|
|
18
|
+
* Used for reconnection downtime toasts.
|
|
19
|
+
*
|
|
20
|
+
* @param durationMs Duration in milliseconds
|
|
21
|
+
* @returns Compact duration string (e.g. "12s", "2m 30s")
|
|
22
|
+
*/
|
|
23
|
+
export declare function formatDuration(durationMs: number): string;
|
|
24
|
+
//# sourceMappingURL=format-time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-time.d.ts","sourceRoot":"","sources":["../src/format-time.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,MAAM,CAkBR;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAczD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
+
|
|
18
|
+
// src/format-time.ts
|
|
19
|
+
function formatRelativeTime(timestampMs, nowMs) {
|
|
20
|
+
const now = nowMs ?? Date.now();
|
|
21
|
+
const diffMs = now - timestampMs;
|
|
22
|
+
if (diffMs < 0)
|
|
23
|
+
return "just now";
|
|
24
|
+
if (timestampMs === 0)
|
|
25
|
+
return "\u2014";
|
|
26
|
+
const seconds = Math.floor(diffMs / 1000);
|
|
27
|
+
const minutes = Math.floor(seconds / 60);
|
|
28
|
+
const hours = Math.floor(minutes / 60);
|
|
29
|
+
const days = Math.floor(hours / 24);
|
|
30
|
+
if (seconds < 60)
|
|
31
|
+
return "< 1m ago";
|
|
32
|
+
if (minutes < 60)
|
|
33
|
+
return `${minutes}m ago`;
|
|
34
|
+
if (hours < 24)
|
|
35
|
+
return `${hours}h ago`;
|
|
36
|
+
if (days < 30)
|
|
37
|
+
return `${days}d ago`;
|
|
38
|
+
return `> 30d ago`;
|
|
39
|
+
}
|
|
40
|
+
function formatDuration(durationMs) {
|
|
41
|
+
const seconds = Math.floor(durationMs / 1000);
|
|
42
|
+
const minutes = Math.floor(seconds / 60);
|
|
43
|
+
const hours = Math.floor(minutes / 60);
|
|
44
|
+
if (hours > 0) {
|
|
45
|
+
const remainMin = minutes % 60;
|
|
46
|
+
return remainMin > 0 ? `${hours}h ${remainMin}m` : `${hours}h`;
|
|
47
|
+
}
|
|
48
|
+
if (minutes > 0) {
|
|
49
|
+
const remainSec = seconds % 60;
|
|
50
|
+
return remainSec > 0 ? `${minutes}m ${remainSec}s` : `${minutes}m`;
|
|
51
|
+
}
|
|
52
|
+
return `${seconds}s`;
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
formatRelativeTime,
|
|
56
|
+
formatDuration
|
|
57
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatters — Number, currency, duration, and timestamp formatting utilities.
|
|
3
|
+
*
|
|
4
|
+
* Pure functions — no side effects, safe for NaN/Infinity/negative/zero.
|
|
5
|
+
*/
|
|
6
|
+
/** Format large numbers with K/M/B suffixes */
|
|
7
|
+
export declare function formatNumber(n: number): string;
|
|
8
|
+
/** Format as compact currency */
|
|
9
|
+
export declare function formatCurrency(n: number): string;
|
|
10
|
+
/** Compact currency without sign prefix for raw values */
|
|
11
|
+
export declare function formatCompactCurrency(n: number): string;
|
|
12
|
+
/** Format duration in seconds to human-readable */
|
|
13
|
+
export declare function formatDuration(seconds: number): string;
|
|
14
|
+
/** Compact duration (e.g. "72h", "1d 3h") */
|
|
15
|
+
export declare function formatDurationCompact(seconds: number): string;
|
|
16
|
+
/** ISO timestamp to human-readable */
|
|
17
|
+
export declare function formatTimestamp(iso: string): string;
|
|
18
|
+
/** Relative time (e.g. "2m ago", "1h ago", "3d ago") */
|
|
19
|
+
export declare function formatRelativeTime(timestamp: number): string;
|
|
20
|
+
/** Format percentage */
|
|
21
|
+
export declare function formatPercent(n: number, decimals?: number): string;
|
|
22
|
+
/** Uptime seconds to human-readable */
|
|
23
|
+
export declare function formatUptime(seconds: number): string;
|
|
24
|
+
/** Latency in ms */
|
|
25
|
+
export declare function formatLatency(ms: number): string;
|
|
26
|
+
/** Request count */
|
|
27
|
+
export declare function formatRequests(n: number): string;
|
|
28
|
+
/** Memory in MB */
|
|
29
|
+
export declare function formatMemory(usedMB: number, limitMB: number): string;
|
|
30
|
+
/** CPU time in ms */
|
|
31
|
+
export declare function formatCpu(ms: number): string;
|
|
32
|
+
//# sourceMappingURL=formatters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,+CAA+C;AAC/C,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAM9C;AAED,iCAAiC;AACjC,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAOhD;AAED,0DAA0D;AAC1D,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAOvD;AAED,mDAAmD;AACnD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAYtD;AAED,6CAA6C;AAC7C,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAS7D;AAED,sCAAsC;AACtC,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQnD;AAED,wDAAwD;AACxD,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAY5D;AAED,wBAAwB;AACxB,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,CAI7D;AAED,uCAAuC;AACvC,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,oBAAoB;AACpB,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAKhD;AAED,oBAAoB;AACpB,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,mBAAmB;AACnB,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAIpE;AAED,qBAAqB;AACrB,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAG5C"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
+
|
|
18
|
+
// src/formatters.ts
|
|
19
|
+
function formatNumber(n) {
|
|
20
|
+
if (!isFinite(n))
|
|
21
|
+
return "\u2014";
|
|
22
|
+
if (Math.abs(n) >= 1e9)
|
|
23
|
+
return `${(n / 1e9).toFixed(1)}B`;
|
|
24
|
+
if (Math.abs(n) >= 1e6)
|
|
25
|
+
return `${(n / 1e6).toFixed(1)}M`;
|
|
26
|
+
if (Math.abs(n) >= 1000)
|
|
27
|
+
return `${(n / 1000).toFixed(1)}K`;
|
|
28
|
+
return n.toLocaleString();
|
|
29
|
+
}
|
|
30
|
+
function formatCurrency(n) {
|
|
31
|
+
if (!isFinite(n))
|
|
32
|
+
return "\u2014";
|
|
33
|
+
const sign = n >= 0 ? "+" : "-";
|
|
34
|
+
const abs = Math.abs(n);
|
|
35
|
+
if (abs >= 1e6)
|
|
36
|
+
return `${sign}$${(abs / 1e6).toFixed(2)}M`;
|
|
37
|
+
if (abs >= 1000)
|
|
38
|
+
return `${sign}$${(abs / 1000).toFixed(2)}K`;
|
|
39
|
+
return `${sign}$${abs.toFixed(2)}`;
|
|
40
|
+
}
|
|
41
|
+
function formatCompactCurrency(n) {
|
|
42
|
+
if (!isFinite(n))
|
|
43
|
+
return "\u2014";
|
|
44
|
+
const abs = Math.abs(n);
|
|
45
|
+
const sign = n < 0 ? "-" : "";
|
|
46
|
+
if (abs >= 1e6)
|
|
47
|
+
return `${sign}$${(abs / 1e6).toFixed(2)}M`;
|
|
48
|
+
if (abs >= 1000)
|
|
49
|
+
return `${sign}$${(abs / 1000).toFixed(2)}K`;
|
|
50
|
+
return `${sign}$${abs.toFixed(2)}`;
|
|
51
|
+
}
|
|
52
|
+
function formatDuration(seconds) {
|
|
53
|
+
if (!isFinite(seconds) || seconds < 0)
|
|
54
|
+
return "\u2014";
|
|
55
|
+
const d = Math.floor(seconds / 86400);
|
|
56
|
+
const h = Math.floor(seconds % 86400 / 3600);
|
|
57
|
+
const m = Math.floor(seconds % 3600 / 60);
|
|
58
|
+
const s = Math.floor(seconds % 60);
|
|
59
|
+
const parts = [];
|
|
60
|
+
if (d > 0)
|
|
61
|
+
parts.push(`${d}d`);
|
|
62
|
+
if (h > 0 || d > 0)
|
|
63
|
+
parts.push(`${h}h`);
|
|
64
|
+
if (m > 0 || h > 0 || d > 0)
|
|
65
|
+
parts.push(`${m}m`);
|
|
66
|
+
parts.push(`${s}s`);
|
|
67
|
+
return parts.join(" ");
|
|
68
|
+
}
|
|
69
|
+
function formatDurationCompact(seconds) {
|
|
70
|
+
if (!isFinite(seconds) || seconds < 0)
|
|
71
|
+
return "\u2014";
|
|
72
|
+
const d = Math.floor(seconds / 86400);
|
|
73
|
+
const h = Math.floor(seconds % 86400 / 3600);
|
|
74
|
+
const m = Math.floor(seconds % 3600 / 60);
|
|
75
|
+
if (d > 0)
|
|
76
|
+
return `${d}d ${h}h`;
|
|
77
|
+
if (h > 0)
|
|
78
|
+
return `${h}h ${m}m`;
|
|
79
|
+
if (m > 0)
|
|
80
|
+
return `${m}m`;
|
|
81
|
+
return `${Math.floor(seconds)}s`;
|
|
82
|
+
}
|
|
83
|
+
function formatTimestamp(iso) {
|
|
84
|
+
try {
|
|
85
|
+
const d = new Date(iso);
|
|
86
|
+
if (isNaN(d.getTime()))
|
|
87
|
+
return iso;
|
|
88
|
+
return d.toLocaleTimeString("en-US", { hour12: false });
|
|
89
|
+
} catch {
|
|
90
|
+
return iso;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function formatRelativeTime(timestamp) {
|
|
94
|
+
const now = Date.now();
|
|
95
|
+
const diff = now - timestamp;
|
|
96
|
+
if (diff < 0)
|
|
97
|
+
return "just now";
|
|
98
|
+
const seconds = Math.floor(diff / 1000);
|
|
99
|
+
if (seconds < 60)
|
|
100
|
+
return `${seconds}s ago`;
|
|
101
|
+
const minutes = Math.floor(seconds / 60);
|
|
102
|
+
if (minutes < 60)
|
|
103
|
+
return `${minutes}m ago`;
|
|
104
|
+
const hours = Math.floor(minutes / 60);
|
|
105
|
+
if (hours < 24)
|
|
106
|
+
return `${hours}h ago`;
|
|
107
|
+
const days = Math.floor(hours / 24);
|
|
108
|
+
return `${days}d ago`;
|
|
109
|
+
}
|
|
110
|
+
function formatPercent(n, decimals = 2) {
|
|
111
|
+
if (!isFinite(n))
|
|
112
|
+
return "\u2014";
|
|
113
|
+
const sign = n >= 0 ? "+" : "";
|
|
114
|
+
return `${sign}${n.toFixed(decimals)}%`;
|
|
115
|
+
}
|
|
116
|
+
function formatUptime(seconds) {
|
|
117
|
+
return formatDuration(seconds);
|
|
118
|
+
}
|
|
119
|
+
function formatLatency(ms) {
|
|
120
|
+
if (!isFinite(ms))
|
|
121
|
+
return "\u2014";
|
|
122
|
+
if (ms < 1)
|
|
123
|
+
return "<1ms";
|
|
124
|
+
if (ms < 1000)
|
|
125
|
+
return `${Math.round(ms)}ms`;
|
|
126
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
127
|
+
}
|
|
128
|
+
function formatRequests(n) {
|
|
129
|
+
return formatNumber(n);
|
|
130
|
+
}
|
|
131
|
+
function formatMemory(usedMB, limitMB) {
|
|
132
|
+
const u = usedMB.toFixed(0);
|
|
133
|
+
const l = limitMB.toFixed(0);
|
|
134
|
+
return `${u}/${l} MB`;
|
|
135
|
+
}
|
|
136
|
+
function formatCpu(ms) {
|
|
137
|
+
if (!isFinite(ms))
|
|
138
|
+
return "\u2014";
|
|
139
|
+
return `${ms.toFixed(1)}ms`;
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
formatUptime,
|
|
143
|
+
formatTimestamp,
|
|
144
|
+
formatRequests,
|
|
145
|
+
formatRelativeTime,
|
|
146
|
+
formatPercent,
|
|
147
|
+
formatNumber,
|
|
148
|
+
formatMemory,
|
|
149
|
+
formatLatency,
|
|
150
|
+
formatDurationCompact,
|
|
151
|
+
formatDuration,
|
|
152
|
+
formatCurrency,
|
|
153
|
+
formatCpu,
|
|
154
|
+
formatCompactCurrency
|
|
155
|
+
};
|
package/dist/health.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health check handler for Cloudflare Workers
|
|
3
|
+
* Provides a standardized /health endpoint response
|
|
4
|
+
*/
|
|
5
|
+
export interface HealthCheckOptions {
|
|
6
|
+
/** Worker/service name included in the response */
|
|
7
|
+
worker?: string;
|
|
8
|
+
/** Version string included in the response */
|
|
9
|
+
version?: string;
|
|
10
|
+
/** Additional details to include */
|
|
11
|
+
details?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a standardized health check response.
|
|
15
|
+
* Returns a JSON response with success status and health metadata.
|
|
16
|
+
* Format: { success: true, result: { status: 'ok', timestamp, worker, version, details } }
|
|
17
|
+
*/
|
|
18
|
+
export declare function healthCheck(options?: HealthCheckOptions): Response;
|
|
19
|
+
//# sourceMappingURL=health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../src/health.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,QAAQ,CAalE"}
|
package/dist/health.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
+
|
|
18
|
+
// src/errors.ts
|
|
19
|
+
function toError(err, fallback = "Unknown error") {
|
|
20
|
+
if (err instanceof Error)
|
|
21
|
+
return err.message;
|
|
22
|
+
if (typeof err === "string")
|
|
23
|
+
return err;
|
|
24
|
+
if (err && typeof err === "object" && "message" in err && typeof err.message === "string") {
|
|
25
|
+
return err.message;
|
|
26
|
+
}
|
|
27
|
+
if (err === null || err === undefined)
|
|
28
|
+
return fallback;
|
|
29
|
+
try {
|
|
30
|
+
return JSON.stringify(err) || fallback;
|
|
31
|
+
} catch {
|
|
32
|
+
return fallback;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function sanitizeOutput(data) {
|
|
36
|
+
if (data instanceof Error) {
|
|
37
|
+
return { name: data.name, message: data.message };
|
|
38
|
+
}
|
|
39
|
+
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
40
|
+
const sanitized = {};
|
|
41
|
+
for (const [k, v] of Object.entries(data)) {
|
|
42
|
+
if (k === "stack" || k === "cause")
|
|
43
|
+
continue;
|
|
44
|
+
sanitized[k] = v instanceof Error ? { name: v.name, message: v.message } : sanitizeOutput(v);
|
|
45
|
+
}
|
|
46
|
+
return sanitized;
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(data)) {
|
|
49
|
+
return data.map(sanitizeOutput);
|
|
50
|
+
}
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
function createJsonResponse(data, status = 200) {
|
|
54
|
+
return new Response(JSON.stringify(sanitizeOutput(data)), {
|
|
55
|
+
status,
|
|
56
|
+
headers: { "Content-Type": "application/json" }
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function createSuccessResponse(result) {
|
|
60
|
+
return createJsonResponse({ success: true, result }, 200);
|
|
61
|
+
}
|
|
62
|
+
function createErrorResponse(error, status) {
|
|
63
|
+
const message = typeof error === "string" ? error : error.message;
|
|
64
|
+
const statusCode = typeof error === "string" ? status ?? 500 : error.status ?? 500;
|
|
65
|
+
const body = { success: false, error: message };
|
|
66
|
+
if (typeof error !== "string" && error.code)
|
|
67
|
+
body.code = error.code;
|
|
68
|
+
if (typeof error !== "string" && error.details !== undefined)
|
|
69
|
+
body.details = error.details;
|
|
70
|
+
return new Response(JSON.stringify(body), {
|
|
71
|
+
status: statusCode,
|
|
72
|
+
headers: { "Content-Type": "application/json" }
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
var Errors = {
|
|
76
|
+
badRequest: (message) => createErrorResponse({ message, status: 400, code: "BAD_REQUEST" }),
|
|
77
|
+
unauthorized: (message = "Unauthorized") => createErrorResponse({ message, status: 401, code: "UNAUTHORIZED" }),
|
|
78
|
+
forbidden: (message = "Forbidden") => createErrorResponse({ message, status: 403, code: "FORBIDDEN" }),
|
|
79
|
+
notFound: (message = "Not found") => createErrorResponse({ message, status: 404, code: "NOT_FOUND" }),
|
|
80
|
+
methodNotAllowed: (message = "Method not allowed") => createErrorResponse({ message, status: 405, code: "METHOD_NOT_ALLOWED" }),
|
|
81
|
+
rateLimited: (retryAfter) => {
|
|
82
|
+
const res = createErrorResponse({
|
|
83
|
+
message: "Rate limit exceeded",
|
|
84
|
+
status: 429,
|
|
85
|
+
code: "RATE_LIMITED"
|
|
86
|
+
});
|
|
87
|
+
if (retryAfter)
|
|
88
|
+
res.headers.set("Retry-After", String(retryAfter));
|
|
89
|
+
return res;
|
|
90
|
+
},
|
|
91
|
+
internal: (err) => {
|
|
92
|
+
const message = err ? toError(err, "Internal server error") : "Internal server error";
|
|
93
|
+
return createErrorResponse({
|
|
94
|
+
message,
|
|
95
|
+
status: 500,
|
|
96
|
+
code: "INTERNAL_ERROR"
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// src/health.ts
|
|
102
|
+
function healthCheck(options) {
|
|
103
|
+
const result = {
|
|
104
|
+
status: "ok",
|
|
105
|
+
timestamp: new Date().toISOString()
|
|
106
|
+
};
|
|
107
|
+
if (options?.worker !== undefined && options?.worker !== null)
|
|
108
|
+
result.service = options.worker;
|
|
109
|
+
if (options?.version !== undefined && options?.version !== null)
|
|
110
|
+
result.version = options.version;
|
|
111
|
+
if (options?.details)
|
|
112
|
+
result.details = options.details;
|
|
113
|
+
return createSuccessResponse(result);
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
healthCheck
|
|
117
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hoox/shared — Shared module for HOOX CLI and TUI
|
|
3
|
+
*
|
|
4
|
+
* Barrel export: re-exports all shared utilities, types, stores, and TUI helpers.
|
|
5
|
+
*/
|
|
6
|
+
export { COPYRIGHT, TRADEMARKS, TRADEMARK_NOTICE, DISCLAIMER, FULL_LEGAL_NOTICE, DISCLAIMER_HEADER, } from "./legal";
|
|
7
|
+
export type { StandardResponse, ApiSuccessResponse, ApiErrorResponse, ApiResponse, WorkerServiceBinding, WorkerD1Binding, WorkerSecretsStoreBinding, WorkerQueueConfig, HousekeepingCheck, HousekeepingPayload, HousekeepingSummary, SettingsPayload, ProcessRequestBody, BaseEnv, Result, } from "./types";
|
|
8
|
+
export { TradeActionSchema, WebhookPayloadSchema, TradeSignalSchema, PositionSchema, BalanceSchema, } from "./types";
|
|
9
|
+
export type { TradeAction, WebhookPayload, TradeSignal } from "./types";
|
|
10
|
+
export { KVKeys } from "./kvKeys";
|
|
11
|
+
export { toError, Errors, createJsonResponse, createSuccessResponse, createErrorResponse, } from "./errors";
|
|
12
|
+
export { BaseExchangeClient, ExchangeRouter } from "./exchange-client";
|
|
13
|
+
export type { ExchangeName, ExchangeConfig, TradeParams, OrderResponse, Position, IExchangeProvider, } from "./exchange-client";
|
|
14
|
+
export { logKvTimestamp, headersToObject } from "./kvUtils";
|
|
15
|
+
export type { EnvWithKV } from "./kvUtils";
|
|
16
|
+
export { trackAnalytics } from "./analytics";
|
|
17
|
+
export type { AnalyticsEnv } from "./analytics";
|
|
18
|
+
export { healthCheck } from "./health";
|
|
19
|
+
export type { HealthCheckOptions } from "./health";
|
|
20
|
+
export { D1Repository } from "./d1/index";
|
|
21
|
+
export { serviceFetch } from "./service-bindings";
|
|
22
|
+
export type { TradeRecord, PositionRecord, BalanceRecord, SystemLogRecord, TradeSignalRecord, D1QueryResult, BatchStatement, } from "./d1/index";
|
|
23
|
+
export { Colors } from "./colors";
|
|
24
|
+
export type { ColorKey } from "./colors";
|
|
25
|
+
export { formatNumber, formatCurrency, formatCompactCurrency, formatDuration, formatDurationCompact, formatTimestamp, formatRelativeTime, formatPercent, formatUptime, formatLatency, formatRequests, formatMemory, formatCpu, } from "./formatters";
|
|
26
|
+
export { readConfigSync, readConfig, writeConfigSync, writeConfig, validateConfig, } from "./config";
|
|
27
|
+
export type { HooxConfig } from "./config";
|
|
28
|
+
export { hooxFetch, WorkerAPIError } from "./api-client";
|
|
29
|
+
export { subscribeSSE } from "./sse";
|
|
30
|
+
export type { SSECallback, SSEStatusCallback } from "./sse";
|
|
31
|
+
export { restoreSession, saveSession } from "./session";
|
|
32
|
+
export type { SessionState } from "./session";
|
|
33
|
+
export { formatRelativeTime as formatRelativeTimeFromTime } from "./format-time";
|
|
34
|
+
export type { ViewId, ModalState, WorkerStatus, WorkerInfo, TradeSide, Trade, AlertSeverity, Alert, LogLevel, LogEntry, SystemMetrics, ConnectionStatus, LogFilter, NotificationPreferences, } from "./types";
|
|
35
|
+
export type { StepId, WorkerPresetName, WorkerPreset, WorkerConfig, WorkersJsonConfig, IntegratedService, ProvisioningPlan, ProvisionResult, WizardCloudflareConfig, WizardState, StepDefinition, } from "./wizard";
|
|
36
|
+
export type { Provisioner } from "./wizard";
|
|
37
|
+
export { WizardEngine, PRESETS, WORKER_DEPENDENCIES, INTEGRATIONS, resolveDependencies, serializeState, deserializeState, WIZARD_STATE_PATH, } from "./wizard";
|
|
38
|
+
export * from "./schemas/index.js";
|
|
39
|
+
export { useUIStore } from "./stores/ui-store";
|
|
40
|
+
export { useServiceStore } from "./stores/service-store";
|
|
41
|
+
export { useConfigStore } from "./stores/config-store";
|
|
42
|
+
export type { UIState } from "./stores/ui-store";
|
|
43
|
+
export type { ServiceState } from "./stores/service-store";
|
|
44
|
+
export type { ConfigState } from "./stores/config-store";
|
|
45
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAIjB,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,yBAAyB,EACzB,iBAAiB,EACjB,iBAAi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