@514labs/moose-lib 0.6.295-ci-20-gbe187727 → 0.6.295

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.
@@ -1,4 +1,4 @@
1
- export { A as Aggregated, h as Api, i as ApiConfig, ak as ConsumerConfig, C as ConsumptionApi, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, g as IngestConfig, j as IngestPipeline, ao as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, ap as MaterializedViewConfig, a as OlapConfig, O as OlapTable, b as S3QueueTableSettings, S as SimpleAggregated, k as SqlResource, c as Stream, d as StreamConfig, T as Task, an as TaskConfig, am as TaskContext, al as TransformConfig, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, x as getApi, w as getApis, K as getCustomView, N as getCustomViews, v as getIngestApi, u as getIngestApis, P as getMaterializedView, Q as getMaterializedViews, z as getSqlResource, y as getSqlResources, t as getStream, s as getStreams, r as getTable, q as getTables, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows } from '../index-CcZRaA0b.mjs';
1
+ export { A as Aggregated, h as Api, i as ApiConfig, ag as ConsumerConfig, C as ConsumptionApi, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, g as IngestConfig, j as IngestPipeline, ak as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, al as MaterializedViewConfig, a as OlapConfig, O as OlapTable, b as S3QueueTableSettings, S as SimpleAggregated, k as SqlResource, c as Stream, d as StreamConfig, T as Task, aj as TaskConfig, ai as TaskContext, ah as TransformConfig, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, x as getApi, w as getApis, v as getIngestApi, u as getIngestApis, z as getSqlResource, y as getSqlResources, t as getStream, s as getStreams, r as getTable, q as getTables, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows } from '../index-rQOQo9sv.mjs';
2
2
  import 'typia';
3
3
  import 'typia/src/schemas/json/IJsonSchemaCollection';
4
4
  import 'node:stream';
@@ -1,4 +1,4 @@
1
- export { A as Aggregated, h as Api, i as ApiConfig, ak as ConsumerConfig, C as ConsumptionApi, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, g as IngestConfig, j as IngestPipeline, ao as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, ap as MaterializedViewConfig, a as OlapConfig, O as OlapTable, b as S3QueueTableSettings, S as SimpleAggregated, k as SqlResource, c as Stream, d as StreamConfig, T as Task, an as TaskConfig, am as TaskContext, al as TransformConfig, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, x as getApi, w as getApis, K as getCustomView, N as getCustomViews, v as getIngestApi, u as getIngestApis, P as getMaterializedView, Q as getMaterializedViews, z as getSqlResource, y as getSqlResources, t as getStream, s as getStreams, r as getTable, q as getTables, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows } from '../index-CcZRaA0b.js';
1
+ export { A as Aggregated, h as Api, i as ApiConfig, ag as ConsumerConfig, C as ConsumptionApi, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, g as IngestConfig, j as IngestPipeline, ak as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, al as MaterializedViewConfig, a as OlapConfig, O as OlapTable, b as S3QueueTableSettings, S as SimpleAggregated, k as SqlResource, c as Stream, d as StreamConfig, T as Task, aj as TaskConfig, ai as TaskContext, ah as TransformConfig, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, x as getApi, w as getApis, v as getIngestApi, u as getIngestApis, z as getSqlResource, y as getSqlResources, t as getStream, s as getStreams, r as getTable, q as getTables, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows } from '../index-rQOQo9sv.js';
2
2
  import 'typia';
3
3
  import 'typia/src/schemas/json/IJsonSchemaCollection';
4
4
  import 'node:stream';
@@ -401,12 +401,8 @@ __export(dmv2_exports, {
401
401
  Workflow: () => Workflow,
402
402
  getApi: () => getApi,
403
403
  getApis: () => getApis,
404
- getCustomView: () => getCustomView,
405
- getCustomViews: () => getCustomViews,
406
404
  getIngestApi: () => getIngestApi,
407
405
  getIngestApis: () => getIngestApis,
408
- getMaterializedView: () => getMaterializedView,
409
- getMaterializedViews: () => getMaterializedViews,
410
406
  getSqlResource: () => getSqlResource,
411
407
  getSqlResources: () => getSqlResources,
412
408
  getStream: () => getStream,
@@ -605,6 +601,16 @@ function emptyIfUndefined(value) {
605
601
  return value === void 0 ? "" : value;
606
602
  }
607
603
 
604
+ // src/blocks/helpers.ts
605
+ function dropView(name) {
606
+ return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
607
+ }
608
+ function createMaterializedView(options) {
609
+ return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
610
+ TO ${quoteIdentifier(options.destinationTable)}
611
+ AS ${options.select}`.trim();
612
+ }
613
+
608
614
  // src/dmv2/internal.ts
609
615
  var import_process = __toESM(require("process"));
610
616
 
@@ -655,9 +661,7 @@ var moose_internal = {
655
661
  apis: /* @__PURE__ */ new Map(),
656
662
  sqlResources: /* @__PURE__ */ new Map(),
657
663
  workflows: /* @__PURE__ */ new Map(),
658
- webApps: /* @__PURE__ */ new Map(),
659
- materializedViews: /* @__PURE__ */ new Map(),
660
- customViews: /* @__PURE__ */ new Map()
664
+ webApps: /* @__PURE__ */ new Map()
661
665
  };
662
666
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
663
667
  var getMooseInternal = () => globalThis.moose_internal;
@@ -2291,67 +2295,6 @@ var ETLPipeline = class {
2291
2295
  }
2292
2296
  };
2293
2297
 
2294
- // src/dmv2/sdk/materializedView.ts
2295
- var requireTargetTableName = (tableName) => {
2296
- if (typeof tableName === "string") {
2297
- return tableName;
2298
- } else {
2299
- throw new Error("Name of targetTable is not specified.");
2300
- }
2301
- };
2302
- var MaterializedView = class {
2303
- /** @internal */
2304
- kind = "MaterializedView";
2305
- /** The name of the materialized view */
2306
- name;
2307
- /** The target OlapTable instance where the materialized data is stored. */
2308
- targetTable;
2309
- /** The SELECT SQL statement */
2310
- selectSql;
2311
- /** Names of source tables that the SELECT reads from */
2312
- sourceTables;
2313
- /** @internal Source file path where this MV was defined */
2314
- sourceFile;
2315
- constructor(options, targetSchema, targetColumns) {
2316
- let selectStatement = options.selectStatement;
2317
- if (typeof selectStatement !== "string") {
2318
- selectStatement = toStaticQuery(selectStatement);
2319
- }
2320
- if (targetSchema === void 0 || targetColumns === void 0) {
2321
- throw new Error(
2322
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2323
- );
2324
- }
2325
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2326
- requireTargetTableName(
2327
- options.targetTable?.name ?? options.tableName
2328
- ),
2329
- {
2330
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2331
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2332
- },
2333
- targetSchema,
2334
- targetColumns
2335
- );
2336
- if (targetTable.name === options.materializedViewName) {
2337
- throw new Error(
2338
- "Materialized view name cannot be the same as the target table name."
2339
- );
2340
- }
2341
- this.name = options.materializedViewName;
2342
- this.targetTable = targetTable;
2343
- this.selectSql = selectStatement;
2344
- this.sourceTables = options.selectTables.map((t) => t.name);
2345
- const stack = new Error().stack;
2346
- this.sourceFile = getSourceFileFromStack(stack);
2347
- const materializedViews = getMooseInternal().materializedViews;
2348
- if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2349
- throw new Error(`MaterializedView with name ${this.name} already exists`);
2350
- }
2351
- materializedViews.set(this.name, this);
2352
- }
2353
- };
2354
-
2355
2298
  // src/dmv2/sdk/sqlResource.ts
2356
2299
  var SqlResource = class {
2357
2300
  /** @internal */
@@ -2406,18 +2349,66 @@ var SqlResource = class {
2406
2349
  }
2407
2350
  };
2408
2351
 
2352
+ // src/dmv2/sdk/materializedView.ts
2353
+ var requireTargetTableName = (tableName) => {
2354
+ if (typeof tableName === "string") {
2355
+ return tableName;
2356
+ } else {
2357
+ throw new Error("Name of targetTable is not specified.");
2358
+ }
2359
+ };
2360
+ var MaterializedView = class extends SqlResource {
2361
+ /** The target OlapTable instance where the materialized data is stored. */
2362
+ targetTable;
2363
+ constructor(options, targetSchema, targetColumns) {
2364
+ let selectStatement = options.selectStatement;
2365
+ if (typeof selectStatement !== "string") {
2366
+ selectStatement = toStaticQuery(selectStatement);
2367
+ }
2368
+ if (targetSchema === void 0 || targetColumns === void 0) {
2369
+ throw new Error(
2370
+ "Supply the type param T so that the schema is inserted by the compiler plugin."
2371
+ );
2372
+ }
2373
+ const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2374
+ requireTargetTableName(
2375
+ options.targetTable?.name ?? options.tableName
2376
+ ),
2377
+ {
2378
+ orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2379
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2380
+ },
2381
+ targetSchema,
2382
+ targetColumns
2383
+ );
2384
+ if (targetTable.name === options.materializedViewName) {
2385
+ throw new Error(
2386
+ "Materialized view name cannot be the same as the target table name."
2387
+ );
2388
+ }
2389
+ super(
2390
+ options.materializedViewName,
2391
+ [
2392
+ createMaterializedView({
2393
+ name: options.materializedViewName,
2394
+ destinationTable: targetTable.name,
2395
+ select: selectStatement
2396
+ })
2397
+ // Population is now handled automatically by Rust infrastructure
2398
+ // based on table engine type and whether this is a new or updated view
2399
+ ],
2400
+ [dropView(options.materializedViewName)],
2401
+ {
2402
+ pullsDataFrom: options.selectTables,
2403
+ pushesDataTo: [targetTable]
2404
+ }
2405
+ );
2406
+ this.targetTable = targetTable;
2407
+ }
2408
+ };
2409
+
2409
2410
  // src/dmv2/sdk/view.ts
2410
- var View = class {
2411
- /** @internal */
2412
- kind = "CustomView";
2413
- /** The name of the view */
2414
- name;
2415
- /** The SELECT SQL statement that defines the view */
2416
- selectSql;
2417
- /** Names of source tables/views that the SELECT reads from */
2418
- sourceTables;
2419
- /** @internal Source file path where this view was defined */
2420
- sourceFile;
2411
+ var View = class extends SqlResource {
2421
2412
  /**
2422
2413
  * Creates a new View instance.
2423
2414
  * @param name The name of the view to be created.
@@ -2428,16 +2419,17 @@ var View = class {
2428
2419
  if (typeof selectStatement !== "string") {
2429
2420
  selectStatement = toStaticQuery(selectStatement);
2430
2421
  }
2431
- this.name = name;
2432
- this.selectSql = selectStatement;
2433
- this.sourceTables = baseTables.map((t) => t.name);
2434
- const stack = new Error().stack;
2435
- this.sourceFile = getSourceFileFromStack(stack);
2436
- const customViews = getMooseInternal().customViews;
2437
- if (!isClientOnlyMode() && customViews.has(this.name)) {
2438
- throw new Error(`View with name ${this.name} already exists`);
2439
- }
2440
- customViews.set(this.name, this);
2422
+ super(
2423
+ name,
2424
+ [
2425
+ `CREATE VIEW IF NOT EXISTS ${name}
2426
+ AS ${selectStatement}`.trim()
2427
+ ],
2428
+ [dropView(name)],
2429
+ {
2430
+ pullsDataFrom: baseTables
2431
+ }
2432
+ );
2441
2433
  }
2442
2434
  };
2443
2435
 
@@ -2626,18 +2618,6 @@ function getWebApps() {
2626
2618
  function getWebApp(name) {
2627
2619
  return getMooseInternal().webApps.get(name);
2628
2620
  }
2629
- function getMaterializedViews() {
2630
- return getMooseInternal().materializedViews;
2631
- }
2632
- function getMaterializedView(name) {
2633
- return getMooseInternal().materializedViews.get(name);
2634
- }
2635
- function getCustomViews() {
2636
- return getMooseInternal().customViews;
2637
- }
2638
- function getCustomView(name) {
2639
- return getMooseInternal().customViews.get(name);
2640
- }
2641
2621
  // Annotate the CommonJS export names for ESM import in node:
2642
2622
  0 && (module.exports = {
2643
2623
  Api,
@@ -2657,12 +2637,8 @@ function getCustomView(name) {
2657
2637
  Workflow,
2658
2638
  getApi,
2659
2639
  getApis,
2660
- getCustomView,
2661
- getCustomViews,
2662
2640
  getIngestApi,
2663
2641
  getIngestApis,
2664
- getMaterializedView,
2665
- getMaterializedViews,
2666
2642
  getSqlResource,
2667
2643
  getSqlResources,
2668
2644
  getStream,