@514labs/moose-lib 0.6.297 → 0.6.298-ci-38-g9d285107
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-FzU17dxm.d.mts → browserCompatible-DGOtJiIs.d.mts} +1 -1
- package/dist/{browserCompatible-CMEunMFq.d.ts → browserCompatible-DzZUjqvL.d.ts} +1 -1
- package/dist/browserCompatible.d.mts +2 -2
- package/dist/browserCompatible.d.ts +2 -2
- package/dist/browserCompatible.js +148 -91
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +144 -91
- 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 +148 -91
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +144 -91
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-CcHF2cVT.d.mts → index-BeUCYK3T.d.mts} +96 -43
- package/dist/{index-CcHF2cVT.d.ts → index-BeUCYK3T.d.ts} +96 -43
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +150 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +146 -83
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +66 -14
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +66 -14
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +1 -1
package/dist/dmv2/index.mjs
CHANGED
|
@@ -217,14 +217,6 @@ var init_sqlHelpers = __esm({
|
|
|
217
217
|
});
|
|
218
218
|
|
|
219
219
|
// src/blocks/helpers.ts
|
|
220
|
-
function dropView(name) {
|
|
221
|
-
return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
|
|
222
|
-
}
|
|
223
|
-
function createMaterializedView(options) {
|
|
224
|
-
return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
|
|
225
|
-
TO ${quoteIdentifier(options.destinationTable)}
|
|
226
|
-
AS ${options.select}`.trim();
|
|
227
|
-
}
|
|
228
220
|
var init_helpers = __esm({
|
|
229
221
|
"src/blocks/helpers.ts"() {
|
|
230
222
|
"use strict";
|
|
@@ -574,7 +566,9 @@ var init_internal = __esm({
|
|
|
574
566
|
apis: /* @__PURE__ */ new Map(),
|
|
575
567
|
sqlResources: /* @__PURE__ */ new Map(),
|
|
576
568
|
workflows: /* @__PURE__ */ new Map(),
|
|
577
|
-
webApps: /* @__PURE__ */ new Map()
|
|
569
|
+
webApps: /* @__PURE__ */ new Map(),
|
|
570
|
+
materializedViews: /* @__PURE__ */ new Map(),
|
|
571
|
+
views: /* @__PURE__ */ new Map()
|
|
578
572
|
};
|
|
579
573
|
defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
580
574
|
getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -2455,6 +2449,93 @@ var init_etlPipeline = __esm({
|
|
|
2455
2449
|
}
|
|
2456
2450
|
});
|
|
2457
2451
|
|
|
2452
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2453
|
+
function formatTableReference(table) {
|
|
2454
|
+
const database = table instanceof OlapTable ? table.config.database : void 0;
|
|
2455
|
+
if (database) {
|
|
2456
|
+
return `\`${database}\`.\`${table.name}\``;
|
|
2457
|
+
}
|
|
2458
|
+
return `\`${table.name}\``;
|
|
2459
|
+
}
|
|
2460
|
+
var requireTargetTableName, MaterializedView;
|
|
2461
|
+
var init_materializedView = __esm({
|
|
2462
|
+
"src/dmv2/sdk/materializedView.ts"() {
|
|
2463
|
+
"use strict";
|
|
2464
|
+
init_helpers();
|
|
2465
|
+
init_sqlHelpers();
|
|
2466
|
+
init_olapTable();
|
|
2467
|
+
init_internal();
|
|
2468
|
+
init_stackTrace();
|
|
2469
|
+
requireTargetTableName = (tableName) => {
|
|
2470
|
+
if (typeof tableName === "string") {
|
|
2471
|
+
return tableName;
|
|
2472
|
+
} else {
|
|
2473
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2474
|
+
}
|
|
2475
|
+
};
|
|
2476
|
+
MaterializedView = class {
|
|
2477
|
+
/** @internal */
|
|
2478
|
+
kind = "MaterializedView";
|
|
2479
|
+
/** The name of the materialized view */
|
|
2480
|
+
name;
|
|
2481
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2482
|
+
targetTable;
|
|
2483
|
+
/** The SELECT SQL statement */
|
|
2484
|
+
selectSql;
|
|
2485
|
+
/** Names of source tables that the SELECT reads from */
|
|
2486
|
+
sourceTables;
|
|
2487
|
+
/** Optional metadata for the materialized view */
|
|
2488
|
+
metadata;
|
|
2489
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2490
|
+
let selectStatement = options.selectStatement;
|
|
2491
|
+
if (typeof selectStatement !== "string") {
|
|
2492
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2493
|
+
}
|
|
2494
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2495
|
+
throw new Error(
|
|
2496
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2497
|
+
);
|
|
2498
|
+
}
|
|
2499
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2500
|
+
requireTargetTableName(
|
|
2501
|
+
options.targetTable?.name ?? options.tableName
|
|
2502
|
+
),
|
|
2503
|
+
{
|
|
2504
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2505
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2506
|
+
},
|
|
2507
|
+
targetSchema,
|
|
2508
|
+
targetColumns
|
|
2509
|
+
);
|
|
2510
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2511
|
+
throw new Error(
|
|
2512
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2513
|
+
);
|
|
2514
|
+
}
|
|
2515
|
+
this.name = options.materializedViewName;
|
|
2516
|
+
this.targetTable = targetTable;
|
|
2517
|
+
this.selectSql = selectStatement;
|
|
2518
|
+
this.sourceTables = options.selectTables.map(
|
|
2519
|
+
(t) => formatTableReference(t)
|
|
2520
|
+
);
|
|
2521
|
+
this.metadata = options.metadata ? { ...options.metadata } : {};
|
|
2522
|
+
if (!this.metadata.source) {
|
|
2523
|
+
const stack = new Error().stack;
|
|
2524
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
2525
|
+
if (sourceInfo) {
|
|
2526
|
+
this.metadata.source = { file: sourceInfo };
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
const materializedViews = getMooseInternal().materializedViews;
|
|
2530
|
+
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2531
|
+
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2532
|
+
}
|
|
2533
|
+
materializedViews.set(this.name, this);
|
|
2534
|
+
}
|
|
2535
|
+
};
|
|
2536
|
+
}
|
|
2537
|
+
});
|
|
2538
|
+
|
|
2458
2539
|
// src/dmv2/sdk/sqlResource.ts
|
|
2459
2540
|
var SqlResource;
|
|
2460
2541
|
var init_sqlResource = __esm({
|
|
@@ -2518,104 +2599,60 @@ var init_sqlResource = __esm({
|
|
|
2518
2599
|
}
|
|
2519
2600
|
});
|
|
2520
2601
|
|
|
2521
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2522
|
-
var requireTargetTableName, MaterializedView;
|
|
2523
|
-
var init_materializedView = __esm({
|
|
2524
|
-
"src/dmv2/sdk/materializedView.ts"() {
|
|
2525
|
-
"use strict";
|
|
2526
|
-
init_helpers();
|
|
2527
|
-
init_sqlHelpers();
|
|
2528
|
-
init_olapTable();
|
|
2529
|
-
init_sqlResource();
|
|
2530
|
-
requireTargetTableName = (tableName) => {
|
|
2531
|
-
if (typeof tableName === "string") {
|
|
2532
|
-
return tableName;
|
|
2533
|
-
} else {
|
|
2534
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2535
|
-
}
|
|
2536
|
-
};
|
|
2537
|
-
MaterializedView = class extends SqlResource {
|
|
2538
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2539
|
-
targetTable;
|
|
2540
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2541
|
-
let selectStatement = options.selectStatement;
|
|
2542
|
-
if (typeof selectStatement !== "string") {
|
|
2543
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2544
|
-
}
|
|
2545
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2546
|
-
throw new Error(
|
|
2547
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2548
|
-
);
|
|
2549
|
-
}
|
|
2550
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2551
|
-
requireTargetTableName(
|
|
2552
|
-
options.targetTable?.name ?? options.tableName
|
|
2553
|
-
),
|
|
2554
|
-
{
|
|
2555
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2556
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2557
|
-
},
|
|
2558
|
-
targetSchema,
|
|
2559
|
-
targetColumns
|
|
2560
|
-
);
|
|
2561
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2562
|
-
throw new Error(
|
|
2563
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2564
|
-
);
|
|
2565
|
-
}
|
|
2566
|
-
super(
|
|
2567
|
-
options.materializedViewName,
|
|
2568
|
-
[
|
|
2569
|
-
createMaterializedView({
|
|
2570
|
-
name: options.materializedViewName,
|
|
2571
|
-
destinationTable: targetTable.name,
|
|
2572
|
-
select: selectStatement
|
|
2573
|
-
})
|
|
2574
|
-
// Population is now handled automatically by Rust infrastructure
|
|
2575
|
-
// based on table engine type and whether this is a new or updated view
|
|
2576
|
-
],
|
|
2577
|
-
[dropView(options.materializedViewName)],
|
|
2578
|
-
{
|
|
2579
|
-
pullsDataFrom: options.selectTables,
|
|
2580
|
-
pushesDataTo: [targetTable]
|
|
2581
|
-
}
|
|
2582
|
-
);
|
|
2583
|
-
this.targetTable = targetTable;
|
|
2584
|
-
}
|
|
2585
|
-
};
|
|
2586
|
-
}
|
|
2587
|
-
});
|
|
2588
|
-
|
|
2589
2602
|
// src/dmv2/sdk/view.ts
|
|
2603
|
+
function formatTableReference2(table) {
|
|
2604
|
+
const database = table instanceof OlapTable ? table.config.database : void 0;
|
|
2605
|
+
if (database) {
|
|
2606
|
+
return `\`${database}\`.\`${table.name}\``;
|
|
2607
|
+
}
|
|
2608
|
+
return `\`${table.name}\``;
|
|
2609
|
+
}
|
|
2590
2610
|
var View;
|
|
2591
2611
|
var init_view = __esm({
|
|
2592
2612
|
"src/dmv2/sdk/view.ts"() {
|
|
2593
2613
|
"use strict";
|
|
2594
|
-
init_helpers();
|
|
2595
2614
|
init_sqlHelpers();
|
|
2596
|
-
|
|
2597
|
-
|
|
2615
|
+
init_olapTable();
|
|
2616
|
+
init_internal();
|
|
2617
|
+
init_stackTrace();
|
|
2618
|
+
View = class {
|
|
2619
|
+
/** @internal */
|
|
2620
|
+
kind = "View";
|
|
2621
|
+
/** The name of the view */
|
|
2622
|
+
name;
|
|
2623
|
+
/** The SELECT SQL statement that defines the view */
|
|
2624
|
+
selectSql;
|
|
2625
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
2626
|
+
sourceTables;
|
|
2627
|
+
/** Optional metadata for the view */
|
|
2628
|
+
metadata;
|
|
2598
2629
|
/**
|
|
2599
2630
|
* Creates a new View instance.
|
|
2600
2631
|
* @param name The name of the view to be created.
|
|
2601
2632
|
* @param selectStatement The SQL SELECT statement that defines the view's logic.
|
|
2602
2633
|
* @param baseTables An array of OlapTable or View objects that the `selectStatement` reads from. Used for dependency tracking.
|
|
2634
|
+
* @param metadata Optional metadata for the view (e.g., description, source file).
|
|
2603
2635
|
*/
|
|
2604
|
-
constructor(name, selectStatement, baseTables) {
|
|
2636
|
+
constructor(name, selectStatement, baseTables, metadata) {
|
|
2605
2637
|
if (typeof selectStatement !== "string") {
|
|
2606
2638
|
selectStatement = toStaticQuery(selectStatement);
|
|
2607
2639
|
}
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
{
|
|
2616
|
-
|
|
2640
|
+
this.name = name;
|
|
2641
|
+
this.selectSql = selectStatement;
|
|
2642
|
+
this.sourceTables = baseTables.map((t) => formatTableReference2(t));
|
|
2643
|
+
this.metadata = metadata ? { ...metadata } : {};
|
|
2644
|
+
if (!this.metadata.source) {
|
|
2645
|
+
const stack = new Error().stack;
|
|
2646
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
2647
|
+
if (sourceInfo) {
|
|
2648
|
+
this.metadata.source = { file: sourceInfo };
|
|
2617
2649
|
}
|
|
2618
|
-
|
|
2650
|
+
}
|
|
2651
|
+
const views = getMooseInternal().views;
|
|
2652
|
+
if (!isClientOnlyMode() && views.has(this.name)) {
|
|
2653
|
+
throw new Error(`View with name ${this.name} already exists`);
|
|
2654
|
+
}
|
|
2655
|
+
views.set(this.name, this);
|
|
2619
2656
|
}
|
|
2620
2657
|
};
|
|
2621
2658
|
}
|
|
@@ -2819,6 +2856,18 @@ function getWebApps() {
|
|
|
2819
2856
|
function getWebApp(name) {
|
|
2820
2857
|
return getMooseInternal().webApps.get(name);
|
|
2821
2858
|
}
|
|
2859
|
+
function getMaterializedViews() {
|
|
2860
|
+
return getMooseInternal().materializedViews;
|
|
2861
|
+
}
|
|
2862
|
+
function getMaterializedView(name) {
|
|
2863
|
+
return getMooseInternal().materializedViews.get(name);
|
|
2864
|
+
}
|
|
2865
|
+
function getViews() {
|
|
2866
|
+
return getMooseInternal().views;
|
|
2867
|
+
}
|
|
2868
|
+
function getView(name) {
|
|
2869
|
+
return getMooseInternal().views.get(name);
|
|
2870
|
+
}
|
|
2822
2871
|
var init_registry = __esm({
|
|
2823
2872
|
"src/dmv2/registry.ts"() {
|
|
2824
2873
|
"use strict";
|
|
@@ -2865,12 +2914,16 @@ export {
|
|
|
2865
2914
|
getApis,
|
|
2866
2915
|
getIngestApi,
|
|
2867
2916
|
getIngestApis,
|
|
2917
|
+
getMaterializedView,
|
|
2918
|
+
getMaterializedViews,
|
|
2868
2919
|
getSqlResource,
|
|
2869
2920
|
getSqlResources,
|
|
2870
2921
|
getStream,
|
|
2871
2922
|
getStreams,
|
|
2872
2923
|
getTable,
|
|
2873
2924
|
getTables,
|
|
2925
|
+
getView,
|
|
2926
|
+
getViews,
|
|
2874
2927
|
getWebApp,
|
|
2875
2928
|
getWebApps,
|
|
2876
2929
|
getWorkflow,
|