@xplane/devtools 1.1.0 → 1.3.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.
|
@@ -1 +1 @@
|
|
|
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;;;;;;;;;;;cA2SvB,KAAA;EAAA,QACJ,WAAA,CAAA;EAGW;EAAA,OAAX,UAAA,CAAW,OAAA,WAAkB,OAAA;EAK7B;EAAA,OAAA,YAAA,CAAa,OAAA,WAAkB,OAAA;EAAA;EAAA,OAK/B,SAAA,CAAU,KAAA,cAAmB,OAAA;EAAnB;EAAA,OAKV,WAAA,CAAY,KAAA,cAAmB,OAAA;EAA/B;EAAA,OAKA,gBAAA,CAAiB,OAAA,WAAkB,MAAA,GAAS,OAAA;EALb;EAAA,OAU/B,MAAA,CAAA,GAAU,OAAA;EALyB;EAAA,OAUnC,QAAA,CAAA,GAAY,OAAA;EAVgC;EAAA,OAe5C,GAAA,CAAI,OAAA,YAAmB,OAAA;EAVb;;;;EAAA,OAkBV,OAAA,CAAQ,QAAA;IAAa,MAAA;IAAiB,IAAA;EAAA,IAAkB,OAAA;AAAA;;;;UCtVhD,iBAAA;EDjBJ;ECmBX,EAAA,GAAK,MAAA;;EAEL,WAAA,GAAc,MAAM;AAAA;ADlBtB;;;;AAAA,cCyBa,QAAA;EAAA,iBACM,UAAA;EAAA,QAEV,WAAA,CAAA;;;;;;;;SAWA,UAAA,yCAAA,CACL,IAAA,YAAgB,WAAA,CAAY,KAAA,EAAO,OAAA,EAAS,QAAA,GAC5C,OAAA,GAAS,iBAAA,GACR,QAAA;ED2QQ;;;;;;;EAAA,
|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;EE5N9B,YAAA,CAAa,SAAA,EAAW,MAAA,SAAe,MAAA;;;;EAQvC,GAAA,CAAA,GAAO,gBAAA;AAAA"}
|
|
@@ -281,6 +281,7 @@ var Template = class Template {
|
|
|
281
281
|
xr,
|
|
282
282
|
pipelineContext,
|
|
283
283
|
requiredResources: /* @__PURE__ */ new Map(),
|
|
284
|
+
observedComposed: /* @__PURE__ */ new Map(),
|
|
284
285
|
graph,
|
|
285
286
|
collector
|
|
286
287
|
};
|
|
@@ -478,6 +479,7 @@ var Simulator = class Simulator {
|
|
|
478
479
|
xr,
|
|
479
480
|
pipelineContext,
|
|
480
481
|
requiredResources: new Map(Object.entries(existing)),
|
|
482
|
+
observedComposed: /* @__PURE__ */ new Map(),
|
|
481
483
|
graph,
|
|
482
484
|
collector
|
|
483
485
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["PENDING_VALUE"],"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\nconst PENDING_VALUE = Symbol.for('xplane.devtools.pending');\n\nclass PendingMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n constructor(private readonly expected?: { source?: string; path?: string }) {}\n test(actual: unknown): MatchResult {\n if (\n typeof actual !== 'object' ||\n actual === null ||\n (actual as Record<symbol, unknown>)[PENDING_VALUE] !== true\n ) {\n return fail(`expected a pending value, got ${JSON.stringify(actual)}`);\n }\n const pending = actual as { source: string; path: string };\n // For PendingTemplate (compound), source/path are comma-joined; match if substring present\n if (this.expected?.source) {\n const sources = pending.source.split(',');\n if (\n !sources.some((s) => s === this.expected!.source || s.endsWith(`/${this.expected!.source}`))\n ) {\n return fail(\n `expected pending from source \"${this.expected.source}\", got \"${pending.source}\"`,\n );\n }\n }\n if (this.expected?.path) {\n const paths = pending.path.split(',');\n if (!paths.includes(this.expected.path)) {\n return fail(`expected pending path \"${this.expected.path}\", got \"${pending.path}\"`);\n }\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 /**\n * Asserts the value is a pending dependency (unresolved cross-resource reference).\n * Optionally match the source resource and/or path.\n */\n static pending(expected?: { source?: string; path?: string }): Matcher {\n return new PendingMatcher(expected);\n }\n}\n","import {\n type Composition,\n type CompositionContext,\n compositionStorage,\n createTokenRegistry,\n DependencyGraph,\n EdgeCollector,\n getDesiredDocument,\n isExternal,\n type KubernetesResource,\n Pending,\n PendingTemplate,\n Resource,\n tokenRegistryStorage,\n} 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 */\nexport class Template {\n private readonly _resources: KubernetesResource[];\n\n private constructor(resources: KubernetesResource[]) {\n this._resources = resources;\n }\n\n /**\n * Instantiate a Composition and run the full pipeline to produce a Template.\n *\n * Includes ALL declared resources (both emitted and blocked) — Pending\n * dependency values are stripped to `undefined`. Use `Simulator` if you\n * need to distinguish emitted vs blocked.\n */\n static synthesize<TSpec, TStatus, TContext extends object>(\n Ctor: new () => Composition<TSpec, TStatus, TContext>,\n options: SynthesizeOptions = {},\n ): Template {\n const xr: Record<string, unknown> = options.xr ?? { spec: {}, status: {} };\n const pipelineContext = new Map<string, unknown>();\n if (options.environment) {\n pipelineContext.set('apiextensions.crossplane.io/environment', options.environment);\n }\n\n const graph = new DependencyGraph();\n const collector = new EdgeCollector();\n const ctx: CompositionContext = {\n xr,\n pipelineContext,\n requiredResources: new Map(),\n graph,\n collector,\n };\n\n const composition = compositionStorage.run(ctx, () =>\n tokenRegistryStorage.run(createTokenRegistry(), () => new Ctor()),\n ) as Composition;\n return Template.fromComposition(composition);\n }\n\n /**\n * Build a Template from an already-instantiated Composition.\n *\n * Extracts desired documents from ALL non-external resources. Unresolved\n * Pending markers are serialized as `PendingValue` objects — use\n * `Match.pending()` to assert them in tests.\n */\n static fromComposition(composition: Composition): Template {\n const resources = composition.node\n .findAll()\n .filter((c): c is Resource => c instanceof Resource && !isExternal(c as Resource));\n\n const docs = resources.map(\n (r) => serializePending(getDesiredDocument(r)) as KubernetesResource,\n );\n return new Template(docs);\n }\n\n /**\n * Build a Template from a pre-built array of resource documents.\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\n// ─── Pending Serialization ────────────────────────────────────────────────────\n\n/** Symbol tag used to identify serialized PendingValue objects. */\nexport const PENDING_VALUE = Symbol.for('xplane.devtools.pending');\n\n/** Serialized form of a Pending marker in Template resource documents. */\nexport interface PendingValue {\n readonly [PENDING_VALUE]: true;\n /** The resource this value is waiting on. */\n readonly source: string;\n /** The path within that resource's observed data. */\n readonly path: string;\n}\n\n/** Type guard for PendingValue. */\nexport function isPendingValue(value: unknown): value is PendingValue {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[PENDING_VALUE] === true\n );\n}\n\n/**\n * Deep-clone a desired document, converting Pending instances into\n * serialized PendingValue objects that matchers can assert against.\n */\nfunction serializePending(obj: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = serializeValue(value);\n }\n return result;\n}\n\nfunction serializeValue(value: unknown): unknown {\n if (value === null || value === undefined) return value;\n\n if (Pending.is(value)) {\n return {\n [PENDING_VALUE]: true,\n source: value.source.id,\n path: value.path,\n } satisfies PendingValue;\n }\n\n if (PendingTemplate.is(value)) {\n // Represent as a pending value with a compound source description\n return {\n [PENDING_VALUE]: true,\n source: value.slots.map((s) => s.source.id).join(','),\n path: value.slots.map((s) => s.path).join(','),\n } satisfies PendingValue;\n }\n\n if (typeof value !== 'object') return value;\n\n if (Array.isArray(value)) {\n return value.map(serializeValue);\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = serializeValue(val);\n }\n return result;\n}\n","import {\n type Composition,\n type CompositionContext,\n compositionStorage,\n createTokenRegistry,\n DEFAULT_CHECKS,\n DependencyGraph,\n EdgeCollector,\n type EmittedResource,\n evaluateReadiness,\n getDesiredDocument,\n getExternalRef,\n isExternal,\n type KubernetesResource,\n runPipeline,\n tokenRegistryStorage,\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 * Evaluate readiness of a specific emitted resource using its registered\n * readyChecks + built-in defaults against the observed state.\n *\n * @param resourceName The construct path of the resource (e.g., 'Cluster Provider Config')\n * @returns `true` if ready, `false` if not ready or resource not found\n */\n isReady(resourceName: string): boolean;\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 _composition: Composition | null;\n private _factory: ((existing: Record<string, Record<string, unknown>>) => Composition) | null;\n private _observed: Record<string, unknown>[] = [];\n private _existing: Record<string, Record<string, unknown>> = {};\n\n private constructor(\n compositionOrFactory:\n | Composition\n | ((existing: Record<string, Record<string, unknown>>) => Composition),\n ) {\n if (typeof compositionOrFactory === 'function') {\n this._composition = null;\n this._factory = compositionOrFactory;\n } else {\n this._composition = compositionOrFactory;\n this._factory = null;\n }\n }\n\n /**\n * Ergonomic factory: captures XR/environment data and the Composition\n * constructor, deferring instantiation to `run()` so that `withExisting()`\n * data is available for pre-hydration during construction.\n */\n static synthesize<TSpec, TStatus, TContext extends object>(\n Ctor: new () => Composition<TSpec, TStatus, TContext>,\n options: SynthesizeOptions = {},\n ): Simulator {\n const xr: Record<string, unknown> = options.xr ?? { spec: {}, status: {} };\n const pipelineContext = new Map<string, unknown>();\n if (options.environment) {\n pipelineContext.set('apiextensions.crossplane.io/environment', options.environment);\n }\n\n const factory = (existing: Record<string, Record<string, unknown>>) => {\n const graph = new DependencyGraph();\n const collector = new EdgeCollector();\n const requiredResources = new Map<string, Record<string, unknown>>(Object.entries(existing));\n const ctx: CompositionContext = {\n xr,\n pipelineContext,\n requiredResources,\n graph,\n collector,\n };\n\n return compositionStorage.run(ctx, () =>\n tokenRegistryStorage.run(createTokenRegistry(), () => new Ctor()),\n ) as Composition;\n };\n\n return new Simulator(factory);\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: Record<string, unknown>[]): 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, Record<string, unknown>>): 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 // Instantiate composition now so that withExisting data is available for pre-hydration\n const composition = this._factory ? this._factory(this._existing) : this._composition!;\n\n // Build observed map keyed by construct path (Composition/<name>)\n const observedComposed = new Map<string, Record<string, unknown>>();\n for (const obs of this._observed) {\n const meta = obs.metadata as Record<string, unknown> | undefined;\n const name = meta?.name as string | undefined;\n if (name) {\n observedComposed.set(`Composition/${name}`, obs);\n }\n }\n\n // Build observedRequired from withExisting\n const observedRequired = new Map<string, Record<string, unknown>>(\n Object.entries(this._existing),\n );\n\n // Run the pipeline\n const result = runPipeline({\n composition,\n observedComposed,\n observedRequired,\n });\n\n // Check for missing existing resources\n const conditions: SimulationResult['conditions'] = [];\n for (const resource of result.resources) {\n if (!isExternal(resource)) continue;\n const ref = getExternalRef(resource);\n if (!ref || typeof ref.name !== 'string') continue;\n if (!observedRequired.has(ref.refKey)) {\n conditions.push({\n type: 'Ready',\n status: 'False',\n reason: 'MissingRequiredResource',\n message: `Required existing resource ${ref.kind}/${ref.name} not found in cluster`,\n });\n }\n }\n\n // Build templates from pipeline results\n const blockedResources = result.resources\n .filter((r) => result.classification.get(r.node.path) === 'blocked')\n .map((r) => getDesiredDocument(r) as KubernetesResource);\n\n // Build a lookup for readiness evaluation\n const emittedByName = new Map<string, EmittedResource>();\n for (const e of result.emitted) {\n emittedByName.set(e.name, e);\n }\n\n return {\n emitted: Template.fromResources(result.emitted.map((e) => e.document as KubernetesResource)),\n blocked: Template.fromResources(blockedResources),\n conditions,\n isReady(resourceName: string): boolean {\n const emitted = emittedByName.get(resourceName);\n if (!emitted) return false;\n if (!emitted.autoReady) return false;\n const allChecks = [...emitted.readyChecks, ...DEFAULT_CHECKS];\n const observed = observedComposed.get(`Composition/${resourceName}`);\n return evaluateReadiness(allChecks, observed);\n },\n };\n }\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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I,CAAC,OAAO,OAAO,IAAI,SAAS,UAAU;GAC1C,IAAI,CAAC,iBAAiB,IAAI,IAAI,MAAM,GAClC,WAAW,KAAK;IACd,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,SAAS,8BAA8B,IAAI,KAAK,GAAG,IAAI,KAAK;GAC9D,CAAC;EAEL;EAGA,MAAM,mBAAmB,OAAO,UAC7B,QAAQ,MAAM,OAAO,eAAe,IAAI,EAAE,KAAK,IAAI,MAAM,SAAS,EAClE,KAAK,MAAM,mBAAmB,CAAC,CAAuB;EAGzD,MAAM,gCAAgB,IAAI,IAA6B;EACvD,KAAK,MAAM,KAAK,OAAO,SACrB,cAAc,IAAI,EAAE,MAAM,CAAC;EAG7B,OAAO;GACL,SAAS,SAAS,cAAc,OAAO,QAAQ,KAAK,MAAM,EAAE,QAA8B,CAAC;GAC3F,SAAS,SAAS,cAAc,gBAAgB;GAChD;GACA,QAAQ,cAA+B;IACrC,MAAM,UAAU,cAAc,IAAI,YAAY;IAC9C,IAAI,CAAC,SAAS,OAAO;IACrB,IAAI,CAAC,QAAQ,WAAW,OAAO;IAG/B,OAAO,kBAAkB,CAFN,GAAG,QAAQ,aAAa,GAAG,cAEb,GADhB,iBAAiB,IAAI,eAAe,cACV,CAAC;GAC9C;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["PENDING_VALUE"],"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\nconst PENDING_VALUE = Symbol.for('xplane.devtools.pending');\n\nclass PendingMatcher implements Matcher {\n readonly [MATCHER] = true as const;\n constructor(private readonly expected?: { source?: string; path?: string }) {}\n test(actual: unknown): MatchResult {\n if (\n typeof actual !== 'object' ||\n actual === null ||\n (actual as Record<symbol, unknown>)[PENDING_VALUE] !== true\n ) {\n return fail(`expected a pending value, got ${JSON.stringify(actual)}`);\n }\n const pending = actual as { source: string; path: string };\n // For PendingTemplate (compound), source/path are comma-joined; match if substring present\n if (this.expected?.source) {\n const sources = pending.source.split(',');\n if (\n !sources.some((s) => s === this.expected!.source || s.endsWith(`/${this.expected!.source}`))\n ) {\n return fail(\n `expected pending from source \"${this.expected.source}\", got \"${pending.source}\"`,\n );\n }\n }\n if (this.expected?.path) {\n const paths = pending.path.split(',');\n if (!paths.includes(this.expected.path)) {\n return fail(`expected pending path \"${this.expected.path}\", got \"${pending.path}\"`);\n }\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 /**\n * Asserts the value is a pending dependency (unresolved cross-resource reference).\n * Optionally match the source resource and/or path.\n */\n static pending(expected?: { source?: string; path?: string }): Matcher {\n return new PendingMatcher(expected);\n }\n}\n","import {\n type Composition,\n type CompositionContext,\n compositionStorage,\n createTokenRegistry,\n DependencyGraph,\n EdgeCollector,\n getDesiredDocument,\n isExternal,\n type KubernetesResource,\n Pending,\n PendingTemplate,\n Resource,\n tokenRegistryStorage,\n} 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 */\nexport class Template {\n private readonly _resources: KubernetesResource[];\n\n private constructor(resources: KubernetesResource[]) {\n this._resources = resources;\n }\n\n /**\n * Instantiate a Composition and run the full pipeline to produce a Template.\n *\n * Includes ALL declared resources (both emitted and blocked) — Pending\n * dependency values are stripped to `undefined`. Use `Simulator` if you\n * need to distinguish emitted vs blocked.\n */\n static synthesize<TSpec, TStatus, TContext extends object>(\n Ctor: new () => Composition<TSpec, TStatus, TContext>,\n options: SynthesizeOptions = {},\n ): Template {\n const xr: Record<string, unknown> = options.xr ?? { spec: {}, status: {} };\n const pipelineContext = new Map<string, unknown>();\n if (options.environment) {\n pipelineContext.set('apiextensions.crossplane.io/environment', options.environment);\n }\n\n const graph = new DependencyGraph();\n const collector = new EdgeCollector();\n const ctx: CompositionContext = {\n xr,\n pipelineContext,\n requiredResources: new Map(),\n observedComposed: new Map(),\n graph,\n collector,\n };\n\n const composition = compositionStorage.run(ctx, () =>\n tokenRegistryStorage.run(createTokenRegistry(), () => new Ctor()),\n ) as Composition;\n return Template.fromComposition(composition);\n }\n\n /**\n * Build a Template from an already-instantiated Composition.\n *\n * Extracts desired documents from ALL non-external resources. Unresolved\n * Pending markers are serialized as `PendingValue` objects — use\n * `Match.pending()` to assert them in tests.\n */\n static fromComposition(composition: Composition): Template {\n const resources = composition.node\n .findAll()\n .filter((c): c is Resource => c instanceof Resource && !isExternal(c as Resource));\n\n const docs = resources.map(\n (r) => serializePending(getDesiredDocument(r)) as KubernetesResource,\n );\n return new Template(docs);\n }\n\n /**\n * Build a Template from a pre-built array of resource documents.\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\n// ─── Pending Serialization ────────────────────────────────────────────────────\n\n/** Symbol tag used to identify serialized PendingValue objects. */\nexport const PENDING_VALUE = Symbol.for('xplane.devtools.pending');\n\n/** Serialized form of a Pending marker in Template resource documents. */\nexport interface PendingValue {\n readonly [PENDING_VALUE]: true;\n /** The resource this value is waiting on. */\n readonly source: string;\n /** The path within that resource's observed data. */\n readonly path: string;\n}\n\n/** Type guard for PendingValue. */\nexport function isPendingValue(value: unknown): value is PendingValue {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[PENDING_VALUE] === true\n );\n}\n\n/**\n * Deep-clone a desired document, converting Pending instances into\n * serialized PendingValue objects that matchers can assert against.\n */\nfunction serializePending(obj: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = serializeValue(value);\n }\n return result;\n}\n\nfunction serializeValue(value: unknown): unknown {\n if (value === null || value === undefined) return value;\n\n if (Pending.is(value)) {\n return {\n [PENDING_VALUE]: true,\n source: value.source.id,\n path: value.path,\n } satisfies PendingValue;\n }\n\n if (PendingTemplate.is(value)) {\n // Represent as a pending value with a compound source description\n return {\n [PENDING_VALUE]: true,\n source: value.slots.map((s) => s.source.id).join(','),\n path: value.slots.map((s) => s.path).join(','),\n } satisfies PendingValue;\n }\n\n if (typeof value !== 'object') return value;\n\n if (Array.isArray(value)) {\n return value.map(serializeValue);\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = serializeValue(val);\n }\n return result;\n}\n","import {\n type Composition,\n type CompositionContext,\n compositionStorage,\n createTokenRegistry,\n DEFAULT_CHECKS,\n DependencyGraph,\n EdgeCollector,\n type EmittedResource,\n evaluateReadiness,\n getDesiredDocument,\n getExternalRef,\n isExternal,\n type KubernetesResource,\n runPipeline,\n tokenRegistryStorage,\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 * Evaluate readiness of a specific emitted resource using its registered\n * readyChecks + built-in defaults against the observed state.\n *\n * @param resourceName The construct path of the resource (e.g., 'Cluster Provider Config')\n * @returns `true` if ready, `false` if not ready or resource not found\n */\n isReady(resourceName: string): boolean;\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 _composition: Composition | null;\n private _factory: ((existing: Record<string, Record<string, unknown>>) => Composition) | null;\n private _observed: Record<string, unknown>[] = [];\n private _existing: Record<string, Record<string, unknown>> = {};\n\n private constructor(\n compositionOrFactory:\n | Composition\n | ((existing: Record<string, Record<string, unknown>>) => Composition),\n ) {\n if (typeof compositionOrFactory === 'function') {\n this._composition = null;\n this._factory = compositionOrFactory;\n } else {\n this._composition = compositionOrFactory;\n this._factory = null;\n }\n }\n\n /**\n * Ergonomic factory: captures XR/environment data and the Composition\n * constructor, deferring instantiation to `run()` so that `withExisting()`\n * data is available for pre-hydration during construction.\n */\n static synthesize<TSpec, TStatus, TContext extends object>(\n Ctor: new () => Composition<TSpec, TStatus, TContext>,\n options: SynthesizeOptions = {},\n ): Simulator {\n const xr: Record<string, unknown> = options.xr ?? { spec: {}, status: {} };\n const pipelineContext = new Map<string, unknown>();\n if (options.environment) {\n pipelineContext.set('apiextensions.crossplane.io/environment', options.environment);\n }\n\n const factory = (existing: Record<string, Record<string, unknown>>) => {\n const graph = new DependencyGraph();\n const collector = new EdgeCollector();\n const requiredResources = new Map<string, Record<string, unknown>>(Object.entries(existing));\n const ctx: CompositionContext = {\n xr,\n pipelineContext,\n requiredResources,\n observedComposed: new Map(),\n graph,\n collector,\n };\n\n return compositionStorage.run(ctx, () =>\n tokenRegistryStorage.run(createTokenRegistry(), () => new Ctor()),\n ) as Composition;\n };\n\n return new Simulator(factory);\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: Record<string, unknown>[]): 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, Record<string, unknown>>): 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 // Instantiate composition now so that withExisting data is available for pre-hydration\n const composition = this._factory ? this._factory(this._existing) : this._composition!;\n\n // Build observed map keyed by construct path (Composition/<name>)\n const observedComposed = new Map<string, Record<string, unknown>>();\n for (const obs of this._observed) {\n const meta = obs.metadata as Record<string, unknown> | undefined;\n const name = meta?.name as string | undefined;\n if (name) {\n observedComposed.set(`Composition/${name}`, obs);\n }\n }\n\n // Build observedRequired from withExisting\n const observedRequired = new Map<string, Record<string, unknown>>(\n Object.entries(this._existing),\n );\n\n // Run the pipeline\n const result = runPipeline({\n composition,\n observedComposed,\n observedRequired,\n });\n\n // Check for missing existing resources\n const conditions: SimulationResult['conditions'] = [];\n for (const resource of result.resources) {\n if (!isExternal(resource)) continue;\n const ref = getExternalRef(resource);\n if (!ref || typeof ref.name !== 'string') continue;\n if (!observedRequired.has(ref.refKey)) {\n conditions.push({\n type: 'Ready',\n status: 'False',\n reason: 'MissingRequiredResource',\n message: `Required existing resource ${ref.kind}/${ref.name} not found in cluster`,\n });\n }\n }\n\n // Build templates from pipeline results\n const blockedResources = result.resources\n .filter((r) => result.classification.get(r.node.path) === 'blocked')\n .map((r) => getDesiredDocument(r) as KubernetesResource);\n\n // Build a lookup for readiness evaluation\n const emittedByName = new Map<string, EmittedResource>();\n for (const e of result.emitted) {\n emittedByName.set(e.name, e);\n }\n\n return {\n emitted: Template.fromResources(result.emitted.map((e) => e.document as KubernetesResource)),\n blocked: Template.fromResources(blockedResources),\n conditions,\n isReady(resourceName: string): boolean {\n const emitted = emittedByName.get(resourceName);\n if (!emitted) return false;\n if (!emitted.autoReady) return false;\n const allChecks = [...emitted.readyChecks, ...DEFAULT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|
2
2
|
"name": "@xplane/devtools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Developer tools and testing utilities for @xplane/core compositions",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"tsdown": "^0.22.0",
|
|
31
31
|
"typescript": "6.0.3",
|
|
32
32
|
"vitest": "4.1.6",
|
|
33
|
-
"@xplane/core": "1.
|
|
33
|
+
"@xplane/core": "1.3.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"constructs": "^10.0.0",
|
|
37
|
-
"@xplane/core": "1.
|
|
37
|
+
"@xplane/core": "1.3.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsdown",
|