@514labs/moose-lib 0.6.297-ci-35-g4e0a867f → 0.6.297-ci-23-g751e4221
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.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
|
+
customViews: /* @__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.customViews.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,84 @@ var init_etlPipeline = __esm({
|
|
|
2460
2464
|
}
|
|
2461
2465
|
});
|
|
2462
2466
|
|
|
2467
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2468
|
+
var requireTargetTableName, MaterializedView;
|
|
2469
|
+
var init_materializedView = __esm({
|
|
2470
|
+
"src/dmv2/sdk/materializedView.ts"() {
|
|
2471
|
+
"use strict";
|
|
2472
|
+
init_helpers();
|
|
2473
|
+
init_sqlHelpers();
|
|
2474
|
+
init_olapTable();
|
|
2475
|
+
init_internal();
|
|
2476
|
+
init_stackTrace();
|
|
2477
|
+
requireTargetTableName = (tableName) => {
|
|
2478
|
+
if (typeof tableName === "string") {
|
|
2479
|
+
return tableName;
|
|
2480
|
+
} else {
|
|
2481
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2482
|
+
}
|
|
2483
|
+
};
|
|
2484
|
+
MaterializedView = class {
|
|
2485
|
+
/** @internal */
|
|
2486
|
+
kind = "MaterializedView";
|
|
2487
|
+
/** The name of the materialized view */
|
|
2488
|
+
name;
|
|
2489
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2490
|
+
targetTable;
|
|
2491
|
+
/** The SELECT SQL statement */
|
|
2492
|
+
selectSql;
|
|
2493
|
+
/** Names of source tables that the SELECT reads from */
|
|
2494
|
+
sourceTables;
|
|
2495
|
+
/** Optional metadata for the materialized view */
|
|
2496
|
+
metadata;
|
|
2497
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2498
|
+
let selectStatement = options.selectStatement;
|
|
2499
|
+
if (typeof selectStatement !== "string") {
|
|
2500
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2501
|
+
}
|
|
2502
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2503
|
+
throw new Error(
|
|
2504
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2505
|
+
);
|
|
2506
|
+
}
|
|
2507
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2508
|
+
requireTargetTableName(
|
|
2509
|
+
options.targetTable?.name ?? options.tableName
|
|
2510
|
+
),
|
|
2511
|
+
{
|
|
2512
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2513
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2514
|
+
},
|
|
2515
|
+
targetSchema,
|
|
2516
|
+
targetColumns
|
|
2517
|
+
);
|
|
2518
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2519
|
+
throw new Error(
|
|
2520
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2521
|
+
);
|
|
2522
|
+
}
|
|
2523
|
+
this.name = options.materializedViewName;
|
|
2524
|
+
this.targetTable = targetTable;
|
|
2525
|
+
this.selectSql = selectStatement;
|
|
2526
|
+
this.sourceTables = options.selectTables.map((t) => t.name);
|
|
2527
|
+
this.metadata = options.metadata ? { ...options.metadata } : {};
|
|
2528
|
+
if (!this.metadata.source) {
|
|
2529
|
+
const stack = new Error().stack;
|
|
2530
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
2531
|
+
if (sourceInfo) {
|
|
2532
|
+
this.metadata.source = { file: sourceInfo };
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
const materializedViews = getMooseInternal().materializedViews;
|
|
2536
|
+
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2537
|
+
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2538
|
+
}
|
|
2539
|
+
materializedViews.set(this.name, this);
|
|
2540
|
+
}
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
});
|
|
2544
|
+
|
|
2463
2545
|
// src/dmv2/sdk/sqlResource.ts
|
|
2464
2546
|
var SqlResource;
|
|
2465
2547
|
var init_sqlResource = __esm({
|
|
@@ -2523,104 +2605,52 @@ var init_sqlResource = __esm({
|
|
|
2523
2605
|
}
|
|
2524
2606
|
});
|
|
2525
2607
|
|
|
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
2608
|
// src/dmv2/sdk/view.ts
|
|
2595
2609
|
var View;
|
|
2596
2610
|
var init_view = __esm({
|
|
2597
2611
|
"src/dmv2/sdk/view.ts"() {
|
|
2598
2612
|
"use strict";
|
|
2599
|
-
init_helpers();
|
|
2600
2613
|
init_sqlHelpers();
|
|
2601
|
-
|
|
2602
|
-
|
|
2614
|
+
init_internal();
|
|
2615
|
+
init_stackTrace();
|
|
2616
|
+
View = class {
|
|
2617
|
+
/** @internal */
|
|
2618
|
+
kind = "CustomView";
|
|
2619
|
+
/** The name of the view */
|
|
2620
|
+
name;
|
|
2621
|
+
/** The SELECT SQL statement that defines the view */
|
|
2622
|
+
selectSql;
|
|
2623
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
2624
|
+
sourceTables;
|
|
2625
|
+
/** Optional metadata for the view */
|
|
2626
|
+
metadata;
|
|
2603
2627
|
/**
|
|
2604
2628
|
* Creates a new View instance.
|
|
2605
2629
|
* @param name The name of the view to be created.
|
|
2606
2630
|
* @param selectStatement The SQL SELECT statement that defines the view's logic.
|
|
2607
2631
|
* @param baseTables An array of OlapTable or View objects that the `selectStatement` reads from. Used for dependency tracking.
|
|
2632
|
+
* @param metadata Optional metadata for the view (e.g., description, source file).
|
|
2608
2633
|
*/
|
|
2609
|
-
constructor(name, selectStatement, baseTables) {
|
|
2634
|
+
constructor(name, selectStatement, baseTables, metadata) {
|
|
2610
2635
|
if (typeof selectStatement !== "string") {
|
|
2611
2636
|
selectStatement = toStaticQuery(selectStatement);
|
|
2612
2637
|
}
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
{
|
|
2621
|
-
|
|
2638
|
+
this.name = name;
|
|
2639
|
+
this.selectSql = selectStatement;
|
|
2640
|
+
this.sourceTables = baseTables.map((t) => t.name);
|
|
2641
|
+
this.metadata = metadata ? { ...metadata } : {};
|
|
2642
|
+
if (!this.metadata.source) {
|
|
2643
|
+
const stack = new Error().stack;
|
|
2644
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
2645
|
+
if (sourceInfo) {
|
|
2646
|
+
this.metadata.source = { file: sourceInfo };
|
|
2622
2647
|
}
|
|
2623
|
-
|
|
2648
|
+
}
|
|
2649
|
+
const customViews = getMooseInternal().customViews;
|
|
2650
|
+
if (!isClientOnlyMode() && customViews.has(this.name)) {
|
|
2651
|
+
throw new Error(`View with name ${this.name} already exists`);
|
|
2652
|
+
}
|
|
2653
|
+
customViews.set(this.name, this);
|
|
2624
2654
|
}
|
|
2625
2655
|
};
|
|
2626
2656
|
}
|
|
@@ -2824,6 +2854,18 @@ function getWebApps() {
|
|
|
2824
2854
|
function getWebApp(name) {
|
|
2825
2855
|
return getMooseInternal().webApps.get(name);
|
|
2826
2856
|
}
|
|
2857
|
+
function getMaterializedViews() {
|
|
2858
|
+
return getMooseInternal().materializedViews;
|
|
2859
|
+
}
|
|
2860
|
+
function getMaterializedView(name) {
|
|
2861
|
+
return getMooseInternal().materializedViews.get(name);
|
|
2862
|
+
}
|
|
2863
|
+
function getCustomViews() {
|
|
2864
|
+
return getMooseInternal().customViews;
|
|
2865
|
+
}
|
|
2866
|
+
function getCustomView(name) {
|
|
2867
|
+
return getMooseInternal().customViews.get(name);
|
|
2868
|
+
}
|
|
2827
2869
|
var init_registry = __esm({
|
|
2828
2870
|
"src/dmv2/registry.ts"() {
|
|
2829
2871
|
"use strict";
|
|
@@ -3727,12 +3769,16 @@ export {
|
|
|
3727
3769
|
getApi,
|
|
3728
3770
|
getApis,
|
|
3729
3771
|
getClickhouseClient,
|
|
3772
|
+
getCustomView,
|
|
3773
|
+
getCustomViews,
|
|
3730
3774
|
getFileName,
|
|
3731
3775
|
getIngestApi,
|
|
3732
3776
|
getIngestApis,
|
|
3733
3777
|
getKafkaClient,
|
|
3734
3778
|
getKafkaProducer,
|
|
3735
3779
|
getLegacyMooseUtils,
|
|
3780
|
+
getMaterializedView,
|
|
3781
|
+
getMaterializedViews,
|
|
3736
3782
|
getMooseClients,
|
|
3737
3783
|
getMooseUtils,
|
|
3738
3784
|
getMooseUtilsFromRequest,
|