@xplane/devtools 0.9.1 → 0.10.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.
@@ -0,0 +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;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AM,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xplane/devtools",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "description": "Developer tools and testing utilities for @xplane/core compositions",
6
6
  "license": "Apache-2.0",
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "exports": {
16
16
  "./assertions": {
17
- "import": "./dist/assertions/index.js",
18
- "types": "./dist/assertions/index.d.ts"
17
+ "import": "./dist/assertions/index.mjs",
18
+ "types": "./dist/assertions/index.d.mts"
19
19
  }
20
20
  },
21
21
  "files": [
@@ -23,17 +23,17 @@
23
23
  ],
24
24
  "devDependencies": {
25
25
  "constructs": "^10.6.0",
26
- "tsup": "8.5.1",
26
+ "tsdown": "^0.22.0",
27
27
  "typescript": "6.0.3",
28
28
  "vitest": "4.1.6",
29
- "@xplane/core": "0.9.1"
29
+ "@xplane/core": "0.10.0"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "constructs": "^10.0.0",
33
- "@xplane/core": "0.9.1"
33
+ "@xplane/core": "0.10.0"
34
34
  },
35
35
  "scripts": {
36
- "build": "tsup",
36
+ "build": "tsdown",
37
37
  "test": "vitest run",
38
38
  "test:watch": "vitest",
39
39
  "typecheck": "tsc --noEmit",
@@ -1,175 +0,0 @@
1
- import { Composition, KubernetesResource } from '@xplane/core';
2
- export { KubernetesResource } from '@xplane/core';
3
-
4
- /** Symbol used to identify Matcher instances. */
5
- declare const MATCHER: unique symbol;
6
- /** Result of a match operation. */
7
- interface MatchResult {
8
- /** Whether the match succeeded. */
9
- pass: boolean;
10
- /** Human-readable failure messages (empty if pass is true). */
11
- failures: string[];
12
- }
13
- /** Interface for custom matchers. */
14
- interface Matcher {
15
- readonly [MATCHER]: true;
16
- test(actual: unknown): MatchResult;
17
- }
18
- /**
19
- * Factory for composable matchers used in assertions.
20
- *
21
- * @example
22
- * ```ts
23
- * template.hasResourceSpec('v1', 'ConfigMap', {
24
- * data: Match.objectLike({ key: 'value' }),
25
- * });
26
- * ```
27
- */
28
- declare class Match {
29
- private constructor();
30
- /** Deep-partial object match — actual may be a superset of pattern. */
31
- static objectLike(pattern: object): Matcher;
32
- /** Exact object match — actual must equal pattern exactly (same keys, same values). */
33
- static objectEquals(pattern: object): Matcher;
34
- /** Array subset match — items must appear in actual in order. */
35
- static arrayWith(items: unknown[]): Matcher;
36
- /** Exact array match — actual must equal items exactly. */
37
- static arrayEquals(items: unknown[]): Matcher;
38
- /** String regex match. */
39
- static stringLikeRegexp(pattern: string | RegExp): Matcher;
40
- /** Asserts the value is absent (undefined). */
41
- static absent(): Matcher;
42
- /** Asserts any non-null/non-undefined value is present. */
43
- static anyValue(): Matcher;
44
- /** Inverts a match — asserts the value does NOT match the given pattern. */
45
- static not(pattern: unknown): Matcher;
46
- }
47
-
48
- /** Options for `Template.synthesize()`. */
49
- interface SynthesizeOptions {
50
- /** XR (composite resource) data to inject before instantiation. */
51
- xr?: Record<string, unknown>;
52
- /** Environment data to inject before instantiation. */
53
- environment?: Record<string, unknown>;
54
- }
55
- /**
56
- * A snapshot of rendered resources from a Composition, providing
57
- * assertion methods for unit testing.
58
- *
59
- * @example
60
- * ```ts
61
- * const template = Template.synthesize(MyComposition, {
62
- * xr: { spec: { region: 'us-east-1' } },
63
- * });
64
- * template.hasResourceSpec('ec2.aws.crossplane.io/v1beta1', 'VPC', {
65
- * forProvider: { region: 'us-east-1' },
66
- * });
67
- * ```
68
- */
69
- declare class Template {
70
- private readonly _resources;
71
- private constructor();
72
- /**
73
- * Ergonomic factory: injects XR/environment data and instantiates
74
- * the Composition class, then builds a Template from the rendered resources.
75
- *
76
- * Users never need to touch `Composition._pendingXR` directly.
77
- */
78
- static synthesize(Ctor: new () => Composition, options?: SynthesizeOptions): Template;
79
- /**
80
- * Build a Template from an already-instantiated Composition.
81
- */
82
- static fromComposition(composition: Composition): Template;
83
- /**
84
- * Build a Template from a pre-built array of KubernetesResource objects.
85
- * Used internally by Simulator.
86
- */
87
- static fromResources(resources: KubernetesResource[]): Template;
88
- /** Get all resources matching apiVersion + kind. */
89
- private _filterByGVK;
90
- /**
91
- * Assert the number of resources with the given apiVersion and kind.
92
- */
93
- resourceCountIs(apiVersion: string, kind: string, count: number): void;
94
- /**
95
- * Assert that at least one resource of the given type matches the expected properties.
96
- * Uses deep-partial matching by default (actual can be a superset of expected).
97
- */
98
- hasResource(apiVersion: string, kind: string, props?: object): void;
99
- /**
100
- * Assert that at least one resource of the given type has a spec matching the expected properties.
101
- * Shorthand for matching against the `spec` field only.
102
- */
103
- hasResourceSpec(apiVersion: string, kind: string, specProps: object): void;
104
- /**
105
- * Assert that at least one resource of the given type has metadata matching the expected properties.
106
- */
107
- hasResourceMetadata(apiVersion: string, kind: string, metaProps: object): void;
108
- /**
109
- * Assert that ALL resources of the given type match the expected properties.
110
- */
111
- allResources(apiVersion: string, kind: string, props: object): void;
112
- /**
113
- * Find all resources of the given type that match the expected properties.
114
- * Returns matches — never throws.
115
- */
116
- findResources(apiVersion: string, kind: string, props?: object): KubernetesResource[];
117
- /**
118
- * Serialize all resources to a JSON-compatible array for snapshot testing.
119
- *
120
- * @example
121
- * ```ts
122
- * expect(template.toJSON()).toMatchSnapshot();
123
- * ```
124
- */
125
- toJSON(): KubernetesResource[];
126
- }
127
-
128
- /** Result of a simulation run. */
129
- interface SimulationResult {
130
- /** Resources that are ready to emit (all dependencies satisfied). */
131
- emitted: Template;
132
- /** Resources that are blocked on unresolved dependencies. */
133
- blocked: Template;
134
- }
135
- /**
136
- * Simulates the full rendering pipeline including observed state injection,
137
- * edge resolution, and sequencing — mimicking what `@xplane/function` does at runtime.
138
- *
139
- * @example
140
- * ```ts
141
- * const result = Simulator.synthesize(MyComposition, { xr: { ... } })
142
- * .withObserved([{ apiVersion: '...', kind: 'VPC', metadata: { name: 'vpc-abc' }, status: { atProvider: { vpcId: 'vpc-123' } } }])
143
- * .run();
144
- *
145
- * result.emitted.hasResourceSpec('ec2.aws.crossplane.io/v1beta1', 'Subnet', {
146
- * forProvider: { vpcId: 'vpc-123' },
147
- * });
148
- * ```
149
- */
150
- declare class Simulator {
151
- private readonly _composition;
152
- private _observed;
153
- private constructor();
154
- /**
155
- * Ergonomic factory: injects XR/environment data, instantiates the
156
- * Composition class, and returns a Simulator ready for `.withObserved().run()`.
157
- */
158
- static synthesize(Ctor: new () => Composition, options?: SynthesizeOptions): Simulator;
159
- /**
160
- * Build a Simulator from an already-instantiated Composition.
161
- */
162
- static fromComposition(composition: Composition): Simulator;
163
- /**
164
- * Provide observed (cluster) state for resources.
165
- * Each resource is matched to a declared resource by its construct path
166
- * (i.e., `metadata.name` in observed state maps to `resource.path` in the composition).
167
- */
168
- withObserved(resources: KubernetesResource[]): this;
169
- /**
170
- * Run the simulation: inject observed state, resolve edges, determine sequencing.
171
- */
172
- run(): SimulationResult;
173
- }
174
-
175
- export { Match, type MatchResult, type Matcher, type SimulationResult, Simulator, type SynthesizeOptions, Template };