@514labs/moose-lib 0.6.262-ci-2-g1c866068 → 0.6.262-ci-7-g8a83699f
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-CC6Jamxn.d.ts → browserCompatible-BpwCKgGF.d.ts} +1 -1
- package/dist/{browserCompatible-GsBQtLKo.d.mts → browserCompatible-CDqMXtd_.d.mts} +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 +85 -81
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +85 -81
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-B1HsstjQ.d.mts → index-B2jILcTY.d.mts} +56 -36
- package/dist/{index-B1HsstjQ.d.ts → index-B2jILcTY.d.ts} +56 -36
- 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
|
@@ -601,16 +601,6 @@ function emptyIfUndefined(value) {
|
|
|
601
601
|
return value === void 0 ? "" : value;
|
|
602
602
|
}
|
|
603
603
|
|
|
604
|
-
// src/blocks/helpers.ts
|
|
605
|
-
function dropView(name) {
|
|
606
|
-
return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
|
|
607
|
-
}
|
|
608
|
-
function createMaterializedView(options) {
|
|
609
|
-
return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
|
|
610
|
-
TO ${quoteIdentifier(options.destinationTable)}
|
|
611
|
-
AS ${options.select}`.trim();
|
|
612
|
-
}
|
|
613
|
-
|
|
614
604
|
// src/dmv2/internal.ts
|
|
615
605
|
import process2 from "process";
|
|
616
606
|
|
|
@@ -664,7 +654,9 @@ var moose_internal = {
|
|
|
664
654
|
apis: /* @__PURE__ */ new Map(),
|
|
665
655
|
sqlResources: /* @__PURE__ */ new Map(),
|
|
666
656
|
workflows: /* @__PURE__ */ new Map(),
|
|
667
|
-
webApps: /* @__PURE__ */ new Map()
|
|
657
|
+
webApps: /* @__PURE__ */ new Map(),
|
|
658
|
+
materializedViews: /* @__PURE__ */ new Map(),
|
|
659
|
+
customViews: /* @__PURE__ */ new Map()
|
|
668
660
|
};
|
|
669
661
|
var defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
670
662
|
var getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -2280,6 +2272,67 @@ var ETLPipeline = class {
|
|
|
2280
2272
|
}
|
|
2281
2273
|
};
|
|
2282
2274
|
|
|
2275
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2276
|
+
var requireTargetTableName = (tableName) => {
|
|
2277
|
+
if (typeof tableName === "string") {
|
|
2278
|
+
return tableName;
|
|
2279
|
+
} else {
|
|
2280
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2281
|
+
}
|
|
2282
|
+
};
|
|
2283
|
+
var MaterializedView = class {
|
|
2284
|
+
/** @internal */
|
|
2285
|
+
kind = "MaterializedView";
|
|
2286
|
+
/** The name of the materialized view */
|
|
2287
|
+
name;
|
|
2288
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2289
|
+
targetTable;
|
|
2290
|
+
/** The SELECT SQL statement */
|
|
2291
|
+
selectSql;
|
|
2292
|
+
/** Names of source tables that the SELECT reads from */
|
|
2293
|
+
sourceTables;
|
|
2294
|
+
/** @internal Source file path where this MV was defined */
|
|
2295
|
+
sourceFile;
|
|
2296
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2297
|
+
let selectStatement = options.selectStatement;
|
|
2298
|
+
if (typeof selectStatement !== "string") {
|
|
2299
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2300
|
+
}
|
|
2301
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2302
|
+
throw new Error(
|
|
2303
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2304
|
+
);
|
|
2305
|
+
}
|
|
2306
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2307
|
+
requireTargetTableName(
|
|
2308
|
+
options.targetTable?.name ?? options.tableName
|
|
2309
|
+
),
|
|
2310
|
+
{
|
|
2311
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2312
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2313
|
+
},
|
|
2314
|
+
targetSchema,
|
|
2315
|
+
targetColumns
|
|
2316
|
+
);
|
|
2317
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2318
|
+
throw new Error(
|
|
2319
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2320
|
+
);
|
|
2321
|
+
}
|
|
2322
|
+
this.name = options.materializedViewName;
|
|
2323
|
+
this.targetTable = targetTable;
|
|
2324
|
+
this.selectSql = selectStatement;
|
|
2325
|
+
this.sourceTables = options.selectTables.map((t) => t.name);
|
|
2326
|
+
const stack = new Error().stack;
|
|
2327
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2328
|
+
const materializedViews = getMooseInternal().materializedViews;
|
|
2329
|
+
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2330
|
+
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2331
|
+
}
|
|
2332
|
+
materializedViews.set(this.name, this);
|
|
2333
|
+
}
|
|
2334
|
+
};
|
|
2335
|
+
|
|
2283
2336
|
// src/dmv2/sdk/sqlResource.ts
|
|
2284
2337
|
var SqlResource = class {
|
|
2285
2338
|
/** @internal */
|
|
@@ -2325,66 +2378,18 @@ var SqlResource = class {
|
|
|
2325
2378
|
}
|
|
2326
2379
|
};
|
|
2327
2380
|
|
|
2328
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2329
|
-
var requireTargetTableName = (tableName) => {
|
|
2330
|
-
if (typeof tableName === "string") {
|
|
2331
|
-
return tableName;
|
|
2332
|
-
} else {
|
|
2333
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2334
|
-
}
|
|
2335
|
-
};
|
|
2336
|
-
var MaterializedView = class extends SqlResource {
|
|
2337
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2338
|
-
targetTable;
|
|
2339
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2340
|
-
let selectStatement = options.selectStatement;
|
|
2341
|
-
if (typeof selectStatement !== "string") {
|
|
2342
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2343
|
-
}
|
|
2344
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2345
|
-
throw new Error(
|
|
2346
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2347
|
-
);
|
|
2348
|
-
}
|
|
2349
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2350
|
-
requireTargetTableName(
|
|
2351
|
-
options.targetTable?.name ?? options.tableName
|
|
2352
|
-
),
|
|
2353
|
-
{
|
|
2354
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2355
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2356
|
-
},
|
|
2357
|
-
targetSchema,
|
|
2358
|
-
targetColumns
|
|
2359
|
-
);
|
|
2360
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2361
|
-
throw new Error(
|
|
2362
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2363
|
-
);
|
|
2364
|
-
}
|
|
2365
|
-
super(
|
|
2366
|
-
options.materializedViewName,
|
|
2367
|
-
[
|
|
2368
|
-
createMaterializedView({
|
|
2369
|
-
name: options.materializedViewName,
|
|
2370
|
-
destinationTable: targetTable.name,
|
|
2371
|
-
select: selectStatement
|
|
2372
|
-
})
|
|
2373
|
-
// Population is now handled automatically by Rust infrastructure
|
|
2374
|
-
// based on table engine type and whether this is a new or updated view
|
|
2375
|
-
],
|
|
2376
|
-
[dropView(options.materializedViewName)],
|
|
2377
|
-
{
|
|
2378
|
-
pullsDataFrom: options.selectTables,
|
|
2379
|
-
pushesDataTo: [targetTable]
|
|
2380
|
-
}
|
|
2381
|
-
);
|
|
2382
|
-
this.targetTable = targetTable;
|
|
2383
|
-
}
|
|
2384
|
-
};
|
|
2385
|
-
|
|
2386
2381
|
// src/dmv2/sdk/view.ts
|
|
2387
|
-
var View = class
|
|
2382
|
+
var View = class {
|
|
2383
|
+
/** @internal */
|
|
2384
|
+
kind = "CustomView";
|
|
2385
|
+
/** The name of the view */
|
|
2386
|
+
name;
|
|
2387
|
+
/** The SELECT SQL statement that defines the view */
|
|
2388
|
+
selectSql;
|
|
2389
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
2390
|
+
sourceTables;
|
|
2391
|
+
/** @internal Source file path where this view was defined */
|
|
2392
|
+
sourceFile;
|
|
2388
2393
|
/**
|
|
2389
2394
|
* Creates a new View instance.
|
|
2390
2395
|
* @param name The name of the view to be created.
|
|
@@ -2395,17 +2400,16 @@ var View = class extends SqlResource {
|
|
|
2395
2400
|
if (typeof selectStatement !== "string") {
|
|
2396
2401
|
selectStatement = toStaticQuery(selectStatement);
|
|
2397
2402
|
}
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
{
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
);
|
|
2403
|
+
this.name = name;
|
|
2404
|
+
this.selectSql = selectStatement;
|
|
2405
|
+
this.sourceTables = baseTables.map((t) => t.name);
|
|
2406
|
+
const stack = new Error().stack;
|
|
2407
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2408
|
+
const customViews = getMooseInternal().customViews;
|
|
2409
|
+
if (!isClientOnlyMode() && customViews.has(this.name)) {
|
|
2410
|
+
throw new Error(`View with name ${this.name} already exists`);
|
|
2411
|
+
}
|
|
2412
|
+
customViews.set(this.name, this);
|
|
2409
2413
|
}
|
|
2410
2414
|
};
|
|
2411
2415
|
|