@hypequery/clickhouse 1.5.0 → 1.6.1

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.
Files changed (118) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +19 -14
  3. package/dist/cli/generate-types.js +5 -12
  4. package/dist/core/adapters/clickhouse-adapter.d.ts +14 -0
  5. package/dist/core/adapters/clickhouse-adapter.d.ts.map +1 -0
  6. package/dist/core/adapters/clickhouse-adapter.js +58 -0
  7. package/dist/core/adapters/database-adapter.d.ts +13 -0
  8. package/dist/core/adapters/database-adapter.d.ts.map +1 -0
  9. package/dist/core/adapters/database-adapter.js +1 -0
  10. package/dist/core/cache/cache-manager.d.ts.map +1 -1
  11. package/dist/core/cache/cache-manager.js +6 -5
  12. package/dist/core/dialects/clickhouse-dialect.d.ts +10 -0
  13. package/dist/core/dialects/clickhouse-dialect.d.ts.map +1 -0
  14. package/dist/core/dialects/clickhouse-dialect.js +47 -0
  15. package/dist/core/dialects/sql-dialect.d.ts +11 -0
  16. package/dist/core/dialects/sql-dialect.d.ts.map +1 -0
  17. package/dist/core/dialects/sql-dialect.js +1 -0
  18. package/dist/core/features/aggregations.d.ts +5 -5
  19. package/dist/core/features/analytics.d.ts +822 -4
  20. package/dist/core/features/analytics.d.ts.map +1 -1
  21. package/dist/core/features/analytics.js +15 -9
  22. package/dist/core/features/executor.d.ts.map +1 -1
  23. package/dist/core/features/executor.js +26 -53
  24. package/dist/core/features/filtering.d.ts +5 -5
  25. package/dist/core/features/joins.d.ts +1 -1
  26. package/dist/core/features/query-modifiers.d.ts +6 -6
  27. package/dist/core/query-builder.d.ts +20 -7
  28. package/dist/core/query-builder.d.ts.map +1 -1
  29. package/dist/core/query-builder.js +45 -32
  30. package/dist/core/tests/integration/setup.d.ts +3 -1
  31. package/dist/core/tests/integration/setup.d.ts.map +1 -1
  32. package/dist/core/tests/test-utils.d.ts.map +1 -1
  33. package/dist/core/tests/test-utils.js +16 -4
  34. package/dist/core/types/builder-state.d.ts +7 -5
  35. package/dist/core/types/builder-state.d.ts.map +1 -1
  36. package/dist/core/types/select-types.d.ts +4 -3
  37. package/dist/core/types/select-types.d.ts.map +1 -1
  38. package/dist/core/utils/predicate-builder.d.ts +4 -0
  39. package/dist/core/utils/predicate-builder.d.ts.map +1 -1
  40. package/dist/core/utils/predicate-builder.js +4 -1
  41. package/dist/core/utils/streaming-helpers.d.ts.map +1 -1
  42. package/dist/core/utils/streaming-helpers.js +8 -0
  43. package/dist/core/utils.d.ts.map +1 -1
  44. package/dist/core/utils.js +3 -0
  45. package/dist/dataset/definition.d.ts +135 -0
  46. package/dist/dataset/definition.d.ts.map +1 -0
  47. package/dist/dataset/definition.js +265 -0
  48. package/dist/dataset/helpers.d.ts +136 -0
  49. package/dist/dataset/helpers.d.ts.map +1 -0
  50. package/dist/dataset/helpers.js +189 -0
  51. package/dist/dataset/index.d.ts +51 -0
  52. package/dist/dataset/index.d.ts.map +1 -0
  53. package/dist/dataset/index.js +59 -0
  54. package/dist/dataset/introspection.d.ts +133 -0
  55. package/dist/dataset/introspection.d.ts.map +1 -0
  56. package/dist/dataset/introspection.js +239 -0
  57. package/dist/dataset/sql-tag.d.ts +51 -0
  58. package/dist/dataset/sql-tag.d.ts.map +1 -0
  59. package/dist/dataset/sql-tag.js +86 -0
  60. package/dist/dataset/types.d.ts +300 -0
  61. package/dist/dataset/types.d.ts.map +1 -0
  62. package/dist/dataset/types.js +11 -0
  63. package/dist/index.d.ts +21 -0
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +25 -15
  66. package/dist/migrations/config/index.d.ts +3 -0
  67. package/dist/migrations/config/index.d.ts.map +1 -0
  68. package/dist/migrations/config/index.js +1 -0
  69. package/dist/migrations/config/types.d.ts +45 -0
  70. package/dist/migrations/config/types.d.ts.map +1 -0
  71. package/dist/migrations/config/types.js +28 -0
  72. package/dist/migrations/diff/diff.d.ts +11 -0
  73. package/dist/migrations/diff/diff.d.ts.map +1 -0
  74. package/dist/migrations/diff/diff.js +240 -0
  75. package/dist/migrations/diff/index.d.ts +3 -0
  76. package/dist/migrations/diff/index.d.ts.map +1 -0
  77. package/dist/migrations/diff/index.js +1 -0
  78. package/dist/migrations/diff/types.d.ts +74 -0
  79. package/dist/migrations/diff/types.d.ts.map +1 -0
  80. package/dist/migrations/diff/types.js +1 -0
  81. package/dist/migrations/schema/column.d.ts +71 -0
  82. package/dist/migrations/schema/column.d.ts.map +1 -0
  83. package/dist/migrations/schema/column.js +123 -0
  84. package/dist/migrations/schema/define.d.ts +24 -0
  85. package/dist/migrations/schema/define.d.ts.map +1 -0
  86. package/dist/migrations/schema/define.js +47 -0
  87. package/dist/migrations/schema/index.d.ts +4 -0
  88. package/dist/migrations/schema/index.d.ts.map +1 -0
  89. package/dist/migrations/schema/index.js +2 -0
  90. package/dist/migrations/schema/types.d.ts +74 -0
  91. package/dist/migrations/schema/types.d.ts.map +1 -0
  92. package/dist/migrations/schema/types.js +1 -0
  93. package/dist/migrations/snapshot/index.d.ts +3 -0
  94. package/dist/migrations/snapshot/index.d.ts.map +1 -0
  95. package/dist/migrations/snapshot/index.js +1 -0
  96. package/dist/migrations/snapshot/serialize.d.ts +21 -0
  97. package/dist/migrations/snapshot/serialize.d.ts.map +1 -0
  98. package/dist/migrations/snapshot/serialize.js +127 -0
  99. package/dist/migrations/snapshot/types.d.ts +47 -0
  100. package/dist/migrations/snapshot/types.d.ts.map +1 -0
  101. package/dist/migrations/snapshot/types.js +1 -0
  102. package/dist/migrations/sql/index.d.ts +4 -0
  103. package/dist/migrations/sql/index.d.ts.map +1 -0
  104. package/dist/migrations/sql/index.js +2 -0
  105. package/dist/migrations/sql/render.d.ts +11 -0
  106. package/dist/migrations/sql/render.d.ts.map +1 -0
  107. package/dist/migrations/sql/render.js +334 -0
  108. package/dist/migrations/sql/types.d.ts +48 -0
  109. package/dist/migrations/sql/types.d.ts.map +1 -0
  110. package/dist/migrations/sql/types.js +1 -0
  111. package/dist/migrations/sql/write.d.ts +9 -0
  112. package/dist/migrations/sql/write.d.ts.map +1 -0
  113. package/dist/migrations/sql/write.js +31 -0
  114. package/dist/types/base.d.ts +2 -1
  115. package/dist/types/base.d.ts.map +1 -1
  116. package/dist/types/clickhouse-types.d.ts +3 -1
  117. package/dist/types/clickhouse-types.d.ts.map +1 -1
  118. package/package.json +20 -20
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Dataset API Type Definitions
3
+ *
4
+ * Comprehensive type system for the dataset API, including:
5
+ * - Dataset definitions
6
+ * - Dimension and metric types
7
+ * - Filter operators and types
8
+ * - Query execution types
9
+ * - Type inference utilities
10
+ */
11
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  export { createQueryBuilder, QueryBuilder } from './core/query-builder.js';
2
2
  export { ClickHouseConnection } from './core/connection.js';
3
3
  export { JoinRelationships } from './core/join-relationships.js';
4
+ export { createClickHouseAdapter, ClickHouseAdapter } from './core/adapters/clickhouse-adapter.js';
5
+ export { ClickHouseDialect } from './core/dialects/clickhouse-dialect.js';
6
+ export type { DatabaseAdapter } from './core/adapters/database-adapter.js';
7
+ export type { SqlDialect } from './core/dialects/sql-dialect.js';
4
8
  export type { ClickHouseConfig, ClickHouseClientConfig, CreateQueryBuilderConfig, ExecuteOptions } from './core/query-builder.js';
5
9
  export { isClientConfig } from './core/query-builder.js';
6
10
  export type { CacheOptions, CacheConfig, CacheProvider, CacheEntry, CacheStatus } from './core/cache/types.js';
@@ -17,4 +21,21 @@ export { logger } from './core/utils/logger.js';
17
21
  export { raw, rawAs, selectExpr, toDateTime, formatDateTime, toStartOfInterval, datePart } from './core/utils/sql-expressions.js';
18
22
  export type { SqlExpression, FormatDateTimeOptions, AliasedExpression } from './core/utils/sql-expressions.js';
19
23
  export type { PredicateExpression, PredicateLiteral, PredicateBuilder, PredicateArg } from './core/utils/predicate-builder.js';
24
+ export { sql, isSQLExpression, toSQLString } from './dataset/sql-tag.js';
25
+ export type { SQLExpression } from './dataset/sql-tag.js';
26
+ export { dimension, metric } from './dataset/helpers.js';
27
+ export type { DimensionOptions, MetricOptions } from './dataset/helpers.js';
28
+ export type { DimensionType, SimpleDimension, DimensionDefinition, Dimension, DimensionsMap, MetricAggregationType, MetricFormat, MetricDefinition, MetricsMap, DatasetDefinition, DatasetsMap, TenantConfig, DatasetLimits, DateRangeValue, FilterValue, FilterDefinition, Filters, SortDirection, OrderByDimension, OrderByMetric, OrderBy, DatasetQuery, QueryContext, QueryResultMetadata, QueryResult, InferDimensionType, InferMetricType, InferQueryRowType, InferQueryResult, IntrospectedDimension, IntrospectedMetric, IntrospectedDataset, } from './dataset/types.js';
29
+ export { validateDatasetDefinition, validateDatasets, normalizeDimension, normalizeDimensions, inferDimensionType, getDimensionSQL, getMetricSQL, getDataset, listDatasets, hasDataset, getDimensionNames, getMetricNames, hasDimension, hasMetric, getDimension, getMetric, } from './dataset/definition.js';
30
+ export { introspectDimension, introspectMetric, getDatasetSchema, getAllDatasetSchemas, summarizeDataset, datasetsToJSON, summarizeAllDatasets, } from './dataset/introspection.js';
31
+ export { defineConfig, resolveClickHouseConfig, DEFAULT_MIGRATIONS_OUT_DIR, DEFAULT_MIGRATIONS_PREFIX, DEFAULT_MIGRATIONS_TABLE, } from './migrations/config/index.js';
32
+ export { column, ClickHouseColumnBuilder, defineMaterializedView, defineSchema, defineTable, } from './migrations/schema/index.js';
33
+ export { diffSnapshots, } from './migrations/diff/index.js';
34
+ export { serializeSchemaToSnapshot, snapshotToStableJson, hashSnapshot, } from './migrations/snapshot/index.js';
35
+ export { renderMigrationArtifacts, writeMigrationArtifacts, } from './migrations/sql/index.js';
36
+ export type { ClickHouseClusterConfig, ClickHouseMigrationDbCredentials, ClickHouseMigrationDirectoryConfig, HypequeryClickHouseConfig, MigrationFilePrefix, ResolvedHypequeryClickHouseConfig, } from './migrations/config/index.js';
37
+ export type { ClickHouseColumnDefinition, ClickHouseColumnBuilderLike, ClickHouseColumnDefaultValue, ClickHouseColumnType, ClickHouseDefaultInput, ClickHouseLowCardinalityColumnType, ClickHouseLiteralDefaultValue, ClickHouseMaterializedViewDefinition, ClickHouseMaterializedViewInputDefinition, ClickHouseNamedColumnType, ClickHouseNullableColumnType, ClickHouseSqlDefaultValue, ClickHouseSchemaAst, ClickHouseSchemaDefinition, ClickHouseSqlExpression, ClickHouseTableDefinition, ClickHouseTableInputDefinition, ClickHouseTableEngine, } from './migrations/schema/index.js';
38
+ export type { AddColumnOperation, AlterTableWithDependentViewsOperation, CreateMaterializedViewOperation, CreateTableOperation, DiffWarning, DropColumnOperation, DropMaterializedViewOperation, DropTableOperation, MigrationOperation, ModifyColumnDefaultOperation, ModifyColumnTypeOperation, RecreateMaterializedViewOperation, SnapshotDiffResult, TableMutationOperation, UnsupportedChange, } from './migrations/diff/index.js';
39
+ export type { MigrationMeta, RenderMigrationArtifactsOptions, RenderMigrationArtifactsResult, WriteMigrationArtifactsOptions, WriteMigrationArtifactsResult, } from './migrations/sql/index.js';
40
+ export type { Snapshot, SnapshotColumn, SnapshotColumnDefault, SnapshotDependencyEdge, SnapshotMaterializedView, SnapshotTable, SnapshotTableEngine, } from './migrations/snapshot/index.js';
20
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,EACxB,cAAc,EACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,YAAY,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,UAAU,EACV,WAAW,EACZ,MAAM,uBAAuB,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B,wBAAwB,EACxB,aAAa,EACb,mBAAmB,GACpB,MAAM,gCAAgC,CAAC"}
package/dist/index.js CHANGED
@@ -1,21 +1,31 @@
1
- // Main entry point
2
- export { createQueryBuilder } from './core/query-builder.js';
1
+ export { createQueryBuilder, QueryBuilder } from './core/query-builder.js';
3
2
  export { ClickHouseConnection } from './core/connection.js';
4
3
  export { JoinRelationships } from './core/join-relationships.js';
5
- export { CrossFilter } from './core/cross-filter.js';
6
- export { logger } from './core/utils/logger.js';
4
+ export { createClickHouseAdapter, ClickHouseAdapter } from './core/adapters/clickhouse-adapter.js';
5
+ export { ClickHouseDialect } from './core/dialects/clickhouse-dialect.js';
6
+ export { isClientConfig } from './core/query-builder.js';
7
7
  export { CacheController } from './core/cache/controller.js';
8
8
  export { MemoryCacheProvider } from './core/cache/providers/memory-lru.js';
9
9
  export { MemoryCacheProvider as MemoryLRUCacheProvider } from './core/cache/providers/memory-lru.js';
10
10
  export { NoopCacheProvider } from './core/cache/providers/noop.js';
11
- export {
12
- raw,
13
- rawAs,
14
- toDateTime,
15
- formatDateTime,
16
- toStartOfInterval,
17
- datePart
18
- } from './core/utils/sql-expressions.js';
19
-
20
- // Note: CLI functionality is deliberately not exported from the main package
21
- // This prevents Node.js-specific modules from being included in browser bundles
11
+ export { CrossFilter } from './core/cross-filter.js';
12
+ export { logger } from './core/utils/logger.js';
13
+ // Re-export SQL expression utilities
14
+ export { raw, rawAs, selectExpr, toDateTime, formatDateTime, toStartOfInterval, datePart } from './core/utils/sql-expressions.js';
15
+ // =============================================================================
16
+ // DATASET API (Phase 1)
17
+ // =============================================================================
18
+ // SQL tagged template
19
+ export { sql, isSQLExpression, toSQLString } from './dataset/sql-tag.js';
20
+ // Dimension and metric helpers
21
+ export { dimension, metric } from './dataset/helpers.js';
22
+ // Dataset definition utilities
23
+ export { validateDatasetDefinition, validateDatasets, normalizeDimension, normalizeDimensions, inferDimensionType, getDimensionSQL, getMetricSQL, getDataset, listDatasets, hasDataset, getDimensionNames, getMetricNames, hasDimension, hasMetric, getDimension, getMetric, } from './dataset/definition.js';
24
+ // Dataset introspection
25
+ export { introspectDimension, introspectMetric, getDatasetSchema, getAllDatasetSchemas, summarizeDataset, datasetsToJSON, summarizeAllDatasets, } from './dataset/introspection.js';
26
+ // Migrations foundations
27
+ export { defineConfig, resolveClickHouseConfig, DEFAULT_MIGRATIONS_OUT_DIR, DEFAULT_MIGRATIONS_PREFIX, DEFAULT_MIGRATIONS_TABLE, } from './migrations/config/index.js';
28
+ export { column, ClickHouseColumnBuilder, defineMaterializedView, defineSchema, defineTable, } from './migrations/schema/index.js';
29
+ export { diffSnapshots, } from './migrations/diff/index.js';
30
+ export { serializeSchemaToSnapshot, snapshotToStableJson, hashSnapshot, } from './migrations/snapshot/index.js';
31
+ export { renderMigrationArtifacts, writeMigrationArtifacts, } from './migrations/sql/index.js';
@@ -0,0 +1,3 @@
1
+ export { DEFAULT_MIGRATIONS_OUT_DIR, DEFAULT_MIGRATIONS_PREFIX, DEFAULT_MIGRATIONS_TABLE, defineConfig, resolveClickHouseConfig, } from './types.js';
2
+ export type { ClickHouseClusterConfig, ClickHouseMigrationDbCredentials, ClickHouseMigrationDirectoryConfig, HypequeryClickHouseConfig, MigrationFilePrefix, ResolvedHypequeryClickHouseConfig, } from './types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,YAAY,EACZ,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,uBAAuB,EACvB,gCAAgC,EAChC,kCAAkC,EAClC,yBAAyB,EACzB,mBAAmB,EACnB,iCAAiC,GAClC,MAAM,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ export { DEFAULT_MIGRATIONS_OUT_DIR, DEFAULT_MIGRATIONS_PREFIX, DEFAULT_MIGRATIONS_TABLE, defineConfig, resolveClickHouseConfig, } from './types.js';
@@ -0,0 +1,45 @@
1
+ export declare const DEFAULT_MIGRATIONS_OUT_DIR = "./migrations";
2
+ export declare const DEFAULT_MIGRATIONS_TABLE = "_hypequery_migrations";
3
+ export declare const DEFAULT_MIGRATIONS_PREFIX: "timestamp";
4
+ export type MigrationFilePrefix = typeof DEFAULT_MIGRATIONS_PREFIX;
5
+ export interface ClickHouseMigrationDirectoryConfig {
6
+ out: string;
7
+ table: string;
8
+ prefix: MigrationFilePrefix;
9
+ }
10
+ export interface ClickHouseMigrationDbCredentials {
11
+ host: string;
12
+ port?: number;
13
+ username: string;
14
+ password?: string;
15
+ database: string;
16
+ secure?: boolean;
17
+ }
18
+ export interface ClickHouseClusterConfig {
19
+ name: string;
20
+ }
21
+ export interface HypequeryClickHouseConfig {
22
+ dialect: 'clickhouse';
23
+ schema: string;
24
+ migrations?: Partial<ClickHouseMigrationDirectoryConfig>;
25
+ dbCredentials: ClickHouseMigrationDbCredentials;
26
+ cluster?: ClickHouseClusterConfig;
27
+ }
28
+ export interface ResolvedHypequeryClickHouseConfig extends Omit<HypequeryClickHouseConfig, 'migrations'> {
29
+ migrations: ClickHouseMigrationDirectoryConfig;
30
+ }
31
+ /**
32
+ * Defines a ClickHouse migration configuration while preserving literal TypeScript types.
33
+ *
34
+ * Use this from `hypequery.config.ts` so the CLI can load database credentials,
35
+ * schema entry points, and migration output settings from one typed object.
36
+ */
37
+ export declare function defineConfig(config: HypequeryClickHouseConfig): HypequeryClickHouseConfig;
38
+ /**
39
+ * Applies default migration settings to a user-provided ClickHouse config.
40
+ *
41
+ * This keeps CLI and programmatic callers aligned on the default output directory,
42
+ * migration table name, and timestamp-based file prefix strategy.
43
+ */
44
+ export declare function resolveClickHouseConfig(config: HypequeryClickHouseConfig): ResolvedHypequeryClickHouseConfig;
45
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/migrations/config/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,iBAAiB,CAAC;AACzD,eAAO,MAAM,wBAAwB,0BAA0B,CAAC;AAChE,eAAO,MAAM,yBAAyB,EAAG,WAAoB,CAAC;AAE9D,MAAM,MAAM,mBAAmB,GAAG,OAAO,yBAAyB,CAAC;AAEnE,MAAM,WAAW,kCAAkC;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAED,MAAM,WAAW,gCAAgC;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC,kCAAkC,CAAC,CAAC;IACzD,aAAa,EAAE,gCAAgC,CAAC;IAChD,OAAO,CAAC,EAAE,uBAAuB,CAAC;CACnC;AAED,MAAM,WAAW,iCACf,SAAQ,IAAI,CAAC,yBAAyB,EAAE,YAAY,CAAC;IACrD,UAAU,EAAE,kCAAkC,CAAC;CAChD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,yBAAyB,GAAG,yBAAyB,CAEzF;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,yBAAyB,GAChC,iCAAiC,CASnC"}
@@ -0,0 +1,28 @@
1
+ export const DEFAULT_MIGRATIONS_OUT_DIR = './migrations';
2
+ export const DEFAULT_MIGRATIONS_TABLE = '_hypequery_migrations';
3
+ export const DEFAULT_MIGRATIONS_PREFIX = 'timestamp';
4
+ /**
5
+ * Defines a ClickHouse migration configuration while preserving literal TypeScript types.
6
+ *
7
+ * Use this from `hypequery.config.ts` so the CLI can load database credentials,
8
+ * schema entry points, and migration output settings from one typed object.
9
+ */
10
+ export function defineConfig(config) {
11
+ return config;
12
+ }
13
+ /**
14
+ * Applies default migration settings to a user-provided ClickHouse config.
15
+ *
16
+ * This keeps CLI and programmatic callers aligned on the default output directory,
17
+ * migration table name, and timestamp-based file prefix strategy.
18
+ */
19
+ export function resolveClickHouseConfig(config) {
20
+ return {
21
+ ...config,
22
+ migrations: {
23
+ out: config.migrations?.out ?? DEFAULT_MIGRATIONS_OUT_DIR,
24
+ table: config.migrations?.table ?? DEFAULT_MIGRATIONS_TABLE,
25
+ prefix: config.migrations?.prefix ?? DEFAULT_MIGRATIONS_PREFIX,
26
+ },
27
+ };
28
+ }
@@ -0,0 +1,11 @@
1
+ import type { Snapshot } from '../snapshot/types.js';
2
+ import type { SnapshotDiffResult } from './types.js';
3
+ /**
4
+ * Computes migration operations needed to move from one snapshot to another.
5
+ *
6
+ * The diff layer is deliberately SQL-free. It emits structured operations,
7
+ * warnings for potentially expensive changes, and unsupported-change diagnostics
8
+ * that the SQL renderer refuses to render automatically.
9
+ */
10
+ export declare function diffSnapshots(previousSnapshot: Snapshot, nextSnapshot: Snapshot): SnapshotDiffResult;
11
+ //# sourceMappingURL=diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/migrations/diff/diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EAIT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAQV,kBAAkB,EAGnB,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,gBAAgB,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,GAAG,kBAAkB,CAqCpG"}
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Computes migration operations needed to move from one snapshot to another.
3
+ *
4
+ * The diff layer is deliberately SQL-free. It emits structured operations,
5
+ * warnings for potentially expensive changes, and unsupported-change diagnostics
6
+ * that the SQL renderer refuses to render automatically.
7
+ */
8
+ export function diffSnapshots(previousSnapshot, nextSnapshot) {
9
+ const warnings = [];
10
+ const unsupportedChanges = [];
11
+ const previousTables = toNameMap(previousSnapshot.tables);
12
+ const nextTables = toNameMap(nextSnapshot.tables);
13
+ const previousViews = toNameMap(previousSnapshot.materializedViews);
14
+ const nextViews = toNameMap(nextSnapshot.materializedViews);
15
+ const dropMaterializedViewOperations = diffDroppedMaterializedViews(previousViews, nextViews);
16
+ const dropTableOperations = diffDroppedTables(previousTables, nextTables);
17
+ const tableOperations = diffTables(previousSnapshot, nextSnapshot, previousTables, nextTables, warnings, unsupportedChanges);
18
+ const createTableOperations = diffCreatedTables(previousTables, nextTables);
19
+ const recreateMaterializedViewOperations = diffChangedMaterializedViews(previousViews, nextViews);
20
+ const createMaterializedViewOperations = diffCreatedMaterializedViews(previousViews, nextViews);
21
+ return {
22
+ previousSnapshot,
23
+ nextSnapshot,
24
+ operations: [
25
+ ...dropMaterializedViewOperations,
26
+ ...dropTableOperations,
27
+ ...tableOperations,
28
+ ...createTableOperations,
29
+ ...recreateMaterializedViewOperations,
30
+ ...createMaterializedViewOperations,
31
+ ],
32
+ warnings,
33
+ unsupportedChanges,
34
+ };
35
+ }
36
+ function diffDroppedMaterializedViews(previousViews, nextViews) {
37
+ return [...previousViews.values()]
38
+ .filter(view => !nextViews.has(view.name))
39
+ .map(view => ({
40
+ kind: 'DropMaterializedView',
41
+ viewName: view.name,
42
+ }));
43
+ }
44
+ function diffDroppedTables(previousTables, nextTables) {
45
+ return [...previousTables.values()]
46
+ .filter(table => !nextTables.has(table.name))
47
+ .map(table => ({
48
+ kind: 'DropTable',
49
+ tableName: table.name,
50
+ }));
51
+ }
52
+ function diffCreatedTables(previousTables, nextTables) {
53
+ return [...nextTables.values()]
54
+ .filter(table => !previousTables.has(table.name))
55
+ .map(table => ({
56
+ kind: 'CreateTable',
57
+ table,
58
+ }));
59
+ }
60
+ function diffCreatedMaterializedViews(previousViews, nextViews) {
61
+ return [...nextViews.values()]
62
+ .filter(view => !previousViews.has(view.name))
63
+ .map(view => ({
64
+ kind: 'CreateMaterializedView',
65
+ view,
66
+ }));
67
+ }
68
+ function diffChangedMaterializedViews(previousViews, nextViews) {
69
+ const operations = [];
70
+ for (const previousView of previousViews.values()) {
71
+ const nextView = nextViews.get(previousView.name);
72
+ if (!nextView) {
73
+ continue;
74
+ }
75
+ if (!isSameMaterializedView(previousView, nextView)) {
76
+ operations.push({
77
+ kind: 'RecreateMaterializedView',
78
+ previousView,
79
+ nextView,
80
+ });
81
+ }
82
+ }
83
+ return operations;
84
+ }
85
+ function diffTables(previousSnapshot, nextSnapshot, previousTables, nextTables, warnings, unsupportedChanges) {
86
+ const operations = [];
87
+ for (const previousTable of previousTables.values()) {
88
+ const nextTable = nextTables.get(previousTable.name);
89
+ if (!nextTable) {
90
+ continue;
91
+ }
92
+ if (!isSameTableEngine(previousTable.engine, nextTable.engine)) {
93
+ unsupportedChanges.push({
94
+ kind: 'TableEngineChanged',
95
+ tableName: previousTable.name,
96
+ message: `Table engine changed for "${previousTable.name}". Engine evolution is not auto-generated yet.`,
97
+ });
98
+ }
99
+ if (!isSameSettings(previousTable.settings, nextTable.settings)) {
100
+ unsupportedChanges.push({
101
+ kind: 'TableSettingsChanged',
102
+ tableName: previousTable.name,
103
+ message: `Table settings changed for "${previousTable.name}". Settings diffs are not auto-generated yet.`,
104
+ });
105
+ }
106
+ const tableMutations = diffColumns(previousTable, nextTable, warnings, unsupportedChanges);
107
+ if (tableMutations.length === 0) {
108
+ continue;
109
+ }
110
+ const dependentViewNames = getDependentViewNames(previousSnapshot, nextSnapshot, previousTable.name);
111
+ if (dependentViewNames.length > 0) {
112
+ operations.push({
113
+ kind: 'AlterTableWithDependentViews',
114
+ tableName: previousTable.name,
115
+ dependentViewNames,
116
+ operations: tableMutations,
117
+ });
118
+ continue;
119
+ }
120
+ operations.push(...tableMutations);
121
+ }
122
+ return operations;
123
+ }
124
+ function diffColumns(previousTable, nextTable, warnings, unsupportedChanges) {
125
+ const operations = [];
126
+ const previousColumns = toNameMap(previousTable.columns);
127
+ const nextColumns = toNameMap(nextTable.columns);
128
+ const droppedColumns = [...previousColumns.values()].filter(column => !nextColumns.has(column.name));
129
+ const addedColumns = [...nextColumns.values()].filter(column => !previousColumns.has(column.name));
130
+ detectPossibleRenames(previousTable.name, droppedColumns, addedColumns, unsupportedChanges);
131
+ for (const column of droppedColumns) {
132
+ operations.push({
133
+ kind: 'DropColumn',
134
+ tableName: previousTable.name,
135
+ columnName: column.name,
136
+ });
137
+ }
138
+ for (const column of addedColumns) {
139
+ operations.push({
140
+ kind: 'AddColumn',
141
+ tableName: previousTable.name,
142
+ column,
143
+ });
144
+ }
145
+ for (const previousColumn of previousColumns.values()) {
146
+ const nextColumn = nextColumns.get(previousColumn.name);
147
+ if (!nextColumn) {
148
+ continue;
149
+ }
150
+ if (previousColumn.type !== nextColumn.type) {
151
+ operations.push({
152
+ kind: 'ModifyColumnType',
153
+ tableName: previousTable.name,
154
+ columnName: previousColumn.name,
155
+ previousType: previousColumn.type,
156
+ nextType: nextColumn.type,
157
+ });
158
+ warnings.push({
159
+ kind: 'ModifyColumnTypeRequiresConfirmation',
160
+ tableName: previousTable.name,
161
+ columnName: previousColumn.name,
162
+ message: `Column type changed for "${previousTable.name}.${previousColumn.name}" ` +
163
+ `from "${previousColumn.type}" to "${nextColumn.type}".`,
164
+ });
165
+ }
166
+ if (!isSameColumnDefault(previousColumn.default, nextColumn.default)) {
167
+ operations.push({
168
+ kind: 'ModifyColumnDefault',
169
+ tableName: previousTable.name,
170
+ columnName: previousColumn.name,
171
+ previousDefault: previousColumn.default,
172
+ nextDefault: nextColumn.default,
173
+ });
174
+ }
175
+ }
176
+ return operations;
177
+ }
178
+ function isSameColumnDefault(left, right) {
179
+ if (left === right) {
180
+ return true;
181
+ }
182
+ if (left === undefined || right === undefined) {
183
+ return false;
184
+ }
185
+ return left.kind === right.kind && left.value === right.value;
186
+ }
187
+ function detectPossibleRenames(tableName, droppedColumns, addedColumns, unsupportedChanges) {
188
+ for (const droppedColumn of droppedColumns) {
189
+ const renameCandidate = addedColumns.find(addedColumn => addedColumn.type === droppedColumn.type &&
190
+ isSameColumnDefault(addedColumn.default, droppedColumn.default));
191
+ if (!renameCandidate) {
192
+ continue;
193
+ }
194
+ unsupportedChanges.push({
195
+ kind: 'PossibleColumnRename',
196
+ tableName,
197
+ columnName: droppedColumn.name,
198
+ message: `Possible column rename detected in "${tableName}": ` +
199
+ `"${droppedColumn.name}" -> "${renameCandidate.name}". ` +
200
+ `Rename inference is not supported in generated migrations.`,
201
+ });
202
+ }
203
+ }
204
+ function getDependentViewNames(previousSnapshot, nextSnapshot, tableName) {
205
+ return [...new Set([
206
+ ...previousSnapshot.dependencies
207
+ .filter(edge => edge.kind === 'table_to_materialized_view' && edge.from === tableName)
208
+ .map(edge => edge.to),
209
+ ...nextSnapshot.dependencies
210
+ .filter(edge => edge.kind === 'table_to_materialized_view' && edge.from === tableName)
211
+ .map(edge => edge.to),
212
+ ])].sort((left, right) => left.localeCompare(right));
213
+ }
214
+ function isSameTableEngine(left, right) {
215
+ return left.type === right.type &&
216
+ isSameStringArray(left.orderBy, right.orderBy) &&
217
+ (left.partitionBy ?? null) === (right.partitionBy ?? null) &&
218
+ isSameStringArray(left.primaryKey, right.primaryKey) &&
219
+ (left.sampleBy ?? null) === (right.sampleBy ?? null);
220
+ }
221
+ function isSameSettings(left, right) {
222
+ const leftEntries = Object.entries(left);
223
+ const rightEntries = Object.entries(right);
224
+ if (leftEntries.length !== rightEntries.length) {
225
+ return false;
226
+ }
227
+ return leftEntries.every(([key, value]) => right[key] === value);
228
+ }
229
+ function isSameMaterializedView(left, right) {
230
+ return left.name === right.name &&
231
+ left.from === right.from &&
232
+ (left.to ?? null) === (right.to ?? null) &&
233
+ left.select === right.select;
234
+ }
235
+ function isSameStringArray(left, right) {
236
+ return left.length === right.length && left.every((value, index) => value === right[index]);
237
+ }
238
+ function toNameMap(entries) {
239
+ return new Map(entries.map(entry => [entry.name, entry]));
240
+ }
@@ -0,0 +1,3 @@
1
+ export { diffSnapshots } from './diff.js';
2
+ export type { AddColumnOperation, AlterTableWithDependentViewsOperation, CreateMaterializedViewOperation, CreateTableOperation, DiffWarning, DropColumnOperation, DropMaterializedViewOperation, DropTableOperation, MigrationOperation, ModifyColumnDefaultOperation, ModifyColumnTypeOperation, RecreateMaterializedViewOperation, SnapshotDiffResult, TableMutationOperation, UnsupportedChange, } from './types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/diff/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,YAAY,EACV,kBAAkB,EAClB,qCAAqC,EACrC,+BAA+B,EAC/B,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EACnB,6BAA6B,EAC7B,kBAAkB,EAClB,kBAAkB,EAClB,4BAA4B,EAC5B,yBAAyB,EACzB,iCAAiC,EACjC,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ export { diffSnapshots } from './diff.js';
@@ -0,0 +1,74 @@
1
+ import type { Snapshot, SnapshotColumn, SnapshotColumnDefault, SnapshotMaterializedView, SnapshotTable } from '../snapshot/types.js';
2
+ export interface CreateTableOperation {
3
+ kind: 'CreateTable';
4
+ table: SnapshotTable;
5
+ }
6
+ export interface DropTableOperation {
7
+ kind: 'DropTable';
8
+ tableName: string;
9
+ }
10
+ export interface AddColumnOperation {
11
+ kind: 'AddColumn';
12
+ tableName: string;
13
+ column: SnapshotColumn;
14
+ }
15
+ export interface DropColumnOperation {
16
+ kind: 'DropColumn';
17
+ tableName: string;
18
+ columnName: string;
19
+ }
20
+ export interface ModifyColumnDefaultOperation {
21
+ kind: 'ModifyColumnDefault';
22
+ tableName: string;
23
+ columnName: string;
24
+ previousDefault?: SnapshotColumnDefault;
25
+ nextDefault?: SnapshotColumnDefault;
26
+ }
27
+ export interface ModifyColumnTypeOperation {
28
+ kind: 'ModifyColumnType';
29
+ tableName: string;
30
+ columnName: string;
31
+ previousType: string;
32
+ nextType: string;
33
+ }
34
+ export interface CreateMaterializedViewOperation {
35
+ kind: 'CreateMaterializedView';
36
+ view: SnapshotMaterializedView;
37
+ }
38
+ export interface DropMaterializedViewOperation {
39
+ kind: 'DropMaterializedView';
40
+ viewName: string;
41
+ }
42
+ export interface RecreateMaterializedViewOperation {
43
+ kind: 'RecreateMaterializedView';
44
+ previousView: SnapshotMaterializedView;
45
+ nextView: SnapshotMaterializedView;
46
+ }
47
+ export type TableMutationOperation = AddColumnOperation | DropColumnOperation | ModifyColumnDefaultOperation | ModifyColumnTypeOperation;
48
+ export interface AlterTableWithDependentViewsOperation {
49
+ kind: 'AlterTableWithDependentViews';
50
+ tableName: string;
51
+ dependentViewNames: string[];
52
+ operations: TableMutationOperation[];
53
+ }
54
+ export type MigrationOperation = AlterTableWithDependentViewsOperation | CreateMaterializedViewOperation | CreateTableOperation | DropMaterializedViewOperation | DropTableOperation | RecreateMaterializedViewOperation | TableMutationOperation;
55
+ export interface DiffWarning {
56
+ kind: 'ModifyColumnTypeRequiresConfirmation';
57
+ tableName: string;
58
+ columnName: string;
59
+ message: string;
60
+ }
61
+ export interface UnsupportedChange {
62
+ kind: 'PossibleColumnRename' | 'TableEngineChanged' | 'TableSettingsChanged';
63
+ message: string;
64
+ tableName: string;
65
+ columnName?: string;
66
+ }
67
+ export interface SnapshotDiffResult {
68
+ previousSnapshot: Snapshot;
69
+ nextSnapshot: Snapshot;
70
+ operations: MigrationOperation[];
71
+ warnings: DiffWarning[];
72
+ unsupportedChanges: UnsupportedChange[];
73
+ }
74
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/migrations/diff/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,aAAa,EACd,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACrC;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,+BAA+B;IAC9C,IAAI,EAAE,wBAAwB,CAAC;IAC/B,IAAI,EAAE,wBAAwB,CAAC;CAChC;AAED,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,s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aultValue, ClickHouseDefaultInput, ClickHouseColumnDefinition, ClickHouseColumnType } from './types.js';
2
+ type NestedColumnTypeInput = string | ClickHouseColumnBuilder | ClickHouseColumnType;
3
+ /**
4
+ * Immutable builder for ClickHouse column definitions.
5
+ *
6
+ * Each modifier returns a new builder so reusable column fragments can be shared
7
+ * safely without later calls mutating earlier definitions.
8
+ */
9
+ export declare class ClickHouseColumnBuilder implements ClickHouseColumnBuilderLike {
10
+ private readonly columnType;
11
+ private readonly defaultExpression?;
12
+ constructor(columnType: ClickHouseColumnType, defaultExpression?: ClickHouseColumnDefaultValue | undefined);
13
+ /**
14
+ * Adds a column default.
15
+ *
16
+ * Primitive values are rendered as SQL literals. Use the `sql` template tag for
17
+ * database expressions such as `sql\`now()\``.
18
+ */
19
+ default(expression: ClickHouseDefaultInput): ClickHouseColumnBuilder;
20
+ /**
21
+ * Wraps this column type in `Nullable(...)`.
22
+ */
23
+ nullable(): ClickHouseColumnBuilder;
24
+ /**
25
+ * Wraps this column type in `LowCardinality(...)`.
26
+ */
27
+ lowCardinality(): ClickHouseColumnBuilder;
28
+ /**
29
+ * Materializes the builder into a named column definition for a table AST.
30
+ */
31
+ build(name: string): ClickHouseColumnDefinition;
32
+ /**
33
+ * Returns the underlying type AST for nested type builders.
34
+ */
35
+ toColumnType(): ClickHouseColumnType;
36
+ }
37
+ /**
38
+ * Factory helpers for common ClickHouse column types.
39
+ *
40
+ * Examples:
41
+ * `column.String().default('pending')`, `column.Nullable('String')`,
42
+ * `column.DateTime('UTC')`.
43
+ */
44
+ export declare const column: {
45
+ Int8: () => ClickHouseColumnBuilder;
46
+ Int16: () => ClickHouseColumnBuilder;
47
+ Int32: () => ClickHouseColumnBuilder;
48
+ Int64: () => ClickHouseColumnBuilder;
49
+ Int128: () => ClickHouseColumnBuilder;
50
+ Int256: () => ClickHouseColumnBuilder;
51
+ UInt8: () => ClickHouseColumnBuilder;
52
+ UInt16: () => ClickHouseColumnBuilder;
53
+ UInt32: () => ClickHouseColumnBuilder;
54
+ UInt64: () => ClickHouseColumnBuilder;
55
+ UInt128: () => ClickHouseColumnBuilder;
56
+ UInt256: () => ClickHouseColumnBuilder;
57
+ Float32: () => ClickHouseColumnBuilder;
58
+ Float64: () => ClickHouseColumnBuilder;
59
+ Decimal: (precision: number, scale: number) => ClickHouseColumnBuilder;
60
+ String: () => ClickHouseColumnBuilder;
61
+ FixedString: (length: number) => ClickHouseColumnBuilder;
62
+ Date: () => ClickHouseColumnBuilder;
63
+ DateTime: (timezone?: string) => ClickHouseColumnBuilder;
64
+ DateTime64: (precision: number, timezone?: string) => ClickHouseColumnBuilder;
65
+ UUID: () => ClickHouseColumnBuilder;
66
+ JSON: () => ClickHouseColumnBuilder;
67
+ LowCardinality: (inner: NestedColumnTypeInput) => ClickHouseColumnBuilder;
68
+ Nullable: (inner: NestedColumnTypeInput) => ClickHouseColumnBuilder;
69
+ };
70
+ export {};
71
+ //# sourceMappingURL=column.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column.d.ts","sourceRoot":"","sources":["../../../src/migrations/schema/column.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,4BAA4B,EAC5B,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EAErB,MAAM,YAAY,CAAC;AAIpB,KAAK,qBAAqB,GAAG,MAAM,GAAG,uBAAuB,GAAG,oBAAoB,CAAC;AAErF;;;;;GAKG;AACH,qBAAa,uBAAwB,YAAW,2BAA2B;IAEvE,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC;gBADlB,UAAU,EAAE,oBAAoB,EAChC,iBAAiB,CAAC,EAAE,4BAA4B,YAAA;IAGnE;;;;;OAKG;IACH,OAAO,CAAC,UAAU,EAAE,sBAAsB,GAAG,uBAAuB;IAIpE;;OAEG;IACH,QAAQ,IAAI,uBAAuB;IAOnC;;OAEG;IACH,cAAc,IAAI,uBAAuB;IAOzC;;OAEG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,0BAA0B;IAQ/C;;OAEG;IACH,YAAY,IAAI,oBAAoB;CAGrC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;yBAeI,MAAM,SAAS,MAAM;;0BAEpB,MAAM;;0BAEN,MAAM;4BACJ,MAAM,aAAa,MAAM;;;4BAIzB,qBAAqB;sBAK3B,qBAAqB;CAKxC,CAAC"}