@hypequery/clickhouse 0.0.0-canary-20260306132943
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/LICENSE +201 -0
- package/README-CLI.md +123 -0
- package/README.md +316 -0
- package/dist/cli/bin.js +285 -0
- package/dist/cli/generate-types.d.ts +5 -0
- package/dist/cli/generate-types.js +218 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +2 -0
- package/dist/core/cache/cache-manager.d.ts +4 -0
- package/dist/core/cache/cache-manager.d.ts.map +1 -0
- package/dist/core/cache/cache-manager.js +176 -0
- package/dist/core/cache/controller.d.ts +15 -0
- package/dist/core/cache/controller.d.ts.map +1 -0
- package/dist/core/cache/controller.js +58 -0
- package/dist/core/cache/key.d.ts +11 -0
- package/dist/core/cache/key.d.ts.map +1 -0
- package/dist/core/cache/key.js +26 -0
- package/dist/core/cache/providers/memory-lru.d.ts +31 -0
- package/dist/core/cache/providers/memory-lru.d.ts.map +1 -0
- package/dist/core/cache/providers/memory-lru.js +156 -0
- package/dist/core/cache/providers/noop.d.ts +7 -0
- package/dist/core/cache/providers/noop.d.ts.map +1 -0
- package/dist/core/cache/providers/noop.js +11 -0
- package/dist/core/cache/runtime-context.d.ts +30 -0
- package/dist/core/cache/runtime-context.d.ts.map +1 -0
- package/dist/core/cache/runtime-context.js +58 -0
- package/dist/core/cache/serialization.d.ts +6 -0
- package/dist/core/cache/serialization.d.ts.map +1 -0
- package/dist/core/cache/serialization.js +166 -0
- package/dist/core/cache/types.d.ts +52 -0
- package/dist/core/cache/types.d.ts.map +1 -0
- package/dist/core/cache/types.js +1 -0
- package/dist/core/cache/utils.d.ts +9 -0
- package/dist/core/cache/utils.d.ts.map +1 -0
- package/dist/core/cache/utils.js +30 -0
- package/dist/core/connection.d.ts +112 -0
- package/dist/core/connection.d.ts.map +1 -0
- package/dist/core/connection.js +150 -0
- package/dist/core/cross-filter.d.ts +73 -0
- package/dist/core/cross-filter.d.ts.map +1 -0
- package/dist/core/cross-filter.js +142 -0
- package/dist/core/env/auto-client.browser.d.ts +3 -0
- package/dist/core/env/auto-client.browser.d.ts.map +1 -0
- package/dist/core/env/auto-client.browser.js +3 -0
- package/dist/core/env/auto-client.d.ts +9 -0
- package/dist/core/env/auto-client.d.ts.map +1 -0
- package/dist/core/env/auto-client.js +21 -0
- package/dist/core/features/aggregations.d.ts +98 -0
- package/dist/core/features/aggregations.d.ts.map +1 -0
- package/dist/core/features/aggregations.js +36 -0
- package/dist/core/features/analytics.d.ts +81 -0
- package/dist/core/features/analytics.d.ts.map +1 -0
- package/dist/core/features/analytics.js +45 -0
- package/dist/core/features/cross-filtering.d.ts +11 -0
- package/dist/core/features/cross-filtering.d.ts.map +1 -0
- package/dist/core/features/cross-filtering.js +90 -0
- package/dist/core/features/executor.d.ts +21 -0
- package/dist/core/features/executor.d.ts.map +1 -0
- package/dist/core/features/executor.js +146 -0
- package/dist/core/features/filtering.d.ts +99 -0
- package/dist/core/features/filtering.d.ts.map +1 -0
- package/dist/core/features/filtering.js +118 -0
- package/dist/core/features/joins.d.ts +26 -0
- package/dist/core/features/joins.d.ts.map +1 -0
- package/dist/core/features/joins.js +17 -0
- package/dist/core/features/query-modifiers.d.ts +116 -0
- package/dist/core/features/query-modifiers.d.ts.map +1 -0
- package/dist/core/features/query-modifiers.js +51 -0
- package/dist/core/formatters/sql-formatter.d.ts +9 -0
- package/dist/core/formatters/sql-formatter.d.ts.map +1 -0
- package/dist/core/formatters/sql-formatter.js +131 -0
- package/dist/core/join-relationships.d.ts +51 -0
- package/dist/core/join-relationships.d.ts.map +1 -0
- package/dist/core/join-relationships.js +54 -0
- package/dist/core/query-builder.d.ts +236 -0
- package/dist/core/query-builder.d.ts.map +1 -0
- package/dist/core/query-builder.js +495 -0
- package/dist/core/tests/index.d.ts +2 -0
- package/dist/core/tests/index.d.ts.map +1 -0
- package/dist/core/tests/index.js +1 -0
- package/dist/core/tests/integration/setup.d.ts +48 -0
- package/dist/core/tests/integration/setup.d.ts.map +1 -0
- package/dist/core/tests/integration/setup.js +349 -0
- package/dist/core/tests/integration/test-config.d.ts +15 -0
- package/dist/core/tests/integration/test-config.d.ts.map +1 -0
- package/dist/core/tests/integration/test-config.js +14 -0
- package/dist/core/tests/integration/test-data.json +190 -0
- package/dist/core/tests/test-utils.d.ts +44 -0
- package/dist/core/tests/test-utils.d.ts.map +1 -0
- package/dist/core/tests/test-utils.js +65 -0
- package/dist/core/types/builder-state.d.ts +27 -0
- package/dist/core/types/builder-state.d.ts.map +1 -0
- package/dist/core/types/builder-state.js +1 -0
- package/dist/core/types/select-types.d.ts +33 -0
- package/dist/core/types/select-types.d.ts.map +1 -0
- package/dist/core/types/select-types.js +1 -0
- package/dist/core/types/type-helpers.d.ts +5 -0
- package/dist/core/types/type-helpers.d.ts.map +1 -0
- package/dist/core/types/type-helpers.js +1 -0
- package/dist/core/utils/logger.d.ts +43 -0
- package/dist/core/utils/logger.d.ts.map +1 -0
- package/dist/core/utils/logger.js +104 -0
- package/dist/core/utils/predicate-builder.d.ts +33 -0
- package/dist/core/utils/predicate-builder.d.ts.map +1 -0
- package/dist/core/utils/predicate-builder.js +95 -0
- package/dist/core/utils/sql-expressions.d.ts +77 -0
- package/dist/core/utils/sql-expressions.d.ts.map +1 -0
- package/dist/core/utils/sql-expressions.js +54 -0
- package/dist/core/utils/streaming-helpers.d.ts +2 -0
- package/dist/core/utils/streaming-helpers.d.ts.map +1 -0
- package/dist/core/utils/streaming-helpers.js +137 -0
- package/dist/core/utils.d.ts +3 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/core/utils.js +29 -0
- package/dist/core/validators/filter-validator.d.ts +9 -0
- package/dist/core/validators/filter-validator.d.ts.map +1 -0
- package/dist/core/validators/filter-validator.js +19 -0
- package/dist/core/validators/value-validator.d.ts +7 -0
- package/dist/core/validators/value-validator.d.ts.map +1 -0
- package/dist/core/validators/value-validator.js +47 -0
- package/dist/formatters/index.d.ts +2 -0
- package/dist/formatters/index.d.ts.map +1 -0
- package/dist/formatters/index.js +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/types/base.d.ts +50 -0
- package/dist/types/base.d.ts.map +1 -0
- package/dist/types/base.js +1 -0
- package/dist/types/clickhouse-types.d.ts +17 -0
- package/dist/types/clickhouse-types.d.ts.map +1 -0
- package/dist/types/clickhouse-types.js +1 -0
- package/dist/types/filters.d.ts +53 -0
- package/dist/types/filters.d.ts.map +1 -0
- package/dist/types/filters.js +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/schema.d.ts +19 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/schema.js +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
const encoder = typeof TextEncoder !== 'undefined' ? new TextEncoder() : null;
|
|
2
|
+
const decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder() : null;
|
|
3
|
+
const TYPE_KEY = '__hq_type';
|
|
4
|
+
function hasBuffer() {
|
|
5
|
+
return typeof globalThis !== 'undefined' && typeof globalThis.Buffer !== 'undefined';
|
|
6
|
+
}
|
|
7
|
+
function bufferFrom(bytes) {
|
|
8
|
+
return globalThis.Buffer.from(bytes);
|
|
9
|
+
}
|
|
10
|
+
function bufferToUint8(buffer) {
|
|
11
|
+
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
12
|
+
}
|
|
13
|
+
function toBase64(bytes) {
|
|
14
|
+
if (hasBuffer()) {
|
|
15
|
+
return bufferFrom(bytes).toString('base64');
|
|
16
|
+
}
|
|
17
|
+
let binary = '';
|
|
18
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
19
|
+
binary += String.fromCharCode(bytes[i]);
|
|
20
|
+
}
|
|
21
|
+
if (typeof btoa !== 'undefined') {
|
|
22
|
+
return btoa(binary);
|
|
23
|
+
}
|
|
24
|
+
throw new Error('Base64 encoding not supported in this environment.');
|
|
25
|
+
}
|
|
26
|
+
function fromBase64(value) {
|
|
27
|
+
if (hasBuffer()) {
|
|
28
|
+
const buf = globalThis.Buffer.from(value, 'base64');
|
|
29
|
+
return bufferToUint8(buf);
|
|
30
|
+
}
|
|
31
|
+
if (typeof atob === 'undefined') {
|
|
32
|
+
throw new Error('Base64 decoding not supported in this environment.');
|
|
33
|
+
}
|
|
34
|
+
const binary = atob(value);
|
|
35
|
+
const bytes = new Uint8Array(binary.length);
|
|
36
|
+
for (let i = 0; i < binary.length; i++) {
|
|
37
|
+
bytes[i] = binary.charCodeAt(i);
|
|
38
|
+
}
|
|
39
|
+
return bytes;
|
|
40
|
+
}
|
|
41
|
+
function normalizeForStable(value) {
|
|
42
|
+
if (value === null || typeof value === 'number' || typeof value === 'boolean') {
|
|
43
|
+
return Number.isNaN(value)
|
|
44
|
+
? { [TYPE_KEY]: 'nan', value: 'NaN' }
|
|
45
|
+
: value;
|
|
46
|
+
}
|
|
47
|
+
if (typeof value === 'string') {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
if (typeof value === 'bigint') {
|
|
51
|
+
return { [TYPE_KEY]: 'bigint', value: value.toString() };
|
|
52
|
+
}
|
|
53
|
+
if (typeof value === 'undefined') {
|
|
54
|
+
return { [TYPE_KEY]: 'undefined' };
|
|
55
|
+
}
|
|
56
|
+
if (value instanceof Date) {
|
|
57
|
+
return { [TYPE_KEY]: 'date', value: value.toISOString() };
|
|
58
|
+
}
|
|
59
|
+
if (Array.isArray(value)) {
|
|
60
|
+
return value.map(item => normalizeForStable(item));
|
|
61
|
+
}
|
|
62
|
+
if (value instanceof Set) {
|
|
63
|
+
return Array.from(value.values())
|
|
64
|
+
.map(item => normalizeForStable(item))
|
|
65
|
+
.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)));
|
|
66
|
+
}
|
|
67
|
+
if (value instanceof Map) {
|
|
68
|
+
const entries = Array.from(value.entries()).sort(([a], [b]) => String(a).localeCompare(String(b)));
|
|
69
|
+
const normalized = {};
|
|
70
|
+
for (const [key, val] of entries) {
|
|
71
|
+
normalized[String(key)] = normalizeForStable(val);
|
|
72
|
+
}
|
|
73
|
+
return normalized;
|
|
74
|
+
}
|
|
75
|
+
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView(value)) {
|
|
76
|
+
const uint8 = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
77
|
+
return { [TYPE_KEY]: 'u8', value: toBase64(uint8) };
|
|
78
|
+
}
|
|
79
|
+
if (value && typeof value === 'object') {
|
|
80
|
+
const raw = value;
|
|
81
|
+
const keys = Object.keys(raw).sort();
|
|
82
|
+
const normalized = {};
|
|
83
|
+
for (const key of keys) {
|
|
84
|
+
normalized[key] = normalizeForStable(raw[key]);
|
|
85
|
+
}
|
|
86
|
+
return normalized;
|
|
87
|
+
}
|
|
88
|
+
return { [TYPE_KEY]: 'unknown', value: String(value) };
|
|
89
|
+
}
|
|
90
|
+
export function stableStringify(value) {
|
|
91
|
+
return JSON.stringify(normalizeForStable(value));
|
|
92
|
+
}
|
|
93
|
+
function encodeSpecial(value) {
|
|
94
|
+
if (typeof value === 'bigint') {
|
|
95
|
+
return { [TYPE_KEY]: 'bigint', value: value.toString() };
|
|
96
|
+
}
|
|
97
|
+
if (value instanceof Date) {
|
|
98
|
+
return { [TYPE_KEY]: 'date', value: value.toISOString() };
|
|
99
|
+
}
|
|
100
|
+
if (typeof value === 'undefined') {
|
|
101
|
+
return { [TYPE_KEY]: 'undefined' };
|
|
102
|
+
}
|
|
103
|
+
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView(value)) {
|
|
104
|
+
const uint8 = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
105
|
+
return { [TYPE_KEY]: 'u8', value: toBase64(uint8) };
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
function decodeSpecial(value) {
|
|
110
|
+
switch (value[TYPE_KEY]) {
|
|
111
|
+
case 'bigint':
|
|
112
|
+
return value.value !== undefined ? BigInt(value.value) : undefined;
|
|
113
|
+
case 'date':
|
|
114
|
+
return value.value ? new Date(value.value) : null;
|
|
115
|
+
case 'undefined':
|
|
116
|
+
return undefined;
|
|
117
|
+
case 'u8':
|
|
118
|
+
if (!value.value)
|
|
119
|
+
return new Uint8Array();
|
|
120
|
+
return fromBase64(value.value);
|
|
121
|
+
case 'nan':
|
|
122
|
+
return Number.NaN;
|
|
123
|
+
default:
|
|
124
|
+
return value.value;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function reviveSpecialValues(value) {
|
|
128
|
+
if (!value || typeof value !== 'object') {
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
if (value[TYPE_KEY]) {
|
|
132
|
+
return decodeSpecial(value);
|
|
133
|
+
}
|
|
134
|
+
if (Array.isArray(value)) {
|
|
135
|
+
return value.map(item => reviveSpecialValues(item));
|
|
136
|
+
}
|
|
137
|
+
const record = value;
|
|
138
|
+
for (const key of Object.keys(record)) {
|
|
139
|
+
record[key] = reviveSpecialValues(record[key]);
|
|
140
|
+
}
|
|
141
|
+
return record;
|
|
142
|
+
}
|
|
143
|
+
export function defaultSerialize(value) {
|
|
144
|
+
const json = JSON.stringify(value, (_key, val) => encodeSpecial(val) ?? val);
|
|
145
|
+
if (!encoder) {
|
|
146
|
+
return { payload: json, byteSize: json.length };
|
|
147
|
+
}
|
|
148
|
+
const bytes = encoder.encode(json);
|
|
149
|
+
return { payload: bytes, byteSize: bytes.byteLength };
|
|
150
|
+
}
|
|
151
|
+
export function defaultDeserialize(raw) {
|
|
152
|
+
const json = typeof raw === 'string'
|
|
153
|
+
? raw
|
|
154
|
+
: encoder && decoder
|
|
155
|
+
? decoder.decode(raw)
|
|
156
|
+
: new TextDecoder().decode(raw);
|
|
157
|
+
const parsed = JSON.parse(json);
|
|
158
|
+
return reviveSpecialValues(parsed);
|
|
159
|
+
}
|
|
160
|
+
export function estimateByteSize(value) {
|
|
161
|
+
const json = JSON.stringify(value);
|
|
162
|
+
if (!encoder) {
|
|
163
|
+
return json.length;
|
|
164
|
+
}
|
|
165
|
+
return encoder.encode(json).byteLength;
|
|
166
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export type hypequeryCacheMode = 'no-store' | 'cache-first' | 'network-first' | 'stale-while-revalidate';
|
|
2
|
+
export interface CacheSerializationResult {
|
|
3
|
+
payload: string | Uint8Array;
|
|
4
|
+
byteSize: number;
|
|
5
|
+
}
|
|
6
|
+
export type CacheSerializeFn = (value: unknown) => CacheSerializationResult | Promise<CacheSerializationResult>;
|
|
7
|
+
export type CacheDeserializeFn<T = unknown> = (raw: string | Uint8Array) => T | Promise<T>;
|
|
8
|
+
export type CacheStatus = 'hit' | 'miss' | 'stale-hit' | 'revalidate' | 'bypass';
|
|
9
|
+
export interface CacheOptions {
|
|
10
|
+
mode?: hypequeryCacheMode;
|
|
11
|
+
ttlMs?: number;
|
|
12
|
+
staleTtlMs?: number;
|
|
13
|
+
cacheTimeMs?: number;
|
|
14
|
+
staleIfError?: boolean;
|
|
15
|
+
dedupe?: boolean;
|
|
16
|
+
tags?: string[];
|
|
17
|
+
key?: string;
|
|
18
|
+
namespace?: string;
|
|
19
|
+
serialize?: CacheSerializeFn;
|
|
20
|
+
deserialize?: CacheDeserializeFn;
|
|
21
|
+
}
|
|
22
|
+
export interface CacheConfig extends CacheOptions {
|
|
23
|
+
provider?: CacheProvider;
|
|
24
|
+
versionTag?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface CacheEntry<TSerialized = string | Uint8Array> {
|
|
27
|
+
value: TSerialized;
|
|
28
|
+
createdAt: number;
|
|
29
|
+
ttlMs: number;
|
|
30
|
+
staleTtlMs: number;
|
|
31
|
+
cacheTimeMs: number;
|
|
32
|
+
tags?: string[];
|
|
33
|
+
rowCount?: number;
|
|
34
|
+
byteSize?: number;
|
|
35
|
+
sqlFingerprint?: string;
|
|
36
|
+
metadata?: Record<string, unknown>;
|
|
37
|
+
status?: 'pending' | 'fulfilled' | 'revalidating' | 'error';
|
|
38
|
+
}
|
|
39
|
+
export interface CacheProvider<TSerialized = string | Uint8Array> {
|
|
40
|
+
get(key: string): Promise<CacheEntry<TSerialized> | null>;
|
|
41
|
+
set(key: string, entry: CacheEntry<TSerialized>): Promise<void>;
|
|
42
|
+
delete(key: string): Promise<void>;
|
|
43
|
+
deleteByTag?(namespace: string, tag: string): Promise<void>;
|
|
44
|
+
clearNamespace?(namespace: string): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
export interface CacheStats {
|
|
47
|
+
hits: number;
|
|
48
|
+
misses: number;
|
|
49
|
+
staleHits: number;
|
|
50
|
+
revalidations: number;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/cache/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAC1B,UAAU,GACV,aAAa,GACb,eAAe,GACf,wBAAwB,CAAC;AAE7B,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAChH,MAAM,MAAM,kBAAkB,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE3F,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,WAAW,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEjF,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC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AW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,WAAW,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,cAAc,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CacheConfig, CacheOptions } from './types.js';
|
|
2
|
+
import type { QueryRuntimeContext } from './runtime-context.js';
|
|
3
|
+
import { CacheController } from './controller.js';
|
|
4
|
+
export declare function mergeCacheOptionsPartial(target: CacheOptions | undefined, update: CacheOptions): CacheOptions;
|
|
5
|
+
export declare function initializeCacheRuntime(cacheConfig: CacheConfig | undefined, namespace: string): {
|
|
6
|
+
runtime: QueryRuntimeContext;
|
|
7
|
+
cacheController: CacheController;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/cache/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIlD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,YAAY,CAgB7G;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,WAAW,GAAG,SAAS,EACpC,SAAS,EAAE,MAAM,GAChB;IAAE,OAAO,EAAE,mBAAmB,CAAC;IAAC,eAAe,EAAE,eAAe,CAAA;CAAE,CASpE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CacheController } from './controller.js';
|
|
2
|
+
import { buildRuntimeContext, resolveCacheConfig } from './runtime-context.js';
|
|
3
|
+
import { MemoryCacheProvider } from './providers/memory-lru.js';
|
|
4
|
+
export function mergeCacheOptionsPartial(target, update) {
|
|
5
|
+
const result = { ...(target || {}) };
|
|
6
|
+
for (const [key, value] of Object.entries(update)) {
|
|
7
|
+
if (key === 'tags') {
|
|
8
|
+
const existing = result.tags || [];
|
|
9
|
+
const incoming = value || [];
|
|
10
|
+
if (incoming.length) {
|
|
11
|
+
result.tags = Array.from(new Set([...existing, ...incoming]));
|
|
12
|
+
}
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (value !== undefined) {
|
|
16
|
+
result[key] = value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
export function initializeCacheRuntime(cacheConfig, namespace) {
|
|
22
|
+
const provider = cacheConfig?.provider ?? (cacheConfig ? new MemoryCacheProvider() : undefined);
|
|
23
|
+
const mergedCacheConfig = cacheConfig
|
|
24
|
+
? { ...cacheConfig, namespace, provider }
|
|
25
|
+
: { namespace, provider };
|
|
26
|
+
const runtimeConfig = resolveCacheConfig(mergedCacheConfig, namespace);
|
|
27
|
+
const runtime = buildRuntimeContext(runtimeConfig);
|
|
28
|
+
const cacheController = new CacheController(runtime);
|
|
29
|
+
return { runtime, cacheController };
|
|
30
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { ClickHouseSettings } from '@clickhouse/client-common';
|
|
2
|
+
import type { ClickHouseClient as NodeClickHouseClient } from '@clickhouse/client';
|
|
3
|
+
import type { ClickHouseClient as WebClickHouseClient } from '@clickhouse/client-web';
|
|
4
|
+
import type { ClickHouseConfig } from './query-builder.js';
|
|
5
|
+
type ClickHouseClient = NodeClickHouseClient | WebClickHouseClient;
|
|
6
|
+
/**
|
|
7
|
+
* The main entry point for connecting to a ClickHouse database.
|
|
8
|
+
* Provides static methods to initialize the connection and retrieve the client.
|
|
9
|
+
*
|
|
10
|
+
* Supports two modes of operation:
|
|
11
|
+
* 1. **Manual injection**: Provide a client instance via `config.client` (required for browser environments)
|
|
12
|
+
* 2. **Auto-detection**: Automatically uses @clickhouse/client for Node.js environments
|
|
13
|
+
*
|
|
14
|
+
* @category Core
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Method 1: Manual injection (required for browser environments)
|
|
18
|
+
* import { createClient } from '@clickhouse/client-web';
|
|
19
|
+
* const client = createClient({
|
|
20
|
+
* host: 'http://localhost:8123',
|
|
21
|
+
* username: 'default',
|
|
22
|
+
* password: 'password'
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* ClickHouseConnection.initialize({
|
|
26
|
+
* host: 'http://localhost:8123',
|
|
27
|
+
* database: 'my_database',
|
|
28
|
+
* client // Explicitly provide the client
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Method 2: Auto-detection (Node.js environments only)
|
|
32
|
+
* ClickHouseConnection.initialize({
|
|
33
|
+
* host: 'http://localhost:8123',
|
|
34
|
+
* username: 'default',
|
|
35
|
+
* password: 'password',
|
|
36
|
+
* database: 'my_database'
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // Get the client to execute queries directly
|
|
40
|
+
* const client = ClickHouseConnection.getClient();
|
|
41
|
+
* const result = await client.query({
|
|
42
|
+
* query: 'SELECT * FROM my_table',
|
|
43
|
+
* format: 'JSONEachRow'
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @note This library requires one of the following peer dependencies:
|
|
48
|
+
* - @clickhouse/client (for Node.js environments)
|
|
49
|
+
* - @clickhouse/client-web (for browser environments)
|
|
50
|
+
*
|
|
51
|
+
* **Important**: Browser environments require manual injection because `require()` calls don't work in browsers.
|
|
52
|
+
*/
|
|
53
|
+
export declare class ClickHouseConnection {
|
|
54
|
+
private static instance;
|
|
55
|
+
private static clientModule;
|
|
56
|
+
/**
|
|
57
|
+
* Initializes the ClickHouse connection with the provided configuration.
|
|
58
|
+
* This method must be called before any queries can be executed.
|
|
59
|
+
*
|
|
60
|
+
* **Priority order:**
|
|
61
|
+
* 1. If `config.client` is provided, use it directly (manual injection)
|
|
62
|
+
* 2. Otherwise, auto-detect @clickhouse/client for Node.js environments
|
|
63
|
+
*
|
|
64
|
+
* **Note**: Browser environments require manual injection because `require()` calls don't work in browsers.
|
|
65
|
+
*
|
|
66
|
+
* @param config - The connection configuration options
|
|
67
|
+
* @returns The ClickHouseConnection class for method chaining
|
|
68
|
+
* @throws Will throw an error if no ClickHouse client is available
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* // Manual injection (required for browser environments)
|
|
73
|
+
* import { createClient } from '@clickhouse/client-web';
|
|
74
|
+
* const client = createClient({ host: 'http://localhost:8123' });
|
|
75
|
+
* ClickHouseConnection.initialize({ host: 'http://localhost:8123', client });
|
|
76
|
+
*
|
|
77
|
+
* // Auto-detection (Node.js environments only)
|
|
78
|
+
* ClickHouseConnection.initialize({
|
|
79
|
+
* host: 'http://localhost:8123',
|
|
80
|
+
* username: 'default',
|
|
81
|
+
* password: 'password',
|
|
82
|
+
* database: 'my_database'
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
static initialize(config: ClickHouseConfig): typeof ClickHouseConnection;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves the ClickHouse client instance for direct query execution.
|
|
89
|
+
*
|
|
90
|
+
* @returns The ClickHouse client instance
|
|
91
|
+
* @throws Will throw an error if the connection has not been initialized
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const client = ClickHouseConnection.getClient();
|
|
96
|
+
* const result = await client.query({
|
|
97
|
+
* query: 'SELECT * FROM my_table',
|
|
98
|
+
* format: 'JSONEachRow'
|
|
99
|
+
* });
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
static getClient(): ClickHouseClient;
|
|
103
|
+
/**
|
|
104
|
+
* Gets the ClickHouseSettings type from the loaded client module.
|
|
105
|
+
* Only available when using auto-detection (not manual injection).
|
|
106
|
+
*
|
|
107
|
+
* @returns The ClickHouseSettings type or an empty object if not available
|
|
108
|
+
*/
|
|
109
|
+
static getClickHouseSettings(): ClickHouseSettings;
|
|
110
|
+
}
|
|
111
|
+
export {};
|
|
112
|
+
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/core/connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,KAAK,EAAE,gBAAgB,IAAI,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAM3D,KAAK,gBAAgB,GAAG,oBAAoB,GAAG,mBAAmB,CAAC;AAsCnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiC;IACxD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAuC;IAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,oBAAoB;IAaxE;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,SAAS,IAAI,gBAAgB;IAOpC;;;;;OAKG;IACH,MAAM,CAAC,qBAAqB,IAAI,kBAAkB;CAGnD"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { isClientConfig } from './query-builder.js';
|
|
2
|
+
import { getAutoClientModule } from './env/auto-client.js';
|
|
3
|
+
// Function to synchronously get the appropriate client
|
|
4
|
+
function getClickHouseClientSync() {
|
|
5
|
+
const isDev = process.env.NODE_ENV === 'development';
|
|
6
|
+
const isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
|
|
7
|
+
// In Node.js environment, use Node.js client only
|
|
8
|
+
if (isNode) {
|
|
9
|
+
if (isDev) {
|
|
10
|
+
console.log('hypequery: Using @clickhouse/client for Node.js environment');
|
|
11
|
+
}
|
|
12
|
+
const clientModule = getAutoClientModule();
|
|
13
|
+
return {
|
|
14
|
+
createClient: clientModule.createClient,
|
|
15
|
+
ClickHouseSettings: clientModule.ClickHouseSettings || {}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
// For browser environments, require() doesn't work, so we can't auto-detect
|
|
19
|
+
// Users must use manual injection in browser environments
|
|
20
|
+
throw new Error('Unable to auto-detect ClickHouse client in browser environment. ' +
|
|
21
|
+
'Please use manual injection by providing a client instance:\n\n' +
|
|
22
|
+
'```typescript\n' +
|
|
23
|
+
'import { createClient } from \'@clickhouse/client-web\';\n' +
|
|
24
|
+
'const client = createClient({ host: \'http://localhost:8123\' });\n' +
|
|
25
|
+
'ClickHouseConnection.initialize({ host: \'http://localhost:8123\', client });\n' +
|
|
26
|
+
'```\n\n' +
|
|
27
|
+
'This is required because browser environments cannot use require() to load modules.');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The main entry point for connecting to a ClickHouse database.
|
|
31
|
+
* Provides static methods to initialize the connection and retrieve the client.
|
|
32
|
+
*
|
|
33
|
+
* Supports two modes of operation:
|
|
34
|
+
* 1. **Manual injection**: Provide a client instance via `config.client` (required for browser environments)
|
|
35
|
+
* 2. **Auto-detection**: Automatically uses @clickhouse/client for Node.js environments
|
|
36
|
+
*
|
|
37
|
+
* @category Core
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* // Method 1: Manual injection (required for browser environments)
|
|
41
|
+
* import { createClient } from '@clickhouse/client-web';
|
|
42
|
+
* const client = createClient({
|
|
43
|
+
* host: 'http://localhost:8123',
|
|
44
|
+
* username: 'default',
|
|
45
|
+
* password: 'password'
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* ClickHouseConnection.initialize({
|
|
49
|
+
* host: 'http://localhost:8123',
|
|
50
|
+
* database: 'my_database',
|
|
51
|
+
* client // Explicitly provide the client
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* // Method 2: Auto-detection (Node.js environments only)
|
|
55
|
+
* ClickHouseConnection.initialize({
|
|
56
|
+
* host: 'http://localhost:8123',
|
|
57
|
+
* username: 'default',
|
|
58
|
+
* password: 'password',
|
|
59
|
+
* database: 'my_database'
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* // Get the client to execute queries directly
|
|
63
|
+
* const client = ClickHouseConnection.getClient();
|
|
64
|
+
* const result = await client.query({
|
|
65
|
+
* query: 'SELECT * FROM my_table',
|
|
66
|
+
* format: 'JSONEachRow'
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @note This library requires one of the following peer dependencies:
|
|
71
|
+
* - @clickhouse/client (for Node.js environments)
|
|
72
|
+
* - @clickhouse/client-web (for browser environments)
|
|
73
|
+
*
|
|
74
|
+
* **Important**: Browser environments require manual injection because `require()` calls don't work in browsers.
|
|
75
|
+
*/
|
|
76
|
+
export class ClickHouseConnection {
|
|
77
|
+
static instance = null;
|
|
78
|
+
static clientModule = null;
|
|
79
|
+
/**
|
|
80
|
+
* Initializes the ClickHouse connection with the provided configuration.
|
|
81
|
+
* This method must be called before any queries can be executed.
|
|
82
|
+
*
|
|
83
|
+
* **Priority order:**
|
|
84
|
+
* 1. If `config.client` is provided, use it directly (manual injection)
|
|
85
|
+
* 2. Otherwise, auto-detect @clickhouse/client for Node.js environments
|
|
86
|
+
*
|
|
87
|
+
* **Note**: Browser environments require manual injection because `require()` calls don't work in browsers.
|
|
88
|
+
*
|
|
89
|
+
* @param config - The connection configuration options
|
|
90
|
+
* @returns The ClickHouseConnection class for method chaining
|
|
91
|
+
* @throws Will throw an error if no ClickHouse client is available
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* // Manual injection (required for browser environments)
|
|
96
|
+
* import { createClient } from '@clickhouse/client-web';
|
|
97
|
+
* const client = createClient({ host: 'http://localhost:8123' });
|
|
98
|
+
* ClickHouseConnection.initialize({ host: 'http://localhost:8123', client });
|
|
99
|
+
*
|
|
100
|
+
* // Auto-detection (Node.js environments only)
|
|
101
|
+
* ClickHouseConnection.initialize({
|
|
102
|
+
* host: 'http://localhost:8123',
|
|
103
|
+
* username: 'default',
|
|
104
|
+
* password: 'password',
|
|
105
|
+
* database: 'my_database'
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
static initialize(config) {
|
|
110
|
+
// If a client is explicitly provided, use it directly
|
|
111
|
+
if (isClientConfig(config)) {
|
|
112
|
+
this.instance = config.client;
|
|
113
|
+
return ClickHouseConnection;
|
|
114
|
+
}
|
|
115
|
+
// Otherwise, auto-detect the client (we know we have a host-based config)
|
|
116
|
+
this.clientModule = getClickHouseClientSync();
|
|
117
|
+
this.instance = this.clientModule.createClient(config);
|
|
118
|
+
return ClickHouseConnection;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Retrieves the ClickHouse client instance for direct query execution.
|
|
122
|
+
*
|
|
123
|
+
* @returns The ClickHouse client instance
|
|
124
|
+
* @throws Will throw an error if the connection has not been initialized
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const client = ClickHouseConnection.getClient();
|
|
129
|
+
* const result = await client.query({
|
|
130
|
+
* query: 'SELECT * FROM my_table',
|
|
131
|
+
* format: 'JSONEachRow'
|
|
132
|
+
* });
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
static getClient() {
|
|
136
|
+
if (!this.instance) {
|
|
137
|
+
throw new Error('ClickHouse connection not initialized. Call ClickHouseConnection.initialize() first.');
|
|
138
|
+
}
|
|
139
|
+
return this.instance;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Gets the ClickHouseSettings type from the loaded client module.
|
|
143
|
+
* Only available when using auto-detection (not manual injection).
|
|
144
|
+
*
|
|
145
|
+
* @returns The ClickHouseSettings type or an empty object if not available
|
|
146
|
+
*/
|
|
147
|
+
static getClickHouseSettings() {
|
|
148
|
+
return this.clientModule?.ClickHouseSettings || {};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { FilterConditionInput, FilterOperator, OperatorValueMap } from '../types/index.js';
|
|
2
|
+
import type { ColumnType, InferColumnType } from '../types/schema.js';
|
|
3
|
+
import type { SchemaDefinition } from './types/builder-state.js';
|
|
4
|
+
type GenericSchema = Record<string, Record<string, ColumnType>>;
|
|
5
|
+
type GenericSchemaDefinition = SchemaDefinition<GenericSchema>;
|
|
6
|
+
export interface FilterGroup<Schema extends SchemaDefinition<Schema> = GenericSchemaDefinition, OriginalT extends Record<string, any> = Record<string, any>> {
|
|
7
|
+
operator: 'AND' | 'OR';
|
|
8
|
+
conditions: Array<FilterConditionInput<any, Schema, OriginalT> | FilterGroup<Schema, OriginalT>>;
|
|
9
|
+
limit?: number;
|
|
10
|
+
orderBy?: {
|
|
11
|
+
column: keyof OriginalT;
|
|
12
|
+
direction: 'ASC' | 'DESC';
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A type-safe filter builder supporting both simple conditions and complex nested groups.
|
|
17
|
+
* @template Schema - The full database schema type
|
|
18
|
+
* @template TableName - The specific table being filtered
|
|
19
|
+
*/
|
|
20
|
+
export declare class CrossFilter<Schema extends SchemaDefinition<Schema> = GenericSchemaDefinition, TableName extends keyof Schema & string = Extract<keyof Schema, string>> {
|
|
21
|
+
private rootGroup;
|
|
22
|
+
private schema?;
|
|
23
|
+
private targetTable?;
|
|
24
|
+
constructor();
|
|
25
|
+
constructor(schema: Schema);
|
|
26
|
+
constructor(schema: Schema, tableName: TableName);
|
|
27
|
+
/**
|
|
28
|
+
* Adds a single filter condition to the root group with an implicit AND conjunction.
|
|
29
|
+
* Performs type-safe validation if a schema is provided.
|
|
30
|
+
*/
|
|
31
|
+
add<ColumnName extends Extract<keyof Schema[TableName], string>, Op extends FilterOperator>(condition: FilterConditionInput<OperatorValueMap<InferColumnType<Schema[TableName][ColumnName]>>[Op], Schema, Schema[TableName]>): this;
|
|
32
|
+
/**
|
|
33
|
+
* Adds multiple filter conditions to the root group.
|
|
34
|
+
*/
|
|
35
|
+
addMultiple(conditions: Array<FilterConditionInput<any, Schema, Schema[TableName]>>): this;
|
|
36
|
+
/**
|
|
37
|
+
* Adds a nested group of filter conditions to the root group using the specified logical operator.
|
|
38
|
+
* @param groupConditions - Array of filter conditions or nested groups to be grouped together.
|
|
39
|
+
* @param operator - Logical operator ('AND' or 'OR') to combine the conditions in the group.
|
|
40
|
+
*/
|
|
41
|
+
addGroup(groupConditions: Array<FilterConditionInput<any, Schema, Schema[TableName]> | FilterGroup<Schema, Schema[TableName]>>, operator: 'AND' | 'OR'): this;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the current filter tree representing all conditions and groups.
|
|
44
|
+
*/
|
|
45
|
+
getConditions(): FilterGroup<Schema, Schema[TableName]>;
|
|
46
|
+
/**
|
|
47
|
+
* Looks up a column's type from the schema.
|
|
48
|
+
* Defaults to 'String' if no schema is provided.
|
|
49
|
+
* @param column - The column name as a string.
|
|
50
|
+
*/
|
|
51
|
+
private getColumnType;
|
|
52
|
+
/**
|
|
53
|
+
* Validates the value of a filter condition against its expected column type.
|
|
54
|
+
*/
|
|
55
|
+
private validateValueType;
|
|
56
|
+
/**
|
|
57
|
+
* Recursively validates an array of filter conditions and nested groups.
|
|
58
|
+
*/
|
|
59
|
+
private validateGroup;
|
|
60
|
+
/**
|
|
61
|
+
* Type guard to check if an item is a FilterGroup.
|
|
62
|
+
*/
|
|
63
|
+
private isGroup;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a filter for top N records by a value column
|
|
66
|
+
* @param valueColumn - The column to filter and order by
|
|
67
|
+
* @param n - Number of records to return
|
|
68
|
+
* @param orderBy - Sort direction, defaults to 'desc'
|
|
69
|
+
*/
|
|
70
|
+
topN<K extends keyof Schema[TableName]>(valueColumn: K, n: number, orderBy?: 'desc' | 'asc'): this;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=cross-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cross-filter.d.ts","sourceRoot":"","sources":["../../src/core/cross-filter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAChE,KAAK,uBAAuB,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;AAG/D,MAAM,WAAW,WAAW,CAC1B,MAAM,SAAS,gBAAgB,CAAC,MAAM,CAAC,GAAG,uBAAuB,EACjE,SAAS,SAAS,MAAM,CAAC,MAAM,EA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