@514labs/moose-lib 0.6.527 → 0.6.528
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browserCompatible.d.mts +2 -2
- package/dist/browserCompatible.d.ts +2 -2
- package/dist/browserCompatible.js +393 -2
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +389 -2
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/compilerPlugin.js +2 -1
- package/dist/compilerPlugin.js.map +1 -1
- package/dist/compilerPlugin.mjs +2 -1
- package/dist/compilerPlugin.mjs.map +1 -1
- package/dist/dmv2/index.d.mts +2 -2
- package/dist/dmv2/index.d.ts +2 -2
- package/dist/dmv2/index.js +393 -2
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +389 -2
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-k_kpRxE3.d.mts → index-BTIlwBBZ.d.mts} +13 -2
- package/dist/{index-7uxZbwmY.d.ts → index-w7pvlv3c.d.ts} +13 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +394 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +390 -2
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +36 -3
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +36 -3
- package/dist/moose-runner.mjs.map +1 -1
- package/dist/{view-BCWJcLF6.d.mts → query-client-6YrlC3Df.d.mts} +420 -80
- package/dist/{view-BCWJcLF6.d.ts → query-client-6YrlC3Df.d.ts} +420 -80
- package/dist/testing/index.d.mts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +10 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/index.mjs +10 -1
- package/dist/testing/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,421 @@ import { IJsonSchemaCollection, tags } from 'typia';
|
|
|
3
3
|
import { Pattern, TagBase } from 'typia/lib/tags';
|
|
4
4
|
import { Readable } from 'node:stream';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Configuration options for creating a View.
|
|
8
|
+
*/
|
|
9
|
+
interface ViewConfig {
|
|
10
|
+
/** The SQL SELECT statement or Sql object defining the view's logic. */
|
|
11
|
+
selectStatement: string | Sql;
|
|
12
|
+
/** Source tables/views the SELECT reads from. Used for dependency tracking during migrations. */
|
|
13
|
+
baseTables: (OlapTable<any> | View)[];
|
|
14
|
+
/** Optional database where the view is created. When set, the view is created as `database`.`name` in ClickHouse. */
|
|
15
|
+
database?: string;
|
|
16
|
+
/** Optional metadata for the view (e.g., description, source file). */
|
|
17
|
+
metadata?: {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
|
|
23
|
+
* Emits structured data for the Moose infrastructure system.
|
|
24
|
+
*/
|
|
25
|
+
declare class View {
|
|
26
|
+
/** @internal */
|
|
27
|
+
readonly kind = "View";
|
|
28
|
+
/** The name of the view */
|
|
29
|
+
name: string;
|
|
30
|
+
/** Optional database where the view is created. When set, the view is created as `database`.`name` in ClickHouse. */
|
|
31
|
+
database?: string;
|
|
32
|
+
/** The SELECT SQL statement that defines the view */
|
|
33
|
+
selectSql: string;
|
|
34
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
35
|
+
sourceTables: string[];
|
|
36
|
+
/** Optional metadata for the view */
|
|
37
|
+
metadata: {
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new View instance.
|
|
42
|
+
* @param name The name of the view to be created.
|
|
43
|
+
* @param config Configuration for the view: select statement, base tables, optional database, and optional metadata.
|
|
44
|
+
*/
|
|
45
|
+
constructor(name: string, config: ViewConfig);
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Use the config-object overload: `new View(name, { selectStatement, baseTables, metadata? })`.
|
|
48
|
+
*/
|
|
49
|
+
constructor(name: string, selectStatement: string | Sql, baseTables: (OlapTable<any> | View)[], metadata?: {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Defines how Moose manages the lifecycle of database resources when your code changes.
|
|
56
|
+
*
|
|
57
|
+
* This enum controls the behavior when there are differences between your code definitions
|
|
58
|
+
* and the actual database schema or structure.
|
|
59
|
+
*/
|
|
60
|
+
declare enum LifeCycle {
|
|
61
|
+
/**
|
|
62
|
+
* Full automatic management (default behavior).
|
|
63
|
+
* Moose will automatically modify database resources to match your code definitions,
|
|
64
|
+
* including potentially destructive operations like dropping columns or tables.
|
|
65
|
+
*/
|
|
66
|
+
FULLY_MANAGED = "FULLY_MANAGED",
|
|
67
|
+
/**
|
|
68
|
+
* Deletion-protected automatic management.
|
|
69
|
+
* Moose will modify resources to match your code but will avoid destructive actions
|
|
70
|
+
* such as dropping columns, or tables. Only additive changes are applied.
|
|
71
|
+
*/
|
|
72
|
+
DELETION_PROTECTED = "DELETION_PROTECTED",
|
|
73
|
+
/**
|
|
74
|
+
* External management - no automatic changes.
|
|
75
|
+
* Moose will not modify the database resources. You are responsible for managing
|
|
76
|
+
* the schema and ensuring it matches your code definitions manually.
|
|
77
|
+
*/
|
|
78
|
+
EXTERNALLY_MANAGED = "EXTERNALLY_MANAGED"
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Per-column attribute configuration for dictionary attributes.
|
|
83
|
+
* The column name and ClickHouse type are inferred from the TypeScript generic T.
|
|
84
|
+
* This object carries optional ClickHouse dictionary attribute flags.
|
|
85
|
+
*/
|
|
86
|
+
interface DictionaryColumnConfig {
|
|
87
|
+
/** DEFAULT expression — fallback value when key is not found */
|
|
88
|
+
defaultValue?: string;
|
|
89
|
+
/** EXPRESSION attribute — computed from other columns */
|
|
90
|
+
expression?: string;
|
|
91
|
+
/** IS_INJECTIVE — enables GROUP BY optimization (one-to-one mapping) */
|
|
92
|
+
isInjective?: boolean;
|
|
93
|
+
/** IS_HIERARCHICAL — enables hierarchical parent-child lookups */
|
|
94
|
+
isHierarchical?: boolean;
|
|
95
|
+
/** IS_OBJECT_ID — MongoDB-specific attribute */
|
|
96
|
+
isObjectId?: boolean;
|
|
97
|
+
/** Optional column comment */
|
|
98
|
+
comment?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* ClickHouse dictionary layout types.
|
|
102
|
+
* All 16 layout variants with their per-layout parameters.
|
|
103
|
+
* The `type` field uses SCREAMING_SNAKE_CASE to match Rust serde.
|
|
104
|
+
*/
|
|
105
|
+
type DictionaryLayout = {
|
|
106
|
+
type: "FLAT";
|
|
107
|
+
} | {
|
|
108
|
+
type: "HASHED";
|
|
109
|
+
initialArraySize?: number;
|
|
110
|
+
maxLoadFactor?: number;
|
|
111
|
+
} | {
|
|
112
|
+
type: "SPARSE_HASHED";
|
|
113
|
+
initialArraySize?: number;
|
|
114
|
+
maxLoadFactor?: number;
|
|
115
|
+
} | {
|
|
116
|
+
type: "HASHED_ARRAY";
|
|
117
|
+
shards?: number;
|
|
118
|
+
} | {
|
|
119
|
+
type: "RANGE_HASHED";
|
|
120
|
+
rangeLookupStrategy?: string;
|
|
121
|
+
} | {
|
|
122
|
+
type: "CACHE";
|
|
123
|
+
sizeInCells: number;
|
|
124
|
+
maxThreadsForUpdates?: number;
|
|
125
|
+
} | {
|
|
126
|
+
type: "SSD_CACHE";
|
|
127
|
+
path: string;
|
|
128
|
+
blockSize?: number;
|
|
129
|
+
fileSize?: number;
|
|
130
|
+
readBufferSize?: number;
|
|
131
|
+
writeBufferSize?: number;
|
|
132
|
+
maxStoredKeys?: number;
|
|
133
|
+
} | {
|
|
134
|
+
type: "DIRECT";
|
|
135
|
+
} | {
|
|
136
|
+
type: "IP_TRIE";
|
|
137
|
+
accessToKeyFromAttributes?: boolean;
|
|
138
|
+
} | {
|
|
139
|
+
type: "COMPLEX_KEY_HASHED";
|
|
140
|
+
initialArraySize?: number;
|
|
141
|
+
maxLoadFactor?: number;
|
|
142
|
+
} | {
|
|
143
|
+
type: "COMPLEX_KEY_SPARSE_HASHED";
|
|
144
|
+
initialArraySize?: number;
|
|
145
|
+
maxLoadFactor?: number;
|
|
146
|
+
} | {
|
|
147
|
+
type: "COMPLEX_KEY_HASHED_ARRAY";
|
|
148
|
+
shards?: number;
|
|
149
|
+
} | {
|
|
150
|
+
type: "COMPLEX_KEY_CACHE";
|
|
151
|
+
sizeInCells: number;
|
|
152
|
+
maxThreadsForUpdates?: number;
|
|
153
|
+
} | {
|
|
154
|
+
type: "COMPLEX_KEY_SSD_CACHE";
|
|
155
|
+
path: string;
|
|
156
|
+
blockSize?: number;
|
|
157
|
+
fileSize?: number;
|
|
158
|
+
readBufferSize?: number;
|
|
159
|
+
writeBufferSize?: number;
|
|
160
|
+
maxStoredKeys?: number;
|
|
161
|
+
} | {
|
|
162
|
+
type: "COMPLEX_KEY_DIRECT";
|
|
163
|
+
};
|
|
164
|
+
/** Set of COMPLEX_KEY_* layouts that accept any-type keys (string, composite, etc.) and support one or more primary key columns */
|
|
165
|
+
declare const COMPLEX_KEY_LAYOUTS: Set<"FLAT" | "HASHED" | "SPARSE_HASHED" | "HASHED_ARRAY" | "RANGE_HASHED" | "CACHE" | "SSD_CACHE" | "DIRECT" | "IP_TRIE" | "COMPLEX_KEY_HASHED" | "COMPLEX_KEY_SPARSE_HASHED" | "COMPLEX_KEY_HASHED_ARRAY" | "COMPLEX_KEY_CACHE" | "COMPLEX_KEY_SSD_CACHE" | "COMPLEX_KEY_DIRECT">;
|
|
166
|
+
/**
|
|
167
|
+
* Dictionary lifetime configuration.
|
|
168
|
+
* - `0` → LIFETIME(0) — static, never reloads
|
|
169
|
+
* - `N` (positive number) → LIFETIME(N) — reload every N seconds
|
|
170
|
+
* - `{ min: N, max: M }` → LIFETIME(MIN N MAX M) — reload with jitter
|
|
171
|
+
*/
|
|
172
|
+
type DictionaryLifetime = number | {
|
|
173
|
+
min: number;
|
|
174
|
+
max: number;
|
|
175
|
+
};
|
|
176
|
+
/** HTTP endpoint source */
|
|
177
|
+
interface HttpExternalSource {
|
|
178
|
+
type: "http";
|
|
179
|
+
url: string;
|
|
180
|
+
format: string;
|
|
181
|
+
method?: string;
|
|
182
|
+
whereClause?: string;
|
|
183
|
+
}
|
|
184
|
+
/** Remote ClickHouse server source */
|
|
185
|
+
interface ClickHouseExternalSource {
|
|
186
|
+
type: "clickhouse";
|
|
187
|
+
host: string;
|
|
188
|
+
port: number;
|
|
189
|
+
user: string;
|
|
190
|
+
password: string;
|
|
191
|
+
db: string;
|
|
192
|
+
table: string;
|
|
193
|
+
query?: string;
|
|
194
|
+
whereClause?: string;
|
|
195
|
+
invalidateQuery?: string;
|
|
196
|
+
}
|
|
197
|
+
/** MySQL database source */
|
|
198
|
+
interface MysqlExternalSource {
|
|
199
|
+
type: "mysql";
|
|
200
|
+
host: string;
|
|
201
|
+
port: number;
|
|
202
|
+
user: string;
|
|
203
|
+
password: string;
|
|
204
|
+
db: string;
|
|
205
|
+
table: string;
|
|
206
|
+
query?: string;
|
|
207
|
+
whereClause?: string;
|
|
208
|
+
invalidateQuery?: string;
|
|
209
|
+
}
|
|
210
|
+
/** PostgreSQL database source */
|
|
211
|
+
interface PostgresqlExternalSource {
|
|
212
|
+
type: "postgresql";
|
|
213
|
+
host: string;
|
|
214
|
+
port: number;
|
|
215
|
+
user: string;
|
|
216
|
+
password: string;
|
|
217
|
+
db: string;
|
|
218
|
+
table: string;
|
|
219
|
+
query?: string;
|
|
220
|
+
whereClause?: string;
|
|
221
|
+
invalidateQuery?: string;
|
|
222
|
+
}
|
|
223
|
+
/** Redis source */
|
|
224
|
+
interface RedisExternalSource {
|
|
225
|
+
type: "redis";
|
|
226
|
+
host: string;
|
|
227
|
+
port: number;
|
|
228
|
+
password?: string;
|
|
229
|
+
dbIndex?: number;
|
|
230
|
+
/** Storage type: "simple", "hash", "range_hashed", etc. */
|
|
231
|
+
storageType: string;
|
|
232
|
+
}
|
|
233
|
+
/** MongoDB collection source */
|
|
234
|
+
interface MongodbExternalSource {
|
|
235
|
+
type: "mongodb";
|
|
236
|
+
host: string;
|
|
237
|
+
port: number;
|
|
238
|
+
user: string;
|
|
239
|
+
password: string;
|
|
240
|
+
db: string;
|
|
241
|
+
collection: string;
|
|
242
|
+
}
|
|
243
|
+
/** External executable process source */
|
|
244
|
+
interface ExecutableExternalSource {
|
|
245
|
+
type: "executable";
|
|
246
|
+
command: string;
|
|
247
|
+
format: string;
|
|
248
|
+
implicitKey?: boolean;
|
|
249
|
+
}
|
|
250
|
+
/** S3 object storage source */
|
|
251
|
+
interface S3ExternalSource {
|
|
252
|
+
type: "s3";
|
|
253
|
+
url: string;
|
|
254
|
+
format: string;
|
|
255
|
+
accessKeyId?: string;
|
|
256
|
+
secretAccessKey?: string;
|
|
257
|
+
}
|
|
258
|
+
/** Union of all supported external source types */
|
|
259
|
+
type ExternalSource = HttpExternalSource | ClickHouseExternalSource | MysqlExternalSource | PostgresqlExternalSource | RedisExternalSource | MongodbExternalSource | ExecutableExternalSource | S3ExternalSource;
|
|
260
|
+
/**
|
|
261
|
+
* Configuration for creating an OlapDictionary.
|
|
262
|
+
*
|
|
263
|
+
* Exactly ONE of `sourceTable`, `sourceQuery`, or `externalSource` must be set.
|
|
264
|
+
*/
|
|
265
|
+
interface OlapDictionaryConfig<T> {
|
|
266
|
+
/**
|
|
267
|
+
* Read from a local ClickHouse table managed by Moose.
|
|
268
|
+
* Moose automatically tracks this as a dependency.
|
|
269
|
+
*/
|
|
270
|
+
sourceTable?: OlapTable<any> | View;
|
|
271
|
+
/**
|
|
272
|
+
* Read from an arbitrary SQL query on the local ClickHouse.
|
|
273
|
+
* Requires `sourceTables` to be set for dependency tracking.
|
|
274
|
+
* Use the `sql` template tag: `sql\`SELECT ...\``
|
|
275
|
+
*/
|
|
276
|
+
sourceQuery?: Sql;
|
|
277
|
+
/**
|
|
278
|
+
* The tables referenced in `sourceQuery`.
|
|
279
|
+
* Required when `sourceQuery` is set to enable dependency tracking.
|
|
280
|
+
*/
|
|
281
|
+
sourceTables?: (OlapTable<any> | View)[];
|
|
282
|
+
/**
|
|
283
|
+
* Read from an external data source (HTTP, MySQL, PostgreSQL, Redis, etc.).
|
|
284
|
+
* Use `mooseRuntimeEnv.get()` for credentials — never hardcode secrets.
|
|
285
|
+
*/
|
|
286
|
+
externalSource?: ExternalSource;
|
|
287
|
+
/** Primary key column names. Use a single column for simple layouts (FLAT, HASHED, CACHE, DIRECT, IP_TRIE, RANGE_HASHED) and multiple columns for COMPLEX_KEY_* layouts. */
|
|
288
|
+
primaryKey: (keyof T & string)[];
|
|
289
|
+
/** Per-column attribute overrides (DEFAULT, EXPRESSION, INJECTIVE, HIERARCHICAL, IS_OBJECT_ID). Column names and types are inferred from T. */
|
|
290
|
+
columns?: Partial<Record<keyof T & string, DictionaryColumnConfig>>;
|
|
291
|
+
/** Dictionary memory layout. Controls in-memory data structure and lookup performance. */
|
|
292
|
+
layout: DictionaryLayout;
|
|
293
|
+
/** Refresh policy: 0 = static, N = every N seconds, { min, max } = random interval */
|
|
294
|
+
lifetime: DictionaryLifetime;
|
|
295
|
+
/** Database where the dictionary is created. Defaults to the project's default database. */
|
|
296
|
+
database?: string;
|
|
297
|
+
/** ON CLUSTER name for distributed ClickHouse deployments. */
|
|
298
|
+
clusterName?: string;
|
|
299
|
+
/** Optional top-level INVALIDATE_QUERY expression. */
|
|
300
|
+
invalidateQuery?: string;
|
|
301
|
+
/** Additional ClickHouse dictionary settings (key=value pairs). */
|
|
302
|
+
settings?: Record<string, string>;
|
|
303
|
+
/** Optional dictionary COMMENT. */
|
|
304
|
+
comment?: string;
|
|
305
|
+
/** Lifecycle management policy. Defaults to FULLY_MANAGED. */
|
|
306
|
+
lifeCycle?: LifeCycle;
|
|
307
|
+
/** Optional metadata for documentation and tooling. */
|
|
308
|
+
metadata?: {
|
|
309
|
+
description?: string;
|
|
310
|
+
[key: string]: any;
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
/** JSON shape for a single DictionaryColumn, matching Rust's #[serde(rename_all = "camelCase")] */
|
|
314
|
+
interface DictionaryColumnJson {
|
|
315
|
+
name: string;
|
|
316
|
+
typeString: string;
|
|
317
|
+
defaultValue?: string;
|
|
318
|
+
expression?: string;
|
|
319
|
+
isInjective?: boolean;
|
|
320
|
+
isHierarchical?: boolean;
|
|
321
|
+
isObjectId?: boolean;
|
|
322
|
+
comment?: string;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Represents a ClickHouse Dictionary — an in-memory key-value store for fast
|
|
326
|
+
* point lookups backed by a local ClickHouse table, a SQL query, or an
|
|
327
|
+
* external data source (MySQL, PostgreSQL, HTTP, Redis, S3, etc.).
|
|
328
|
+
*
|
|
329
|
+
* Dictionaries are significantly faster than JOINs for repeated lookups of
|
|
330
|
+
* static or slowly-changing reference data.
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```typescript
|
|
334
|
+
* interface ProductLookup {
|
|
335
|
+
* ProductId: string;
|
|
336
|
+
* ProductName: string;
|
|
337
|
+
* PriceLevel: number & ClickHouseInt<"Int32">;
|
|
338
|
+
* }
|
|
339
|
+
*
|
|
340
|
+
* export const ProductDict = new OlapDictionary<ProductLookup>("dict_products", {
|
|
341
|
+
* sourceTable: ProductsTable,
|
|
342
|
+
* primaryKey: ["ProductId"],
|
|
343
|
+
* layout: { type: "HASHED" },
|
|
344
|
+
* lifetime: 3600,
|
|
345
|
+
* });
|
|
346
|
+
*
|
|
347
|
+
* // Use in a materialized view:
|
|
348
|
+
* sql`SELECT ${ProductDict.get("ProductName", sql.raw("product_id"))} AS name FROM ...`
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
declare class OlapDictionary<T> {
|
|
352
|
+
/** @internal */
|
|
353
|
+
readonly kind = "OlapDictionary";
|
|
354
|
+
/** Dictionary name */
|
|
355
|
+
readonly name: string;
|
|
356
|
+
/** User configuration */
|
|
357
|
+
readonly config: OlapDictionaryConfig<T>;
|
|
358
|
+
/** Compiler-injected columns (name + type from T) */
|
|
359
|
+
readonly _columns: Column[];
|
|
360
|
+
/** Serialized column list (DictionaryColumn JSON objects) */
|
|
361
|
+
readonly serializedColumns: DictionaryColumnJson[];
|
|
362
|
+
/**
|
|
363
|
+
* Creates a new OlapDictionary.
|
|
364
|
+
*
|
|
365
|
+
* @param name - Dictionary name (used in ClickHouse DDL and dictGet calls)
|
|
366
|
+
* @param config - Dictionary configuration
|
|
367
|
+
*/
|
|
368
|
+
constructor(name: string, config: OlapDictionaryConfig<T>);
|
|
369
|
+
/** @internal — compiler plugin injects schema and columns */
|
|
370
|
+
constructor(name: string, config: OlapDictionaryConfig<T>, _schema: IJsonSchemaCollection.IV3_1, columns: Column[]);
|
|
371
|
+
/**
|
|
372
|
+
* Returns the qualified dictionary name for use in dictGet calls.
|
|
373
|
+
* Format: `database.name` if database is set, otherwise just `name`.
|
|
374
|
+
*/
|
|
375
|
+
getQualifiedName(): string;
|
|
376
|
+
/**
|
|
377
|
+
* Formats key arguments for use in dictGet/dictHas SQL functions.
|
|
378
|
+
* Strings are treated as SQL identifiers, numbers as literals.
|
|
379
|
+
*/
|
|
380
|
+
private formatKeyArgs;
|
|
381
|
+
/**
|
|
382
|
+
* Generates a `dictGet('dict', 'attr', key)` SQL fragment.
|
|
383
|
+
*
|
|
384
|
+
* @param attr - The attribute (column) name to retrieve
|
|
385
|
+
* @param keys - Key expression(s). Strings are treated as column identifiers.
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```typescript
|
|
389
|
+
* sql`SELECT ${ProductDict.get("ProductName", "product_id")} AS name FROM ...`
|
|
390
|
+
* // → SELECT dictGet('db.dict_products', 'ProductName', `product_id`) AS name FROM ...
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
get(attr: keyof T & string, ...keys: Array<Sql | string | number>): Sql;
|
|
394
|
+
/**
|
|
395
|
+
* Generates a `dictGetOrDefault('dict', 'attr', key, default)` SQL fragment.
|
|
396
|
+
*
|
|
397
|
+
* @param attr - The attribute (column) name to retrieve
|
|
398
|
+
* @param defaultVal - The default value if the key is not found
|
|
399
|
+
* @param keys - Key expression(s)
|
|
400
|
+
*/
|
|
401
|
+
getOrDefault(attr: keyof T & string, defaultVal: Sql | string | number, ...keys: Array<Sql | string | number>): Sql;
|
|
402
|
+
/**
|
|
403
|
+
* Generates a `dictHas('dict', key)` SQL fragment.
|
|
404
|
+
*
|
|
405
|
+
* @param keys - Key expression(s)
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* ```typescript
|
|
409
|
+
* sql`SELECT * FROM source WHERE ${ProductDict.has("product_id")}`
|
|
410
|
+
* // → SELECT * FROM source WHERE dictHas('db.dict_products', `product_id`)
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
has(...keys: Array<Sql | string | number>): Sql;
|
|
414
|
+
/**
|
|
415
|
+
* Serializes this dictionary to the JSON format expected by the Rust CLI.
|
|
416
|
+
* @internal
|
|
417
|
+
*/
|
|
418
|
+
toJson(): Record<string, unknown>;
|
|
419
|
+
}
|
|
420
|
+
|
|
6
421
|
/**
|
|
7
422
|
* Quote a ClickHouse identifier with backticks if not already quoted.
|
|
8
423
|
* Backticks allow special characters (e.g., hyphens) in identifiers.
|
|
@@ -29,17 +444,17 @@ interface SqlTemplateTag {
|
|
|
29
444
|
/**
|
|
30
445
|
* @deprecated Use `sql.statement` for full SQL statements or `sql.fragment` for SQL fragments.
|
|
31
446
|
*/
|
|
32
|
-
(strings: readonly string[], ...values: readonly (RawValue | Column | OlapTable<any> | View)[]): Sql;
|
|
447
|
+
(strings: readonly string[], ...values: readonly (RawValue | Column | OlapTable<any> | View | OlapDictionary<any>)[]): Sql;
|
|
33
448
|
/**
|
|
34
449
|
* Template literal tag for complete SQL statements (e.g. SELECT, INSERT, CREATE).
|
|
35
450
|
* Produces a Sql instance with `isFragment = false`.
|
|
36
451
|
*/
|
|
37
|
-
statement(strings: readonly string[], ...values: readonly (RawValue | Column | OlapTable<any> | View)[]): Sql;
|
|
452
|
+
statement(strings: readonly string[], ...values: readonly (RawValue | Column | OlapTable<any> | View | OlapDictionary<any>)[]): Sql;
|
|
38
453
|
/**
|
|
39
454
|
* Template literal tag for SQL fragments (e.g. expressions, conditions, partial clauses).
|
|
40
455
|
* Produces a Sql instance with `isFragment = true`.
|
|
41
456
|
*/
|
|
42
|
-
fragment(strings: readonly string[], ...values: readonly (RawValue | Column | OlapTable<any> | View)[]): Sql;
|
|
457
|
+
fragment(strings: readonly string[], ...values: readonly (RawValue | Column | OlapTable<any> | View | OlapDictionary<any>)[]): Sql;
|
|
43
458
|
/**
|
|
44
459
|
* Join an array of Sql fragments with a separator.
|
|
45
460
|
* @param fragments - Array of Sql fragments to join
|
|
@@ -60,7 +475,7 @@ declare class Sql {
|
|
|
60
475
|
readonly values: Value[];
|
|
61
476
|
readonly strings: string[];
|
|
62
477
|
readonly isFragment: boolean | undefined;
|
|
63
|
-
constructor(rawStrings: readonly string[], rawValues: readonly (RawValue | Column | OlapTable<any> | View | Sql)[], isFragment?: boolean);
|
|
478
|
+
constructor(rawStrings: readonly string[], rawValues: readonly (RawValue | Column | OlapTable<any> | View | OlapDictionary<any> | Sql)[], isFragment?: boolean);
|
|
64
479
|
/**
|
|
65
480
|
* Append another Sql fragment, returning a new Sql instance.
|
|
66
481
|
*/
|
|
@@ -494,33 +909,6 @@ declare enum ClickHouseEngines {
|
|
|
494
909
|
ReplicatedVersionedCollapsingMergeTree = "ReplicatedVersionedCollapsingMergeTree"
|
|
495
910
|
}
|
|
496
911
|
|
|
497
|
-
/**
|
|
498
|
-
* Defines how Moose manages the lifecycle of database resources when your code changes.
|
|
499
|
-
*
|
|
500
|
-
* This enum controls the behavior when there are differences between your code definitions
|
|
501
|
-
* and the actual database schema or structure.
|
|
502
|
-
*/
|
|
503
|
-
declare enum LifeCycle {
|
|
504
|
-
/**
|
|
505
|
-
* Full automatic management (default behavior).
|
|
506
|
-
* Moose will automatically modify database resources to match your code definitions,
|
|
507
|
-
* including potentially destructive operations like dropping columns or tables.
|
|
508
|
-
*/
|
|
509
|
-
FULLY_MANAGED = "FULLY_MANAGED",
|
|
510
|
-
/**
|
|
511
|
-
* Deletion-protected automatic management.
|
|
512
|
-
* Moose will modify resources to match your code but will avoid destructive actions
|
|
513
|
-
* such as dropping columns, or tables. Only additive changes are applied.
|
|
514
|
-
*/
|
|
515
|
-
DELETION_PROTECTED = "DELETION_PROTECTED",
|
|
516
|
-
/**
|
|
517
|
-
* External management - no automatic changes.
|
|
518
|
-
* Moose will not modify the database resources. You are responsible for managing
|
|
519
|
-
* the schema and ensuring it matches your code definitions manually.
|
|
520
|
-
*/
|
|
521
|
-
EXTERNALLY_MANAGED = "EXTERNALLY_MANAGED"
|
|
522
|
-
}
|
|
523
|
-
|
|
524
912
|
interface TableIndex {
|
|
525
913
|
name: string;
|
|
526
914
|
expression: string;
|
|
@@ -1364,52 +1752,4 @@ declare class QueryClient {
|
|
|
1364
1752
|
command(sql: Sql): Promise<CommandResult>;
|
|
1365
1753
|
}
|
|
1366
1754
|
|
|
1367
|
-
|
|
1368
|
-
* Configuration options for creating a View.
|
|
1369
|
-
*/
|
|
1370
|
-
interface ViewConfig {
|
|
1371
|
-
/** The SQL SELECT statement or Sql object defining the view's logic. */
|
|
1372
|
-
selectStatement: string | Sql;
|
|
1373
|
-
/** Source tables/views the SELECT reads from. Used for dependency tracking during migrations. */
|
|
1374
|
-
baseTables: (OlapTable<any> | View)[];
|
|
1375
|
-
/** Optional database where the view is created. When set, the view is created as `database`.`name` in ClickHouse. */
|
|
1376
|
-
database?: string;
|
|
1377
|
-
/** Optional metadata for the view (e.g., description, source file). */
|
|
1378
|
-
metadata?: {
|
|
1379
|
-
[key: string]: any;
|
|
1380
|
-
};
|
|
1381
|
-
}
|
|
1382
|
-
/**
|
|
1383
|
-
* Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
|
|
1384
|
-
* Emits structured data for the Moose infrastructure system.
|
|
1385
|
-
*/
|
|
1386
|
-
declare class View {
|
|
1387
|
-
/** @internal */
|
|
1388
|
-
readonly kind = "View";
|
|
1389
|
-
/** The name of the view */
|
|
1390
|
-
name: string;
|
|
1391
|
-
/** Optional database where the view is created. When set, the view is created as `database`.`name` in ClickHouse. */
|
|
1392
|
-
database?: string;
|
|
1393
|
-
/** The SELECT SQL statement that defines the view */
|
|
1394
|
-
selectSql: string;
|
|
1395
|
-
/** Names of source tables/views that the SELECT reads from */
|
|
1396
|
-
sourceTables: string[];
|
|
1397
|
-
/** Optional metadata for the view */
|
|
1398
|
-
metadata: {
|
|
1399
|
-
[key: string]: any;
|
|
1400
|
-
};
|
|
1401
|
-
/**
|
|
1402
|
-
* Creates a new View instance.
|
|
1403
|
-
* @param name The name of the view to be created.
|
|
1404
|
-
* @param config Configuration for the view: select statement, base tables, optional database, and optional metadata.
|
|
1405
|
-
*/
|
|
1406
|
-
constructor(name: string, config: ViewConfig);
|
|
1407
|
-
/**
|
|
1408
|
-
* @deprecated Use the config-object overload: `new View(name, { selectStatement, baseTables, metadata? })`.
|
|
1409
|
-
*/
|
|
1410
|
-
constructor(name: string, selectStatement: string | Sql, baseTables: (OlapTable<any> | View)[], metadata?: {
|
|
1411
|
-
[key: string]: any;
|
|
1412
|
-
});
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
export { QueryClient as $, type Decimal as A, type Insertable as B, ClickHouseEngines as C, type DateTime as D, quoteIdentifier as E, type FixedString as F, type IdentifierBrandedString as G, type Value as H, type Int8 as I, type SqlTemplateTag as J, sql as K, LifeCycle as L, Sql as M, type NonIdentifierBrandedString as N, OlapTable as O, toStaticQuery as P, toQuery as Q, type RawValue as R, type S3QueueTableSettings as S, type TableConstraint as T, type UInt8 as U, View as V, type WithDefault as W, toQueryPreview as X, getValueFromParameter as Y, createClickhouseParameter as Z, mapToClickHouseType as _, type OlapConfig as a, TypedBase as a0, type Column as a1, type RowPolicyOptions as a2, type TypiaValidators as a3, type ViewConfig as a4, type DataType as a5, type ClickHousePoint as a6, type ClickHouseRing as a7, type ClickHouseLineString as a8, type ClickHouseMultiLineString as a9, type ClickHousePolygon as aa, type ClickHouseMultiPolygon as ab, type ClickHousePrecision as b, type ClickHouseDecimal as c, type ClickHouseByteSize as d, type ClickHouseFixedStringSize as e, type ClickHouseFloat as f, type ClickHouseInt as g, type ClickHouseJson as h, type LowCardinality as i, type ClickHouseNamedTuple as j, type ClickHouseDefault as k, type ClickHouseTTL as l, type ClickHouseMaterialized as m, type ClickHouseAlias as n, type ClickHouseCodec as o, type DateTime64 as p, type DateTimeString as q, type DateTime64String as r, type Float32 as s, type Float64 as t, type Int16 as u, type Int32 as v, type Int64 as w, type UInt16 as x, type UInt32 as y, type UInt64 as z };
|
|
1755
|
+
export { type Insertable as $, type DateTimeString as A, type DateTime64String as B, ClickHouseEngines as C, type DictionaryColumnConfig as D, type ExternalSource as E, type FixedString as F, type Float32 as G, type HttpExternalSource as H, type Float64 as I, type Int8 as J, type Int16 as K, LifeCycle as L, type MysqlExternalSource as M, type Int32 as N, OlapTable as O, type PostgresqlExternalSource as P, type Int64 as Q, type RedisExternalSource as R, type S3QueueTableSettings as S, type TableConstraint as T, type UInt8 as U, View as V, type WithDefault as W, type UInt16 as X, type UInt32 as Y, type UInt64 as Z, type Decimal as _, type OlapConfig as a, quoteIdentifier as a0, type IdentifierBrandedString as a1, type NonIdentifierBrandedString as a2, type Value as a3, type RawValue as a4, type SqlTemplateTag as a5, sql as a6, Sql as a7, toStaticQuery as a8, toQuery as a9, toQueryPreview as aa, getValueFromParameter as ab, createClickhouseParameter as ac, mapToClickHouseType as ad, QueryClient as ae, TypedBase as af, type Column as ag, type RowPolicyOptions as ah, type TypiaValidators as ai, type ViewConfig as aj, type DataType as ak, type ClickHousePoint as al, type ClickHouseRing as am, type ClickHouseLineString as an, type ClickHouseMultiLineString as ao, type ClickHousePolygon as ap, type ClickHouseMultiPolygon as aq, OlapDictionary as b, type OlapDictionaryConfig as c, type DictionaryLayout as d, type DictionaryLifetime as e, type ClickHouseExternalSource as f, type MongodbExternalSource as g, type ExecutableExternalSource as h, type S3ExternalSource as i, COMPLEX_KEY_LAYOUTS as j, type ClickHousePrecision as k, type ClickHouseDecimal as l, type ClickHouseByteSize as m, type ClickHouseFixedStringSize as n, type ClickHouseFloat as o, type ClickHouseInt as p, type ClickHouseJson as q, type LowCardinality as r, type ClickHouseNamedTuple as s, type ClickHouseDefault as t, type ClickHouseTTL as u, type ClickHouseMaterialized as v, type ClickHouseAlias as w, type ClickHouseCodec as x, type DateTime as y, type DateTime64 as z };
|