@514labs/moose-lib 0.6.297-ci-35-g4e0a867f → 0.6.297-ci-24-g9a20c7e5
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-CkJwv4dC.d.mts} +1 -1
- package/dist/{browserCompatible-CMEunMFq.d.ts → browserCompatible-Dqfdy6x5.d.ts} +1 -1
- package/dist/browserCompatible.d.mts +2 -2
- package/dist/browserCompatible.d.ts +2 -2
- package/dist/browserCompatible.js +131 -91
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +127 -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 +131 -91
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +127 -91
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-CcHF2cVT.d.mts → index-CdKEq7FH.d.mts} +96 -43
- package/dist/{index-CcHF2cVT.d.ts → index-CdKEq7FH.d.ts} +96 -43
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +133 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +129 -83
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +41 -14
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +41 -14
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -562,7 +562,9 @@ var init_internal = __esm({
|
|
|
562
562
|
apis: /* @__PURE__ */ new Map(),
|
|
563
563
|
sqlResources: /* @__PURE__ */ new Map(),
|
|
564
564
|
workflows: /* @__PURE__ */ new Map(),
|
|
565
|
-
webApps: /* @__PURE__ */ new Map()
|
|
565
|
+
webApps: /* @__PURE__ */ new Map(),
|
|
566
|
+
materializedViews: /* @__PURE__ */ new Map(),
|
|
567
|
+
customViews: /* @__PURE__ */ new Map()
|
|
566
568
|
};
|
|
567
569
|
defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
568
570
|
getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -578,6 +580,8 @@ var init_internal = __esm({
|
|
|
578
580
|
registry.sqlResources.clear();
|
|
579
581
|
registry.workflows.clear();
|
|
580
582
|
registry.webApps.clear();
|
|
583
|
+
registry.materializedViews.clear();
|
|
584
|
+
registry.customViews.clear();
|
|
581
585
|
const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
|
|
582
586
|
Object.keys(require.cache).forEach((key) => {
|
|
583
587
|
if (key.startsWith(appDir)) {
|
|
@@ -2476,6 +2480,84 @@ var init_etlPipeline = __esm({
|
|
|
2476
2480
|
}
|
|
2477
2481
|
});
|
|
2478
2482
|
|
|
2483
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2484
|
+
var requireTargetTableName, MaterializedView;
|
|
2485
|
+
var init_materializedView = __esm({
|
|
2486
|
+
"src/dmv2/sdk/materializedView.ts"() {
|
|
2487
|
+
"use strict";
|
|
2488
|
+
init_helpers();
|
|
2489
|
+
init_sqlHelpers();
|
|
2490
|
+
init_olapTable();
|
|
2491
|
+
init_internal();
|
|
2492
|
+
init_stackTrace();
|
|
2493
|
+
requireTargetTableName = (tableName) => {
|
|
2494
|
+
if (typeof tableName === "string") {
|
|
2495
|
+
return tableName;
|
|
2496
|
+
} else {
|
|
2497
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2498
|
+
}
|
|
2499
|
+
};
|
|
2500
|
+
MaterializedView = class {
|
|
2501
|
+
/** @internal */
|
|
2502
|
+
kind = "MaterializedView";
|
|
2503
|
+
/** The name of the materialized view */
|
|
2504
|
+
name;
|
|
2505
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2506
|
+
targetTable;
|
|
2507
|
+
/** The SELECT SQL statement */
|
|
2508
|
+
selectSql;
|
|
2509
|
+
/** Names of source tables that the SELECT reads from */
|
|
2510
|
+
sourceTables;
|
|
2511
|
+
/** Optional metadata for the materialized view */
|
|
2512
|
+
metadata;
|
|
2513
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2514
|
+
let selectStatement = options.selectStatement;
|
|
2515
|
+
if (typeof selectStatement !== "string") {
|
|
2516
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2517
|
+
}
|
|
2518
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2519
|
+
throw new Error(
|
|
2520
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2521
|
+
);
|
|
2522
|
+
}
|
|
2523
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2524
|
+
requireTargetTableName(
|
|
2525
|
+
options.targetTable?.name ?? options.tableName
|
|
2526
|
+
),
|
|
2527
|
+
{
|
|
2528
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2529
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2530
|
+
},
|
|
2531
|
+
targetSchema,
|
|
2532
|
+
targetColumns
|
|
2533
|
+
);
|
|
2534
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2535
|
+
throw new Error(
|
|
2536
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2537
|
+
);
|
|
2538
|
+
}
|
|
2539
|
+
this.name = options.materializedViewName;
|
|
2540
|
+
this.targetTable = targetTable;
|
|
2541
|
+
this.selectSql = selectStatement;
|
|
2542
|
+
this.sourceTables = options.selectTables.map((t) => t.name);
|
|
2543
|
+
this.metadata = options.metadata ? { ...options.metadata } : {};
|
|
2544
|
+
if (!this.metadata.source) {
|
|
2545
|
+
const stack = new Error().stack;
|
|
2546
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
2547
|
+
if (sourceInfo) {
|
|
2548
|
+
this.metadata.source = { file: sourceInfo };
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
const materializedViews = getMooseInternal().materializedViews;
|
|
2552
|
+
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2553
|
+
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2554
|
+
}
|
|
2555
|
+
materializedViews.set(this.name, this);
|
|
2556
|
+
}
|
|
2557
|
+
};
|
|
2558
|
+
}
|
|
2559
|
+
});
|
|
2560
|
+
|
|
2479
2561
|
// src/dmv2/sdk/sqlResource.ts
|
|
2480
2562
|
var SqlResource;
|
|
2481
2563
|
var init_sqlResource = __esm({
|
|
@@ -2539,104 +2621,52 @@ var init_sqlResource = __esm({
|
|
|
2539
2621
|
}
|
|
2540
2622
|
});
|
|
2541
2623
|
|
|
2542
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2543
|
-
var requireTargetTableName, MaterializedView;
|
|
2544
|
-
var init_materializedView = __esm({
|
|
2545
|
-
"src/dmv2/sdk/materializedView.ts"() {
|
|
2546
|
-
"use strict";
|
|
2547
|
-
init_helpers();
|
|
2548
|
-
init_sqlHelpers();
|
|
2549
|
-
init_olapTable();
|
|
2550
|
-
init_sqlResource();
|
|
2551
|
-
requireTargetTableName = (tableName) => {
|
|
2552
|
-
if (typeof tableName === "string") {
|
|
2553
|
-
return tableName;
|
|
2554
|
-
} else {
|
|
2555
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2556
|
-
}
|
|
2557
|
-
};
|
|
2558
|
-
MaterializedView = class extends SqlResource {
|
|
2559
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2560
|
-
targetTable;
|
|
2561
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2562
|
-
let selectStatement = options.selectStatement;
|
|
2563
|
-
if (typeof selectStatement !== "string") {
|
|
2564
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2565
|
-
}
|
|
2566
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2567
|
-
throw new Error(
|
|
2568
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2569
|
-
);
|
|
2570
|
-
}
|
|
2571
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2572
|
-
requireTargetTableName(
|
|
2573
|
-
options.targetTable?.name ?? options.tableName
|
|
2574
|
-
),
|
|
2575
|
-
{
|
|
2576
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2577
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2578
|
-
},
|
|
2579
|
-
targetSchema,
|
|
2580
|
-
targetColumns
|
|
2581
|
-
);
|
|
2582
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2583
|
-
throw new Error(
|
|
2584
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2585
|
-
);
|
|
2586
|
-
}
|
|
2587
|
-
super(
|
|
2588
|
-
options.materializedViewName,
|
|
2589
|
-
[
|
|
2590
|
-
createMaterializedView({
|
|
2591
|
-
name: options.materializedViewName,
|
|
2592
|
-
destinationTable: targetTable.name,
|
|
2593
|
-
select: selectStatement
|
|
2594
|
-
})
|
|
2595
|
-
// Population is now handled automatically by Rust infrastructure
|
|
2596
|
-
// based on table engine type and whether this is a new or updated view
|
|
2597
|
-
],
|
|
2598
|
-
[dropView(options.materializedViewName)],
|
|
2599
|
-
{
|
|
2600
|
-
pullsDataFrom: options.selectTables,
|
|
2601
|
-
pushesDataTo: [targetTable]
|
|
2602
|
-
}
|
|
2603
|
-
);
|
|
2604
|
-
this.targetTable = targetTable;
|
|
2605
|
-
}
|
|
2606
|
-
};
|
|
2607
|
-
}
|
|
2608
|
-
});
|
|
2609
|
-
|
|
2610
2624
|
// src/dmv2/sdk/view.ts
|
|
2611
2625
|
var View;
|
|
2612
2626
|
var init_view = __esm({
|
|
2613
2627
|
"src/dmv2/sdk/view.ts"() {
|
|
2614
2628
|
"use strict";
|
|
2615
|
-
init_helpers();
|
|
2616
2629
|
init_sqlHelpers();
|
|
2617
|
-
|
|
2618
|
-
|
|
2630
|
+
init_internal();
|
|
2631
|
+
init_stackTrace();
|
|
2632
|
+
View = class {
|
|
2633
|
+
/** @internal */
|
|
2634
|
+
kind = "CustomView";
|
|
2635
|
+
/** The name of the view */
|
|
2636
|
+
name;
|
|
2637
|
+
/** The SELECT SQL statement that defines the view */
|
|
2638
|
+
selectSql;
|
|
2639
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
2640
|
+
sourceTables;
|
|
2641
|
+
/** Optional metadata for the view */
|
|
2642
|
+
metadata;
|
|
2619
2643
|
/**
|
|
2620
2644
|
* Creates a new View instance.
|
|
2621
2645
|
* @param name The name of the view to be created.
|
|
2622
2646
|
* @param selectStatement The SQL SELECT statement that defines the view's logic.
|
|
2623
2647
|
* @param baseTables An array of OlapTable or View objects that the `selectStatement` reads from. Used for dependency tracking.
|
|
2648
|
+
* @param metadata Optional metadata for the view (e.g., description, source file).
|
|
2624
2649
|
*/
|
|
2625
|
-
constructor(name, selectStatement, baseTables) {
|
|
2650
|
+
constructor(name, selectStatement, baseTables, metadata) {
|
|
2626
2651
|
if (typeof selectStatement !== "string") {
|
|
2627
2652
|
selectStatement = toStaticQuery(selectStatement);
|
|
2628
2653
|
}
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
{
|
|
2637
|
-
|
|
2654
|
+
this.name = name;
|
|
2655
|
+
this.selectSql = selectStatement;
|
|
2656
|
+
this.sourceTables = baseTables.map((t) => t.name);
|
|
2657
|
+
this.metadata = metadata ? { ...metadata } : {};
|
|
2658
|
+
if (!this.metadata.source) {
|
|
2659
|
+
const stack = new Error().stack;
|
|
2660
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
2661
|
+
if (sourceInfo) {
|
|
2662
|
+
this.metadata.source = { file: sourceInfo };
|
|
2638
2663
|
}
|
|
2639
|
-
|
|
2664
|
+
}
|
|
2665
|
+
const customViews = getMooseInternal().customViews;
|
|
2666
|
+
if (!isClientOnlyMode() && customViews.has(this.name)) {
|
|
2667
|
+
throw new Error(`View with name ${this.name} already exists`);
|
|
2668
|
+
}
|
|
2669
|
+
customViews.set(this.name, this);
|
|
2640
2670
|
}
|
|
2641
2671
|
};
|
|
2642
2672
|
}
|
|
@@ -2840,6 +2870,18 @@ function getWebApps() {
|
|
|
2840
2870
|
function getWebApp(name) {
|
|
2841
2871
|
return getMooseInternal().webApps.get(name);
|
|
2842
2872
|
}
|
|
2873
|
+
function getMaterializedViews() {
|
|
2874
|
+
return getMooseInternal().materializedViews;
|
|
2875
|
+
}
|
|
2876
|
+
function getMaterializedView(name) {
|
|
2877
|
+
return getMooseInternal().materializedViews.get(name);
|
|
2878
|
+
}
|
|
2879
|
+
function getCustomViews() {
|
|
2880
|
+
return getMooseInternal().customViews;
|
|
2881
|
+
}
|
|
2882
|
+
function getCustomView(name) {
|
|
2883
|
+
return getMooseInternal().customViews.get(name);
|
|
2884
|
+
}
|
|
2843
2885
|
var init_registry = __esm({
|
|
2844
2886
|
"src/dmv2/registry.ts"() {
|
|
2845
2887
|
"use strict";
|
|
@@ -3722,12 +3764,16 @@ __export(index_exports, {
|
|
|
3722
3764
|
getApi: () => getApi,
|
|
3723
3765
|
getApis: () => getApis,
|
|
3724
3766
|
getClickhouseClient: () => getClickhouseClient,
|
|
3767
|
+
getCustomView: () => getCustomView,
|
|
3768
|
+
getCustomViews: () => getCustomViews,
|
|
3725
3769
|
getFileName: () => getFileName,
|
|
3726
3770
|
getIngestApi: () => getIngestApi,
|
|
3727
3771
|
getIngestApis: () => getIngestApis,
|
|
3728
3772
|
getKafkaClient: () => getKafkaClient,
|
|
3729
3773
|
getKafkaProducer: () => getKafkaProducer,
|
|
3730
3774
|
getLegacyMooseUtils: () => getLegacyMooseUtils,
|
|
3775
|
+
getMaterializedView: () => getMaterializedView,
|
|
3776
|
+
getMaterializedViews: () => getMaterializedViews,
|
|
3731
3777
|
getMooseClients: () => getMooseClients,
|
|
3732
3778
|
getMooseUtils: () => getMooseUtils,
|
|
3733
3779
|
getMooseUtilsFromRequest: () => getMooseUtilsFromRequest,
|
|
@@ -3830,12 +3876,16 @@ init_index();
|
|
|
3830
3876
|
getApi,
|
|
3831
3877
|
getApis,
|
|
3832
3878
|
getClickhouseClient,
|
|
3879
|
+
getCustomView,
|
|
3880
|
+
getCustomViews,
|
|
3833
3881
|
getFileName,
|
|
3834
3882
|
getIngestApi,
|
|
3835
3883
|
getIngestApis,
|
|
3836
3884
|
getKafkaClient,
|
|
3837
3885
|
getKafkaProducer,
|
|
3838
3886
|
getLegacyMooseUtils,
|
|
3887
|
+
getMaterializedView,
|
|
3888
|
+
getMaterializedViews,
|
|
3839
3889
|
getMooseClients,
|
|
3840
3890
|
getMooseUtils,
|
|
3841
3891
|
getMooseUtilsFromRequest,
|