@514labs/moose-lib 0.6.293 → 0.6.294-ci-16-gb7a5d464
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-ChWHzgtb.d.mts → browserCompatible-DCCiBirg.d.mts} +1 -1
- package/dist/{browserCompatible-B8CAYjv5.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 +105 -81
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +101 -81
- 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 +105 -81
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +101 -81
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-rQOQo9sv.d.mts → index-CcZRaA0b.d.mts} +83 -41
- package/dist/{index-rQOQo9sv.d.ts → index-CcZRaA0b.d.ts} +83 -41
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +107 -71
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -71
- 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
|
@@ -639,16 +639,6 @@ function emptyIfUndefined(value) {
|
|
|
639
639
|
return value === void 0 ? "" : value;
|
|
640
640
|
}
|
|
641
641
|
|
|
642
|
-
// src/blocks/helpers.ts
|
|
643
|
-
function dropView(name) {
|
|
644
|
-
return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
|
|
645
|
-
}
|
|
646
|
-
function createMaterializedView(options) {
|
|
647
|
-
return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
|
|
648
|
-
TO ${quoteIdentifier(options.destinationTable)}
|
|
649
|
-
AS ${options.select}`.trim();
|
|
650
|
-
}
|
|
651
|
-
|
|
652
642
|
// src/dmv2/internal.ts
|
|
653
643
|
import process2 from "process";
|
|
654
644
|
|
|
@@ -702,7 +692,9 @@ var moose_internal = {
|
|
|
702
692
|
apis: /* @__PURE__ */ new Map(),
|
|
703
693
|
sqlResources: /* @__PURE__ */ new Map(),
|
|
704
694
|
workflows: /* @__PURE__ */ new Map(),
|
|
705
|
-
webApps: /* @__PURE__ */ new Map()
|
|
695
|
+
webApps: /* @__PURE__ */ new Map(),
|
|
696
|
+
materializedViews: /* @__PURE__ */ new Map(),
|
|
697
|
+
customViews: /* @__PURE__ */ new Map()
|
|
706
698
|
};
|
|
707
699
|
var defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
708
700
|
var getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -2336,6 +2328,67 @@ var ETLPipeline = class {
|
|
|
2336
2328
|
}
|
|
2337
2329
|
};
|
|
2338
2330
|
|
|
2331
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2332
|
+
var requireTargetTableName = (tableName) => {
|
|
2333
|
+
if (typeof tableName === "string") {
|
|
2334
|
+
return tableName;
|
|
2335
|
+
} else {
|
|
2336
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2337
|
+
}
|
|
2338
|
+
};
|
|
2339
|
+
var MaterializedView = class {
|
|
2340
|
+
/** @internal */
|
|
2341
|
+
kind = "MaterializedView";
|
|
2342
|
+
/** The name of the materialized view */
|
|
2343
|
+
name;
|
|
2344
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2345
|
+
targetTable;
|
|
2346
|
+
/** The SELECT SQL statement */
|
|
2347
|
+
selectSql;
|
|
2348
|
+
/** Names of source tables that the SELECT reads from */
|
|
2349
|
+
sourceTables;
|
|
2350
|
+
/** @internal Source file path where this MV was defined */
|
|
2351
|
+
sourceFile;
|
|
2352
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2353
|
+
let selectStatement = options.selectStatement;
|
|
2354
|
+
if (typeof selectStatement !== "string") {
|
|
2355
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2356
|
+
}
|
|
2357
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2358
|
+
throw new Error(
|
|
2359
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2360
|
+
);
|
|
2361
|
+
}
|
|
2362
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2363
|
+
requireTargetTableName(
|
|
2364
|
+
options.targetTable?.name ?? options.tableName
|
|
2365
|
+
),
|
|
2366
|
+
{
|
|
2367
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2368
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2369
|
+
},
|
|
2370
|
+
targetSchema,
|
|
2371
|
+
targetColumns
|
|
2372
|
+
);
|
|
2373
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2374
|
+
throw new Error(
|
|
2375
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2376
|
+
);
|
|
2377
|
+
}
|
|
2378
|
+
this.name = options.materializedViewName;
|
|
2379
|
+
this.targetTable = targetTable;
|
|
2380
|
+
this.selectSql = selectStatement;
|
|
2381
|
+
this.sourceTables = options.selectTables.map((t) => t.name);
|
|
2382
|
+
const stack = new Error().stack;
|
|
2383
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2384
|
+
const materializedViews = getMooseInternal().materializedViews;
|
|
2385
|
+
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2386
|
+
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2387
|
+
}
|
|
2388
|
+
materializedViews.set(this.name, this);
|
|
2389
|
+
}
|
|
2390
|
+
};
|
|
2391
|
+
|
|
2339
2392
|
// src/dmv2/sdk/sqlResource.ts
|
|
2340
2393
|
var SqlResource = class {
|
|
2341
2394
|
/** @internal */
|
|
@@ -2390,66 +2443,18 @@ var SqlResource = class {
|
|
|
2390
2443
|
}
|
|
2391
2444
|
};
|
|
2392
2445
|
|
|
2393
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2394
|
-
var requireTargetTableName = (tableName) => {
|
|
2395
|
-
if (typeof tableName === "string") {
|
|
2396
|
-
return tableName;
|
|
2397
|
-
} else {
|
|
2398
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2399
|
-
}
|
|
2400
|
-
};
|
|
2401
|
-
var MaterializedView = class extends SqlResource {
|
|
2402
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2403
|
-
targetTable;
|
|
2404
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2405
|
-
let selectStatement = options.selectStatement;
|
|
2406
|
-
if (typeof selectStatement !== "string") {
|
|
2407
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2408
|
-
}
|
|
2409
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2410
|
-
throw new Error(
|
|
2411
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2412
|
-
);
|
|
2413
|
-
}
|
|
2414
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2415
|
-
requireTargetTableName(
|
|
2416
|
-
options.targetTable?.name ?? options.tableName
|
|
2417
|
-
),
|
|
2418
|
-
{
|
|
2419
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2420
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2421
|
-
},
|
|
2422
|
-
targetSchema,
|
|
2423
|
-
targetColumns
|
|
2424
|
-
);
|
|
2425
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2426
|
-
throw new Error(
|
|
2427
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2428
|
-
);
|
|
2429
|
-
}
|
|
2430
|
-
super(
|
|
2431
|
-
options.materializedViewName,
|
|
2432
|
-
[
|
|
2433
|
-
createMaterializedView({
|
|
2434
|
-
name: options.materializedViewName,
|
|
2435
|
-
destinationTable: targetTable.name,
|
|
2436
|
-
select: selectStatement
|
|
2437
|
-
})
|
|
2438
|
-
// Population is now handled automatically by Rust infrastructure
|
|
2439
|
-
// based on table engine type and whether this is a new or updated view
|
|
2440
|
-
],
|
|
2441
|
-
[dropView(options.materializedViewName)],
|
|
2442
|
-
{
|
|
2443
|
-
pullsDataFrom: options.selectTables,
|
|
2444
|
-
pushesDataTo: [targetTable]
|
|
2445
|
-
}
|
|
2446
|
-
);
|
|
2447
|
-
this.targetTable = targetTable;
|
|
2448
|
-
}
|
|
2449
|
-
};
|
|
2450
|
-
|
|
2451
2446
|
// src/dmv2/sdk/view.ts
|
|
2452
|
-
var View = class
|
|
2447
|
+
var View = class {
|
|
2448
|
+
/** @internal */
|
|
2449
|
+
kind = "CustomView";
|
|
2450
|
+
/** The name of the view */
|
|
2451
|
+
name;
|
|
2452
|
+
/** The SELECT SQL statement that defines the view */
|
|
2453
|
+
selectSql;
|
|
2454
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
2455
|
+
sourceTables;
|
|
2456
|
+
/** @internal Source file path where this view was defined */
|
|
2457
|
+
sourceFile;
|
|
2453
2458
|
/**
|
|
2454
2459
|
* Creates a new View instance.
|
|
2455
2460
|
* @param name The name of the view to be created.
|
|
@@ -2460,17 +2465,16 @@ var View = class extends SqlResource {
|
|
|
2460
2465
|
if (typeof selectStatement !== "string") {
|
|
2461
2466
|
selectStatement = toStaticQuery(selectStatement);
|
|
2462
2467
|
}
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
{
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
);
|
|
2468
|
+
this.name = name;
|
|
2469
|
+
this.selectSql = selectStatement;
|
|
2470
|
+
this.sourceTables = baseTables.map((t) => t.name);
|
|
2471
|
+
const stack = new Error().stack;
|
|
2472
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2473
|
+
const customViews = getMooseInternal().customViews;
|
|
2474
|
+
if (!isClientOnlyMode() && customViews.has(this.name)) {
|
|
2475
|
+
throw new Error(`View with name ${this.name} already exists`);
|
|
2476
|
+
}
|
|
2477
|
+
customViews.set(this.name, this);
|
|
2474
2478
|
}
|
|
2475
2479
|
};
|
|
2476
2480
|
|
|
@@ -2659,6 +2663,18 @@ function getWebApps2() {
|
|
|
2659
2663
|
function getWebApp(name) {
|
|
2660
2664
|
return getMooseInternal().webApps.get(name);
|
|
2661
2665
|
}
|
|
2666
|
+
function getMaterializedViews() {
|
|
2667
|
+
return getMooseInternal().materializedViews;
|
|
2668
|
+
}
|
|
2669
|
+
function getMaterializedView(name) {
|
|
2670
|
+
return getMooseInternal().materializedViews.get(name);
|
|
2671
|
+
}
|
|
2672
|
+
function getCustomViews() {
|
|
2673
|
+
return getMooseInternal().customViews;
|
|
2674
|
+
}
|
|
2675
|
+
function getCustomView(name) {
|
|
2676
|
+
return getMooseInternal().customViews.get(name);
|
|
2677
|
+
}
|
|
2662
2678
|
export {
|
|
2663
2679
|
Api,
|
|
2664
2680
|
ConsumptionApi,
|
|
@@ -2679,8 +2695,12 @@ export {
|
|
|
2679
2695
|
createClickhouseParameter,
|
|
2680
2696
|
getApi,
|
|
2681
2697
|
getApis2 as getApis,
|
|
2698
|
+
getCustomView,
|
|
2699
|
+
getCustomViews,
|
|
2682
2700
|
getIngestApi,
|
|
2683
2701
|
getIngestApis,
|
|
2702
|
+
getMaterializedView,
|
|
2703
|
+
getMaterializedViews,
|
|
2684
2704
|
getSqlResource,
|
|
2685
2705
|
getSqlResources,
|
|
2686
2706
|
getStream,
|