@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
package/dist/dmv2/index.mjs
CHANGED
|
@@ -541,6 +541,16 @@ function emptyIfUndefined(value) {
|
|
|
541
541
|
return value === void 0 ? "" : value;
|
|
542
542
|
}
|
|
543
543
|
|
|
544
|
+
// src/blocks/helpers.ts
|
|
545
|
+
function dropView(name) {
|
|
546
|
+
return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
|
|
547
|
+
}
|
|
548
|
+
function createMaterializedView(options) {
|
|
549
|
+
return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
|
|
550
|
+
TO ${quoteIdentifier(options.destinationTable)}
|
|
551
|
+
AS ${options.select}`.trim();
|
|
552
|
+
}
|
|
553
|
+
|
|
544
554
|
// src/dmv2/internal.ts
|
|
545
555
|
import process2 from "process";
|
|
546
556
|
|
|
@@ -594,9 +604,7 @@ var moose_internal = {
|
|
|
594
604
|
apis: /* @__PURE__ */ new Map(),
|
|
595
605
|
sqlResources: /* @__PURE__ */ new Map(),
|
|
596
606
|
workflows: /* @__PURE__ */ new Map(),
|
|
597
|
-
webApps: /* @__PURE__ */ new Map()
|
|
598
|
-
materializedViews: /* @__PURE__ */ new Map(),
|
|
599
|
-
customViews: /* @__PURE__ */ new Map()
|
|
607
|
+
webApps: /* @__PURE__ */ new Map()
|
|
600
608
|
};
|
|
601
609
|
var defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
602
610
|
var getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -2225,67 +2233,6 @@ var ETLPipeline = class {
|
|
|
2225
2233
|
}
|
|
2226
2234
|
};
|
|
2227
2235
|
|
|
2228
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2229
|
-
var requireTargetTableName = (tableName) => {
|
|
2230
|
-
if (typeof tableName === "string") {
|
|
2231
|
-
return tableName;
|
|
2232
|
-
} else {
|
|
2233
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2234
|
-
}
|
|
2235
|
-
};
|
|
2236
|
-
var MaterializedView = class {
|
|
2237
|
-
/** @internal */
|
|
2238
|
-
kind = "MaterializedView";
|
|
2239
|
-
/** The name of the materialized view */
|
|
2240
|
-
name;
|
|
2241
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2242
|
-
targetTable;
|
|
2243
|
-
/** The SELECT SQL statement */
|
|
2244
|
-
selectSql;
|
|
2245
|
-
/** Names of source tables that the SELECT reads from */
|
|
2246
|
-
sourceTables;
|
|
2247
|
-
/** @internal Source file path where this MV was defined */
|
|
2248
|
-
sourceFile;
|
|
2249
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2250
|
-
let selectStatement = options.selectStatement;
|
|
2251
|
-
if (typeof selectStatement !== "string") {
|
|
2252
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2253
|
-
}
|
|
2254
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2255
|
-
throw new Error(
|
|
2256
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2257
|
-
);
|
|
2258
|
-
}
|
|
2259
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2260
|
-
requireTargetTableName(
|
|
2261
|
-
options.targetTable?.name ?? options.tableName
|
|
2262
|
-
),
|
|
2263
|
-
{
|
|
2264
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2265
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2266
|
-
},
|
|
2267
|
-
targetSchema,
|
|
2268
|
-
targetColumns
|
|
2269
|
-
);
|
|
2270
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2271
|
-
throw new Error(
|
|
2272
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2273
|
-
);
|
|
2274
|
-
}
|
|
2275
|
-
this.name = options.materializedViewName;
|
|
2276
|
-
this.targetTable = targetTable;
|
|
2277
|
-
this.selectSql = selectStatement;
|
|
2278
|
-
this.sourceTables = options.selectTables.map((t) => t.name);
|
|
2279
|
-
const stack = new Error().stack;
|
|
2280
|
-
this.sourceFile = getSourceFileFromStack(stack);
|
|
2281
|
-
const materializedViews = getMooseInternal().materializedViews;
|
|
2282
|
-
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2283
|
-
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2284
|
-
}
|
|
2285
|
-
materializedViews.set(this.name, this);
|
|
2286
|
-
}
|
|
2287
|
-
};
|
|
2288
|
-
|
|
2289
2236
|
// src/dmv2/sdk/sqlResource.ts
|
|
2290
2237
|
var SqlResource = class {
|
|
2291
2238
|
/** @internal */
|
|
@@ -2340,18 +2287,66 @@ var SqlResource = class {
|
|
|
2340
2287
|
}
|
|
2341
2288
|
};
|
|
2342
2289
|
|
|
2290
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2291
|
+
var requireTargetTableName = (tableName) => {
|
|
2292
|
+
if (typeof tableName === "string") {
|
|
2293
|
+
return tableName;
|
|
2294
|
+
} else {
|
|
2295
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2296
|
+
}
|
|
2297
|
+
};
|
|
2298
|
+
var MaterializedView = class extends SqlResource {
|
|
2299
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2300
|
+
targetTable;
|
|
2301
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2302
|
+
let selectStatement = options.selectStatement;
|
|
2303
|
+
if (typeof selectStatement !== "string") {
|
|
2304
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2305
|
+
}
|
|
2306
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2307
|
+
throw new Error(
|
|
2308
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2309
|
+
);
|
|
2310
|
+
}
|
|
2311
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2312
|
+
requireTargetTableName(
|
|
2313
|
+
options.targetTable?.name ?? options.tableName
|
|
2314
|
+
),
|
|
2315
|
+
{
|
|
2316
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2317
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2318
|
+
},
|
|
2319
|
+
targetSchema,
|
|
2320
|
+
targetColumns
|
|
2321
|
+
);
|
|
2322
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2323
|
+
throw new Error(
|
|
2324
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2325
|
+
);
|
|
2326
|
+
}
|
|
2327
|
+
super(
|
|
2328
|
+
options.materializedViewName,
|
|
2329
|
+
[
|
|
2330
|
+
createMaterializedView({
|
|
2331
|
+
name: options.materializedViewName,
|
|
2332
|
+
destinationTable: targetTable.name,
|
|
2333
|
+
select: selectStatement
|
|
2334
|
+
})
|
|
2335
|
+
// Population is now handled automatically by Rust infrastructure
|
|
2336
|
+
// based on table engine type and whether this is a new or updated view
|
|
2337
|
+
],
|
|
2338
|
+
[dropView(options.materializedViewName)],
|
|
2339
|
+
{
|
|
2340
|
+
pullsDataFrom: options.selectTables,
|
|
2341
|
+
pushesDataTo: [targetTable]
|
|
2342
|
+
}
|
|
2343
|
+
);
|
|
2344
|
+
this.targetTable = targetTable;
|
|
2345
|
+
}
|
|
2346
|
+
};
|
|
2347
|
+
|
|
2343
2348
|
// src/dmv2/sdk/view.ts
|
|
2344
|
-
var View = class {
|
|
2345
|
-
/** @internal */
|
|
2346
|
-
kind = "CustomView";
|
|
2347
|
-
/** The name of the view */
|
|
2348
|
-
name;
|
|
2349
|
-
/** The SELECT SQL statement that defines the view */
|
|
2350
|
-
selectSql;
|
|
2351
|
-
/** Names of source tables/views that the SELECT reads from */
|
|
2352
|
-
sourceTables;
|
|
2353
|
-
/** @internal Source file path where this view was defined */
|
|
2354
|
-
sourceFile;
|
|
2349
|
+
var View = class extends SqlResource {
|
|
2355
2350
|
/**
|
|
2356
2351
|
* Creates a new View instance.
|
|
2357
2352
|
* @param name The name of the view to be created.
|
|
@@ -2362,16 +2357,17 @@ var View = class {
|
|
|
2362
2357
|
if (typeof selectStatement !== "string") {
|
|
2363
2358
|
selectStatement = toStaticQuery(selectStatement);
|
|
2364
2359
|
}
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2360
|
+
super(
|
|
2361
|
+
name,
|
|
2362
|
+
[
|
|
2363
|
+
`CREATE VIEW IF NOT EXISTS ${name}
|
|
2364
|
+
AS ${selectStatement}`.trim()
|
|
2365
|
+
],
|
|
2366
|
+
[dropView(name)],
|
|
2367
|
+
{
|
|
2368
|
+
pullsDataFrom: baseTables
|
|
2369
|
+
}
|
|
2370
|
+
);
|
|
2375
2371
|
}
|
|
2376
2372
|
};
|
|
2377
2373
|
|
|
@@ -2560,18 +2556,6 @@ function getWebApps() {
|
|
|
2560
2556
|
function getWebApp(name) {
|
|
2561
2557
|
return getMooseInternal().webApps.get(name);
|
|
2562
2558
|
}
|
|
2563
|
-
function getMaterializedViews() {
|
|
2564
|
-
return getMooseInternal().materializedViews;
|
|
2565
|
-
}
|
|
2566
|
-
function getMaterializedView(name) {
|
|
2567
|
-
return getMooseInternal().materializedViews.get(name);
|
|
2568
|
-
}
|
|
2569
|
-
function getCustomViews() {
|
|
2570
|
-
return getMooseInternal().customViews;
|
|
2571
|
-
}
|
|
2572
|
-
function getCustomView(name) {
|
|
2573
|
-
return getMooseInternal().customViews.get(name);
|
|
2574
|
-
}
|
|
2575
2559
|
export {
|
|
2576
2560
|
Api,
|
|
2577
2561
|
ConsumptionApi,
|
|
@@ -2590,12 +2574,8 @@ export {
|
|
|
2590
2574
|
Workflow,
|
|
2591
2575
|
getApi,
|
|
2592
2576
|
getApis,
|
|
2593
|
-
getCustomView,
|
|
2594
|
-
getCustomViews,
|
|
2595
2577
|
getIngestApi,
|
|
2596
2578
|
getIngestApis,
|
|
2597
|
-
getMaterializedView,
|
|
2598
|
-
getMaterializedViews,
|
|
2599
2579
|
getSqlResource,
|
|
2600
2580
|
getSqlResources,
|
|
2601
2581
|
getStream,
|