typekro 0.14.0 → 0.15.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 (79) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/alchemy/deployers.d.ts +2 -2
  3. package/dist/alchemy/deployers.d.ts.map +1 -1
  4. package/dist/alchemy/deployers.js +12 -5
  5. package/dist/alchemy/deployers.js.map +1 -1
  6. package/dist/alchemy/index.d.ts +4 -2
  7. package/dist/alchemy/index.d.ts.map +1 -1
  8. package/dist/alchemy/index.js +4 -3
  9. package/dist/alchemy/index.js.map +1 -1
  10. package/dist/alchemy/resource-registration.d.ts +81 -19
  11. package/dist/alchemy/resource-registration.d.ts.map +1 -1
  12. package/dist/alchemy/resource-registration.js +296 -147
  13. package/dist/alchemy/resource-registration.js.map +1 -1
  14. package/dist/alchemy/types.d.ts +76 -8
  15. package/dist/alchemy/types.d.ts.map +1 -1
  16. package/dist/alchemy/wrapper.d.ts +0 -9
  17. package/dist/alchemy/wrapper.d.ts.map +1 -1
  18. package/dist/alchemy/wrapper.js +0 -15
  19. package/dist/alchemy/wrapper.js.map +1 -1
  20. package/dist/core/deployment/direct-factory.d.ts +14 -2
  21. package/dist/core/deployment/direct-factory.d.ts.map +1 -1
  22. package/dist/core/deployment/direct-factory.js +117 -14
  23. package/dist/core/deployment/direct-factory.js.map +1 -1
  24. package/dist/core/deployment/engine.d.ts +8 -5
  25. package/dist/core/deployment/engine.d.ts.map +1 -1
  26. package/dist/core/deployment/engine.js +36 -12
  27. package/dist/core/deployment/engine.js.map +1 -1
  28. package/dist/core/deployment/kro-factory.d.ts +35 -9
  29. package/dist/core/deployment/kro-factory.d.ts.map +1 -1
  30. package/dist/core/deployment/kro-factory.js +143 -151
  31. package/dist/core/deployment/kro-factory.js.map +1 -1
  32. package/dist/core/deployment/shared-utilities.d.ts +15 -4
  33. package/dist/core/deployment/shared-utilities.d.ts.map +1 -1
  34. package/dist/core/deployment/shared-utilities.js +47 -14
  35. package/dist/core/deployment/shared-utilities.js.map +1 -1
  36. package/dist/core/deployment/strategies/direct-strategy.d.ts.map +1 -1
  37. package/dist/core/deployment/strategies/direct-strategy.js +1 -2
  38. package/dist/core/deployment/strategies/direct-strategy.js.map +1 -1
  39. package/dist/core/deployment/strategies/index.d.ts +0 -1
  40. package/dist/core/deployment/strategies/index.d.ts.map +1 -1
  41. package/dist/core/deployment/strategies/index.js +0 -1
  42. package/dist/core/deployment/strategies/index.js.map +1 -1
  43. package/dist/core/expressions/composition/composition-analyzer-helpers.d.ts +0 -13
  44. package/dist/core/expressions/composition/composition-analyzer-helpers.d.ts.map +1 -1
  45. package/dist/core/expressions/composition/composition-analyzer-helpers.js +78 -1
  46. package/dist/core/expressions/composition/composition-analyzer-helpers.js.map +1 -1
  47. package/dist/core/expressions/composition/imperative-analyzer.d.ts.map +1 -1
  48. package/dist/core/expressions/composition/imperative-analyzer.js +34 -1
  49. package/dist/core/expressions/composition/imperative-analyzer.js.map +1 -1
  50. package/dist/core/serialization/cel-references.d.ts +1 -1
  51. package/dist/core/serialization/cel-references.d.ts.map +1 -1
  52. package/dist/core/serialization/cel-references.js +19 -3
  53. package/dist/core/serialization/cel-references.js.map +1 -1
  54. package/dist/core/serialization/core.d.ts.map +1 -1
  55. package/dist/core/serialization/core.js +19 -4
  56. package/dist/core/serialization/core.js.map +1 -1
  57. package/dist/core/types/deployment.d.ts +28 -42
  58. package/dist/core/types/deployment.d.ts.map +1 -1
  59. package/dist/core/types/resource-graph.d.ts +2 -6
  60. package/dist/core/types/resource-graph.d.ts.map +1 -1
  61. package/dist/core/types/schema.d.ts +0 -1
  62. package/dist/core/types/schema.d.ts.map +1 -1
  63. package/dist/core/types/serialization.d.ts +3 -7
  64. package/dist/core/types/serialization.d.ts.map +1 -1
  65. package/dist/factories/kubernetes/yaml/yaml-directory.d.ts.map +1 -1
  66. package/dist/factories/kubernetes/yaml/yaml-directory.js +2 -13
  67. package/dist/factories/kubernetes/yaml/yaml-directory.js.map +1 -1
  68. package/dist/factories/kubernetes/yaml/yaml-file.d.ts.map +1 -1
  69. package/dist/factories/kubernetes/yaml/yaml-file.js +2 -18
  70. package/dist/factories/kubernetes/yaml/yaml-file.js.map +1 -1
  71. package/package.json +6 -3
  72. package/dist/alchemy/deployment.d.ts +0 -12
  73. package/dist/alchemy/deployment.d.ts.map +0 -1
  74. package/dist/alchemy/deployment.js +0 -12
  75. package/dist/alchemy/deployment.js.map +0 -1
  76. package/dist/core/deployment/strategies/alchemy-strategy.d.ts +0 -109
  77. package/dist/core/deployment/strategies/alchemy-strategy.d.ts.map +0 -1
  78. package/dist/core/deployment/strategies/alchemy-strategy.js +0 -556
  79. package/dist/core/deployment/strategies/alchemy-strategy.js.map +0 -1
@@ -4,9 +4,8 @@
4
4
  * This module provides type definitions for alchemy integration
5
5
  * with TypeKro resources.
6
6
  */
7
- import type { Resource as AlchemyResource } from 'alchemy';
8
7
  import type { KubernetesClientConfig } from '../core/kubernetes/client-provider.js';
9
- import type { DeploymentOptions } from '../core/types/deployment.js';
8
+ import type { DeployedResource, DeploymentOptions } from '../core/types/deployment.js';
10
9
  import type { Enhanced } from '../core/types/kubernetes.js';
11
10
  import type { KroDeletionOptions } from './kro-delete.js';
12
11
  /**
@@ -14,9 +13,11 @@ import type { KroDeletionOptions } from './kro-delete.js';
14
13
  */
15
14
  export interface TypeKroDeployer {
16
15
  /**
17
- * Deploy a TypeKro resource to Kubernetes
16
+ * Deploy a TypeKro resource to Kubernetes. `seedResources` (direct mode) supplies the live state
17
+ * of resources deployed elsewhere (e.g. sibling alchemy resources) so this resource's
18
+ * cross-resource references/CEL resolve without redeploying them.
18
19
  */
19
- deploy<T extends Enhanced<any, any>>(resource: T, options: DeploymentOptions): Promise<T>;
20
+ deploy<T extends Enhanced<any, any>>(resource: T, options: DeploymentOptions, seedResources?: DeployedResource[]): Promise<T>;
20
21
  /**
21
22
  * Delete a TypeKro resource from Kubernetes
22
23
  */
@@ -46,18 +47,67 @@ export interface TypeKroResourceProps<T extends Enhanced<any, any>> {
46
47
  */
47
48
  deploymentStrategy: 'direct' | 'kro';
48
49
  /**
49
- * Serializable kubeConfig options
50
+ * The resource's logical id within its composition graph (e.g. `webappDeployment`) — the id
51
+ * sibling resources' `KubernetesRef`s point at. Surfaced on the output so dependents can seed
52
+ * reference resolution against this resource's live state. Set by `toAlchemyResources`.
53
+ */
54
+ resourceId?: string;
55
+ /**
56
+ * Serializable kubeConfig options used to reach the cluster (and to reconnect on a rehydrated
57
+ * delete). Echoed onto the output so a state-driven delete works.
58
+ *
59
+ * ⚠️ SECURITY: alchemy persists props + output to its state store, so these options are written
60
+ * to state. If they carry static secrets — `user.token` / `user.certData` / `user.keyData` — those
61
+ * land in state (e.g. plaintext for the local/HTTP stores). Prefer re-derived auth (`user.exec`
62
+ * such as `aws eks get-token`, or `authProvider`), which is a command spec rather than a secret,
63
+ * and use a secured state backend. See {@link extractSerializableKubeConfigOptions}.
50
64
  */
51
65
  kubeConfigOptions?: SerializableKubeConfigOptions;
52
66
  /** Optional preconfigured deployer. Runtime-only; do not rely on this surviving Alchemy rehydration. */
53
67
  deployer?: TypeKroDeployer;
54
68
  /** Serializable metadata used to preserve finalizer-safe KRO teardown after Alchemy rehydration. */
55
69
  kroDeletion?: KroDeletionOptions;
70
+ /**
71
+ * Resolved outputs of the resources this one depends on. Two jobs:
72
+ *
73
+ * 1. **Ordering** — because each entry traces back (via an alchemy `Output`) to another
74
+ * resource, alchemy deploys those first. KRO uses this so the CR instance waits for its
75
+ * RGD's CRD; direct mode uses it to honor the composition's dependency graph.
76
+ * 2. **Reference resolution (direct mode)** — each entry's `deployedResource` is the live
77
+ * dependency, so the reconcile can resolve this resource's cross-resource `KubernetesRef`s
78
+ * against already-deployed siblings before applying the (now concrete) single manifest.
79
+ *
80
+ * Populated by {@link AlchemyResourceDeclaration} + the `materializeAlchemyResources` helper,
81
+ * not by hand. By the time `reconcile` runs, alchemy has resolved these to concrete values.
82
+ */
83
+ dependencies?: TypeKroResource<Enhanced<unknown, unknown>>[];
56
84
  /**
57
85
  * Optional deployment options
58
86
  */
59
87
  options?: Partial<Omit<DeploymentOptions, 'mode' | 'namespace'>>;
60
88
  }
89
+ /**
90
+ * A single declarative alchemy v2 resource to instantiate: a stable `id` plus the
91
+ * `props` to pass to `KroResource`. Produced by a factory's `toAlchemyResources(spec)`
92
+ * (the v2 analog of the removed imperative `deployWithAlchemy`) so callers can fan a
93
+ * KRO factory out into its independent state entries (the RGD + each CR instance):
94
+ *
95
+ * ```ts
96
+ * for (const { id, props } of await factory.toAlchemyResources(spec)) {
97
+ * yield* KroResource(id, props);
98
+ * }
99
+ * ```
100
+ */
101
+ export interface AlchemyResourceDeclaration {
102
+ readonly id: string;
103
+ readonly props: TypeKroResourceProps<Enhanced<unknown, unknown>>;
104
+ /**
105
+ * Ids of the other declarations (in the same array) this one must deploy after. The
106
+ * declarations are returned topologically sorted, and `materializeAlchemyResources` turns
107
+ * these into alchemy `Output` dependencies (ordering + direct-mode reference resolution).
108
+ */
109
+ readonly dependsOn: readonly string[];
110
+ }
61
111
  /**
62
112
  * Alchemy resource state structure
63
113
  */
@@ -68,18 +118,36 @@ export interface AlchemyResourceState {
68
118
  [key: string]: unknown;
69
119
  }
70
120
  /**
71
- * Output returned after TypeKro resource deployment through alchemy
72
- * Following alchemy pattern: interface name matches exported resource name
121
+ * Output returned after TypeKro resource deployment through alchemy.
122
+ *
123
+ * Under alchemy v2 a resource's output is a plain, serializable shape (the value
124
+ * `reconcile` returns and alchemy persists to state) — not an extension of a
125
+ * framework `Resource` type as it was under v1.
73
126
  */
74
- export interface TypeKroResource<T extends Enhanced<any, any>> extends AlchemyResource<string> {
127
+ export interface TypeKroResource<T extends Enhanced<any, any>> {
75
128
  /**
76
129
  * The original TypeKro resource
77
130
  */
78
131
  resource: T;
132
+ /**
133
+ * The resource's logical composition-graph id (mirrors {@link TypeKroResourceProps.resourceId}).
134
+ * Lets a dependent reconcile match this resource against its `KubernetesRef`s when seeding
135
+ * direct-mode reference resolution. Undefined for resources not produced via `toAlchemyResources`.
136
+ */
137
+ resourceId?: string;
79
138
  /**
80
139
  * The namespace the resource was deployed to
81
140
  */
82
141
  namespace: string;
142
+ /**
143
+ * Persisted delete-time metadata: how the resource was deployed + how to reach/tear it down.
144
+ * Echoed from the props so a state-driven `delete` (no live `news`) can reconstruct them.
145
+ * ⚠️ SECURITY: `kubeConfigOptions` is persisted to alchemy state — see the note on
146
+ * {@link TypeKroResourceProps.kubeConfigOptions}.
147
+ */
148
+ deploymentStrategy?: 'direct' | 'kro';
149
+ kubeConfigOptions?: SerializableKubeConfigOptions;
150
+ kroDeletion?: KroDeletionOptions;
83
151
  /**
84
152
  * The deployed resource with live status from the cluster
85
153
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/alchemy/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE1F;;OAEG;IACH,MAAM,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,I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C;IAClD,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAEjC;;OAEG;IACH,gBAAgB,EAAE,CAAC,CAAC;IAEpB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB"}
@@ -1,16 +1,7 @@
1
1
  /**
2
2
  * Alchemy Integration Utilities
3
- *
4
- * This file contains utility functions that align with the dynamic registration approach.
5
- * Static resource registration functions have been removed to avoid conflicts.
6
3
  */
7
4
  import { generateDeterministicResourceId as _generateDeterministicResourceId } from '../core/resources/id.js';
8
- /**
9
- * Utility to check if a factory is alchemy-managed
10
- */
11
- export declare function isAlchemyWrapped(factory: unknown): factory is {
12
- isAlchemyManaged: true;
13
- };
14
5
  /**
15
6
  * Re-export utility function for deterministic resource ID generation
16
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../src/alchemy/wrapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,+BAA+B,IAAI,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAE9G;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI;IAAE,gBAAgB,EAAE,IAAI,CAAA;CAAE,CAQxF;AAED;;GAEG;AACH,eAAO,MAAM,+BAA+B,yCAAmC,CAAC"}
1
+ {"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../src/alchemy/wrapper.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,+BAA+B,IAAI,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAE9G;;GAEG;AACH,eAAO,MAAM,+BAA+B,yCAAmC,CAAC"}
@@ -1,24 +1,9 @@
1
1
  /**
2
2
  * Alchemy Integration Utilities
3
- *
4
- * This file contains utility functions that align with the dynamic registration approach.
5
- * Static resource registration functions have been removed to avoid conflicts.
6
3
  */
7
4
  import { generateDeterministicResourceId as _generateDeterministicResourceId } from '../core/resources/id.js';
8
- /**
9
- * Utility to check if a factory is alchemy-managed
10
- */
11
- export function isAlchemyWrapped(factory) {
12
- return (factory !== null &&
13
- factory !== undefined &&
14
- typeof factory === 'object' &&
15
- 'isAlchemyManaged' in factory &&
16
- factory.isAlchemyManaged === true);
17
- }
18
5
  /**
19
6
  * Re-export utility function for deterministic resource ID generation
20
7
  */
21
8
  export const generateDeterministicResourceId = _generateDeterministicResourceId;
22
- // All static resource registration functions have been removed to align with
23
- // the dynamic registration approach using ensureResourceTypeRegistered()
24
9
  //# sourceMappingURL=wrapper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../src/alchemy/wrapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,+BAA+B,IAAI,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAE9G;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,OAAO,CACL,OAAO,KAAK,IAAI;QAChB,OAAO,KAAK,SAAS;QACrB,OAAO,OAAO,KAAK,QAAQ;QAC3B,kBAAkB,IAAI,OAAO;QAC7B,OAAO,CAAC,gBAAgB,KAAK,IAAI,CAClC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,gCAAgC,CAAC;AAEhF,6EAA6E;AAC7E,yEAAyE"}
1
+ {"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../src/alchemy/wrapper.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,+BAA+B,IAAI,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAE9G;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,gCAAgC,CAAC"}
@@ -7,6 +7,7 @@
7
7
  import type { DeploymentClosure, DeploymentError, DeploymentResourceGraph, DeploymentResult, DirectResourceFactory, FactoryOptions, FactoryStatus, RollbackResult } from '../types/deployment.js';
8
8
  import type { Enhanced, KubernetesResource } from '../types/kubernetes.js';
9
9
  import type { KroCompatibleType, SchemaDefinition, StatusBuilder } from '../types/serialization.js';
10
+ import type { AlchemyResourceDeclaration } from '../../alchemy/types.js';
10
11
  /**
11
12
  * DirectResourceFactory implementation
12
13
  *
@@ -17,13 +18,11 @@ export declare class DirectResourceFactoryImpl<TSpec extends KroCompatibleType,
17
18
  readonly mode: "direct";
18
19
  readonly name: string;
19
20
  readonly namespace: string;
20
- readonly isAlchemyManaged: boolean;
21
21
  private readonly resources;
22
22
  private readonly closures;
23
23
  private readonly schemaDefinition;
24
24
  private readonly statusBuilder;
25
25
  private deploymentEngine;
26
- private readonly alchemyScope;
27
26
  private readonly factoryOptions;
28
27
  private readonly singletonDefinitions;
29
28
  private readonly singletonOwnerStatuses;
@@ -156,6 +155,19 @@ export declare class DirectResourceFactoryImpl<TSpec extends KroCompatibleType,
156
155
  * Create a resource graph for a specific instance
157
156
  */
158
157
  createResourceGraphForInstance(spec: TSpec, instanceNameOverride?: string): DeploymentResourceGraph;
158
+ /**
159
+ * Emit this composition's resolved resources as declarative alchemy **v2** resources — one
160
+ * {@link AlchemyResourceDeclaration} per Kubernetes resource (matching the v1 integration's
161
+ * per-resource state granularity), topologically ordered with `dependsOn` wired from the
162
+ * composition's dependency graph. The v2 analog of the removed imperative direct-mode alchemy
163
+ * deploy. Instantiate them with `materializeAlchemyResources(KroResource, …)`, which turns
164
+ * `dependsOn` into alchemy `Output` edges so (a) each resource deploys only after the resources
165
+ * it references and (b) each reconcile resolves its cross-resource `KubernetesRef`s against those
166
+ * dependencies' live state before applying.
167
+ */
168
+ toAlchemyResources(spec: TSpec, opts?: {
169
+ instanceNameOverride?: string;
170
+ }): Promise<AlchemyResourceDeclaration[]>;
159
171
  /**
160
172
  * Resolve resources for a specific spec
161
173
  * This uses composition re-execution when available, or falls back to reference resolution
@@ -1 +1 @@
1
- {"version":3,"file":"direct-factory.d.ts","sourceRoot":"","sources":["../../../src/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O,CAAC,kBAAkB;CAI3B;AA4GD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,SAAS,iBAAiB,EAC/B,OAAO,SAAS,iBAAiB,EAEjC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC7C,gBAAgB,EAAE,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,EAElD,aAAa,CAAC,EAAE,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,EAClD,OAAO,GAAE,cAAmB,GAC3B,qBAAqB,CAAC,KAAK,EAAE,OAAO,CAAC,CAQvC"}
@@ -23,9 +23,12 @@ import { DirectDeploymentEngine } from './engine.js';
23
23
  import { logHandleSnapshot } from './handle-tracing.js';
24
24
  import { synthesizeNestedCompositionStatus } from './nested-composition-status.js';
25
25
  import { ResourceReadinessChecker } from './readiness.js';
26
- import { generateInstanceName, getSingletonInstanceName, validateSpec, } from './shared-utilities.js';
26
+ import { ensureReadinessEvaluator } from '../readiness/evaluator.js';
27
+ import { extractResourceReferencesFromExpression } from '../expressions/analysis/scope-resolver.js';
28
+ import { createAlchemyResourceId } from '../../alchemy/utilities.js';
29
+ import { extractSerializableKubeConfigOptions, generateInstanceName, getSingletonInstanceName, validateSpec, } from './shared-utilities.js';
27
30
  import { assertNoDeployedSingletonSpecDrift, assertNoDiscoveredSingletonSpecDrift, singletonSpecFingerprintAnnotationValue, } from './singleton-owner-drift.js';
28
- import { AlchemyDeploymentStrategy, DirectDeploymentStrategy } from './strategies/index.js';
31
+ import { DirectDeploymentStrategy } from './strategies/index.js';
29
32
  /**
30
33
  * DirectResourceFactory implementation
31
34
  *
@@ -36,14 +39,12 @@ export class DirectResourceFactoryImpl {
36
39
  mode = 'direct';
37
40
  name;
38
41
  namespace;
39
- isAlchemyManaged;
40
42
  resources;
41
43
  closures;
42
44
  schemaDefinition;
43
45
  // biome-ignore lint/suspicious/noExplicitAny: status builders accept composition-specific resource maps that cannot be expressed more tightly here.
44
46
  statusBuilder;
45
47
  deploymentEngine;
46
- alchemyScope;
47
48
  factoryOptions;
48
49
  singletonDefinitions;
49
50
  singletonOwnerStatuses = new Map();
@@ -57,8 +58,6 @@ export class DirectResourceFactoryImpl {
57
58
  statusBuilder, options = {}) {
58
59
  this.name = name;
59
60
  this.namespace = options.namespace || 'default';
60
- this.alchemyScope = options.alchemyScope;
61
- this.isAlchemyManaged = !!options.alchemyScope;
62
61
  this.resources = resources;
63
62
  this.closures = options.closures || {};
64
63
  this.schemaDefinition = schemaDefinition;
@@ -149,14 +148,8 @@ export class DirectResourceFactoryImpl {
149
148
  * Get the appropriate deployment strategy based on configuration
150
149
  */
151
150
  getDeploymentStrategy() {
152
- // Create base strategy
153
- const baseStrategy = new DirectDeploymentStrategy(this.name, this.namespace, this.schemaDefinition, this.statusBuilder, this.resources, this.factoryOptions, this.getDeploymentEngine(), this // This factory acts as the resource resolver
151
+ return new DirectDeploymentStrategy(this.name, this.namespace, this.schemaDefinition, this.statusBuilder, this.resources, this.factoryOptions, this.getDeploymentEngine(), this // This factory acts as the resource resolver
154
152
  );
155
- // Wrap with alchemy if needed
156
- if (this.isAlchemyManaged && this.alchemyScope) {
157
- return new AlchemyDeploymentStrategy(this.name, this.namespace, this.schemaDefinition, this.statusBuilder, this.resources, this.factoryOptions, this.alchemyScope, baseStrategy);
158
- }
159
- return baseStrategy;
160
153
  }
161
154
  /**
162
155
  * Get all deployed instances
@@ -398,7 +391,6 @@ export class DirectResourceFactoryImpl {
398
391
  return {
399
392
  name: this.name,
400
393
  mode: this.mode,
401
- isAlchemyManaged: this.isAlchemyManaged,
402
394
  namespace: this.namespace,
403
395
  instanceCount: instances.length,
404
396
  health,
@@ -819,6 +811,78 @@ export class DirectResourceFactoryImpl {
819
811
  dependencyGraph,
820
812
  };
821
813
  }
814
+ /**
815
+ * Emit this composition's resolved resources as declarative alchemy **v2** resources — one
816
+ * {@link AlchemyResourceDeclaration} per Kubernetes resource (matching the v1 integration's
817
+ * per-resource state granularity), topologically ordered with `dependsOn` wired from the
818
+ * composition's dependency graph. The v2 analog of the removed imperative direct-mode alchemy
819
+ * deploy. Instantiate them with `materializeAlchemyResources(KroResource, …)`, which turns
820
+ * `dependsOn` into alchemy `Output` edges so (a) each resource deploys only after the resources
821
+ * it references and (b) each reconcile resolves its cross-resource `KubernetesRef`s against those
822
+ * dependencies' live state before applying.
823
+ */
824
+ async toAlchemyResources(spec, opts) {
825
+ const graph = this.createResourceGraphForInstance(spec, opts?.instanceNameOverride);
826
+ const kubeConfigOptions = extractSerializableKubeConfigOptions(this.getClientProvider().getKubeConfig(), this.factoryOptions.skipTLSVerify === true ? true : undefined);
827
+ const byGraphId = new Map();
828
+ for (const { id: graphId, manifest } of graph.resources) {
829
+ const resource = ensureReadinessEvaluator(manifest);
830
+ byGraphId.set(graphId, {
831
+ resource,
832
+ alchemyId: createAlchemyResourceId(resource, this.namespace),
833
+ logicalId: getResourceId(manifest) ?? graphId,
834
+ serialized: JSON.stringify(manifest),
835
+ });
836
+ }
837
+ const nodeByLogicalId = new Map(Array.from(byGraphId.values(), (n) => [n.logicalId, n]));
838
+ const logicalIds = new Set(nodeByLogicalId.keys());
839
+ const alchemyIdByLogicalId = new Map(Array.from(byGraphId.values(), (n) => [n.logicalId, n.alchemyId]));
840
+ // Compute each node's dependency logical-ids. The dependency graph captures `KubernetesRef`
841
+ // OBJECT references, but by the time the instance is resolved most cross-resource references
842
+ // have been serialized to CEL strings (`${otherResource.status.field}`) that the graph no
843
+ // longer sees — so we ALSO scan each manifest's serialized form for references to sibling
844
+ // logical ids. Union of both is the complete dependency set.
845
+ const depsByLogicalId = new Map();
846
+ for (const [graphId, node] of byGraphId) {
847
+ const deps = new Set();
848
+ for (const depGraphId of graph.dependencyGraph.getDependencies(graphId)) {
849
+ const dep = byGraphId.get(depGraphId);
850
+ if (dep)
851
+ deps.add(dep.logicalId);
852
+ }
853
+ for (const ref of extractResourceReferencesFromExpression(node.serialized)) {
854
+ const head = ref.split(/[.[]/, 1)[0];
855
+ if (head && head !== node.logicalId && logicalIds.has(head))
856
+ deps.add(head);
857
+ }
858
+ depsByLogicalId.set(node.logicalId, deps);
859
+ }
860
+ const waitForReady = this.factoryOptions.waitForReady ?? false;
861
+ const timeout = this.factoryOptions.timeout;
862
+ // Topologically sort by the COMPLETE dependency set (Kahn) so each declaration precedes its
863
+ // dependents — `getTopologicalOrder` alone would miss the CEL-string edges recovered above.
864
+ const ordered = topoSortLogicalIds(logicalIds, depsByLogicalId);
865
+ return ordered.flatMap((logicalId) => {
866
+ const node = nodeByLogicalId.get(logicalId);
867
+ if (!node)
868
+ return [];
869
+ const dependsOn = Array.from(depsByLogicalId.get(logicalId) ?? [])
870
+ .map((depLogicalId) => alchemyIdByLogicalId.get(depLogicalId))
871
+ .filter((id) => id !== undefined);
872
+ return {
873
+ id: node.alchemyId,
874
+ dependsOn,
875
+ props: {
876
+ resource: node.resource,
877
+ resourceId: node.logicalId,
878
+ namespace: this.namespace,
879
+ deploymentStrategy: 'direct',
880
+ kubeConfigOptions,
881
+ options: { waitForReady, ...(timeout !== undefined && { timeout }) },
882
+ },
883
+ };
884
+ });
885
+ }
822
886
  /**
823
887
  * Resolve resources for a specific spec
824
888
  * This uses composition re-execution when available, or falls back to reference resolution
@@ -1590,6 +1654,45 @@ export class DirectResourceFactoryImpl {
1590
1654
  return `${kind}/${namespace ?? ''}/${name}`;
1591
1655
  }
1592
1656
  }
1657
+ /**
1658
+ * Kahn topological sort of `ids` by their dependency set (`deps`: id → set of ids it depends on),
1659
+ * returning dependencies-first order. Edges to ids outside the set are ignored; if a cycle leaves
1660
+ * nodes unprocessed they're appended in stable order (best effort) rather than throwing.
1661
+ */
1662
+ function topoSortLogicalIds(ids, deps) {
1663
+ const inDegree = new Map();
1664
+ const dependents = new Map();
1665
+ for (const id of ids) {
1666
+ inDegree.set(id, 0);
1667
+ dependents.set(id, []);
1668
+ }
1669
+ for (const id of ids) {
1670
+ for (const dep of deps.get(id) ?? []) {
1671
+ if (!ids.has(dep))
1672
+ continue;
1673
+ inDegree.set(id, (inDegree.get(id) ?? 0) + 1);
1674
+ dependents.get(dep)?.push(id);
1675
+ }
1676
+ }
1677
+ const queue = Array.from(ids).filter((id) => (inDegree.get(id) ?? 0) === 0);
1678
+ const result = [];
1679
+ while (queue.length > 0) {
1680
+ const id = queue.shift();
1681
+ result.push(id);
1682
+ for (const dependent of dependents.get(id) ?? []) {
1683
+ const next = (inDegree.get(dependent) ?? 0) - 1;
1684
+ inDegree.set(dependent, next);
1685
+ if (next === 0)
1686
+ queue.push(dependent);
1687
+ }
1688
+ }
1689
+ if (result.length < ids.size) {
1690
+ for (const id of ids)
1691
+ if (!result.includes(id))
1692
+ result.push(id);
1693
+ }
1694
+ return result;
1695
+ }
1593
1696
  /**
1594
1697
  * Recursively walk a resolved resource tree and collect any remaining
1595
1698
  * KubernetesRef or CelExpression objects. These cannot be serialized