@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/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
|
+
customViews: /* @__PURE__ */ new Map()
|
|
578
572
|
};
|
|
579
573
|
defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
580
574
|
getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -2455,6 +2449,84 @@ var init_etlPipeline = __esm({
|
|
|
2455
2449
|
}
|
|
2456
2450
|
});
|
|
2457
2451
|
|
|
2452
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2453
|
+
var requireTargetTableName, MaterializedView;
|
|
2454
|
+
var init_materializedView = __esm({
|
|
2455
|
+
"src/dmv2/sdk/materializedView.ts"() {
|
|
2456
|
+
"use strict";
|
|
2457
|
+
init_helpers();
|
|
2458
|
+
init_sqlHelpers();
|
|
2459
|
+
init_olapTable();
|
|
2460
|
+
init_internal();
|
|
2461
|
+
init_stackTrace();
|
|
2462
|
+
requireTargetTableName = (tableName) => {
|
|
2463
|
+
if (typeof tableName === "string") {
|
|
2464
|
+
return tableName;
|
|
2465
|
+
} else {
|
|
2466
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2467
|
+
}
|
|
2468
|
+
};
|
|
2469
|
+
MaterializedView = class {
|
|
2470
|
+
/** @internal */
|
|
2471
|
+
kind = "MaterializedView";
|
|
2472
|
+
/** The name of the materialized view */
|
|
2473
|
+
name;
|
|
2474
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2475
|
+
targetTable;
|
|
2476
|
+
/** The SELECT SQL statement */
|
|
2477
|
+
selectSql;
|
|
2478
|
+
/** Names of source tables that the SELECT reads from */
|
|
2479
|
+
sourceTables;
|
|
2480
|
+
/** Optional metadata for the materialized view */
|
|
2481
|
+
metadata;
|
|
2482
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2483
|
+
let selectStatement = options.selectStatement;
|
|
2484
|
+
if (typeof selectStatement !== "string") {
|
|
2485
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2486
|
+
}
|
|
2487
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2488
|
+
throw new Error(
|
|
2489
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2490
|
+
);
|
|
2491
|
+
}
|
|
2492
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2493
|
+
requireTargetTableName(
|
|
2494
|
+
options.targetTable?.name ?? options.tableName
|
|
2495
|
+
),
|
|
2496
|
+
{
|
|
2497
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2498
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2499
|
+
},
|
|
2500
|
+
targetSchema,
|
|
2501
|
+
targetColumns
|
|
2502
|
+
);
|
|
2503
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2504
|
+
throw new Error(
|
|
2505
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2506
|
+
);
|
|
2507
|
+
}
|
|
2508
|
+
this.name = options.materializedViewName;
|
|
2509
|
+
this.targetTable = targetTable;
|
|
2510
|
+
this.selectSql = selectStatement;
|
|
2511
|
+
this.sourceTables = options.selectTables.map((t) => t.name);
|
|
2512
|
+
this.metadata = options.metadata ? { ...options.metadata } : {};
|
|
2513
|
+
if (!this.metadata.source) {
|
|
2514
|
+
const stack = new Error().stack;
|
|
2515
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
2516
|
+
if (sourceInfo) {
|
|
2517
|
+
this.metadata.source = { file: sourceInfo };
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
const materializedViews = getMooseInternal().materializedViews;
|
|
2521
|
+
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2522
|
+
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2523
|
+
}
|
|
2524
|
+
materializedViews.set(this.name, this);
|
|
2525
|
+
}
|
|
2526
|
+
};
|
|
2527
|
+
}
|
|
2528
|
+
});
|
|
2529
|
+
|
|
2458
2530
|
// src/dmv2/sdk/sqlResource.ts
|
|
2459
2531
|
var SqlResource;
|
|
2460
2532
|
var init_sqlResource = __esm({
|
|
@@ -2518,104 +2590,52 @@ var init_sqlResource = __esm({
|
|
|
2518
2590
|
}
|
|
2519
2591
|
});
|
|
2520
2592
|
|
|
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
2593
|
// src/dmv2/sdk/view.ts
|
|
2590
2594
|
var View;
|
|
2591
2595
|
var init_view = __esm({
|
|
2592
2596
|
"src/dmv2/sdk/view.ts"() {
|
|
2593
2597
|
"use strict";
|
|
2594
|
-
init_helpers();
|
|
2595
2598
|
init_sqlHelpers();
|
|
2596
|
-
|
|
2597
|
-
|
|
2599
|
+
init_internal();
|
|
2600
|
+
init_stackTrace();
|
|
2601
|
+
View = class {
|
|
2602
|
+
/** @internal */
|
|
2603
|
+
kind = "CustomView";
|
|
2604
|
+
/** The name of the view */
|
|
2605
|
+
name;
|
|
2606
|
+
/** The SELECT SQL statement that defines the view */
|
|
2607
|
+
selectSql;
|
|
2608
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
2609
|
+
sourceTables;
|
|
2610
|
+
/** Optional metadata for the view */
|
|
2611
|
+
metadata;
|
|
2598
2612
|
/**
|
|
2599
2613
|
* Creates a new View instance.
|
|
2600
2614
|
* @param name The name of the view to be created.
|
|
2601
2615
|
* @param selectStatement The SQL SELECT statement that defines the view's logic.
|
|
2602
2616
|
* @param baseTables An array of OlapTable or View objects that the `selectStatement` reads from. Used for dependency tracking.
|
|
2617
|
+
* @param metadata Optional metadata for the view (e.g., description, source file).
|
|
2603
2618
|
*/
|
|
2604
|
-
constructor(name, selectStatement, baseTables) {
|
|
2619
|
+
constructor(name, selectStatement, baseTables, metadata) {
|
|
2605
2620
|
if (typeof selectStatement !== "string") {
|
|
2606
2621
|
selectStatement = toStaticQuery(selectStatement);
|
|
2607
2622
|
}
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
{
|
|
2616
|
-
|
|
2623
|
+
this.name = name;
|
|
2624
|
+
this.selectSql = selectStatement;
|
|
2625
|
+
this.sourceTables = baseTables.map((t) => t.name);
|
|
2626
|
+
this.metadata = metadata ? { ...metadata } : {};
|
|
2627
|
+
if (!this.metadata.source) {
|
|
2628
|
+
const stack = new Error().stack;
|
|
2629
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
2630
|
+
if (sourceInfo) {
|
|
2631
|
+
this.metadata.source = { file: sourceInfo };
|
|
2617
2632
|
}
|
|
2618
|
-
|
|
2633
|
+
}
|
|
2634
|
+
const customViews = getMooseInternal().customViews;
|
|
2635
|
+
if (!isClientOnlyMode() && customViews.has(this.name)) {
|
|
2636
|
+
throw new Error(`View with name ${this.name} already exists`);
|
|
2637
|
+
}
|
|
2638
|
+
customViews.set(this.name, this);
|
|
2619
2639
|
}
|
|
2620
2640
|
};
|
|
2621
2641
|
}
|
|
@@ -2819,6 +2839,18 @@ function getWebApps() {
|
|
|
2819
2839
|
function getWebApp(name) {
|
|
2820
2840
|
return getMooseInternal().webApps.get(name);
|
|
2821
2841
|
}
|
|
2842
|
+
function getMaterializedViews() {
|
|
2843
|
+
return getMooseInternal().materializedViews;
|
|
2844
|
+
}
|
|
2845
|
+
function getMaterializedView(name) {
|
|
2846
|
+
return getMooseInternal().materializedViews.get(name);
|
|
2847
|
+
}
|
|
2848
|
+
function getCustomViews() {
|
|
2849
|
+
return getMooseInternal().customViews;
|
|
2850
|
+
}
|
|
2851
|
+
function getCustomView(name) {
|
|
2852
|
+
return getMooseInternal().customViews.get(name);
|
|
2853
|
+
}
|
|
2822
2854
|
var init_registry = __esm({
|
|
2823
2855
|
"src/dmv2/registry.ts"() {
|
|
2824
2856
|
"use strict";
|
|
@@ -2863,8 +2895,12 @@ export {
|
|
|
2863
2895
|
Workflow,
|
|
2864
2896
|
getApi,
|
|
2865
2897
|
getApis,
|
|
2898
|
+
getCustomView,
|
|
2899
|
+
getCustomViews,
|
|
2866
2900
|
getIngestApi,
|
|
2867
2901
|
getIngestApis,
|
|
2902
|
+
getMaterializedView,
|
|
2903
|
+
getMaterializedViews,
|
|
2868
2904
|
getSqlResource,
|
|
2869
2905
|
getSqlResources,
|
|
2870
2906
|
getStream,
|