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