@514labs/moose-lib 0.6.262-ci-2-g39e53084 → 0.6.262-ci-5-gf85ca97c

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.
@@ -1822,46 +1822,21 @@ declare class ETLPipeline<T, U> {
1822
1822
  run(): Promise<void>;
1823
1823
  }
1824
1824
 
1825
- type SqlObject = OlapTable<any> | SqlResource;
1826
1825
  /**
1827
- * Represents a generic SQL resource that requires setup and teardown commands.
1828
- * Base class for constructs like Views and Materialized Views. Tracks dependencies.
1826
+ * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1827
+ * Emits structured data for the Moose infrastructure system.
1829
1828
  */
1830
- declare class SqlResource {
1829
+ declare class View {
1831
1830
  /** @internal */
1832
- readonly kind = "SqlResource";
1833
- /** Array of SQL statements to execute for setting up the resource. */
1834
- setup: readonly string[];
1835
- /** Array of SQL statements to execute for tearing down the resource. */
1836
- teardown: readonly string[];
1837
- /** The name of the SQL resource (e.g., view name, materialized view name). */
1831
+ readonly kind = "CustomView";
1832
+ /** The name of the view */
1838
1833
  name: string;
1839
- /** List of OlapTables or Views that this resource reads data from. */
1840
- pullsDataFrom: SqlObject[];
1841
- /** List of OlapTables or Views that this resource writes data to. */
1842
- pushesDataTo: SqlObject[];
1843
- /** @internal Source file path where this resource was defined */
1834
+ /** The SELECT SQL statement that defines the view */
1835
+ selectSql: string;
1836
+ /** Names of source tables/views that the SELECT reads from */
1837
+ sourceTables: string[];
1838
+ /** @internal Source file path where this view was defined */
1844
1839
  sourceFile?: string;
1845
- /**
1846
- * Creates a new SqlResource instance.
1847
- * @param name The name of the resource.
1848
- * @param setup An array of SQL DDL statements to create the resource.
1849
- * @param teardown An array of SQL DDL statements to drop the resource.
1850
- * @param options Optional configuration for specifying data dependencies.
1851
- * @param options.pullsDataFrom Tables/Views this resource reads from.
1852
- * @param options.pushesDataTo Tables/Views this resource writes to.
1853
- */
1854
- constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1855
- pullsDataFrom?: SqlObject[];
1856
- pushesDataTo?: SqlObject[];
1857
- });
1858
- }
1859
-
1860
- /**
1861
- * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1862
- * Inherits from SqlResource, providing setup (CREATE VIEW) and teardown (DROP VIEW) commands.
1863
- */
1864
- declare class View extends SqlResource {
1865
1840
  /**
1866
1841
  * Creates a new View instance.
1867
1842
  * @param name The name of the view to be created.
@@ -1907,9 +1882,19 @@ interface MaterializedViewConfig<T> {
1907
1882
  *
1908
1883
  * @template TargetTable The data type of the records stored in the underlying target OlapTable. The structure of T defines the target table schema.
1909
1884
  */
1910
- declare class MaterializedView<TargetTable> extends SqlResource {
1885
+ declare class MaterializedView<TargetTable> {
1886
+ /** @internal */
1887
+ readonly kind = "MaterializedView";
1888
+ /** The name of the materialized view */
1889
+ name: string;
1911
1890
  /** The target OlapTable instance where the materialized data is stored. */
1912
1891
  targetTable: OlapTable<TargetTable>;
1892
+ /** The SELECT SQL statement */
1893
+ selectSql: string;
1894
+ /** Names of source tables that the SELECT reads from */
1895
+ sourceTables: string[];
1896
+ /** @internal Source file path where this MV was defined */
1897
+ sourceFile?: string;
1913
1898
  /**
1914
1899
  * Creates a new MaterializedView instance.
1915
1900
  * Requires the `TargetTable` type parameter to be explicitly provided or inferred,
@@ -1922,6 +1907,41 @@ declare class MaterializedView<TargetTable> extends SqlResource {
1922
1907
  constructor(options: MaterializedViewConfig<TargetTable>, targetSchema: IJsonSchemaCollection$1.IV3_1, targetColumns: Column[]);
1923
1908
  }
1924
1909
 
1910
+ type SqlObject = OlapTable<any> | SqlResource;
1911
+ /**
1912
+ * Represents a generic SQL resource that requires setup and teardown commands.
1913
+ * Base class for constructs like Views and Materialized Views. Tracks dependencies.
1914
+ */
1915
+ declare class SqlResource {
1916
+ /** @internal */
1917
+ readonly kind = "SqlResource";
1918
+ /** Array of SQL statements to execute for setting up the resource. */
1919
+ setup: readonly string[];
1920
+ /** Array of SQL statements to execute for tearing down the resource. */
1921
+ teardown: readonly string[];
1922
+ /** The name of the SQL resource (e.g., view name, materialized view name). */
1923
+ name: string;
1924
+ /** List of OlapTables or Views that this resource reads data from. */
1925
+ pullsDataFrom: SqlObject[];
1926
+ /** List of OlapTables or Views that this resource writes data to. */
1927
+ pushesDataTo: SqlObject[];
1928
+ /** @internal Source file path where this resource was defined */
1929
+ sourceFile?: string;
1930
+ /**
1931
+ * Creates a new SqlResource instance.
1932
+ * @param name The name of the resource.
1933
+ * @param setup An array of SQL DDL statements to create the resource.
1934
+ * @param teardown An array of SQL DDL statements to drop the resource.
1935
+ * @param options Optional configuration for specifying data dependencies.
1936
+ * @param options.pullsDataFrom Tables/Views this resource reads from.
1937
+ * @param options.pushesDataTo Tables/Views this resource writes to.
1938
+ */
1939
+ constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1940
+ pullsDataFrom?: SqlObject[];
1941
+ pushesDataTo?: SqlObject[];
1942
+ });
1943
+ }
1944
+
1925
1945
  type WebAppHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void | Promise<void>;
1926
1946
  interface FrameworkApp {
1927
1947
  handle?: (req: http.IncomingMessage, res: http.ServerResponse, next?: (err?: any) => void) => void;
@@ -1822,46 +1822,21 @@ declare class ETLPipeline<T, U> {
1822
1822
  run(): Promise<void>;
1823
1823
  }
1824
1824
 
1825
- type SqlObject = OlapTable<any> | SqlResource;
1826
1825
  /**
1827
- * Represents a generic SQL resource that requires setup and teardown commands.
1828
- * Base class for constructs like Views and Materialized Views. Tracks dependencies.
1826
+ * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1827
+ * Emits structured data for the Moose infrastructure system.
1829
1828
  */
1830
- declare class SqlResource {
1829
+ declare class View {
1831
1830
  /** @internal */
1832
- readonly kind = "SqlResource";
1833
- /** Array of SQL statements to execute for setting up the resource. */
1834
- setup: readonly string[];
1835
- /** Array of SQL statements to execute for tearing down the resource. */
1836
- teardown: readonly string[];
1837
- /** The name of the SQL resource (e.g., view name, materialized view name). */
1831
+ readonly kind = "CustomView";
1832
+ /** The name of the view */
1838
1833
  name: string;
1839
- /** List of OlapTables or Views that this resource reads data from. */
1840
- pullsDataFrom: SqlObject[];
1841
- /** List of OlapTables or Views that this resource writes data to. */
1842
- pushesDataTo: SqlObject[];
1843
- /** @internal Source file path where this resource was defined */
1834
+ /** The SELECT SQL statement that defines the view */
1835
+ selectSql: string;
1836
+ /** Names of source tables/views that the SELECT reads from */
1837
+ sourceTables: string[];
1838
+ /** @internal Source file path where this view was defined */
1844
1839
  sourceFile?: string;
1845
- /**
1846
- * Creates a new SqlResource instance.
1847
- * @param name The name of the resource.
1848
- * @param setup An array of SQL DDL statements to create the resource.
1849
- * @param teardown An array of SQL DDL statements to drop the resource.
1850
- * @param options Optional configuration for specifying data dependencies.
1851
- * @param options.pullsDataFrom Tables/Views this resource reads from.
1852
- * @param options.pushesDataTo Tables/Views this resource writes to.
1853
- */
1854
- constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1855
- pullsDataFrom?: SqlObject[];
1856
- pushesDataTo?: SqlObject[];
1857
- });
1858
- }
1859
-
1860
- /**
1861
- * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1862
- * Inherits from SqlResource, providing setup (CREATE VIEW) and teardown (DROP VIEW) commands.
1863
- */
1864
- declare class View extends SqlResource {
1865
1840
  /**
1866
1841
  * Creates a new View instance.
1867
1842
  * @param name The name of the view to be created.
@@ -1907,9 +1882,19 @@ interface MaterializedViewConfig<T> {
1907
1882
  *
1908
1883
  * @template TargetTable The data type of the records stored in the underlying target OlapTable. The structure of T defines the target table schema.
1909
1884
  */
1910
- declare class MaterializedView<TargetTable> extends SqlResource {
1885
+ declare class MaterializedView<TargetTable> {
1886
+ /** @internal */
1887
+ readonly kind = "MaterializedView";
1888
+ /** The name of the materialized view */
1889
+ name: string;
1911
1890
  /** The target OlapTable instance where the materialized data is stored. */
1912
1891
  targetTable: OlapTable<TargetTable>;
1892
+ /** The SELECT SQL statement */
1893
+ selectSql: string;
1894
+ /** Names of source tables that the SELECT reads from */
1895
+ sourceTables: string[];
1896
+ /** @internal Source file path where this MV was defined */
1897
+ sourceFile?: string;
1913
1898
  /**
1914
1899
  * Creates a new MaterializedView instance.
1915
1900
  * Requires the `TargetTable` type parameter to be explicitly provided or inferred,
@@ -1922,6 +1907,41 @@ declare class MaterializedView<TargetTable> extends SqlResource {
1922
1907
  constructor(options: MaterializedViewConfig<TargetTable>, targetSchema: IJsonSchemaCollection$1.IV3_1, targetColumns: Column[]);
1923
1908
  }
1924
1909
 
1910
+ type SqlObject = OlapTable<any> | SqlResource;
1911
+ /**
1912
+ * Represents a generic SQL resource that requires setup and teardown commands.
1913
+ * Base class for constructs like Views and Materialized Views. Tracks dependencies.
1914
+ */
1915
+ declare class SqlResource {
1916
+ /** @internal */
1917
+ readonly kind = "SqlResource";
1918
+ /** Array of SQL statements to execute for setting up the resource. */
1919
+ setup: readonly string[];
1920
+ /** Array of SQL statements to execute for tearing down the resource. */
1921
+ teardown: readonly string[];
1922
+ /** The name of the SQL resource (e.g., view name, materialized view name). */
1923
+ name: string;
1924
+ /** List of OlapTables or Views that this resource reads data from. */
1925
+ pullsDataFrom: SqlObject[];
1926
+ /** List of OlapTables or Views that this resource writes data to. */
1927
+ pushesDataTo: SqlObject[];
1928
+ /** @internal Source file path where this resource was defined */
1929
+ sourceFile?: string;
1930
+ /**
1931
+ * Creates a new SqlResource instance.
1932
+ * @param name The name of the resource.
1933
+ * @param setup An array of SQL DDL statements to create the resource.
1934
+ * @param teardown An array of SQL DDL statements to drop the resource.
1935
+ * @param options Optional configuration for specifying data dependencies.
1936
+ * @param options.pullsDataFrom Tables/Views this resource reads from.
1937
+ * @param options.pushesDataTo Tables/Views this resource writes to.
1938
+ */
1939
+ constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1940
+ pullsDataFrom?: SqlObject[];
1941
+ pushesDataTo?: SqlObject[];
1942
+ });
1943
+ }
1944
+
1925
1945
  type WebAppHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void | Promise<void>;
1926
1946
  interface FrameworkApp {
1927
1947
  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-GsBQtLKo.mjs';
2
- import { K as ApiUtil, a4 as MooseClient } from './index-B1HsstjQ.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-B1HsstjQ.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-CDqMXtd_.mjs';
2
+ import { K as ApiUtil, a4 as MooseClient } from './index-B2jILcTY.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-B2jILcTY.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-CC6Jamxn.js';
2
- import { K as ApiUtil, a4 as MooseClient } from './index-B1HsstjQ.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-B1HsstjQ.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-BpwCKgGF.js';
2
+ import { K as ApiUtil, a4 as MooseClient } from './index-B2jILcTY.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-B2jILcTY.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
@@ -759,7 +759,9 @@ var moose_internal = {
759
759
  apis: /* @__PURE__ */ new Map(),
760
760
  sqlResources: /* @__PURE__ */ new Map(),
761
761
  workflows: /* @__PURE__ */ new Map(),
762
- webApps: /* @__PURE__ */ new Map()
762
+ webApps: /* @__PURE__ */ new Map(),
763
+ materializedViews: /* @__PURE__ */ new Map(),
764
+ customViews: /* @__PURE__ */ new Map()
763
765
  };
764
766
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
765
767
  var getMooseInternal = () => globalThis.moose_internal;
@@ -775,6 +777,8 @@ var loadIndex = () => {
775
777
  registry.sqlResources.clear();
776
778
  registry.workflows.clear();
777
779
  registry.webApps.clear();
780
+ registry.materializedViews.clear();
781
+ registry.customViews.clear();
778
782
  const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
779
783
  Object.keys(require.cache).forEach((key) => {
780
784
  if (key.startsWith(appDir)) {
@@ -2408,6 +2412,67 @@ var ETLPipeline = class {
2408
2412
  }
2409
2413
  };
2410
2414
 
2415
+ // src/dmv2/sdk/materializedView.ts
2416
+ var requireTargetTableName = (tableName) => {
2417
+ if (typeof tableName === "string") {
2418
+ return tableName;
2419
+ } else {
2420
+ throw new Error("Name of targetTable is not specified.");
2421
+ }
2422
+ };
2423
+ var MaterializedView = class {
2424
+ /** @internal */
2425
+ kind = "MaterializedView";
2426
+ /** The name of the materialized view */
2427
+ name;
2428
+ /** The target OlapTable instance where the materialized data is stored. */
2429
+ targetTable;
2430
+ /** The SELECT SQL statement */
2431
+ selectSql;
2432
+ /** Names of source tables that the SELECT reads from */
2433
+ sourceTables;
2434
+ /** @internal Source file path where this MV was defined */
2435
+ sourceFile;
2436
+ constructor(options, targetSchema, targetColumns) {
2437
+ let selectStatement = options.selectStatement;
2438
+ if (typeof selectStatement !== "string") {
2439
+ selectStatement = toStaticQuery(selectStatement);
2440
+ }
2441
+ if (targetSchema === void 0 || targetColumns === void 0) {
2442
+ throw new Error(
2443
+ "Supply the type param T so that the schema is inserted by the compiler plugin."
2444
+ );
2445
+ }
2446
+ const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2447
+ requireTargetTableName(
2448
+ options.targetTable?.name ?? options.tableName
2449
+ ),
2450
+ {
2451
+ orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2452
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2453
+ },
2454
+ targetSchema,
2455
+ targetColumns
2456
+ );
2457
+ if (targetTable.name === options.materializedViewName) {
2458
+ throw new Error(
2459
+ "Materialized view name cannot be the same as the target table name."
2460
+ );
2461
+ }
2462
+ this.name = options.materializedViewName;
2463
+ this.targetTable = targetTable;
2464
+ this.selectSql = selectStatement;
2465
+ this.sourceTables = options.selectTables.map((t) => t.name);
2466
+ const stack = new Error().stack;
2467
+ this.sourceFile = getSourceFileFromStack(stack);
2468
+ const materializedViews = getMooseInternal().materializedViews;
2469
+ if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2470
+ throw new Error(`MaterializedView with name ${this.name} already exists`);
2471
+ }
2472
+ materializedViews.set(this.name, this);
2473
+ }
2474
+ };
2475
+
2411
2476
  // src/dmv2/sdk/sqlResource.ts
2412
2477
  var SqlResource = class {
2413
2478
  /** @internal */
@@ -2453,66 +2518,18 @@ var SqlResource = class {
2453
2518
  }
2454
2519
  };
2455
2520
 
2456
- // src/dmv2/sdk/materializedView.ts
2457
- var requireTargetTableName = (tableName) => {
2458
- if (typeof tableName === "string") {
2459
- return tableName;
2460
- } else {
2461
- throw new Error("Name of targetTable is not specified.");
2462
- }
2463
- };
2464
- var MaterializedView = class extends SqlResource {
2465
- /** The target OlapTable instance where the materialized data is stored. */
2466
- targetTable;
2467
- constructor(options, targetSchema, targetColumns) {
2468
- let selectStatement = options.selectStatement;
2469
- if (typeof selectStatement !== "string") {
2470
- selectStatement = toStaticQuery(selectStatement);
2471
- }
2472
- if (targetSchema === void 0 || targetColumns === void 0) {
2473
- throw new Error(
2474
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2475
- );
2476
- }
2477
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2478
- requireTargetTableName(
2479
- options.targetTable?.name ?? options.tableName
2480
- ),
2481
- {
2482
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2483
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2484
- },
2485
- targetSchema,
2486
- targetColumns
2487
- );
2488
- if (targetTable.name === options.materializedViewName) {
2489
- throw new Error(
2490
- "Materialized view name cannot be the same as the target table name."
2491
- );
2492
- }
2493
- super(
2494
- options.materializedViewName,
2495
- [
2496
- createMaterializedView({
2497
- name: options.materializedViewName,
2498
- destinationTable: targetTable.name,
2499
- select: selectStatement
2500
- })
2501
- // Population is now handled automatically by Rust infrastructure
2502
- // based on table engine type and whether this is a new or updated view
2503
- ],
2504
- [dropView(options.materializedViewName)],
2505
- {
2506
- pullsDataFrom: options.selectTables,
2507
- pushesDataTo: [targetTable]
2508
- }
2509
- );
2510
- this.targetTable = targetTable;
2511
- }
2512
- };
2513
-
2514
2521
  // src/dmv2/sdk/view.ts
2515
- var View = class extends SqlResource {
2522
+ var View = class {
2523
+ /** @internal */
2524
+ kind = "CustomView";
2525
+ /** The name of the view */
2526
+ name;
2527
+ /** The SELECT SQL statement that defines the view */
2528
+ selectSql;
2529
+ /** Names of source tables/views that the SELECT reads from */
2530
+ sourceTables;
2531
+ /** @internal Source file path where this view was defined */
2532
+ sourceFile;
2516
2533
  /**
2517
2534
  * Creates a new View instance.
2518
2535
  * @param name The name of the view to be created.
@@ -2523,17 +2540,16 @@ var View = class extends SqlResource {
2523
2540
  if (typeof selectStatement !== "string") {
2524
2541
  selectStatement = toStaticQuery(selectStatement);
2525
2542
  }
2526
- super(
2527
- name,
2528
- [
2529
- `CREATE VIEW IF NOT EXISTS ${name}
2530
- AS ${selectStatement}`.trim()
2531
- ],
2532
- [dropView(name)],
2533
- {
2534
- pullsDataFrom: baseTables
2535
- }
2536
- );
2543
+ this.name = name;
2544
+ this.selectSql = selectStatement;
2545
+ this.sourceTables = baseTables.map((t) => t.name);
2546
+ const stack = new Error().stack;
2547
+ this.sourceFile = getSourceFileFromStack(stack);
2548
+ const customViews = getMooseInternal().customViews;
2549
+ if (!isClientOnlyMode() && customViews.has(this.name)) {
2550
+ throw new Error(`View with name ${this.name} already exists`);
2551
+ }
2552
+ customViews.set(this.name, this);
2537
2553
  }
2538
2554
  };
2539
2555