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