@prorobotech/openapi-k8s-toolkit 0.0.1-alpha.139 → 0.0.1-alpha.140

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.
@@ -47861,14 +47861,16 @@ const materializeAdditionalFromValues = (props, values, blockedPathsRef) => {
47861
47861
  return { props: next, toExpand, toPersist };
47862
47862
  };
47863
47863
 
47864
- const DEBUG_PREFILLS = false;
47865
47864
  const dbg = (...args) => {
47865
+ console.log("[prefill]", ...args);
47866
47866
  };
47867
- const group = (label) => DEBUG_PREFILLS;
47868
- const DEBUG_WILDCARDS = false;
47867
+ const group = (label) => console.groupCollapsed("[prefill]", label);
47868
+ const end = () => console.groupEnd();
47869
47869
  const wdbg = (...args) => {
47870
+ console.log("[wildcards]", ...args);
47870
47871
  };
47871
- const wgroup = (label) => DEBUG_WILDCARDS;
47872
+ const wgroup = (label) => console.groupCollapsed("[wildcards]", label);
47873
+ const wend = () => console.groupEnd();
47872
47874
  const prettyPath = (arr) => arr.map((s) => s === "*" ? "*" : String(s)).join(".");
47873
47875
 
47874
47876
  const pathKey = (p) => JSON.stringify(p);
@@ -47885,6 +47887,7 @@ const collectArrayLengths = (obj, base = [], out = /* @__PURE__ */ new Map()) =>
47885
47887
  const templateMatchesArray = (tpl, arrayPath) => {
47886
47888
  const w = tpl.wildcardPath;
47887
47889
  if (w.length < arrayPath.length + 1) {
47890
+ dbg("⛔ length too short to match", { w, arrayPath });
47888
47891
  return false;
47889
47892
  }
47890
47893
  for (let i = 0; i < arrayPath.length; i++) {
@@ -47904,8 +47907,21 @@ const buildConcretePathForNewItem = (tpl, arrayPath, newIndex) => {
47904
47907
  realizedPrefix.push(w[i] === "*" ? arrayPath[i] : w[i]);
47905
47908
  }
47906
47909
  const result = [...realizedPrefix, newIndex, ...w.slice(arrayPath.length + 1)];
47910
+ dbg("→ concrete path", { wildcard: w, arrayPath, newIndex, realizedPrefix, result });
47907
47911
  return result;
47908
47912
  };
47913
+ const scrubLiteralWildcardKeys = (input) => {
47914
+ if (Array.isArray(input)) return input.map(scrubLiteralWildcardKeys);
47915
+ if (_$1.isPlainObject(input)) {
47916
+ const out = {};
47917
+ Object.entries(input).forEach(([k, v]) => {
47918
+ if (k === "*") return;
47919
+ out[k] = scrubLiteralWildcardKeys(v);
47920
+ });
47921
+ return out;
47922
+ }
47923
+ return input;
47924
+ };
47909
47925
 
47910
47926
  const sanitizeWildcardPath = (p) => {
47911
47927
  const out = p.map((seg) => {
@@ -47914,6 +47930,7 @@ const sanitizeWildcardPath = (p) => {
47914
47930
  if (typeof seg === "string") return /^\d+$/.test(seg) ? "*" : seg;
47915
47931
  return "*";
47916
47932
  });
47933
+ wdbg("sanitize →", p, "=>", out);
47917
47934
  return out;
47918
47935
  };
47919
47936
  const isPlainObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
@@ -47940,22 +47957,31 @@ const expandOneTemplate = (tpl, node, base = [], out = []) => {
47940
47957
  }
47941
47958
  } else if (isPlainObj(curr)) {
47942
47959
  const keys = Object.keys(curr);
47960
+ wdbg(" wildcard over object keys", keys);
47943
47961
  for (const k of keys) {
47944
47962
  step(i + 1, curr[k], [...path, k]);
47945
47963
  }
47946
- } else ;
47964
+ } else {
47965
+ wdbg(" wildcard dead-end (not array/object)");
47966
+ }
47947
47967
  return;
47948
47968
  }
47949
47969
  if (isPlainObj(curr) && seg in curr) {
47970
+ wdbg(" descend object key", seg);
47950
47971
  step(i + 1, curr[seg], [...path, seg]);
47951
47972
  } else if (Array.isArray(curr) && typeof seg === "number" && curr[seg] !== void 0) {
47973
+ wdbg(" descend array index", seg);
47952
47974
  step(i + 1, curr[seg], [...path, seg]);
47953
- } else ;
47975
+ } else {
47976
+ wdbg(" dead-end at concrete seg", seg);
47977
+ }
47954
47978
  };
47955
47979
  step(0, node, base);
47980
+ wend();
47956
47981
  return out;
47957
47982
  };
47958
- const expandWildcardTemplates = (templates, values) => {
47983
+ const expandWildcardTemplates = (templates, values, opts) => {
47984
+ wgroup("expand templates");
47959
47985
  templates.forEach((t, i) => wdbg(`#${i}`, prettyPath(t)));
47960
47986
  const acc = [];
47961
47987
  const seen = /* @__PURE__ */ new Set();
@@ -47968,8 +47994,17 @@ const expandWildcardTemplates = (templates, values) => {
47968
47994
  acc.push(p);
47969
47995
  }
47970
47996
  }
47997
+ if (!hits.length && opts?.includeMissingExact && !tpl.some((seg) => seg === "*")) {
47998
+ const k = JSON.stringify(tpl);
47999
+ if (!seen.has(k)) {
48000
+ wdbg('no hits; include exact (no "*") →', prettyPath(tpl));
48001
+ seen.add(k);
48002
+ acc.push(tpl);
48003
+ }
48004
+ }
47971
48005
  }
47972
48006
  wdbg("expanded →", acc.map(prettyPath));
48007
+ wend();
47973
48008
  return acc;
47974
48009
  };
47975
48010
  const isPathArray = (p) => Array.isArray(p);
@@ -48112,7 +48147,8 @@ const BlackholeForm = ({
48112
48147
  setError(void 0);
48113
48148
  const name = form.getFieldValue(["metadata", "name"]);
48114
48149
  const namespace = form.getFieldValue(["metadata", "namespace"]);
48115
- const values = form.getFieldsValue();
48150
+ const valuesRaw = form.getFieldsValue();
48151
+ const values = scrubLiteralWildcardKeys(valuesRaw);
48116
48152
  const payload = {
48117
48153
  values,
48118
48154
  persistedKeys,
@@ -48185,7 +48221,10 @@ const BlackholeForm = ({
48185
48221
  }
48186
48222
  if (formsPrefills) {
48187
48223
  formsPrefills.spec.values.forEach(({ path, value }) => {
48188
- _$1.set(allValues, path, value);
48224
+ const hasWildcard = path.some((seg) => seg === "*");
48225
+ if (!hasWildcard) {
48226
+ _$1.set(allValues, path, value);
48227
+ }
48189
48228
  });
48190
48229
  }
48191
48230
  if (prefillValueNamespaceOnly) {
@@ -48215,7 +48254,8 @@ const BlackholeForm = ({
48215
48254
  return templates.sort((a, b) => b.wildcardPath.length - a.wildcardPath.length);
48216
48255
  }, [formsPrefills, normalizedPrefill]);
48217
48256
  useEffect(() => {
48218
- return;
48257
+ dbg("templates (wildcards, ordered specific→generic):");
48258
+ prefillTemplates.forEach((t, i) => dbg(`#${i}`, t.wildcardPath.join("."), "=>", t.value));
48219
48259
  }, [prefillTemplates]);
48220
48260
  const prevArrayLengthsRef = useRef(/* @__PURE__ */ new Map());
48221
48261
  const applyPrefillForNewArrayItem = useCallback(
@@ -48227,31 +48267,47 @@ const BlackholeForm = ({
48227
48267
  if (!matches) continue;
48228
48268
  const concretePath = buildConcretePathForNewItem(tpl, arrayPath, newIndex);
48229
48269
  const current = form.getFieldValue(concretePath);
48270
+ dbg("current value at path", concretePath, ":", current);
48230
48271
  if (typeof current === "undefined") {
48231
48272
  const toSet = _$1.cloneDeep(tpl.value);
48273
+ dbg("setting value", { path: concretePath, value: toSet });
48232
48274
  form.setFieldValue(concretePath, toSet);
48275
+ } else {
48276
+ dbg("skipping set (already has value)");
48233
48277
  }
48234
48278
  }
48279
+ end();
48235
48280
  },
48236
48281
  [form, prefillTemplates]
48237
48282
  );
48238
48283
  const hiddenWildcardTemplates = useMemo(() => {
48239
48284
  const raw = hiddenPaths ?? [];
48285
+ wgroup("hidden raw templates");
48240
48286
  raw.forEach((p, i) => wdbg(`#${i}`, p));
48287
+ wend();
48241
48288
  const sanitized = raw.map((p) => sanitizeWildcardPath(p));
48289
+ wgroup("hidden sanitized templates");
48242
48290
  sanitized.forEach((p, i) => wdbg(`#${i}`, prettyPath(p)));
48291
+ wend();
48243
48292
  return sanitized;
48244
48293
  }, [hiddenPaths]);
48245
48294
  const expandedWildcardTemplates = useMemo(() => {
48246
48295
  const raw = expandedPaths ?? [];
48296
+ wgroup("expanded raw templates");
48247
48297
  raw.forEach((p, i) => wdbg(`#${i}`, p));
48298
+ wend();
48248
48299
  const sanitized = raw.map((p) => sanitizeWildcardPath(p));
48300
+ wgroup("expanded sanitized templates");
48249
48301
  sanitized.forEach((p, i) => wdbg(`#${i}`, prettyPath(p)));
48302
+ wend();
48250
48303
  return sanitized;
48251
48304
  }, [expandedPaths]);
48252
48305
  useEffect(() => {
48253
48306
  if (!initialValues) return;
48254
- const hiddenResolved = expandWildcardTemplates(hiddenWildcardTemplates, initialValues);
48307
+ wgroup("initial resolve");
48308
+ const hiddenResolved = expandWildcardTemplates(hiddenWildcardTemplates, initialValues, {
48309
+ includeMissingExact: true
48310
+ });
48255
48311
  wdbg("hidden resolved", hiddenResolved.map(prettyPath));
48256
48312
  setResolvedHiddenPaths(hiddenResolved);
48257
48313
  const expandedResolved = expandWildcardTemplates(expandedWildcardTemplates, initialValues);
@@ -48268,6 +48324,7 @@ const BlackholeForm = ({
48268
48324
  }
48269
48325
  return merged;
48270
48326
  });
48327
+ wend();
48271
48328
  }, [initialValues, hiddenWildcardTemplates, expandedWildcardTemplates]);
48272
48329
  const resolvedHiddenStringPaths = useMemo(
48273
48330
  () => resolvedHiddenPaths.map(toStringPath),
@@ -48294,8 +48351,15 @@ const BlackholeForm = ({
48294
48351
  }, 300);
48295
48352
  const onValuesChangeCallback = useCallback(
48296
48353
  (values) => {
48297
- const v = values ?? form.getFieldsValue(true);
48298
- const hiddenResolved = expandWildcardTemplates(hiddenWildcardTemplates, v);
48354
+ const vRaw = values ?? form.getFieldsValue(true);
48355
+ const v = scrubLiteralWildcardKeys(vRaw);
48356
+ wgroup("values→resolve wildcards");
48357
+ const hiddenResolved = expandWildcardTemplates(
48358
+ hiddenWildcardTemplates,
48359
+ v,
48360
+ { includeMissingExact: true }
48361
+ // only hidden opts in
48362
+ );
48299
48363
  wdbg("hidden resolved", hiddenResolved.map(prettyPath));
48300
48364
  setResolvedHiddenPaths(hiddenResolved);
48301
48365
  const expandedResolved = expandWildcardTemplates(expandedWildcardTemplates, v);
@@ -48314,20 +48378,27 @@ const BlackholeForm = ({
48314
48378
  return merged;
48315
48379
  });
48316
48380
  }
48381
+ wend();
48382
+ group("values change");
48383
+ dbg("values snapshot keys", Object.keys(v || {}));
48317
48384
  const newLengths = collectArrayLengths(v);
48318
48385
  const prevLengths = prevArrayLengthsRef.current;
48386
+ dbg("array lengths (prev → new)");
48319
48387
  const allKeys = /* @__PURE__ */ new Set([...prevLengths.keys(), ...newLengths.keys()]);
48320
48388
  [...allKeys].forEach((k) => dbg(k, " : ", prevLengths.get(k), "→", newLengths.get(k)));
48321
48389
  for (const [k, newLen] of newLengths.entries()) {
48322
48390
  const prevLen = prevLengths.get(k) ?? 0;
48323
48391
  if (newLen > prevLen) {
48324
48392
  const arrayPath = JSON.parse(k);
48393
+ dbg("🟢 detected growth", { pathKey: k, arrayPath, prevLen, newLen });
48325
48394
  for (let i = prevLen; i < newLen; i++) {
48395
+ dbg("…prefilling new index", i, "under", arrayPath);
48326
48396
  applyPrefillForNewArrayItem(arrayPath, i);
48327
48397
  }
48328
48398
  }
48329
48399
  }
48330
48400
  prevArrayLengthsRef.current = newLengths;
48401
+ end();
48331
48402
  const payload = {
48332
48403
  values: v,
48333
48404
  persistedKeys,