@514labs/moose-lib 0.6.297-ci-35-g4e0a867f → 0.6.297-ci-23-g751e4221

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, 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';
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-CdKEq7FH.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, 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';
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-CdKEq7FH.js';
2
2
  import 'typia';
3
3
  import 'typia/src/schemas/json/IJsonSchemaCollection';
4
4
  import 'node:stream';
@@ -239,14 +239,6 @@ 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
- }
250
242
  var init_helpers = __esm({
251
243
  "src/blocks/helpers.ts"() {
252
244
  "use strict";
@@ -597,7 +589,9 @@ var init_internal = __esm({
597
589
  apis: /* @__PURE__ */ new Map(),
598
590
  sqlResources: /* @__PURE__ */ new Map(),
599
591
  workflows: /* @__PURE__ */ new Map(),
600
- webApps: /* @__PURE__ */ new Map()
592
+ webApps: /* @__PURE__ */ new Map(),
593
+ materializedViews: /* @__PURE__ */ new Map(),
594
+ customViews: /* @__PURE__ */ new Map()
601
595
  };
602
596
  defaultRetentionPeriod = 60 * 60 * 24 * 7;
603
597
  getMooseInternal = () => globalThis.moose_internal;
@@ -2478,6 +2472,84 @@ var init_etlPipeline = __esm({
2478
2472
  }
2479
2473
  });
2480
2474
 
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
+ /** Optional metadata for the materialized view */
2504
+ metadata;
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
+ this.metadata = options.metadata ? { ...options.metadata } : {};
2536
+ if (!this.metadata.source) {
2537
+ const stack = new Error().stack;
2538
+ const sourceInfo = getSourceFileFromStack(stack);
2539
+ if (sourceInfo) {
2540
+ this.metadata.source = { file: sourceInfo };
2541
+ }
2542
+ }
2543
+ const materializedViews = getMooseInternal().materializedViews;
2544
+ if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2545
+ throw new Error(`MaterializedView with name ${this.name} already exists`);
2546
+ }
2547
+ materializedViews.set(this.name, this);
2548
+ }
2549
+ };
2550
+ }
2551
+ });
2552
+
2481
2553
  // src/dmv2/sdk/sqlResource.ts
2482
2554
  var SqlResource;
2483
2555
  var init_sqlResource = __esm({
@@ -2541,104 +2613,52 @@ var init_sqlResource = __esm({
2541
2613
  }
2542
2614
  });
2543
2615
 
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
-
2612
2616
  // src/dmv2/sdk/view.ts
2613
2617
  var View;
2614
2618
  var init_view = __esm({
2615
2619
  "src/dmv2/sdk/view.ts"() {
2616
2620
  "use strict";
2617
- init_helpers();
2618
2621
  init_sqlHelpers();
2619
- init_sqlResource();
2620
- View = class extends SqlResource {
2622
+ init_internal();
2623
+ init_stackTrace();
2624
+ View = class {
2625
+ /** @internal */
2626
+ kind = "CustomView";
2627
+ /** The name of the view */
2628
+ name;
2629
+ /** The SELECT SQL statement that defines the view */
2630
+ selectSql;
2631
+ /** Names of source tables/views that the SELECT reads from */
2632
+ sourceTables;
2633
+ /** Optional metadata for the view */
2634
+ metadata;
2621
2635
  /**
2622
2636
  * Creates a new View instance.
2623
2637
  * @param name The name of the view to be created.
2624
2638
  * @param selectStatement The SQL SELECT statement that defines the view's logic.
2625
2639
  * @param baseTables An array of OlapTable or View objects that the `selectStatement` reads from. Used for dependency tracking.
2640
+ * @param metadata Optional metadata for the view (e.g., description, source file).
2626
2641
  */
2627
- constructor(name, selectStatement, baseTables) {
2642
+ constructor(name, selectStatement, baseTables, metadata) {
2628
2643
  if (typeof selectStatement !== "string") {
2629
2644
  selectStatement = toStaticQuery(selectStatement);
2630
2645
  }
2631
- super(
2632
- name,
2633
- [
2634
- `CREATE VIEW IF NOT EXISTS ${name}
2635
- AS ${selectStatement}`.trim()
2636
- ],
2637
- [dropView(name)],
2638
- {
2639
- pullsDataFrom: baseTables
2646
+ this.name = name;
2647
+ this.selectSql = selectStatement;
2648
+ this.sourceTables = baseTables.map((t) => t.name);
2649
+ this.metadata = metadata ? { ...metadata } : {};
2650
+ if (!this.metadata.source) {
2651
+ const stack = new Error().stack;
2652
+ const sourceInfo = getSourceFileFromStack(stack);
2653
+ if (sourceInfo) {
2654
+ this.metadata.source = { file: sourceInfo };
2640
2655
  }
2641
- );
2656
+ }
2657
+ const customViews = getMooseInternal().customViews;
2658
+ if (!isClientOnlyMode() && customViews.has(this.name)) {
2659
+ throw new Error(`View with name ${this.name} already exists`);
2660
+ }
2661
+ customViews.set(this.name, this);
2642
2662
  }
2643
2663
  };
2644
2664
  }
@@ -2842,6 +2862,18 @@ function getWebApps() {
2842
2862
  function getWebApp(name) {
2843
2863
  return getMooseInternal().webApps.get(name);
2844
2864
  }
2865
+ function getMaterializedViews() {
2866
+ return getMooseInternal().materializedViews;
2867
+ }
2868
+ function getMaterializedView(name) {
2869
+ return getMooseInternal().materializedViews.get(name);
2870
+ }
2871
+ function getCustomViews() {
2872
+ return getMooseInternal().customViews;
2873
+ }
2874
+ function getCustomView(name) {
2875
+ return getMooseInternal().customViews.get(name);
2876
+ }
2845
2877
  var init_registry = __esm({
2846
2878
  "src/dmv2/registry.ts"() {
2847
2879
  "use strict";
@@ -2869,8 +2901,12 @@ __export(dmv2_exports, {
2869
2901
  Workflow: () => Workflow,
2870
2902
  getApi: () => getApi,
2871
2903
  getApis: () => getApis,
2904
+ getCustomView: () => getCustomView,
2905
+ getCustomViews: () => getCustomViews,
2872
2906
  getIngestApi: () => getIngestApi,
2873
2907
  getIngestApis: () => getIngestApis,
2908
+ getMaterializedView: () => getMaterializedView,
2909
+ getMaterializedViews: () => getMaterializedViews,
2874
2910
  getSqlResource: () => getSqlResource,
2875
2911
  getSqlResources: () => getSqlResources,
2876
2912
  getStream: () => getStream,
@@ -2920,8 +2956,12 @@ init_dmv2();
2920
2956
  Workflow,
2921
2957
  getApi,
2922
2958
  getApis,
2959
+ getCustomView,
2960
+ getCustomViews,
2923
2961
  getIngestApi,
2924
2962
  getIngestApis,
2963
+ getMaterializedView,
2964
+ getMaterializedViews,
2925
2965
  getSqlResource,
2926
2966
  getSqlResources,
2927
2967
  getStream,