@f5-sales-demo/pi-resource-management 23.0.0 → 23.0.2

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@f5-sales-demo/pi-resource-management",
4
- "version": "23.0.0",
4
+ "version": "23.0.2",
5
5
  "description": "Shared resource management for F5 XC manifest parsing, validation, diff, and CRUD operations",
6
6
  "homepage": "https://github.com/f5-sales-demo/xcsh",
7
7
  "author": "Robin Mordasiewicz",
@@ -124,7 +124,7 @@ export class ResourceClient {
124
124
  const getUrl = this.#buildUrl(resolved.paths.get, namespace, name);
125
125
 
126
126
  const startMs = performance.now();
127
- const existing = await this.#fetchResource(getUrl);
127
+ const existing = await this.#fetchComparisonResource(getUrl, resolved);
128
128
 
129
129
  if (existing.status === 404) {
130
130
  if (dryRun) return { status: "dry-run", action: "create" };
@@ -166,7 +166,7 @@ export class ResourceClient {
166
166
  const name = manifest.metadata.name;
167
167
  const getUrl = this.#buildUrl(resolved.paths.get, namespace, name);
168
168
  const startMs = performance.now();
169
- const existing = await this.#fetchResource(getUrl);
169
+ const existing = await this.#fetchComparisonResource(getUrl, resolved);
170
170
 
171
171
  if (existing.error) return { status: "error", error: existing.error };
172
172
 
@@ -275,7 +275,7 @@ export class ResourceClient {
275
275
  const name = manifest.metadata.name;
276
276
  const url = this.#buildUrl(resolved.paths.get, namespace, name);
277
277
 
278
- const existing = await this.#fetchResource(url);
278
+ const existing = await this.#fetchComparisonResource(url, resolved);
279
279
  if (existing.status === 404) {
280
280
  return { isNew: true };
281
281
  }
@@ -369,6 +369,22 @@ export class ResourceClient {
369
369
  return body;
370
370
  }
371
371
 
372
+ async #fetchComparisonResource(
373
+ url: string,
374
+ resolved: ResolvedKind,
375
+ ): Promise<{ status: number; body?: Record<string, unknown>; error?: ResourceError }> {
376
+ // The normal certificate projection omits encrypted key material. Compare
377
+ // against its writable form instead of treating an omitted key as a change.
378
+ if (resolved.kind !== "certificate") return this.#fetchResource(url);
379
+ const comparisonUrl = new URL(url);
380
+ comparisonUrl.searchParams.set("response_format", "2");
381
+ const result = await this.#fetchResource(comparisonUrl.toString());
382
+ const replaceForm = result.body?.replace_form;
383
+ if (replaceForm && typeof replaceForm === "object" && !Array.isArray(replaceForm))
384
+ return { ...result, body: replaceForm as Record<string, unknown> };
385
+ return result;
386
+ }
387
+
372
388
  async #fetchResource(
373
389
  url: string,
374
390
  ): Promise<{ status: number; body?: Record<string, unknown>; error?: ResourceError }> {