typekro 0.22.1 → 0.24.0

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 (120) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/core/deployment/kro-factory.d.ts +19 -0
  3. package/dist/core/deployment/kro-factory.d.ts.map +1 -1
  4. package/dist/core/deployment/kro-factory.js +60 -6
  5. package/dist/core/deployment/kro-factory.js.map +1 -1
  6. package/dist/core/proxy/create-resource.d.ts.map +1 -1
  7. package/dist/core/proxy/create-resource.js +37 -0
  8. package/dist/core/proxy/create-resource.js.map +1 -1
  9. package/dist/core/references/schema-proxy.d.ts.map +1 -1
  10. package/dist/core/references/schema-proxy.js +21 -5
  11. package/dist/core/references/schema-proxy.js.map +1 -1
  12. package/dist/factories/clickhouse/compositions/clickhouse-cluster.d.ts +78 -0
  13. package/dist/factories/clickhouse/compositions/clickhouse-cluster.d.ts.map +1 -0
  14. package/dist/factories/clickhouse/compositions/clickhouse-cluster.js +258 -0
  15. package/dist/factories/clickhouse/compositions/clickhouse-cluster.js.map +1 -0
  16. package/dist/factories/clickhouse/compositions/clickhouse-helm-repository.d.ts +22 -0
  17. package/dist/factories/clickhouse/compositions/clickhouse-helm-repository.d.ts.map +1 -0
  18. package/dist/factories/clickhouse/compositions/clickhouse-helm-repository.js +35 -0
  19. package/dist/factories/clickhouse/compositions/clickhouse-helm-repository.js.map +1 -0
  20. package/dist/factories/clickhouse/compositions/clickhouse-operator-bootstrap.d.ts +68 -0
  21. package/dist/factories/clickhouse/compositions/clickhouse-operator-bootstrap.d.ts.map +1 -0
  22. package/dist/factories/clickhouse/compositions/clickhouse-operator-bootstrap.js +137 -0
  23. package/dist/factories/clickhouse/compositions/clickhouse-operator-bootstrap.js.map +1 -0
  24. package/dist/factories/clickhouse/compositions/index.d.ts +4 -0
  25. package/dist/factories/clickhouse/compositions/index.d.ts.map +1 -0
  26. package/dist/factories/clickhouse/compositions/index.js +4 -0
  27. package/dist/factories/clickhouse/compositions/index.js.map +1 -0
  28. package/dist/factories/clickhouse/index.d.ts +70 -0
  29. package/dist/factories/clickhouse/index.d.ts.map +1 -0
  30. package/dist/factories/clickhouse/index.js +70 -0
  31. package/dist/factories/clickhouse/index.js.map +1 -0
  32. package/dist/factories/clickhouse/resources/helm.d.ts +62 -0
  33. package/dist/factories/clickhouse/resources/helm.d.ts.map +1 -0
  34. package/dist/factories/clickhouse/resources/helm.js +94 -0
  35. package/dist/factories/clickhouse/resources/helm.js.map +1 -0
  36. package/dist/factories/clickhouse/resources/index.d.ts +4 -0
  37. package/dist/factories/clickhouse/resources/index.d.ts.map +1 -0
  38. package/dist/factories/clickhouse/resources/index.js +4 -0
  39. package/dist/factories/clickhouse/resources/index.js.map +1 -0
  40. package/dist/factories/clickhouse/resources/installation.d.ts +83 -0
  41. package/dist/factories/clickhouse/resources/installation.d.ts.map +1 -0
  42. package/dist/factories/clickhouse/resources/installation.js +316 -0
  43. package/dist/factories/clickhouse/resources/installation.js.map +1 -0
  44. package/dist/factories/clickhouse/resources/keeper.d.ts +40 -0
  45. package/dist/factories/clickhouse/resources/keeper.d.ts.map +1 -0
  46. package/dist/factories/clickhouse/resources/keeper.js +107 -0
  47. package/dist/factories/clickhouse/resources/keeper.js.map +1 -0
  48. package/dist/factories/clickhouse/types.d.ts +552 -0
  49. package/dist/factories/clickhouse/types.d.ts.map +1 -0
  50. package/dist/factories/clickhouse/types.js +295 -0
  51. package/dist/factories/clickhouse/types.js.map +1 -0
  52. package/dist/factories/clickhouse/utils/helm-values-mapper.d.ts +65 -0
  53. package/dist/factories/clickhouse/utils/helm-values-mapper.d.ts.map +1 -0
  54. package/dist/factories/clickhouse/utils/helm-values-mapper.js +80 -0
  55. package/dist/factories/clickhouse/utils/helm-values-mapper.js.map +1 -0
  56. package/dist/factories/clickhouse/utils/index.d.ts +4 -0
  57. package/dist/factories/clickhouse/utils/index.d.ts.map +1 -0
  58. package/dist/factories/clickhouse/utils/index.js +4 -0
  59. package/dist/factories/clickhouse/utils/index.js.map +1 -0
  60. package/dist/factories/clickhouse/utils/validation.d.ts +21 -0
  61. package/dist/factories/clickhouse/utils/validation.d.ts.map +1 -0
  62. package/dist/factories/clickhouse/utils/validation.js +27 -0
  63. package/dist/factories/clickhouse/utils/validation.js.map +1 -0
  64. package/dist/factories/clickhouse/utils/zone-layout.d.ts +74 -0
  65. package/dist/factories/clickhouse/utils/zone-layout.d.ts.map +1 -0
  66. package/dist/factories/clickhouse/utils/zone-layout.js +103 -0
  67. package/dist/factories/clickhouse/utils/zone-layout.js.map +1 -0
  68. package/dist/factories/clickstack/compositions/clickstack-bootstrap.d.ts +248 -0
  69. package/dist/factories/clickstack/compositions/clickstack-bootstrap.d.ts.map +1 -0
  70. package/dist/factories/clickstack/compositions/clickstack-bootstrap.js +251 -0
  71. package/dist/factories/clickstack/compositions/clickstack-bootstrap.js.map +1 -0
  72. package/dist/factories/clickstack/compositions/clickstack-helm-repository.d.ts +23 -0
  73. package/dist/factories/clickstack/compositions/clickstack-helm-repository.d.ts.map +1 -0
  74. package/dist/factories/clickstack/compositions/clickstack-helm-repository.js +36 -0
  75. package/dist/factories/clickstack/compositions/clickstack-helm-repository.js.map +1 -0
  76. package/dist/factories/clickstack/compositions/index.d.ts +5 -0
  77. package/dist/factories/clickstack/compositions/index.d.ts.map +1 -0
  78. package/dist/factories/clickstack/compositions/index.js +5 -0
  79. package/dist/factories/clickstack/compositions/index.js.map +1 -0
  80. package/dist/factories/clickstack/compositions/k8s-telemetry.d.ts +83 -0
  81. package/dist/factories/clickstack/compositions/k8s-telemetry.d.ts.map +1 -0
  82. package/dist/factories/clickstack/compositions/k8s-telemetry.js +134 -0
  83. package/dist/factories/clickstack/compositions/k8s-telemetry.js.map +1 -0
  84. package/dist/factories/clickstack/compositions/otel-helm-repository.d.ts +18 -0
  85. package/dist/factories/clickstack/compositions/otel-helm-repository.d.ts.map +1 -0
  86. package/dist/factories/clickstack/compositions/otel-helm-repository.js +31 -0
  87. package/dist/factories/clickstack/compositions/otel-helm-repository.js.map +1 -0
  88. package/dist/factories/clickstack/index.d.ts +40 -0
  89. package/dist/factories/clickstack/index.d.ts.map +1 -0
  90. package/dist/factories/clickstack/index.js +40 -0
  91. package/dist/factories/clickstack/index.js.map +1 -0
  92. package/dist/factories/clickstack/resources/helm.d.ts +78 -0
  93. package/dist/factories/clickstack/resources/helm.d.ts.map +1 -0
  94. package/dist/factories/clickstack/resources/helm.js +139 -0
  95. package/dist/factories/clickstack/resources/helm.js.map +1 -0
  96. package/dist/factories/clickstack/resources/index.d.ts +3 -0
  97. package/dist/factories/clickstack/resources/index.d.ts.map +1 -0
  98. package/dist/factories/clickstack/resources/index.js +3 -0
  99. package/dist/factories/clickstack/resources/index.js.map +1 -0
  100. package/dist/factories/clickstack/resources/mongo.d.ts +40 -0
  101. package/dist/factories/clickstack/resources/mongo.d.ts.map +1 -0
  102. package/dist/factories/clickstack/resources/mongo.js +122 -0
  103. package/dist/factories/clickstack/resources/mongo.js.map +1 -0
  104. package/dist/factories/clickstack/types.d.ts +483 -0
  105. package/dist/factories/clickstack/types.d.ts.map +1 -0
  106. package/dist/factories/clickstack/types.js +300 -0
  107. package/dist/factories/clickstack/types.js.map +1 -0
  108. package/dist/factories/clickstack/utils/helm-values-mapper.d.ts +118 -0
  109. package/dist/factories/clickstack/utils/helm-values-mapper.d.ts.map +1 -0
  110. package/dist/factories/clickstack/utils/helm-values-mapper.js +505 -0
  111. package/dist/factories/clickstack/utils/helm-values-mapper.js.map +1 -0
  112. package/dist/factories/clickstack/utils/index.d.ts +2 -0
  113. package/dist/factories/clickstack/utils/index.d.ts.map +1 -0
  114. package/dist/factories/clickstack/utils/index.js +2 -0
  115. package/dist/factories/clickstack/utils/index.js.map +1 -0
  116. package/dist/factories/index.d.ts +1 -0
  117. package/dist/factories/index.d.ts.map +1 -1
  118. package/dist/factories/index.js +4 -0
  119. package/dist/factories/index.js.map +1 -1
  120. package/package.json +9 -1
@@ -0,0 +1,295 @@
1
+ /**
2
+ * ClickHouse (Altinity clickhouse-operator) Type Definitions
3
+ *
4
+ * ArkType schemas as the single source of truth for config shapes, with types
5
+ * inferred via `typeof Schema.infer`. Status types remain hand-written
6
+ * interfaces, mirroring the CNPG factory family.
7
+ *
8
+ * Wraps the OFFICIAL Altinity clickhouse-operator (Apache-2.0):
9
+ * - Operator chart: `altinity-clickhouse-operator` from https://helm.altinity.com
10
+ * - CHI CRD: `clickhouseinstallations.clickhouse.altinity.com/v1`
11
+ * - CHK CRD: `clickhousekeeperinstallations.clickhouse-keeper.altinity.com/v1`
12
+ *
13
+ * @see https://github.com/Altinity/clickhouse-operator
14
+ * @see https://docs.altinity.com/altinitykubernetesoperator/
15
+ */
16
+ import { type } from 'arktype';
17
+ // ============================================================================
18
+ // Bootstrap Config (Helm Operator Install)
19
+ // ============================================================================
20
+ /**
21
+ * ArkType schema for ClickHouseOperatorBootstrapConfig.
22
+ *
23
+ * Configuration for installing the Altinity clickhouse-operator via Helm.
24
+ * Used by the `clickhouseOperatorBootstrap` composition to deploy the
25
+ * operator controller into the cluster.
26
+ *
27
+ * IMPORTANT: the operator is CLUSTER-SCOPED and owns the ClickHouse CRDs —
28
+ * install exactly ONE per cluster. Multiple installs fight over CRD ownership
29
+ * and watch the same resources. The bootstrap defaults to `shared: true`
30
+ * (cluster-scoped resource tagging) accordingly.
31
+ */
32
+ export const ClickHouseOperatorBootstrapConfigSchema = type({
33
+ /** Release name for the Helm installation. */
34
+ name: 'string',
35
+ /** Namespace for the operator (default: 'clickhouse-system'). */
36
+ 'namespace?': 'string',
37
+ /** Chart version (default: '0.27.1'). */
38
+ 'version?': 'string',
39
+ /**
40
+ * Metrics exporter configuration. The chart enables the metrics exporter
41
+ * by default (`metrics.enabled: true`).
42
+ */
43
+ 'metrics?': { 'enabled?': 'boolean' },
44
+ /**
45
+ * CRD installation via Helm hook (`crdHook.enabled`). NOTE: when deploying
46
+ * through Flux (as this composition does), helm-controller's CRD handling
47
+ * interacts with hook-installed CRDs — Flux only upgrades CRDs per its
48
+ * `install.crds`/`upgrade.crds` policy, so CRD upgrades across operator
49
+ * versions may need explicit attention. Leave unset to use chart defaults.
50
+ */
51
+ 'crdHook?': { 'enabled?': 'boolean' },
52
+ /** Operator pod resources. */
53
+ 'resources?': {
54
+ 'requests?': { 'cpu?': 'string', 'memory?': 'string' },
55
+ 'limits?': { 'cpu?': 'string', 'memory?': 'string' },
56
+ },
57
+ /**
58
+ * Additional Helm values for user overrides. Works in BOTH modes:
59
+ * a concrete object is deep-merged into the mapped values at build time,
60
+ * and a schema reference (`customValues: schema.spec.customValues` in an
61
+ * outer composition) is carried through the graph-aware runtime values
62
+ * merge, so the override lands in the KRO-serialized HelmRelease values.
63
+ */
64
+ 'customValues?': 'Record<string, unknown>',
65
+ /**
66
+ * Whether the operator install should be treated as shared cluster
67
+ * infrastructure (default: `true`). When `true`, the Namespace and
68
+ * HelmRelease are tagged with `scopes: ['cluster']` so
69
+ * `factory.deleteInstance()` will NOT remove them — the operator is
70
+ * one-per-cluster infrastructure that every ClickHouseInstallation
71
+ * consumer depends on. Set to `false` only for dedicated throwaway
72
+ * environments (e.g. kind-cluster integration tests).
73
+ */
74
+ 'shared?': 'boolean',
75
+ });
76
+ /** ArkType schema for ClickHouseOperatorBootstrapStatus. */
77
+ export const ClickHouseOperatorBootstrapStatusSchema = type({
78
+ phase: '"Ready" | "Installing"',
79
+ ready: 'boolean',
80
+ 'version?': 'string',
81
+ });
82
+ // ============================================================================
83
+ // Shared HelmRepository Singleton
84
+ // ============================================================================
85
+ /** Spec accepted by the shared ClickHouse HelmRepository singleton. */
86
+ export const ClickHouseHelmRepositorySingletonSpecSchema = type({
87
+ name: 'string',
88
+ namespace: 'string',
89
+ url: 'string',
90
+ });
91
+ /** Status surfaced by the shared ClickHouse HelmRepository singleton. */
92
+ export const ClickHouseHelmRepositorySingletonStatusSchema = type({
93
+ ready: 'boolean',
94
+ });
95
+ // ============================================================================
96
+ // Helm Integration Types
97
+ // ============================================================================
98
+ /**
99
+ * ArkType schema for ClickHouseHelmRepositoryConfig.
100
+ *
101
+ * Configuration for the Altinity Helm chart repository.
102
+ */
103
+ export const ClickHouseHelmRepositoryConfigSchema = type({
104
+ /** Repository name (default: 'altinity'). */
105
+ 'name?': 'string',
106
+ /** Namespace for the HelmRepository (default: flux-system). */
107
+ 'namespace?': 'string',
108
+ /** Repository URL (default: 'https://helm.altinity.com'). */
109
+ 'url?': 'string',
110
+ /** Sync interval (default: '5m'). */
111
+ 'interval?': 'string',
112
+ /** Resource ID for composition references. */
113
+ 'id?': 'string',
114
+ });
115
+ /**
116
+ * ArkType schema for ClickHouseOperatorHelmReleaseConfig.
117
+ *
118
+ * Configuration for the altinity-clickhouse-operator Helm release.
119
+ */
120
+ export const ClickHouseOperatorHelmReleaseConfigSchema = type({
121
+ /** Release name. */
122
+ name: 'string',
123
+ /** Target namespace. */
124
+ 'namespace?': 'string',
125
+ /** Chart version (default: '0.27.1'). */
126
+ 'version?': 'string',
127
+ /** Helm values (plain object, or a graph-aware runtime values merge). */
128
+ 'values?': 'object',
129
+ /** HelmRepository name to reference (default: 'altinity'). */
130
+ 'repositoryName?': 'string',
131
+ /** Resource ID for composition references. */
132
+ 'id?': 'string',
133
+ });
134
+ // ============================================================================
135
+ // ClickHouseInstallation (CHI) Resource
136
+ // ============================================================================
137
+ /**
138
+ * ArkType schema for a single ClickHouse user entry.
139
+ *
140
+ * ARRAY shape (not a name-keyed map): user NAMES become CHI configuration
141
+ * PATH FRAGMENTS (`<user>/password_sha256_hex`), so they must be concrete
142
+ * strings at build time — a map keyed by schema proxies would serialize its
143
+ * keys as `__typekroSchemaKey/...` garbage. The array shape keeps names in a
144
+ * plain value position where the factory can validate them loudly, while
145
+ * `passwordSha256Hex`/`networksIp` are ordinary VALUES and may be schema
146
+ * references or CEL expressions.
147
+ */
148
+ export const ClickHouseUserSchema = type({
149
+ /** User name — becomes a CHI config path fragment; MUST be concrete. */
150
+ name: 'string',
151
+ /** SHA256 hex digest of the user password (value position — refs OK). */
152
+ 'passwordSha256Hex?': 'string',
153
+ /** Allowed source networks, e.g. ['::/0'] (value position — refs OK). */
154
+ 'networksIp?': 'string[]',
155
+ });
156
+ /**
157
+ * ArkType schema for ClickHouseInstallationConfig.
158
+ *
159
+ * HIGH-LEVEL configuration compiled by `clickHouseInstallation()` into a
160
+ * `clickhouse.altinity.com/v1` ClickHouseInstallation (CHI) spec. This is
161
+ * deliberately not a 1:1 CRD mirror: the typed factory exists to compile the
162
+ * zone-pinning layout the operator cannot express natively (see
163
+ * `utils/zone-layout.ts`).
164
+ *
165
+ * BUILD-TIME vs RUNTIME: `shards`, `replicas`, `zones`, and user NAMES are
166
+ * BUILD-TIME fields — the compiler enumerates pod templates and per-replica
167
+ * layout entries from them, so they must be concrete JS values (the factory
168
+ * throws loudly if any receives a KubernetesRef/CEL expression). Everything
169
+ * else (name, namespace, version, storage sizes, credentials, keeper host,
170
+ * ...) sits in plain VALUE positions and may be schema references. For
171
+ * schema-driven topology use `makeClickHouseCluster()`, which fixes the
172
+ * topology at construction time and exposes only ref-safe runtime spec.
173
+ */
174
+ export const ClickHouseInstallationConfigSchema = type({
175
+ /** Installation name. */
176
+ name: 'string',
177
+ /** Target namespace. */
178
+ 'namespace?': 'string',
179
+ /** Resource ID for composition references. */
180
+ 'id?': 'string',
181
+ /**
182
+ * Logical cluster name inside the CHI (default: 'cluster').
183
+ *
184
+ * SIGNOZ COMPATIBILITY: SigNoz's ClickHouse migrations hardcode the cluster
185
+ * name `cluster` — a SigNoz deployment pointed at this CHI only works when
186
+ * the default is kept. Override only for non-SigNoz consumers.
187
+ */
188
+ 'clusterName?': 'string',
189
+ /**
190
+ * ClickHouse server image tag (e.g. '25.12.5'). Compiled into the pod
191
+ * template image `clickhouse/clickhouse-server:<version>` unless `image`
192
+ * overrides the full reference.
193
+ */
194
+ version: 'string',
195
+ /** Full image override (takes precedence over `version`). */
196
+ 'image?': 'string',
197
+ /** Shard count (default: 1). */
198
+ 'shards?': 'number',
199
+ /** Replicas per shard (default: 1). */
200
+ 'replicas?': 'number',
201
+ /**
202
+ * Availability zones to pin replicas to (e.g. ['us-east-2a','us-east-2b']).
203
+ *
204
+ * When provided, the factory compiles a PER-REPLICA layout where each
205
+ * replica's pod template pins one zone via nodeAffinity on
206
+ * `topology.kubernetes.io/zone` (round-robin when replicas > zones).
207
+ * See `utils/zone-layout.ts` for why the operator's own `podDistribution`
208
+ * cannot do this (Altinity/clickhouse-operator#772).
209
+ */
210
+ 'zones?': 'string[]',
211
+ /** Persistent storage for ClickHouse data. Required. */
212
+ storage: {
213
+ /** Volume size (e.g. '100Gi'). Required. */
214
+ size: 'string',
215
+ /**
216
+ * StorageClass name. On EKS this should be a WaitForFirstConsumer +
217
+ * `allowVolumeExpansion: true` gp3 class so the PVC binds in the zone the
218
+ * scheduler places the pod (and can grow in place).
219
+ */
220
+ 'storageClassName?': 'string',
221
+ },
222
+ /**
223
+ * ClickHouse users (ARRAY shape), compiled to the operator's path-keyed
224
+ * `spec.configuration.users` format
225
+ * (`<user>/password_sha256_hex`, `<user>/networks/ip`).
226
+ *
227
+ * User NAMES become path fragments and must be concrete strings (the
228
+ * factory throws on refs); password/networks values may be refs.
229
+ */
230
+ 'users?': ClickHouseUserSchema.array(),
231
+ /**
232
+ * (ClickHouse) Keeper coordination endpoint, wired into
233
+ * `spec.configuration.zookeeper.nodes` (the operator uses the zookeeper
234
+ * section for clickhouse-keeper too). Required for replicated tables
235
+ * when `replicas > 1`.
236
+ */
237
+ 'keeper?': {
238
+ host: 'string',
239
+ /** Keeper client port (default: 2181). */
240
+ 'port?': 'number',
241
+ },
242
+ /** ClickHouse server container resources. */
243
+ 'podResources?': {
244
+ 'requests?': { 'cpu?': 'string', 'memory?': 'string' },
245
+ 'limits?': { 'cpu?': 'string', 'memory?': 'string' },
246
+ },
247
+ });
248
+ /** ArkType schema for {@link ClickHouseClusterStatus}. */
249
+ export const ClickHouseClusterStatusSchema = type({
250
+ ready: 'boolean',
251
+ phase: '"Installing" | "Ready" | "Failed"',
252
+ clickhouse: {
253
+ host: 'string',
254
+ port: 'number',
255
+ nativeUrl: 'string',
256
+ httpUrl: 'string',
257
+ clusterName: 'string',
258
+ database: 'string',
259
+ 'user?': 'string',
260
+ },
261
+ 'keeper?': { host: 'string', port: 'number' },
262
+ installation: {
263
+ name: 'string',
264
+ namespace: 'string',
265
+ 'endpoint?': 'string',
266
+ 'hostsCount?': 'number',
267
+ 'hostsCompletedCount?': 'number',
268
+ },
269
+ });
270
+ // ============================================================================
271
+ // ClickHouseKeeperInstallation (CHK) Resource
272
+ // ============================================================================
273
+ /**
274
+ * ArkType schema for ClickHouseKeeperInstallationConfig.
275
+ *
276
+ * Minimal high-level configuration compiled by
277
+ * `clickHouseKeeperInstallation()` into a `clickhouse-keeper.altinity.com/v1`
278
+ * ClickHouseKeeperInstallation (CHK) spec.
279
+ */
280
+ export const ClickHouseKeeperInstallationConfigSchema = type({
281
+ /** Keeper installation name. */
282
+ name: 'string',
283
+ /** Target namespace. */
284
+ 'namespace?': 'string',
285
+ /** Resource ID for composition references. */
286
+ 'id?': 'string',
287
+ /** Keeper replica count (default: 1; use an odd number for quorum). */
288
+ 'replicas?': 'number',
289
+ /** Persistent storage for the keeper log/snapshot data. */
290
+ 'storage?': {
291
+ size: 'string',
292
+ 'storageClassName?': 'string',
293
+ },
294
+ });
295
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/factories/clickhouse/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,+EAA+E;AAC/E,2CAA2C;AAC3C,+EAA+E;AAE/E;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,IAAI,CAAC;IAC1D,8CAA8C;IAC9C,IAAI,EAAE,QAAQ;IACd,iEAAiE;IACjE,YAAY,E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,mBAAmB,EAAE,QAAQ;KAC9B;CACF,CAAC,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Maps ClickHouseOperatorBootstrapConfig to altinity-clickhouse-operator
3
+ * Helm chart values.
4
+ *
5
+ * Chart: `altinity-clickhouse-operator` 0.27.x from https://helm.altinity.com
6
+ * (Apache-2.0). Values of note:
7
+ * - `metrics.enabled` — metrics exporter sidecar (chart default: true)
8
+ * - `crdHook.enabled` — CRDs installed via a Helm hook. CAVEAT: under Flux,
9
+ * helm-controller applies its own CRD policy (`install.crds`/`upgrade.crds`),
10
+ * so hook-managed CRD upgrades across operator versions deserve explicit
11
+ * review rather than blind chart bumps.
12
+ * - `operator.resources` — controller pod resources
13
+ */
14
+ import { type ValuesMergeExpression } from '../../../core/aspects/values-merge.js';
15
+ import type { ClickHouseOperatorBootstrapConfig } from '../types.js';
16
+ /** Chart values shape (subset we map; the chart accepts more via customValues). */
17
+ export interface ClickHouseOperatorHelmValues {
18
+ metrics?: {
19
+ enabled?: boolean;
20
+ };
21
+ crdHook?: {
22
+ enabled?: boolean;
23
+ };
24
+ operator?: {
25
+ resources?: {
26
+ requests?: {
27
+ cpu?: string;
28
+ memory?: string;
29
+ };
30
+ limits?: {
31
+ cpu?: string;
32
+ memory?: string;
33
+ };
34
+ };
35
+ };
36
+ [key: string]: unknown;
37
+ }
38
+ /**
39
+ * Mapper result: plain values, or a graph-aware runtime merge when
40
+ * `customValues` arrives as a schema reference / CEL expression (KRO then
41
+ * merges the override map into the mapped values at reconcile time).
42
+ */
43
+ export type ClickHouseOperatorMappedHelmValues = ClickHouseOperatorHelmValues | ValuesMergeExpression;
44
+ /**
45
+ * Fields the mapper consumes. The bootstrap passes them EXPLICITLY (never a
46
+ * spread of the schema proxy — spreading enumerates proxy keys and leaks
47
+ * `__typekroSchemaKey` marker garbage into the rendered values).
48
+ */
49
+ export type ClickHouseOperatorHelmValuesInput = {
50
+ [K in keyof Pick<ClickHouseOperatorBootstrapConfig, 'metrics' | 'crdHook' | 'resources' | 'customValues'>]: ClickHouseOperatorBootstrapConfig[K] | undefined;
51
+ };
52
+ /**
53
+ * Map bootstrap config to Helm chart values.
54
+ *
55
+ * Only explicitly-provided fields are emitted so chart defaults win
56
+ * everywhere else. `customValues` merges LAST so user overrides always win:
57
+ * - concrete object → deep-merged at build time (works in both modes);
58
+ * - schema reference / CEL expression → wrapped in the graph-aware runtime
59
+ * values merge (`mergeValuesExpression`), which the serializer compiles to
60
+ * a KRO runtime map-merge — the same path the Dagster factory uses. This is
61
+ * what makes `customValues` WORK in kro mode instead of being silently
62
+ * dropped from the serialized HelmRelease values.
63
+ */
64
+ export declare function mapClickHouseOperatorConfigToHelmValues(config: ClickHouseOperatorHelmValuesInput): ClickHouseOperatorMappedHelmValues;
65
+ //# sourceMappingURL=helm-values-mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helm-values-mapper.d.ts","sourceRoot":"","sources":["../../../../src/factories/clickhouse/utils/helm-values-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAErE,mFAAmF;AACnF,MAAM,WAAW,4BAA4B;IAC3C,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAChC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAChC,QAAQ,CAAC,EAAE;QACT,SAAS,CAAC,EAAE;YACV,QAAQ,CAAC,EAAE;gBAAE,GAAG,CAAC,EAAE,MAAM,CAAC;gBAAC,MAAM,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC;YAC7C,MAAM,CAAC,EAAE;gBAAE,GAAG,CAAC,EAAE,MAAM,CAAC;gBAAC,MAAM,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC;SAC5C,CAAC;KACH,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,kCAAkC,GAC1C,4BAA4B,GAC5B,qBAAqB,CAAC;AAE1B;;;;GAIG;AACH,MAAM,MAAM,iCAAiC,GAAG;KAC7C,CAAC,IAAI,MAAM,IAAI,CACd,iCAAiC,EACjC,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,cAAc,CACrD,GAAG,iCAAiC,CAAC,CAAC,CAAC,GAAG,SAAS;CACrD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,uCAAuC,CACrD,MAAM,EAAE,iCAAiC,GACxC,kCAAkC,CAgBpC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Maps ClickHouseOperatorBootstrapConfig to altinity-clickhouse-operator
3
+ * Helm chart values.
4
+ *
5
+ * Chart: `altinity-clickhouse-operator` 0.27.x from https://helm.altinity.com
6
+ * (Apache-2.0). Values of note:
7
+ * - `metrics.enabled` — metrics exporter sidecar (chart default: true)
8
+ * - `crdHook.enabled` — CRDs installed via a Helm hook. CAVEAT: under Flux,
9
+ * helm-controller applies its own CRD policy (`install.crds`/`upgrade.crds`),
10
+ * so hook-managed CRD upgrades across operator versions deserve explicit
11
+ * review rather than blind chart bumps.
12
+ * - `operator.resources` — controller pod resources
13
+ */
14
+ import { isValuesMergeExpression, mergeValuesExpression, } from '../../../core/aspects/values-merge.js';
15
+ import { isCelExpression, isKubernetesRef } from '../../../utils/type-guards.js';
16
+ /**
17
+ * Map bootstrap config to Helm chart values.
18
+ *
19
+ * Only explicitly-provided fields are emitted so chart defaults win
20
+ * everywhere else. `customValues` merges LAST so user overrides always win:
21
+ * - concrete object → deep-merged at build time (works in both modes);
22
+ * - schema reference / CEL expression → wrapped in the graph-aware runtime
23
+ * values merge (`mergeValuesExpression`), which the serializer compiles to
24
+ * a KRO runtime map-merge — the same path the Dagster factory uses. This is
25
+ * what makes `customValues` WORK in kro mode instead of being silently
26
+ * dropped from the serialized HelmRelease values.
27
+ */
28
+ export function mapClickHouseOperatorConfigToHelmValues(config) {
29
+ const values = {};
30
+ if (config.metrics !== undefined) {
31
+ values.metrics = config.metrics;
32
+ }
33
+ if (config.crdHook !== undefined) {
34
+ values.crdHook = config.crdHook;
35
+ }
36
+ if (config.resources !== undefined) {
37
+ values.operator = { resources: config.resources };
38
+ }
39
+ return mergeCustomValuesLast(values, config.customValues);
40
+ }
41
+ /**
42
+ * Merge `customValues` last — build-time deep merge for concrete objects,
43
+ * graph-aware runtime merge for refs / CEL / merge expressions.
44
+ */
45
+ function mergeCustomValuesLast(base, customValues) {
46
+ if (customValues === undefined)
47
+ return base;
48
+ if (isKubernetesRef(customValues) ||
49
+ isCelExpression(customValues) ||
50
+ isValuesMergeExpression(customValues)) {
51
+ return mergeValuesExpression(base, customValues);
52
+ }
53
+ if (isPlainObject(customValues)) {
54
+ deepMerge(base, customValues);
55
+ }
56
+ return base;
57
+ }
58
+ function isPlainObject(value) {
59
+ return (!!value &&
60
+ typeof value === 'object' &&
61
+ !Array.isArray(value) &&
62
+ !isKubernetesRef(value) &&
63
+ !isCelExpression(value) &&
64
+ !isValuesMergeExpression(value));
65
+ }
66
+ /** Minimal deep merge (objects only; arrays/scalars replace), proto-safe. */
67
+ function deepMerge(target, source) {
68
+ for (const [key, sourceValue] of Object.entries(source)) {
69
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype')
70
+ continue;
71
+ const targetValue = target[key];
72
+ if (isPlainObject(targetValue) && isPlainObject(sourceValue)) {
73
+ deepMerge(targetValue, sourceValue);
74
+ }
75
+ else {
76
+ target[key] = sourceValue;
77
+ }
78
+ }
79
+ }
80
+ //# sourceMappingURL=helm-values-mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helm-values-mapper.js","sourceRoot":"","sources":["../../../../src/factories/clickhouse/utils/helm-values-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG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ACzB,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,CAAC,eAAe,CAAC,KAAK,CAAC;QACvB,CAAC,eAAe,CAAC,KAAK,CAAC;QACvB,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAChC,CAAC;AACJ,CAAC;AAED,6EAA6E;AAC7E,SAAS,SAAS,CAAC,MAA+B,EAAE,MAA+B;IACjF,KAAK,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACxD,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,aAAa,IAAI,GAAG,KAAK,WAAW;YAAE,SAAS;QAClF,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,aAAa,CAAC,WAAW,CAAC,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;YAC7D,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;QAC5B,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './helm-values-mapper.js';
2
+ export * from './validation.js';
3
+ export * from './zone-layout.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/factories/clickhouse/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './helm-values-mapper.js';
2
+ export * from './validation.js';
3
+ export * from './zone-layout.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/factories/clickhouse/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Shared build-time validation for ClickHouse topology counts.
3
+ *
4
+ * The Altinity operator rejects a CHI/CHK layout with `shardsCount: 0` /
5
+ * `replicasCount: 0` (and fractional or negative counts are never valid), so
6
+ * every entry point that compiles a layout — the plain homogeneous path, the
7
+ * zone-pinned path, the keeper compiler, and the `makeClickHouseCluster`
8
+ * constructor — validates counts here BEFORE emitting operator input.
9
+ */
10
+ /**
11
+ * Assert that a topology count is a positive integer (>= 1).
12
+ *
13
+ * @param context - The entry point name for the error message
14
+ * (e.g. `clickHouseInstallation`)
15
+ * @param field - The offending config field (e.g. `replicas`)
16
+ * @param value - The value received
17
+ * @throws Error naming the entry point, field, and received value when the
18
+ * value is zero, negative, or not an integer
19
+ */
20
+ export declare function assertPositiveIntegerCount(context: string, field: string, value: number): void;
21
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/factories/clickhouse/utils/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,IAAI,CAQN"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Shared build-time validation for ClickHouse topology counts.
3
+ *
4
+ * The Altinity operator rejects a CHI/CHK layout with `shardsCount: 0` /
5
+ * `replicasCount: 0` (and fractional or negative counts are never valid), so
6
+ * every entry point that compiles a layout — the plain homogeneous path, the
7
+ * zone-pinned path, the keeper compiler, and the `makeClickHouseCluster`
8
+ * constructor — validates counts here BEFORE emitting operator input.
9
+ */
10
+ /**
11
+ * Assert that a topology count is a positive integer (>= 1).
12
+ *
13
+ * @param context - The entry point name for the error message
14
+ * (e.g. `clickHouseInstallation`)
15
+ * @param field - The offending config field (e.g. `replicas`)
16
+ * @param value - The value received
17
+ * @throws Error naming the entry point, field, and received value when the
18
+ * value is zero, negative, or not an integer
19
+ */
20
+ export function assertPositiveIntegerCount(context, field, value) {
21
+ if (!Number.isInteger(value) || value < 1) {
22
+ throw new Error(`${context}: '${field}' must be a positive integer (got ${JSON.stringify(value)}). ` +
23
+ `The clickhouse-operator rejects a layout with a zero/invalid count — ` +
24
+ `use ${field} >= 1, or omit the field to use the default of 1.`);
25
+ }
26
+ }
27
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../src/factories/clickhouse/utils/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAAe,EACf,KAAa,EACb,KAAa;IAEb,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CACb,GAAG,OAAO,MAAM,KAAK,qCAAqC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK;YAClF,uEAAuE;YACvE,OAAO,KAAK,mDAAmD,CAClE,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Zone-pinned CHI layout compilation.
3
+ *
4
+ * WHY THIS EXISTS: the clickhouse-operator's own `podDistribution` supports
5
+ * ONLY the `kubernetes.io/hostname` topologyKey (Altinity/clickhouse-operator
6
+ * issue #772), so per-ZONE spreading cannot be expressed operator-natively.
7
+ * On EKS this matters operationally: EBS volumes are ZONAL, so a replica pod
8
+ * rescheduled into another AZ strands its PVC and the pod wedges Pending
9
+ * (we hit exactly this in production). The fix the operator DOES support is a
10
+ * per-replica `layout.replicas:` list where each replica's pod template pins
11
+ * one zone via nodeAffinity on `topology.kubernetes.io/zone` — this module
12
+ * compiles that layout deterministically.
13
+ *
14
+ * These helpers are pure (no resource construction) and unit-tested directly.
15
+ */
16
+ import type { ChiClusterLayoutReplica, ChiPodTemplate } from '../types.js';
17
+ /** Standard Kubernetes zone topology label. */
18
+ export declare const ZONE_TOPOLOGY_KEY = "topology.kubernetes.io/zone";
19
+ /**
20
+ * Assign one zone per replica index, round-robin.
21
+ *
22
+ * When `replicaCount > zones.length`, zones repeat in order:
23
+ * replicas=5, zones=[a,b,c] → [a, b, c, a, b].
24
+ *
25
+ * @param replicaCount - Number of replicas per shard
26
+ * @param zones - Non-empty list of availability zones
27
+ * @returns Zone for each replica index (length === replicaCount)
28
+ */
29
+ export declare function assignZonesRoundRobin(replicaCount: number, zones: readonly string[]): string[];
30
+ /**
31
+ * Deterministic pod template name for a zone-pinned template.
32
+ *
33
+ * Zone names are DNS-safe label values, so embedding them keeps the template
34
+ * name valid and self-describing (e.g. `clickhouse-us-east-2a`).
35
+ */
36
+ export declare function zonePodTemplateName(baseName: string, zone: string): string;
37
+ /**
38
+ * Explicit required nodeAffinity pinning a pod to one zone.
39
+ *
40
+ * Emitted as a plain PodSpec affinity (rather than the operator's
41
+ * `podTemplate.zone` sugar) so the pinning is visible verbatim in the
42
+ * rendered CHI and doesn't depend on operator-side template expansion.
43
+ */
44
+ export declare function zoneNodeAffinity(zone: string): Record<string, unknown>;
45
+ /** Result of compiling a zone-pinned per-replica cluster layout. */
46
+ export interface ZonePinnedLayout {
47
+ /**
48
+ * Replica-first layout entries — one per replica, each referencing its
49
+ * zone's pod template. Emitted INSTEAD of `replicasCount` (the replica
50
+ * list itself defines the replica count).
51
+ */
52
+ replicas: ChiClusterLayoutReplica[];
53
+ /**
54
+ * One pod template per DISTINCT assigned zone. Replicas sharing a zone
55
+ * (replicaCount > zones.length) share the template.
56
+ */
57
+ podTemplates: ChiPodTemplate[];
58
+ }
59
+ /**
60
+ * Compile the per-replica zone-pinned layout for a CHI cluster.
61
+ *
62
+ * @param options.replicaCount - Replicas per shard
63
+ * @param options.zones - Availability zones to round-robin replicas across
64
+ * @param options.podTemplateBaseName - Base name for generated pod templates
65
+ * @param options.podSpec - Shared PodSpec (containers etc.); the zone
66
+ * nodeAffinity is merged in per template
67
+ */
68
+ export declare function compileZonePinnedLayout(options: {
69
+ replicaCount: number;
70
+ zones: readonly string[];
71
+ podTemplateBaseName: string;
72
+ podSpec: Record<string, unknown>;
73
+ }): ZonePinnedLayout;
74
+ //# sourceMappingURL=zone-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zone-layout.d.ts","sourceRoot":"","sources":["../../../../src/factories/clickhouse/utils/zone-layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE3E,+CAA+C;AAC/C,eAAO,MAAM,iBAAiB,gCAAgC,CAAC;AAE/D;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,MAAM,EAAE,CAiBV;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAkBtE;AAED,oEAAoE;AACpE,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,QAAQ,EAAE,uBAAuB,EAAE,CAAC;IACpC;;;OAGG;IACH,YAAY,EAAE,cAAc,EAAE,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,GAAG,gBAAgB,CAkBnB"}