@514labs/moose-lib 0.6.295-ci-20-gbe187727 → 0.6.295
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-DhVPp9qX.d.ts → browserCompatible-B8CAYjv5.d.ts} +1 -1
- package/dist/{browserCompatible-DCCiBirg.d.mts → browserCompatible-ChWHzgtb.d.mts} +1 -1
- package/dist/browserCompatible.d.mts +2 -2
- package/dist/browserCompatible.d.ts +2 -2
- package/dist/browserCompatible.js +81 -105
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +81 -101
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/dmv2/index.d.mts +1 -1
- package/dist/dmv2/index.d.ts +1 -1
- package/dist/dmv2/index.js +81 -105
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +81 -101
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-CcZRaA0b.d.mts → index-rQOQo9sv.d.mts} +41 -83
- package/dist/{index-CcZRaA0b.d.ts → index-rQOQo9sv.d.ts} +41 -83
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +71 -107
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -103
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +2 -28
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +2 -28
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -639,6 +639,16 @@ function emptyIfUndefined(value) {
|
|
|
639
639
|
return value === void 0 ? "" : value;
|
|
640
640
|
}
|
|
641
641
|
|
|
642
|
+
// src/blocks/helpers.ts
|
|
643
|
+
function dropView(name) {
|
|
644
|
+
return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
|
|
645
|
+
}
|
|
646
|
+
function createMaterializedView(options) {
|
|
647
|
+
return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
|
|
648
|
+
TO ${quoteIdentifier(options.destinationTable)}
|
|
649
|
+
AS ${options.select}`.trim();
|
|
650
|
+
}
|
|
651
|
+
|
|
642
652
|
// src/dmv2/internal.ts
|
|
643
653
|
import process2 from "process";
|
|
644
654
|
|
|
@@ -692,9 +702,7 @@ var moose_internal = {
|
|
|
692
702
|
apis: /* @__PURE__ */ new Map(),
|
|
693
703
|
sqlResources: /* @__PURE__ */ new Map(),
|
|
694
704
|
workflows: /* @__PURE__ */ new Map(),
|
|
695
|
-
webApps: /* @__PURE__ */ new Map()
|
|
696
|
-
materializedViews: /* @__PURE__ */ new Map(),
|
|
697
|
-
customViews: /* @__PURE__ */ new Map()
|
|
705
|
+
webApps: /* @__PURE__ */ new Map()
|
|
698
706
|
};
|
|
699
707
|
var defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
700
708
|
var getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -2328,67 +2336,6 @@ var ETLPipeline = class {
|
|
|
2328
2336
|
}
|
|
2329
2337
|
};
|
|
2330
2338
|
|
|
2331
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2332
|
-
var requireTargetTableName = (tableName) => {
|
|
2333
|
-
if (typeof tableName === "string") {
|
|
2334
|
-
return tableName;
|
|
2335
|
-
} else {
|
|
2336
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2337
|
-
}
|
|
2338
|
-
};
|
|
2339
|
-
var MaterializedView = class {
|
|
2340
|
-
/** @internal */
|
|
2341
|
-
kind = "MaterializedView";
|
|
2342
|
-
/** The name of the materialized view */
|
|
2343
|
-
name;
|
|
2344
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2345
|
-
targetTable;
|
|
2346
|
-
/** The SELECT SQL statement */
|
|
2347
|
-
selectSql;
|
|
2348
|
-
/** Names of source tables that the SELECT reads from */
|
|
2349
|
-
sourceTables;
|
|
2350
|
-
/** @internal Source file path where this MV was defined */
|
|
2351
|
-
sourceFile;
|
|
2352
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2353
|
-
let selectStatement = options.selectStatement;
|
|
2354
|
-
if (typeof selectStatement !== "string") {
|
|
2355
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2356
|
-
}
|
|
2357
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2358
|
-
throw new Error(
|
|
2359
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2360
|
-
);
|
|
2361
|
-
}
|
|
2362
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2363
|
-
requireTargetTableName(
|
|
2364
|
-
options.targetTable?.name ?? options.tableName
|
|
2365
|
-
),
|
|
2366
|
-
{
|
|
2367
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2368
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2369
|
-
},
|
|
2370
|
-
targetSchema,
|
|
2371
|
-
targetColumns
|
|
2372
|
-
);
|
|
2373
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2374
|
-
throw new Error(
|
|
2375
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2376
|
-
);
|
|
2377
|
-
}
|
|
2378
|
-
this.name = options.materializedViewName;
|
|
2379
|
-
this.targetTable = targetTable;
|
|
2380
|
-
this.selectSql = selectStatement;
|
|
2381
|
-
this.sourceTables = options.selectTables.map((t) => t.name);
|
|
2382
|
-
const stack = new Error().stack;
|
|
2383
|
-
this.sourceFile = getSourceFileFromStack(stack);
|
|
2384
|
-
const materializedViews = getMooseInternal().materializedViews;
|
|
2385
|
-
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2386
|
-
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2387
|
-
}
|
|
2388
|
-
materializedViews.set(this.name, this);
|
|
2389
|
-
}
|
|
2390
|
-
};
|
|
2391
|
-
|
|
2392
2339
|
// src/dmv2/sdk/sqlResource.ts
|
|
2393
2340
|
var SqlResource = class {
|
|
2394
2341
|
/** @internal */
|
|
@@ -2443,18 +2390,66 @@ var SqlResource = class {
|
|
|
2443
2390
|
}
|
|
2444
2391
|
};
|
|
2445
2392
|
|
|
2393
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2394
|
+
var requireTargetTableName = (tableName) => {
|
|
2395
|
+
if (typeof tableName === "string") {
|
|
2396
|
+
return tableName;
|
|
2397
|
+
} else {
|
|
2398
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2399
|
+
}
|
|
2400
|
+
};
|
|
2401
|
+
var MaterializedView = class extends SqlResource {
|
|
2402
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2403
|
+
targetTable;
|
|
2404
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2405
|
+
let selectStatement = options.selectStatement;
|
|
2406
|
+
if (typeof selectStatement !== "string") {
|
|
2407
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2408
|
+
}
|
|
2409
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2410
|
+
throw new Error(
|
|
2411
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2412
|
+
);
|
|
2413
|
+
}
|
|
2414
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2415
|
+
requireTargetTableName(
|
|
2416
|
+
options.targetTable?.name ?? options.tableName
|
|
2417
|
+
),
|
|
2418
|
+
{
|
|
2419
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2420
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2421
|
+
},
|
|
2422
|
+
targetSchema,
|
|
2423
|
+
targetColumns
|
|
2424
|
+
);
|
|
2425
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2426
|
+
throw new Error(
|
|
2427
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2428
|
+
);
|
|
2429
|
+
}
|
|
2430
|
+
super(
|
|
2431
|
+
options.materializedViewName,
|
|
2432
|
+
[
|
|
2433
|
+
createMaterializedView({
|
|
2434
|
+
name: options.materializedViewName,
|
|
2435
|
+
destinationTable: targetTable.name,
|
|
2436
|
+
select: selectStatement
|
|
2437
|
+
})
|
|
2438
|
+
// Population is now handled automatically by Rust infrastructure
|
|
2439
|
+
// based on table engine type and whether this is a new or updated view
|
|
2440
|
+
],
|
|
2441
|
+
[dropView(options.materializedViewName)],
|
|
2442
|
+
{
|
|
2443
|
+
pullsDataFrom: options.selectTables,
|
|
2444
|
+
pushesDataTo: [targetTable]
|
|
2445
|
+
}
|
|
2446
|
+
);
|
|
2447
|
+
this.targetTable = targetTable;
|
|
2448
|
+
}
|
|
2449
|
+
};
|
|
2450
|
+
|
|
2446
2451
|
// src/dmv2/sdk/view.ts
|
|
2447
|
-
var View = class {
|
|
2448
|
-
/** @internal */
|
|
2449
|
-
kind = "CustomView";
|
|
2450
|
-
/** The name of the view */
|
|
2451
|
-
name;
|
|
2452
|
-
/** The SELECT SQL statement that defines the view */
|
|
2453
|
-
selectSql;
|
|
2454
|
-
/** Names of source tables/views that the SELECT reads from */
|
|
2455
|
-
sourceTables;
|
|
2456
|
-
/** @internal Source file path where this view was defined */
|
|
2457
|
-
sourceFile;
|
|
2452
|
+
var View = class extends SqlResource {
|
|
2458
2453
|
/**
|
|
2459
2454
|
* Creates a new View instance.
|
|
2460
2455
|
* @param name The name of the view to be created.
|
|
@@ -2465,16 +2460,17 @@ var View = class {
|
|
|
2465
2460
|
if (typeof selectStatement !== "string") {
|
|
2466
2461
|
selectStatement = toStaticQuery(selectStatement);
|
|
2467
2462
|
}
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2463
|
+
super(
|
|
2464
|
+
name,
|
|
2465
|
+
[
|
|
2466
|
+
`CREATE VIEW IF NOT EXISTS ${name}
|
|
2467
|
+
AS ${selectStatement}`.trim()
|
|
2468
|
+
],
|
|
2469
|
+
[dropView(name)],
|
|
2470
|
+
{
|
|
2471
|
+
pullsDataFrom: baseTables
|
|
2472
|
+
}
|
|
2473
|
+
);
|
|
2478
2474
|
}
|
|
2479
2475
|
};
|
|
2480
2476
|
|
|
@@ -2663,18 +2659,6 @@ function getWebApps2() {
|
|
|
2663
2659
|
function getWebApp(name) {
|
|
2664
2660
|
return getMooseInternal().webApps.get(name);
|
|
2665
2661
|
}
|
|
2666
|
-
function getMaterializedViews() {
|
|
2667
|
-
return getMooseInternal().materializedViews;
|
|
2668
|
-
}
|
|
2669
|
-
function getMaterializedView(name) {
|
|
2670
|
-
return getMooseInternal().materializedViews.get(name);
|
|
2671
|
-
}
|
|
2672
|
-
function getCustomViews() {
|
|
2673
|
-
return getMooseInternal().customViews;
|
|
2674
|
-
}
|
|
2675
|
-
function getCustomView(name) {
|
|
2676
|
-
return getMooseInternal().customViews.get(name);
|
|
2677
|
-
}
|
|
2678
2662
|
export {
|
|
2679
2663
|
Api,
|
|
2680
2664
|
ConsumptionApi,
|
|
@@ -2695,12 +2679,8 @@ export {
|
|
|
2695
2679
|
createClickhouseParameter,
|
|
2696
2680
|
getApi,
|
|
2697
2681
|
getApis2 as getApis,
|
|
2698
|
-
getCustomView,
|
|
2699
|
-
getCustomViews,
|
|
2700
2682
|
getIngestApi,
|
|
2701
2683
|
getIngestApis,
|
|
2702
|
-
getMaterializedView,
|
|
2703
|
-
getMaterializedViews,
|
|
2704
2684
|
getSqlResource,
|
|
2705
2685
|
getSqlResources,
|
|
2706
2686
|
getStream,
|