@514labs/moose-lib 0.6.266-ci-2-g933b2685 → 0.6.266-ci-8-ge6e86870

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.
@@ -1841,50 +1841,21 @@ declare class ETLPipeline<T, U> {
1841
1841
  run(): Promise<void>;
1842
1842
  }
1843
1843
 
1844
- type SqlObject = OlapTable<any> | SqlResource;
1845
1844
  /**
1846
- * Represents a generic SQL resource that requires setup and teardown commands.
1847
- * Base class for constructs like Views and Materialized Views. Tracks dependencies.
1845
+ * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1846
+ * Emits structured data for the Moose infrastructure system.
1848
1847
  */
1849
- declare class SqlResource {
1848
+ declare class View {
1850
1849
  /** @internal */
1851
- readonly kind = "SqlResource";
1852
- /** Array of SQL statements to execute for setting up the resource. */
1853
- setup: readonly string[];
1854
- /** Array of SQL statements to execute for tearing down the resource. */
1855
- teardown: readonly string[];
1856
- /** The name of the SQL resource (e.g., view name, materialized view name). */
1850
+ readonly kind = "CustomView";
1851
+ /** The name of the view */
1857
1852
  name: string;
1858
- /** List of OlapTables or Views that this resource reads data from. */
1859
- pullsDataFrom: SqlObject[];
1860
- /** List of OlapTables or Views that this resource writes data to. */
1861
- pushesDataTo: SqlObject[];
1862
- /** @internal Source file path where this resource was defined */
1853
+ /** The SELECT SQL statement that defines the view */
1854
+ selectSql: string;
1855
+ /** Names of source tables/views that the SELECT reads from */
1856
+ sourceTables: string[];
1857
+ /** @internal Source file path where this view was defined */
1863
1858
  sourceFile?: string;
1864
- /** @internal Source line number where this resource was defined */
1865
- sourceLine?: number;
1866
- /** @internal Source column number where this resource was defined */
1867
- sourceColumn?: number;
1868
- /**
1869
- * Creates a new SqlResource instance.
1870
- * @param name The name of the resource.
1871
- * @param setup An array of SQL DDL statements to create the resource.
1872
- * @param teardown An array of SQL DDL statements to drop the resource.
1873
- * @param options Optional configuration for specifying data dependencies.
1874
- * @param options.pullsDataFrom Tables/Views this resource reads from.
1875
- * @param options.pushesDataTo Tables/Views this resource writes to.
1876
- */
1877
- constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1878
- pullsDataFrom?: SqlObject[];
1879
- pushesDataTo?: SqlObject[];
1880
- });
1881
- }
1882
-
1883
- /**
1884
- * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1885
- * Inherits from SqlResource, providing setup (CREATE VIEW) and teardown (DROP VIEW) commands.
1886
- */
1887
- declare class View extends SqlResource {
1888
1859
  /**
1889
1860
  * Creates a new View instance.
1890
1861
  * @param name The name of the view to be created.
@@ -1930,9 +1901,19 @@ interface MaterializedViewConfig<T> {
1930
1901
  *
1931
1902
  * @template TargetTable The data type of the records stored in the underlying target OlapTable. The structure of T defines the target table schema.
1932
1903
  */
1933
- declare class MaterializedView<TargetTable> extends SqlResource {
1904
+ declare class MaterializedView<TargetTable> {
1905
+ /** @internal */
1906
+ readonly kind = "MaterializedView";
1907
+ /** The name of the materialized view */
1908
+ name: string;
1934
1909
  /** The target OlapTable instance where the materialized data is stored. */
1935
1910
  targetTable: OlapTable<TargetTable>;
1911
+ /** The SELECT SQL statement */
1912
+ selectSql: string;
1913
+ /** Names of source tables that the SELECT reads from */
1914
+ sourceTables: string[];
1915
+ /** @internal Source file path where this MV was defined */
1916
+ sourceFile?: string;
1936
1917
  /**
1937
1918
  * Creates a new MaterializedView instance.
1938
1919
  * Requires the `TargetTable` type parameter to be explicitly provided or inferred,
@@ -1945,6 +1926,45 @@ declare class MaterializedView<TargetTable> extends SqlResource {
1945
1926
  constructor(options: MaterializedViewConfig<TargetTable>, targetSchema: IJsonSchemaCollection$1.IV3_1, targetColumns: Column[]);
1946
1927
  }
1947
1928
 
1929
+ type SqlObject = OlapTable<any> | SqlResource;
1930
+ /**
1931
+ * Represents a generic SQL resource that requires setup and teardown commands.
1932
+ * Base class for constructs like Views and Materialized Views. Tracks dependencies.
1933
+ */
1934
+ declare class SqlResource {
1935
+ /** @internal */
1936
+ readonly kind = "SqlResource";
1937
+ /** Array of SQL statements to execute for setting up the resource. */
1938
+ setup: readonly string[];
1939
+ /** Array of SQL statements to execute for tearing down the resource. */
1940
+ teardown: readonly string[];
1941
+ /** The name of the SQL resource (e.g., view name, materialized view name). */
1942
+ name: string;
1943
+ /** List of OlapTables or Views that this resource reads data from. */
1944
+ pullsDataFrom: SqlObject[];
1945
+ /** List of OlapTables or Views that this resource writes data to. */
1946
+ pushesDataTo: SqlObject[];
1947
+ /** @internal Source file path where this resource was defined */
1948
+ sourceFile?: string;
1949
+ /** @internal Source line number where this resource was defined */
1950
+ sourceLine?: number;
1951
+ /** @internal Source column number where this resource was defined */
1952
+ sourceColumn?: number;
1953
+ /**
1954
+ * Creates a new SqlResource instance.
1955
+ * @param name The name of the resource.
1956
+ * @param setup An array of SQL DDL statements to create the resource.
1957
+ * @param teardown An array of SQL DDL statements to drop the resource.
1958
+ * @param options Optional configuration for specifying data dependencies.
1959
+ * @param options.pullsDataFrom Tables/Views this resource reads from.
1960
+ * @param options.pushesDataTo Tables/Views this resource writes to.
1961
+ */
1962
+ constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1963
+ pullsDataFrom?: SqlObject[];
1964
+ pushesDataTo?: SqlObject[];
1965
+ });
1966
+ }
1967
+
1948
1968
  type WebAppHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void | Promise<void>;
1949
1969
  interface FrameworkApp {
1950
1970
  handle?: (req: http.IncomingMessage, res: http.ServerResponse, next?: (err?: any) => void) => void;
@@ -1841,50 +1841,21 @@ declare class ETLPipeline<T, U> {
1841
1841
  run(): Promise<void>;
1842
1842
  }
1843
1843
 
1844
- type SqlObject = OlapTable<any> | SqlResource;
1845
1844
  /**
1846
- * Represents a generic SQL resource that requires setup and teardown commands.
1847
- * Base class for constructs like Views and Materialized Views. Tracks dependencies.
1845
+ * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1846
+ * Emits structured data for the Moose infrastructure system.
1848
1847
  */
1849
- declare class SqlResource {
1848
+ declare class View {
1850
1849
  /** @internal */
1851
- readonly kind = "SqlResource";
1852
- /** Array of SQL statements to execute for setting up the resource. */
1853
- setup: readonly string[];
1854
- /** Array of SQL statements to execute for tearing down the resource. */
1855
- teardown: readonly string[];
1856
- /** The name of the SQL resource (e.g., view name, materialized view name). */
1850
+ readonly kind = "CustomView";
1851
+ /** The name of the view */
1857
1852
  name: string;
1858
- /** List of OlapTables or Views that this resource reads data from. */
1859
- pullsDataFrom: SqlObject[];
1860
- /** List of OlapTables or Views that this resource writes data to. */
1861
- pushesDataTo: SqlObject[];
1862
- /** @internal Source file path where this resource was defined */
1853
+ /** The SELECT SQL statement that defines the view */
1854
+ selectSql: string;
1855
+ /** Names of source tables/views that the SELECT reads from */
1856
+ sourceTables: string[];
1857
+ /** @internal Source file path where this view was defined */
1863
1858
  sourceFile?: string;
1864
- /** @internal Source line number where this resource was defined */
1865
- sourceLine?: number;
1866
- /** @internal Source column number where this resource was defined */
1867
- sourceColumn?: number;
1868
- /**
1869
- * Creates a new SqlResource instance.
1870
- * @param name The name of the resource.
1871
- * @param setup An array of SQL DDL statements to create the resource.
1872
- * @param teardown An array of SQL DDL statements to drop the resource.
1873
- * @param options Optional configuration for specifying data dependencies.
1874
- * @param options.pullsDataFrom Tables/Views this resource reads from.
1875
- * @param options.pushesDataTo Tables/Views this resource writes to.
1876
- */
1877
- constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1878
- pullsDataFrom?: SqlObject[];
1879
- pushesDataTo?: SqlObject[];
1880
- });
1881
- }
1882
-
1883
- /**
1884
- * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1885
- * Inherits from SqlResource, providing setup (CREATE VIEW) and teardown (DROP VIEW) commands.
1886
- */
1887
- declare class View extends SqlResource {
1888
1859
  /**
1889
1860
  * Creates a new View instance.
1890
1861
  * @param name The name of the view to be created.
@@ -1930,9 +1901,19 @@ interface MaterializedViewConfig<T> {
1930
1901
  *
1931
1902
  * @template TargetTable The data type of the records stored in the underlying target OlapTable. The structure of T defines the target table schema.
1932
1903
  */
1933
- declare class MaterializedView<TargetTable> extends SqlResource {
1904
+ declare class MaterializedView<TargetTable> {
1905
+ /** @internal */
1906
+ readonly kind = "MaterializedView";
1907
+ /** The name of the materialized view */
1908
+ name: string;
1934
1909
  /** The target OlapTable instance where the materialized data is stored. */
1935
1910
  targetTable: OlapTable<TargetTable>;
1911
+ /** The SELECT SQL statement */
1912
+ selectSql: string;
1913
+ /** Names of source tables that the SELECT reads from */
1914
+ sourceTables: string[];
1915
+ /** @internal Source file path where this MV was defined */
1916
+ sourceFile?: string;
1936
1917
  /**
1937
1918
  * Creates a new MaterializedView instance.
1938
1919
  * Requires the `TargetTable` type parameter to be explicitly provided or inferred,
@@ -1945,6 +1926,45 @@ declare class MaterializedView<TargetTable> extends SqlResource {
1945
1926
  constructor(options: MaterializedViewConfig<TargetTable>, targetSchema: IJsonSchemaCollection$1.IV3_1, targetColumns: Column[]);
1946
1927
  }
1947
1928
 
1929
+ type SqlObject = OlapTable<any> | SqlResource;
1930
+ /**
1931
+ * Represents a generic SQL resource that requires setup and teardown commands.
1932
+ * Base class for constructs like Views and Materialized Views. Tracks dependencies.
1933
+ */
1934
+ declare class SqlResource {
1935
+ /** @internal */
1936
+ readonly kind = "SqlResource";
1937
+ /** Array of SQL statements to execute for setting up the resource. */
1938
+ setup: readonly string[];
1939
+ /** Array of SQL statements to execute for tearing down the resource. */
1940
+ teardown: readonly string[];
1941
+ /** The name of the SQL resource (e.g., view name, materialized view name). */
1942
+ name: string;
1943
+ /** List of OlapTables or Views that this resource reads data from. */
1944
+ pullsDataFrom: SqlObject[];
1945
+ /** List of OlapTables or Views that this resource writes data to. */
1946
+ pushesDataTo: SqlObject[];
1947
+ /** @internal Source file path where this resource was defined */
1948
+ sourceFile?: string;
1949
+ /** @internal Source line number where this resource was defined */
1950
+ sourceLine?: number;
1951
+ /** @internal Source column number where this resource was defined */
1952
+ sourceColumn?: number;
1953
+ /**
1954
+ * Creates a new SqlResource instance.
1955
+ * @param name The name of the resource.
1956
+ * @param setup An array of SQL DDL statements to create the resource.
1957
+ * @param teardown An array of SQL DDL statements to drop the resource.
1958
+ * @param options Optional configuration for specifying data dependencies.
1959
+ * @param options.pullsDataFrom Tables/Views this resource reads from.
1960
+ * @param options.pushesDataTo Tables/Views this resource writes to.
1961
+ */
1962
+ constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1963
+ pullsDataFrom?: SqlObject[];
1964
+ pushesDataTo?: SqlObject[];
1965
+ });
1966
+ }
1967
+
1948
1968
  type WebAppHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void | Promise<void>;
1949
1969
  interface FrameworkApp {
1950
1970
  handle?: (req: http.IncomingMessage, res: http.ServerResponse, next?: (err?: any) => void) => void;
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- export { C as ClickHouseByteSize, q as ClickHouseCodec, j as ClickHouseDecimal, n as ClickHouseDefault, k as ClickHouseFixedStringSize, l as ClickHouseFloat, a as ClickHouseInt, m as ClickHouseJson, e as ClickHouseLineString, p as ClickHouseMaterialized, f as ClickHouseMultiLineString, h as ClickHouseMultiPolygon, b as ClickHouseNamedTuple, c as ClickHousePoint, g as ClickHousePolygon, i as ClickHousePrecision, d as ClickHouseRing, o as ClickHouseTTL, D as DateTime, r as DateTime64, t as DateTime64String, s as DateTimeString, E as Decimal, F as FixedString, u as Float32, v as Float64, w as Int16, x as Int32, y as Int64, I as Int8, J as JWT, K as Key, L as LowCardinality, z as UInt16, A as UInt32, B as UInt64, U as UInt8, W as WithDefault } from './browserCompatible-fk6xPzoB.mjs';
2
- import { K as ApiUtil, a4 as MooseClient } from './index-Dd3ZmpTq.mjs';
3
- export { A as Aggregated, h as Api, i as ApiConfig, ad as ApiHelpers, a5 as Blocks, a6 as ClickHouseEngines, C as ConsumptionApi, ae as ConsumptionHelpers, N as ConsumptionUtil, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, Q as IdentifierBrandedString, I as IngestApi, g as IngestConfig, j as IngestPipeline, L as LifeCycle, M as MaterializedView, R as NonIdentifierBrandedString, a as OlapConfig, O as OlapTable, aa as QueryClient, X as RawValue, b as S3QueueTableSettings, S as SimpleAggregated, Z as Sql, k as SqlResource, c as Stream, d as StreamConfig, T as Task, U as Value, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, ab as WorkflowClient, a2 as createClickhouseParameter, a8 as createMaterializedView, a7 as dropView, 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, ac as getTemporalClient, a1 as getValueFromParameter, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows, af as joinQueries, a3 as mapToClickHouseType, a9 as populateTable, P as quoteIdentifier, Y as sql, $ as toQuery, a0 as toQueryPreview, _ as toStaticQuery } from './index-Dd3ZmpTq.mjs';
1
+ export { C as ClickHouseByteSize, q as ClickHouseCodec, j as ClickHouseDecimal, n as ClickHouseDefault, k as ClickHouseFixedStringSize, l as ClickHouseFloat, a as ClickHouseInt, m as ClickHouseJson, e as ClickHouseLineString, p as ClickHouseMaterialized, f as ClickHouseMultiLineString, h as ClickHouseMultiPolygon, b as ClickHouseNamedTuple, c as ClickHousePoint, g as ClickHousePolygon, i as ClickHousePrecision, d as ClickHouseRing, o as ClickHouseTTL, D as DateTime, r as DateTime64, t as DateTime64String, s as DateTimeString, E as Decimal, F as FixedString, u as Float32, v as Float64, w as Int16, x as Int32, y as Int64, I as Int8, J as JWT, K as Key, L as LowCardinality, z as UInt16, A as UInt32, B as UInt64, U as UInt8, W as WithDefault } from './browserCompatible-y8O70Ttx.mjs';
2
+ import { K as ApiUtil, a4 as MooseClient } from './index-DSzxmiN9.mjs';
3
+ export { A as Aggregated, h as Api, i as ApiConfig, ad as ApiHelpers, a5 as Blocks, a6 as ClickHouseEngines, C as ConsumptionApi, ae as ConsumptionHelpers, N as ConsumptionUtil, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, Q as IdentifierBrandedString, I as IngestApi, g as IngestConfig, j as IngestPipeline, L as LifeCycle, M as MaterializedView, R as NonIdentifierBrandedString, a as OlapConfig, O as OlapTable, aa as QueryClient, X as RawValue, b as S3QueueTableSettings, S as SimpleAggregated, Z as Sql, k as SqlResource, c as Stream, d as StreamConfig, T as Task, U as Value, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, ab as WorkflowClient, a2 as createClickhouseParameter, a8 as createMaterializedView, a7 as dropView, 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, ac as getTemporalClient, a1 as getValueFromParameter, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows, af as joinQueries, a3 as mapToClickHouseType, a9 as populateTable, P as quoteIdentifier, Y as sql, $ as toQuery, a0 as toQueryPreview, _ as toStaticQuery } from './index-DSzxmiN9.mjs';
4
4
  import * as _clickhouse_client from '@clickhouse/client';
5
5
  import { KafkaJS } from '@confluentinc/kafka-javascript';
6
6
  import http from 'http';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { C as ClickHouseByteSize, q as ClickHouseCodec, j as ClickHouseDecimal, n as ClickHouseDefault, k as ClickHouseFixedStringSize, l as ClickHouseFloat, a as ClickHouseInt, m as ClickHouseJson, e as ClickHouseLineString, p as ClickHouseMaterialized, f as ClickHouseMultiLineString, h as ClickHouseMultiPolygon, b as ClickHouseNamedTuple, c as ClickHousePoint, g as ClickHousePolygon, i as ClickHousePrecision, d as ClickHouseRing, o as ClickHouseTTL, D as DateTime, r as DateTime64, t as DateTime64String, s as DateTimeString, E as Decimal, F as FixedString, u as Float32, v as Float64, w as Int16, x as Int32, y as Int64, I as Int8, J as JWT, K as Key, L as LowCardinality, z as UInt16, A as UInt32, B as UInt64, U as UInt8, W as WithDefault } from './browserCompatible-CpjUXotI.js';
2
- import { K as ApiUtil, a4 as MooseClient } from './index-Dd3ZmpTq.js';
3
- export { A as Aggregated, h as Api, i as ApiConfig, ad as ApiHelpers, a5 as Blocks, a6 as ClickHouseEngines, C as ConsumptionApi, ae as ConsumptionHelpers, N as ConsumptionUtil, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, Q as IdentifierBrandedString, I as IngestApi, g as IngestConfig, j as IngestPipeline, L as LifeCycle, M as MaterializedView, R as NonIdentifierBrandedString, a as OlapConfig, O as OlapTable, aa as QueryClient, X as RawValue, b as S3QueueTableSettings, S as SimpleAggregated, Z as Sql, k as SqlResource, c as Stream, d as StreamConfig, T as Task, U as Value, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, ab as WorkflowClient, a2 as createClickhouseParameter, a8 as createMaterializedView, a7 as dropView, 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, ac as getTemporalClient, a1 as getValueFromParameter, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows, af as joinQueries, a3 as mapToClickHouseType, a9 as populateTable, P as quoteIdentifier, Y as sql, $ as toQuery, a0 as toQueryPreview, _ as toStaticQuery } from './index-Dd3ZmpTq.js';
1
+ export { C as ClickHouseByteSize, q as ClickHouseCodec, j as ClickHouseDecimal, n as ClickHouseDefault, k as ClickHouseFixedStringSize, l as ClickHouseFloat, a as ClickHouseInt, m as ClickHouseJson, e as ClickHouseLineString, p as ClickHouseMaterialized, f as ClickHouseMultiLineString, h as ClickHouseMultiPolygon, b as ClickHouseNamedTuple, c as ClickHousePoint, g as ClickHousePolygon, i as ClickHousePrecision, d as ClickHouseRing, o as ClickHouseTTL, D as DateTime, r as DateTime64, t as DateTime64String, s as DateTimeString, E as Decimal, F as FixedString, u as Float32, v as Float64, w as Int16, x as Int32, y as Int64, I as Int8, J as JWT, K as Key, L as LowCardinality, z as UInt16, A as UInt32, B as UInt64, U as UInt8, W as WithDefault } from './browserCompatible-vY6tmKGn.js';
2
+ import { K as ApiUtil, a4 as MooseClient } from './index-DSzxmiN9.js';
3
+ export { A as Aggregated, h as Api, i as ApiConfig, ad as ApiHelpers, a5 as Blocks, a6 as ClickHouseEngines, C as ConsumptionApi, ae as ConsumptionHelpers, N as ConsumptionUtil, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, Q as IdentifierBrandedString, I as IngestApi, g as IngestConfig, j as IngestPipeline, L as LifeCycle, M as MaterializedView, R as NonIdentifierBrandedString, a as OlapConfig, O as OlapTable, aa as QueryClient, X as RawValue, b as S3QueueTableSettings, S as SimpleAggregated, Z as Sql, k as SqlResource, c as Stream, d as StreamConfig, T as Task, U as Value, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, ab as WorkflowClient, a2 as createClickhouseParameter, a8 as createMaterializedView, a7 as dropView, 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, ac as getTemporalClient, a1 as getValueFromParameter, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows, af as joinQueries, a3 as mapToClickHouseType, a9 as populateTable, P as quoteIdentifier, Y as sql, $ as toQuery, a0 as toQueryPreview, _ as toStaticQuery } from './index-DSzxmiN9.js';
4
4
  import * as _clickhouse_client from '@clickhouse/client';
5
5
  import { KafkaJS } from '@confluentinc/kafka-javascript';
6
6
  import http from 'http';
package/dist/index.js CHANGED
@@ -794,7 +794,9 @@ var moose_internal = {
794
794
  apis: /* @__PURE__ */ new Map(),
795
795
  sqlResources: /* @__PURE__ */ new Map(),
796
796
  workflows: /* @__PURE__ */ new Map(),
797
- webApps: /* @__PURE__ */ new Map()
797
+ webApps: /* @__PURE__ */ new Map(),
798
+ materializedViews: /* @__PURE__ */ new Map(),
799
+ customViews: /* @__PURE__ */ new Map()
798
800
  };
799
801
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
800
802
  var getMooseInternal = () => globalThis.moose_internal;
@@ -810,6 +812,8 @@ var loadIndex = () => {
810
812
  registry.sqlResources.clear();
811
813
  registry.workflows.clear();
812
814
  registry.webApps.clear();
815
+ registry.materializedViews.clear();
816
+ registry.customViews.clear();
813
817
  const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
814
818
  Object.keys(require.cache).forEach((key) => {
815
819
  if (key.startsWith(appDir)) {
@@ -2454,6 +2458,67 @@ var ETLPipeline = class {
2454
2458
  }
2455
2459
  };
2456
2460
 
2461
+ // src/dmv2/sdk/materializedView.ts
2462
+ var requireTargetTableName = (tableName) => {
2463
+ if (typeof tableName === "string") {
2464
+ return tableName;
2465
+ } else {
2466
+ throw new Error("Name of targetTable is not specified.");
2467
+ }
2468
+ };
2469
+ var MaterializedView = class {
2470
+ /** @internal */
2471
+ kind = "MaterializedView";
2472
+ /** The name of the materialized view */
2473
+ name;
2474
+ /** The target OlapTable instance where the materialized data is stored. */
2475
+ targetTable;
2476
+ /** The SELECT SQL statement */
2477
+ selectSql;
2478
+ /** Names of source tables that the SELECT reads from */
2479
+ sourceTables;
2480
+ /** @internal Source file path where this MV was defined */
2481
+ sourceFile;
2482
+ constructor(options, targetSchema, targetColumns) {
2483
+ let selectStatement = options.selectStatement;
2484
+ if (typeof selectStatement !== "string") {
2485
+ selectStatement = toStaticQuery(selectStatement);
2486
+ }
2487
+ if (targetSchema === void 0 || targetColumns === void 0) {
2488
+ throw new Error(
2489
+ "Supply the type param T so that the schema is inserted by the compiler plugin."
2490
+ );
2491
+ }
2492
+ const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2493
+ requireTargetTableName(
2494
+ options.targetTable?.name ?? options.tableName
2495
+ ),
2496
+ {
2497
+ orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2498
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2499
+ },
2500
+ targetSchema,
2501
+ targetColumns
2502
+ );
2503
+ if (targetTable.name === options.materializedViewName) {
2504
+ throw new Error(
2505
+ "Materialized view name cannot be the same as the target table name."
2506
+ );
2507
+ }
2508
+ this.name = options.materializedViewName;
2509
+ this.targetTable = targetTable;
2510
+ this.selectSql = selectStatement;
2511
+ this.sourceTables = options.selectTables.map((t) => t.name);
2512
+ const stack = new Error().stack;
2513
+ this.sourceFile = getSourceFileFromStack(stack);
2514
+ const materializedViews = getMooseInternal().materializedViews;
2515
+ if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2516
+ throw new Error(`MaterializedView with name ${this.name} already exists`);
2517
+ }
2518
+ materializedViews.set(this.name, this);
2519
+ }
2520
+ };
2521
+
2457
2522
  // src/dmv2/sdk/sqlResource.ts
2458
2523
  var SqlResource = class {
2459
2524
  /** @internal */
@@ -2508,66 +2573,18 @@ var SqlResource = class {
2508
2573
  }
2509
2574
  };
2510
2575
 
2511
- // src/dmv2/sdk/materializedView.ts
2512
- var requireTargetTableName = (tableName) => {
2513
- if (typeof tableName === "string") {
2514
- return tableName;
2515
- } else {
2516
- throw new Error("Name of targetTable is not specified.");
2517
- }
2518
- };
2519
- var MaterializedView = class extends SqlResource {
2520
- /** The target OlapTable instance where the materialized data is stored. */
2521
- targetTable;
2522
- constructor(options, targetSchema, targetColumns) {
2523
- let selectStatement = options.selectStatement;
2524
- if (typeof selectStatement !== "string") {
2525
- selectStatement = toStaticQuery(selectStatement);
2526
- }
2527
- if (targetSchema === void 0 || targetColumns === void 0) {
2528
- throw new Error(
2529
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2530
- );
2531
- }
2532
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2533
- requireTargetTableName(
2534
- options.targetTable?.name ?? options.tableName
2535
- ),
2536
- {
2537
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2538
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2539
- },
2540
- targetSchema,
2541
- targetColumns
2542
- );
2543
- if (targetTable.name === options.materializedViewName) {
2544
- throw new Error(
2545
- "Materialized view name cannot be the same as the target table name."
2546
- );
2547
- }
2548
- super(
2549
- options.materializedViewName,
2550
- [
2551
- createMaterializedView({
2552
- name: options.materializedViewName,
2553
- destinationTable: targetTable.name,
2554
- select: selectStatement
2555
- })
2556
- // Population is now handled automatically by Rust infrastructure
2557
- // based on table engine type and whether this is a new or updated view
2558
- ],
2559
- [dropView(options.materializedViewName)],
2560
- {
2561
- pullsDataFrom: options.selectTables,
2562
- pushesDataTo: [targetTable]
2563
- }
2564
- );
2565
- this.targetTable = targetTable;
2566
- }
2567
- };
2568
-
2569
2576
  // src/dmv2/sdk/view.ts
2570
- var View = class extends SqlResource {
2577
+ var View = class {
2578
+ /** @internal */
2579
+ kind = "CustomView";
2580
+ /** The name of the view */
2581
+ name;
2582
+ /** The SELECT SQL statement that defines the view */
2583
+ selectSql;
2584
+ /** Names of source tables/views that the SELECT reads from */
2585
+ sourceTables;
2586
+ /** @internal Source file path where this view was defined */
2587
+ sourceFile;
2571
2588
  /**
2572
2589
  * Creates a new View instance.
2573
2590
  * @param name The name of the view to be created.
@@ -2578,17 +2595,16 @@ var View = class extends SqlResource {
2578
2595
  if (typeof selectStatement !== "string") {
2579
2596
  selectStatement = toStaticQuery(selectStatement);
2580
2597
  }
2581
- super(
2582
- name,
2583
- [
2584
- `CREATE VIEW IF NOT EXISTS ${name}
2585
- AS ${selectStatement}`.trim()
2586
- ],
2587
- [dropView(name)],
2588
- {
2589
- pullsDataFrom: baseTables
2590
- }
2591
- );
2598
+ this.name = name;
2599
+ this.selectSql = selectStatement;
2600
+ this.sourceTables = baseTables.map((t) => t.name);
2601
+ const stack = new Error().stack;
2602
+ this.sourceFile = getSourceFileFromStack(stack);
2603
+ const customViews = getMooseInternal().customViews;
2604
+ if (!isClientOnlyMode() && customViews.has(this.name)) {
2605
+ throw new Error(`View with name ${this.name} already exists`);
2606
+ }
2607
+ customViews.set(this.name, this);
2592
2608
  }
2593
2609
  };
2594
2610