@514labs/moose-lib 0.6.262-ci-2-g39e53084 → 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-CC6Jamxn.d.ts → browserCompatible-BpwCKgGF.d.ts} +1 -1
- package/dist/{browserCompatible-GsBQtLKo.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 +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 +85 -81
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +85 -81
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-B1HsstjQ.d.mts → index-B2jILcTY.d.mts} +56 -36
- package/dist/{index-B1HsstjQ.d.ts → index-B2jILcTY.d.ts} +56 -36
- 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
|
@@ -506,16 +506,6 @@ function emptyIfUndefined(value) {
|
|
|
506
506
|
return value === void 0 ? "" : value;
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
-
// src/blocks/helpers.ts
|
|
510
|
-
function dropView(name) {
|
|
511
|
-
return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
|
|
512
|
-
}
|
|
513
|
-
function createMaterializedView(options) {
|
|
514
|
-
return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
|
|
515
|
-
TO ${quoteIdentifier(options.destinationTable)}
|
|
516
|
-
AS ${options.select}`.trim();
|
|
517
|
-
}
|
|
518
|
-
|
|
519
509
|
// src/dmv2/internal.ts
|
|
520
510
|
import process2 from "process";
|
|
521
511
|
|
|
@@ -569,7 +559,9 @@ var moose_internal = {
|
|
|
569
559
|
apis: /* @__PURE__ */ new Map(),
|
|
570
560
|
sqlResources: /* @__PURE__ */ new Map(),
|
|
571
561
|
workflows: /* @__PURE__ */ new Map(),
|
|
572
|
-
webApps: /* @__PURE__ */ new Map()
|
|
562
|
+
webApps: /* @__PURE__ */ new Map(),
|
|
563
|
+
materializedViews: /* @__PURE__ */ new Map(),
|
|
564
|
+
customViews: /* @__PURE__ */ new Map()
|
|
573
565
|
};
|
|
574
566
|
var defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
575
567
|
var getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -2185,6 +2177,67 @@ var ETLPipeline = class {
|
|
|
2185
2177
|
}
|
|
2186
2178
|
};
|
|
2187
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
|
+
|
|
2188
2241
|
// src/dmv2/sdk/sqlResource.ts
|
|
2189
2242
|
var SqlResource = class {
|
|
2190
2243
|
/** @internal */
|
|
@@ -2230,66 +2283,18 @@ var SqlResource = class {
|
|
|
2230
2283
|
}
|
|
2231
2284
|
};
|
|
2232
2285
|
|
|
2233
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2234
|
-
var requireTargetTableName = (tableName) => {
|
|
2235
|
-
if (typeof tableName === "string") {
|
|
2236
|
-
return tableName;
|
|
2237
|
-
} else {
|
|
2238
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2239
|
-
}
|
|
2240
|
-
};
|
|
2241
|
-
var MaterializedView = class extends SqlResource {
|
|
2242
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2243
|
-
targetTable;
|
|
2244
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2245
|
-
let selectStatement = options.selectStatement;
|
|
2246
|
-
if (typeof selectStatement !== "string") {
|
|
2247
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2248
|
-
}
|
|
2249
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2250
|
-
throw new Error(
|
|
2251
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2252
|
-
);
|
|
2253
|
-
}
|
|
2254
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2255
|
-
requireTargetTableName(
|
|
2256
|
-
options.targetTable?.name ?? options.tableName
|
|
2257
|
-
),
|
|
2258
|
-
{
|
|
2259
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2260
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2261
|
-
},
|
|
2262
|
-
targetSchema,
|
|
2263
|
-
targetColumns
|
|
2264
|
-
);
|
|
2265
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2266
|
-
throw new Error(
|
|
2267
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2268
|
-
);
|
|
2269
|
-
}
|
|
2270
|
-
super(
|
|
2271
|
-
options.materializedViewName,
|
|
2272
|
-
[
|
|
2273
|
-
createMaterializedView({
|
|
2274
|
-
name: options.materializedViewName,
|
|
2275
|
-
destinationTable: targetTable.name,
|
|
2276
|
-
select: selectStatement
|
|
2277
|
-
})
|
|
2278
|
-
// Population is now handled automatically by Rust infrastructure
|
|
2279
|
-
// based on table engine type and whether this is a new or updated view
|
|
2280
|
-
],
|
|
2281
|
-
[dropView(options.materializedViewName)],
|
|
2282
|
-
{
|
|
2283
|
-
pullsDataFrom: options.selectTables,
|
|
2284
|
-
pushesDataTo: [targetTable]
|
|
2285
|
-
}
|
|
2286
|
-
);
|
|
2287
|
-
this.targetTable = targetTable;
|
|
2288
|
-
}
|
|
2289
|
-
};
|
|
2290
|
-
|
|
2291
2286
|
// src/dmv2/sdk/view.ts
|
|
2292
|
-
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;
|
|
2293
2298
|
/**
|
|
2294
2299
|
* Creates a new View instance.
|
|
2295
2300
|
* @param name The name of the view to be created.
|
|
@@ -2300,17 +2305,16 @@ var View = class extends SqlResource {
|
|
|
2300
2305
|
if (typeof selectStatement !== "string") {
|
|
2301
2306
|
selectStatement = toStaticQuery(selectStatement);
|
|
2302
2307
|
}
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
{
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
);
|
|
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);
|
|
2314
2318
|
}
|
|
2315
2319
|
};
|
|
2316
2320
|
|