@514labs/moose-lib 0.6.262-ci-2-g350aed07 → 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,50 +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
- /** @internal Source line number where this resource was defined */
1846
- sourceLine?: number;
1847
- /** @internal Source column number where this resource was defined */
1848
- sourceColumn?: number;
1849
- /**
1850
- * Creates a new SqlResource instance.
1851
- * @param name The name of the resource.
1852
- * @param setup An array of SQL DDL statements to create the resource.
1853
- * @param teardown An array of SQL DDL statements to drop the resource.
1854
- * @param options Optional configuration for specifying data dependencies.
1855
- * @param options.pullsDataFrom Tables/Views this resource reads from.
1856
- * @param options.pushesDataTo Tables/Views this resource writes to.
1857
- */
1858
- constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1859
- pullsDataFrom?: SqlObject[];
1860
- pushesDataTo?: SqlObject[];
1861
- });
1862
- }
1863
-
1864
- /**
1865
- * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1866
- * Inherits from SqlResource, providing setup (CREATE VIEW) and teardown (DROP VIEW) commands.
1867
- */
1868
- declare class View extends SqlResource {
1869
1840
  /**
1870
1841
  * Creates a new View instance.
1871
1842
  * @param name The name of the view to be created.
@@ -1911,9 +1882,19 @@ interface MaterializedViewConfig<T> {
1911
1882
  *
1912
1883
  * @template TargetTable The data type of the records stored in the underlying target OlapTable. The structure of T defines the target table schema.
1913
1884
  */
1914
- 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;
1915
1890
  /** The target OlapTable instance where the materialized data is stored. */
1916
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;
1917
1898
  /**
1918
1899
  * Creates a new MaterializedView instance.
1919
1900
  * Requires the `TargetTable` type parameter to be explicitly provided or inferred,
@@ -1926,6 +1907,41 @@ declare class MaterializedView<TargetTable> extends SqlResource {
1926
1907
  constructor(options: MaterializedViewConfig<TargetTable>, targetSchema: IJsonSchemaCollection$1.IV3_1, targetColumns: Column[]);
1927
1908
  }
1928
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
+
1929
1945
  type WebAppHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void | Promise<void>;
1930
1946
  interface FrameworkApp {
1931
1947
  handle?: (req: http.IncomingMessage, res: http.ServerResponse, next?: (err?: any) => void) => void;
@@ -1822,50 +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
- /** @internal Source line number where this resource was defined */
1846
- sourceLine?: number;
1847
- /** @internal Source column number where this resource was defined */
1848
- sourceColumn?: number;
1849
- /**
1850
- * Creates a new SqlResource instance.
1851
- * @param name The name of the resource.
1852
- * @param setup An array of SQL DDL statements to create the resource.
1853
- * @param teardown An array of SQL DDL statements to drop the resource.
1854
- * @param options Optional configuration for specifying data dependencies.
1855
- * @param options.pullsDataFrom Tables/Views this resource reads from.
1856
- * @param options.pushesDataTo Tables/Views this resource writes to.
1857
- */
1858
- constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1859
- pullsDataFrom?: SqlObject[];
1860
- pushesDataTo?: SqlObject[];
1861
- });
1862
- }
1863
-
1864
- /**
1865
- * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1866
- * Inherits from SqlResource, providing setup (CREATE VIEW) and teardown (DROP VIEW) commands.
1867
- */
1868
- declare class View extends SqlResource {
1869
1840
  /**
1870
1841
  * Creates a new View instance.
1871
1842
  * @param name The name of the view to be created.
@@ -1911,9 +1882,19 @@ interface MaterializedViewConfig<T> {
1911
1882
  *
1912
1883
  * @template TargetTable The data type of the records stored in the underlying target OlapTable. The structure of T defines the target table schema.
1913
1884
  */
1914
- 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;
1915
1890
  /** The target OlapTable instance where the materialized data is stored. */
1916
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;
1917
1898
  /**
1918
1899
  * Creates a new MaterializedView instance.
1919
1900
  * Requires the `TargetTable` type parameter to be explicitly provided or inferred,
@@ -1926,6 +1907,41 @@ declare class MaterializedView<TargetTable> extends SqlResource {
1926
1907
  constructor(options: MaterializedViewConfig<TargetTable>, targetSchema: IJsonSchemaCollection$1.IV3_1, targetColumns: Column[]);
1927
1908
  }
1928
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
+
1929
1945
  type WebAppHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void | Promise<void>;
1930
1946
  interface FrameworkApp {
1931
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-DTtKuO-Y.mjs';
2
- import { K as ApiUtil, a4 as MooseClient } from './index-CQB6bk1i.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-CQB6bk1i.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-Bqhjy4pn.js';
2
- import { K as ApiUtil, a4 as MooseClient } from './index-CQB6bk1i.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-CQB6bk1i.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
@@ -497,35 +497,8 @@ function getSourceFileInfo(stack) {
497
497
  }
498
498
  return {};
499
499
  }
500
- function getSourceLocationFromStack(stack) {
501
- if (!stack) return void 0;
502
- const lines = stack.split("\n");
503
- for (const line of lines.slice(1)) {
504
- if (shouldSkipStackLine(line)) {
505
- continue;
506
- }
507
- const v8Match = line.match(/at\s+(?:.*?\s+\()?(.+):(\d+):(\d+)\)?/);
508
- if (v8Match) {
509
- return {
510
- file: v8Match[1],
511
- line: parseInt(v8Match[2], 10),
512
- column: parseInt(v8Match[3], 10)
513
- };
514
- }
515
- const smMatch = line.match(/(?:.*@)?(.+):(\d+):(\d+)/);
516
- if (smMatch) {
517
- return {
518
- file: smMatch[1],
519
- line: parseInt(smMatch[2], 10),
520
- column: parseInt(smMatch[3], 10)
521
- };
522
- }
523
- }
524
- return void 0;
525
- }
526
500
  function getSourceFileFromStack(stack) {
527
- const location = getSourceLocationFromStack(stack);
528
- return location?.file;
501
+ return getSourceFileInfo(stack).file;
529
502
  }
530
503
 
531
504
  // src/dmv2/typedBase.ts
@@ -786,7 +759,9 @@ var moose_internal = {
786
759
  apis: /* @__PURE__ */ new Map(),
787
760
  sqlResources: /* @__PURE__ */ new Map(),
788
761
  workflows: /* @__PURE__ */ new Map(),
789
- webApps: /* @__PURE__ */ new Map()
762
+ webApps: /* @__PURE__ */ new Map(),
763
+ materializedViews: /* @__PURE__ */ new Map(),
764
+ customViews: /* @__PURE__ */ new Map()
790
765
  };
791
766
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
792
767
  var getMooseInternal = () => globalThis.moose_internal;
@@ -802,6 +777,8 @@ var loadIndex = () => {
802
777
  registry.sqlResources.clear();
803
778
  registry.workflows.clear();
804
779
  registry.webApps.clear();
780
+ registry.materializedViews.clear();
781
+ registry.customViews.clear();
805
782
  const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
806
783
  Object.keys(require.cache).forEach((key) => {
807
784
  if (key.startsWith(appDir)) {
@@ -2435,6 +2412,67 @@ var ETLPipeline = class {
2435
2412
  }
2436
2413
  };
2437
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
+
2438
2476
  // src/dmv2/sdk/sqlResource.ts
2439
2477
  var SqlResource = class {
2440
2478
  /** @internal */
@@ -2451,10 +2489,6 @@ var SqlResource = class {
2451
2489
  pushesDataTo;
2452
2490
  /** @internal Source file path where this resource was defined */
2453
2491
  sourceFile;
2454
- /** @internal Source line number where this resource was defined */
2455
- sourceLine;
2456
- /** @internal Source column number where this resource was defined */
2457
- sourceColumn;
2458
2492
  /**
2459
2493
  * Creates a new SqlResource instance.
2460
2494
  * @param name The name of the resource.
@@ -2480,75 +2514,22 @@ var SqlResource = class {
2480
2514
  this.pullsDataFrom = options?.pullsDataFrom ?? [];
2481
2515
  this.pushesDataTo = options?.pushesDataTo ?? [];
2482
2516
  const stack = new Error().stack;
2483
- const location = getSourceLocationFromStack(stack);
2484
- if (location) {
2485
- this.sourceFile = location.file;
2486
- this.sourceLine = location.line;
2487
- this.sourceColumn = location.column;
2488
- }
2489
- }
2490
- };
2491
-
2492
- // src/dmv2/sdk/materializedView.ts
2493
- var requireTargetTableName = (tableName) => {
2494
- if (typeof tableName === "string") {
2495
- return tableName;
2496
- } else {
2497
- throw new Error("Name of targetTable is not specified.");
2498
- }
2499
- };
2500
- var MaterializedView = class extends SqlResource {
2501
- /** The target OlapTable instance where the materialized data is stored. */
2502
- targetTable;
2503
- constructor(options, targetSchema, targetColumns) {
2504
- let selectStatement = options.selectStatement;
2505
- if (typeof selectStatement !== "string") {
2506
- selectStatement = toStaticQuery(selectStatement);
2507
- }
2508
- if (targetSchema === void 0 || targetColumns === void 0) {
2509
- throw new Error(
2510
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2511
- );
2512
- }
2513
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2514
- requireTargetTableName(
2515
- options.targetTable?.name ?? options.tableName
2516
- ),
2517
- {
2518
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2519
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2520
- },
2521
- targetSchema,
2522
- targetColumns
2523
- );
2524
- if (targetTable.name === options.materializedViewName) {
2525
- throw new Error(
2526
- "Materialized view name cannot be the same as the target table name."
2527
- );
2528
- }
2529
- super(
2530
- options.materializedViewName,
2531
- [
2532
- createMaterializedView({
2533
- name: options.materializedViewName,
2534
- destinationTable: targetTable.name,
2535
- select: selectStatement
2536
- })
2537
- // Population is now handled automatically by Rust infrastructure
2538
- // based on table engine type and whether this is a new or updated view
2539
- ],
2540
- [dropView(options.materializedViewName)],
2541
- {
2542
- pullsDataFrom: options.selectTables,
2543
- pushesDataTo: [targetTable]
2544
- }
2545
- );
2546
- this.targetTable = targetTable;
2517
+ this.sourceFile = getSourceFileFromStack(stack);
2547
2518
  }
2548
2519
  };
2549
2520
 
2550
2521
  // src/dmv2/sdk/view.ts
2551
- 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;
2552
2533
  /**
2553
2534
  * Creates a new View instance.
2554
2535
  * @param name The name of the view to be created.
@@ -2559,17 +2540,16 @@ var View = class extends SqlResource {
2559
2540
  if (typeof selectStatement !== "string") {
2560
2541
  selectStatement = toStaticQuery(selectStatement);
2561
2542
  }
2562
- super(
2563
- name,
2564
- [
2565
- `CREATE VIEW IF NOT EXISTS ${name}
2566
- AS ${selectStatement}`.trim()
2567
- ],
2568
- [dropView(name)],
2569
- {
2570
- pullsDataFrom: baseTables
2571
- }
2572
- );
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);
2573
2553
  }
2574
2554
  };
2575
2555