typekro 0.22.0 → 0.23.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 (68) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/core/composition/nested-status-cel.d.ts +10 -11
  3. package/dist/core/composition/nested-status-cel.d.ts.map +1 -1
  4. package/dist/core/composition/nested-status-cel.js +13 -2
  5. package/dist/core/composition/nested-status-cel.js.map +1 -1
  6. package/dist/core/expressions/analysis/cache.d.ts.map +1 -1
  7. package/dist/core/expressions/analysis/cache.js +4 -0
  8. package/dist/core/expressions/analysis/cache.js.map +1 -1
  9. package/dist/core/validation/cel-validator.d.ts.map +1 -1
  10. package/dist/core/validation/cel-validator.js +92 -52
  11. package/dist/core/validation/cel-validator.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 +251 -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 +532 -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/package.json +5 -1
@@ -0,0 +1,70 @@
1
+ /**
2
+ * ClickHouse (Altinity clickhouse-operator) Integration for TypeKro
3
+ *
4
+ * Provides type-safe factories for managing ClickHouse clusters on Kubernetes
5
+ * using the OFFICIAL Altinity clickhouse-operator (build-around: the official
6
+ * `altinity-clickhouse-operator` chart from https://helm.altinity.com,
7
+ * Apache-2.0 — never hand-rolled manifests).
8
+ *
9
+ * ONE OPERATOR PER CLUSTER: the operator is cluster-scoped and owns the
10
+ * ClickHouse CRDs; install exactly one `clickhouseOperatorBootstrap` per
11
+ * cluster and point every CHI/CHK at it.
12
+ *
13
+ * BUILD-TIME vs RUNTIME: topology (`zones`/`replicas`/`shards`/keeper
14
+ * presence/user names) is fixed at CONSTRUCTION time via
15
+ * `makeClickHouseCluster(topology)`; everything else (name, namespace,
16
+ * version, storage, credentials, keeper host) is proxy-safe RUNTIME spec.
17
+ *
18
+ * ## Compositions
19
+ * - `makeClickHouseCluster(topology)` — build-time topology constructor;
20
+ * returns a composition whose runtime spec is fully schema-ref safe and
21
+ * whose status exposes the typed connection contract
22
+ * - `clickHouseCluster` — the default single-node topology
23
+ * - `clickhouseOperatorBootstrap` — complete operator deployment
24
+ * (namespace + shared Helm repo singleton + release)
25
+ * - `clickhouseHelmRepositoryBootstrap` — shared HelmRepository singleton owner
26
+ *
27
+ * ## Resources
28
+ * - `clickHouseInstallation()` — LOW-LEVEL typed CHI (concrete topology only;
29
+ * zone-pinned replica layout, SigNoz-compatible `cluster` name default)
30
+ * - `clickHouseKeeperInstallation()` — typed CHK (coordination service)
31
+ * - `clickhouseHelmRepository()` — Altinity Helm chart repository
32
+ * - `clickhouseOperatorHelmRelease()` — operator installation via Helm
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * import {
37
+ * clickhouseOperatorBootstrap,
38
+ * makeClickHouseCluster,
39
+ * } from 'typekro/clickhouse';
40
+ *
41
+ * // Install the operator (once per cluster)
42
+ * const operatorFactory = clickhouseOperatorBootstrap.factory('kro', {
43
+ * namespace: 'clickhouse-system',
44
+ * });
45
+ * await operatorFactory.deploy({ name: 'clickhouse-operator' });
46
+ *
47
+ * // Fix the topology at construction, deploy with runtime spec
48
+ * const clickhouse = makeClickHouseCluster({
49
+ * zones: ['us-east-2a', 'us-east-2b'],
50
+ * replicas: 2,
51
+ * users: [{ name: 'signoz' }],
52
+ * });
53
+ * await clickhouse.factory('kro', { namespace: 'observability' }).deploy({
54
+ * name: 'signoz-clickhouse',
55
+ * namespace: 'observability',
56
+ * version: '25.12.5',
57
+ * storage: { size: '100Gi', storageClassName: 'gp3-expandable' },
58
+ * keeper: { host: 'keeper-signoz.observability.svc.cluster.local' },
59
+ * users: { signoz: { passwordSha256Hex: '<sha256-hex>' } },
60
+ * });
61
+ * ```
62
+ *
63
+ * @see https://github.com/Altinity/clickhouse-operator
64
+ * @module
65
+ */
66
+ export * from './compositions/index.js';
67
+ export * from './resources/index.js';
68
+ export * from './types.js';
69
+ export * from './utils/index.js';
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/factories/clickhouse/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * ClickHouse Operator Helm Resource Factories
3
+ *
4
+ * Wrappers around the generic Helm factories with Altinity-specific defaults.
5
+ * Used by the `clickhouseOperatorBootstrap` composition to install the
6
+ * OFFICIAL Altinity clickhouse-operator (build-around: we wrap the official
7
+ * chart rather than hand-rolling operator manifests).
8
+ *
9
+ * Chart: `altinity-clickhouse-operator` from https://helm.altinity.com
10
+ * (Apache-2.0). The operator is cluster-scoped and owns the ClickHouse CRDs —
11
+ * exactly ONE install per cluster.
12
+ */
13
+ import type { Composable, Enhanced } from '../../../core/types/index.js';
14
+ import { type HelmRepositorySpec, type HelmRepositoryStatus } from '../../helm/helm-repository.js';
15
+ import type { HelmReleaseSpec, HelmReleaseStatus } from '../../helm/types.js';
16
+ import type { ClickHouseHelmRepositoryConfig, ClickHouseOperatorHelmReleaseConfig } from '../types.js';
17
+ /** Official Altinity Helm chart repository URL. */
18
+ export declare const DEFAULT_CLICKHOUSE_REPO_URL = "https://helm.altinity.com";
19
+ /** Default Flux HelmRepository name for the Altinity chart repository. */
20
+ export declare const DEFAULT_CLICKHOUSE_REPO_NAME = "altinity";
21
+ /** Official operator chart name. */
22
+ export declare const CLICKHOUSE_OPERATOR_CHART_NAME = "altinity-clickhouse-operator";
23
+ /** Default altinity-clickhouse-operator chart version. */
24
+ export declare const DEFAULT_CLICKHOUSE_OPERATOR_VERSION = "0.27.1";
25
+ /**
26
+ * Create a Flux HelmRepository for the official Altinity chart repository.
27
+ *
28
+ * @param config - Repository configuration with Altinity defaults
29
+ * @returns Enhanced HelmRepository resource
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const repo = clickhouseHelmRepository({
34
+ * name: 'altinity',
35
+ * namespace: 'flux-system',
36
+ * id: 'clickhouseHelmRepository',
37
+ * });
38
+ * ```
39
+ */
40
+ export declare function clickhouseHelmRepository(config: Composable<ClickHouseHelmRepositoryConfig>): Enhanced<HelmRepositorySpec, HelmRepositoryStatus>;
41
+ /**
42
+ * Create a Flux HelmRelease for the Altinity clickhouse-operator.
43
+ *
44
+ * IMPORTANT: the operator owns the ClickHouse CRDs and watches cluster-wide —
45
+ * install exactly ONE release per cluster (enforced by convention via the
46
+ * `shared` default in `clickhouseOperatorBootstrap`).
47
+ *
48
+ * @param config - Release configuration with Altinity defaults
49
+ * @returns Enhanced HelmRelease resource
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const release = clickhouseOperatorHelmRelease({
54
+ * name: 'clickhouse-operator',
55
+ * namespace: 'clickhouse-system',
56
+ * version: '0.27.1',
57
+ * id: 'clickhouseOperatorHelmRelease',
58
+ * });
59
+ * ```
60
+ */
61
+ export declare function clickhouseOperatorHelmRelease(config: Composable<ClickHouseOperatorHelmReleaseConfig>): Enhanced<HelmReleaseSpec, HelmReleaseStatus>;
62
+ //# sourceMappingURL=helm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helm.d.ts","sourceRoot":"","sources":["../../../../src/factories/clickhouse/resources/helm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,EACV,8BAA8B,EAC9B,mCAAmC,EACpC,MAAM,aAAa,CAAC;AAErB,mDAAmD;AACnD,eAAO,MAAM,2BAA2B,8BAA8B,CAAC;AAEvE,0EAA0E;AAC1E,eAAO,MAAM,4BAA4B,aAAa,CAAC;AAEvD,oCAAoC;AACpC,eAAO,MAAM,8BAA8B,iCAAiC,CAAC;AAE7E,0DAA0D;AAC1D,eAAO,MAAM,mCAAmC,WAAW,CAAC;AAE5D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,UAAU,CAAC,8BAA8B,CAAC,GACjD,QAAQ,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAgBpD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,UAAU,CAAC,mCAAmC,CAAC,GACtD,QAAQ,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAqB9C"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * ClickHouse Operator Helm Resource Factories
3
+ *
4
+ * Wrappers around the generic Helm factories with Altinity-specific defaults.
5
+ * Used by the `clickhouseOperatorBootstrap` composition to install the
6
+ * OFFICIAL Altinity clickhouse-operator (build-around: we wrap the official
7
+ * chart rather than hand-rolling operator manifests).
8
+ *
9
+ * Chart: `altinity-clickhouse-operator` from https://helm.altinity.com
10
+ * (Apache-2.0). The operator is cluster-scoped and owns the ClickHouse CRDs —
11
+ * exactly ONE install per cluster.
12
+ */
13
+ import { DEFAULT_FLUX_NAMESPACE } from '../../../core/config/defaults.js';
14
+ import { setMetadataField } from '../../../core/metadata/resource-metadata.js';
15
+ import { helmRelease } from '../../helm/helm-release.js';
16
+ import { createHelmRepositoryReadinessEvaluator, helmRepository, } from '../../helm/helm-repository.js';
17
+ import { createLabeledHelmReleaseEvaluator } from '../../helm/readiness-evaluators.js';
18
+ /** Official Altinity Helm chart repository URL. */
19
+ export const DEFAULT_CLICKHOUSE_REPO_URL = 'https://helm.altinity.com';
20
+ /** Default Flux HelmRepository name for the Altinity chart repository. */
21
+ export const DEFAULT_CLICKHOUSE_REPO_NAME = 'altinity';
22
+ /** Official operator chart name. */
23
+ export const CLICKHOUSE_OPERATOR_CHART_NAME = 'altinity-clickhouse-operator';
24
+ /** Default altinity-clickhouse-operator chart version. */
25
+ export const DEFAULT_CLICKHOUSE_OPERATOR_VERSION = '0.27.1';
26
+ /**
27
+ * Create a Flux HelmRepository for the official Altinity chart repository.
28
+ *
29
+ * @param config - Repository configuration with Altinity defaults
30
+ * @returns Enhanced HelmRepository resource
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const repo = clickhouseHelmRepository({
35
+ * name: 'altinity',
36
+ * namespace: 'flux-system',
37
+ * id: 'clickhouseHelmRepository',
38
+ * });
39
+ * ```
40
+ */
41
+ export function clickhouseHelmRepository(config) {
42
+ const repo = helmRepository({
43
+ name: config.name || DEFAULT_CLICKHOUSE_REPO_NAME,
44
+ namespace: config.namespace || DEFAULT_FLUX_NAMESPACE,
45
+ url: config.url || DEFAULT_CLICKHOUSE_REPO_URL,
46
+ interval: config.interval || '5m',
47
+ ...(config.id && { id: config.id }),
48
+ }).withReadinessEvaluator(createHelmRepositoryReadinessEvaluator('ClickHouse'));
49
+ // The chart repository is one cluster-level Flux source shared by every
50
+ // consumer — never torn down with an individual instance.
51
+ setMetadataField(repo, 'scopes', ['cluster']);
52
+ return repo;
53
+ }
54
+ /**
55
+ * Create a Flux HelmRelease for the Altinity clickhouse-operator.
56
+ *
57
+ * IMPORTANT: the operator owns the ClickHouse CRDs and watches cluster-wide —
58
+ * install exactly ONE release per cluster (enforced by convention via the
59
+ * `shared` default in `clickhouseOperatorBootstrap`).
60
+ *
61
+ * @param config - Release configuration with Altinity defaults
62
+ * @returns Enhanced HelmRelease resource
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const release = clickhouseOperatorHelmRelease({
67
+ * name: 'clickhouse-operator',
68
+ * namespace: 'clickhouse-system',
69
+ * version: '0.27.1',
70
+ * id: 'clickhouseOperatorHelmRelease',
71
+ * });
72
+ * ```
73
+ */
74
+ export function clickhouseOperatorHelmRelease(config) {
75
+ // Pass values directly — the core proxy system handles serialization.
76
+ return helmRelease({
77
+ name: config.name,
78
+ namespace: config.namespace || 'clickhouse-system',
79
+ chart: {
80
+ repository: DEFAULT_CLICKHOUSE_REPO_URL,
81
+ name: CLICKHOUSE_OPERATOR_CHART_NAME,
82
+ version: config.version || DEFAULT_CLICKHOUSE_OPERATOR_VERSION,
83
+ },
84
+ sourceRef: {
85
+ name: config.repositoryName || DEFAULT_CLICKHOUSE_REPO_NAME,
86
+ namespace: DEFAULT_FLUX_NAMESPACE,
87
+ kind: 'HelmRepository',
88
+ },
89
+ driftDetection: { mode: 'enabled' },
90
+ values: config.values || {},
91
+ ...(config.id && { id: config.id }),
92
+ }).withReadinessEvaluator(createLabeledHelmReleaseEvaluator('ClickHouse'));
93
+ }
94
+ //# sourceMappingURL=helm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helm.js","sourceRoot":"","sources":["../../../../src/factories/clickhouse/resources/helm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EACL,sCAAsC,EACtC,cAAc,GAGf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AAOvF,mDAAmD;AACnD,MAAM,CAAC,MAAM,2BAA2B,GAAG,2BAA2B,CAAC;AAEvE,0EAA0E;AAC1E,MAAM,CAAC,MAAM,4BAA4B,GAAG,UAAU,CAAC;AAEvD,oCAAoC;AACpC,MAAM,CAAC,MAAM,8BAA8B,GAAG,8BAA8B,CAAC;AAE7E,0DAA0D;AAC1D,MAAM,CAAC,MAAM,mCAAmC,GAAG,QAAQ,CAAC;AAE5D;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAkD;IAElD,MAAM,IAAI,GAAG,cAAc,CAAC;QAC1B,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,4BAA4B;QACjD,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,sBAAsB;QACrD,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,2BAA2B;QAC9C,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;QACjC,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;KACpC,CAAC,CAAC,sBAAsB,CACvB,sCAAsC,CAAC,YAAY,CAAC,CACC,CAAC;IAExD,wEAAwE;IACxE,0DAA0D;IAC1D,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAE9C,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,6BAA6B,CAC3C,MAAuD;IAEvD,sEAAsE;IACtE,OAAO,WAAW,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,mBAAmB;QAClD,KAAK,EAAE;YACL,UAAU,EAAE,2BAA2B;YACvC,IAAI,EAAE,8BAA8B;YACpC,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,mCAAmC;SAC/D;QACD,SAAS,EAAE;YACT,IAAI,EAAE,MAAM,CAAC,cAAc,IAAI,4BAA4B;YAC3D,SAAS,EAAE,sBAAsB;YACjC,IAAI,EAAE,gBAAgB;SACvB;QACD,cAAc,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QACnC,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;QAC3B,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;KACpC,CAAC,CAAC,sBAAsB,CACvB,iCAAiC,CAAC,YAAY,CAAC,CACA,CAAC;AACpD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './helm.js';
2
+ export * from './installation.js';
3
+ export * from './keeper.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/factories/clickhouse/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './helm.js';
2
+ export * from './installation.js';
3
+ export * from './keeper.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/factories/clickhouse/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * ClickHouseInstallation (CHI) Factory
3
+ *
4
+ * Compiles a high-level typed config into a `clickhouse.altinity.com/v1`
5
+ * ClickHouseInstallation managed by the Altinity clickhouse-operator.
6
+ *
7
+ * THE POINT of this typed factory is the zone-pinned layout: the operator's
8
+ * `podDistribution` supports only the `kubernetes.io/hostname` topologyKey
9
+ * (Altinity/clickhouse-operator#772), so per-zone spreading must be compiled
10
+ * as a per-replica `layout.replicas:` list with zone-pinned pod templates.
11
+ * On EKS, EBS volumes are zonal — a replica rescheduled into another AZ
12
+ * strands its PVC (production incident) — so `zones` should be set for any
13
+ * multi-replica production CHI.
14
+ *
15
+ * CHI shape follows the official examples
16
+ * (docs/chi-examples/01-simple-layout-01-1shard-1repl.yaml and
17
+ * 14-zones-distribution-01.yaml in the operator repo).
18
+ */
19
+ import type { Composable, Enhanced, ResourceStatus } from '../../../core/types/index.js';
20
+ import type { ClickHouseInstallationConfig, ClickHouseInstallationSpec, ClickHouseInstallationStatus } from '../types.js';
21
+ /**
22
+ * Known CHI/CHK reconcile status strings.
23
+ *
24
+ * Source: clickhouse-operator `pkg/apis/clickhouse.altinity.com/v1/type_status.go`
25
+ * (StatusInProgress/StatusCompleted/StatusAborted/StatusTerminating). The
26
+ * operator writes them to `status.status`; `Completed` means the installation
27
+ * is fully reconciled.
28
+ */
29
+ export declare const CHI_STATUS: {
30
+ readonly IN_PROGRESS: "InProgress";
31
+ readonly COMPLETED: "Completed";
32
+ readonly ABORTED: "Aborted";
33
+ readonly TERMINATING: "Terminating";
34
+ };
35
+ /**
36
+ * CHI/CHK Readiness Evaluator
37
+ *
38
+ * Keys off the operator-reported `status.status` reconcile state (see
39
+ * CHI_STATUS). Unlike condition-based CRDs, the clickhouse-operator reports a
40
+ * single status string plus host progress counters.
41
+ */
42
+ export declare function chiReadinessEvaluator(liveResource: unknown): ResourceStatus;
43
+ /**
44
+ * Default logical cluster name.
45
+ *
46
+ * SIGNOZ COMPATIBILITY: SigNoz's ClickHouse migrations hardcode the cluster
47
+ * name `cluster`, so a CHI consumed by SigNoz MUST keep this default.
48
+ */
49
+ export declare const DEFAULT_CHI_CLUSTER_NAME = "cluster";
50
+ /**
51
+ * ClickHouseInstallation Factory (LOW-LEVEL, concrete topology)
52
+ *
53
+ * Creates a ClickHouse cluster managed by the Altinity clickhouse-operator.
54
+ *
55
+ * BUILD-TIME topology fields (`shards`, `replicas`, `zones`, user names) must
56
+ * be concrete JS values — the factory throws loudly if any receives a schema
57
+ * reference (the compiler enumerates templates/replica entries from them).
58
+ * Prefer `makeClickHouseCluster()` in compositions: it fixes the topology at
59
+ * construction time and exposes only proxy-safe runtime spec.
60
+ *
61
+ * @param config - High-level installation configuration
62
+ * @returns Enhanced ClickHouseInstallation resource with readiness evaluation
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const chi = clickHouseInstallation({
67
+ * name: 'signoz-clickhouse',
68
+ * namespace: 'observability',
69
+ * version: '25.12.5', // SigNoz-coupled server version
70
+ * shards: 1,
71
+ * replicas: 2,
72
+ * zones: ['us-east-2a', 'us-east-2b'], // zone-pinned replicas (EBS is zonal)
73
+ * storage: { size: '100Gi', storageClassName: 'gp3-expandable' },
74
+ * users: [{ name: 'signoz', passwordSha256Hex: '...', networksIp: ['::/0'] }],
75
+ * keeper: { host: 'keeper-signoz.observability.svc.cluster.local' },
76
+ * id: 'signozClickhouse',
77
+ * });
78
+ * ```
79
+ */
80
+ declare function createClickHouseInstallationResource(config: Composable<ClickHouseInstallationConfig>): Enhanced<ClickHouseInstallationSpec, ClickHouseInstallationStatus>;
81
+ export declare const clickHouseInstallation: typeof createClickHouseInstallationResource;
82
+ export {};
83
+ //# sourceMappingURL=installation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installation.d.ts","sourceRoot":"","sources":["../../../../src/factories/clickhouse/resources/installation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGzF,OAAO,KAAK,EAEV,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,aAAa,CAAC;AAIrB;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU;;;;;CAKb,CAAC;AAEX;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,OAAO,GAAG,cAAc,CAoD3E;AAKD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,YAAY,CAAC;AA6LlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,iBAAS,oCAAoC,CAC3C,MAAM,EAAE,UAAU,CAAC,4BAA4B,CAAC,GAC/C,QAAQ,CAAC,0BAA0B,EAAE,4BAA4B,CAAC,CAmBpE;AAED,eAAO,MAAM,sBAAsB,6CAAuC,CAAC"}
@@ -0,0 +1,316 @@
1
+ /**
2
+ * ClickHouseInstallation (CHI) Factory
3
+ *
4
+ * Compiles a high-level typed config into a `clickhouse.altinity.com/v1`
5
+ * ClickHouseInstallation managed by the Altinity clickhouse-operator.
6
+ *
7
+ * THE POINT of this typed factory is the zone-pinned layout: the operator's
8
+ * `podDistribution` supports only the `kubernetes.io/hostname` topologyKey
9
+ * (Altinity/clickhouse-operator#772), so per-zone spreading must be compiled
10
+ * as a per-replica `layout.replicas:` list with zone-pinned pod templates.
11
+ * On EKS, EBS volumes are zonal — a replica rescheduled into another AZ
12
+ * strands its PVC (production incident) — so `zones` should be set for any
13
+ * multi-replica production CHI.
14
+ *
15
+ * CHI shape follows the official examples
16
+ * (docs/chi-examples/01-simple-layout-01-1shard-1repl.yaml and
17
+ * 14-zones-distribution-01.yaml in the operator repo).
18
+ */
19
+ import { isCelExpression, isKubernetesRef } from '../../../utils/type-guards.js';
20
+ import { createResource } from '../../shared.js';
21
+ import { assertPositiveIntegerCount } from '../utils/validation.js';
22
+ import { compileZonePinnedLayout } from '../utils/zone-layout.js';
23
+ /**
24
+ * Known CHI/CHK reconcile status strings.
25
+ *
26
+ * Source: clickhouse-operator `pkg/apis/clickhouse.altinity.com/v1/type_status.go`
27
+ * (StatusInProgress/StatusCompleted/StatusAborted/StatusTerminating). The
28
+ * operator writes them to `status.status`; `Completed` means the installation
29
+ * is fully reconciled.
30
+ */
31
+ export const CHI_STATUS = {
32
+ IN_PROGRESS: 'InProgress',
33
+ COMPLETED: 'Completed',
34
+ ABORTED: 'Aborted',
35
+ TERMINATING: 'Terminating',
36
+ };
37
+ /**
38
+ * CHI/CHK Readiness Evaluator
39
+ *
40
+ * Keys off the operator-reported `status.status` reconcile state (see
41
+ * CHI_STATUS). Unlike condition-based CRDs, the clickhouse-operator reports a
42
+ * single status string plus host progress counters.
43
+ */
44
+ export function chiReadinessEvaluator(liveResource) {
45
+ const resource = liveResource;
46
+ const status = resource?.status;
47
+ if (!status || status.status === undefined) {
48
+ return {
49
+ ready: false,
50
+ message: 'Installation has no status yet',
51
+ reason: 'StatusMissing',
52
+ };
53
+ }
54
+ if (status.status === CHI_STATUS.COMPLETED) {
55
+ return {
56
+ ready: true,
57
+ message: `Installation reconciled (${status.hostsCompletedCount ?? status.hostsCount ?? 0}/${status.hostsCount ?? 0} hosts)`,
58
+ reason: 'Completed',
59
+ };
60
+ }
61
+ if (status.status === CHI_STATUS.IN_PROGRESS) {
62
+ return {
63
+ ready: false,
64
+ message: `Reconcile in progress (${status.hostsCompletedCount ?? 0}/${status.hostsCount ?? 0} hosts)`,
65
+ reason: 'InProgress',
66
+ };
67
+ }
68
+ if (status.status === CHI_STATUS.ABORTED) {
69
+ return {
70
+ ready: false,
71
+ message: `Reconcile aborted${status.errors?.length ? `: ${status.errors[0]}` : ''}`,
72
+ reason: 'Aborted',
73
+ };
74
+ }
75
+ if (status.status === CHI_STATUS.TERMINATING) {
76
+ return {
77
+ ready: false,
78
+ message: 'Installation is terminating',
79
+ reason: 'Terminating',
80
+ };
81
+ }
82
+ return {
83
+ ready: false,
84
+ message: `Unknown installation status: ${status.status}`,
85
+ reason: 'UnknownStatus',
86
+ };
87
+ }
88
+ /** Default ClickHouse server image repository. */
89
+ const DEFAULT_CLICKHOUSE_IMAGE_REPOSITORY = 'clickhouse/clickhouse-server';
90
+ /**
91
+ * Default logical cluster name.
92
+ *
93
+ * SIGNOZ COMPATIBILITY: SigNoz's ClickHouse migrations hardcode the cluster
94
+ * name `cluster`, so a CHI consumed by SigNoz MUST keep this default.
95
+ */
96
+ export const DEFAULT_CHI_CLUSTER_NAME = 'cluster';
97
+ /** Name of the generated data volume claim template. */
98
+ const DATA_VOLUME_TEMPLATE = 'data-volume';
99
+ /** Base name for generated pod templates. */
100
+ const POD_TEMPLATE_BASE = 'clickhouse';
101
+ /** True when the value is a graph reference (KubernetesRef or CEL expression). */
102
+ function isGraphRef(value) {
103
+ return isKubernetesRef(value) || isCelExpression(value);
104
+ }
105
+ /**
106
+ * LOUD build-time validation: the CHI compiler BRANCHES on these fields
107
+ * (zone round-robin, template enumeration, path-keyed user settings), so a
108
+ * KubernetesRef/CEL expression here can never work — it would either crash
109
+ * graph construction or serialize garbage paths. Fail fast with a pointer to
110
+ * the build-time constructor instead of leaking `__KUBERNETES_REF__` markers.
111
+ */
112
+ function assertConcreteTopology(config) {
113
+ const reject = (field) => {
114
+ throw new Error(`clickHouseInstallation: '${field}' is a BUILD-TIME topology field and received a ` +
115
+ `schema reference or CEL expression. The compiler enumerates pod templates and ` +
116
+ `per-replica layout entries from it, so it must be a concrete JS value. ` +
117
+ `For schema-driven compositions, fix the topology at construction time with ` +
118
+ `makeClickHouseCluster({ zones, replicas, shards, users }) and pass only runtime ` +
119
+ `fields (name, version, storage, credentials, keeper host) through the spec.`);
120
+ };
121
+ if (isGraphRef(config.shards))
122
+ reject('shards');
123
+ if (isGraphRef(config.replicas))
124
+ reject('replicas');
125
+ if (isGraphRef(config.zones))
126
+ reject('zones');
127
+ if (Array.isArray(config.zones)) {
128
+ for (const zone of config.zones) {
129
+ if (isGraphRef(zone))
130
+ reject('zones[]');
131
+ }
132
+ }
133
+ if (isGraphRef(config.users))
134
+ reject('users');
135
+ if (Array.isArray(config.users)) {
136
+ config.users.forEach((user, index) => {
137
+ if (isGraphRef(user))
138
+ reject(`users[${index}]`);
139
+ if (isGraphRef(user.name))
140
+ reject(`users[${index}].name`);
141
+ });
142
+ }
143
+ }
144
+ /**
145
+ * Flatten the typed users ARRAY to the operator's path-keyed format.
146
+ *
147
+ * User names become path fragments (`<user>/password_sha256_hex`) — they are
148
+ * validated concrete by `assertConcreteTopology`. The password hash and
149
+ * networks are plain VALUES and may be schema references (they serialize to
150
+ * CEL cleanly).
151
+ */
152
+ function compileUsers(users) {
153
+ const compiled = {};
154
+ for (const user of users) {
155
+ if (user.passwordSha256Hex !== undefined) {
156
+ compiled[`${user.name}/password_sha256_hex`] = user.passwordSha256Hex;
157
+ }
158
+ if (user.networksIp !== undefined) {
159
+ compiled[`${user.name}/networks/ip`] = user.networksIp;
160
+ }
161
+ }
162
+ return compiled;
163
+ }
164
+ /** Compile the high-level config into a full CHI spec. */
165
+ function compileInstallationSpec(config) {
166
+ assertConcreteTopology(config);
167
+ const shards = config.shards ?? 1;
168
+ const replicas = config.replicas ?? 1;
169
+ // SHARED count validation for BOTH layout paths: the plain homogeneous
170
+ // layout would otherwise emit `shardsCount: 0` / `replicasCount: 0` —
171
+ // invalid operator input the zone-pinned path already rejected.
172
+ assertPositiveIntegerCount('clickHouseInstallation', 'shards', shards);
173
+ assertPositiveIntegerCount('clickHouseInstallation', 'replicas', replicas);
174
+ const clusterName = config.clusterName ?? DEFAULT_CHI_CLUSTER_NAME;
175
+ const image = config.image ?? `${DEFAULT_CLICKHOUSE_IMAGE_REPOSITORY}:${config.version}`;
176
+ const zones = config.zones ?? [];
177
+ // Shared ClickHouse server pod spec (per-zone templates add affinity).
178
+ const podSpec = {
179
+ containers: [
180
+ {
181
+ name: 'clickhouse',
182
+ image,
183
+ ...(config.podResources && { resources: config.podResources }),
184
+ },
185
+ ],
186
+ };
187
+ // Storage claim: only storageClassName is set from input. On EKS the class
188
+ // should be a WaitForFirstConsumer + allowVolumeExpansion gp3 StorageClass
189
+ // so the PVC binds in the zone the scheduler picks (and can expand later);
190
+ // WaitForFirstConsumer is a StorageClass property, not a PVC field.
191
+ const volumeClaimTemplates = [
192
+ {
193
+ name: DATA_VOLUME_TEMPLATE,
194
+ spec: {
195
+ accessModes: ['ReadWriteOnce'],
196
+ resources: { requests: { storage: config.storage.size } },
197
+ ...(config.storage.storageClassName && {
198
+ storageClassName: config.storage.storageClassName,
199
+ }),
200
+ },
201
+ },
202
+ ];
203
+ let layout;
204
+ let podTemplates;
205
+ let defaultPodTemplate;
206
+ if (zones.length > 0) {
207
+ // Zone-pinned per-replica layout: NO replicasCount — the explicit
208
+ // replicas list defines the replica count, and each replica references
209
+ // its zone's nodeAffinity-pinned pod template (round-robin across zones
210
+ // when replicas > zones.length). See utils/zone-layout.ts.
211
+ const zonePinned = compileZonePinnedLayout({
212
+ replicaCount: replicas,
213
+ zones,
214
+ podTemplateBaseName: POD_TEMPLATE_BASE,
215
+ podSpec,
216
+ });
217
+ podTemplates = zonePinned.podTemplates;
218
+ layout = {
219
+ clusters: [
220
+ {
221
+ name: clusterName,
222
+ layout: {
223
+ shardsCount: shards,
224
+ replicas: zonePinned.replicas,
225
+ },
226
+ },
227
+ ],
228
+ };
229
+ }
230
+ else {
231
+ // Plain homogeneous layout: shardsCount x replicasCount with one shared
232
+ // pod template applied via defaults.
233
+ podTemplates = [{ name: POD_TEMPLATE_BASE, spec: podSpec }];
234
+ defaultPodTemplate = POD_TEMPLATE_BASE;
235
+ layout = {
236
+ clusters: [
237
+ {
238
+ name: clusterName,
239
+ layout: {
240
+ shardsCount: shards,
241
+ replicasCount: replicas,
242
+ },
243
+ },
244
+ ],
245
+ };
246
+ }
247
+ return {
248
+ defaults: {
249
+ templates: {
250
+ ...(defaultPodTemplate && { podTemplate: defaultPodTemplate }),
251
+ dataVolumeClaimTemplate: DATA_VOLUME_TEMPLATE,
252
+ },
253
+ },
254
+ configuration: {
255
+ ...layout,
256
+ // The operator's `zookeeper` section serves clickhouse-keeper too.
257
+ ...(config.keeper && {
258
+ zookeeper: {
259
+ nodes: [
260
+ { host: config.keeper.host, port: config.keeper.port ?? 2181 },
261
+ ],
262
+ },
263
+ }),
264
+ ...(config.users && { users: compileUsers(config.users) }),
265
+ },
266
+ templates: {
267
+ podTemplates,
268
+ volumeClaimTemplates,
269
+ },
270
+ };
271
+ }
272
+ /**
273
+ * ClickHouseInstallation Factory (LOW-LEVEL, concrete topology)
274
+ *
275
+ * Creates a ClickHouse cluster managed by the Altinity clickhouse-operator.
276
+ *
277
+ * BUILD-TIME topology fields (`shards`, `replicas`, `zones`, user names) must
278
+ * be concrete JS values — the factory throws loudly if any receives a schema
279
+ * reference (the compiler enumerates templates/replica entries from them).
280
+ * Prefer `makeClickHouseCluster()` in compositions: it fixes the topology at
281
+ * construction time and exposes only proxy-safe runtime spec.
282
+ *
283
+ * @param config - High-level installation configuration
284
+ * @returns Enhanced ClickHouseInstallation resource with readiness evaluation
285
+ *
286
+ * @example
287
+ * ```typescript
288
+ * const chi = clickHouseInstallation({
289
+ * name: 'signoz-clickhouse',
290
+ * namespace: 'observability',
291
+ * version: '25.12.5', // SigNoz-coupled server version
292
+ * shards: 1,
293
+ * replicas: 2,
294
+ * zones: ['us-east-2a', 'us-east-2b'], // zone-pinned replicas (EBS is zonal)
295
+ * storage: { size: '100Gi', storageClassName: 'gp3-expandable' },
296
+ * users: [{ name: 'signoz', passwordSha256Hex: '...', networksIp: ['::/0'] }],
297
+ * keeper: { host: 'keeper-signoz.observability.svc.cluster.local' },
298
+ * id: 'signozClickhouse',
299
+ * });
300
+ * ```
301
+ */
302
+ function createClickHouseInstallationResource(config) {
303
+ const spec = compileInstallationSpec(config);
304
+ return createResource({
305
+ apiVersion: 'clickhouse.altinity.com/v1',
306
+ kind: 'ClickHouseInstallation',
307
+ metadata: {
308
+ name: config.name,
309
+ ...(config.namespace && { namespace: config.namespace }),
310
+ },
311
+ spec,
312
+ ...(config.id && { id: config.id }),
313
+ }, { scope: 'namespaced', dnsAddressable: true }).withReadinessEvaluator(chiReadinessEvaluator);
314
+ }
315
+ export const clickHouseInstallation = createClickHouseInstallationResource;
316
+ //# sourceMappingURL=installation.js.map