@514labs/moose-lib 0.6.284-ci-8-g9790d0a6 → 0.6.284-ci-5-g1643505d
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-Bs-byVfO.d.mts} +1 -1
- package/dist/{browserCompatible-BUKAJYbj.d.ts → browserCompatible-D8Hbpq6L.d.ts} +1 -1
- package/dist/browserCompatible.d.mts +2 -2
- package/dist/browserCompatible.d.ts +2 -2
- package/dist/browserCompatible.js +85 -81
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +85 -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-BtkwFbT9.d.mts → index-KhGbXtkS.d.mts} +83 -41
- package/dist/{index-BtkwFbT9.d.ts → index-KhGbXtkS.d.ts} +83 -41
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +87 -71
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -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;
|
|
@@ -2331,6 +2323,67 @@ var ETLPipeline = class {
|
|
|
2331
2323
|
}
|
|
2332
2324
|
};
|
|
2333
2325
|
|
|
2326
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2327
|
+
var requireTargetTableName = (tableName) => {
|
|
2328
|
+
if (typeof tableName === "string") {
|
|
2329
|
+
return tableName;
|
|
2330
|
+
} else {
|
|
2331
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2332
|
+
}
|
|
2333
|
+
};
|
|
2334
|
+
var MaterializedView = class {
|
|
2335
|
+
/** @internal */
|
|
2336
|
+
kind = "MaterializedView";
|
|
2337
|
+
/** The name of the materialized view */
|
|
2338
|
+
name;
|
|
2339
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2340
|
+
targetTable;
|
|
2341
|
+
/** The SELECT SQL statement */
|
|
2342
|
+
selectSql;
|
|
2343
|
+
/** Names of source tables that the SELECT reads from */
|
|
2344
|
+
sourceTables;
|
|
2345
|
+
/** @internal Source file path where this MV was defined */
|
|
2346
|
+
sourceFile;
|
|
2347
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2348
|
+
let selectStatement = options.selectStatement;
|
|
2349
|
+
if (typeof selectStatement !== "string") {
|
|
2350
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2351
|
+
}
|
|
2352
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2353
|
+
throw new Error(
|
|
2354
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2355
|
+
);
|
|
2356
|
+
}
|
|
2357
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2358
|
+
requireTargetTableName(
|
|
2359
|
+
options.targetTable?.name ?? options.tableName
|
|
2360
|
+
),
|
|
2361
|
+
{
|
|
2362
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2363
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2364
|
+
},
|
|
2365
|
+
targetSchema,
|
|
2366
|
+
targetColumns
|
|
2367
|
+
);
|
|
2368
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2369
|
+
throw new Error(
|
|
2370
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2371
|
+
);
|
|
2372
|
+
}
|
|
2373
|
+
this.name = options.materializedViewName;
|
|
2374
|
+
this.targetTable = targetTable;
|
|
2375
|
+
this.selectSql = selectStatement;
|
|
2376
|
+
this.sourceTables = options.selectTables.map((t) => t.name);
|
|
2377
|
+
const stack = new Error().stack;
|
|
2378
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2379
|
+
const materializedViews = getMooseInternal().materializedViews;
|
|
2380
|
+
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2381
|
+
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2382
|
+
}
|
|
2383
|
+
materializedViews.set(this.name, this);
|
|
2384
|
+
}
|
|
2385
|
+
};
|
|
2386
|
+
|
|
2334
2387
|
// src/dmv2/sdk/sqlResource.ts
|
|
2335
2388
|
var SqlResource = class {
|
|
2336
2389
|
/** @internal */
|
|
@@ -2385,66 +2438,18 @@ var SqlResource = class {
|
|
|
2385
2438
|
}
|
|
2386
2439
|
};
|
|
2387
2440
|
|
|
2388
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2389
|
-
var requireTargetTableName = (tableName) => {
|
|
2390
|
-
if (typeof tableName === "string") {
|
|
2391
|
-
return tableName;
|
|
2392
|
-
} else {
|
|
2393
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2394
|
-
}
|
|
2395
|
-
};
|
|
2396
|
-
var MaterializedView = class extends SqlResource {
|
|
2397
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2398
|
-
targetTable;
|
|
2399
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2400
|
-
let selectStatement = options.selectStatement;
|
|
2401
|
-
if (typeof selectStatement !== "string") {
|
|
2402
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2403
|
-
}
|
|
2404
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2405
|
-
throw new Error(
|
|
2406
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2407
|
-
);
|
|
2408
|
-
}
|
|
2409
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2410
|
-
requireTargetTableName(
|
|
2411
|
-
options.targetTable?.name ?? options.tableName
|
|
2412
|
-
),
|
|
2413
|
-
{
|
|
2414
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2415
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2416
|
-
},
|
|
2417
|
-
targetSchema,
|
|
2418
|
-
targetColumns
|
|
2419
|
-
);
|
|
2420
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2421
|
-
throw new Error(
|
|
2422
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2423
|
-
);
|
|
2424
|
-
}
|
|
2425
|
-
super(
|
|
2426
|
-
options.materializedViewName,
|
|
2427
|
-
[
|
|
2428
|
-
createMaterializedView({
|
|
2429
|
-
name: options.materializedViewName,
|
|
2430
|
-
destinationTable: targetTable.name,
|
|
2431
|
-
select: selectStatement
|
|
2432
|
-
})
|
|
2433
|
-
// Population is now handled automatically by Rust infrastructure
|
|
2434
|
-
// based on table engine type and whether this is a new or updated view
|
|
2435
|
-
],
|
|
2436
|
-
[dropView(options.materializedViewName)],
|
|
2437
|
-
{
|
|
2438
|
-
pullsDataFrom: options.selectTables,
|
|
2439
|
-
pushesDataTo: [targetTable]
|
|
2440
|
-
}
|
|
2441
|
-
);
|
|
2442
|
-
this.targetTable = targetTable;
|
|
2443
|
-
}
|
|
2444
|
-
};
|
|
2445
|
-
|
|
2446
2441
|
// src/dmv2/sdk/view.ts
|
|
2447
|
-
var View = class
|
|
2442
|
+
var View = class {
|
|
2443
|
+
/** @internal */
|
|
2444
|
+
kind = "CustomView";
|
|
2445
|
+
/** The name of the view */
|
|
2446
|
+
name;
|
|
2447
|
+
/** The SELECT SQL statement that defines the view */
|
|
2448
|
+
selectSql;
|
|
2449
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
2450
|
+
sourceTables;
|
|
2451
|
+
/** @internal Source file path where this view was defined */
|
|
2452
|
+
sourceFile;
|
|
2448
2453
|
/**
|
|
2449
2454
|
* Creates a new View instance.
|
|
2450
2455
|
* @param name The name of the view to be created.
|
|
@@ -2455,17 +2460,16 @@ var View = class extends SqlResource {
|
|
|
2455
2460
|
if (typeof selectStatement !== "string") {
|
|
2456
2461
|
selectStatement = toStaticQuery(selectStatement);
|
|
2457
2462
|
}
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
{
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
);
|
|
2463
|
+
this.name = name;
|
|
2464
|
+
this.selectSql = selectStatement;
|
|
2465
|
+
this.sourceTables = baseTables.map((t) => t.name);
|
|
2466
|
+
const stack = new Error().stack;
|
|
2467
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2468
|
+
const customViews = getMooseInternal().customViews;
|
|
2469
|
+
if (!isClientOnlyMode() && customViews.has(this.name)) {
|
|
2470
|
+
throw new Error(`View with name ${this.name} already exists`);
|
|
2471
|
+
}
|
|
2472
|
+
customViews.set(this.name, this);
|
|
2469
2473
|
}
|
|
2470
2474
|
};
|
|
2471
2475
|
|