typekro 0.13.0 → 0.15.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 (85) 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/constants/brands.d.ts +1 -1
  21. package/dist/core/constants/brands.d.ts.map +1 -1
  22. package/dist/core/constants/brands.js +1 -1
  23. package/dist/core/constants/brands.js.map +1 -1
  24. package/dist/core/containers/image.d.ts +40 -43
  25. package/dist/core/containers/image.d.ts.map +1 -1
  26. package/dist/core/containers/image.js +52 -34
  27. package/dist/core/containers/image.js.map +1 -1
  28. package/dist/core/containers/index.d.ts +8 -12
  29. package/dist/core/containers/index.d.ts.map +1 -1
  30. package/dist/core/containers/index.js +8 -12
  31. package/dist/core/containers/index.js.map +1 -1
  32. package/dist/core/deployment/direct-factory.d.ts +14 -2
  33. package/dist/core/deployment/direct-factory.d.ts.map +1 -1
  34. package/dist/core/deployment/direct-factory.js +117 -21
  35. package/dist/core/deployment/direct-factory.js.map +1 -1
  36. package/dist/core/deployment/engine.d.ts +8 -5
  37. package/dist/core/deployment/engine.d.ts.map +1 -1
  38. package/dist/core/deployment/engine.js +36 -12
  39. package/dist/core/deployment/engine.js.map +1 -1
  40. package/dist/core/deployment/kro-factory.d.ts +33 -14
  41. package/dist/core/deployment/kro-factory.d.ts.map +1 -1
  42. package/dist/core/deployment/kro-factory.js +130 -164
  43. package/dist/core/deployment/kro-factory.js.map +1 -1
  44. package/dist/core/deployment/shared-utilities.d.ts +15 -4
  45. package/dist/core/deployment/shared-utilities.d.ts.map +1 -1
  46. package/dist/core/deployment/shared-utilities.js +47 -14
  47. package/dist/core/deployment/shared-utilities.js.map +1 -1
  48. package/dist/core/deployment/strategies/direct-strategy.d.ts.map +1 -1
  49. package/dist/core/deployment/strategies/direct-strategy.js +1 -2
  50. package/dist/core/deployment/strategies/direct-strategy.js.map +1 -1
  51. package/dist/core/deployment/strategies/index.d.ts +0 -1
  52. package/dist/core/deployment/strategies/index.d.ts.map +1 -1
  53. package/dist/core/deployment/strategies/index.js +0 -1
  54. package/dist/core/deployment/strategies/index.js.map +1 -1
  55. package/dist/core/types/deployment.d.ts +28 -42
  56. package/dist/core/types/deployment.d.ts.map +1 -1
  57. package/dist/core/types/resource-graph.d.ts +2 -6
  58. package/dist/core/types/resource-graph.d.ts.map +1 -1
  59. package/dist/core/types/schema.d.ts +0 -1
  60. package/dist/core/types/schema.d.ts.map +1 -1
  61. package/dist/core/types/serialization.d.ts +3 -7
  62. package/dist/core/types/serialization.d.ts.map +1 -1
  63. package/dist/factories/kubernetes/yaml/yaml-directory.d.ts.map +1 -1
  64. package/dist/factories/kubernetes/yaml/yaml-directory.js +2 -13
  65. package/dist/factories/kubernetes/yaml/yaml-directory.js.map +1 -1
  66. package/dist/factories/kubernetes/yaml/yaml-file.d.ts.map +1 -1
  67. package/dist/factories/kubernetes/yaml/yaml-file.js +2 -18
  68. package/dist/factories/kubernetes/yaml/yaml-file.js.map +1 -1
  69. package/dist/shared/brands.d.ts +0 -9
  70. package/dist/shared/brands.d.ts.map +1 -1
  71. package/dist/shared/brands.js +0 -9
  72. package/dist/shared/brands.js.map +1 -1
  73. package/package.json +6 -3
  74. package/dist/alchemy/deployment.d.ts +0 -12
  75. package/dist/alchemy/deployment.d.ts.map +0 -1
  76. package/dist/alchemy/deployment.js +0 -12
  77. package/dist/alchemy/deployment.js.map +0 -1
  78. package/dist/core/containers/resolve.d.ts +0 -14
  79. package/dist/core/containers/resolve.d.ts.map +0 -1
  80. package/dist/core/containers/resolve.js +0 -88
  81. package/dist/core/containers/resolve.js.map +0 -1
  82. package/dist/core/deployment/strategies/alchemy-strategy.d.ts +0 -109
  83. package/dist/core/deployment/strategies/alchemy-strategy.d.ts.map +0 -1
  84. package/dist/core/deployment/strategies/alchemy-strategy.js +0 -556
  85. 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,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,GAAG,KAAK,CAAC;IACtC,iBAAiB,CAAC,EAAE,6BAA6B,CAAC;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"}
@@ -5,5 +5,5 @@
5
5
  * New code within `src/utils/` should import directly from `../../shared/brands.js`
6
6
  * to maintain the clean dependency direction: `shared/ <-- utils/ <-- core/`.
7
7
  */
8
- export { CALLABLE_COMPOSITION_BRAND, CEL_EXPRESSION_BRAND, CONTAINER_IMAGE_REF_BRAND, KUBERNETES_REF_BRAND, KUBERNETES_REF_MARKER_FIELD_PATH_SOURCE, KUBERNETES_REF_MARKER_PATTERN, KUBERNETES_REF_MARKER_RESOURCE_ID_SOURCE, KUBERNETES_REF_MARKER_SOURCE, KUBERNETES_REF_SCHEMA_MARKER_SOURCE, MIXED_TEMPLATE_BRAND, NESTED_COMPOSITION_BRAND, SINGLETON_HANDLE_BRAND, } from '../../shared/brands.js';
8
+ export { CALLABLE_COMPOSITION_BRAND, CEL_EXPRESSION_BRAND, KUBERNETES_REF_BRAND, KUBERNETES_REF_MARKER_FIELD_PATH_SOURCE, KUBERNETES_REF_MARKER_PATTERN, KUBERNETES_REF_MARKER_RESOURCE_ID_SOURCE, KUBERNETES_REF_MARKER_SOURCE, KUBERNETES_REF_SCHEMA_MARKER_SOURCE, MIXED_TEMPLATE_BRAND, NESTED_COMPOSITION_BRAND, SINGLETON_HANDLE_BRAND, } from '../../shared/brands.js';
9
9
  //# sourceMappingURL=brands.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"brands.d.ts","sourceRoot":"","sources":["../../../src/core/constants/brands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,uCAAuC,EACvC,6BAA6B,EAC7B,wCAAwC,EACxC,4BAA4B,EAC5B,mCAAmC,EACnC,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"brands.d.ts","sourceRoot":"","sources":["../../../src/core/constants/brands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,uCAAuC,EACvC,6BAA6B,EAC7B,wCAAwC,EACxC,4BAA4B,EAC5B,mCAAmC,EACnC,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC"}
@@ -5,5 +5,5 @@
5
5
  * New code within `src/utils/` should import directly from `../../shared/brands.js`
6
6
  * to maintain the clean dependency direction: `shared/ <-- utils/ <-- core/`.
7
7
  */
8
- export { CALLABLE_COMPOSITION_BRAND, CEL_EXPRESSION_BRAND, CONTAINER_IMAGE_REF_BRAND, KUBERNETES_REF_BRAND, KUBERNETES_REF_MARKER_FIELD_PATH_SOURCE, KUBERNETES_REF_MARKER_PATTERN, KUBERNETES_REF_MARKER_RESOURCE_ID_SOURCE, KUBERNETES_REF_MARKER_SOURCE, KUBERNETES_REF_SCHEMA_MARKER_SOURCE, MIXED_TEMPLATE_BRAND, NESTED_COMPOSITION_BRAND, SINGLETON_HANDLE_BRAND, } from '../../shared/brands.js';
8
+ export { CALLABLE_COMPOSITION_BRAND, CEL_EXPRESSION_BRAND, KUBERNETES_REF_BRAND, KUBERNETES_REF_MARKER_FIELD_PATH_SOURCE, KUBERNETES_REF_MARKER_PATTERN, KUBERNETES_REF_MARKER_RESOURCE_ID_SOURCE, KUBERNETES_REF_MARKER_SOURCE, KUBERNETES_REF_SCHEMA_MARKER_SOURCE, MIXED_TEMPLATE_BRAND, NESTED_COMPOSITION_BRAND, SINGLETON_HANDLE_BRAND, } from '../../shared/brands.js';
9
9
  //# sourceMappingURL=brands.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"brands.js","sourceRoot":"","sources":["../../../src/core/constants/brands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,uCAAuC,EACvC,6BAA6B,EAC7B,wCAAwC,EACxC,4BAA4B,EAC5B,mCAAmC,EACnC,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"brands.js","sourceRoot":"","sources":["../../../src/core/constants/brands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,uCAAuC,EACvC,6BAA6B,EAC7B,wCAAwC,EACxC,4BAA4B,EAC5B,mCAAmC,EACnC,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC"}
@@ -1,65 +1,62 @@
1
1
  /**
2
2
  * Container Image Utility
3
3
  *
4
- * `container()` declares a container image built from source and pushed to a registry, as a
5
- * FIRST-CLASS typekro utility. It is defined at program scope OUTSIDE a `kubernetesComposition`
6
- * because an image is a build-time artifact with no dependency on cluster state; it should never be a
7
- * node in the cluster resource graph. Resources WITHIN a composition reference its `.imageUri`.
4
+ * `container()` declares a container image built from source and pushed to a registry. It is the
5
+ * high-level front door over {@link buildContainer}: a memoized async builder that resolves to a
6
+ * SHAPED result (`{ imageUri, repository, tag }`) so callers can use the full URI for a resource's
7
+ * image field OR the split `repository`/`tag` for a Helm chart's image values without re-splitting.
8
8
  *
9
- * `.imageUri` is a `ContainerImageRef` (a distinct brand, NOT a `KubernetesRef`): typekro resolves it
10
- * CLIENT-SIDE to a literal image URI before apply (direct mode) / RGD serialization (kro mode), by
11
- * delegating to the existing {@link buildContainer} once per container identity. Kro never sees a
12
- * build, only a literal image string.
9
+ * An image build is an async, client-side, pre-deploy side effect, so `container()` is honest about
10
+ * that: you `await` it. It is NOT a deferred reference resolve images in (async) setup code before
11
+ * composing, then feed the resulting literals into resources or chart values.
12
+ *
13
+ * Memoization: the build is keyed by container identity (`id ?? imageName`) and cached, so awaiting
14
+ * the same container many times (e.g. several deployments sharing one image) builds it exactly ONCE.
13
15
  *
14
16
  * @example
15
17
  * ```typescript
16
18
  * import { container } from 'typekro/containers';
17
19
  *
18
- * // Defined OUTSIDE the composition:
19
- * const appImage = container({ context: './app', imageName: 'app', registry: { type: 'ecr' } });
20
+ * const img = await container({ context: './app', imageName: 'app', registry: { type: 'ecr' } });
21
+ * // img.imageUri → '123.dkr.ecr.us-east-1.amazonaws.com/app:sha-abc'
22
+ * // img.repository → '123.dkr.ecr.us-east-1.amazonaws.com/app' img.tag → 'sha-abc'
20
23
  *
21
- * // Referenced WITHIN one:
22
- * kubernetesComposition(def, () => {
23
- * Deployment({ name: 'app', image: appImage.imageUri, ports: [{ containerPort: 3000 }] });
24
- * });
24
+ * Deployment({ name: 'app', image: img.imageUri, ports: [{ containerPort: 3000 }] });
25
+ * // or for a Helm chart's split image values: { repository: img.repository, tag: img.tag }
25
26
  * ```
26
27
  */
27
- import { CONTAINER_IMAGE_REF_BRAND } from '../constants/brands.js';
28
- import type { ContainerBuildOptions } from './registries/types.js';
29
- /**
30
- * A reference to a container image's URI. Resolved client-side to a literal string (the built +
31
- * pushed image URI) before apply / RGD serialization — distinct from a `KubernetesRef`, which is a
32
- * cluster-state reference serialized to CEL.
33
- */
34
- export interface ContainerImageRef<T extends string = string> {
35
- readonly [CONTAINER_IMAGE_REF_BRAND]: true;
36
- /** Stable identity — multiple references to the same container build the image only ONCE. */
37
- readonly containerId: string;
38
- /** The build spec, carried inline so the resolver is self-contained (delegates to `buildContainer`). */
39
- readonly buildOptions: ContainerBuildOptions;
40
- readonly _type?: T;
41
- }
42
- /** A first-class container image: defined outside a composition, referenced within one. */
28
+ import type { ContainerBuildOptions, ContainerBuildResult } from './registries/types.js';
29
+ /** A built container image, resolved to a literal — both the full URI and its split parts. */
43
30
  export interface ContainerImage {
44
- /**
45
- * The image-URI reference — assign to any resource image field (e.g. a container's `image`). Typed
46
- * as `string` so it's assignable to plain string fields, exactly like typekro's schema/resource
47
- * refs; at RUNTIME it is a branded {@link ContainerImageRef} that the resolver substitutes with the
48
- * built image URI at deploy time. Use {@link isContainerImageRef} to detect it.
49
- */
31
+ /** Full image URI, e.g. `123.dkr.ecr.us-east-1.amazonaws.com/app:sha-abc`. */
50
32
  readonly imageUri: string;
33
+ /** The URI without the tag, e.g. `123.dkr.ecr.us-east-1.amazonaws.com/app`. */
34
+ readonly repository: string;
35
+ /** The tag, e.g. `sha-abc`. */
36
+ readonly tag: string;
51
37
  }
52
38
  /** Options for {@link container}: the {@link ContainerBuildOptions} plus an optional stable identity. */
53
39
  export interface ContainerOptions extends ContainerBuildOptions {
54
- /** Stable identity for dedup across references; defaults to `imageName`. Set when two containers share one. */
40
+ /** Stable identity for build memoization; defaults to `imageName`. Set when two containers share one. */
55
41
  id?: string;
56
42
  }
57
43
  /**
58
- * Declare a container image as a first-class typekro utility (see the module doc). Returns a handle
59
- * whose `.imageUri` is referenced from resources; the build (via {@link buildContainer}) happens once
60
- * at deploy time and the literal URI is substituted before apply / serialization.
44
+ * Split a full image URI into `{ repository, tag }`. Handles digest form (`repo@sha256:…`) and tag
45
+ * form (`repo:tag`), registry-port-colon aware (a colon in `host:port/...` is not the tag separator).
46
+ */
47
+ export declare function splitImageUri(uri: string): {
48
+ repository: string;
49
+ tag: string;
50
+ };
51
+ /** Test seam: the builder `container()` delegates to (defaults to the real {@link buildContainer}). */
52
+ type Builder = (options: ContainerBuildOptions) => Promise<ContainerBuildResult>;
53
+ /**
54
+ * Build a container image (delegating to {@link buildContainer}) and resolve to its shaped result.
55
+ * Memoized by identity — see the module doc. `build` is an injectable test seam; production callers
56
+ * pass only `options`.
61
57
  */
62
- export declare function container(options: ContainerOptions): ContainerImage;
63
- /** Type guard: is `value` a {@link ContainerImageRef} (the `.imageUri` of a `container()`)? */
64
- export declare function isContainerImageRef(value: unknown): value is ContainerImageRef;
58
+ export declare function container(options: ContainerOptions, build?: Builder): Promise<ContainerImage>;
59
+ /** Clear the build memoization cache. Intended for tests/long-lived processes that need a rebuild. */
60
+ export declare function clearContainerCache(): void;
61
+ export {};
65
62
  //# sourceMappingURL=image.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/core/containers/image.ts"],"names":[],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+BAA+B;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,yGAAyG;AACzG,MAAM,WAAW,gBAAiB,SAAQ,qBAAqB;IAC7D,yGAAyG;IACzG,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAQ9E;AAKD,uGAAuG;AACvG,KAAK,OAAO,GAAG,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;AASjF;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,gBAAgB,EACzB,KAAK,GAAE,OAAwB,GAC9B,OAAO,CAAC,cAAc,CAAC,CAQzB;AAED,sGAAsG;AACtG,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}
@@ -1,51 +1,69 @@
1
1
  /**
2
2
  * Container Image Utility
3
3
  *
4
- * `container()` declares a container image built from source and pushed to a registry, as a
5
- * FIRST-CLASS typekro utility. It is defined at program scope OUTSIDE a `kubernetesComposition`
6
- * because an image is a build-time artifact with no dependency on cluster state; it should never be a
7
- * node in the cluster resource graph. Resources WITHIN a composition reference its `.imageUri`.
4
+ * `container()` declares a container image built from source and pushed to a registry. It is the
5
+ * high-level front door over {@link buildContainer}: a memoized async builder that resolves to a
6
+ * SHAPED result (`{ imageUri, repository, tag }`) so callers can use the full URI for a resource's
7
+ * image field OR the split `repository`/`tag` for a Helm chart's image values without re-splitting.
8
8
  *
9
- * `.imageUri` is a `ContainerImageRef` (a distinct brand, NOT a `KubernetesRef`): typekro resolves it
10
- * CLIENT-SIDE to a literal image URI before apply (direct mode) / RGD serialization (kro mode), by
11
- * delegating to the existing {@link buildContainer} once per container identity. Kro never sees a
12
- * build, only a literal image string.
9
+ * An image build is an async, client-side, pre-deploy side effect, so `container()` is honest about
10
+ * that: you `await` it. It is NOT a deferred reference resolve images in (async) setup code before
11
+ * composing, then feed the resulting literals into resources or chart values.
12
+ *
13
+ * Memoization: the build is keyed by container identity (`id ?? imageName`) and cached, so awaiting
14
+ * the same container many times (e.g. several deployments sharing one image) builds it exactly ONCE.
13
15
  *
14
16
  * @example
15
17
  * ```typescript
16
18
  * import { container } from 'typekro/containers';
17
19
  *
18
- * // Defined OUTSIDE the composition:
19
- * const appImage = container({ context: './app', imageName: 'app', registry: { type: 'ecr' } });
20
+ * const img = await container({ context: './app', imageName: 'app', registry: { type: 'ecr' } });
21
+ * // img.imageUri → '123.dkr.ecr.us-east-1.amazonaws.com/app:sha-abc'
22
+ * // img.repository → '123.dkr.ecr.us-east-1.amazonaws.com/app' img.tag → 'sha-abc'
20
23
  *
21
- * // Referenced WITHIN one:
22
- * kubernetesComposition(def, () => {
23
- * Deployment({ name: 'app', image: appImage.imageUri, ports: [{ containerPort: 3000 }] });
24
- * });
24
+ * Deployment({ name: 'app', image: img.imageUri, ports: [{ containerPort: 3000 }] });
25
+ * // or for a Helm chart's split image values: { repository: img.repository, tag: img.tag }
25
26
  * ```
26
27
  */
27
- import { CONTAINER_IMAGE_REF_BRAND } from '../constants/brands.js';
28
+ import { buildContainer } from './build.js';
29
+ /**
30
+ * Split a full image URI into `{ repository, tag }`. Handles digest form (`repo@sha256:…`) and tag
31
+ * form (`repo:tag`), registry-port-colon aware (a colon in `host:port/...` is not the tag separator).
32
+ */
33
+ export function splitImageUri(uri) {
34
+ const at = uri.lastIndexOf('@');
35
+ if (at !== -1)
36
+ return { repository: uri.slice(0, at), tag: uri.slice(at + 1) };
37
+ const colon = uri.lastIndexOf(':');
38
+ const slash = uri.lastIndexOf('/');
39
+ return colon > slash
40
+ ? { repository: uri.slice(0, colon), tag: uri.slice(colon + 1) }
41
+ : { repository: uri, tag: 'latest' };
42
+ }
43
+ /** Build memoization, keyed by container identity (`id ?? imageName`) — builds each image once. */
44
+ const buildCache = new Map();
45
+ async function buildAndShape(options, build) {
46
+ const { id: _id, ...buildOptions } = options;
47
+ const result = await build({ ...buildOptions, tag: buildOptions.tag ?? 'content-hash' });
48
+ const { repository, tag } = splitImageUri(result.imageUri);
49
+ return { imageUri: result.imageUri, repository, tag };
50
+ }
28
51
  /**
29
- * Declare a container image as a first-class typekro utility (see the module doc). Returns a handle
30
- * whose `.imageUri` is referenced from resources; the build (via {@link buildContainer}) happens once
31
- * at deploy time and the literal URI is substituted before apply / serialization.
52
+ * Build a container image (delegating to {@link buildContainer}) and resolve to its shaped result.
53
+ * Memoized by identity see the module doc. `build` is an injectable test seam; production callers
54
+ * pass only `options`.
32
55
  */
33
- export function container(options) {
34
- const { id, ...buildOptions } = options;
35
- const containerId = id ?? buildOptions.imageName;
36
- const ref = {
37
- [CONTAINER_IMAGE_REF_BRAND]: true,
38
- containerId,
39
- buildOptions,
40
- };
41
- // Typed as `string` (assignable to any image field) but a branded ref at runtime — mirrors how
42
- // typekro's schema/resource refs present as their underlying type while carrying runtime markers.
43
- return { imageUri: ref };
56
+ export function container(options, build = buildContainer) {
57
+ const key = options.id ?? options.imageName;
58
+ let pending = buildCache.get(key);
59
+ if (!pending) {
60
+ pending = buildAndShape(options, build);
61
+ buildCache.set(key, pending);
62
+ }
63
+ return pending;
44
64
  }
45
- /** Type guard: is `value` a {@link ContainerImageRef} (the `.imageUri` of a `container()`)? */
46
- export function isContainerImageRef(value) {
47
- return (typeof value === 'object' &&
48
- value !== null &&
49
- value[CONTAINER_IMAGE_REF_BRAND] === true);
65
+ /** Clear the build memoization cache. Intended for tests/long-lived processes that need a rebuild. */
66
+ export function clearContainerCache() {
67
+ buildCache.clear();
50
68
  }
51
69
  //# sourceMappingURL=image.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"image.js","sourceRoot":"","sources":["../../../src/core/containers/image.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;A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 +5,21 @@
5
5
  * Returns image URIs for use in TypeKro compositions.
6
6
  *
7
7
  * The low-level `buildContainer` builds + pushes imperatively and returns a URI. The higher-level
8
- * `container()` utility wraps it declaratively: define an image once at program scope and reference
9
- * its `.imageUri` from resources inside a composition typekro builds it (via `buildContainer`) and
10
- * substitutes the literal URI at deploy time.
8
+ * `container()` is a memoized async builder that resolves to a SHAPED result (`{ imageUri,
9
+ * repository, tag }`) `await` it in setup code, then feed the full URI to a resource's image field
10
+ * or the split `repository`/`tag` to a Helm chart's image values.
11
11
  *
12
12
  * @example
13
13
  * ```typescript
14
- * import { buildContainer, container } from 'typekro/containers';
14
+ * import { container } from 'typekro/containers';
15
15
  *
16
- * // Imperative (build now, get a URI):
17
- * const { imageUri } = await buildContainer({ context: './app', imageName: 'app', registry: { type: 'orbstack' } });
18
- *
19
- * // Declarative (defined outside a composition, referenced within):
20
- * const appImage = container({ context: './app', imageName: 'app', registry: { type: 'ecr' } });
21
- * // … later, inside a composition: Deployment({ image: appImage.imageUri, … })
16
+ * const img = await container({ context: './app', imageName: 'app', registry: { type: 'ecr' } });
17
+ * Deployment({ image: img.imageUri, }); // full URI
18
+ * // or chart values: { repository: img.repository, tag: img.tag }
22
19
  * ```
23
20
  */
24
21
  export { buildContainer } from './build.js';
25
22
  export { ContainerBuildError } from './errors.js';
26
- export { container, type ContainerImage, type ContainerImageRef, type ContainerOptions, isContainerImageRef } from './image.js';
27
- export { hasContainerImageRefs, resolveContainerImages } from './resolve.js';
23
+ export { type ContainerImage, type ContainerOptions, clearContainerCache, container, splitImageUri, } from './image.js';
28
24
  export type { ContainerBuildOptions, ContainerBuildResult, EcrRegistryConfig, OrbstackRegistryConfig, RegistryConfig, } from './registries/types.js';
29
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/containers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAChI,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC7E,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,GACf,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/containers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,mBAAmB,EACnB,SAAS,EACT,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,GACf,MAAM,uBAAuB,CAAC"}
@@ -5,24 +5,20 @@
5
5
  * Returns image URIs for use in TypeKro compositions.
6
6
  *
7
7
  * The low-level `buildContainer` builds + pushes imperatively and returns a URI. The higher-level
8
- * `container()` utility wraps it declaratively: define an image once at program scope and reference
9
- * its `.imageUri` from resources inside a composition typekro builds it (via `buildContainer`) and
10
- * substitutes the literal URI at deploy time.
8
+ * `container()` is a memoized async builder that resolves to a SHAPED result (`{ imageUri,
9
+ * repository, tag }`) `await` it in setup code, then feed the full URI to a resource's image field
10
+ * or the split `repository`/`tag` to a Helm chart's image values.
11
11
  *
12
12
  * @example
13
13
  * ```typescript
14
- * import { buildContainer, container } from 'typekro/containers';
14
+ * import { container } from 'typekro/containers';
15
15
  *
16
- * // Imperative (build now, get a URI):
17
- * const { imageUri } = await buildContainer({ context: './app', imageName: 'app', registry: { type: 'orbstack' } });
18
- *
19
- * // Declarative (defined outside a composition, referenced within):
20
- * const appImage = container({ context: './app', imageName: 'app', registry: { type: 'ecr' } });
21
- * // … later, inside a composition: Deployment({ image: appImage.imageUri, … })
16
+ * const img = await container({ context: './app', imageName: 'app', registry: { type: 'ecr' } });
17
+ * Deployment({ image: img.imageUri, }); // full URI
18
+ * // or chart values: { repository: img.repository, tag: img.tag }
22
19
  * ```
23
20
  */
24
21
  export { buildContainer } from './build.js';
25
22
  export { ContainerBuildError } from './errors.js';
26
- export { container, isContainerImageRef } from './image.js';
27
- export { hasContainerImageRefs, resolveContainerImages } from './resolve.js';
23
+ export { clearContainerCache, container, splitImageUri, } from './image.js';
28
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/containers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAsE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAChI,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/containers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAGL,mBAAmB,EACnB,SAAS,EACT,aAAa,GACd,MAAM,YAAY,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