@514labs/moose-lib 0.6.266-ci-8-ge6e86870 → 0.6.267
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-y8O70Ttx.d.mts → browserCompatible-15NCyT1P.d.mts} +1 -1
- package/dist/{browserCompatible-vY6tmKGn.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 -85
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +81 -85
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-DSzxmiN9.d.mts → index-BtkwFbT9.d.mts} +83 -62
- package/dist/{index-DSzxmiN9.d.ts → index-BtkwFbT9.d.ts} +83 -62
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +73 -87
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -87
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +37 -29
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +37 -29
- 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;
|
|
@@ -2223,67 +2231,6 @@ var ETLPipeline = class {
|
|
|
2223
2231
|
}
|
|
2224
2232
|
};
|
|
2225
2233
|
|
|
2226
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2227
|
-
var requireTargetTableName = (tableName) => {
|
|
2228
|
-
if (typeof tableName === "string") {
|
|
2229
|
-
return tableName;
|
|
2230
|
-
} else {
|
|
2231
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2232
|
-
}
|
|
2233
|
-
};
|
|
2234
|
-
var MaterializedView = class {
|
|
2235
|
-
/** @internal */
|
|
2236
|
-
kind = "MaterializedView";
|
|
2237
|
-
/** The name of the materialized view */
|
|
2238
|
-
name;
|
|
2239
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2240
|
-
targetTable;
|
|
2241
|
-
/** The SELECT SQL statement */
|
|
2242
|
-
selectSql;
|
|
2243
|
-
/** Names of source tables that the SELECT reads from */
|
|
2244
|
-
sourceTables;
|
|
2245
|
-
/** @internal Source file path where this MV was defined */
|
|
2246
|
-
sourceFile;
|
|
2247
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2248
|
-
let selectStatement = options.selectStatement;
|
|
2249
|
-
if (typeof selectStatement !== "string") {
|
|
2250
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2251
|
-
}
|
|
2252
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2253
|
-
throw new Error(
|
|
2254
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2255
|
-
);
|
|
2256
|
-
}
|
|
2257
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2258
|
-
requireTargetTableName(
|
|
2259
|
-
options.targetTable?.name ?? options.tableName
|
|
2260
|
-
),
|
|
2261
|
-
{
|
|
2262
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2263
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2264
|
-
},
|
|
2265
|
-
targetSchema,
|
|
2266
|
-
targetColumns
|
|
2267
|
-
);
|
|
2268
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2269
|
-
throw new Error(
|
|
2270
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2271
|
-
);
|
|
2272
|
-
}
|
|
2273
|
-
this.name = options.materializedViewName;
|
|
2274
|
-
this.targetTable = targetTable;
|
|
2275
|
-
this.selectSql = selectStatement;
|
|
2276
|
-
this.sourceTables = options.selectTables.map((t) => t.name);
|
|
2277
|
-
const stack = new Error().stack;
|
|
2278
|
-
this.sourceFile = getSourceFileFromStack(stack);
|
|
2279
|
-
const materializedViews = getMooseInternal().materializedViews;
|
|
2280
|
-
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2281
|
-
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2282
|
-
}
|
|
2283
|
-
materializedViews.set(this.name, this);
|
|
2284
|
-
}
|
|
2285
|
-
};
|
|
2286
|
-
|
|
2287
2234
|
// src/dmv2/sdk/sqlResource.ts
|
|
2288
2235
|
var SqlResource = class {
|
|
2289
2236
|
/** @internal */
|
|
@@ -2338,18 +2285,66 @@ var SqlResource = class {
|
|
|
2338
2285
|
}
|
|
2339
2286
|
};
|
|
2340
2287
|
|
|
2288
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2289
|
+
var requireTargetTableName = (tableName) => {
|
|
2290
|
+
if (typeof tableName === "string") {
|
|
2291
|
+
return tableName;
|
|
2292
|
+
} else {
|
|
2293
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2294
|
+
}
|
|
2295
|
+
};
|
|
2296
|
+
var MaterializedView = class extends SqlResource {
|
|
2297
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2298
|
+
targetTable;
|
|
2299
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2300
|
+
let selectStatement = options.selectStatement;
|
|
2301
|
+
if (typeof selectStatement !== "string") {
|
|
2302
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2303
|
+
}
|
|
2304
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2305
|
+
throw new Error(
|
|
2306
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2307
|
+
);
|
|
2308
|
+
}
|
|
2309
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2310
|
+
requireTargetTableName(
|
|
2311
|
+
options.targetTable?.name ?? options.tableName
|
|
2312
|
+
),
|
|
2313
|
+
{
|
|
2314
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2315
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2316
|
+
},
|
|
2317
|
+
targetSchema,
|
|
2318
|
+
targetColumns
|
|
2319
|
+
);
|
|
2320
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2321
|
+
throw new Error(
|
|
2322
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2323
|
+
);
|
|
2324
|
+
}
|
|
2325
|
+
super(
|
|
2326
|
+
options.materializedViewName,
|
|
2327
|
+
[
|
|
2328
|
+
createMaterializedView({
|
|
2329
|
+
name: options.materializedViewName,
|
|
2330
|
+
destinationTable: targetTable.name,
|
|
2331
|
+
select: selectStatement
|
|
2332
|
+
})
|
|
2333
|
+
// Population is now handled automatically by Rust infrastructure
|
|
2334
|
+
// based on table engine type and whether this is a new or updated view
|
|
2335
|
+
],
|
|
2336
|
+
[dropView(options.materializedViewName)],
|
|
2337
|
+
{
|
|
2338
|
+
pullsDataFrom: options.selectTables,
|
|
2339
|
+
pushesDataTo: [targetTable]
|
|
2340
|
+
}
|
|
2341
|
+
);
|
|
2342
|
+
this.targetTable = targetTable;
|
|
2343
|
+
}
|
|
2344
|
+
};
|
|
2345
|
+
|
|
2341
2346
|
// src/dmv2/sdk/view.ts
|
|
2342
|
-
var View = class {
|
|
2343
|
-
/** @internal */
|
|
2344
|
-
kind = "CustomView";
|
|
2345
|
-
/** The name of the view */
|
|
2346
|
-
name;
|
|
2347
|
-
/** The SELECT SQL statement that defines the view */
|
|
2348
|
-
selectSql;
|
|
2349
|
-
/** Names of source tables/views that the SELECT reads from */
|
|
2350
|
-
sourceTables;
|
|
2351
|
-
/** @internal Source file path where this view was defined */
|
|
2352
|
-
sourceFile;
|
|
2347
|
+
var View = class extends SqlResource {
|
|
2353
2348
|
/**
|
|
2354
2349
|
* Creates a new View instance.
|
|
2355
2350
|
* @param name The name of the view to be created.
|
|
@@ -2360,16 +2355,17 @@ var View = class {
|
|
|
2360
2355
|
if (typeof selectStatement !== "string") {
|
|
2361
2356
|
selectStatement = toStaticQuery(selectStatement);
|
|
2362
2357
|
}
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2358
|
+
super(
|
|
2359
|
+
name,
|
|
2360
|
+
[
|
|
2361
|
+
`CREATE VIEW IF NOT EXISTS ${name}
|
|
2362
|
+
AS ${selectStatement}`.trim()
|
|
2363
|
+
],
|
|
2364
|
+
[dropView(name)],
|
|
2365
|
+
{
|
|
2366
|
+
pullsDataFrom: baseTables
|
|
2367
|
+
}
|
|
2368
|
+
);
|
|
2373
2369
|
}
|
|
2374
2370
|
};
|
|
2375
2371
|
|