@xplane/devtools 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.
|
@@ -133,6 +133,13 @@ interface SimulationResult {
|
|
|
133
133
|
emitted: Template;
|
|
134
134
|
/** Resources that are blocked on unresolved dependencies. */
|
|
135
135
|
blocked: Template;
|
|
136
|
+
/** Conditions that would be set on the XR status (e.g., missing existing resources). */
|
|
137
|
+
conditions: Array<{
|
|
138
|
+
type: string;
|
|
139
|
+
status: string;
|
|
140
|
+
reason: string;
|
|
141
|
+
message: string;
|
|
142
|
+
}>;
|
|
136
143
|
}
|
|
137
144
|
/**
|
|
138
145
|
* Simulates the full rendering pipeline including observed state injection,
|
|
@@ -152,6 +159,7 @@ interface SimulationResult {
|
|
|
152
159
|
declare class Simulator {
|
|
153
160
|
private readonly _composition;
|
|
154
161
|
private _observed;
|
|
162
|
+
private _existing;
|
|
155
163
|
private constructor();
|
|
156
164
|
/**
|
|
157
165
|
* Ergonomic factory: injects XR/environment data, instantiates the
|
|
@@ -168,6 +176,14 @@ declare class Simulator {
|
|
|
168
176
|
* (i.e., `metadata.name` in observed state maps to `resource.path` in the composition).
|
|
169
177
|
*/
|
|
170
178
|
withObserved(resources: KubernetesResource$1[]): this;
|
|
179
|
+
/**
|
|
180
|
+
* Provide existing resource data keyed by refKey.
|
|
181
|
+
* The refKey format is `apiVersion/kind/[namespace/]name`
|
|
182
|
+
* (e.g., `"example.io/v1/Project/my-project"` or `"v1/Secret/default/db-creds"`).
|
|
183
|
+
*
|
|
184
|
+
* This simulates what Crossplane would return via the Required Resources mechanism.
|
|
185
|
+
*/
|
|
186
|
+
withExisting(resources: Record<string, KubernetesResource$1>): this;
|
|
171
187
|
/**
|
|
172
188
|
* Run the simulation: inject observed state, resolve edges, determine sequencing.
|
|
173
189
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/assertions/match.ts","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UAAA,UAAoB,IAAA,UAAc,SAAA;EDoL/B;;;EC9JnB,mBAAA,CAAoB,UAAA,UAAoB,IAAA,UAAc,SAAA;EDmKjB;AAAA;;EC7IrC,YAAA,CAAa,UAAA,UAAoB,IAAA,UAAc,KAAA;;AA5KjD;;;EAsME,aAAA,CAAc,UAAA,UAAoB,IAAA,UAAc,KAAA,YAAiB,oBAAA;EApMjE;;;;;AAEoB;AAiBtB;;EAmME,MAAA,CAAA,GAAU,oBAAA;AAAA;;;;UClNK,gBAAA;EFT2C;EEW1D,OAAA,EAAS,QAAA;EFXiD;EEa1D,OAAA,EAAS,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/assertions/match.ts","../../src/assertions/template.ts","../../src/assertions/simulator.ts"],"mappings":";;;;cACa,OAAA;;UAGI,WAAA;EAH2C;EAK1D,IAAA;EAL0D;EAO1D,QAAQ;AAAA;;UAIO,OAAA;EAAA,UACL,OAAA;EACV,IAAA,CAAK,MAAA,YAAkB,WAAW;AAAA;;;;;;;;;;;cAwQvB,KAAA;EAAA,QACJ,WAAA,CAAA;EAG6B;EAAA,OAA7B,UAAA,CAAW,OAAA,WAAkB,OAAA;EAKhB;EAAA,OAAb,YAAA,CAAa,OAAA,WAAkB,OAAA;EAK/B;EAAA,OAAA,SAAA,CAAU,KAAA,cAAmB,OAAA;EAAA;EAAA,OAK7B,WAAA,CAAY,KAAA,cAAmB,OAAA;EAAnB;EAAA,OAKZ,gBAAA,CAAiB,OAAA,WAAkB,MAAA,GAAS,OAAA;EAA5C;EAAA,OAKA,MAAA,CAAA,GAAU,OAAA;EALO;EAAA,OAUjB,QAAA,CAAA,GAAY,OAAA;EALZ;EAAA,OAUA,GAAA,CAAI,OAAA,YAAmB,OAAA;AAAA;;;;UCzTf,iBAAA;EDHJ;ECKX,EAAA,GAAK,MAAA;;EAEL,WAAA,GAAc,MAAM;AAAA;ADJtB;;;;AAIU;AAIV;;;;;;;;;AARA,cCqBa,QAAA;EAAA,iB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CAAa,SAAA,EAAW,oBAAA;EF4LkB;;;;;;;EEhL1C,YAAA,CAAa,SAAA,EAAW,MAAA,SAAe,oBAAA;EF+L5B;;;EEvLX,GAAA,CAAA,GAAO,gBAAA;AAAA"}
|
|
@@ -410,6 +410,7 @@ function setNestedValue(obj, path, value) {
|
|
|
410
410
|
var Simulator = class Simulator {
|
|
411
411
|
_composition;
|
|
412
412
|
_observed = [];
|
|
413
|
+
_existing = {};
|
|
413
414
|
constructor(composition) {
|
|
414
415
|
this._composition = composition;
|
|
415
416
|
}
|
|
@@ -447,11 +448,23 @@ var Simulator = class Simulator {
|
|
|
447
448
|
return this;
|
|
448
449
|
}
|
|
449
450
|
/**
|
|
451
|
+
* Provide existing resource data keyed by refKey.
|
|
452
|
+
* The refKey format is `apiVersion/kind/[namespace/]name`
|
|
453
|
+
* (e.g., `"example.io/v1/Project/my-project"` or `"v1/Secret/default/db-creds"`).
|
|
454
|
+
*
|
|
455
|
+
* This simulates what Crossplane would return via the Required Resources mechanism.
|
|
456
|
+
*/
|
|
457
|
+
withExisting(resources) {
|
|
458
|
+
this._existing = resources;
|
|
459
|
+
return this;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
450
462
|
* Run the simulation: inject observed state, resolve edges, determine sequencing.
|
|
451
463
|
*/
|
|
452
464
|
run() {
|
|
453
465
|
const composition = this._composition;
|
|
454
466
|
const resources = composition.resources;
|
|
467
|
+
const existingResources = composition.existingResources;
|
|
455
468
|
const collector = composition.collector;
|
|
456
469
|
const graph = composition.graph;
|
|
457
470
|
const observedMap = /* @__PURE__ */ new Map();
|
|
@@ -464,6 +477,24 @@ var Simulator = class Simulator {
|
|
|
464
477
|
const observed = observedMap.get(path);
|
|
465
478
|
if (observed) resource.setObserved(observed);
|
|
466
479
|
}
|
|
480
|
+
const conditions = [];
|
|
481
|
+
for (const [refKey, existingResource] of existingResources) {
|
|
482
|
+
const data = this._existing[refKey];
|
|
483
|
+
if (data) {
|
|
484
|
+
existingResource.setObservedFull(data);
|
|
485
|
+
observedMap.set(existingResource.path, data);
|
|
486
|
+
} else {
|
|
487
|
+
const ref = existingResource.existingRef;
|
|
488
|
+
const name = typeof ref?.name === "string" ? ref.name : "<unresolved>";
|
|
489
|
+
const kind = ref?.kind ?? "Unknown";
|
|
490
|
+
conditions.push({
|
|
491
|
+
type: "Ready",
|
|
492
|
+
status: "False",
|
|
493
|
+
reason: "MissingRequiredResource",
|
|
494
|
+
message: `Required existing resource ${kind}/${name} not found in cluster`
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
}
|
|
467
498
|
for (const edge of collector.edges) {
|
|
468
499
|
const observed = observedMap.get(edge.from.id);
|
|
469
500
|
if (!observed) continue;
|
|
@@ -477,7 +508,8 @@ var Simulator = class Simulator {
|
|
|
477
508
|
const sequencing = resolveSequencing(resources, graph, observedMap);
|
|
478
509
|
return {
|
|
479
510
|
emitted: Template.fromResources(sequencing.emit.map((r) => r.toDesired())),
|
|
480
|
-
blocked: Template.fromResources(sequencing.blocked.map((r) => r.toDesired()))
|
|
511
|
+
blocked: Template.fromResources(sequencing.blocked.map((r) => r.toDesired())),
|
|
512
|
+
conditions
|
|
481
513
|
};
|
|
482
514
|
}
|
|
483
515
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/assertions/match.ts","../../src/assertions/template.ts","../../src/assertions/simulator.ts"],"sourcesContent":["/** Symbol used to identify Matcher instances. */\nexport const MATCHER = Symbol.for('xplane.devtools.matcher');\n\n/** Result of a match operation. */\nexport interface MatchResult {\n /** Whether the match succeeded. */\n pass: boolean;\n /** Human-readable failure messages (empty if pass is true). */\n failures: string[];\n}\n\n/** Interface for custom matchers. */\nexport interface Matcher {\n readonly [MATCHER]: true;\n test(actual: unknown): MatchResult;\n}\n\n/** Check whether a value is a Matcher instance. */\nexport function isMatcher(value: unknown): value is Matcher {\n return (\n typeof value === 'object' &&\n value !== null &&\n MATCHER in value &&\n (value as Matcher)[MATCHER] === true\n );\n}\n\nfunction pass(): MatchResult {\n return { pass: true, failures: [] };\n}\n\nfunction fail(message: string): MatchResult {\n return { pass: false, failures: [message] };\n}\n\nfunction merge(results: MatchResult[]): MatchResult {\n const failures = results.flatMap((r) => r.failures);\n return { pass: failures.length === 0, failures };\n}\n\n/**\n * Deep-match `actual` against `expected`.\n * - If `expected` is a Matcher, delegates to its `.test()`.\n * - Literal objects are matched recursively (deep-partial by default via objectLike semantics at the top level is handled by the caller).\n * - This function performs EXACT matching — partial matching is handled by ObjectLikeMatcher.\n */\nexport function deepMatch(actual: unknown, expected: unknown, path = ''): MatchResult {\n if (isMatcher(expected)) {\n const result = expected.test(actual);\n if (!result.pass) {\n return { pass: false, failures: result.failures.map((f) => (path ? `${path}: ${f}` : f)) };\n }\n return pass();\n }\n\n // Null / undefined / primitives\n if (expected === null || expected === undefined || typeof expected !== 'object') {\n if (actual === expected) return pass();\n return fail(\n path\n ? `${path}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`\n : `expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`,\n );\n }\n\n // Arrays\n if (Array.isArray(expected)) {\n if (!Array.isArray(actual)) {\n return fail(`${path || 'value'}: expected an array, got ${typeof actual}`);\n }\n if (actual.length !== expected.length) {\n return fail(\n `${path || 'value'}: expected array of length ${expected.length}, got length ${actual.length}`,\n );\n }\n const results: MatchResult[] = [];\n for (let i = 0; i < expected.length; i++) {\n results.push(deepMatch(actual[i], expected[i], `${path}[${i}]`));\n }\n return merge(results);\n }\n\n // Objects (exact match — all keys in expected must match, no extra keys allowed)\n if (typeof actual !== 'object' || actual === null || Array.isArray(actual)) {\n return fail(`${path || 'value'}: expected an object, got ${JSON.stringify(actual)}`);\n }\n const expectedObj = expected as Record<string, unknown>;\n const actualObj = actual as Record<string, unknown>;\n const results: MatchResult[] = [];\n\n // Check expected keys exist and match\n for (const key of Object.keys(expectedObj)) {\n results.push(deepMatch(actualObj[key], expectedObj[key], path ? `${path}.${key}` : key));\n }\n // Check no extra keys in actual\n for (const key of Object.keys(actualObj)) {\n if (!(key in expectedObj)) {\n results.push(fail(`${path ? `${path}.${key}` : key}: unexpected key`));\n }\n }\n return merge(results);\n}\n\n/**\n * Deep-partial match: all keys in `expected` must match in `actual`, but\n * `actual` may have additional keys at any level.\n */\nexport function deepPartialMatch(actual: unknown, expected: unknown, path = ''): MatchResult {\n if (isMatcher(expected)) {\n const result = expected.test(actual);\n if (!result.pass) {\n return { pass: false, failures: result.failures.map((f) => (path ? `${path}: ${f}` : f)) };\n }\n return pass();\n }\n\n if (expected === null || expected === undefined || typeof expected !== 'object') {\n if (actual === expected) return pass();\n return fail(\n path\n ? `${path}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`\n : `expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`,\n );\n }\n\n if (Array.isArray(expected)) {\n if (!Array.isArray(actual)) {\n return fail(`${path || 'value'}: expected an array, got ${typeof actual}`);\n }\n if (actual.length !== expected.length) {\n return fail(\n `${path || 'value'}: expected array of length ${expected.length}, got length ${actual.length}`,\n );\n }\n const results: MatchResult[] = [];\n for (let i = 0; i < expected.length; i++) {\n results.push(deepPartialMatch(actual[i], expected[i], `${path}[${i}]`));\n }\n return merge(results);\n }\n\n if (typeof actual !== 'object' || actual === null || Array.isArray(actual)) {\n return fail(`${path || 'value'}: expected an object, got ${JSON.stringify(actual)}`);\n }\n\n const expectedObj = expected as Record<string, unknown>;\n const actualObj = actual as Record<string, unknown>;\n const results: MatchResult[] = [];\n\n // Only check keys present in expected — actual may have extras\n for (const key of Object.keys(expectedObj)) {\n if (!(key in actualObj)) {\n results.push(fail(`${path ? `${path}.${key}` : key}: key not found in actual`));\n } else {\n results.push(\n deepPartialMatch(actualObj[key], expectedObj[key], path ? `${path}.${key}` : key),\n );\n }\n }\n return merge(results);\n}\n\n// ─── Matcher Implementations ────────────────────────────────────────────\n\nclass ObjectLikeMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n constructor(private readonly pattern: object) {}\n test(actual: unknown): MatchResult {\n return deepPartialMatch(actual, this.pattern);\n }\n}\n\nclass ObjectEqualsMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n constructor(private readonly pattern: object) {}\n test(actual: unknown): MatchResult {\n return deepMatch(actual, this.pattern);\n }\n}\n\nclass ArrayWithMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n constructor(private readonly items: unknown[]) {}\n test(actual: unknown): MatchResult {\n if (!Array.isArray(actual)) {\n return fail(`expected an array, got ${typeof actual}`);\n }\n // Each item in `this.items` must appear in `actual` in order (not necessarily contiguous)\n let searchStart = 0;\n for (let i = 0; i < this.items.length; i++) {\n let found = false;\n for (let j = searchStart; j < actual.length; j++) {\n const r = deepPartialMatch(actual[j], this.items[i]);\n if (r.pass) {\n searchStart = j + 1;\n found = true;\n break;\n }\n }\n if (!found) {\n return fail(\n `arrayWith: could not find match for item at index ${i}: ${JSON.stringify(this.items[i])}`,\n );\n }\n }\n return pass();\n }\n}\n\nclass ArrayEqualsMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n constructor(private readonly items: unknown[]) {}\n test(actual: unknown): MatchResult {\n return deepMatch(actual, this.items);\n }\n}\n\nclass StringLikeRegexpMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n private readonly regex: RegExp;\n constructor(pattern: string | RegExp) {\n this.regex = typeof pattern === 'string' ? new RegExp(pattern) : pattern;\n }\n test(actual: unknown): MatchResult {\n if (typeof actual !== 'string') {\n return fail(`expected a string, got ${typeof actual}`);\n }\n if (!this.regex.test(actual)) {\n return fail(`expected string matching ${this.regex}, got \"${actual}\"`);\n }\n return pass();\n }\n}\n\nclass AbsentMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n test(actual: unknown): MatchResult {\n if (actual !== undefined) {\n return fail(`expected absent (undefined), got ${JSON.stringify(actual)}`);\n }\n return pass();\n }\n}\n\nclass AnyValueMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n test(actual: unknown): MatchResult {\n if (actual === null || actual === undefined) {\n return fail(`expected any value, got ${actual}`);\n }\n return pass();\n }\n}\n\nclass NotMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n constructor(private readonly pattern: unknown) {}\n test(actual: unknown): MatchResult {\n const inner = isMatcher(this.pattern)\n ? this.pattern.test(actual)\n : deepPartialMatch(actual, this.pattern);\n if (inner.pass) {\n return fail(`expected NOT to match, but matched: ${JSON.stringify(actual)}`);\n }\n return pass();\n }\n}\n\n/**\n * Factory for composable matchers used in assertions.\n *\n * @example\n * ```ts\n * template.hasResourceSpec('v1', 'ConfigMap', {\n * data: Match.objectLike({ key: 'value' }),\n * });\n * ```\n */\nexport class Match {\n private constructor() {}\n\n /** Deep-partial object match — actual may be a superset of pattern. */\n static objectLike(pattern: object): Matcher {\n return new ObjectLikeMatcher(pattern);\n }\n\n /** Exact object match — actual must equal pattern exactly (same keys, same values). */\n static objectEquals(pattern: object): Matcher {\n return new ObjectEqualsMatcher(pattern);\n }\n\n /** Array subset match — items must appear in actual in order. */\n static arrayWith(items: unknown[]): Matcher {\n return new ArrayWithMatcher(items);\n }\n\n /** Exact array match — actual must equal items exactly. */\n static arrayEquals(items: unknown[]): Matcher {\n return new ArrayEqualsMatcher(items);\n }\n\n /** String regex match. */\n static stringLikeRegexp(pattern: string | RegExp): Matcher {\n return new StringLikeRegexpMatcher(pattern);\n }\n\n /** Asserts the value is absent (undefined). */\n static absent(): Matcher {\n return new AbsentMatcher();\n }\n\n /** Asserts any non-null/non-undefined value is present. */\n static anyValue(): Matcher {\n return new AnyValueMatcher();\n }\n\n /** Inverts a match — asserts the value does NOT match the given pattern. */\n static not(pattern: unknown): Matcher {\n return new NotMatcher(pattern);\n }\n}\n","import type { Composition, KubernetesResource } from '@xplane/core';\nimport { deepPartialMatch } from './match.js';\n\n/** Options for `Template.synthesize()`. */\nexport interface SynthesizeOptions {\n /** XR (composite resource) data to inject before instantiation. */\n xr?: Record<string, unknown>;\n /** Environment data to inject before instantiation. */\n environment?: Record<string, unknown>;\n}\n\n/**\n * A snapshot of rendered resources from a Composition, providing\n * assertion methods for unit testing.\n *\n * @example\n * ```ts\n * const template = Template.synthesize(MyComposition, {\n * xr: { spec: { region: 'us-east-1' } },\n * });\n * template.hasResourceSpec('ec2.aws.crossplane.io/v1beta1', 'VPC', {\n * forProvider: { region: 'us-east-1' },\n * });\n * ```\n */\nexport class Template {\n private readonly _resources: KubernetesResource[];\n\n private constructor(resources: KubernetesResource[]) {\n this._resources = resources;\n }\n\n /**\n * Ergonomic factory: injects XR/environment data and instantiates\n * the Composition class, then builds a Template from the rendered resources.\n *\n * Users never need to touch `Composition._pendingXR` directly.\n */\n static synthesize(Ctor: new () => Composition, options: SynthesizeOptions = {}): Template {\n // Walk up prototype chain to find the base Composition class with _pendingXR\n let base = Ctor as unknown as Record<string, unknown>;\n while (base && !Object.hasOwn(base, '_pendingXR')) {\n base = Object.getPrototypeOf(base) as Record<string, unknown>;\n }\n if (!base) {\n throw new Error('Could not find Composition base class with _pendingXR');\n }\n\n const BaseComposition = base as unknown as {\n _pendingXR: Record<string, unknown> | undefined;\n _pendingEnvironment: Record<string, unknown> | undefined;\n };\n\n BaseComposition._pendingXR = options.xr;\n BaseComposition._pendingEnvironment = options.environment;\n try {\n const instance = new Ctor();\n return Template.fromComposition(instance);\n } finally {\n BaseComposition._pendingXR = undefined;\n BaseComposition._pendingEnvironment = undefined;\n }\n }\n\n /**\n * Build a Template from an already-instantiated Composition.\n */\n static fromComposition(composition: Composition): Template {\n const resources = [\n ...(\n composition as unknown as {\n resources: ReadonlyMap<string, { toDesired(): KubernetesResource }>;\n }\n ).resources.values(),\n ].map((r) => r.toDesired());\n return new Template(resources);\n }\n\n /**\n * Build a Template from a pre-built array of KubernetesResource objects.\n * Used internally by Simulator.\n */\n static fromResources(resources: KubernetesResource[]): Template {\n return new Template(resources);\n }\n\n /** Get all resources matching apiVersion + kind. */\n private _filterByGVK(apiVersion: string, kind: string): KubernetesResource[] {\n return this._resources.filter((r) => r.apiVersion === apiVersion && r.kind === kind);\n }\n\n /**\n * Assert the number of resources with the given apiVersion and kind.\n */\n resourceCountIs(apiVersion: string, kind: string, count: number): void {\n const matched = this._filterByGVK(apiVersion, kind);\n if (matched.length !== count) {\n throw new Error(\n `Expected ${count} resource(s) of type ${apiVersion}/${kind}, found ${matched.length}`,\n );\n }\n }\n\n /**\n * Assert that at least one resource of the given type matches the expected properties.\n * Uses deep-partial matching by default (actual can be a superset of expected).\n */\n hasResource(apiVersion: string, kind: string, props?: object): void {\n const matched = this._filterByGVK(apiVersion, kind);\n if (matched.length === 0) {\n throw new Error(`No resources found with type ${apiVersion}/${kind}`);\n }\n\n if (!props) return; // Just checking existence\n\n const allFailures: string[] = [];\n for (const resource of matched) {\n const result = deepPartialMatch(resource, props);\n if (result.pass) return; // At least one matches\n allFailures.push(\n ` Resource: ${JSON.stringify(resource.metadata?.name ?? '(unnamed)')}\\n ${result.failures.join('\\n ')}`,\n );\n }\n throw new Error(\n `No resource of type ${apiVersion}/${kind} matches the expected properties:\\n${allFailures.join('\\n')}`,\n );\n }\n\n /**\n * Assert that at least one resource of the given type has a spec matching the expected properties.\n * Shorthand for matching against the `spec` field only.\n */\n hasResourceSpec(apiVersion: string, kind: string, specProps: object): void {\n const matched = this._filterByGVK(apiVersion, kind);\n if (matched.length === 0) {\n throw new Error(`No resources found with type ${apiVersion}/${kind}`);\n }\n\n const allFailures: string[] = [];\n for (const resource of matched) {\n const result = deepPartialMatch(resource.spec ?? {}, specProps);\n if (result.pass) return;\n allFailures.push(\n ` Resource: ${JSON.stringify(resource.metadata?.name ?? '(unnamed)')}\\n ${result.failures.join('\\n ')}`,\n );\n }\n throw new Error(\n `No resource of type ${apiVersion}/${kind} has spec matching the expected properties:\\n${allFailures.join('\\n')}`,\n );\n }\n\n /**\n * Assert that at least one resource of the given type has metadata matching the expected properties.\n */\n hasResourceMetadata(apiVersion: string, kind: string, metaProps: object): void {\n const matched = this._filterByGVK(apiVersion, kind);\n if (matched.length === 0) {\n throw new Error(`No resources found with type ${apiVersion}/${kind}`);\n }\n\n const allFailures: string[] = [];\n for (const resource of matched) {\n const result = deepPartialMatch(resource.metadata ?? {}, metaProps);\n if (result.pass) return;\n allFailures.push(\n ` Resource: ${JSON.stringify(resource.metadata?.name ?? '(unnamed)')}\\n ${result.failures.join('\\n ')}`,\n );\n }\n throw new Error(\n `No resource of type ${apiVersion}/${kind} has metadata matching the expected properties:\\n${allFailures.join('\\n')}`,\n );\n }\n\n /**\n * Assert that ALL resources of the given type match the expected properties.\n */\n allResources(apiVersion: string, kind: string, props: object): void {\n const matched = this._filterByGVK(apiVersion, kind);\n if (matched.length === 0) {\n throw new Error(`No resources found with type ${apiVersion}/${kind}`);\n }\n\n const failures: string[] = [];\n for (const resource of matched) {\n const result = deepPartialMatch(resource, props);\n if (!result.pass) {\n failures.push(\n ` Resource: ${JSON.stringify(resource.metadata?.name ?? '(unnamed)')}\\n ${result.failures.join('\\n ')}`,\n );\n }\n }\n if (failures.length > 0) {\n throw new Error(\n `Not all resources of type ${apiVersion}/${kind} match:\\n${failures.join('\\n')}`,\n );\n }\n }\n\n /**\n * Find all resources of the given type that match the expected properties.\n * Returns matches — never throws.\n */\n findResources(apiVersion: string, kind: string, props?: object): KubernetesResource[] {\n const matched = this._filterByGVK(apiVersion, kind);\n if (!props) return matched;\n\n return matched.filter((resource) => {\n const result = deepPartialMatch(resource, props);\n return result.pass;\n });\n }\n\n /**\n * Serialize all resources to a JSON-compatible array for snapshot testing.\n *\n * @example\n * ```ts\n * expect(template.toJSON()).toMatchSnapshot();\n * ```\n */\n toJSON(): KubernetesResource[] {\n return structuredClone(this._resources);\n }\n}\n","import {\n type Composition,\n type DependencyGraph,\n type KubernetesResource,\n type Resource,\n resolveSequencing,\n} from '@xplane/core';\nimport { type SynthesizeOptions, Template } from './template.js';\n\n/** Result of a simulation run. */\nexport interface SimulationResult {\n /** Resources that are ready to emit (all dependencies satisfied). */\n emitted: Template;\n /** Resources that are blocked on unresolved dependencies. */\n blocked: Template;\n}\n\n// ─── Path Utilities (same logic as @xplane/function handler) ─────────\n\nfunction getNestedValue(obj: unknown, path: string): unknown {\n let current: unknown = obj;\n for (const segment of path.split('.')) {\n if (current === null || current === undefined || typeof current !== 'object') {\n return undefined;\n }\n current = (current as Record<string, unknown>)[segment];\n }\n return current;\n}\n\nfunction setNestedValue(obj: Record<string, unknown>, path: string, value: unknown): void {\n const segments = path.split('.');\n let current: Record<string, unknown> = obj;\n for (let i = 0; i < segments.length - 1; i++) {\n const seg = segments[i]!;\n if (!(seg in current) || typeof current[seg] !== 'object' || current[seg] === null) {\n current[seg] = {};\n }\n current = current[seg] as Record<string, unknown>;\n }\n const lastSeg = segments[segments.length - 1];\n if (lastSeg !== undefined) {\n current[lastSeg] = value;\n }\n}\n\n/**\n * Simulates the full rendering pipeline including observed state injection,\n * edge resolution, and sequencing — mimicking what `@xplane/function` does at runtime.\n *\n * @example\n * ```ts\n * const result = Simulator.synthesize(MyComposition, { xr: { ... } })\n * .withObserved([{ apiVersion: '...', kind: 'VPC', metadata: { name: 'vpc-abc' }, status: { atProvider: { vpcId: 'vpc-123' } } }])\n * .run();\n *\n * result.emitted.hasResourceSpec('ec2.aws.crossplane.io/v1beta1', 'Subnet', {\n * forProvider: { vpcId: 'vpc-123' },\n * });\n * ```\n */\nexport class Simulator {\n private readonly _composition: Composition;\n private _observed: KubernetesResource[] = [];\n\n private constructor(composition: Composition) {\n this._composition = composition;\n }\n\n /**\n * Ergonomic factory: injects XR/environment data, instantiates the\n * Composition class, and returns a Simulator ready for `.withObserved().run()`.\n */\n static synthesize(Ctor: new () => Composition, options: SynthesizeOptions = {}): Simulator {\n // Find base Composition class with _pendingXR\n let base = Ctor as unknown as Record<string, unknown>;\n while (base && !Object.hasOwn(base, '_pendingXR')) {\n base = Object.getPrototypeOf(base) as Record<string, unknown>;\n }\n if (!base) {\n throw new Error('Could not find Composition base class with _pendingXR');\n }\n\n const BaseComposition = base as unknown as {\n _pendingXR: Record<string, unknown> | undefined;\n _pendingEnvironment: Record<string, unknown> | undefined;\n };\n\n BaseComposition._pendingXR = options.xr;\n BaseComposition._pendingEnvironment = options.environment;\n try {\n const instance = new Ctor();\n return new Simulator(instance);\n } finally {\n BaseComposition._pendingXR = undefined;\n BaseComposition._pendingEnvironment = undefined;\n }\n }\n\n /**\n * Build a Simulator from an already-instantiated Composition.\n */\n static fromComposition(composition: Composition): Simulator {\n return new Simulator(composition);\n }\n\n /**\n * Provide observed (cluster) state for resources.\n * Each resource is matched to a declared resource by its construct path\n * (i.e., `metadata.name` in observed state maps to `resource.path` in the composition).\n */\n withObserved(resources: KubernetesResource[]): this {\n this._observed = resources;\n return this;\n }\n\n /**\n * Run the simulation: inject observed state, resolve edges, determine sequencing.\n */\n run(): SimulationResult {\n const composition = this._composition;\n const resources = (composition as unknown as { resources: ReadonlyMap<string, ResourceLike> })\n .resources;\n const collector = (\n composition as unknown as { collector: { edges: ReadonlyArray<DependencyEdgeLike> } }\n ).collector;\n const graph = (composition as unknown as { graph: DependencyGraph }).graph;\n\n // Build observed map keyed by resource path (same as handler)\n const observedMap = new Map<string, KubernetesResource>();\n for (const obs of this._observed) {\n const name = obs.metadata?.name;\n if (name) {\n observedMap.set(name, obs);\n }\n }\n\n // Add edges to graph\n graph.addEdges(collector.edges);\n\n // Feed observed state into resources\n for (const [path, resource] of resources) {\n const observed = observedMap.get(path);\n if (observed) {\n resource.setObserved(observed);\n }\n }\n\n // Resolve cross-resource edge values from observed state\n for (const edge of collector.edges) {\n const observed = observedMap.get(edge.from.id);\n if (!observed) continue;\n\n const value = getNestedValue(observed, edge.fromPath);\n if (value === undefined || value === null) continue;\n\n const targetResource = resources.get(edge.to.id);\n if (!targetResource) continue;\n\n const toPath = edge.toPath;\n if (toPath.startsWith('spec.')) {\n setNestedValue(\n targetResource.spec as Record<string, unknown>,\n toPath.slice('spec.'.length),\n value,\n );\n }\n }\n\n // Resolve sequencing\n const sequencing = resolveSequencing(\n resources as unknown as ReadonlyMap<string, Resource>,\n graph as DependencyGraph,\n observedMap,\n );\n\n return {\n emitted: Template.fromResources(sequencing.emit.map((r) => r.toDesired())),\n blocked: Template.fromResources(sequencing.blocked.map((r) => r.toDesired())),\n };\n }\n}\n\n// ─── Internal type helpers (avoid importing private types) ───────────\n\ninterface ResourceLike {\n path: string;\n spec: Record<string, unknown>;\n setObserved(observed: KubernetesResource): void;\n toDesired(): KubernetesResource;\n}\n\ninterface DependencyEdgeLike {\n from: { id: string };\n fromPath: string;\n to: { id: string };\n toPath: string;\n}\n"],"mappings":";;;AACA,MAAa,UAAU,OAAO,IAAI,yBAAyB;;AAiB3D,SAAgB,UAAU,OAAkC;CAC1D,OACE,OAAO,UAAU,YACjB,UAAU,QACV,WAAW,SACV,MAAkB,aAAa;AAEpC;AAEA,SAAS,OAAoB;CAC3B,OAAO;EAAE,MAAM;EAAM,UAAU,CAAC;CAAE;AACpC;AAEA,SAAS,KAAK,SAA8B;CAC1C,OAAO;EAAE,MAAM;EAAO,UAAU,CAAC,OAAO;CAAE;AAC5C;AAEA,SAAS,MAAM,SAAqC;CAClD,MAAM,WAAW,QAAQ,SAAS,MAAM,EAAE,QAAQ;CAClD,OAAO;EAAE,MAAM,SAAS,WAAW;EAAG;CAAS;AACjD;;;;;;;AAQA,SAAgB,UAAU,QAAiB,UAAmB,OAAO,IAAiB;CACpF,IAAI,UAAU,QAAQ,GAAG;EACvB,MAAM,SAAS,SAAS,KAAK,MAAM;EACnC,IAAI,CAAC,OAAO,MACV,OAAO;GAAE,MAAM;GAAO,UAAU,OAAO,SAAS,KAAK,MAAO,OAAO,GAAG,KAAK,IAAI,MAAM,CAAE;EAAE;EAE3F,OAAO,KAAK;CACd;CAGA,IAAI,aAAa,QAAQ,aAAa,KAAA,KAAa,OAAO,aAAa,UAAU;EAC/E,IAAI,WAAW,UAAU,OAAO,KAAK;EACrC,OAAO,KACL,OACI,GAAG,KAAK,aAAa,KAAK,UAAU,QAAQ,EAAE,QAAQ,KAAK,UAA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AC3B,IAAI,MACF,YAAY,IAAI,MAAM,GAAG;EAE7B;EAGA,MAAM,SAAS,UAAU,KAAK;EAG9B,KAAK,MAAM,CAAC,MAAM,aAAa,WAAW;GACxC,MAAM,WAAW,YAAY,IAAI,IAAI;GACrC,IAAI,UACF,SAAS,YAAY,QAAQ;EAEjC;EAGA,KAAK,MAAM,QAAQ,UAAU,OAAO;GAClC,MAAM,WAAW,YAAY,IAAI,KAAK,KAAK,EAAE;GAC7C,IAAI,CAAC,UAAU;GAEf,MAAM,QAAQ,eAAe,UAAU,KAAK,QAAQ;GACpD,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM;GAE3C,MAAM,iBAAiB,UAAU,IAAI,KAAK,GAAG,EAAE;GAC/C,IAAI,CAAC,gBAAgB;GAErB,MAAM,SAAS,KAAK;GACpB,IAAI,OAAO,WAAW,OAAO,GAC3B,eACE,eAAe,MACf,OAAO,MAAM,CAAc,GAC3B,KACF;EAEJ;EAGA,MAAM,aAAa,kBACjB,WACA,OACA,WACF;EAEA,OAAO;GACL,SAAS,SAAS,cAAc,WAAW,KAAK,KAAK,MAAM,EAAE,UAAU,CAAC,CAAC;GACzE,SAAS,SAAS,cAAc,WAAW,QAAQ,KAAK,MAAM,EAAE,UAAU,CAAC,CAAC;EAC9E;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/assertions/match.ts","../../src/assertions/template.ts","../../src/assertions/simulator.ts"],"sourcesContent":["/** Symbol used to identify Matcher instances. */\nexport const MATCHER = Symbol.for('xplane.devtools.matcher');\n\n/** Result of a match operation. */\nexport interface MatchResult {\n /** Whether the match succeeded. */\n pass: boolean;\n /** Human-readable failure messages (empty if pass is true). */\n failures: string[];\n}\n\n/** Interface for custom matchers. */\nexport interface Matcher {\n readonly [MATCHER]: true;\n test(actual: unknown): MatchResult;\n}\n\n/** Check whether a value is a Matcher instance. */\nexport function isMatcher(value: unknown): value is Matcher {\n return (\n typeof value === 'object' &&\n value !== null &&\n MATCHER in value &&\n (value as Matcher)[MATCHER] === true\n );\n}\n\nfunction pass(): MatchResult {\n return { pass: true, failures: [] };\n}\n\nfunction fail(message: string): MatchResult {\n return { pass: false, failures: [message] };\n}\n\nfunction merge(results: MatchResult[]): MatchResult {\n const failures = results.flatMap((r) => r.failures);\n return { pass: failures.length === 0, failures };\n}\n\n/**\n * Deep-match `actual` against `expected`.\n * - If `expected` is a Matcher, delegates to its `.test()`.\n * - Literal objects are matched recursively (deep-partial by default via objectLike semantics at the top level is handled by the caller).\n * - This function performs EXACT matching — partial matching is handled by ObjectLikeMatcher.\n */\nexport function deepMatch(actual: unknown, expected: unknown, path = ''): MatchResult {\n if (isMatcher(expected)) {\n const result = expected.test(actual);\n if (!result.pass) {\n return { pass: false, failures: result.failures.map((f) => (path ? `${path}: ${f}` : f)) };\n }\n return pass();\n }\n\n // Null / undefined / primitives\n if (expected === null || expected === undefined || typeof expected !== 'object') {\n if (actual === expected) return pass();\n return fail(\n path\n ? `${path}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`\n : `expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`,\n );\n }\n\n // Arrays\n if (Array.isArray(expected)) {\n if (!Array.isArray(actual)) {\n return fail(`${path || 'value'}: expected an array, got ${typeof actual}`);\n }\n if (actual.length !== expected.length) {\n return fail(\n `${path || 'value'}: expected array of length ${expected.length}, got length ${actual.length}`,\n );\n }\n const results: MatchResult[] = [];\n for (let i = 0; i < expected.length; i++) {\n results.push(deepMatch(actual[i], expected[i], `${path}[${i}]`));\n }\n return merge(results);\n }\n\n // Objects (exact match — all keys in expected must match, no extra keys allowed)\n if (typeof actual !== 'object' || actual === null || Array.isArray(actual)) {\n return fail(`${path || 'value'}: expected an object, got ${JSON.stringify(actual)}`);\n }\n const expectedObj = expected as Record<string, unknown>;\n const actualObj = actual as Record<string, unknown>;\n const results: MatchResult[] = [];\n\n // Check expected keys exist and match\n for (const key of Object.keys(expectedObj)) {\n results.push(deepMatch(actualObj[key], expectedObj[key], path ? `${path}.${key}` : key));\n }\n // Check no extra keys in actual\n for (const key of Object.keys(actualObj)) {\n if (!(key in expectedObj)) {\n results.push(fail(`${path ? `${path}.${key}` : key}: unexpected key`));\n }\n }\n return merge(results);\n}\n\n/**\n * Deep-partial match: all keys in `expected` must match in `actual`, but\n * `actual` may have additional keys at any level.\n */\nexport function deepPartialMatch(actual: unknown, expected: unknown, path = ''): MatchResult {\n if (isMatcher(expected)) {\n const result = expected.test(actual);\n if (!result.pass) {\n return { pass: false, failures: result.failures.map((f) => (path ? `${path}: ${f}` : f)) };\n }\n return pass();\n }\n\n if (expected === null || expected === undefined || typeof expected !== 'object') {\n if (actual === expected) return pass();\n return fail(\n path\n ? `${path}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`\n : `expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`,\n );\n }\n\n if (Array.isArray(expected)) {\n if (!Array.isArray(actual)) {\n return fail(`${path || 'value'}: expected an array, got ${typeof actual}`);\n }\n if (actual.length !== expected.length) {\n return fail(\n `${path || 'value'}: expected array of length ${expected.length}, got length ${actual.length}`,\n );\n }\n const results: MatchResult[] = [];\n for (let i = 0; i < expected.length; i++) {\n results.push(deepPartialMatch(actual[i], expected[i], `${path}[${i}]`));\n }\n return merge(results);\n }\n\n if (typeof actual !== 'object' || actual === null || Array.isArray(actual)) {\n return fail(`${path || 'value'}: expected an object, got ${JSON.stringify(actual)}`);\n }\n\n const expectedObj = expected as Record<string, unknown>;\n const actualObj = actual as Record<string, unknown>;\n const results: MatchResult[] = [];\n\n // Only check keys present in expected — actual may have extras\n for (const key of Object.keys(expectedObj)) {\n if (!(key in actualObj)) {\n results.push(fail(`${path ? `${path}.${key}` : key}: key not found in actual`));\n } else {\n results.push(\n deepPartialMatch(actualObj[key], expectedObj[key], path ? `${path}.${key}` : key),\n );\n }\n }\n return merge(results);\n}\n\n// ─── Matcher Implementations ────────────────────────────────────────────\n\nclass ObjectLikeMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n constructor(private readonly pattern: object) {}\n test(actual: unknown): MatchResult {\n return deepPartialMatch(actual, this.pattern);\n }\n}\n\nclass ObjectEqualsMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n constructor(private readonly pattern: object) {}\n test(actual: unknown): MatchResult {\n return deepMatch(actual, this.pattern);\n }\n}\n\nclass ArrayWithMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n constructor(private readonly items: unknown[]) {}\n test(actual: unknown): MatchResult {\n if (!Array.isArray(actual)) {\n return fail(`expected an array, got ${typeof actual}`);\n }\n // Each item in `this.items` must appear in `actual` in order (not necessarily contiguous)\n let searchStart = 0;\n for (let i = 0; i < this.items.length; i++) {\n let found = false;\n for (let j = searchStart; j < actual.length; j++) {\n const r = deepPartialMatch(actual[j], this.items[i]);\n if (r.pass) {\n searchStart = j + 1;\n found = true;\n break;\n }\n }\n if (!found) {\n return fail(\n `arrayWith: could not find match for item at index ${i}: ${JSON.stringify(this.items[i])}`,\n );\n }\n }\n return pass();\n }\n}\n\nclass ArrayEqualsMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n constructor(private readonly items: unknown[]) {}\n test(actual: unknown): MatchResult {\n return deepMatch(actual, this.items);\n }\n}\n\nclass StringLikeRegexpMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n private readonly regex: RegExp;\n constructor(pattern: string | RegExp) {\n this.regex = typeof pattern === 'string' ? new RegExp(pattern) : pattern;\n }\n test(actual: unknown): MatchResult {\n if (typeof actual !== 'string') {\n return fail(`expected a string, got ${typeof actual}`);\n }\n if (!this.regex.test(actual)) {\n return fail(`expected string matching ${this.regex}, got \"${actual}\"`);\n }\n return pass();\n }\n}\n\nclass AbsentMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n test(actual: unknown): MatchResult {\n if (actual !== undefined) {\n return fail(`expected absent (undefined), got ${JSON.stringify(actual)}`);\n }\n return pass();\n }\n}\n\nclass AnyValueMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n test(actual: unknown): MatchResult {\n if (actual === null || actual === undefined) {\n return fail(`expected any value, got ${actual}`);\n }\n return pass();\n }\n}\n\nclass NotMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n constructor(private readonly pattern: unknown) {}\n test(actual: unknown): MatchResult {\n const inner = isMatcher(this.pattern)\n ? this.pattern.test(actual)\n : deepPartialMatch(actual, this.pattern);\n if (inner.pass) {\n return fail(`expected NOT to match, but matched: ${JSON.stringify(actual)}`);\n }\n return pass();\n }\n}\n\n/**\n * Factory for composable matchers used in assertions.\n *\n * @example\n * ```ts\n * template.hasResourceSpec('v1', 'ConfigMap', {\n * data: Match.objectLike({ key: 'value' }),\n * });\n * ```\n */\nexport class Match {\n private constructor() {}\n\n /** Deep-partial object match — actual may be a superset of pattern. */\n static objectLike(pattern: object): Matcher {\n return new ObjectLikeMatcher(pattern);\n }\n\n /** Exact object match — actual must equal pattern exactly (same keys, same values). */\n static objectEquals(pattern: object): Matcher {\n return new ObjectEqualsMatcher(pattern);\n }\n\n /** Array subset match — items must appear in actual in order. */\n static arrayWith(items: unknown[]): Matcher {\n return new ArrayWithMatcher(items);\n }\n\n /** Exact array match — actual must equal items exactly. */\n static arrayEquals(items: unknown[]): Matcher {\n return new ArrayEqualsMatcher(items);\n }\n\n /** String regex match. */\n static stringLikeRegexp(pattern: string | RegExp): Matcher {\n return new StringLikeRegexpMatcher(pattern);\n }\n\n /** Asserts the value is absent (undefined). */\n static absent(): Matcher {\n return new AbsentMatcher();\n }\n\n /** Asserts any non-null/non-undefined value is present. */\n static anyValue(): Matcher {\n return new AnyValueMatcher();\n }\n\n /** Inverts a match — asserts the value does NOT match the given pattern. */\n static not(pattern: unknown): Matcher {\n return new NotMatcher(pattern);\n }\n}\n","import type { Composition, KubernetesResource } from '@xplane/core';\nimport { deepPartialMatch } from './match.js';\n\n/** Options for `Template.synthesize()`. */\nexport interface SynthesizeOptions {\n /** XR (composite resource) data to inject before instantiation. */\n xr?: Record<string, unknown>;\n /** Environment data to inject before instantiation. */\n environment?: Record<string, unknown>;\n}\n\n/**\n * A snapshot of rendered resources from a Composition, providing\n * assertion methods for unit testing.\n *\n * @example\n * ```ts\n * const template = Template.synthesize(MyComposition, {\n * xr: { spec: { region: 'us-east-1' } },\n * });\n * template.hasResourceSpec('ec2.aws.crossplane.io/v1beta1', 'VPC', {\n * forProvider: { region: 'us-east-1' },\n * });\n * ```\n */\nexport class Template {\n private readonly _resources: KubernetesResource[];\n\n private constructor(resources: KubernetesResource[]) {\n this._resources = resources;\n }\n\n /**\n * Ergonomic factory: injects XR/environment data and instantiates\n * the Composition class, then builds a Template from the rendered resources.\n *\n * Users never need to touch `Composition._pendingXR` directly.\n */\n static synthesize(Ctor: new () => Composition, options: SynthesizeOptions = {}): Template {\n // Walk up prototype chain to find the base Composition class with _pendingXR\n let base = Ctor as unknown as Record<string, unknown>;\n while (base && !Object.hasOwn(base, '_pendingXR')) {\n base = Object.getPrototypeOf(base) as Record<string, unknown>;\n }\n if (!base) {\n throw new Error('Could not find Composition base class with _pendingXR');\n }\n\n const BaseComposition = base as unknown as {\n _pendingXR: Record<string, unknown> | undefined;\n _pendingEnvironment: Record<string, unknown> | undefined;\n };\n\n BaseComposition._pendingXR = options.xr;\n BaseComposition._pendingEnvironment = options.environment;\n try {\n const instance = new Ctor();\n return Template.fromComposition(instance);\n } finally {\n BaseComposition._pendingXR = undefined;\n BaseComposition._pendingEnvironment = undefined;\n }\n }\n\n /**\n * Build a Template from an already-instantiated Composition.\n */\n static fromComposition(composition: Composition): Template {\n const resources = [\n ...(\n composition as unknown as {\n resources: ReadonlyMap<string, { toDesired(): KubernetesResource }>;\n }\n ).resources.values(),\n ].map((r) => r.toDesired());\n return new Template(resources);\n }\n\n /**\n * Build a Template from a pre-built array of KubernetesResource objects.\n * Used internally by Simulator.\n */\n static fromResources(resources: KubernetesResource[]): Template {\n return new Template(resources);\n }\n\n /** Get all resources matching apiVersion + kind. */\n private _filterByGVK(apiVersion: string, kind: string): KubernetesResource[] {\n return this._resources.filter((r) => r.apiVersion === apiVersion && r.kind === kind);\n }\n\n /**\n * Assert the number of resources with the given apiVersion and kind.\n */\n resourceCountIs(apiVersion: string, kind: string, count: number): void {\n const matched = this._filterByGVK(apiVersion, kind);\n if (matched.length !== count) {\n throw new Error(\n `Expected ${count} resource(s) of type ${apiVersion}/${kind}, found ${matched.length}`,\n );\n }\n }\n\n /**\n * Assert that at least one resource of the given type matches the expected properties.\n * Uses deep-partial matching by default (actual can be a superset of expected).\n */\n hasResource(apiVersion: string, kind: string, props?: object): void {\n const matched = this._filterByGVK(apiVersion, kind);\n if (matched.length === 0) {\n throw new Error(`No resources found with type ${apiVersion}/${kind}`);\n }\n\n if (!props) return; // Just checking existence\n\n const allFailures: string[] = [];\n for (const resource of matched) {\n const result = deepPartialMatch(resource, props);\n if (result.pass) return; // At least one matches\n allFailures.push(\n ` Resource: ${JSON.stringify(resource.metadata?.name ?? '(unnamed)')}\\n ${result.failures.join('\\n ')}`,\n );\n }\n throw new Error(\n `No resource of type ${apiVersion}/${kind} matches the expected properties:\\n${allFailures.join('\\n')}`,\n );\n }\n\n /**\n * Assert that at least one resource of the given type has a spec matching the expected properties.\n * Shorthand for matching against the `spec` field only.\n */\n hasResourceSpec(apiVersion: string, kind: string, specProps: object): void {\n const matched = this._filterByGVK(apiVersion, kind);\n if (matched.length === 0) {\n throw new Error(`No resources found with type ${apiVersion}/${kind}`);\n }\n\n const allFailures: string[] = [];\n for (const resource of matched) {\n const result = deepPartialMatch(resource.spec ?? {}, specProps);\n if (result.pass) return;\n allFailures.push(\n ` Resource: ${JSON.stringify(resource.metadata?.name ?? '(unnamed)')}\\n ${result.failures.join('\\n ')}`,\n );\n }\n throw new Error(\n `No resource of type ${apiVersion}/${kind} has spec matching the expected properties:\\n${allFailures.join('\\n')}`,\n );\n }\n\n /**\n * Assert that at least one resource of the given type has metadata matching the expected properties.\n */\n hasResourceMetadata(apiVersion: string, kind: string, metaProps: object): void {\n const matched = this._filterByGVK(apiVersion, kind);\n if (matched.length === 0) {\n throw new Error(`No resources found with type ${apiVersion}/${kind}`);\n }\n\n const allFailures: string[] = [];\n for (const resource of matched) {\n const result = deepPartialMatch(resource.metadata ?? {}, metaProps);\n if (result.pass) return;\n allFailures.push(\n ` Resource: ${JSON.stringify(resource.metadata?.name ?? '(unnamed)')}\\n ${result.failures.join('\\n ')}`,\n );\n }\n throw new Error(\n `No resource of type ${apiVersion}/${kind} has metadata matching the expected properties:\\n${allFailures.join('\\n')}`,\n );\n }\n\n /**\n * Assert that ALL resources of the given type match the expected properties.\n */\n allResources(apiVersion: string, kind: string, props: object): void {\n const matched = this._filterByGVK(apiVersion, kind);\n if (matched.length === 0) {\n throw new Error(`No resources found with type ${apiVersion}/${kind}`);\n }\n\n const failures: string[] = [];\n for (const resource of matched) {\n const result = deepPartialMatch(resource, props);\n if (!result.pass) {\n failures.push(\n ` Resource: ${JSON.stringify(resource.metadata?.name ?? '(unnamed)')}\\n ${result.failures.join('\\n ')}`,\n );\n }\n }\n if (failures.length > 0) {\n throw new Error(\n `Not all resources of type ${apiVersion}/${kind} match:\\n${failures.join('\\n')}`,\n );\n }\n }\n\n /**\n * Find all resources of the given type that match the expected properties.\n * Returns matches — never throws.\n */\n findResources(apiVersion: string, kind: string, props?: object): KubernetesResource[] {\n const matched = this._filterByGVK(apiVersion, kind);\n if (!props) return matched;\n\n return matched.filter((resource) => {\n const result = deepPartialMatch(resource, props);\n return result.pass;\n });\n }\n\n /**\n * Serialize all resources to a JSON-compatible array for snapshot testing.\n *\n * @example\n * ```ts\n * expect(template.toJSON()).toMatchSnapshot();\n * ```\n */\n toJSON(): KubernetesResource[] {\n return structuredClone(this._resources);\n }\n}\n","import {\n type Composition,\n type DependencyGraph,\n type KubernetesResource,\n type Resource,\n resolveSequencing,\n} from '@xplane/core';\nimport { type SynthesizeOptions, Template } from './template.js';\n\n/** Result of a simulation run. */\nexport interface SimulationResult {\n /** Resources that are ready to emit (all dependencies satisfied). */\n emitted: Template;\n /** Resources that are blocked on unresolved dependencies. */\n blocked: Template;\n /** Conditions that would be set on the XR status (e.g., missing existing resources). */\n conditions: Array<{ type: string; status: string; reason: string; message: string }>;\n}\n\n// ─── Path Utilities (same logic as @xplane/function handler) ─────────\n\nfunction getNestedValue(obj: unknown, path: string): unknown {\n let current: unknown = obj;\n for (const segment of path.split('.')) {\n if (current === null || current === undefined || typeof current !== 'object') {\n return undefined;\n }\n current = (current as Record<string, unknown>)[segment];\n }\n return current;\n}\n\nfunction setNestedValue(obj: Record<string, unknown>, path: string, value: unknown): void {\n const segments = path.split('.');\n let current: Record<string, unknown> = obj;\n for (let i = 0; i < segments.length - 1; i++) {\n const seg = segments[i]!;\n if (!(seg in current) || typeof current[seg] !== 'object' || current[seg] === null) {\n current[seg] = {};\n }\n current = current[seg] as Record<string, unknown>;\n }\n const lastSeg = segments[segments.length - 1];\n if (lastSeg !== undefined) {\n current[lastSeg] = value;\n }\n}\n\n/**\n * Simulates the full rendering pipeline including observed state injection,\n * edge resolution, and sequencing — mimicking what `@xplane/function` does at runtime.\n *\n * @example\n * ```ts\n * const result = Simulator.synthesize(MyComposition, { xr: { ... } })\n * .withObserved([{ apiVersion: '...', kind: 'VPC', metadata: { name: 'vpc-abc' }, status: { atProvider: { vpcId: 'vpc-123' } } }])\n * .run();\n *\n * result.emitted.hasResourceSpec('ec2.aws.crossplane.io/v1beta1', 'Subnet', {\n * forProvider: { vpcId: 'vpc-123' },\n * });\n * ```\n */\nexport class Simulator {\n private readonly _composition: Composition;\n private _observed: KubernetesResource[] = [];\n private _existing: Record<string, KubernetesResource> = {};\n\n private constructor(composition: Composition) {\n this._composition = composition;\n }\n\n /**\n * Ergonomic factory: injects XR/environment data, instantiates the\n * Composition class, and returns a Simulator ready for `.withObserved().run()`.\n */\n static synthesize(Ctor: new () => Composition, options: SynthesizeOptions = {}): Simulator {\n // Find base Composition class with _pendingXR\n let base = Ctor as unknown as Record<string, unknown>;\n while (base && !Object.hasOwn(base, '_pendingXR')) {\n base = Object.getPrototypeOf(base) as Record<string, unknown>;\n }\n if (!base) {\n throw new Error('Could not find Composition base class with _pendingXR');\n }\n\n const BaseComposition = base as unknown as {\n _pendingXR: Record<string, unknown> | undefined;\n _pendingEnvironment: Record<string, unknown> | undefined;\n };\n\n BaseComposition._pendingXR = options.xr;\n BaseComposition._pendingEnvironment = options.environment;\n try {\n const instance = new Ctor();\n return new Simulator(instance);\n } finally {\n BaseComposition._pendingXR = undefined;\n BaseComposition._pendingEnvironment = undefined;\n }\n }\n\n /**\n * Build a Simulator from an already-instantiated Composition.\n */\n static fromComposition(composition: Composition): Simulator {\n return new Simulator(composition);\n }\n\n /**\n * Provide observed (cluster) state for resources.\n * Each resource is matched to a declared resource by its construct path\n * (i.e., `metadata.name` in observed state maps to `resource.path` in the composition).\n */\n withObserved(resources: KubernetesResource[]): this {\n this._observed = resources;\n return this;\n }\n\n /**\n * Provide existing resource data keyed by refKey.\n * The refKey format is `apiVersion/kind/[namespace/]name`\n * (e.g., `\"example.io/v1/Project/my-project\"` or `\"v1/Secret/default/db-creds\"`).\n *\n * This simulates what Crossplane would return via the Required Resources mechanism.\n */\n withExisting(resources: Record<string, KubernetesResource>): this {\n this._existing = resources;\n return this;\n }\n\n /**\n * Run the simulation: inject observed state, resolve edges, determine sequencing.\n */\n run(): SimulationResult {\n const composition = this._composition;\n const resources = (composition as unknown as { resources: ReadonlyMap<string, ResourceLike> })\n .resources;\n const existingResources = (\n composition as unknown as { existingResources: ReadonlyMap<string, ExistingResourceLike> }\n ).existingResources;\n const collector = (\n composition as unknown as { collector: { edges: ReadonlyArray<DependencyEdgeLike> } }\n ).collector;\n const graph = (composition as unknown as { graph: DependencyGraph }).graph;\n\n // Build observed map keyed by resource path (same as handler)\n const observedMap = new Map<string, KubernetesResource>();\n for (const obs of this._observed) {\n const name = obs.metadata?.name;\n if (name) {\n observedMap.set(name, obs);\n }\n }\n\n // Add edges to graph\n graph.addEdges(collector.edges);\n\n // Feed observed state into resources\n for (const [path, resource] of resources) {\n const observed = observedMap.get(path);\n if (observed) {\n resource.setObserved(observed);\n }\n }\n\n // Resolve existing resources from the withExisting() map\n const conditions: SimulationResult['conditions'] = [];\n for (const [refKey, existingResource] of existingResources) {\n const data = this._existing[refKey];\n if (data) {\n existingResource.setObservedFull(data);\n observedMap.set(existingResource.path, data);\n } else {\n // Existing resource not provided — emit condition\n const ref = existingResource.existingRef;\n const name = typeof ref?.name === 'string' ? ref.name : '<unresolved>';\n const kind = ref?.kind ?? 'Unknown';\n conditions.push({\n type: 'Ready',\n status: 'False',\n reason: 'MissingRequiredResource',\n message: `Required existing resource ${kind}/${name} not found in cluster`,\n });\n }\n }\n\n // Resolve cross-resource edge values from observed state\n for (const edge of collector.edges) {\n const observed = observedMap.get(edge.from.id);\n if (!observed) continue;\n\n const value = getNestedValue(observed, edge.fromPath);\n if (value === undefined || value === null) continue;\n\n const targetResource = resources.get(edge.to.id);\n if (!targetResource) continue;\n\n const toPath = edge.toPath;\n if (toPath.startsWith('spec.')) {\n setNestedValue(\n targetResource.spec as Record<string, unknown>,\n toPath.slice('spec.'.length),\n value,\n );\n }\n }\n\n // Resolve sequencing\n const sequencing = resolveSequencing(\n resources as unknown as ReadonlyMap<string, Resource>,\n graph as DependencyGraph,\n observedMap,\n );\n\n return {\n emitted: Template.fromResources(sequencing.emit.map((r) => r.toDesired())),\n blocked: Template.fromResources(sequencing.blocked.map((r) => r.toDesired())),\n conditions,\n };\n }\n}\n\n// ─── Internal type helpers (avoid importing private types) ───────────\n\ninterface ResourceLike {\n path: string;\n spec: Record<string, unknown>;\n setObserved(observed: KubernetesResource): void;\n toDesired(): KubernetesResource;\n}\n\ninterface ExistingResourceLike {\n path: string;\n existingRef:\n | { apiVersion: string; kind: string; name: unknown; namespace?: string; refKey: string }\n | undefined;\n setObservedFull(resource: KubernetesResource): void;\n}\n\ninterface DependencyEdgeLike {\n from: { id: string };\n fromPath: string;\n to: { id: string };\n toPath: string;\n}\n"],"mappings":";;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,CAAC,QAAQ,qBAAqB,mBAAmB;GAC1D,MAAM,OAAO,KAAK,UAAU;GAC5B,IAAI,MAAM;IACR,iBAAiB,gBAAgB,IAAI;IACrC,YAAY,IAAI,iBAAiB,MAAM,IAAI;GAC7C,OAAO;IAEL,MAAM,MAAM,iBAAiB;IAC7B,MAAM,OAAO,OAAO,KAAK,SAAS,WAAW,IAAI,OAAO;IACxD,MAAM,OAAO,KAAK,QAAQ;IAC1B,WAAW,KAAK;KACd,MAAM;KACN,QAAQ;KACR,QAAQ;KACR,SAAS,8BAA8B,KAAK,GAAG,KAAK;IACtD,CAAC;GACH;EACF;EAGA,KAAK,MAAM,QAAQ,UAAU,OAAO;GAClC,MAAM,WAAW,YAAY,IAAI,KAAK,KAAK,EAAE;GAC7C,IAAI,CAAC,UAAU;GAEf,MAAM,QAAQ,eAAe,UAAU,KAAK,QAAQ;GACpD,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM;GAE3C,MAAM,iBAAiB,UAAU,IAAI,KAAK,GAAG,EAAE;GAC/C,IAAI,CAAC,gBAAgB;GAErB,MAAM,SAAS,KAAK;GACpB,IAAI,OAAO,WAAW,OAAO,GAC3B,eACE,eAAe,MACf,OAAO,MAAM,CAAc,GAC3B,KACF;EAEJ;EAGA,MAAM,aAAa,kBACjB,WACA,OACA,WACF;EAEA,OAAO;GACL,SAAS,SAAS,cAAc,WAAW,KAAK,KAAK,MAAM,EAAE,UAAU,CAAC,CAAC;GACzE,SAAS,SAAS,cAAc,WAAW,QAAQ,KAAK,MAAM,EAAE,UAAU,CAAC,CAAC;GAC5E;EACF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xplane/devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Developer tools and testing utilities for @xplane/core compositions",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"tsdown": "^0.22.0",
|
|
27
27
|
"typescript": "6.0.3",
|
|
28
28
|
"vitest": "4.1.6",
|
|
29
|
-
"@xplane/core": "0.
|
|
29
|
+
"@xplane/core": "0.15.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"constructs": "^10.0.0",
|
|
33
|
-
"@xplane/core": "0.
|
|
33
|
+
"@xplane/core": "0.15.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsdown",
|