@514labs/moose-lib 0.6.262-ci-5-gf85ca97c → 0.6.262-ci-2-gfc2fb4ba

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/index.mjs CHANGED
@@ -655,9 +655,7 @@ var moose_internal = {
655
655
  apis: /* @__PURE__ */ new Map(),
656
656
  sqlResources: /* @__PURE__ */ new Map(),
657
657
  workflows: /* @__PURE__ */ new Map(),
658
- webApps: /* @__PURE__ */ new Map(),
659
- materializedViews: /* @__PURE__ */ new Map(),
660
- customViews: /* @__PURE__ */ new Map()
658
+ webApps: /* @__PURE__ */ new Map()
661
659
  };
662
660
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
663
661
  var getMooseInternal = () => globalThis.moose_internal;
@@ -673,8 +671,6 @@ var loadIndex = () => {
673
671
  registry.sqlResources.clear();
674
672
  registry.workflows.clear();
675
673
  registry.webApps.clear();
676
- registry.materializedViews.clear();
677
- registry.customViews.clear();
678
674
  const appDir = `${process2.cwd()}/${getSourceDir()}`;
679
675
  Object.keys(__require.cache).forEach((key) => {
680
676
  if (key.startsWith(appDir)) {
@@ -2102,6 +2098,7 @@ var IngestPipeline = class extends TypedBase {
2102
2098
  if (config.table) {
2103
2099
  const tableConfig = typeof config.table === "object" ? {
2104
2100
  ...config.table,
2101
+ lifeCycle: config.table.lifeCycle ?? config.lifeCycle,
2105
2102
  ...config.version && { version: config.version }
2106
2103
  } : {
2107
2104
  lifeCycle: config.lifeCycle,
@@ -2132,7 +2129,10 @@ var IngestPipeline = class extends TypedBase {
2132
2129
  const streamConfig = {
2133
2130
  destination: this.table,
2134
2131
  defaultDeadLetterQueue: this.deadLetterQueue,
2135
- ...typeof config.stream === "object" ? config.stream : { lifeCycle: config.lifeCycle },
2132
+ ...typeof config.stream === "object" ? {
2133
+ ...config.stream,
2134
+ lifeCycle: config.stream.lifeCycle ?? config.lifeCycle
2135
+ } : { lifeCycle: config.lifeCycle },
2136
2136
  ...config.version && { version: config.version }
2137
2137
  };
2138
2138
  this.stream = new Stream(
@@ -2308,67 +2308,6 @@ var ETLPipeline = class {
2308
2308
  }
2309
2309
  };
2310
2310
 
2311
- // src/dmv2/sdk/materializedView.ts
2312
- var requireTargetTableName = (tableName) => {
2313
- if (typeof tableName === "string") {
2314
- return tableName;
2315
- } else {
2316
- throw new Error("Name of targetTable is not specified.");
2317
- }
2318
- };
2319
- var MaterializedView = class {
2320
- /** @internal */
2321
- kind = "MaterializedView";
2322
- /** The name of the materialized view */
2323
- name;
2324
- /** The target OlapTable instance where the materialized data is stored. */
2325
- targetTable;
2326
- /** The SELECT SQL statement */
2327
- selectSql;
2328
- /** Names of source tables that the SELECT reads from */
2329
- sourceTables;
2330
- /** @internal Source file path where this MV was defined */
2331
- sourceFile;
2332
- constructor(options, targetSchema, targetColumns) {
2333
- let selectStatement = options.selectStatement;
2334
- if (typeof selectStatement !== "string") {
2335
- selectStatement = toStaticQuery(selectStatement);
2336
- }
2337
- if (targetSchema === void 0 || targetColumns === void 0) {
2338
- throw new Error(
2339
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2340
- );
2341
- }
2342
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2343
- requireTargetTableName(
2344
- options.targetTable?.name ?? options.tableName
2345
- ),
2346
- {
2347
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2348
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2349
- },
2350
- targetSchema,
2351
- targetColumns
2352
- );
2353
- if (targetTable.name === options.materializedViewName) {
2354
- throw new Error(
2355
- "Materialized view name cannot be the same as the target table name."
2356
- );
2357
- }
2358
- this.name = options.materializedViewName;
2359
- this.targetTable = targetTable;
2360
- this.selectSql = selectStatement;
2361
- this.sourceTables = options.selectTables.map((t) => t.name);
2362
- const stack = new Error().stack;
2363
- this.sourceFile = getSourceFileFromStack(stack);
2364
- const materializedViews = getMooseInternal().materializedViews;
2365
- if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2366
- throw new Error(`MaterializedView with name ${this.name} already exists`);
2367
- }
2368
- materializedViews.set(this.name, this);
2369
- }
2370
- };
2371
-
2372
2311
  // src/dmv2/sdk/sqlResource.ts
2373
2312
  var SqlResource = class {
2374
2313
  /** @internal */
@@ -2414,18 +2353,66 @@ var SqlResource = class {
2414
2353
  }
2415
2354
  };
2416
2355
 
2356
+ // src/dmv2/sdk/materializedView.ts
2357
+ var requireTargetTableName = (tableName) => {
2358
+ if (typeof tableName === "string") {
2359
+ return tableName;
2360
+ } else {
2361
+ throw new Error("Name of targetTable is not specified.");
2362
+ }
2363
+ };
2364
+ var MaterializedView = class extends SqlResource {
2365
+ /** The target OlapTable instance where the materialized data is stored. */
2366
+ targetTable;
2367
+ constructor(options, targetSchema, targetColumns) {
2368
+ let selectStatement = options.selectStatement;
2369
+ if (typeof selectStatement !== "string") {
2370
+ selectStatement = toStaticQuery(selectStatement);
2371
+ }
2372
+ if (targetSchema === void 0 || targetColumns === void 0) {
2373
+ throw new Error(
2374
+ "Supply the type param T so that the schema is inserted by the compiler plugin."
2375
+ );
2376
+ }
2377
+ const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2378
+ requireTargetTableName(
2379
+ options.targetTable?.name ?? options.tableName
2380
+ ),
2381
+ {
2382
+ orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2383
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2384
+ },
2385
+ targetSchema,
2386
+ targetColumns
2387
+ );
2388
+ if (targetTable.name === options.materializedViewName) {
2389
+ throw new Error(
2390
+ "Materialized view name cannot be the same as the target table name."
2391
+ );
2392
+ }
2393
+ super(
2394
+ options.materializedViewName,
2395
+ [
2396
+ createMaterializedView({
2397
+ name: options.materializedViewName,
2398
+ destinationTable: targetTable.name,
2399
+ select: selectStatement
2400
+ })
2401
+ // Population is now handled automatically by Rust infrastructure
2402
+ // based on table engine type and whether this is a new or updated view
2403
+ ],
2404
+ [dropView(options.materializedViewName)],
2405
+ {
2406
+ pullsDataFrom: options.selectTables,
2407
+ pushesDataTo: [targetTable]
2408
+ }
2409
+ );
2410
+ this.targetTable = targetTable;
2411
+ }
2412
+ };
2413
+
2417
2414
  // src/dmv2/sdk/view.ts
2418
- var View = class {
2419
- /** @internal */
2420
- kind = "CustomView";
2421
- /** The name of the view */
2422
- name;
2423
- /** The SELECT SQL statement that defines the view */
2424
- selectSql;
2425
- /** Names of source tables/views that the SELECT reads from */
2426
- sourceTables;
2427
- /** @internal Source file path where this view was defined */
2428
- sourceFile;
2415
+ var View = class extends SqlResource {
2429
2416
  /**
2430
2417
  * Creates a new View instance.
2431
2418
  * @param name The name of the view to be created.
@@ -2436,16 +2423,17 @@ var View = class {
2436
2423
  if (typeof selectStatement !== "string") {
2437
2424
  selectStatement = toStaticQuery(selectStatement);
2438
2425
  }
2439
- this.name = name;
2440
- this.selectSql = selectStatement;
2441
- this.sourceTables = baseTables.map((t) => t.name);
2442
- const stack = new Error().stack;
2443
- this.sourceFile = getSourceFileFromStack(stack);
2444
- const customViews = getMooseInternal().customViews;
2445
- if (!isClientOnlyMode() && customViews.has(this.name)) {
2446
- throw new Error(`View with name ${this.name} already exists`);
2447
- }
2448
- customViews.set(this.name, this);
2426
+ super(
2427
+ name,
2428
+ [
2429
+ `CREATE VIEW IF NOT EXISTS ${name}
2430
+ AS ${selectStatement}`.trim()
2431
+ ],
2432
+ [dropView(name)],
2433
+ {
2434
+ pullsDataFrom: baseTables
2435
+ }
2436
+ );
2449
2437
  }
2450
2438
  };
2451
2439