@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
|
@@ -312,14 +312,6 @@ var init_sqlHelpers = __esm({
|
|
|
312
312
|
});
|
|
313
313
|
|
|
314
314
|
// src/blocks/helpers.ts
|
|
315
|
-
function dropView(name) {
|
|
316
|
-
return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
|
|
317
|
-
}
|
|
318
|
-
function createMaterializedView(options) {
|
|
319
|
-
return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
|
|
320
|
-
TO ${quoteIdentifier(options.destinationTable)}
|
|
321
|
-
AS ${options.select}`.trim();
|
|
322
|
-
}
|
|
323
315
|
var init_helpers = __esm({
|
|
324
316
|
"src/blocks/helpers.ts"() {
|
|
325
317
|
"use strict";
|
|
@@ -659,7 +651,9 @@ var init_internal = __esm({
|
|
|
659
651
|
apis: /* @__PURE__ */ new Map(),
|
|
660
652
|
sqlResources: /* @__PURE__ */ new Map(),
|
|
661
653
|
workflows: /* @__PURE__ */ new Map(),
|
|
662
|
-
webApps: /* @__PURE__ */ new Map()
|
|
654
|
+
webApps: /* @__PURE__ */ new Map(),
|
|
655
|
+
materializedViews: /* @__PURE__ */ new Map(),
|
|
656
|
+
views: /* @__PURE__ */ new Map()
|
|
663
657
|
};
|
|
664
658
|
defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
665
659
|
getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -2540,6 +2534,93 @@ var init_etlPipeline = __esm({
|
|
|
2540
2534
|
}
|
|
2541
2535
|
});
|
|
2542
2536
|
|
|
2537
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2538
|
+
function formatTableReference(table) {
|
|
2539
|
+
const database = table instanceof OlapTable ? table.config.database : void 0;
|
|
2540
|
+
if (database) {
|
|
2541
|
+
return `\`${database}\`.\`${table.name}\``;
|
|
2542
|
+
}
|
|
2543
|
+
return `\`${table.name}\``;
|
|
2544
|
+
}
|
|
2545
|
+
var requireTargetTableName, MaterializedView;
|
|
2546
|
+
var init_materializedView = __esm({
|
|
2547
|
+
"src/dmv2/sdk/materializedView.ts"() {
|
|
2548
|
+
"use strict";
|
|
2549
|
+
init_helpers();
|
|
2550
|
+
init_sqlHelpers();
|
|
2551
|
+
init_olapTable();
|
|
2552
|
+
init_internal();
|
|
2553
|
+
init_stackTrace();
|
|
2554
|
+
requireTargetTableName = (tableName) => {
|
|
2555
|
+
if (typeof tableName === "string") {
|
|
2556
|
+
return tableName;
|
|
2557
|
+
} else {
|
|
2558
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2559
|
+
}
|
|
2560
|
+
};
|
|
2561
|
+
MaterializedView = class {
|
|
2562
|
+
/** @internal */
|
|
2563
|
+
kind = "MaterializedView";
|
|
2564
|
+
/** The name of the materialized view */
|
|
2565
|
+
name;
|
|
2566
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2567
|
+
targetTable;
|
|
2568
|
+
/** The SELECT SQL statement */
|
|
2569
|
+
selectSql;
|
|
2570
|
+
/** Names of source tables that the SELECT reads from */
|
|
2571
|
+
sourceTables;
|
|
2572
|
+
/** Optional metadata for the materialized view */
|
|
2573
|
+
metadata;
|
|
2574
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2575
|
+
let selectStatement = options.selectStatement;
|
|
2576
|
+
if (typeof selectStatement !== "string") {
|
|
2577
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2578
|
+
}
|
|
2579
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2580
|
+
throw new Error(
|
|
2581
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2582
|
+
);
|
|
2583
|
+
}
|
|
2584
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2585
|
+
requireTargetTableName(
|
|
2586
|
+
options.targetTable?.name ?? options.tableName
|
|
2587
|
+
),
|
|
2588
|
+
{
|
|
2589
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2590
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2591
|
+
},
|
|
2592
|
+
targetSchema,
|
|
2593
|
+
targetColumns
|
|
2594
|
+
);
|
|
2595
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2596
|
+
throw new Error(
|
|
2597
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2598
|
+
);
|
|
2599
|
+
}
|
|
2600
|
+
this.name = options.materializedViewName;
|
|
2601
|
+
this.targetTable = targetTable;
|
|
2602
|
+
this.selectSql = selectStatement;
|
|
2603
|
+
this.sourceTables = options.selectTables.map(
|
|
2604
|
+
(t) => formatTableReference(t)
|
|
2605
|
+
);
|
|
2606
|
+
this.metadata = options.metadata ? { ...options.metadata } : {};
|
|
2607
|
+
if (!this.metadata.source) {
|
|
2608
|
+
const stack = new Error().stack;
|
|
2609
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
2610
|
+
if (sourceInfo) {
|
|
2611
|
+
this.metadata.source = { file: sourceInfo };
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
const materializedViews = getMooseInternal().materializedViews;
|
|
2615
|
+
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2616
|
+
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2617
|
+
}
|
|
2618
|
+
materializedViews.set(this.name, this);
|
|
2619
|
+
}
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
2622
|
+
});
|
|
2623
|
+
|
|
2543
2624
|
// src/dmv2/sdk/sqlResource.ts
|
|
2544
2625
|
var SqlResource;
|
|
2545
2626
|
var init_sqlResource = __esm({
|
|
@@ -2603,104 +2684,60 @@ var init_sqlResource = __esm({
|
|
|
2603
2684
|
}
|
|
2604
2685
|
});
|
|
2605
2686
|
|
|
2606
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2607
|
-
var requireTargetTableName, MaterializedView;
|
|
2608
|
-
var init_materializedView = __esm({
|
|
2609
|
-
"src/dmv2/sdk/materializedView.ts"() {
|
|
2610
|
-
"use strict";
|
|
2611
|
-
init_helpers();
|
|
2612
|
-
init_sqlHelpers();
|
|
2613
|
-
init_olapTable();
|
|
2614
|
-
init_sqlResource();
|
|
2615
|
-
requireTargetTableName = (tableName) => {
|
|
2616
|
-
if (typeof tableName === "string") {
|
|
2617
|
-
return tableName;
|
|
2618
|
-
} else {
|
|
2619
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2620
|
-
}
|
|
2621
|
-
};
|
|
2622
|
-
MaterializedView = class extends SqlResource {
|
|
2623
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2624
|
-
targetTable;
|
|
2625
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2626
|
-
let selectStatement = options.selectStatement;
|
|
2627
|
-
if (typeof selectStatement !== "string") {
|
|
2628
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2629
|
-
}
|
|
2630
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2631
|
-
throw new Error(
|
|
2632
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2633
|
-
);
|
|
2634
|
-
}
|
|
2635
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2636
|
-
requireTargetTableName(
|
|
2637
|
-
options.targetTable?.name ?? options.tableName
|
|
2638
|
-
),
|
|
2639
|
-
{
|
|
2640
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2641
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2642
|
-
},
|
|
2643
|
-
targetSchema,
|
|
2644
|
-
targetColumns
|
|
2645
|
-
);
|
|
2646
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2647
|
-
throw new Error(
|
|
2648
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2649
|
-
);
|
|
2650
|
-
}
|
|
2651
|
-
super(
|
|
2652
|
-
options.materializedViewName,
|
|
2653
|
-
[
|
|
2654
|
-
createMaterializedView({
|
|
2655
|
-
name: options.materializedViewName,
|
|
2656
|
-
destinationTable: targetTable.name,
|
|
2657
|
-
select: selectStatement
|
|
2658
|
-
})
|
|
2659
|
-
// Population is now handled automatically by Rust infrastructure
|
|
2660
|
-
// based on table engine type and whether this is a new or updated view
|
|
2661
|
-
],
|
|
2662
|
-
[dropView(options.materializedViewName)],
|
|
2663
|
-
{
|
|
2664
|
-
pullsDataFrom: options.selectTables,
|
|
2665
|
-
pushesDataTo: [targetTable]
|
|
2666
|
-
}
|
|
2667
|
-
);
|
|
2668
|
-
this.targetTable = targetTable;
|
|
2669
|
-
}
|
|
2670
|
-
};
|
|
2671
|
-
}
|
|
2672
|
-
});
|
|
2673
|
-
|
|
2674
2687
|
// src/dmv2/sdk/view.ts
|
|
2688
|
+
function formatTableReference2(table) {
|
|
2689
|
+
const database = table instanceof OlapTable ? table.config.database : void 0;
|
|
2690
|
+
if (database) {
|
|
2691
|
+
return `\`${database}\`.\`${table.name}\``;
|
|
2692
|
+
}
|
|
2693
|
+
return `\`${table.name}\``;
|
|
2694
|
+
}
|
|
2675
2695
|
var View;
|
|
2676
2696
|
var init_view = __esm({
|
|
2677
2697
|
"src/dmv2/sdk/view.ts"() {
|
|
2678
2698
|
"use strict";
|
|
2679
|
-
init_helpers();
|
|
2680
2699
|
init_sqlHelpers();
|
|
2681
|
-
|
|
2682
|
-
|
|
2700
|
+
init_olapTable();
|
|
2701
|
+
init_internal();
|
|
2702
|
+
init_stackTrace();
|
|
2703
|
+
View = class {
|
|
2704
|
+
/** @internal */
|
|
2705
|
+
kind = "View";
|
|
2706
|
+
/** The name of the view */
|
|
2707
|
+
name;
|
|
2708
|
+
/** The SELECT SQL statement that defines the view */
|
|
2709
|
+
selectSql;
|
|
2710
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
2711
|
+
sourceTables;
|
|
2712
|
+
/** Optional metadata for the view */
|
|
2713
|
+
metadata;
|
|
2683
2714
|
/**
|
|
2684
2715
|
* Creates a new View instance.
|
|
2685
2716
|
* @param name The name of the view to be created.
|
|
2686
2717
|
* @param selectStatement The SQL SELECT statement that defines the view's logic.
|
|
2687
2718
|
* @param baseTables An array of OlapTable or View objects that the `selectStatement` reads from. Used for dependency tracking.
|
|
2719
|
+
* @param metadata Optional metadata for the view (e.g., description, source file).
|
|
2688
2720
|
*/
|
|
2689
|
-
constructor(name, selectStatement, baseTables) {
|
|
2721
|
+
constructor(name, selectStatement, baseTables, metadata) {
|
|
2690
2722
|
if (typeof selectStatement !== "string") {
|
|
2691
2723
|
selectStatement = toStaticQuery(selectStatement);
|
|
2692
2724
|
}
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
{
|
|
2701
|
-
|
|
2725
|
+
this.name = name;
|
|
2726
|
+
this.selectSql = selectStatement;
|
|
2727
|
+
this.sourceTables = baseTables.map((t) => formatTableReference2(t));
|
|
2728
|
+
this.metadata = metadata ? { ...metadata } : {};
|
|
2729
|
+
if (!this.metadata.source) {
|
|
2730
|
+
const stack = new Error().stack;
|
|
2731
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
2732
|
+
if (sourceInfo) {
|
|
2733
|
+
this.metadata.source = { file: sourceInfo };
|
|
2702
2734
|
}
|
|
2703
|
-
|
|
2735
|
+
}
|
|
2736
|
+
const views = getMooseInternal().views;
|
|
2737
|
+
if (!isClientOnlyMode() && views.has(this.name)) {
|
|
2738
|
+
throw new Error(`View with name ${this.name} already exists`);
|
|
2739
|
+
}
|
|
2740
|
+
views.set(this.name, this);
|
|
2704
2741
|
}
|
|
2705
2742
|
};
|
|
2706
2743
|
}
|
|
@@ -2904,6 +2941,18 @@ function getWebApps2() {
|
|
|
2904
2941
|
function getWebApp(name) {
|
|
2905
2942
|
return getMooseInternal().webApps.get(name);
|
|
2906
2943
|
}
|
|
2944
|
+
function getMaterializedViews() {
|
|
2945
|
+
return getMooseInternal().materializedViews;
|
|
2946
|
+
}
|
|
2947
|
+
function getMaterializedView(name) {
|
|
2948
|
+
return getMooseInternal().materializedViews.get(name);
|
|
2949
|
+
}
|
|
2950
|
+
function getViews() {
|
|
2951
|
+
return getMooseInternal().views;
|
|
2952
|
+
}
|
|
2953
|
+
function getView(name) {
|
|
2954
|
+
return getMooseInternal().views.get(name);
|
|
2955
|
+
}
|
|
2907
2956
|
var init_registry = __esm({
|
|
2908
2957
|
"src/dmv2/registry.ts"() {
|
|
2909
2958
|
"use strict";
|
|
@@ -2962,6 +3011,8 @@ export {
|
|
|
2962
3011
|
getApis2 as getApis,
|
|
2963
3012
|
getIngestApi,
|
|
2964
3013
|
getIngestApis,
|
|
3014
|
+
getMaterializedView,
|
|
3015
|
+
getMaterializedViews,
|
|
2965
3016
|
getSqlResource,
|
|
2966
3017
|
getSqlResources,
|
|
2967
3018
|
getStream,
|
|
@@ -2969,6 +3020,8 @@ export {
|
|
|
2969
3020
|
getTable,
|
|
2970
3021
|
getTables,
|
|
2971
3022
|
getValueFromParameter,
|
|
3023
|
+
getView,
|
|
3024
|
+
getViews,
|
|
2972
3025
|
getWebApp,
|
|
2973
3026
|
getWebApps2 as getWebApps,
|
|
2974
3027
|
getWorkflow,
|