@514labs/moose-lib 0.6.288 → 0.6.289-ci-9-g221fb3d9
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-DCCiBirg.d.mts} +1 -1
- package/dist/{browserCompatible-BUKAJYbj.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 +115 -86
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +111 -86
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/compilerPlugin.js +4 -1
- package/dist/compilerPlugin.js.map +1 -1
- package/dist/compilerPlugin.mjs +5 -1
- package/dist/compilerPlugin.mjs.map +1 -1
- package/dist/dataModels/toDataModels.js +4 -1
- package/dist/dataModels/toDataModels.js.map +1 -1
- package/dist/dataModels/toDataModels.mjs +5 -1
- package/dist/dataModels/toDataModels.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 +115 -86
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +111 -86
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-BtkwFbT9.d.mts → index-CcZRaA0b.d.mts} +84 -41
- package/dist/{index-BtkwFbT9.d.ts → index-CcZRaA0b.d.ts} +84 -41
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +117 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +113 -76
- 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
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;
|
|
@@ -682,7 +674,8 @@ var dlqColumns = [
|
|
|
682
674
|
annotations: [],
|
|
683
675
|
ttl: null,
|
|
684
676
|
codec: null,
|
|
685
|
-
materialized: null
|
|
677
|
+
materialized: null,
|
|
678
|
+
comment: null
|
|
686
679
|
},
|
|
687
680
|
{
|
|
688
681
|
name: "errorMessage",
|
|
@@ -694,7 +687,8 @@ var dlqColumns = [
|
|
|
694
687
|
annotations: [],
|
|
695
688
|
ttl: null,
|
|
696
689
|
codec: null,
|
|
697
|
-
materialized: null
|
|
690
|
+
materialized: null,
|
|
691
|
+
comment: null
|
|
698
692
|
},
|
|
699
693
|
{
|
|
700
694
|
name: "errorType",
|
|
@@ -706,7 +700,8 @@ var dlqColumns = [
|
|
|
706
700
|
annotations: [],
|
|
707
701
|
ttl: null,
|
|
708
702
|
codec: null,
|
|
709
|
-
materialized: null
|
|
703
|
+
materialized: null,
|
|
704
|
+
comment: null
|
|
710
705
|
},
|
|
711
706
|
{
|
|
712
707
|
name: "failedAt",
|
|
@@ -718,7 +713,8 @@ var dlqColumns = [
|
|
|
718
713
|
annotations: [],
|
|
719
714
|
ttl: null,
|
|
720
715
|
codec: null,
|
|
721
|
-
materialized: null
|
|
716
|
+
materialized: null,
|
|
717
|
+
comment: null
|
|
722
718
|
},
|
|
723
719
|
{
|
|
724
720
|
name: "source",
|
|
@@ -730,7 +726,8 @@ var dlqColumns = [
|
|
|
730
726
|
annotations: [],
|
|
731
727
|
ttl: null,
|
|
732
728
|
codec: null,
|
|
733
|
-
materialized: null
|
|
729
|
+
materialized: null,
|
|
730
|
+
comment: null
|
|
734
731
|
}
|
|
735
732
|
];
|
|
736
733
|
|
|
@@ -2236,6 +2233,67 @@ var ETLPipeline = class {
|
|
|
2236
2233
|
}
|
|
2237
2234
|
};
|
|
2238
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
|
+
|
|
2239
2297
|
// src/dmv2/sdk/sqlResource.ts
|
|
2240
2298
|
var SqlResource = class {
|
|
2241
2299
|
/** @internal */
|
|
@@ -2290,66 +2348,18 @@ var SqlResource = class {
|
|
|
2290
2348
|
}
|
|
2291
2349
|
};
|
|
2292
2350
|
|
|
2293
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2294
|
-
var requireTargetTableName = (tableName) => {
|
|
2295
|
-
if (typeof tableName === "string") {
|
|
2296
|
-
return tableName;
|
|
2297
|
-
} else {
|
|
2298
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2299
|
-
}
|
|
2300
|
-
};
|
|
2301
|
-
var MaterializedView = class extends SqlResource {
|
|
2302
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2303
|
-
targetTable;
|
|
2304
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2305
|
-
let selectStatement = options.selectStatement;
|
|
2306
|
-
if (typeof selectStatement !== "string") {
|
|
2307
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2308
|
-
}
|
|
2309
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2310
|
-
throw new Error(
|
|
2311
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2312
|
-
);
|
|
2313
|
-
}
|
|
2314
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2315
|
-
requireTargetTableName(
|
|
2316
|
-
options.targetTable?.name ?? options.tableName
|
|
2317
|
-
),
|
|
2318
|
-
{
|
|
2319
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2320
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2321
|
-
},
|
|
2322
|
-
targetSchema,
|
|
2323
|
-
targetColumns
|
|
2324
|
-
);
|
|
2325
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2326
|
-
throw new Error(
|
|
2327
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2328
|
-
);
|
|
2329
|
-
}
|
|
2330
|
-
super(
|
|
2331
|
-
options.materializedViewName,
|
|
2332
|
-
[
|
|
2333
|
-
createMaterializedView({
|
|
2334
|
-
name: options.materializedViewName,
|
|
2335
|
-
destinationTable: targetTable.name,
|
|
2336
|
-
select: selectStatement
|
|
2337
|
-
})
|
|
2338
|
-
// Population is now handled automatically by Rust infrastructure
|
|
2339
|
-
// based on table engine type and whether this is a new or updated view
|
|
2340
|
-
],
|
|
2341
|
-
[dropView(options.materializedViewName)],
|
|
2342
|
-
{
|
|
2343
|
-
pullsDataFrom: options.selectTables,
|
|
2344
|
-
pushesDataTo: [targetTable]
|
|
2345
|
-
}
|
|
2346
|
-
);
|
|
2347
|
-
this.targetTable = targetTable;
|
|
2348
|
-
}
|
|
2349
|
-
};
|
|
2350
|
-
|
|
2351
2351
|
// src/dmv2/sdk/view.ts
|
|
2352
|
-
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;
|
|
2353
2363
|
/**
|
|
2354
2364
|
* Creates a new View instance.
|
|
2355
2365
|
* @param name The name of the view to be created.
|
|
@@ -2360,17 +2370,16 @@ var View = class extends SqlResource {
|
|
|
2360
2370
|
if (typeof selectStatement !== "string") {
|
|
2361
2371
|
selectStatement = toStaticQuery(selectStatement);
|
|
2362
2372
|
}
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
{
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
);
|
|
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);
|
|
2374
2383
|
}
|
|
2375
2384
|
};
|
|
2376
2385
|
|
|
@@ -2559,6 +2568,18 @@ function getWebApps() {
|
|
|
2559
2568
|
function getWebApp(name) {
|
|
2560
2569
|
return getMooseInternal().webApps.get(name);
|
|
2561
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
|
+
}
|
|
2562
2583
|
export {
|
|
2563
2584
|
Api,
|
|
2564
2585
|
ConsumptionApi,
|
|
@@ -2577,8 +2598,12 @@ export {
|
|
|
2577
2598
|
Workflow,
|
|
2578
2599
|
getApi,
|
|
2579
2600
|
getApis,
|
|
2601
|
+
getCustomView,
|
|
2602
|
+
getCustomViews,
|
|
2580
2603
|
getIngestApi,
|
|
2581
2604
|
getIngestApis,
|
|
2605
|
+
getMaterializedView,
|
|
2606
|
+
getMaterializedViews,
|
|
2582
2607
|
getSqlResource,
|
|
2583
2608
|
getSqlResources,
|
|
2584
2609
|
getStream,
|