@514labs/moose-lib 0.6.297-ci-40-g26f564af → 0.6.297

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, al 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, ap as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, aq 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, ao as TaskConfig, an as TaskContext, am 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, P as getMaterializedView, Q as getMaterializedViews, z as getSqlResource, y as getSqlResources, t as getStream, s as getStreams, r as getTable, q as getTables, K as getView, N as getViews, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows } from '../index-CI9e2hZ2.mjs';
1
+ export { A as Aggregated, h as Api, i as ApiConfig, ah 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, al as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, am 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, ak as TaskConfig, aj as TaskContext, ai 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-CcHF2cVT.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, al 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, ap as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, aq 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, ao as TaskConfig, an as TaskContext, am 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, P as getMaterializedView, Q as getMaterializedViews, z as getSqlResource, y as getSqlResources, t as getStream, s as getStreams, r as getTable, q as getTables, K as getView, N as getViews, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows } from '../index-CI9e2hZ2.js';
1
+ export { A as Aggregated, h as Api, i as ApiConfig, ah 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, al as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, am 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, ak as TaskConfig, aj as TaskContext, ai 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-CcHF2cVT.js';
2
2
  import 'typia';
3
3
  import 'typia/src/schemas/json/IJsonSchemaCollection';
4
4
  import 'node:stream';
@@ -239,6 +239,14 @@ var init_sqlHelpers = __esm({
239
239
  });
240
240
 
241
241
  // src/blocks/helpers.ts
242
+ function dropView(name) {
243
+ return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
244
+ }
245
+ function createMaterializedView(options) {
246
+ return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
247
+ TO ${quoteIdentifier(options.destinationTable)}
248
+ AS ${options.select}`.trim();
249
+ }
242
250
  var init_helpers = __esm({
243
251
  "src/blocks/helpers.ts"() {
244
252
  "use strict";
@@ -589,9 +597,7 @@ var init_internal = __esm({
589
597
  apis: /* @__PURE__ */ new Map(),
590
598
  sqlResources: /* @__PURE__ */ new Map(),
591
599
  workflows: /* @__PURE__ */ new Map(),
592
- webApps: /* @__PURE__ */ new Map(),
593
- materializedViews: /* @__PURE__ */ new Map(),
594
- views: /* @__PURE__ */ new Map()
600
+ webApps: /* @__PURE__ */ new Map()
595
601
  };
596
602
  defaultRetentionPeriod = 60 * 60 * 24 * 7;
597
603
  getMooseInternal = () => globalThis.moose_internal;
@@ -2472,93 +2478,6 @@ var init_etlPipeline = __esm({
2472
2478
  }
2473
2479
  });
2474
2480
 
2475
- // src/dmv2/sdk/materializedView.ts
2476
- function formatTableReference(table) {
2477
- const database = table instanceof OlapTable ? table.config.database : void 0;
2478
- if (database) {
2479
- return `\`${database}\`.\`${table.name}\``;
2480
- }
2481
- return `\`${table.name}\``;
2482
- }
2483
- var requireTargetTableName, MaterializedView;
2484
- var init_materializedView = __esm({
2485
- "src/dmv2/sdk/materializedView.ts"() {
2486
- "use strict";
2487
- init_helpers();
2488
- init_sqlHelpers();
2489
- init_olapTable();
2490
- init_internal();
2491
- init_stackTrace();
2492
- requireTargetTableName = (tableName) => {
2493
- if (typeof tableName === "string") {
2494
- return tableName;
2495
- } else {
2496
- throw new Error("Name of targetTable is not specified.");
2497
- }
2498
- };
2499
- MaterializedView = class {
2500
- /** @internal */
2501
- kind = "MaterializedView";
2502
- /** The name of the materialized view */
2503
- name;
2504
- /** The target OlapTable instance where the materialized data is stored. */
2505
- targetTable;
2506
- /** The SELECT SQL statement */
2507
- selectSql;
2508
- /** Names of source tables that the SELECT reads from */
2509
- sourceTables;
2510
- /** Optional metadata for the materialized view */
2511
- metadata;
2512
- constructor(options, targetSchema, targetColumns) {
2513
- let selectStatement = options.selectStatement;
2514
- if (typeof selectStatement !== "string") {
2515
- selectStatement = toStaticQuery(selectStatement);
2516
- }
2517
- if (targetSchema === void 0 || targetColumns === void 0) {
2518
- throw new Error(
2519
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2520
- );
2521
- }
2522
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2523
- requireTargetTableName(
2524
- options.targetTable?.name ?? options.tableName
2525
- ),
2526
- {
2527
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2528
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2529
- },
2530
- targetSchema,
2531
- targetColumns
2532
- );
2533
- if (targetTable.name === options.materializedViewName) {
2534
- throw new Error(
2535
- "Materialized view name cannot be the same as the target table name."
2536
- );
2537
- }
2538
- this.name = options.materializedViewName;
2539
- this.targetTable = targetTable;
2540
- this.selectSql = selectStatement;
2541
- this.sourceTables = options.selectTables.map(
2542
- (t) => formatTableReference(t)
2543
- );
2544
- this.metadata = options.metadata ? { ...options.metadata } : {};
2545
- if (!this.metadata.source) {
2546
- const stack = new Error().stack;
2547
- const sourceInfo = getSourceFileFromStack(stack);
2548
- if (sourceInfo) {
2549
- this.metadata.source = { file: sourceInfo };
2550
- }
2551
- }
2552
- const materializedViews = getMooseInternal().materializedViews;
2553
- if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2554
- throw new Error(`MaterializedView with name ${this.name} already exists`);
2555
- }
2556
- materializedViews.set(this.name, this);
2557
- }
2558
- };
2559
- }
2560
- });
2561
-
2562
2481
  // src/dmv2/sdk/sqlResource.ts
2563
2482
  var SqlResource;
2564
2483
  var init_sqlResource = __esm({
@@ -2622,60 +2541,104 @@ var init_sqlResource = __esm({
2622
2541
  }
2623
2542
  });
2624
2543
 
2625
- // src/dmv2/sdk/view.ts
2626
- function formatTableReference2(table) {
2627
- const database = table instanceof OlapTable ? table.config.database : void 0;
2628
- if (database) {
2629
- return `\`${database}\`.\`${table.name}\``;
2544
+ // src/dmv2/sdk/materializedView.ts
2545
+ var requireTargetTableName, MaterializedView;
2546
+ var init_materializedView = __esm({
2547
+ "src/dmv2/sdk/materializedView.ts"() {
2548
+ "use strict";
2549
+ init_helpers();
2550
+ init_sqlHelpers();
2551
+ init_olapTable();
2552
+ init_sqlResource();
2553
+ requireTargetTableName = (tableName) => {
2554
+ if (typeof tableName === "string") {
2555
+ return tableName;
2556
+ } else {
2557
+ throw new Error("Name of targetTable is not specified.");
2558
+ }
2559
+ };
2560
+ MaterializedView = class extends SqlResource {
2561
+ /** The target OlapTable instance where the materialized data is stored. */
2562
+ targetTable;
2563
+ constructor(options, targetSchema, targetColumns) {
2564
+ let selectStatement = options.selectStatement;
2565
+ if (typeof selectStatement !== "string") {
2566
+ selectStatement = toStaticQuery(selectStatement);
2567
+ }
2568
+ if (targetSchema === void 0 || targetColumns === void 0) {
2569
+ throw new Error(
2570
+ "Supply the type param T so that the schema is inserted by the compiler plugin."
2571
+ );
2572
+ }
2573
+ const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2574
+ requireTargetTableName(
2575
+ options.targetTable?.name ?? options.tableName
2576
+ ),
2577
+ {
2578
+ orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2579
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2580
+ },
2581
+ targetSchema,
2582
+ targetColumns
2583
+ );
2584
+ if (targetTable.name === options.materializedViewName) {
2585
+ throw new Error(
2586
+ "Materialized view name cannot be the same as the target table name."
2587
+ );
2588
+ }
2589
+ super(
2590
+ options.materializedViewName,
2591
+ [
2592
+ createMaterializedView({
2593
+ name: options.materializedViewName,
2594
+ destinationTable: targetTable.name,
2595
+ select: selectStatement
2596
+ })
2597
+ // Population is now handled automatically by Rust infrastructure
2598
+ // based on table engine type and whether this is a new or updated view
2599
+ ],
2600
+ [dropView(options.materializedViewName)],
2601
+ {
2602
+ pullsDataFrom: options.selectTables,
2603
+ pushesDataTo: [targetTable]
2604
+ }
2605
+ );
2606
+ this.targetTable = targetTable;
2607
+ }
2608
+ };
2630
2609
  }
2631
- return `\`${table.name}\``;
2632
- }
2610
+ });
2611
+
2612
+ // src/dmv2/sdk/view.ts
2633
2613
  var View;
2634
2614
  var init_view = __esm({
2635
2615
  "src/dmv2/sdk/view.ts"() {
2636
2616
  "use strict";
2617
+ init_helpers();
2637
2618
  init_sqlHelpers();
2638
- init_olapTable();
2639
- init_internal();
2640
- init_stackTrace();
2641
- View = class {
2642
- /** @internal */
2643
- kind = "View";
2644
- /** The name of the view */
2645
- name;
2646
- /** The SELECT SQL statement that defines the view */
2647
- selectSql;
2648
- /** Names of source tables/views that the SELECT reads from */
2649
- sourceTables;
2650
- /** Optional metadata for the view */
2651
- metadata;
2619
+ init_sqlResource();
2620
+ View = class extends SqlResource {
2652
2621
  /**
2653
2622
  * Creates a new View instance.
2654
2623
  * @param name The name of the view to be created.
2655
2624
  * @param selectStatement The SQL SELECT statement that defines the view's logic.
2656
2625
  * @param baseTables An array of OlapTable or View objects that the `selectStatement` reads from. Used for dependency tracking.
2657
- * @param metadata Optional metadata for the view (e.g., description, source file).
2658
2626
  */
2659
- constructor(name, selectStatement, baseTables, metadata) {
2627
+ constructor(name, selectStatement, baseTables) {
2660
2628
  if (typeof selectStatement !== "string") {
2661
2629
  selectStatement = toStaticQuery(selectStatement);
2662
2630
  }
2663
- this.name = name;
2664
- this.selectSql = selectStatement;
2665
- this.sourceTables = baseTables.map((t) => formatTableReference2(t));
2666
- this.metadata = metadata ? { ...metadata } : {};
2667
- if (!this.metadata.source) {
2668
- const stack = new Error().stack;
2669
- const sourceInfo = getSourceFileFromStack(stack);
2670
- if (sourceInfo) {
2671
- this.metadata.source = { file: sourceInfo };
2631
+ super(
2632
+ name,
2633
+ [
2634
+ `CREATE VIEW IF NOT EXISTS ${name}
2635
+ AS ${selectStatement}`.trim()
2636
+ ],
2637
+ [dropView(name)],
2638
+ {
2639
+ pullsDataFrom: baseTables
2672
2640
  }
2673
- }
2674
- const views = getMooseInternal().views;
2675
- if (!isClientOnlyMode() && views.has(this.name)) {
2676
- throw new Error(`View with name ${this.name} already exists`);
2677
- }
2678
- views.set(this.name, this);
2641
+ );
2679
2642
  }
2680
2643
  };
2681
2644
  }
@@ -2879,18 +2842,6 @@ function getWebApps() {
2879
2842
  function getWebApp(name) {
2880
2843
  return getMooseInternal().webApps.get(name);
2881
2844
  }
2882
- function getMaterializedViews() {
2883
- return getMooseInternal().materializedViews;
2884
- }
2885
- function getMaterializedView(name) {
2886
- return getMooseInternal().materializedViews.get(name);
2887
- }
2888
- function getViews() {
2889
- return getMooseInternal().views;
2890
- }
2891
- function getView(name) {
2892
- return getMooseInternal().views.get(name);
2893
- }
2894
2845
  var init_registry = __esm({
2895
2846
  "src/dmv2/registry.ts"() {
2896
2847
  "use strict";
@@ -2920,16 +2871,12 @@ __export(dmv2_exports, {
2920
2871
  getApis: () => getApis,
2921
2872
  getIngestApi: () => getIngestApi,
2922
2873
  getIngestApis: () => getIngestApis,
2923
- getMaterializedView: () => getMaterializedView,
2924
- getMaterializedViews: () => getMaterializedViews,
2925
2874
  getSqlResource: () => getSqlResource,
2926
2875
  getSqlResources: () => getSqlResources,
2927
2876
  getStream: () => getStream,
2928
2877
  getStreams: () => getStreams,
2929
2878
  getTable: () => getTable,
2930
2879
  getTables: () => getTables,
2931
- getView: () => getView,
2932
- getViews: () => getViews,
2933
2880
  getWebApp: () => getWebApp,
2934
2881
  getWebApps: () => getWebApps,
2935
2882
  getWorkflow: () => getWorkflow,
@@ -2975,16 +2922,12 @@ init_dmv2();
2975
2922
  getApis,
2976
2923
  getIngestApi,
2977
2924
  getIngestApis,
2978
- getMaterializedView,
2979
- getMaterializedViews,
2980
2925
  getSqlResource,
2981
2926
  getSqlResources,
2982
2927
  getStream,
2983
2928
  getStreams,
2984
2929
  getTable,
2985
2930
  getTables,
2986
- getView,
2987
- getViews,
2988
2931
  getWebApp,
2989
2932
  getWebApps,
2990
2933
  getWorkflow,