@514labs/moose-lib 0.6.297-ci-29-gef88e0aa → 0.6.297-ci-4-g8012f636

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.
@@ -259,6 +259,42 @@ interface TableIndex {
259
259
  arguments?: string[];
260
260
  granularity?: number;
261
261
  }
262
+ /**
263
+ * Defines a ClickHouse projection for optimizing specific query patterns.
264
+ * Projections duplicate data with different sort orders or pre-computed aggregations.
265
+ *
266
+ * ClickHouse rules:
267
+ * - Non-aggregate projections: Must have ORDER BY
268
+ * - Aggregate projections (with GROUP BY): Cannot have ORDER BY (ordering is implicit from GROUP BY)
269
+ */
270
+ type TableProjection<T = any> = {
271
+ /** Unique name for the projection */
272
+ name: string;
273
+ } & ({
274
+ /** List of column names to include in non-aggregate projection */
275
+ select: (keyof T & string)[];
276
+ /** Columns to order by (required for non-aggregate projections) */
277
+ orderBy: (keyof T & string)[];
278
+ groupBy?: never;
279
+ } | {
280
+ /** List of column names to include in aggregate projection */
281
+ select: (keyof T & string)[];
282
+ /** GROUP BY columns (for aggregate projections). ORDER BY is implicit from this. */
283
+ groupBy: (keyof T & string)[];
284
+ orderBy?: never;
285
+ } | {
286
+ /** SQL expression for SELECT clause (non-aggregate) */
287
+ select: string;
288
+ /** SQL expression for ORDER BY clause (required for non-aggregate projections) */
289
+ orderBy: string;
290
+ groupBy?: never;
291
+ } | {
292
+ /** SQL expression for SELECT clause (aggregate) */
293
+ select: string;
294
+ /** SQL expression for GROUP BY clause (for aggregate projections). ORDER BY is implicit from this. */
295
+ groupBy: string;
296
+ orderBy?: never;
297
+ });
262
298
  /**
263
299
  * Represents a failed record during insertion with error details
264
300
  */
@@ -458,6 +494,11 @@ type BaseOlapConfig<T> = ({
458
494
  ttl?: string;
459
495
  /** Optional secondary/data-skipping indexes */
460
496
  indexes?: TableIndex[];
497
+ /**
498
+ * Optional projections for optimizing specific query patterns.
499
+ * Projections store duplicate data with different sort orders or pre-computed aggregations.
500
+ */
501
+ projections?: TableProjection<T>[];
461
502
  /**
462
503
  * Optional database name for multi-database support.
463
504
  * When not specified, uses the global ClickHouse config database.
@@ -259,6 +259,42 @@ interface TableIndex {
259
259
  arguments?: string[];
260
260
  granularity?: number;
261
261
  }
262
+ /**
263
+ * Defines a ClickHouse projection for optimizing specific query patterns.
264
+ * Projections duplicate data with different sort orders or pre-computed aggregations.
265
+ *
266
+ * ClickHouse rules:
267
+ * - Non-aggregate projections: Must have ORDER BY
268
+ * - Aggregate projections (with GROUP BY): Cannot have ORDER BY (ordering is implicit from GROUP BY)
269
+ */
270
+ type TableProjection<T = any> = {
271
+ /** Unique name for the projection */
272
+ name: string;
273
+ } & ({
274
+ /** List of column names to include in non-aggregate projection */
275
+ select: (keyof T & string)[];
276
+ /** Columns to order by (required for non-aggregate projections) */
277
+ orderBy: (keyof T & string)[];
278
+ groupBy?: never;
279
+ } | {
280
+ /** List of column names to include in aggregate projection */
281
+ select: (keyof T & string)[];
282
+ /** GROUP BY columns (for aggregate projections). ORDER BY is implicit from this. */
283
+ groupBy: (keyof T & string)[];
284
+ orderBy?: never;
285
+ } | {
286
+ /** SQL expression for SELECT clause (non-aggregate) */
287
+ select: string;
288
+ /** SQL expression for ORDER BY clause (required for non-aggregate projections) */
289
+ orderBy: string;
290
+ groupBy?: never;
291
+ } | {
292
+ /** SQL expression for SELECT clause (aggregate) */
293
+ select: string;
294
+ /** SQL expression for GROUP BY clause (for aggregate projections). ORDER BY is implicit from this. */
295
+ groupBy: string;
296
+ orderBy?: never;
297
+ });
262
298
  /**
263
299
  * Represents a failed record during insertion with error details
264
300
  */
@@ -458,6 +494,11 @@ type BaseOlapConfig<T> = ({
458
494
  ttl?: string;
459
495
  /** Optional secondary/data-skipping indexes */
460
496
  indexes?: TableIndex[];
497
+ /**
498
+ * Optional projections for optimizing specific query patterns.
499
+ * Projections store duplicate data with different sort orders or pre-computed aggregations.
500
+ */
501
+ projections?: TableProjection<T>[];
461
502
  /**
462
503
  * Optional database name for multi-database support.
463
504
  * When not specified, uses the global ClickHouse config database.
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-FzU17dxm.mjs';
2
- import { a4 as MooseUtils, K as ApiUtil, a5 as MooseClient } from './index-CcHF2cVT.mjs';
3
- export { A as Aggregated, h as Api, i as ApiConfig, ae as ApiHelpers, a6 as Blocks, a7 as ClickHouseEngines, C as ConsumptionApi, af 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, ab 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, ac as WorkflowClient, a2 as createClickhouseParameter, a9 as createMaterializedView, a8 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, ad as getTemporalClient, a1 as getValueFromParameter, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows, ag as joinQueries, a3 as mapToClickHouseType, aa as populateTable, P as quoteIdentifier, Y as sql, $ as toQuery, a0 as toQueryPreview, _ as toStaticQuery } from './index-CcHF2cVT.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-nqz7MwT7.mjs';
2
+ import { a4 as MooseUtils, K as ApiUtil, a5 as MooseClient } from './index-B9bvaKAq.mjs';
3
+ export { A as Aggregated, h as Api, i as ApiConfig, ae as ApiHelpers, a6 as Blocks, a7 as ClickHouseEngines, C as ConsumptionApi, af 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, ab 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, ac as WorkflowClient, a2 as createClickhouseParameter, a9 as createMaterializedView, a8 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, ad as getTemporalClient, a1 as getValueFromParameter, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows, ag as joinQueries, a3 as mapToClickHouseType, aa as populateTable, P as quoteIdentifier, Y as sql, $ as toQuery, a0 as toQueryPreview, _ as toStaticQuery } from './index-B9bvaKAq.mjs';
4
4
  import * as _clickhouse_client from '@clickhouse/client';
5
5
  import { KafkaJS } from '@514labs/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-CMEunMFq.js';
2
- import { a4 as MooseUtils, K as ApiUtil, a5 as MooseClient } from './index-CcHF2cVT.js';
3
- export { A as Aggregated, h as Api, i as ApiConfig, ae as ApiHelpers, a6 as Blocks, a7 as ClickHouseEngines, C as ConsumptionApi, af 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, ab 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, ac as WorkflowClient, a2 as createClickhouseParameter, a9 as createMaterializedView, a8 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, ad as getTemporalClient, a1 as getValueFromParameter, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows, ag as joinQueries, a3 as mapToClickHouseType, aa as populateTable, P as quoteIdentifier, Y as sql, $ as toQuery, a0 as toQueryPreview, _ as toStaticQuery } from './index-CcHF2cVT.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-ZQ9mCsFj.js';
2
+ import { a4 as MooseUtils, K as ApiUtil, a5 as MooseClient } from './index-B9bvaKAq.js';
3
+ export { A as Aggregated, h as Api, i as ApiConfig, ae as ApiHelpers, a6 as Blocks, a7 as ClickHouseEngines, C as ConsumptionApi, af 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, ab 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, ac as WorkflowClient, a2 as createClickhouseParameter, a9 as createMaterializedView, a8 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, ad as getTemporalClient, a1 as getValueFromParameter, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows, ag as joinQueries, a3 as mapToClickHouseType, aa as populateTable, P as quoteIdentifier, Y as sql, $ as toQuery, a0 as toQueryPreview, _ as toStaticQuery } from './index-B9bvaKAq.js';
4
4
  import * as _clickhouse_client from '@clickhouse/client';
5
5
  import { KafkaJS } from '@514labs/kafka-javascript';
6
6
  import http from 'http';