@514labs/moose-lib 0.6.256-ci-4-g0ca62054 → 0.6.256-ci-3-gafce5840

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.
@@ -1789,46 +1789,21 @@ declare class ETLPipeline<T, U> {
1789
1789
  run(): Promise<void>;
1790
1790
  }
1791
1791
 
1792
- type SqlObject = OlapTable<any> | SqlResource;
1793
1792
  /**
1794
- * Represents a generic SQL resource that requires setup and teardown commands.
1795
- * Base class for constructs like Views and Materialized Views. Tracks dependencies.
1793
+ * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1794
+ * Emits structured data for the Moose infrastructure system.
1796
1795
  */
1797
- declare class SqlResource {
1796
+ declare class View {
1798
1797
  /** @internal */
1799
- readonly kind = "SqlResource";
1800
- /** Array of SQL statements to execute for setting up the resource. */
1801
- setup: readonly string[];
1802
- /** Array of SQL statements to execute for tearing down the resource. */
1803
- teardown: readonly string[];
1804
- /** The name of the SQL resource (e.g., view name, materialized view name). */
1798
+ readonly kind = "CustomView";
1799
+ /** The name of the view */
1805
1800
  name: string;
1806
- /** List of OlapTables or Views that this resource reads data from. */
1807
- pullsDataFrom: SqlObject[];
1808
- /** List of OlapTables or Views that this resource writes data to. */
1809
- pushesDataTo: SqlObject[];
1810
- /** @internal Source file path where this resource was defined */
1801
+ /** The SELECT SQL statement that defines the view */
1802
+ selectSql: string;
1803
+ /** Names of source tables/views that the SELECT reads from */
1804
+ sourceTables: string[];
1805
+ /** @internal Source file path where this view was defined */
1811
1806
  sourceFile?: string;
1812
- /**
1813
- * Creates a new SqlResource instance.
1814
- * @param name The name of the resource.
1815
- * @param setup An array of SQL DDL statements to create the resource.
1816
- * @param teardown An array of SQL DDL statements to drop the resource.
1817
- * @param options Optional configuration for specifying data dependencies.
1818
- * @param options.pullsDataFrom Tables/Views this resource reads from.
1819
- * @param options.pushesDataTo Tables/Views this resource writes to.
1820
- */
1821
- constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1822
- pullsDataFrom?: SqlObject[];
1823
- pushesDataTo?: SqlObject[];
1824
- });
1825
- }
1826
-
1827
- /**
1828
- * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1829
- * Inherits from SqlResource, providing setup (CREATE VIEW) and teardown (DROP VIEW) commands.
1830
- */
1831
- declare class View extends SqlResource {
1832
1807
  /**
1833
1808
  * Creates a new View instance.
1834
1809
  * @param name The name of the view to be created.
@@ -1874,9 +1849,19 @@ interface MaterializedViewConfig<T> {
1874
1849
  *
1875
1850
  * @template TargetTable The data type of the records stored in the underlying target OlapTable. The structure of T defines the target table schema.
1876
1851
  */
1877
- declare class MaterializedView<TargetTable> extends SqlResource {
1852
+ declare class MaterializedView<TargetTable> {
1853
+ /** @internal */
1854
+ readonly kind = "MaterializedView";
1855
+ /** The name of the materialized view */
1856
+ name: string;
1878
1857
  /** The target OlapTable instance where the materialized data is stored. */
1879
1858
  targetTable: OlapTable<TargetTable>;
1859
+ /** The SELECT SQL statement */
1860
+ selectSql: string;
1861
+ /** Names of source tables that the SELECT reads from */
1862
+ sourceTables: string[];
1863
+ /** @internal Source file path where this MV was defined */
1864
+ sourceFile?: string;
1880
1865
  /**
1881
1866
  * Creates a new MaterializedView instance.
1882
1867
  * Requires the `TargetTable` type parameter to be explicitly provided or inferred,
@@ -1889,6 +1874,41 @@ declare class MaterializedView<TargetTable> extends SqlResource {
1889
1874
  constructor(options: MaterializedViewConfig<TargetTable>, targetSchema: IJsonSchemaCollection$1.IV3_1, targetColumns: Column[]);
1890
1875
  }
1891
1876
 
1877
+ type SqlObject = OlapTable<any> | SqlResource;
1878
+ /**
1879
+ * Represents a generic SQL resource that requires setup and teardown commands.
1880
+ * Base class for constructs like Views and Materialized Views. Tracks dependencies.
1881
+ */
1882
+ declare class SqlResource {
1883
+ /** @internal */
1884
+ readonly kind = "SqlResource";
1885
+ /** Array of SQL statements to execute for setting up the resource. */
1886
+ setup: readonly string[];
1887
+ /** Array of SQL statements to execute for tearing down the resource. */
1888
+ teardown: readonly string[];
1889
+ /** The name of the SQL resource (e.g., view name, materialized view name). */
1890
+ name: string;
1891
+ /** List of OlapTables or Views that this resource reads data from. */
1892
+ pullsDataFrom: SqlObject[];
1893
+ /** List of OlapTables or Views that this resource writes data to. */
1894
+ pushesDataTo: SqlObject[];
1895
+ /** @internal Source file path where this resource was defined */
1896
+ sourceFile?: string;
1897
+ /**
1898
+ * Creates a new SqlResource instance.
1899
+ * @param name The name of the resource.
1900
+ * @param setup An array of SQL DDL statements to create the resource.
1901
+ * @param teardown An array of SQL DDL statements to drop the resource.
1902
+ * @param options Optional configuration for specifying data dependencies.
1903
+ * @param options.pullsDataFrom Tables/Views this resource reads from.
1904
+ * @param options.pushesDataTo Tables/Views this resource writes to.
1905
+ */
1906
+ constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1907
+ pullsDataFrom?: SqlObject[];
1908
+ pushesDataTo?: SqlObject[];
1909
+ });
1910
+ }
1911
+
1892
1912
  type WebAppHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void | Promise<void>;
1893
1913
  interface FrameworkApp {
1894
1914
  handle?: (req: http.IncomingMessage, res: http.ServerResponse, next?: (err?: any) => void) => void;
@@ -1789,46 +1789,21 @@ declare class ETLPipeline<T, U> {
1789
1789
  run(): Promise<void>;
1790
1790
  }
1791
1791
 
1792
- type SqlObject = OlapTable<any> | SqlResource;
1793
1792
  /**
1794
- * Represents a generic SQL resource that requires setup and teardown commands.
1795
- * Base class for constructs like Views and Materialized Views. Tracks dependencies.
1793
+ * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1794
+ * Emits structured data for the Moose infrastructure system.
1796
1795
  */
1797
- declare class SqlResource {
1796
+ declare class View {
1798
1797
  /** @internal */
1799
- readonly kind = "SqlResource";
1800
- /** Array of SQL statements to execute for setting up the resource. */
1801
- setup: readonly string[];
1802
- /** Array of SQL statements to execute for tearing down the resource. */
1803
- teardown: readonly string[];
1804
- /** The name of the SQL resource (e.g., view name, materialized view name). */
1798
+ readonly kind = "CustomView";
1799
+ /** The name of the view */
1805
1800
  name: string;
1806
- /** List of OlapTables or Views that this resource reads data from. */
1807
- pullsDataFrom: SqlObject[];
1808
- /** List of OlapTables or Views that this resource writes data to. */
1809
- pushesDataTo: SqlObject[];
1810
- /** @internal Source file path where this resource was defined */
1801
+ /** The SELECT SQL statement that defines the view */
1802
+ selectSql: string;
1803
+ /** Names of source tables/views that the SELECT reads from */
1804
+ sourceTables: string[];
1805
+ /** @internal Source file path where this view was defined */
1811
1806
  sourceFile?: string;
1812
- /**
1813
- * Creates a new SqlResource instance.
1814
- * @param name The name of the resource.
1815
- * @param setup An array of SQL DDL statements to create the resource.
1816
- * @param teardown An array of SQL DDL statements to drop the resource.
1817
- * @param options Optional configuration for specifying data dependencies.
1818
- * @param options.pullsDataFrom Tables/Views this resource reads from.
1819
- * @param options.pushesDataTo Tables/Views this resource writes to.
1820
- */
1821
- constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1822
- pullsDataFrom?: SqlObject[];
1823
- pushesDataTo?: SqlObject[];
1824
- });
1825
- }
1826
-
1827
- /**
1828
- * Represents a database View, defined by a SQL SELECT statement based on one or more base tables or other views.
1829
- * Inherits from SqlResource, providing setup (CREATE VIEW) and teardown (DROP VIEW) commands.
1830
- */
1831
- declare class View extends SqlResource {
1832
1807
  /**
1833
1808
  * Creates a new View instance.
1834
1809
  * @param name The name of the view to be created.
@@ -1874,9 +1849,19 @@ interface MaterializedViewConfig<T> {
1874
1849
  *
1875
1850
  * @template TargetTable The data type of the records stored in the underlying target OlapTable. The structure of T defines the target table schema.
1876
1851
  */
1877
- declare class MaterializedView<TargetTable> extends SqlResource {
1852
+ declare class MaterializedView<TargetTable> {
1853
+ /** @internal */
1854
+ readonly kind = "MaterializedView";
1855
+ /** The name of the materialized view */
1856
+ name: string;
1878
1857
  /** The target OlapTable instance where the materialized data is stored. */
1879
1858
  targetTable: OlapTable<TargetTable>;
1859
+ /** The SELECT SQL statement */
1860
+ selectSql: string;
1861
+ /** Names of source tables that the SELECT reads from */
1862
+ sourceTables: string[];
1863
+ /** @internal Source file path where this MV was defined */
1864
+ sourceFile?: string;
1880
1865
  /**
1881
1866
  * Creates a new MaterializedView instance.
1882
1867
  * Requires the `TargetTable` type parameter to be explicitly provided or inferred,
@@ -1889,6 +1874,41 @@ declare class MaterializedView<TargetTable> extends SqlResource {
1889
1874
  constructor(options: MaterializedViewConfig<TargetTable>, targetSchema: IJsonSchemaCollection$1.IV3_1, targetColumns: Column[]);
1890
1875
  }
1891
1876
 
1877
+ type SqlObject = OlapTable<any> | SqlResource;
1878
+ /**
1879
+ * Represents a generic SQL resource that requires setup and teardown commands.
1880
+ * Base class for constructs like Views and Materialized Views. Tracks dependencies.
1881
+ */
1882
+ declare class SqlResource {
1883
+ /** @internal */
1884
+ readonly kind = "SqlResource";
1885
+ /** Array of SQL statements to execute for setting up the resource. */
1886
+ setup: readonly string[];
1887
+ /** Array of SQL statements to execute for tearing down the resource. */
1888
+ teardown: readonly string[];
1889
+ /** The name of the SQL resource (e.g., view name, materialized view name). */
1890
+ name: string;
1891
+ /** List of OlapTables or Views that this resource reads data from. */
1892
+ pullsDataFrom: SqlObject[];
1893
+ /** List of OlapTables or Views that this resource writes data to. */
1894
+ pushesDataTo: SqlObject[];
1895
+ /** @internal Source file path where this resource was defined */
1896
+ sourceFile?: string;
1897
+ /**
1898
+ * Creates a new SqlResource instance.
1899
+ * @param name The name of the resource.
1900
+ * @param setup An array of SQL DDL statements to create the resource.
1901
+ * @param teardown An array of SQL DDL statements to drop the resource.
1902
+ * @param options Optional configuration for specifying data dependencies.
1903
+ * @param options.pullsDataFrom Tables/Views this resource reads from.
1904
+ * @param options.pushesDataTo Tables/Views this resource writes to.
1905
+ */
1906
+ constructor(name: string, setup: readonly (string | Sql)[], teardown: readonly (string | Sql)[], options?: {
1907
+ pullsDataFrom?: SqlObject[];
1908
+ pushesDataTo?: SqlObject[];
1909
+ });
1910
+ }
1911
+
1892
1912
  type WebAppHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void | Promise<void>;
1893
1913
  interface FrameworkApp {
1894
1914
  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-DnYA4Zgi.mjs';
2
- import { K as ApiUtil, a4 as MooseClient } from './index-rECDLgTX.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-rECDLgTX.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-CMIa49e4.mjs';
2
+ import { K as ApiUtil, a4 as MooseClient } from './index-BpasnHLt.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-BpasnHLt.mjs';
4
4
  import * as _clickhouse_client from '@clickhouse/client';
5
5
  import { KafkaJS } from '@confluentinc/kafka-javascript';
6
6
  import http from 'http';
@@ -44,25 +44,6 @@ declare const RETRY_INITIAL_TIME_MS = 100;
44
44
  declare const MAX_RETRIES_PRODUCER = 150;
45
45
  declare const RETRY_FACTOR_PRODUCER = 0.2;
46
46
  declare const ACKs = -1;
47
- /**
48
- * Creates the base producer configuration for Kafka.
49
- * Used by both the SDK stream publishing and streaming function workers.
50
- *
51
- * @param maxMessageBytes - Optional max message size in bytes (synced with topic config)
52
- * @returns Producer configuration object for the Confluent Kafka client
53
- */
54
- declare function createProducerConfig(maxMessageBytes?: number): {
55
- "message.max.bytes"?: number | undefined;
56
- kafkaJS: {
57
- idempotent: boolean;
58
- acks: number;
59
- retry: {
60
- retries: number;
61
- maxRetryTime: number;
62
- };
63
- };
64
- "linger.ms": number;
65
- };
66
47
  type KafkaClientConfig = {
67
48
  clientId: string;
68
49
  broker: string;
@@ -74,12 +55,8 @@ type KafkaClientConfig = {
74
55
  /**
75
56
  * Dynamically creates and connects a KafkaJS producer using the provided configuration.
76
57
  * Returns a connected producer instance.
77
- *
78
- * @param cfg - Kafka client configuration
79
- * @param logger - Logger instance
80
- * @param maxMessageBytes - Optional max message size in bytes (synced with topic config)
81
58
  */
82
- declare function getKafkaProducer(cfg: KafkaClientConfig, logger: Logger, maxMessageBytes?: number): Promise<Producer>;
59
+ declare function getKafkaProducer(cfg: KafkaClientConfig, logger: Logger): Promise<Producer>;
83
60
  /**
84
61
  * Interface for logging functionality
85
62
  */
@@ -554,4 +531,4 @@ type DataModelConfig<T> = Partial<{
554
531
  parallelism?: number;
555
532
  }>;
556
533
 
557
- export { ACKs, ApiUtil, type CSVParsingConfig, CSV_DELIMITERS, type CliLogData, DEFAULT_CSV_CONFIG, DEFAULT_JSON_CONFIG, type DataModelConfig, DataSource, type DataSourceConfig, type ExpressRequestWithMoose, type ExtractionResult, type JSONParsingConfig, type KafkaClientConfig, type Logger, MAX_RETRIES, MAX_RETRIES_PRODUCER, MAX_RETRY_TIME_MS, MOOSE_RUNTIME_ENV_PREFIX, MooseCache, MooseClient, type Producer, RETRY_FACTOR_PRODUCER, RETRY_INITIAL_TIME_MS, type StripDateIntersection, type TaskConfig, type TaskDefinition, type TaskFunction, antiCachePath, cliLog, compilerLog, createApi, createConsumptionApi, createProducerConfig, expressMiddleware, getClickhouseClient, getFileName, getKafkaClient, getKafkaProducer, getMooseClients, getMooseUtils, isValidCSVDelimiter, logError, mapTstoJs, mooseEnvSecrets, mooseRuntimeEnv, parseCSV, parseJSON, parseJSONWithDates };
534
+ export { ACKs, ApiUtil, type CSVParsingConfig, CSV_DELIMITERS, type CliLogData, DEFAULT_CSV_CONFIG, DEFAULT_JSON_CONFIG, type DataModelConfig, DataSource, type DataSourceConfig, type ExpressRequestWithMoose, type ExtractionResult, type JSONParsingConfig, type KafkaClientConfig, type Logger, MAX_RETRIES, MAX_RETRIES_PRODUCER, MAX_RETRY_TIME_MS, MOOSE_RUNTIME_ENV_PREFIX, MooseCache, MooseClient, type Producer, RETRY_FACTOR_PRODUCER, RETRY_INITIAL_TIME_MS, type StripDateIntersection, type TaskConfig, type TaskDefinition, type TaskFunction, antiCachePath, cliLog, compilerLog, createApi, createConsumptionApi, expressMiddleware, getClickhouseClient, getFileName, getKafkaClient, getKafkaProducer, getMooseClients, getMooseUtils, isValidCSVDelimiter, logError, mapTstoJs, mooseEnvSecrets, mooseRuntimeEnv, parseCSV, parseJSON, parseJSONWithDates };
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-B_aEflr_.js';
2
- import { K as ApiUtil, a4 as MooseClient } from './index-rECDLgTX.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-rECDLgTX.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-B6i2YRSY.js';
2
+ import { K as ApiUtil, a4 as MooseClient } from './index-BpasnHLt.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-BpasnHLt.js';
4
4
  import * as _clickhouse_client from '@clickhouse/client';
5
5
  import { KafkaJS } from '@confluentinc/kafka-javascript';
6
6
  import http from 'http';
@@ -44,25 +44,6 @@ declare const RETRY_INITIAL_TIME_MS = 100;
44
44
  declare const MAX_RETRIES_PRODUCER = 150;
45
45
  declare const RETRY_FACTOR_PRODUCER = 0.2;
46
46
  declare const ACKs = -1;
47
- /**
48
- * Creates the base producer configuration for Kafka.
49
- * Used by both the SDK stream publishing and streaming function workers.
50
- *
51
- * @param maxMessageBytes - Optional max message size in bytes (synced with topic config)
52
- * @returns Producer configuration object for the Confluent Kafka client
53
- */
54
- declare function createProducerConfig(maxMessageBytes?: number): {
55
- "message.max.bytes"?: number | undefined;
56
- kafkaJS: {
57
- idempotent: boolean;
58
- acks: number;
59
- retry: {
60
- retries: number;
61
- maxRetryTime: number;
62
- };
63
- };
64
- "linger.ms": number;
65
- };
66
47
  type KafkaClientConfig = {
67
48
  clientId: string;
68
49
  broker: string;
@@ -74,12 +55,8 @@ type KafkaClientConfig = {
74
55
  /**
75
56
  * Dynamically creates and connects a KafkaJS producer using the provided configuration.
76
57
  * Returns a connected producer instance.
77
- *
78
- * @param cfg - Kafka client configuration
79
- * @param logger - Logger instance
80
- * @param maxMessageBytes - Optional max message size in bytes (synced with topic config)
81
58
  */
82
- declare function getKafkaProducer(cfg: KafkaClientConfig, logger: Logger, maxMessageBytes?: number): Promise<Producer>;
59
+ declare function getKafkaProducer(cfg: KafkaClientConfig, logger: Logger): Promise<Producer>;
83
60
  /**
84
61
  * Interface for logging functionality
85
62
  */
@@ -554,4 +531,4 @@ type DataModelConfig<T> = Partial<{
554
531
  parallelism?: number;
555
532
  }>;
556
533
 
557
- export { ACKs, ApiUtil, type CSVParsingConfig, CSV_DELIMITERS, type CliLogData, DEFAULT_CSV_CONFIG, DEFAULT_JSON_CONFIG, type DataModelConfig, DataSource, type DataSourceConfig, type ExpressRequestWithMoose, type ExtractionResult, type JSONParsingConfig, type KafkaClientConfig, type Logger, MAX_RETRIES, MAX_RETRIES_PRODUCER, MAX_RETRY_TIME_MS, MOOSE_RUNTIME_ENV_PREFIX, MooseCache, MooseClient, type Producer, RETRY_FACTOR_PRODUCER, RETRY_INITIAL_TIME_MS, type StripDateIntersection, type TaskConfig, type TaskDefinition, type TaskFunction, antiCachePath, cliLog, compilerLog, createApi, createConsumptionApi, createProducerConfig, expressMiddleware, getClickhouseClient, getFileName, getKafkaClient, getKafkaProducer, getMooseClients, getMooseUtils, isValidCSVDelimiter, logError, mapTstoJs, mooseEnvSecrets, mooseRuntimeEnv, parseCSV, parseJSON, parseJSONWithDates };
534
+ export { ACKs, ApiUtil, type CSVParsingConfig, CSV_DELIMITERS, type CliLogData, DEFAULT_CSV_CONFIG, DEFAULT_JSON_CONFIG, type DataModelConfig, DataSource, type DataSourceConfig, type ExpressRequestWithMoose, type ExtractionResult, type JSONParsingConfig, type KafkaClientConfig, type Logger, MAX_RETRIES, MAX_RETRIES_PRODUCER, MAX_RETRY_TIME_MS, MOOSE_RUNTIME_ENV_PREFIX, MooseCache, MooseClient, type Producer, RETRY_FACTOR_PRODUCER, RETRY_INITIAL_TIME_MS, type StripDateIntersection, type TaskConfig, type TaskDefinition, type TaskFunction, antiCachePath, cliLog, compilerLog, createApi, createConsumptionApi, expressMiddleware, getClickhouseClient, getFileName, getKafkaClient, getKafkaProducer, getMooseClients, getMooseUtils, isValidCSVDelimiter, logError, mapTstoJs, mooseEnvSecrets, mooseRuntimeEnv, parseCSV, parseJSON, parseJSONWithDates };
package/dist/index.js CHANGED
@@ -42,7 +42,6 @@ __export(commons_exports, {
42
42
  antiCachePath: () => antiCachePath,
43
43
  cliLog: () => cliLog,
44
44
  compilerLog: () => compilerLog,
45
- createProducerConfig: () => createProducerConfig,
46
45
  getClickhouseClient: () => getClickhouseClient,
47
46
  getFileName: () => getFileName,
48
47
  getKafkaClient: () => getKafkaClient,
@@ -65,25 +64,18 @@ function isTruthy(value) {
65
64
  function mapTstoJs(filePath) {
66
65
  return filePath.replace(/\.ts$/, ".js").replace(/\.cts$/, ".cjs").replace(/\.mts$/, ".mjs");
67
66
  }
68
- function createProducerConfig(maxMessageBytes) {
69
- return {
67
+ async function getKafkaProducer(cfg, logger) {
68
+ const kafka = await getKafkaClient(cfg, logger);
69
+ const producer = kafka.producer({
70
70
  kafkaJS: {
71
- idempotent: false,
72
- // Not needed for at-least-once delivery
71
+ idempotent: true,
73
72
  acks: ACKs,
74
73
  retry: {
75
74
  retries: MAX_RETRIES_PRODUCER,
76
75
  maxRetryTime: MAX_RETRY_TIME_MS
77
76
  }
78
- },
79
- "linger.ms": 0,
80
- // This is to make sure at least once delivery with immediate feedback on the send
81
- ...maxMessageBytes && { "message.max.bytes": maxMessageBytes }
82
- };
83
- }
84
- async function getKafkaProducer(cfg, logger, maxMessageBytes) {
85
- const kafka = await getKafkaClient(cfg, logger);
86
- const producer = kafka.producer(createProducerConfig(maxMessageBytes));
77
+ }
78
+ });
87
79
  await producer.connect();
88
80
  return producer;
89
81
  }
@@ -425,7 +417,6 @@ __export(index_exports, {
425
417
  createClickhouseParameter: () => createClickhouseParameter,
426
418
  createConsumptionApi: () => createConsumptionApi,
427
419
  createMaterializedView: () => createMaterializedView,
428
- createProducerConfig: () => createProducerConfig,
429
420
  dropView: () => dropView,
430
421
  expressMiddleware: () => expressMiddleware,
431
422
  getApi: () => getApi,
@@ -758,7 +749,9 @@ var moose_internal = {
758
749
  apis: /* @__PURE__ */ new Map(),
759
750
  sqlResources: /* @__PURE__ */ new Map(),
760
751
  workflows: /* @__PURE__ */ new Map(),
761
- webApps: /* @__PURE__ */ new Map()
752
+ webApps: /* @__PURE__ */ new Map(),
753
+ materializedViews: /* @__PURE__ */ new Map(),
754
+ customViews: /* @__PURE__ */ new Map()
762
755
  };
763
756
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
764
757
  var getMooseInternal = () => globalThis.moose_internal;
@@ -774,6 +767,8 @@ var loadIndex = () => {
774
767
  registry.sqlResources.clear();
775
768
  registry.workflows.clear();
776
769
  registry.webApps.clear();
770
+ registry.materializedViews.clear();
771
+ registry.customViews.clear();
777
772
  const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
778
773
  Object.keys(require.cache).forEach((key) => {
779
774
  if (key.startsWith(appDir)) {
@@ -2407,6 +2402,67 @@ var ETLPipeline = class {
2407
2402
  }
2408
2403
  };
2409
2404
 
2405
+ // src/dmv2/sdk/materializedView.ts
2406
+ var requireTargetTableName = (tableName) => {
2407
+ if (typeof tableName === "string") {
2408
+ return tableName;
2409
+ } else {
2410
+ throw new Error("Name of targetTable is not specified.");
2411
+ }
2412
+ };
2413
+ var MaterializedView = class {
2414
+ /** @internal */
2415
+ kind = "MaterializedView";
2416
+ /** The name of the materialized view */
2417
+ name;
2418
+ /** The target OlapTable instance where the materialized data is stored. */
2419
+ targetTable;
2420
+ /** The SELECT SQL statement */
2421
+ selectSql;
2422
+ /** Names of source tables that the SELECT reads from */
2423
+ sourceTables;
2424
+ /** @internal Source file path where this MV was defined */
2425
+ sourceFile;
2426
+ constructor(options, targetSchema, targetColumns) {
2427
+ let selectStatement = options.selectStatement;
2428
+ if (typeof selectStatement !== "string") {
2429
+ selectStatement = toStaticQuery(selectStatement);
2430
+ }
2431
+ if (targetSchema === void 0 || targetColumns === void 0) {
2432
+ throw new Error(
2433
+ "Supply the type param T so that the schema is inserted by the compiler plugin."
2434
+ );
2435
+ }
2436
+ const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2437
+ requireTargetTableName(
2438
+ options.targetTable?.name ?? options.tableName
2439
+ ),
2440
+ {
2441
+ orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2442
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2443
+ },
2444
+ targetSchema,
2445
+ targetColumns
2446
+ );
2447
+ if (targetTable.name === options.materializedViewName) {
2448
+ throw new Error(
2449
+ "Materialized view name cannot be the same as the target table name."
2450
+ );
2451
+ }
2452
+ this.name = options.materializedViewName;
2453
+ this.targetTable = targetTable;
2454
+ this.selectSql = selectStatement;
2455
+ this.sourceTables = options.selectTables.map((t) => t.name);
2456
+ const stack = new Error().stack;
2457
+ this.sourceFile = getSourceFileFromStack(stack);
2458
+ const materializedViews = getMooseInternal().materializedViews;
2459
+ if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2460
+ throw new Error(`MaterializedView with name ${this.name} already exists`);
2461
+ }
2462
+ materializedViews.set(this.name, this);
2463
+ }
2464
+ };
2465
+
2410
2466
  // src/dmv2/sdk/sqlResource.ts
2411
2467
  var SqlResource = class {
2412
2468
  /** @internal */
@@ -2452,66 +2508,18 @@ var SqlResource = class {
2452
2508
  }
2453
2509
  };
2454
2510
 
2455
- // src/dmv2/sdk/materializedView.ts
2456
- var requireTargetTableName = (tableName) => {
2457
- if (typeof tableName === "string") {
2458
- return tableName;
2459
- } else {
2460
- throw new Error("Name of targetTable is not specified.");
2461
- }
2462
- };
2463
- var MaterializedView = class extends SqlResource {
2464
- /** The target OlapTable instance where the materialized data is stored. */
2465
- targetTable;
2466
- constructor(options, targetSchema, targetColumns) {
2467
- let selectStatement = options.selectStatement;
2468
- if (typeof selectStatement !== "string") {
2469
- selectStatement = toStaticQuery(selectStatement);
2470
- }
2471
- if (targetSchema === void 0 || targetColumns === void 0) {
2472
- throw new Error(
2473
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2474
- );
2475
- }
2476
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2477
- requireTargetTableName(
2478
- options.targetTable?.name ?? options.tableName
2479
- ),
2480
- {
2481
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2482
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2483
- },
2484
- targetSchema,
2485
- targetColumns
2486
- );
2487
- if (targetTable.name === options.materializedViewName) {
2488
- throw new Error(
2489
- "Materialized view name cannot be the same as the target table name."
2490
- );
2491
- }
2492
- super(
2493
- options.materializedViewName,
2494
- [
2495
- createMaterializedView({
2496
- name: options.materializedViewName,
2497
- destinationTable: targetTable.name,
2498
- select: selectStatement
2499
- })
2500
- // Population is now handled automatically by Rust infrastructure
2501
- // based on table engine type and whether this is a new or updated view
2502
- ],
2503
- [dropView(options.materializedViewName)],
2504
- {
2505
- pullsDataFrom: options.selectTables,
2506
- pushesDataTo: [targetTable]
2507
- }
2508
- );
2509
- this.targetTable = targetTable;
2510
- }
2511
- };
2512
-
2513
2511
  // src/dmv2/sdk/view.ts
2514
- var View = class extends SqlResource {
2512
+ var View = class {
2513
+ /** @internal */
2514
+ kind = "CustomView";
2515
+ /** The name of the view */
2516
+ name;
2517
+ /** The SELECT SQL statement that defines the view */
2518
+ selectSql;
2519
+ /** Names of source tables/views that the SELECT reads from */
2520
+ sourceTables;
2521
+ /** @internal Source file path where this view was defined */
2522
+ sourceFile;
2515
2523
  /**
2516
2524
  * Creates a new View instance.
2517
2525
  * @param name The name of the view to be created.
@@ -2522,17 +2530,16 @@ var View = class extends SqlResource {
2522
2530
  if (typeof selectStatement !== "string") {
2523
2531
  selectStatement = toStaticQuery(selectStatement);
2524
2532
  }
2525
- super(
2526
- name,
2527
- [
2528
- `CREATE VIEW IF NOT EXISTS ${name}
2529
- AS ${selectStatement}`.trim()
2530
- ],
2531
- [dropView(name)],
2532
- {
2533
- pullsDataFrom: baseTables
2534
- }
2535
- );
2533
+ this.name = name;
2534
+ this.selectSql = selectStatement;
2535
+ this.sourceTables = baseTables.map((t) => t.name);
2536
+ const stack = new Error().stack;
2537
+ this.sourceFile = getSourceFileFromStack(stack);
2538
+ const customViews = getMooseInternal().customViews;
2539
+ if (!isClientOnlyMode() && customViews.has(this.name)) {
2540
+ throw new Error(`View with name ${this.name} already exists`);
2541
+ }
2542
+ customViews.set(this.name, this);
2536
2543
  }
2537
2544
  };
2538
2545
 
@@ -3414,7 +3421,6 @@ var DataSource = class {
3414
3421
  createClickhouseParameter,
3415
3422
  createConsumptionApi,
3416
3423
  createMaterializedView,
3417
- createProducerConfig,
3418
3424
  dropView,
3419
3425
  expressMiddleware,
3420
3426
  getApi,