@514labs/moose-lib 0.6.288 → 0.6.289-ci-9-g221fb3d9
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-15NCyT1P.d.mts → browserCompatible-DCCiBirg.d.mts} +1 -1
- package/dist/{browserCompatible-BUKAJYbj.d.ts → browserCompatible-DhVPp9qX.d.ts} +1 -1
- package/dist/browserCompatible.d.mts +2 -2
- package/dist/browserCompatible.d.ts +2 -2
- package/dist/browserCompatible.js +115 -86
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +111 -86
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/compilerPlugin.js +4 -1
- package/dist/compilerPlugin.js.map +1 -1
- package/dist/compilerPlugin.mjs +5 -1
- package/dist/compilerPlugin.mjs.map +1 -1
- package/dist/dataModels/toDataModels.js +4 -1
- package/dist/dataModels/toDataModels.js.map +1 -1
- package/dist/dataModels/toDataModels.mjs +5 -1
- package/dist/dataModels/toDataModels.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 +115 -86
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +111 -86
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-BtkwFbT9.d.mts → index-CcZRaA0b.d.mts} +84 -41
- package/dist/{index-BtkwFbT9.d.ts → index-CcZRaA0b.d.ts} +84 -41
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +117 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +113 -76
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +28 -2
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +28 -2
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -431,11 +431,15 @@ __export(index_exports, {
|
|
|
431
431
|
getApi: () => getApi,
|
|
432
432
|
getApis: () => getApis,
|
|
433
433
|
getClickhouseClient: () => getClickhouseClient,
|
|
434
|
+
getCustomView: () => getCustomView,
|
|
435
|
+
getCustomViews: () => getCustomViews,
|
|
434
436
|
getFileName: () => getFileName,
|
|
435
437
|
getIngestApi: () => getIngestApi,
|
|
436
438
|
getIngestApis: () => getIngestApis,
|
|
437
439
|
getKafkaClient: () => getKafkaClient,
|
|
438
440
|
getKafkaProducer: () => getKafkaProducer,
|
|
441
|
+
getMaterializedView: () => getMaterializedView,
|
|
442
|
+
getMaterializedViews: () => getMaterializedViews,
|
|
439
443
|
getMooseClients: () => getMooseClients,
|
|
440
444
|
getMooseUtils: () => getMooseUtils,
|
|
441
445
|
getSqlResource: () => getSqlResource,
|
|
@@ -799,7 +803,9 @@ var moose_internal = {
|
|
|
799
803
|
apis: /* @__PURE__ */ new Map(),
|
|
800
804
|
sqlResources: /* @__PURE__ */ new Map(),
|
|
801
805
|
workflows: /* @__PURE__ */ new Map(),
|
|
802
|
-
webApps: /* @__PURE__ */ new Map()
|
|
806
|
+
webApps: /* @__PURE__ */ new Map(),
|
|
807
|
+
materializedViews: /* @__PURE__ */ new Map(),
|
|
808
|
+
customViews: /* @__PURE__ */ new Map()
|
|
803
809
|
};
|
|
804
810
|
var defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
805
811
|
var getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -815,6 +821,8 @@ var loadIndex = () => {
|
|
|
815
821
|
registry.sqlResources.clear();
|
|
816
822
|
registry.workflows.clear();
|
|
817
823
|
registry.webApps.clear();
|
|
824
|
+
registry.materializedViews.clear();
|
|
825
|
+
registry.customViews.clear();
|
|
818
826
|
const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
|
|
819
827
|
Object.keys(require.cache).forEach((key) => {
|
|
820
828
|
if (key.startsWith(appDir)) {
|
|
@@ -902,7 +910,8 @@ var dlqColumns = [
|
|
|
902
910
|
annotations: [],
|
|
903
911
|
ttl: null,
|
|
904
912
|
codec: null,
|
|
905
|
-
materialized: null
|
|
913
|
+
materialized: null,
|
|
914
|
+
comment: null
|
|
906
915
|
},
|
|
907
916
|
{
|
|
908
917
|
name: "errorMessage",
|
|
@@ -914,7 +923,8 @@ var dlqColumns = [
|
|
|
914
923
|
annotations: [],
|
|
915
924
|
ttl: null,
|
|
916
925
|
codec: null,
|
|
917
|
-
materialized: null
|
|
926
|
+
materialized: null,
|
|
927
|
+
comment: null
|
|
918
928
|
},
|
|
919
929
|
{
|
|
920
930
|
name: "errorType",
|
|
@@ -926,7 +936,8 @@ var dlqColumns = [
|
|
|
926
936
|
annotations: [],
|
|
927
937
|
ttl: null,
|
|
928
938
|
codec: null,
|
|
929
|
-
materialized: null
|
|
939
|
+
materialized: null,
|
|
940
|
+
comment: null
|
|
930
941
|
},
|
|
931
942
|
{
|
|
932
943
|
name: "failedAt",
|
|
@@ -938,7 +949,8 @@ var dlqColumns = [
|
|
|
938
949
|
annotations: [],
|
|
939
950
|
ttl: null,
|
|
940
951
|
codec: null,
|
|
941
|
-
materialized: null
|
|
952
|
+
materialized: null,
|
|
953
|
+
comment: null
|
|
942
954
|
},
|
|
943
955
|
{
|
|
944
956
|
name: "source",
|
|
@@ -950,7 +962,8 @@ var dlqColumns = [
|
|
|
950
962
|
annotations: [],
|
|
951
963
|
ttl: null,
|
|
952
964
|
codec: null,
|
|
953
|
-
materialized: null
|
|
965
|
+
materialized: null,
|
|
966
|
+
comment: null
|
|
954
967
|
}
|
|
955
968
|
];
|
|
956
969
|
var getWorkflows = async () => {
|
|
@@ -2461,6 +2474,67 @@ var ETLPipeline = class {
|
|
|
2461
2474
|
}
|
|
2462
2475
|
};
|
|
2463
2476
|
|
|
2477
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2478
|
+
var requireTargetTableName = (tableName) => {
|
|
2479
|
+
if (typeof tableName === "string") {
|
|
2480
|
+
return tableName;
|
|
2481
|
+
} else {
|
|
2482
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2483
|
+
}
|
|
2484
|
+
};
|
|
2485
|
+
var MaterializedView = class {
|
|
2486
|
+
/** @internal */
|
|
2487
|
+
kind = "MaterializedView";
|
|
2488
|
+
/** The name of the materialized view */
|
|
2489
|
+
name;
|
|
2490
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2491
|
+
targetTable;
|
|
2492
|
+
/** The SELECT SQL statement */
|
|
2493
|
+
selectSql;
|
|
2494
|
+
/** Names of source tables that the SELECT reads from */
|
|
2495
|
+
sourceTables;
|
|
2496
|
+
/** @internal Source file path where this MV was defined */
|
|
2497
|
+
sourceFile;
|
|
2498
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2499
|
+
let selectStatement = options.selectStatement;
|
|
2500
|
+
if (typeof selectStatement !== "string") {
|
|
2501
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2502
|
+
}
|
|
2503
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2504
|
+
throw new Error(
|
|
2505
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2506
|
+
);
|
|
2507
|
+
}
|
|
2508
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2509
|
+
requireTargetTableName(
|
|
2510
|
+
options.targetTable?.name ?? options.tableName
|
|
2511
|
+
),
|
|
2512
|
+
{
|
|
2513
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2514
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2515
|
+
},
|
|
2516
|
+
targetSchema,
|
|
2517
|
+
targetColumns
|
|
2518
|
+
);
|
|
2519
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2520
|
+
throw new Error(
|
|
2521
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2522
|
+
);
|
|
2523
|
+
}
|
|
2524
|
+
this.name = options.materializedViewName;
|
|
2525
|
+
this.targetTable = targetTable;
|
|
2526
|
+
this.selectSql = selectStatement;
|
|
2527
|
+
this.sourceTables = options.selectTables.map((t) => t.name);
|
|
2528
|
+
const stack = new Error().stack;
|
|
2529
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2530
|
+
const materializedViews = getMooseInternal().materializedViews;
|
|
2531
|
+
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2532
|
+
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2533
|
+
}
|
|
2534
|
+
materializedViews.set(this.name, this);
|
|
2535
|
+
}
|
|
2536
|
+
};
|
|
2537
|
+
|
|
2464
2538
|
// src/dmv2/sdk/sqlResource.ts
|
|
2465
2539
|
var SqlResource = class {
|
|
2466
2540
|
/** @internal */
|
|
@@ -2515,66 +2589,18 @@ var SqlResource = class {
|
|
|
2515
2589
|
}
|
|
2516
2590
|
};
|
|
2517
2591
|
|
|
2518
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2519
|
-
var requireTargetTableName = (tableName) => {
|
|
2520
|
-
if (typeof tableName === "string") {
|
|
2521
|
-
return tableName;
|
|
2522
|
-
} else {
|
|
2523
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2524
|
-
}
|
|
2525
|
-
};
|
|
2526
|
-
var MaterializedView = class extends SqlResource {
|
|
2527
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2528
|
-
targetTable;
|
|
2529
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2530
|
-
let selectStatement = options.selectStatement;
|
|
2531
|
-
if (typeof selectStatement !== "string") {
|
|
2532
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2533
|
-
}
|
|
2534
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2535
|
-
throw new Error(
|
|
2536
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2537
|
-
);
|
|
2538
|
-
}
|
|
2539
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2540
|
-
requireTargetTableName(
|
|
2541
|
-
options.targetTable?.name ?? options.tableName
|
|
2542
|
-
),
|
|
2543
|
-
{
|
|
2544
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2545
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2546
|
-
},
|
|
2547
|
-
targetSchema,
|
|
2548
|
-
targetColumns
|
|
2549
|
-
);
|
|
2550
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2551
|
-
throw new Error(
|
|
2552
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2553
|
-
);
|
|
2554
|
-
}
|
|
2555
|
-
super(
|
|
2556
|
-
options.materializedViewName,
|
|
2557
|
-
[
|
|
2558
|
-
createMaterializedView({
|
|
2559
|
-
name: options.materializedViewName,
|
|
2560
|
-
destinationTable: targetTable.name,
|
|
2561
|
-
select: selectStatement
|
|
2562
|
-
})
|
|
2563
|
-
// Population is now handled automatically by Rust infrastructure
|
|
2564
|
-
// based on table engine type and whether this is a new or updated view
|
|
2565
|
-
],
|
|
2566
|
-
[dropView(options.materializedViewName)],
|
|
2567
|
-
{
|
|
2568
|
-
pullsDataFrom: options.selectTables,
|
|
2569
|
-
pushesDataTo: [targetTable]
|
|
2570
|
-
}
|
|
2571
|
-
);
|
|
2572
|
-
this.targetTable = targetTable;
|
|
2573
|
-
}
|
|
2574
|
-
};
|
|
2575
|
-
|
|
2576
2592
|
// src/dmv2/sdk/view.ts
|
|
2577
|
-
var View = class
|
|
2593
|
+
var View = class {
|
|
2594
|
+
/** @internal */
|
|
2595
|
+
kind = "CustomView";
|
|
2596
|
+
/** The name of the view */
|
|
2597
|
+
name;
|
|
2598
|
+
/** The SELECT SQL statement that defines the view */
|
|
2599
|
+
selectSql;
|
|
2600
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
2601
|
+
sourceTables;
|
|
2602
|
+
/** @internal Source file path where this view was defined */
|
|
2603
|
+
sourceFile;
|
|
2578
2604
|
/**
|
|
2579
2605
|
* Creates a new View instance.
|
|
2580
2606
|
* @param name The name of the view to be created.
|
|
@@ -2585,17 +2611,16 @@ var View = class extends SqlResource {
|
|
|
2585
2611
|
if (typeof selectStatement !== "string") {
|
|
2586
2612
|
selectStatement = toStaticQuery(selectStatement);
|
|
2587
2613
|
}
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
{
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
);
|
|
2614
|
+
this.name = name;
|
|
2615
|
+
this.selectSql = selectStatement;
|
|
2616
|
+
this.sourceTables = baseTables.map((t) => t.name);
|
|
2617
|
+
const stack = new Error().stack;
|
|
2618
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2619
|
+
const customViews = getMooseInternal().customViews;
|
|
2620
|
+
if (!isClientOnlyMode() && customViews.has(this.name)) {
|
|
2621
|
+
throw new Error(`View with name ${this.name} already exists`);
|
|
2622
|
+
}
|
|
2623
|
+
customViews.set(this.name, this);
|
|
2599
2624
|
}
|
|
2600
2625
|
};
|
|
2601
2626
|
|
|
@@ -2784,6 +2809,18 @@ function getWebApps() {
|
|
|
2784
2809
|
function getWebApp(name) {
|
|
2785
2810
|
return getMooseInternal().webApps.get(name);
|
|
2786
2811
|
}
|
|
2812
|
+
function getMaterializedViews() {
|
|
2813
|
+
return getMooseInternal().materializedViews;
|
|
2814
|
+
}
|
|
2815
|
+
function getMaterializedView(name) {
|
|
2816
|
+
return getMooseInternal().materializedViews.get(name);
|
|
2817
|
+
}
|
|
2818
|
+
function getCustomViews() {
|
|
2819
|
+
return getMooseInternal().customViews;
|
|
2820
|
+
}
|
|
2821
|
+
function getCustomView(name) {
|
|
2822
|
+
return getMooseInternal().customViews.get(name);
|
|
2823
|
+
}
|
|
2787
2824
|
|
|
2788
2825
|
// src/index.ts
|
|
2789
2826
|
init_commons();
|
|
@@ -3483,11 +3520,15 @@ var DataSource = class {
|
|
|
3483
3520
|
getApi,
|
|
3484
3521
|
getApis,
|
|
3485
3522
|
getClickhouseClient,
|
|
3523
|
+
getCustomView,
|
|
3524
|
+
getCustomViews,
|
|
3486
3525
|
getFileName,
|
|
3487
3526
|
getIngestApi,
|
|
3488
3527
|
getIngestApis,
|
|
3489
3528
|
getKafkaClient,
|
|
3490
3529
|
getKafkaProducer,
|
|
3530
|
+
getMaterializedView,
|
|
3531
|
+
getMaterializedViews,
|
|
3491
3532
|
getMooseClients,
|
|
3492
3533
|
getMooseUtils,
|
|
3493
3534
|
getSqlResource,
|