@514labs/moose-lib 0.6.297-ci-22-g1be0de24 → 0.6.297-ci-35-g4e0a867f

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, 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-9XL-mk89.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, 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-9XL-mk89.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
- customViews: /* @__PURE__ */ new Map()
600
+ webApps: /* @__PURE__ */ new Map()
595
601
  };
596
602
  defaultRetentionPeriod = 60 * 60 * 24 * 7;
597
603
  getMooseInternal = () => globalThis.moose_internal;
@@ -2472,78 +2478,6 @@ var init_etlPipeline = __esm({
2472
2478
  }
2473
2479
  });
2474
2480
 
2475
- // src/dmv2/sdk/materializedView.ts
2476
- var requireTargetTableName, MaterializedView;
2477
- var init_materializedView = __esm({
2478
- "src/dmv2/sdk/materializedView.ts"() {
2479
- "use strict";
2480
- init_helpers();
2481
- init_sqlHelpers();
2482
- init_olapTable();
2483
- init_internal();
2484
- init_stackTrace();
2485
- requireTargetTableName = (tableName) => {
2486
- if (typeof tableName === "string") {
2487
- return tableName;
2488
- } else {
2489
- throw new Error("Name of targetTable is not specified.");
2490
- }
2491
- };
2492
- MaterializedView = class {
2493
- /** @internal */
2494
- kind = "MaterializedView";
2495
- /** The name of the materialized view */
2496
- name;
2497
- /** The target OlapTable instance where the materialized data is stored. */
2498
- targetTable;
2499
- /** The SELECT SQL statement */
2500
- selectSql;
2501
- /** Names of source tables that the SELECT reads from */
2502
- sourceTables;
2503
- /** @internal Source file path where this MV was defined */
2504
- sourceFile;
2505
- constructor(options, targetSchema, targetColumns) {
2506
- let selectStatement = options.selectStatement;
2507
- if (typeof selectStatement !== "string") {
2508
- selectStatement = toStaticQuery(selectStatement);
2509
- }
2510
- if (targetSchema === void 0 || targetColumns === void 0) {
2511
- throw new Error(
2512
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2513
- );
2514
- }
2515
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2516
- requireTargetTableName(
2517
- options.targetTable?.name ?? options.tableName
2518
- ),
2519
- {
2520
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2521
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2522
- },
2523
- targetSchema,
2524
- targetColumns
2525
- );
2526
- if (targetTable.name === options.materializedViewName) {
2527
- throw new Error(
2528
- "Materialized view name cannot be the same as the target table name."
2529
- );
2530
- }
2531
- this.name = options.materializedViewName;
2532
- this.targetTable = targetTable;
2533
- this.selectSql = selectStatement;
2534
- this.sourceTables = options.selectTables.map((t) => t.name);
2535
- const stack = new Error().stack;
2536
- this.sourceFile = getSourceFileFromStack(stack);
2537
- const materializedViews = getMooseInternal().materializedViews;
2538
- if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2539
- throw new Error(`MaterializedView with name ${this.name} already exists`);
2540
- }
2541
- materializedViews.set(this.name, this);
2542
- }
2543
- };
2544
- }
2545
- });
2546
-
2547
2481
  // src/dmv2/sdk/sqlResource.ts
2548
2482
  var SqlResource;
2549
2483
  var init_sqlResource = __esm({
@@ -2607,25 +2541,83 @@ var init_sqlResource = __esm({
2607
2541
  }
2608
2542
  });
2609
2543
 
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
+ };
2609
+ }
2610
+ });
2611
+
2610
2612
  // src/dmv2/sdk/view.ts
2611
2613
  var View;
2612
2614
  var init_view = __esm({
2613
2615
  "src/dmv2/sdk/view.ts"() {
2614
2616
  "use strict";
2617
+ init_helpers();
2615
2618
  init_sqlHelpers();
2616
- init_internal();
2617
- init_stackTrace();
2618
- View = class {
2619
- /** @internal */
2620
- kind = "CustomView";
2621
- /** The name of the view */
2622
- name;
2623
- /** The SELECT SQL statement that defines the view */
2624
- selectSql;
2625
- /** Names of source tables/views that the SELECT reads from */
2626
- sourceTables;
2627
- /** @internal Source file path where this view was defined */
2628
- sourceFile;
2619
+ init_sqlResource();
2620
+ View = class extends SqlResource {
2629
2621
  /**
2630
2622
  * Creates a new View instance.
2631
2623
  * @param name The name of the view to be created.
@@ -2636,16 +2628,17 @@ var init_view = __esm({
2636
2628
  if (typeof selectStatement !== "string") {
2637
2629
  selectStatement = toStaticQuery(selectStatement);
2638
2630
  }
2639
- this.name = name;
2640
- this.selectSql = selectStatement;
2641
- this.sourceTables = baseTables.map((t) => t.name);
2642
- const stack = new Error().stack;
2643
- this.sourceFile = getSourceFileFromStack(stack);
2644
- const customViews = getMooseInternal().customViews;
2645
- if (!isClientOnlyMode() && customViews.has(this.name)) {
2646
- throw new Error(`View with name ${this.name} already exists`);
2647
- }
2648
- customViews.set(this.name, this);
2631
+ super(
2632
+ name,
2633
+ [
2634
+ `CREATE VIEW IF NOT EXISTS ${name}
2635
+ AS ${selectStatement}`.trim()
2636
+ ],
2637
+ [dropView(name)],
2638
+ {
2639
+ pullsDataFrom: baseTables
2640
+ }
2641
+ );
2649
2642
  }
2650
2643
  };
2651
2644
  }
@@ -2849,18 +2842,6 @@ function getWebApps() {
2849
2842
  function getWebApp(name) {
2850
2843
  return getMooseInternal().webApps.get(name);
2851
2844
  }
2852
- function getMaterializedViews() {
2853
- return getMooseInternal().materializedViews;
2854
- }
2855
- function getMaterializedView(name) {
2856
- return getMooseInternal().materializedViews.get(name);
2857
- }
2858
- function getCustomViews() {
2859
- return getMooseInternal().customViews;
2860
- }
2861
- function getCustomView(name) {
2862
- return getMooseInternal().customViews.get(name);
2863
- }
2864
2845
  var init_registry = __esm({
2865
2846
  "src/dmv2/registry.ts"() {
2866
2847
  "use strict";
@@ -2888,12 +2869,8 @@ __export(dmv2_exports, {
2888
2869
  Workflow: () => Workflow,
2889
2870
  getApi: () => getApi,
2890
2871
  getApis: () => getApis,
2891
- getCustomView: () => getCustomView,
2892
- getCustomViews: () => getCustomViews,
2893
2872
  getIngestApi: () => getIngestApi,
2894
2873
  getIngestApis: () => getIngestApis,
2895
- getMaterializedView: () => getMaterializedView,
2896
- getMaterializedViews: () => getMaterializedViews,
2897
2874
  getSqlResource: () => getSqlResource,
2898
2875
  getSqlResources: () => getSqlResources,
2899
2876
  getStream: () => getStream,
@@ -2943,12 +2920,8 @@ init_dmv2();
2943
2920
  Workflow,
2944
2921
  getApi,
2945
2922
  getApis,
2946
- getCustomView,
2947
- getCustomViews,
2948
2923
  getIngestApi,
2949
2924
  getIngestApis,
2950
- getMaterializedView,
2951
- getMaterializedViews,
2952
2925
  getSqlResource,
2953
2926
  getSqlResources,
2954
2927
  getStream,