@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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as Aggregated, f as Api, g as ApiConfig,
|
|
2
|
-
export {
|
|
1
|
+
export { A as Aggregated, f as Api, g as ApiConfig, V as ApiUtil, C as ConsumptionApi, X as ConsumptionUtil, c as DeadLetter, D as DeadLetterModel, d as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, e as IngestConfig, h as IngestPipeline, M as MaterializedView, j as SelectRowPolicy, k as SelectRowPolicyConfig, S as SimpleAggregated, i as SqlResource, a as Stream, b as StreamConfig, T as Task, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, x as getApi, w as getApis, v as getIngestApi, u as getIngestApis, N as getMaterializedView, O as getMaterializedViews, R as getOlapDictionaries, U as getOlapDictionary, P as getSelectRowPolicies, Q as getSelectRowPolicy, z as getSqlResource, y as getSqlResources, t as getStream, s as getStreams, r as getTable, q as getTables, K as getView, L as getViews, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows } from './index-BTIlwBBZ.mjs';
|
|
2
|
+
export { j as COMPLEX_KEY_LAYOUTS, w as ClickHouseAlias, m as ClickHouseByteSize, x as ClickHouseCodec, l as ClickHouseDecimal, t as ClickHouseDefault, C as ClickHouseEngines, f as ClickHouseExternalSource, n as ClickHouseFixedStringSize, o as ClickHouseFloat, p as ClickHouseInt, q as ClickHouseJson, v as ClickHouseMaterialized, s as ClickHouseNamedTuple, k as ClickHousePrecision, u as ClickHouseTTL, y as DateTime, z as DateTime64, B as DateTime64String, A as DateTimeString, _ as Decimal, D as DictionaryColumnConfig, d as DictionaryLayout, e as DictionaryLifetime, h as ExecutableExternalSource, E as ExternalSource, F as FixedString, G as Float32, I as Float64, H as HttpExternalSource, a1 as IdentifierBrandedString, $ as Insertable, K as Int16, N as Int32, Q as Int64, J as Int8, L as LifeCycle, r as LowCardinality, g as MongodbExternalSource, M as MysqlExternalSource, a2 as NonIdentifierBrandedString, a as OlapConfig, b as OlapDictionary, c as OlapDictionaryConfig, O as OlapTable, P as PostgresqlExternalSource, a4 as RawValue, R as RedisExternalSource, i as S3ExternalSource, S as S3QueueTableSettings, a7 as Sql, a5 as SqlTemplateTag, T as TableConstraint, X as UInt16, Y as UInt32, Z as UInt64, U as UInt8, a3 as Value, V as View, W as WithDefault, ac as createClickhouseParameter, ab as getValueFromParameter, ad as mapToClickHouseType, a0 as quoteIdentifier, a6 as sql, a9 as toQuery, aa as toQueryPreview, a8 as toStaticQuery } from './query-client-6YrlC3Df.mjs';
|
|
3
3
|
import 'typia';
|
|
4
4
|
import '@temporalio/client';
|
|
5
5
|
import 'jose';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as Aggregated, f as Api, g as ApiConfig,
|
|
2
|
-
export {
|
|
1
|
+
export { A as Aggregated, f as Api, g as ApiConfig, V as ApiUtil, C as ConsumptionApi, X as ConsumptionUtil, c as DeadLetter, D as DeadLetterModel, d as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, e as IngestConfig, h as IngestPipeline, M as MaterializedView, j as SelectRowPolicy, k as SelectRowPolicyConfig, S as SimpleAggregated, i as SqlResource, a as Stream, b as StreamConfig, T as Task, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, x as getApi, w as getApis, v as getIngestApi, u as getIngestApis, N as getMaterializedView, O as getMaterializedViews, R as getOlapDictionaries, U as getOlapDictionary, P as getSelectRowPolicies, Q as getSelectRowPolicy, z as getSqlResource, y as getSqlResources, t as getStream, s as getStreams, r as getTable, q as getTables, K as getView, L as getViews, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows } from './index-w7pvlv3c.js';
|
|
2
|
+
export { j as COMPLEX_KEY_LAYOUTS, w as ClickHouseAlias, m as ClickHouseByteSize, x as ClickHouseCodec, l as ClickHouseDecimal, t as ClickHouseDefault, C as ClickHouseEngines, f as ClickHouseExternalSource, n as ClickHouseFixedStringSize, o as ClickHouseFloat, p as ClickHouseInt, q as ClickHouseJson, v as ClickHouseMaterialized, s as ClickHouseNamedTuple, k as ClickHousePrecision, u as ClickHouseTTL, y as DateTime, z as DateTime64, B as DateTime64String, A as DateTimeString, _ as Decimal, D as DictionaryColumnConfig, d as DictionaryLayout, e as DictionaryLifetime, h as ExecutableExternalSource, E as ExternalSource, F as FixedString, G as Float32, I as Float64, H as HttpExternalSource, a1 as IdentifierBrandedString, $ as Insertable, K as Int16, N as Int32, Q as Int64, J as Int8, L as LifeCycle, r as LowCardinality, g as MongodbExternalSource, M as MysqlExternalSource, a2 as NonIdentifierBrandedString, a as OlapConfig, b as OlapDictionary, c as OlapDictionaryConfig, O as OlapTable, P as PostgresqlExternalSource, a4 as RawValue, R as RedisExternalSource, i as S3ExternalSource, S as S3QueueTableSettings, a7 as Sql, a5 as SqlTemplateTag, T as TableConstraint, X as UInt16, Y as UInt32, Z as UInt64, U as UInt8, a3 as Value, V as View, W as WithDefault, ac as createClickhouseParameter, ab as getValueFromParameter, ad as mapToClickHouseType, a0 as quoteIdentifier, a6 as sql, a9 as toQuery, aa as toQueryPreview, a8 as toStaticQuery } from './query-client-6YrlC3Df.js';
|
|
3
3
|
import 'typia';
|
|
4
4
|
import '@temporalio/client';
|
|
5
5
|
import 'jose';
|
|
@@ -484,6 +484,7 @@ var init_runtime = __esm({
|
|
|
484
484
|
var browserCompatible_exports = {};
|
|
485
485
|
__export(browserCompatible_exports, {
|
|
486
486
|
Api: () => Api,
|
|
487
|
+
COMPLEX_KEY_LAYOUTS: () => COMPLEX_KEY_LAYOUTS,
|
|
487
488
|
ClickHouseEngines: () => ClickHouseEngines,
|
|
488
489
|
ConsumptionApi: () => ConsumptionApi,
|
|
489
490
|
DeadLetterQueue: () => DeadLetterQueue,
|
|
@@ -492,6 +493,7 @@ __export(browserCompatible_exports, {
|
|
|
492
493
|
IngestPipeline: () => IngestPipeline,
|
|
493
494
|
LifeCycle: () => LifeCycle,
|
|
494
495
|
MaterializedView: () => MaterializedView,
|
|
496
|
+
OlapDictionary: () => OlapDictionary,
|
|
495
497
|
OlapTable: () => OlapTable,
|
|
496
498
|
SelectRowPolicy: () => SelectRowPolicy,
|
|
497
499
|
Sql: () => Sql,
|
|
@@ -508,6 +510,8 @@ __export(browserCompatible_exports, {
|
|
|
508
510
|
getIngestApis: () => getIngestApis,
|
|
509
511
|
getMaterializedView: () => getMaterializedView,
|
|
510
512
|
getMaterializedViews: () => getMaterializedViews,
|
|
513
|
+
getOlapDictionaries: () => getOlapDictionaries,
|
|
514
|
+
getOlapDictionary: () => getOlapDictionary,
|
|
511
515
|
getSelectRowPolicies: () => getSelectRowPolicies,
|
|
512
516
|
getSelectRowPolicy: () => getSelectRowPolicy,
|
|
513
517
|
getSqlResource: () => getSqlResource,
|
|
@@ -703,6 +707,7 @@ var quoteIdentifier = (name) => {
|
|
|
703
707
|
};
|
|
704
708
|
var isTable = (value) => typeof value === "object" && value !== null && "kind" in value && value.kind === "OlapTable";
|
|
705
709
|
var isView = (value) => typeof value === "object" && value !== null && "kind" in value && value.kind === "View";
|
|
710
|
+
var isDictionary = (value) => typeof value === "object" && value !== null && "kind" in value && value.kind === "OlapDictionary";
|
|
706
711
|
var isColumn = (value) => typeof value === "object" && value !== null && !("kind" in value) && "name" in value && "annotations" in value;
|
|
707
712
|
function sqlImpl(strings, ...values) {
|
|
708
713
|
return new Sql(strings, values);
|
|
@@ -729,7 +734,7 @@ var Sql = class _Sql {
|
|
|
729
734
|
);
|
|
730
735
|
}
|
|
731
736
|
const valuesLength = rawValues.reduce(
|
|
732
|
-
(len, value) => len + (instanceofSql(value) ? value.values.length : isColumn(value) || isTable(value) || isView(value) ? 0 : 1),
|
|
737
|
+
(len, value) => len + (instanceofSql(value) ? value.values.length : isColumn(value) || isTable(value) || isView(value) || isDictionary(value) ? 0 : 1),
|
|
733
738
|
0
|
|
734
739
|
);
|
|
735
740
|
this.values = new Array(valuesLength);
|
|
@@ -776,6 +781,14 @@ var Sql = class _Sql {
|
|
|
776
781
|
this.strings[pos] += `\`${child.name}\``;
|
|
777
782
|
}
|
|
778
783
|
this.strings[pos] += rawString;
|
|
784
|
+
} else if (isDictionary(child)) {
|
|
785
|
+
if (/\b(?:FROM|JOIN)\s*$/i.test(this.strings[pos])) {
|
|
786
|
+
console.warn(
|
|
787
|
+
`OlapDictionary '${child.getQualifiedName()}' interpolated after FROM/JOIN in sql tag. Dictionaries render as string literals (e.g. 'db.dict_name') for use with dictGet(), not as table identifiers. ClickHouse dictionaries cannot be queried directly with FROM/JOIN.`
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
this.strings[pos] += `'${child.getQualifiedName().replace(/'/g, "''")}'`;
|
|
791
|
+
this.strings[pos] += rawString;
|
|
779
792
|
} else {
|
|
780
793
|
this.values[pos++] = child;
|
|
781
794
|
this.strings[pos] = rawString;
|
|
@@ -1043,6 +1056,12 @@ function getSelectRowPolicies() {
|
|
|
1043
1056
|
function getSelectRowPolicy(name) {
|
|
1044
1057
|
return getMooseInternal().selectRowPolicies.get(name);
|
|
1045
1058
|
}
|
|
1059
|
+
function getOlapDictionaries() {
|
|
1060
|
+
return getMooseInternal().olapDictionaries;
|
|
1061
|
+
}
|
|
1062
|
+
function getOlapDictionary(name) {
|
|
1063
|
+
return getMooseInternal().olapDictionaries.get(name);
|
|
1064
|
+
}
|
|
1046
1065
|
|
|
1047
1066
|
// src/consumption-apis/standalone.ts
|
|
1048
1067
|
var import_node_async_hooks = require("async_hooks");
|
|
@@ -1240,7 +1259,8 @@ function createRegistryFrom(existing) {
|
|
|
1240
1259
|
webApps: toTrackingMap(existing?.webApps),
|
|
1241
1260
|
materializedViews: toTrackingMap(existing?.materializedViews),
|
|
1242
1261
|
views: toTrackingMap(existing?.views),
|
|
1243
|
-
selectRowPolicies: toTrackingMap(existing?.selectRowPolicies)
|
|
1262
|
+
selectRowPolicies: toTrackingMap(existing?.selectRowPolicies),
|
|
1263
|
+
olapDictionaries: toTrackingMap(existing?.olapDictionaries)
|
|
1244
1264
|
};
|
|
1245
1265
|
}
|
|
1246
1266
|
var moose_internal = {
|
|
@@ -1280,6 +1300,10 @@ var moose_internal = {
|
|
|
1280
1300
|
selectRowPolicies: new MutationTrackingMap(
|
|
1281
1301
|
void 0,
|
|
1282
1302
|
markRegistryMutated
|
|
1303
|
+
),
|
|
1304
|
+
olapDictionaries: new MutationTrackingMap(
|
|
1305
|
+
void 0,
|
|
1306
|
+
markRegistryMutated
|
|
1283
1307
|
)
|
|
1284
1308
|
};
|
|
1285
1309
|
var defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
@@ -3161,6 +3185,369 @@ var LifeCycle = /* @__PURE__ */ ((LifeCycle2) => {
|
|
|
3161
3185
|
return LifeCycle2;
|
|
3162
3186
|
})(LifeCycle || {});
|
|
3163
3187
|
|
|
3188
|
+
// src/dmv2/sdk/olapDictionary.ts
|
|
3189
|
+
var COMPLEX_KEY_LAYOUTS = /* @__PURE__ */ new Set([
|
|
3190
|
+
"COMPLEX_KEY_HASHED",
|
|
3191
|
+
"COMPLEX_KEY_SPARSE_HASHED",
|
|
3192
|
+
"COMPLEX_KEY_HASHED_ARRAY",
|
|
3193
|
+
"COMPLEX_KEY_CACHE",
|
|
3194
|
+
"COMPLEX_KEY_SSD_CACHE",
|
|
3195
|
+
"COMPLEX_KEY_DIRECT"
|
|
3196
|
+
]);
|
|
3197
|
+
function dataTypeToString(dataType) {
|
|
3198
|
+
if (typeof dataType === "string") {
|
|
3199
|
+
return dataType;
|
|
3200
|
+
}
|
|
3201
|
+
if (typeof dataType === "object" && dataType !== null) {
|
|
3202
|
+
if ("nullable" in dataType) {
|
|
3203
|
+
const inner = dataTypeToString(
|
|
3204
|
+
dataType.nullable
|
|
3205
|
+
);
|
|
3206
|
+
return `Nullable(${inner})`;
|
|
3207
|
+
}
|
|
3208
|
+
if ("elementType" in dataType) {
|
|
3209
|
+
const arr = dataType;
|
|
3210
|
+
const inner = dataTypeToString(arr.elementType);
|
|
3211
|
+
return arr.elementNullable ? `Array(Nullable(${inner}))` : `Array(${inner})`;
|
|
3212
|
+
}
|
|
3213
|
+
if ("name" in dataType && "values" in dataType) {
|
|
3214
|
+
const d = dataType;
|
|
3215
|
+
const entries = d.values.map(
|
|
3216
|
+
(v) => v.value.String !== void 0 ? `'${v.name}' = '${v.value.String}'` : `'${v.name}' = ${v.value.Int ?? 0}`
|
|
3217
|
+
).join(", ");
|
|
3218
|
+
return `${d.name}(${entries})`;
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
throw new Error(
|
|
3222
|
+
`OlapDictionary: unsupported column data type for dictionary attribute: ${JSON.stringify(dataType)}. Dictionaries only support scalar value types (strings, integers, floats, booleans, dates, Nullable wrappers, Array wrappers, and Enum types).`
|
|
3223
|
+
);
|
|
3224
|
+
}
|
|
3225
|
+
function buildDictionaryColumns(columns, overrides) {
|
|
3226
|
+
return columns.map((col) => {
|
|
3227
|
+
const override = overrides?.[col.name] ?? {};
|
|
3228
|
+
const result = {
|
|
3229
|
+
name: col.name,
|
|
3230
|
+
typeString: dataTypeToString(col.data_type)
|
|
3231
|
+
};
|
|
3232
|
+
if (override.defaultValue !== void 0)
|
|
3233
|
+
result.defaultValue = override.defaultValue;
|
|
3234
|
+
if (override.expression !== void 0)
|
|
3235
|
+
result.expression = override.expression;
|
|
3236
|
+
if (override.isInjective !== void 0)
|
|
3237
|
+
result.isInjective = override.isInjective;
|
|
3238
|
+
if (override.isHierarchical !== void 0)
|
|
3239
|
+
result.isHierarchical = override.isHierarchical;
|
|
3240
|
+
if (override.isObjectId !== void 0)
|
|
3241
|
+
result.isObjectId = override.isObjectId;
|
|
3242
|
+
if (override.comment !== void 0) result.comment = override.comment;
|
|
3243
|
+
return result;
|
|
3244
|
+
});
|
|
3245
|
+
}
|
|
3246
|
+
function serializeLifetime(lifetime) {
|
|
3247
|
+
if (typeof lifetime === "number") {
|
|
3248
|
+
if (!Number.isFinite(lifetime) || lifetime < 0 || !Number.isInteger(lifetime)) {
|
|
3249
|
+
throw new Error(
|
|
3250
|
+
`OlapDictionary: lifetime must be a finite non-negative integer (got ${lifetime}).`
|
|
3251
|
+
);
|
|
3252
|
+
}
|
|
3253
|
+
if (lifetime === 0) {
|
|
3254
|
+
return { type: "STATIC" };
|
|
3255
|
+
}
|
|
3256
|
+
return { type: "SINGLE", seconds: lifetime };
|
|
3257
|
+
}
|
|
3258
|
+
if (!Number.isFinite(lifetime.min) || !Number.isFinite(lifetime.max) || !Number.isInteger(lifetime.min) || !Number.isInteger(lifetime.max) || lifetime.min < 0 || lifetime.max < lifetime.min) {
|
|
3259
|
+
throw new Error(
|
|
3260
|
+
`OlapDictionary: lifetime range must use finite non-negative integers with min <= max (got min=${lifetime.min}, max=${lifetime.max}).`
|
|
3261
|
+
);
|
|
3262
|
+
}
|
|
3263
|
+
if (lifetime.min === 0 && lifetime.max === 0) {
|
|
3264
|
+
return { type: "STATIC" };
|
|
3265
|
+
}
|
|
3266
|
+
if (lifetime.min === lifetime.max) {
|
|
3267
|
+
return { type: "SINGLE", seconds: lifetime.min };
|
|
3268
|
+
}
|
|
3269
|
+
return { type: "RANGE", min: lifetime.min, max: lifetime.max };
|
|
3270
|
+
}
|
|
3271
|
+
function serializeLayout(layout) {
|
|
3272
|
+
const { type, ...rest } = layout;
|
|
3273
|
+
const snakeCaseFields = {};
|
|
3274
|
+
for (const [key, value] of Object.entries(rest)) {
|
|
3275
|
+
if (value === void 0) continue;
|
|
3276
|
+
const snake = key.replace(/([A-Z])/g, "_$1").toLowerCase();
|
|
3277
|
+
snakeCaseFields[snake] = value;
|
|
3278
|
+
}
|
|
3279
|
+
return { type, ...snakeCaseFields };
|
|
3280
|
+
}
|
|
3281
|
+
function externalTypeToRust(type) {
|
|
3282
|
+
const mapping = {
|
|
3283
|
+
http: "HTTP",
|
|
3284
|
+
clickhouse: "CLICK_HOUSE",
|
|
3285
|
+
mysql: "MYSQL",
|
|
3286
|
+
postgresql: "POSTGRESQL",
|
|
3287
|
+
redis: "REDIS",
|
|
3288
|
+
mongodb: "MONGODB",
|
|
3289
|
+
executable: "EXECUTABLE",
|
|
3290
|
+
s3: "S3"
|
|
3291
|
+
};
|
|
3292
|
+
return mapping[type];
|
|
3293
|
+
}
|
|
3294
|
+
function serializeExternalSource(ext) {
|
|
3295
|
+
const { type, ...rest } = ext;
|
|
3296
|
+
const inner = {
|
|
3297
|
+
source_type: externalTypeToRust(type)
|
|
3298
|
+
};
|
|
3299
|
+
for (const [key, value] of Object.entries(rest)) {
|
|
3300
|
+
inner[key] = value;
|
|
3301
|
+
}
|
|
3302
|
+
return {
|
|
3303
|
+
type: "EXTERNAL",
|
|
3304
|
+
externalSource: inner
|
|
3305
|
+
};
|
|
3306
|
+
}
|
|
3307
|
+
function serializeSource(config) {
|
|
3308
|
+
if (config.sourceTable !== void 0) {
|
|
3309
|
+
const table = config.sourceTable;
|
|
3310
|
+
if (table instanceof OlapTable) {
|
|
3311
|
+
return {
|
|
3312
|
+
type: "TABLE",
|
|
3313
|
+
table: table.generateTableName(),
|
|
3314
|
+
database: table.config.database,
|
|
3315
|
+
...config.invalidateQuery !== void 0 ? { invalidateQuery: config.invalidateQuery } : {}
|
|
3316
|
+
};
|
|
3317
|
+
} else {
|
|
3318
|
+
return {
|
|
3319
|
+
type: "TABLE",
|
|
3320
|
+
table: table.name,
|
|
3321
|
+
database: table.database,
|
|
3322
|
+
...config.invalidateQuery !== void 0 ? { invalidateQuery: config.invalidateQuery } : {}
|
|
3323
|
+
};
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
if (config.sourceQuery !== void 0) {
|
|
3327
|
+
return {
|
|
3328
|
+
type: "QUERY",
|
|
3329
|
+
query: toStaticQuery(config.sourceQuery),
|
|
3330
|
+
...config.invalidateQuery !== void 0 ? { invalidateQuery: config.invalidateQuery } : {}
|
|
3331
|
+
};
|
|
3332
|
+
}
|
|
3333
|
+
if (config.externalSource !== void 0) {
|
|
3334
|
+
return serializeExternalSource(config.externalSource);
|
|
3335
|
+
}
|
|
3336
|
+
throw new Error(
|
|
3337
|
+
"OlapDictionary: no source configured (unreachable after validation)"
|
|
3338
|
+
);
|
|
3339
|
+
}
|
|
3340
|
+
var OlapDictionary = class {
|
|
3341
|
+
/** @internal */
|
|
3342
|
+
kind = "OlapDictionary";
|
|
3343
|
+
/** Dictionary name */
|
|
3344
|
+
name;
|
|
3345
|
+
/** User configuration */
|
|
3346
|
+
config;
|
|
3347
|
+
/** Compiler-injected columns (name + type from T) */
|
|
3348
|
+
_columns;
|
|
3349
|
+
/** Serialized column list (DictionaryColumn JSON objects) */
|
|
3350
|
+
serializedColumns;
|
|
3351
|
+
constructor(name, config, _schema, columns) {
|
|
3352
|
+
if (_schema === void 0 || columns === void 0) {
|
|
3353
|
+
throw new Error(
|
|
3354
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
3355
|
+
);
|
|
3356
|
+
}
|
|
3357
|
+
this.name = name;
|
|
3358
|
+
this.config = config;
|
|
3359
|
+
this._columns = columns;
|
|
3360
|
+
const sourcesSet = [
|
|
3361
|
+
config.sourceTable !== void 0,
|
|
3362
|
+
config.sourceQuery !== void 0,
|
|
3363
|
+
config.externalSource !== void 0
|
|
3364
|
+
].filter(Boolean).length;
|
|
3365
|
+
if (sourcesSet === 0) {
|
|
3366
|
+
throw new Error(
|
|
3367
|
+
`OlapDictionary '${name}': exactly one of sourceTable, sourceQuery, or externalSource must be set (none provided).`
|
|
3368
|
+
);
|
|
3369
|
+
}
|
|
3370
|
+
if (sourcesSet > 1) {
|
|
3371
|
+
throw new Error(
|
|
3372
|
+
`OlapDictionary '${name}': exactly one of sourceTable, sourceQuery, or externalSource must be set (${sourcesSet} provided).`
|
|
3373
|
+
);
|
|
3374
|
+
}
|
|
3375
|
+
if (config.sourceQuery !== void 0 && !config.sourceTables?.length) {
|
|
3376
|
+
throw new Error(
|
|
3377
|
+
`OlapDictionary '${name}': sourceQuery requires sourceTables to be set for dependency tracking.`
|
|
3378
|
+
);
|
|
3379
|
+
}
|
|
3380
|
+
if (config.sourceQuery !== void 0) {
|
|
3381
|
+
if (!toStaticQuery(config.sourceQuery).trim()) {
|
|
3382
|
+
throw new Error(
|
|
3383
|
+
`OlapDictionary '${name}': sourceQuery must not be blank.`
|
|
3384
|
+
);
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
if (!config.primaryKey.length) {
|
|
3388
|
+
throw new Error(
|
|
3389
|
+
`OlapDictionary '${name}': primaryKey must contain at least one column name.`
|
|
3390
|
+
);
|
|
3391
|
+
}
|
|
3392
|
+
if (!COMPLEX_KEY_LAYOUTS.has(config.layout.type)) {
|
|
3393
|
+
if (config.primaryKey.length !== 1) {
|
|
3394
|
+
throw new Error(
|
|
3395
|
+
`OlapDictionary '${name}': layout '${config.layout.type}' requires exactly 1 primary key column (got ${config.primaryKey.length}). Use a COMPLEX_KEY_* layout for string or multi-column keys.`
|
|
3396
|
+
);
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
this.serializedColumns = buildDictionaryColumns(
|
|
3400
|
+
columns,
|
|
3401
|
+
config.columns
|
|
3402
|
+
);
|
|
3403
|
+
if (!config.metadata?.source) {
|
|
3404
|
+
const stack = new Error().stack;
|
|
3405
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
3406
|
+
if (sourceInfo) {
|
|
3407
|
+
this.config.metadata = {
|
|
3408
|
+
...config.metadata,
|
|
3409
|
+
source: { file: sourceInfo }
|
|
3410
|
+
};
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
const olapDictionaries = getMooseInternal().olapDictionaries;
|
|
3414
|
+
if (!isClientOnlyMode() && olapDictionaries.has(name)) {
|
|
3415
|
+
throw new Error(`OlapDictionary with name '${name}' already exists`);
|
|
3416
|
+
}
|
|
3417
|
+
olapDictionaries.set(name, this);
|
|
3418
|
+
}
|
|
3419
|
+
/**
|
|
3420
|
+
* Returns the qualified dictionary name for use in dictGet calls.
|
|
3421
|
+
* Format: `database.name` if database is set, otherwise just `name`.
|
|
3422
|
+
*/
|
|
3423
|
+
getQualifiedName() {
|
|
3424
|
+
if (this.config.database) {
|
|
3425
|
+
return `${this.config.database}.${this.name}`;
|
|
3426
|
+
}
|
|
3427
|
+
return this.name;
|
|
3428
|
+
}
|
|
3429
|
+
/**
|
|
3430
|
+
* Formats key arguments for use in dictGet/dictHas SQL functions.
|
|
3431
|
+
* Strings are treated as SQL identifiers, numbers as literals.
|
|
3432
|
+
*/
|
|
3433
|
+
formatKeyArgs(keys) {
|
|
3434
|
+
if (keys.length !== this.config.primaryKey.length) {
|
|
3435
|
+
throw new Error(
|
|
3436
|
+
`OlapDictionary '${this.name}': expected ${this.config.primaryKey.length} key argument(s) but got ${keys.length}.`
|
|
3437
|
+
);
|
|
3438
|
+
}
|
|
3439
|
+
const parts = keys.map((k) => {
|
|
3440
|
+
if (typeof k === "object" && "strings" in k) {
|
|
3441
|
+
return toStaticQuery(k);
|
|
3442
|
+
}
|
|
3443
|
+
if (typeof k === "string") {
|
|
3444
|
+
return `\`${k.replace(/`/g, "``")}\``;
|
|
3445
|
+
}
|
|
3446
|
+
return String(k);
|
|
3447
|
+
});
|
|
3448
|
+
return parts.length === 1 ? parts[0] : `(${parts.join(", ")})`;
|
|
3449
|
+
}
|
|
3450
|
+
/**
|
|
3451
|
+
* Generates a `dictGet('dict', 'attr', key)` SQL fragment.
|
|
3452
|
+
*
|
|
3453
|
+
* @param attr - The attribute (column) name to retrieve
|
|
3454
|
+
* @param keys - Key expression(s). Strings are treated as column identifiers.
|
|
3455
|
+
*
|
|
3456
|
+
* @example
|
|
3457
|
+
* ```typescript
|
|
3458
|
+
* sql`SELECT ${ProductDict.get("ProductName", "product_id")} AS name FROM ...`
|
|
3459
|
+
* // → SELECT dictGet('db.dict_products', 'ProductName', `product_id`) AS name FROM ...
|
|
3460
|
+
* ```
|
|
3461
|
+
*/
|
|
3462
|
+
get(attr, ...keys) {
|
|
3463
|
+
if (!keys.length) {
|
|
3464
|
+
throw new Error(
|
|
3465
|
+
`OlapDictionary.get('${attr}'): at least one key argument is required.`
|
|
3466
|
+
);
|
|
3467
|
+
}
|
|
3468
|
+
const qualifiedName = this.getQualifiedName().replace(/'/g, "''");
|
|
3469
|
+
const escapedAttr = attr.replace(/'/g, "''");
|
|
3470
|
+
const keyExpr = this.formatKeyArgs(keys);
|
|
3471
|
+
return sql.raw(`dictGet('${qualifiedName}', '${escapedAttr}', ${keyExpr})`);
|
|
3472
|
+
}
|
|
3473
|
+
/**
|
|
3474
|
+
* Generates a `dictGetOrDefault('dict', 'attr', key, default)` SQL fragment.
|
|
3475
|
+
*
|
|
3476
|
+
* @param attr - The attribute (column) name to retrieve
|
|
3477
|
+
* @param defaultVal - The default value if the key is not found
|
|
3478
|
+
* @param keys - Key expression(s)
|
|
3479
|
+
*/
|
|
3480
|
+
getOrDefault(attr, defaultVal, ...keys) {
|
|
3481
|
+
if (!keys.length) {
|
|
3482
|
+
throw new Error(
|
|
3483
|
+
`OlapDictionary.getOrDefault('${attr}'): at least one key argument is required.`
|
|
3484
|
+
);
|
|
3485
|
+
}
|
|
3486
|
+
const qualifiedName = this.getQualifiedName().replace(/'/g, "''");
|
|
3487
|
+
const escapedAttr = attr.replace(/'/g, "''");
|
|
3488
|
+
const keyExpr = this.formatKeyArgs(keys);
|
|
3489
|
+
let defaultExpr;
|
|
3490
|
+
if (typeof defaultVal === "object" && "strings" in defaultVal) {
|
|
3491
|
+
defaultExpr = toStaticQuery(defaultVal);
|
|
3492
|
+
} else if (typeof defaultVal === "string") {
|
|
3493
|
+
defaultExpr = `'${defaultVal.replace(/'/g, "''")}'`;
|
|
3494
|
+
} else {
|
|
3495
|
+
defaultExpr = String(defaultVal);
|
|
3496
|
+
}
|
|
3497
|
+
return sql.raw(
|
|
3498
|
+
`dictGetOrDefault('${qualifiedName}', '${escapedAttr}', ${keyExpr}, ${defaultExpr})`
|
|
3499
|
+
);
|
|
3500
|
+
}
|
|
3501
|
+
/**
|
|
3502
|
+
* Generates a `dictHas('dict', key)` SQL fragment.
|
|
3503
|
+
*
|
|
3504
|
+
* @param keys - Key expression(s)
|
|
3505
|
+
*
|
|
3506
|
+
* @example
|
|
3507
|
+
* ```typescript
|
|
3508
|
+
* sql`SELECT * FROM source WHERE ${ProductDict.has("product_id")}`
|
|
3509
|
+
* // → SELECT * FROM source WHERE dictHas('db.dict_products', `product_id`)
|
|
3510
|
+
* ```
|
|
3511
|
+
*/
|
|
3512
|
+
has(...keys) {
|
|
3513
|
+
if (!keys.length) {
|
|
3514
|
+
throw new Error(
|
|
3515
|
+
`OlapDictionary.has(): at least one key argument is required.`
|
|
3516
|
+
);
|
|
3517
|
+
}
|
|
3518
|
+
const qualifiedName = this.getQualifiedName().replace(/'/g, "''");
|
|
3519
|
+
const keyExpr = this.formatKeyArgs(keys);
|
|
3520
|
+
return sql.raw(`dictHas('${qualifiedName}', ${keyExpr})`);
|
|
3521
|
+
}
|
|
3522
|
+
/**
|
|
3523
|
+
* Serializes this dictionary to the JSON format expected by the Rust CLI.
|
|
3524
|
+
* @internal
|
|
3525
|
+
*/
|
|
3526
|
+
toJson() {
|
|
3527
|
+
const source = serializeSource(this.config);
|
|
3528
|
+
const result = {
|
|
3529
|
+
name: this.name,
|
|
3530
|
+
source,
|
|
3531
|
+
primaryKey: this.config.primaryKey,
|
|
3532
|
+
columns: this.serializedColumns,
|
|
3533
|
+
layout: serializeLayout(this.config.layout),
|
|
3534
|
+
lifetime: serializeLifetime(this.config.lifetime),
|
|
3535
|
+
settings: this.config.settings ?? {},
|
|
3536
|
+
lifeCycle: this.config.lifeCycle ?? "FULLY_MANAGED" /* FULLY_MANAGED */
|
|
3537
|
+
};
|
|
3538
|
+
if (this.config.database !== void 0)
|
|
3539
|
+
result.database = this.config.database;
|
|
3540
|
+
if (this.config.clusterName !== void 0)
|
|
3541
|
+
result.clusterName = this.config.clusterName;
|
|
3542
|
+
if (this.config.invalidateQuery !== void 0)
|
|
3543
|
+
result.invalidateQuery = this.config.invalidateQuery;
|
|
3544
|
+
if (this.config.comment !== void 0) result.comment = this.config.comment;
|
|
3545
|
+
if (this.config.metadata !== void 0)
|
|
3546
|
+
result.metadata = this.config.metadata;
|
|
3547
|
+
return result;
|
|
3548
|
+
}
|
|
3549
|
+
};
|
|
3550
|
+
|
|
3164
3551
|
// src/dmv2/sdk/webApp.ts
|
|
3165
3552
|
var RESERVED_MOUNT_PATHS = [
|
|
3166
3553
|
"/admin",
|
|
@@ -3290,6 +3677,7 @@ Examples:
|
|
|
3290
3677
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3291
3678
|
0 && (module.exports = {
|
|
3292
3679
|
Api,
|
|
3680
|
+
COMPLEX_KEY_LAYOUTS,
|
|
3293
3681
|
ClickHouseEngines,
|
|
3294
3682
|
ConsumptionApi,
|
|
3295
3683
|
DeadLetterQueue,
|
|
@@ -3298,6 +3686,7 @@ Examples:
|
|
|
3298
3686
|
IngestPipeline,
|
|
3299
3687
|
LifeCycle,
|
|
3300
3688
|
MaterializedView,
|
|
3689
|
+
OlapDictionary,
|
|
3301
3690
|
OlapTable,
|
|
3302
3691
|
SelectRowPolicy,
|
|
3303
3692
|
Sql,
|
|
@@ -3314,6 +3703,8 @@ Examples:
|
|
|
3314
3703
|
getIngestApis,
|
|
3315
3704
|
getMaterializedView,
|
|
3316
3705
|
getMaterializedViews,
|
|
3706
|
+
getOlapDictionaries,
|
|
3707
|
+
getOlapDictionary,
|
|
3317
3708
|
getSelectRowPolicies,
|
|
3318
3709
|
getSelectRowPolicy,
|
|
3319
3710
|
getSqlResource,
|