@514labs/moose-lib 0.6.262-ci-2-g350aed07 → 0.6.262-ci-5-gf85ca97c
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-Bqhjy4pn.d.ts → browserCompatible-BpwCKgGF.d.ts} +1 -1
- package/dist/{browserCompatible-DTtKuO-Y.d.mts → browserCompatible-CDqMXtd_.d.mts} +1 -1
- package/dist/browserCompatible.d.mts +2 -2
- package/dist/browserCompatible.d.ts +2 -2
- package/dist/browserCompatible.js +87 -119
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +87 -119
- 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 +87 -119
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +87 -119
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-CQB6bk1i.d.mts → index-B2jILcTY.d.mts} +56 -40
- package/dist/{index-CQB6bk1i.d.ts → index-B2jILcTY.d.ts} +56 -40
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +89 -109
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -109
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +28 -4
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +28 -4
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +1 -1
package/dist/dmv2/index.mjs
CHANGED
|
@@ -387,35 +387,8 @@ function getSourceFileInfo(stack) {
|
|
|
387
387
|
}
|
|
388
388
|
return {};
|
|
389
389
|
}
|
|
390
|
-
function getSourceLocationFromStack(stack) {
|
|
391
|
-
if (!stack) return void 0;
|
|
392
|
-
const lines = stack.split("\n");
|
|
393
|
-
for (const line of lines.slice(1)) {
|
|
394
|
-
if (shouldSkipStackLine(line)) {
|
|
395
|
-
continue;
|
|
396
|
-
}
|
|
397
|
-
const v8Match = line.match(/at\s+(?:.*?\s+\()?(.+):(\d+):(\d+)\)?/);
|
|
398
|
-
if (v8Match) {
|
|
399
|
-
return {
|
|
400
|
-
file: v8Match[1],
|
|
401
|
-
line: parseInt(v8Match[2], 10),
|
|
402
|
-
column: parseInt(v8Match[3], 10)
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
const smMatch = line.match(/(?:.*@)?(.+):(\d+):(\d+)/);
|
|
406
|
-
if (smMatch) {
|
|
407
|
-
return {
|
|
408
|
-
file: smMatch[1],
|
|
409
|
-
line: parseInt(smMatch[2], 10),
|
|
410
|
-
column: parseInt(smMatch[3], 10)
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
return void 0;
|
|
415
|
-
}
|
|
416
390
|
function getSourceFileFromStack(stack) {
|
|
417
|
-
|
|
418
|
-
return location?.file;
|
|
391
|
+
return getSourceFileInfo(stack).file;
|
|
419
392
|
}
|
|
420
393
|
|
|
421
394
|
// src/dmv2/typedBase.ts
|
|
@@ -533,16 +506,6 @@ function emptyIfUndefined(value) {
|
|
|
533
506
|
return value === void 0 ? "" : value;
|
|
534
507
|
}
|
|
535
508
|
|
|
536
|
-
// src/blocks/helpers.ts
|
|
537
|
-
function dropView(name) {
|
|
538
|
-
return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
|
|
539
|
-
}
|
|
540
|
-
function createMaterializedView(options) {
|
|
541
|
-
return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
|
|
542
|
-
TO ${quoteIdentifier(options.destinationTable)}
|
|
543
|
-
AS ${options.select}`.trim();
|
|
544
|
-
}
|
|
545
|
-
|
|
546
509
|
// src/dmv2/internal.ts
|
|
547
510
|
import process2 from "process";
|
|
548
511
|
|
|
@@ -596,7 +559,9 @@ var moose_internal = {
|
|
|
596
559
|
apis: /* @__PURE__ */ new Map(),
|
|
597
560
|
sqlResources: /* @__PURE__ */ new Map(),
|
|
598
561
|
workflows: /* @__PURE__ */ new Map(),
|
|
599
|
-
webApps: /* @__PURE__ */ new Map()
|
|
562
|
+
webApps: /* @__PURE__ */ new Map(),
|
|
563
|
+
materializedViews: /* @__PURE__ */ new Map(),
|
|
564
|
+
customViews: /* @__PURE__ */ new Map()
|
|
600
565
|
};
|
|
601
566
|
var defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
602
567
|
var getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -2212,6 +2177,67 @@ var ETLPipeline = class {
|
|
|
2212
2177
|
}
|
|
2213
2178
|
};
|
|
2214
2179
|
|
|
2180
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2181
|
+
var requireTargetTableName = (tableName) => {
|
|
2182
|
+
if (typeof tableName === "string") {
|
|
2183
|
+
return tableName;
|
|
2184
|
+
} else {
|
|
2185
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2186
|
+
}
|
|
2187
|
+
};
|
|
2188
|
+
var MaterializedView = class {
|
|
2189
|
+
/** @internal */
|
|
2190
|
+
kind = "MaterializedView";
|
|
2191
|
+
/** The name of the materialized view */
|
|
2192
|
+
name;
|
|
2193
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2194
|
+
targetTable;
|
|
2195
|
+
/** The SELECT SQL statement */
|
|
2196
|
+
selectSql;
|
|
2197
|
+
/** Names of source tables that the SELECT reads from */
|
|
2198
|
+
sourceTables;
|
|
2199
|
+
/** @internal Source file path where this MV was defined */
|
|
2200
|
+
sourceFile;
|
|
2201
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2202
|
+
let selectStatement = options.selectStatement;
|
|
2203
|
+
if (typeof selectStatement !== "string") {
|
|
2204
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2205
|
+
}
|
|
2206
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2207
|
+
throw new Error(
|
|
2208
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2209
|
+
);
|
|
2210
|
+
}
|
|
2211
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2212
|
+
requireTargetTableName(
|
|
2213
|
+
options.targetTable?.name ?? options.tableName
|
|
2214
|
+
),
|
|
2215
|
+
{
|
|
2216
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2217
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2218
|
+
},
|
|
2219
|
+
targetSchema,
|
|
2220
|
+
targetColumns
|
|
2221
|
+
);
|
|
2222
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2223
|
+
throw new Error(
|
|
2224
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2225
|
+
);
|
|
2226
|
+
}
|
|
2227
|
+
this.name = options.materializedViewName;
|
|
2228
|
+
this.targetTable = targetTable;
|
|
2229
|
+
this.selectSql = selectStatement;
|
|
2230
|
+
this.sourceTables = options.selectTables.map((t) => t.name);
|
|
2231
|
+
const stack = new Error().stack;
|
|
2232
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2233
|
+
const materializedViews = getMooseInternal().materializedViews;
|
|
2234
|
+
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2235
|
+
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2236
|
+
}
|
|
2237
|
+
materializedViews.set(this.name, this);
|
|
2238
|
+
}
|
|
2239
|
+
};
|
|
2240
|
+
|
|
2215
2241
|
// src/dmv2/sdk/sqlResource.ts
|
|
2216
2242
|
var SqlResource = class {
|
|
2217
2243
|
/** @internal */
|
|
@@ -2228,10 +2254,6 @@ var SqlResource = class {
|
|
|
2228
2254
|
pushesDataTo;
|
|
2229
2255
|
/** @internal Source file path where this resource was defined */
|
|
2230
2256
|
sourceFile;
|
|
2231
|
-
/** @internal Source line number where this resource was defined */
|
|
2232
|
-
sourceLine;
|
|
2233
|
-
/** @internal Source column number where this resource was defined */
|
|
2234
|
-
sourceColumn;
|
|
2235
2257
|
/**
|
|
2236
2258
|
* Creates a new SqlResource instance.
|
|
2237
2259
|
* @param name The name of the resource.
|
|
@@ -2257,75 +2279,22 @@ var SqlResource = class {
|
|
|
2257
2279
|
this.pullsDataFrom = options?.pullsDataFrom ?? [];
|
|
2258
2280
|
this.pushesDataTo = options?.pushesDataTo ?? [];
|
|
2259
2281
|
const stack = new Error().stack;
|
|
2260
|
-
|
|
2261
|
-
if (location) {
|
|
2262
|
-
this.sourceFile = location.file;
|
|
2263
|
-
this.sourceLine = location.line;
|
|
2264
|
-
this.sourceColumn = location.column;
|
|
2265
|
-
}
|
|
2266
|
-
}
|
|
2267
|
-
};
|
|
2268
|
-
|
|
2269
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2270
|
-
var requireTargetTableName = (tableName) => {
|
|
2271
|
-
if (typeof tableName === "string") {
|
|
2272
|
-
return tableName;
|
|
2273
|
-
} else {
|
|
2274
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2275
|
-
}
|
|
2276
|
-
};
|
|
2277
|
-
var MaterializedView = class extends SqlResource {
|
|
2278
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2279
|
-
targetTable;
|
|
2280
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2281
|
-
let selectStatement = options.selectStatement;
|
|
2282
|
-
if (typeof selectStatement !== "string") {
|
|
2283
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2284
|
-
}
|
|
2285
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2286
|
-
throw new Error(
|
|
2287
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2288
|
-
);
|
|
2289
|
-
}
|
|
2290
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2291
|
-
requireTargetTableName(
|
|
2292
|
-
options.targetTable?.name ?? options.tableName
|
|
2293
|
-
),
|
|
2294
|
-
{
|
|
2295
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2296
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2297
|
-
},
|
|
2298
|
-
targetSchema,
|
|
2299
|
-
targetColumns
|
|
2300
|
-
);
|
|
2301
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2302
|
-
throw new Error(
|
|
2303
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2304
|
-
);
|
|
2305
|
-
}
|
|
2306
|
-
super(
|
|
2307
|
-
options.materializedViewName,
|
|
2308
|
-
[
|
|
2309
|
-
createMaterializedView({
|
|
2310
|
-
name: options.materializedViewName,
|
|
2311
|
-
destinationTable: targetTable.name,
|
|
2312
|
-
select: selectStatement
|
|
2313
|
-
})
|
|
2314
|
-
// Population is now handled automatically by Rust infrastructure
|
|
2315
|
-
// based on table engine type and whether this is a new or updated view
|
|
2316
|
-
],
|
|
2317
|
-
[dropView(options.materializedViewName)],
|
|
2318
|
-
{
|
|
2319
|
-
pullsDataFrom: options.selectTables,
|
|
2320
|
-
pushesDataTo: [targetTable]
|
|
2321
|
-
}
|
|
2322
|
-
);
|
|
2323
|
-
this.targetTable = targetTable;
|
|
2282
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2324
2283
|
}
|
|
2325
2284
|
};
|
|
2326
2285
|
|
|
2327
2286
|
// src/dmv2/sdk/view.ts
|
|
2328
|
-
var View = class
|
|
2287
|
+
var View = class {
|
|
2288
|
+
/** @internal */
|
|
2289
|
+
kind = "CustomView";
|
|
2290
|
+
/** The name of the view */
|
|
2291
|
+
name;
|
|
2292
|
+
/** The SELECT SQL statement that defines the view */
|
|
2293
|
+
selectSql;
|
|
2294
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
2295
|
+
sourceTables;
|
|
2296
|
+
/** @internal Source file path where this view was defined */
|
|
2297
|
+
sourceFile;
|
|
2329
2298
|
/**
|
|
2330
2299
|
* Creates a new View instance.
|
|
2331
2300
|
* @param name The name of the view to be created.
|
|
@@ -2336,17 +2305,16 @@ var View = class extends SqlResource {
|
|
|
2336
2305
|
if (typeof selectStatement !== "string") {
|
|
2337
2306
|
selectStatement = toStaticQuery(selectStatement);
|
|
2338
2307
|
}
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
{
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
);
|
|
2308
|
+
this.name = name;
|
|
2309
|
+
this.selectSql = selectStatement;
|
|
2310
|
+
this.sourceTables = baseTables.map((t) => t.name);
|
|
2311
|
+
const stack = new Error().stack;
|
|
2312
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2313
|
+
const customViews = getMooseInternal().customViews;
|
|
2314
|
+
if (!isClientOnlyMode() && customViews.has(this.name)) {
|
|
2315
|
+
throw new Error(`View with name ${this.name} already exists`);
|
|
2316
|
+
}
|
|
2317
|
+
customViews.set(this.name, this);
|
|
2350
2318
|
}
|
|
2351
2319
|
};
|
|
2352
2320
|
|