@514labs/moose-lib 0.6.279-ci-9-gaf2329aa → 0.6.279-ci-1-g5f380e27
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-Bs-byVfO.d.mts} +1 -1
- package/dist/{browserCompatible-BUKAJYbj.d.ts → browserCompatible-D8Hbpq6L.d.ts} +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 +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-BtkwFbT9.d.mts → index-KhGbXtkS.d.mts} +83 -41
- package/dist/{index-BtkwFbT9.d.ts → index-KhGbXtkS.d.ts} +83 -41
- 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
package/dist/dmv2/index.mjs
CHANGED
|
@@ -541,16 +541,6 @@ 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
|
-
|
|
554
544
|
// src/dmv2/internal.ts
|
|
555
545
|
import process2 from "process";
|
|
556
546
|
|
|
@@ -604,7 +594,9 @@ var moose_internal = {
|
|
|
604
594
|
apis: /* @__PURE__ */ new Map(),
|
|
605
595
|
sqlResources: /* @__PURE__ */ new Map(),
|
|
606
596
|
workflows: /* @__PURE__ */ new Map(),
|
|
607
|
-
webApps: /* @__PURE__ */ new Map()
|
|
597
|
+
webApps: /* @__PURE__ */ new Map(),
|
|
598
|
+
materializedViews: /* @__PURE__ */ new Map(),
|
|
599
|
+
customViews: /* @__PURE__ */ new Map()
|
|
608
600
|
};
|
|
609
601
|
var defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
610
602
|
var getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -2233,6 +2225,67 @@ var ETLPipeline = class {
|
|
|
2233
2225
|
}
|
|
2234
2226
|
};
|
|
2235
2227
|
|
|
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
|
+
|
|
2236
2289
|
// src/dmv2/sdk/sqlResource.ts
|
|
2237
2290
|
var SqlResource = class {
|
|
2238
2291
|
/** @internal */
|
|
@@ -2287,66 +2340,18 @@ var SqlResource = class {
|
|
|
2287
2340
|
}
|
|
2288
2341
|
};
|
|
2289
2342
|
|
|
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
|
-
|
|
2348
2343
|
// src/dmv2/sdk/view.ts
|
|
2349
|
-
var View = class
|
|
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;
|
|
2350
2355
|
/**
|
|
2351
2356
|
* Creates a new View instance.
|
|
2352
2357
|
* @param name The name of the view to be created.
|
|
@@ -2357,17 +2362,16 @@ var View = class extends SqlResource {
|
|
|
2357
2362
|
if (typeof selectStatement !== "string") {
|
|
2358
2363
|
selectStatement = toStaticQuery(selectStatement);
|
|
2359
2364
|
}
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
{
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
);
|
|
2365
|
+
this.name = name;
|
|
2366
|
+
this.selectSql = selectStatement;
|
|
2367
|
+
this.sourceTables = baseTables.map((t) => t.name);
|
|
2368
|
+
const stack = new Error().stack;
|
|
2369
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2370
|
+
const customViews = getMooseInternal().customViews;
|
|
2371
|
+
if (!isClientOnlyMode() && customViews.has(this.name)) {
|
|
2372
|
+
throw new Error(`View with name ${this.name} already exists`);
|
|
2373
|
+
}
|
|
2374
|
+
customViews.set(this.name, this);
|
|
2371
2375
|
}
|
|
2372
2376
|
};
|
|
2373
2377
|
|
|
@@ -2556,6 +2560,18 @@ function getWebApps() {
|
|
|
2556
2560
|
function getWebApp(name) {
|
|
2557
2561
|
return getMooseInternal().webApps.get(name);
|
|
2558
2562
|
}
|
|
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
|
+
}
|
|
2559
2575
|
export {
|
|
2560
2576
|
Api,
|
|
2561
2577
|
ConsumptionApi,
|
|
@@ -2574,8 +2590,12 @@ export {
|
|
|
2574
2590
|
Workflow,
|
|
2575
2591
|
getApi,
|
|
2576
2592
|
getApis,
|
|
2593
|
+
getCustomView,
|
|
2594
|
+
getCustomViews,
|
|
2577
2595
|
getIngestApi,
|
|
2578
2596
|
getIngestApis,
|
|
2597
|
+
getMaterializedView,
|
|
2598
|
+
getMaterializedViews,
|
|
2579
2599
|
getSqlResource,
|
|
2580
2600
|
getSqlResources,
|
|
2581
2601
|
getStream,
|