@514labs/moose-lib 0.6.297 → 0.6.298
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/index.mjs
CHANGED
|
@@ -546,7 +546,9 @@ var init_internal = __esm({
|
|
|
546
546
|
apis: /* @__PURE__ */ new Map(),
|
|
547
547
|
sqlResources: /* @__PURE__ */ new Map(),
|
|
548
548
|
workflows: /* @__PURE__ */ new Map(),
|
|
549
|
-
webApps: /* @__PURE__ */ new Map()
|
|
549
|
+
webApps: /* @__PURE__ */ new Map(),
|
|
550
|
+
materializedViews: /* @__PURE__ */ new Map(),
|
|
551
|
+
views: /* @__PURE__ */ new Map()
|
|
550
552
|
};
|
|
551
553
|
defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
552
554
|
getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -562,6 +564,8 @@ var init_internal = __esm({
|
|
|
562
564
|
registry.sqlResources.clear();
|
|
563
565
|
registry.workflows.clear();
|
|
564
566
|
registry.webApps.clear();
|
|
567
|
+
registry.materializedViews.clear();
|
|
568
|
+
registry.views.clear();
|
|
565
569
|
const appDir = `${process2.cwd()}/${getSourceDir()}`;
|
|
566
570
|
Object.keys(__require.cache).forEach((key) => {
|
|
567
571
|
if (key.startsWith(appDir)) {
|
|
@@ -2460,6 +2464,93 @@ var init_etlPipeline = __esm({
|
|
|
2460
2464
|
}
|
|
2461
2465
|
});
|
|
2462
2466
|
|
|
2467
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2468
|
+
function formatTableReference(table) {
|
|
2469
|
+
const database = table instanceof OlapTable ? table.config.database : void 0;
|
|
2470
|
+
if (database) {
|
|
2471
|
+
return `\`${database}\`.\`${table.name}\``;
|
|
2472
|
+
}
|
|
2473
|
+
return `\`${table.name}\``;
|
|
2474
|
+
}
|
|
2475
|
+
var requireTargetTableName, MaterializedView;
|
|
2476
|
+
var init_materializedView = __esm({
|
|
2477
|
+
"src/dmv2/sdk/materializedView.ts"() {
|
|
2478
|
+
"use strict";
|
|
2479
|
+
init_helpers();
|
|
2480
|
+
init_sqlHelpers();
|
|
2481
|
+
init_olapTable();
|
|
2482
|
+
init_internal();
|
|
2483
|
+
init_stackTrace();
|
|
2484
|
+
requireTargetTableName = (tableName) => {
|
|
2485
|
+
if (typeof tableName === "string") {
|
|
2486
|
+
return tableName;
|
|
2487
|
+
} else {
|
|
2488
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2489
|
+
}
|
|
2490
|
+
};
|
|
2491
|
+
MaterializedView = class {
|
|
2492
|
+
/** @internal */
|
|
2493
|
+
kind = "MaterializedView";
|
|
2494
|
+
/** The name of the materialized view */
|
|
2495
|
+
name;
|
|
2496
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2497
|
+
targetTable;
|
|
2498
|
+
/** The SELECT SQL statement */
|
|
2499
|
+
selectSql;
|
|
2500
|
+
/** Names of source tables that the SELECT reads from */
|
|
2501
|
+
sourceTables;
|
|
2502
|
+
/** Optional metadata for the materialized view */
|
|
2503
|
+
metadata;
|
|
2504
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2505
|
+
let selectStatement = options.selectStatement;
|
|
2506
|
+
if (typeof selectStatement !== "string") {
|
|
2507
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2508
|
+
}
|
|
2509
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2510
|
+
throw new Error(
|
|
2511
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2512
|
+
);
|
|
2513
|
+
}
|
|
2514
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2515
|
+
requireTargetTableName(
|
|
2516
|
+
options.targetTable?.name ?? options.tableName
|
|
2517
|
+
),
|
|
2518
|
+
{
|
|
2519
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2520
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2521
|
+
},
|
|
2522
|
+
targetSchema,
|
|
2523
|
+
targetColumns
|
|
2524
|
+
);
|
|
2525
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2526
|
+
throw new Error(
|
|
2527
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2528
|
+
);
|
|
2529
|
+
}
|
|
2530
|
+
this.name = options.materializedViewName;
|
|
2531
|
+
this.targetTable = targetTable;
|
|
2532
|
+
this.selectSql = selectStatement;
|
|
2533
|
+
this.sourceTables = options.selectTables.map(
|
|
2534
|
+
(t) => formatTableReference(t)
|
|
2535
|
+
);
|
|
2536
|
+
this.metadata = options.metadata ? { ...options.metadata } : {};
|
|
2537
|
+
if (!this.metadata.source) {
|
|
2538
|
+
const stack = new Error().stack;
|
|
2539
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
2540
|
+
if (sourceInfo) {
|
|
2541
|
+
this.metadata.source = { file: sourceInfo };
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
const materializedViews = getMooseInternal().materializedViews;
|
|
2545
|
+
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2546
|
+
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2547
|
+
}
|
|
2548
|
+
materializedViews.set(this.name, this);
|
|
2549
|
+
}
|
|
2550
|
+
};
|
|
2551
|
+
}
|
|
2552
|
+
});
|
|
2553
|
+
|
|
2463
2554
|
// src/dmv2/sdk/sqlResource.ts
|
|
2464
2555
|
var SqlResource;
|
|
2465
2556
|
var init_sqlResource = __esm({
|
|
@@ -2523,104 +2614,60 @@ var init_sqlResource = __esm({
|
|
|
2523
2614
|
}
|
|
2524
2615
|
});
|
|
2525
2616
|
|
|
2526
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2527
|
-
var requireTargetTableName, MaterializedView;
|
|
2528
|
-
var init_materializedView = __esm({
|
|
2529
|
-
"src/dmv2/sdk/materializedView.ts"() {
|
|
2530
|
-
"use strict";
|
|
2531
|
-
init_helpers();
|
|
2532
|
-
init_sqlHelpers();
|
|
2533
|
-
init_olapTable();
|
|
2534
|
-
init_sqlResource();
|
|
2535
|
-
requireTargetTableName = (tableName) => {
|
|
2536
|
-
if (typeof tableName === "string") {
|
|
2537
|
-
return tableName;
|
|
2538
|
-
} else {
|
|
2539
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2540
|
-
}
|
|
2541
|
-
};
|
|
2542
|
-
MaterializedView = class extends SqlResource {
|
|
2543
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2544
|
-
targetTable;
|
|
2545
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2546
|
-
let selectStatement = options.selectStatement;
|
|
2547
|
-
if (typeof selectStatement !== "string") {
|
|
2548
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2549
|
-
}
|
|
2550
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2551
|
-
throw new Error(
|
|
2552
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2553
|
-
);
|
|
2554
|
-
}
|
|
2555
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2556
|
-
requireTargetTableName(
|
|
2557
|
-
options.targetTable?.name ?? options.tableName
|
|
2558
|
-
),
|
|
2559
|
-
{
|
|
2560
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2561
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2562
|
-
},
|
|
2563
|
-
targetSchema,
|
|
2564
|
-
targetColumns
|
|
2565
|
-
);
|
|
2566
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2567
|
-
throw new Error(
|
|
2568
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2569
|
-
);
|
|
2570
|
-
}
|
|
2571
|
-
super(
|
|
2572
|
-
options.materializedViewName,
|
|
2573
|
-
[
|
|
2574
|
-
createMaterializedView({
|
|
2575
|
-
name: options.materializedViewName,
|
|
2576
|
-
destinationTable: targetTable.name,
|
|
2577
|
-
select: selectStatement
|
|
2578
|
-
})
|
|
2579
|
-
// Population is now handled automatically by Rust infrastructure
|
|
2580
|
-
// based on table engine type and whether this is a new or updated view
|
|
2581
|
-
],
|
|
2582
|
-
[dropView(options.materializedViewName)],
|
|
2583
|
-
{
|
|
2584
|
-
pullsDataFrom: options.selectTables,
|
|
2585
|
-
pushesDataTo: [targetTable]
|
|
2586
|
-
}
|
|
2587
|
-
);
|
|
2588
|
-
this.targetTable = targetTable;
|
|
2589
|
-
}
|
|
2590
|
-
};
|
|
2591
|
-
}
|
|
2592
|
-
});
|
|
2593
|
-
|
|
2594
2617
|
// src/dmv2/sdk/view.ts
|
|
2618
|
+
function formatTableReference2(table) {
|
|
2619
|
+
const database = table instanceof OlapTable ? table.config.database : void 0;
|
|
2620
|
+
if (database) {
|
|
2621
|
+
return `\`${database}\`.\`${table.name}\``;
|
|
2622
|
+
}
|
|
2623
|
+
return `\`${table.name}\``;
|
|
2624
|
+
}
|
|
2595
2625
|
var View;
|
|
2596
2626
|
var init_view = __esm({
|
|
2597
2627
|
"src/dmv2/sdk/view.ts"() {
|
|
2598
2628
|
"use strict";
|
|
2599
|
-
init_helpers();
|
|
2600
2629
|
init_sqlHelpers();
|
|
2601
|
-
|
|
2602
|
-
|
|
2630
|
+
init_olapTable();
|
|
2631
|
+
init_internal();
|
|
2632
|
+
init_stackTrace();
|
|
2633
|
+
View = class {
|
|
2634
|
+
/** @internal */
|
|
2635
|
+
kind = "View";
|
|
2636
|
+
/** The name of the view */
|
|
2637
|
+
name;
|
|
2638
|
+
/** The SELECT SQL statement that defines the view */
|
|
2639
|
+
selectSql;
|
|
2640
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
2641
|
+
sourceTables;
|
|
2642
|
+
/** Optional metadata for the view */
|
|
2643
|
+
metadata;
|
|
2603
2644
|
/**
|
|
2604
2645
|
* Creates a new View instance.
|
|
2605
2646
|
* @param name The name of the view to be created.
|
|
2606
2647
|
* @param selectStatement The SQL SELECT statement that defines the view's logic.
|
|
2607
2648
|
* @param baseTables An array of OlapTable or View objects that the `selectStatement` reads from. Used for dependency tracking.
|
|
2649
|
+
* @param metadata Optional metadata for the view (e.g., description, source file).
|
|
2608
2650
|
*/
|
|
2609
|
-
constructor(name, selectStatement, baseTables) {
|
|
2651
|
+
constructor(name, selectStatement, baseTables, metadata) {
|
|
2610
2652
|
if (typeof selectStatement !== "string") {
|
|
2611
2653
|
selectStatement = toStaticQuery(selectStatement);
|
|
2612
2654
|
}
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
{
|
|
2621
|
-
|
|
2655
|
+
this.name = name;
|
|
2656
|
+
this.selectSql = selectStatement;
|
|
2657
|
+
this.sourceTables = baseTables.map((t) => formatTableReference2(t));
|
|
2658
|
+
this.metadata = metadata ? { ...metadata } : {};
|
|
2659
|
+
if (!this.metadata.source) {
|
|
2660
|
+
const stack = new Error().stack;
|
|
2661
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
2662
|
+
if (sourceInfo) {
|
|
2663
|
+
this.metadata.source = { file: sourceInfo };
|
|
2622
2664
|
}
|
|
2623
|
-
|
|
2665
|
+
}
|
|
2666
|
+
const views = getMooseInternal().views;
|
|
2667
|
+
if (!isClientOnlyMode() && views.has(this.name)) {
|
|
2668
|
+
throw new Error(`View with name ${this.name} already exists`);
|
|
2669
|
+
}
|
|
2670
|
+
views.set(this.name, this);
|
|
2624
2671
|
}
|
|
2625
2672
|
};
|
|
2626
2673
|
}
|
|
@@ -2824,6 +2871,18 @@ function getWebApps() {
|
|
|
2824
2871
|
function getWebApp(name) {
|
|
2825
2872
|
return getMooseInternal().webApps.get(name);
|
|
2826
2873
|
}
|
|
2874
|
+
function getMaterializedViews() {
|
|
2875
|
+
return getMooseInternal().materializedViews;
|
|
2876
|
+
}
|
|
2877
|
+
function getMaterializedView(name) {
|
|
2878
|
+
return getMooseInternal().materializedViews.get(name);
|
|
2879
|
+
}
|
|
2880
|
+
function getViews() {
|
|
2881
|
+
return getMooseInternal().views;
|
|
2882
|
+
}
|
|
2883
|
+
function getView(name) {
|
|
2884
|
+
return getMooseInternal().views.get(name);
|
|
2885
|
+
}
|
|
2827
2886
|
var init_registry = __esm({
|
|
2828
2887
|
"src/dmv2/registry.ts"() {
|
|
2829
2888
|
"use strict";
|
|
@@ -3733,6 +3792,8 @@ export {
|
|
|
3733
3792
|
getKafkaClient,
|
|
3734
3793
|
getKafkaProducer,
|
|
3735
3794
|
getLegacyMooseUtils,
|
|
3795
|
+
getMaterializedView,
|
|
3796
|
+
getMaterializedViews,
|
|
3736
3797
|
getMooseClients,
|
|
3737
3798
|
getMooseUtils,
|
|
3738
3799
|
getMooseUtilsFromRequest,
|
|
@@ -3744,6 +3805,8 @@ export {
|
|
|
3744
3805
|
getTables,
|
|
3745
3806
|
getTemporalClient,
|
|
3746
3807
|
getValueFromParameter,
|
|
3808
|
+
getView,
|
|
3809
|
+
getViews,
|
|
3747
3810
|
getWebApp,
|
|
3748
3811
|
getWebApps,
|
|
3749
3812
|
getWorkflow,
|