@514labs/moose-lib 0.6.334 → 0.6.335
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 +7 -3
- package/dist/browserCompatible.d.ts +7 -3
- package/dist/browserCompatible.js +197 -180
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +196 -180
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/compilerPlugin.js.map +1 -1
- package/dist/compilerPlugin.mjs.map +1 -1
- package/dist/dataModels/toDataModels.js.map +1 -1
- package/dist/dataModels/toDataModels.mjs.map +1 -1
- package/dist/dmv2/index.d.mts +2 -1
- package/dist/dmv2/index.d.ts +2 -1
- package/dist/dmv2/index.js +41 -24
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +40 -24
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-C4miZc-A.d.mts → index-Aq9KzsRd.d.mts} +181 -33
- package/dist/{index-C4miZc-A.d.ts → index-Aq9KzsRd.d.ts} +181 -33
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +176 -202
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +176 -199
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +90 -254
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +91 -255
- package/dist/moose-runner.mjs.map +1 -1
- package/dist/scripts/workflow.js +9 -11
- package/dist/scripts/workflow.js.map +1 -1
- package/dist/scripts/workflow.mjs +9 -11
- package/dist/scripts/workflow.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/browserCompatible-BVw4gSAN.d.mts +0 -184
- package/dist/browserCompatible-rK8ei0bt.d.ts +0 -184
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
export { A as Aggregated, h as Api, i as ApiConfig,
|
|
2
|
-
export { C as ClickHouseByteSize, q as ClickHouseCodec, j as ClickHouseDecimal, n as ClickHouseDefault, k as ClickHouseFixedStringSize, l as ClickHouseFloat, a as ClickHouseInt, m as ClickHouseJson, p as ClickHouseMaterialized, b as ClickHouseNamedTuple, i as ClickHousePrecision, o as ClickHouseTTL, D as DateTime, r as DateTime64, t as DateTime64String, s as DateTimeString, E as Decimal, F as FixedString, u as Float32, v as Float64, w as Int16, x as Int32, y as Int64, I as Int8, J as JWT, K as Key, L as LowCardinality, z as UInt16, A as UInt32, B as UInt64, U as UInt8, W as WithDefault } from './browserCompatible-BVw4gSAN.mjs';
|
|
1
|
+
export { A as Aggregated, h as Api, i as ApiConfig, ao as ApiUtil, Y as ClickHouseByteSize, a7 as ClickHouseCodec, X as ClickHouseDecimal, a3 as ClickHouseDefault, C as ClickHouseEngines, Z as ClickHouseFixedStringSize, _ as ClickHouseFloat, $ as ClickHouseInt, a0 as ClickHouseJson, a5 as ClickHouseMaterialized, a2 as ClickHouseNamedTuple, U as ClickHousePrecision, a4 as ClickHouseTTL, j as ConsumptionApi, ap as ConsumptionUtil, a8 as DateTime, a9 as DateTime64, ab as DateTime64String, aa as DateTimeString, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, an as Decimal, m as ETLPipeline, n as ETLPipelineConfig, E as EgressConfig, ac as FixedString, ad as Float32, ae as Float64, F as FrameworkApp, ar as IdentifierBrandedString, I as IngestApi, g as IngestConfig, k as IngestPipeline, ag as Int16, ah as Int32, ai as Int64, af as Int8, L as LifeCycle, a1 as LowCardinality, M as MaterializedView, as as NonIdentifierBrandedString, a as OlapConfig, O as OlapTable, au as RawValue, b as S3QueueTableSettings, S as SimpleAggregated, aw as Sql, l as SqlResource, c as Stream, d as StreamConfig, T as Task, ak as UInt16, al as UInt32, am as UInt64, aj as UInt8, at as Value, V as View, o as WebApp, p as WebAppConfig, q as WebAppHandler, a6 as WithDefault, W as Workflow, aB as createClickhouseParameter, y as getApi, x as getApis, w as getIngestApi, v as getIngestApis, Q as getMaterializedView, R as getMaterializedViews, B as getSqlResource, z as getSqlResources, u as getStream, t as getStreams, s as getTable, r as getTables, aA as getValueFromParameter, N as getView, P as getViews, K as getWebApp, J as getWebApps, H as getWorkflow, G as getWorkflows, aC as mapToClickHouseType, aq as quoteIdentifier, av as sql, ay as toQuery, az as toQueryPreview, ax as toStaticQuery } from './index-Aq9KzsRd.mjs';
|
|
3
2
|
import 'typia';
|
|
4
3
|
import 'typia/src/schemas/json/IJsonSchemaCollection';
|
|
4
|
+
import 'typia/lib/tags';
|
|
5
5
|
import 'node:stream';
|
|
6
6
|
import '@clickhouse/client';
|
|
7
7
|
import '@temporalio/client';
|
|
8
8
|
import 'jose';
|
|
9
9
|
import 'http';
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
type Key<T extends string | number | Date> = T;
|
|
12
|
+
type JWT<T extends object> = T;
|
|
13
|
+
|
|
14
|
+
export type { JWT, Key };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
export { A as Aggregated, h as Api, i as ApiConfig,
|
|
2
|
-
export { C as ClickHouseByteSize, q as ClickHouseCodec, j as ClickHouseDecimal, n as ClickHouseDefault, k as ClickHouseFixedStringSize, l as ClickHouseFloat, a as ClickHouseInt, m as ClickHouseJson, p as ClickHouseMaterialized, b as ClickHouseNamedTuple, i as ClickHousePrecision, o as ClickHouseTTL, D as DateTime, r as DateTime64, t as DateTime64String, s as DateTimeString, E as Decimal, F as FixedString, u as Float32, v as Float64, w as Int16, x as Int32, y as Int64, I as Int8, J as JWT, K as Key, L as LowCardinality, z as UInt16, A as UInt32, B as UInt64, U as UInt8, W as WithDefault } from './browserCompatible-rK8ei0bt.js';
|
|
1
|
+
export { A as Aggregated, h as Api, i as ApiConfig, ao as ApiUtil, Y as ClickHouseByteSize, a7 as ClickHouseCodec, X as ClickHouseDecimal, a3 as ClickHouseDefault, C as ClickHouseEngines, Z as ClickHouseFixedStringSize, _ as ClickHouseFloat, $ as ClickHouseInt, a0 as ClickHouseJson, a5 as ClickHouseMaterialized, a2 as ClickHouseNamedTuple, U as ClickHousePrecision, a4 as ClickHouseTTL, j as ConsumptionApi, ap as ConsumptionUtil, a8 as DateTime, a9 as DateTime64, ab as DateTime64String, aa as DateTimeString, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, an as Decimal, m as ETLPipeline, n as ETLPipelineConfig, E as EgressConfig, ac as FixedString, ad as Float32, ae as Float64, F as FrameworkApp, ar as IdentifierBrandedString, I as IngestApi, g as IngestConfig, k as IngestPipeline, ag as Int16, ah as Int32, ai as Int64, af as Int8, L as LifeCycle, a1 as LowCardinality, M as MaterializedView, as as NonIdentifierBrandedString, a as OlapConfig, O as OlapTable, au as RawValue, b as S3QueueTableSettings, S as SimpleAggregated, aw as Sql, l as SqlResource, c as Stream, d as StreamConfig, T as Task, ak as UInt16, al as UInt32, am as UInt64, aj as UInt8, at as Value, V as View, o as WebApp, p as WebAppConfig, q as WebAppHandler, a6 as WithDefault, W as Workflow, aB as createClickhouseParameter, y as getApi, x as getApis, w as getIngestApi, v as getIngestApis, Q as getMaterializedView, R as getMaterializedViews, B as getSqlResource, z as getSqlResources, u as getStream, t as getStreams, s as getTable, r as getTables, aA as getValueFromParameter, N as getView, P as getViews, K as getWebApp, J as getWebApps, H as getWorkflow, G as getWorkflows, aC as mapToClickHouseType, aq as quoteIdentifier, av as sql, ay as toQuery, az as toQueryPreview, ax as toStaticQuery } from './index-Aq9KzsRd.js';
|
|
3
2
|
import 'typia';
|
|
4
3
|
import 'typia/src/schemas/json/IJsonSchemaCollection';
|
|
4
|
+
import 'typia/lib/tags';
|
|
5
5
|
import 'node:stream';
|
|
6
6
|
import '@clickhouse/client';
|
|
7
7
|
import '@temporalio/client';
|
|
8
8
|
import 'jose';
|
|
9
9
|
import 'http';
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
type Key<T extends string | number | Date> = T;
|
|
12
|
+
type JWT<T extends object> = T;
|
|
13
|
+
|
|
14
|
+
export type { JWT, Key };
|
|
@@ -177,171 +177,33 @@ var init_dataModelTypes = __esm({
|
|
|
177
177
|
}
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
-
// src/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
function createClickhouseParameter(parameterIndex, value) {
|
|
185
|
-
return `{p${parameterIndex}:${mapToClickHouseType(value)}}`;
|
|
186
|
-
}
|
|
187
|
-
function emptyIfUndefined(value) {
|
|
188
|
-
return value === void 0 ? "" : value;
|
|
189
|
-
}
|
|
190
|
-
var quoteIdentifier, isTable, isView, isColumn, instanceofSql, Sql, toStaticQuery, toQuery, toQueryPreview, getValueFromParameter, mapToClickHouseType;
|
|
191
|
-
var init_sqlHelpers = __esm({
|
|
192
|
-
"src/sqlHelpers.ts"() {
|
|
193
|
-
"use strict";
|
|
194
|
-
quoteIdentifier = (name) => {
|
|
195
|
-
return name.startsWith("`") && name.endsWith("`") ? name : `\`${name}\``;
|
|
196
|
-
};
|
|
197
|
-
isTable = (value) => typeof value === "object" && value !== null && "kind" in value && value.kind === "OlapTable";
|
|
198
|
-
isView = (value) => typeof value === "object" && value !== null && "kind" in value && value.kind === "View";
|
|
199
|
-
isColumn = (value) => typeof value === "object" && value !== null && !("kind" in value) && "name" in value && "annotations" in value;
|
|
200
|
-
instanceofSql = (value) => typeof value === "object" && "values" in value && "strings" in value;
|
|
201
|
-
Sql = class {
|
|
202
|
-
values;
|
|
203
|
-
strings;
|
|
204
|
-
constructor(rawStrings, rawValues) {
|
|
205
|
-
if (rawStrings.length - 1 !== rawValues.length) {
|
|
206
|
-
if (rawStrings.length === 0) {
|
|
207
|
-
throw new TypeError("Expected at least 1 string");
|
|
208
|
-
}
|
|
209
|
-
throw new TypeError(
|
|
210
|
-
`Expected ${rawStrings.length} strings to have ${rawStrings.length - 1} values`
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
const valuesLength = rawValues.reduce(
|
|
214
|
-
(len, value) => len + (instanceofSql(value) ? value.values.length : isColumn(value) || isTable(value) || isView(value) ? 0 : 1),
|
|
215
|
-
0
|
|
216
|
-
);
|
|
217
|
-
this.values = new Array(valuesLength);
|
|
218
|
-
this.strings = new Array(valuesLength + 1);
|
|
219
|
-
this.strings[0] = rawStrings[0];
|
|
220
|
-
let i = 0, pos = 0;
|
|
221
|
-
while (i < rawValues.length) {
|
|
222
|
-
const child = rawValues[i++];
|
|
223
|
-
const rawString = rawStrings[i];
|
|
224
|
-
if (instanceofSql(child)) {
|
|
225
|
-
this.strings[pos] += child.strings[0];
|
|
226
|
-
let childIndex = 0;
|
|
227
|
-
while (childIndex < child.values.length) {
|
|
228
|
-
this.values[pos++] = child.values[childIndex++];
|
|
229
|
-
this.strings[pos] = child.strings[childIndex];
|
|
230
|
-
}
|
|
231
|
-
this.strings[pos] += rawString;
|
|
232
|
-
} else if (isColumn(child)) {
|
|
233
|
-
const aggregationFunction = child.annotations.find(
|
|
234
|
-
([k, _]) => k === "aggregationFunction"
|
|
235
|
-
);
|
|
236
|
-
if (aggregationFunction !== void 0) {
|
|
237
|
-
this.strings[pos] += `${aggregationFunction[1].functionName}Merge(\`${child.name}\`)`;
|
|
238
|
-
} else {
|
|
239
|
-
this.strings[pos] += `\`${child.name}\``;
|
|
240
|
-
}
|
|
241
|
-
this.strings[pos] += rawString;
|
|
242
|
-
} else if (isTable(child)) {
|
|
243
|
-
if (child.config.database) {
|
|
244
|
-
this.strings[pos] += `\`${child.config.database}\`.\`${child.name}\``;
|
|
245
|
-
} else {
|
|
246
|
-
this.strings[pos] += `\`${child.name}\``;
|
|
247
|
-
}
|
|
248
|
-
this.strings[pos] += rawString;
|
|
249
|
-
} else if (isView(child)) {
|
|
250
|
-
this.strings[pos] += `\`${child.name}\``;
|
|
251
|
-
this.strings[pos] += rawString;
|
|
252
|
-
} else {
|
|
253
|
-
this.values[pos++] = child;
|
|
254
|
-
this.strings[pos] = rawString;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
toStaticQuery = (sql3) => {
|
|
260
|
-
const [query, params] = toQuery(sql3);
|
|
261
|
-
if (Object.keys(params).length !== 0) {
|
|
262
|
-
throw new Error(
|
|
263
|
-
"Dynamic SQL is not allowed in the select statement in view creation."
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
return query;
|
|
267
|
-
};
|
|
268
|
-
toQuery = (sql3) => {
|
|
269
|
-
const parameterizedStubs = sql3.values.map(
|
|
270
|
-
(v, i) => createClickhouseParameter(i, v)
|
|
271
|
-
);
|
|
272
|
-
const query = sql3.strings.map(
|
|
273
|
-
(s, i) => s != "" ? `${s}${emptyIfUndefined(parameterizedStubs[i])}` : ""
|
|
274
|
-
).join("");
|
|
275
|
-
const query_params = sql3.values.reduce(
|
|
276
|
-
(acc, v, i) => ({
|
|
277
|
-
...acc,
|
|
278
|
-
[`p${i}`]: getValueFromParameter(v)
|
|
279
|
-
}),
|
|
280
|
-
{}
|
|
281
|
-
);
|
|
282
|
-
return [query, query_params];
|
|
283
|
-
};
|
|
284
|
-
toQueryPreview = (sql3) => {
|
|
285
|
-
try {
|
|
286
|
-
const formatValue = (v) => {
|
|
287
|
-
if (Array.isArray(v)) {
|
|
288
|
-
const [type, val] = v;
|
|
289
|
-
if (type === "Identifier") {
|
|
290
|
-
return `\`${String(val)}\``;
|
|
291
|
-
}
|
|
292
|
-
return `[${v.map((x) => formatValue(x)).join(", ")}]`;
|
|
293
|
-
}
|
|
294
|
-
if (v === null || v === void 0) return "NULL";
|
|
295
|
-
if (typeof v === "string") return `'${v.replace(/'/g, "''")}'`;
|
|
296
|
-
if (typeof v === "number") return String(v);
|
|
297
|
-
if (typeof v === "boolean") return v ? "true" : "false";
|
|
298
|
-
if (v instanceof Date)
|
|
299
|
-
return `'${v.toISOString().replace("T", " ").slice(0, 19)}'`;
|
|
300
|
-
try {
|
|
301
|
-
return JSON.stringify(v);
|
|
302
|
-
} catch {
|
|
303
|
-
return String(v);
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
let out = sql3.strings[0] ?? "";
|
|
307
|
-
for (let i = 0; i < sql3.values.length; i++) {
|
|
308
|
-
const val = getValueFromParameter(sql3.values[i]);
|
|
309
|
-
out += formatValue(val);
|
|
310
|
-
out += sql3.strings[i + 1] ?? "";
|
|
311
|
-
}
|
|
312
|
-
return out.replace(/\s+/g, " ").trim();
|
|
313
|
-
} catch (error) {
|
|
314
|
-
console.log(`toQueryPreview error: ${error}`);
|
|
315
|
-
return "/* query preview unavailable */";
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
getValueFromParameter = (value) => {
|
|
319
|
-
if (Array.isArray(value)) {
|
|
320
|
-
const [type, val] = value;
|
|
321
|
-
if (type === "Identifier") return val;
|
|
322
|
-
}
|
|
323
|
-
return value;
|
|
324
|
-
};
|
|
325
|
-
mapToClickHouseType = (value) => {
|
|
326
|
-
if (typeof value === "number") {
|
|
327
|
-
return Number.isInteger(value) ? "Int" : "Float";
|
|
328
|
-
}
|
|
329
|
-
if (typeof value === "boolean") return "Bool";
|
|
330
|
-
if (value instanceof Date) return "DateTime";
|
|
331
|
-
if (Array.isArray(value)) {
|
|
332
|
-
const [type, _] = value;
|
|
333
|
-
return type;
|
|
334
|
-
}
|
|
335
|
-
return "String";
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
// src/blocks/helpers.ts
|
|
341
|
-
var init_helpers = __esm({
|
|
342
|
-
"src/blocks/helpers.ts"() {
|
|
180
|
+
// src/dataModels/types.ts
|
|
181
|
+
var ClickHouseEngines;
|
|
182
|
+
var init_types = __esm({
|
|
183
|
+
"src/dataModels/types.ts"() {
|
|
343
184
|
"use strict";
|
|
344
|
-
|
|
185
|
+
ClickHouseEngines = /* @__PURE__ */ ((ClickHouseEngines2) => {
|
|
186
|
+
ClickHouseEngines2["MergeTree"] = "MergeTree";
|
|
187
|
+
ClickHouseEngines2["ReplacingMergeTree"] = "ReplacingMergeTree";
|
|
188
|
+
ClickHouseEngines2["SummingMergeTree"] = "SummingMergeTree";
|
|
189
|
+
ClickHouseEngines2["AggregatingMergeTree"] = "AggregatingMergeTree";
|
|
190
|
+
ClickHouseEngines2["CollapsingMergeTree"] = "CollapsingMergeTree";
|
|
191
|
+
ClickHouseEngines2["VersionedCollapsingMergeTree"] = "VersionedCollapsingMergeTree";
|
|
192
|
+
ClickHouseEngines2["GraphiteMergeTree"] = "GraphiteMergeTree";
|
|
193
|
+
ClickHouseEngines2["S3Queue"] = "S3Queue";
|
|
194
|
+
ClickHouseEngines2["S3"] = "S3";
|
|
195
|
+
ClickHouseEngines2["Buffer"] = "Buffer";
|
|
196
|
+
ClickHouseEngines2["Distributed"] = "Distributed";
|
|
197
|
+
ClickHouseEngines2["IcebergS3"] = "IcebergS3";
|
|
198
|
+
ClickHouseEngines2["Kafka"] = "Kafka";
|
|
199
|
+
ClickHouseEngines2["ReplicatedMergeTree"] = "ReplicatedMergeTree";
|
|
200
|
+
ClickHouseEngines2["ReplicatedReplacingMergeTree"] = "ReplicatedReplacingMergeTree";
|
|
201
|
+
ClickHouseEngines2["ReplicatedAggregatingMergeTree"] = "ReplicatedAggregatingMergeTree";
|
|
202
|
+
ClickHouseEngines2["ReplicatedSummingMergeTree"] = "ReplicatedSummingMergeTree";
|
|
203
|
+
ClickHouseEngines2["ReplicatedCollapsingMergeTree"] = "ReplicatedCollapsingMergeTree";
|
|
204
|
+
ClickHouseEngines2["ReplicatedVersionedCollapsingMergeTree"] = "ReplicatedVersionedCollapsingMergeTree";
|
|
205
|
+
return ClickHouseEngines2;
|
|
206
|
+
})(ClickHouseEngines || {});
|
|
345
207
|
}
|
|
346
208
|
});
|
|
347
209
|
|
|
@@ -610,9 +472,169 @@ var init_secrets = __esm({
|
|
|
610
472
|
}
|
|
611
473
|
});
|
|
612
474
|
|
|
475
|
+
// src/sqlHelpers.ts
|
|
476
|
+
function sql(strings, ...values) {
|
|
477
|
+
return new Sql(strings, values);
|
|
478
|
+
}
|
|
479
|
+
function createClickhouseParameter(parameterIndex, value) {
|
|
480
|
+
return `{p${parameterIndex}:${mapToClickHouseType(value)}}`;
|
|
481
|
+
}
|
|
482
|
+
function emptyIfUndefined(value) {
|
|
483
|
+
return value === void 0 ? "" : value;
|
|
484
|
+
}
|
|
485
|
+
var quoteIdentifier, isTable, isView, isColumn, instanceofSql, Sql, toStaticQuery, toQuery, toQueryPreview, getValueFromParameter, mapToClickHouseType;
|
|
486
|
+
var init_sqlHelpers = __esm({
|
|
487
|
+
"src/sqlHelpers.ts"() {
|
|
488
|
+
"use strict";
|
|
489
|
+
quoteIdentifier = (name) => {
|
|
490
|
+
return name.startsWith("`") && name.endsWith("`") ? name : `\`${name}\``;
|
|
491
|
+
};
|
|
492
|
+
isTable = (value) => typeof value === "object" && value !== null && "kind" in value && value.kind === "OlapTable";
|
|
493
|
+
isView = (value) => typeof value === "object" && value !== null && "kind" in value && value.kind === "View";
|
|
494
|
+
isColumn = (value) => typeof value === "object" && value !== null && !("kind" in value) && "name" in value && "annotations" in value;
|
|
495
|
+
instanceofSql = (value) => typeof value === "object" && "values" in value && "strings" in value;
|
|
496
|
+
Sql = class {
|
|
497
|
+
values;
|
|
498
|
+
strings;
|
|
499
|
+
constructor(rawStrings, rawValues) {
|
|
500
|
+
if (rawStrings.length - 1 !== rawValues.length) {
|
|
501
|
+
if (rawStrings.length === 0) {
|
|
502
|
+
throw new TypeError("Expected at least 1 string");
|
|
503
|
+
}
|
|
504
|
+
throw new TypeError(
|
|
505
|
+
`Expected ${rawStrings.length} strings to have ${rawStrings.length - 1} values`
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
const valuesLength = rawValues.reduce(
|
|
509
|
+
(len, value) => len + (instanceofSql(value) ? value.values.length : isColumn(value) || isTable(value) || isView(value) ? 0 : 1),
|
|
510
|
+
0
|
|
511
|
+
);
|
|
512
|
+
this.values = new Array(valuesLength);
|
|
513
|
+
this.strings = new Array(valuesLength + 1);
|
|
514
|
+
this.strings[0] = rawStrings[0];
|
|
515
|
+
let i = 0, pos = 0;
|
|
516
|
+
while (i < rawValues.length) {
|
|
517
|
+
const child = rawValues[i++];
|
|
518
|
+
const rawString = rawStrings[i];
|
|
519
|
+
if (instanceofSql(child)) {
|
|
520
|
+
this.strings[pos] += child.strings[0];
|
|
521
|
+
let childIndex = 0;
|
|
522
|
+
while (childIndex < child.values.length) {
|
|
523
|
+
this.values[pos++] = child.values[childIndex++];
|
|
524
|
+
this.strings[pos] = child.strings[childIndex];
|
|
525
|
+
}
|
|
526
|
+
this.strings[pos] += rawString;
|
|
527
|
+
} else if (isColumn(child)) {
|
|
528
|
+
const aggregationFunction = child.annotations.find(
|
|
529
|
+
([k, _]) => k === "aggregationFunction"
|
|
530
|
+
);
|
|
531
|
+
if (aggregationFunction !== void 0) {
|
|
532
|
+
this.strings[pos] += `${aggregationFunction[1].functionName}Merge(\`${child.name}\`)`;
|
|
533
|
+
} else {
|
|
534
|
+
this.strings[pos] += `\`${child.name}\``;
|
|
535
|
+
}
|
|
536
|
+
this.strings[pos] += rawString;
|
|
537
|
+
} else if (isTable(child)) {
|
|
538
|
+
if (child.config.database) {
|
|
539
|
+
this.strings[pos] += `\`${child.config.database}\`.\`${child.name}\``;
|
|
540
|
+
} else {
|
|
541
|
+
this.strings[pos] += `\`${child.name}\``;
|
|
542
|
+
}
|
|
543
|
+
this.strings[pos] += rawString;
|
|
544
|
+
} else if (isView(child)) {
|
|
545
|
+
this.strings[pos] += `\`${child.name}\``;
|
|
546
|
+
this.strings[pos] += rawString;
|
|
547
|
+
} else {
|
|
548
|
+
this.values[pos++] = child;
|
|
549
|
+
this.strings[pos] = rawString;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
toStaticQuery = (sql3) => {
|
|
555
|
+
const [query, params] = toQuery(sql3);
|
|
556
|
+
if (Object.keys(params).length !== 0) {
|
|
557
|
+
throw new Error(
|
|
558
|
+
"Dynamic SQL is not allowed in the select statement in view creation."
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
return query;
|
|
562
|
+
};
|
|
563
|
+
toQuery = (sql3) => {
|
|
564
|
+
const parameterizedStubs = sql3.values.map(
|
|
565
|
+
(v, i) => createClickhouseParameter(i, v)
|
|
566
|
+
);
|
|
567
|
+
const query = sql3.strings.map(
|
|
568
|
+
(s, i) => s != "" ? `${s}${emptyIfUndefined(parameterizedStubs[i])}` : ""
|
|
569
|
+
).join("");
|
|
570
|
+
const query_params = sql3.values.reduce(
|
|
571
|
+
(acc, v, i) => ({
|
|
572
|
+
...acc,
|
|
573
|
+
[`p${i}`]: getValueFromParameter(v)
|
|
574
|
+
}),
|
|
575
|
+
{}
|
|
576
|
+
);
|
|
577
|
+
return [query, query_params];
|
|
578
|
+
};
|
|
579
|
+
toQueryPreview = (sql3) => {
|
|
580
|
+
try {
|
|
581
|
+
const formatValue = (v) => {
|
|
582
|
+
if (Array.isArray(v)) {
|
|
583
|
+
const [type, val] = v;
|
|
584
|
+
if (type === "Identifier") {
|
|
585
|
+
return `\`${String(val)}\``;
|
|
586
|
+
}
|
|
587
|
+
return `[${v.map((x) => formatValue(x)).join(", ")}]`;
|
|
588
|
+
}
|
|
589
|
+
if (v === null || v === void 0) return "NULL";
|
|
590
|
+
if (typeof v === "string") return `'${v.replace(/'/g, "''")}'`;
|
|
591
|
+
if (typeof v === "number") return String(v);
|
|
592
|
+
if (typeof v === "boolean") return v ? "true" : "false";
|
|
593
|
+
if (v instanceof Date)
|
|
594
|
+
return `'${v.toISOString().replace("T", " ").slice(0, 19)}'`;
|
|
595
|
+
try {
|
|
596
|
+
return JSON.stringify(v);
|
|
597
|
+
} catch {
|
|
598
|
+
return String(v);
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
let out = sql3.strings[0] ?? "";
|
|
602
|
+
for (let i = 0; i < sql3.values.length; i++) {
|
|
603
|
+
const val = getValueFromParameter(sql3.values[i]);
|
|
604
|
+
out += formatValue(val);
|
|
605
|
+
out += sql3.strings[i + 1] ?? "";
|
|
606
|
+
}
|
|
607
|
+
return out.replace(/\s+/g, " ").trim();
|
|
608
|
+
} catch (error) {
|
|
609
|
+
console.log(`toQueryPreview error: ${error}`);
|
|
610
|
+
return "/* query preview unavailable */";
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
getValueFromParameter = (value) => {
|
|
614
|
+
if (Array.isArray(value)) {
|
|
615
|
+
const [type, val] = value;
|
|
616
|
+
if (type === "Identifier") return val;
|
|
617
|
+
}
|
|
618
|
+
return value;
|
|
619
|
+
};
|
|
620
|
+
mapToClickHouseType = (value) => {
|
|
621
|
+
if (typeof value === "number") {
|
|
622
|
+
return Number.isInteger(value) ? "Int" : "Float";
|
|
623
|
+
}
|
|
624
|
+
if (typeof value === "boolean") return "Bool";
|
|
625
|
+
if (value instanceof Date) return "DateTime";
|
|
626
|
+
if (Array.isArray(value)) {
|
|
627
|
+
const [type, _] = value;
|
|
628
|
+
return type;
|
|
629
|
+
}
|
|
630
|
+
return "String";
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
|
|
613
635
|
// src/consumption-apis/helpers.ts
|
|
614
636
|
var import_client2, import_node_crypto;
|
|
615
|
-
var
|
|
637
|
+
var init_helpers = __esm({
|
|
616
638
|
"src/consumption-apis/helpers.ts"() {
|
|
617
639
|
"use strict";
|
|
618
640
|
import_client2 = require("@temporalio/client");
|
|
@@ -660,7 +682,7 @@ var init_runner = __esm({
|
|
|
660
682
|
"src/consumption-apis/runner.ts"() {
|
|
661
683
|
"use strict";
|
|
662
684
|
init_commons();
|
|
663
|
-
|
|
685
|
+
init_helpers();
|
|
664
686
|
jose = __toESM(require("jose"));
|
|
665
687
|
init_cluster_utils();
|
|
666
688
|
init_sqlHelpers();
|
|
@@ -682,7 +704,7 @@ var init_redisClient = __esm({
|
|
|
682
704
|
var init_standalone = __esm({
|
|
683
705
|
"src/consumption-apis/standalone.ts"() {
|
|
684
706
|
"use strict";
|
|
685
|
-
|
|
707
|
+
init_helpers();
|
|
686
708
|
init_commons();
|
|
687
709
|
init_sqlHelpers();
|
|
688
710
|
}
|
|
@@ -732,27 +754,19 @@ var init_dataSource = __esm({
|
|
|
732
754
|
}
|
|
733
755
|
});
|
|
734
756
|
|
|
735
|
-
// src/dataModels/types.ts
|
|
736
|
-
var init_types = __esm({
|
|
737
|
-
"src/dataModels/types.ts"() {
|
|
738
|
-
"use strict";
|
|
739
|
-
}
|
|
740
|
-
});
|
|
741
|
-
|
|
742
757
|
// src/index.ts
|
|
743
758
|
var init_index = __esm({
|
|
744
759
|
"src/index.ts"() {
|
|
745
760
|
"use strict";
|
|
746
761
|
init_browserCompatible();
|
|
747
|
-
init_helpers();
|
|
748
762
|
init_commons();
|
|
749
763
|
init_secrets();
|
|
750
|
-
|
|
764
|
+
init_helpers();
|
|
751
765
|
init_webAppHelpers();
|
|
752
766
|
init_task();
|
|
753
767
|
init_runner();
|
|
754
768
|
init_redisClient();
|
|
755
|
-
|
|
769
|
+
init_helpers();
|
|
756
770
|
init_standalone();
|
|
757
771
|
init_sqlHelpers();
|
|
758
772
|
init_utilities();
|
|
@@ -1105,7 +1119,7 @@ var init_olapTable = __esm({
|
|
|
1105
1119
|
"use strict";
|
|
1106
1120
|
init_typedBase();
|
|
1107
1121
|
init_dataModelTypes();
|
|
1108
|
-
|
|
1122
|
+
init_types();
|
|
1109
1123
|
init_internal();
|
|
1110
1124
|
import_node_stream = require("stream");
|
|
1111
1125
|
import_node_crypto2 = require("crypto");
|
|
@@ -2400,7 +2414,7 @@ var init_ingestPipeline = __esm({
|
|
|
2400
2414
|
init_stream();
|
|
2401
2415
|
init_olapTable();
|
|
2402
2416
|
init_ingestApi();
|
|
2403
|
-
|
|
2417
|
+
init_types();
|
|
2404
2418
|
IngestPipeline = class extends TypedBase {
|
|
2405
2419
|
/**
|
|
2406
2420
|
* The OLAP table component of the pipeline, if configured.
|
|
@@ -2673,7 +2687,7 @@ var requireTargetTableName, MaterializedView;
|
|
|
2673
2687
|
var init_materializedView = __esm({
|
|
2674
2688
|
"src/dmv2/sdk/materializedView.ts"() {
|
|
2675
2689
|
"use strict";
|
|
2676
|
-
|
|
2690
|
+
init_types();
|
|
2677
2691
|
init_sqlHelpers();
|
|
2678
2692
|
init_olapTable();
|
|
2679
2693
|
init_internal();
|
|
@@ -3092,6 +3106,7 @@ var init_dmv2 = __esm({
|
|
|
3092
3106
|
"src/dmv2/index.ts"() {
|
|
3093
3107
|
"use strict";
|
|
3094
3108
|
init_olapTable();
|
|
3109
|
+
init_types();
|
|
3095
3110
|
init_stream();
|
|
3096
3111
|
init_workflow();
|
|
3097
3112
|
init_ingestApi();
|
|
@@ -3111,6 +3126,7 @@ var init_dmv2 = __esm({
|
|
|
3111
3126
|
var browserCompatible_exports = {};
|
|
3112
3127
|
__export(browserCompatible_exports, {
|
|
3113
3128
|
Api: () => Api,
|
|
3129
|
+
ClickHouseEngines: () => ClickHouseEngines,
|
|
3114
3130
|
ConsumptionApi: () => ConsumptionApi,
|
|
3115
3131
|
DeadLetterQueue: () => DeadLetterQueue,
|
|
3116
3132
|
ETLPipeline: () => ETLPipeline,
|
|
@@ -3165,6 +3181,7 @@ init_browserCompatible();
|
|
|
3165
3181
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3166
3182
|
0 && (module.exports = {
|
|
3167
3183
|
Api,
|
|
3184
|
+
ClickHouseEngines,
|
|
3168
3185
|
ConsumptionApi,
|
|
3169
3186
|
DeadLetterQueue,
|
|
3170
3187
|
ETLPipeline,
|