agent-contracts 0.22.7 → 0.22.9

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/dist/cli.js CHANGED
@@ -50222,7 +50222,7 @@ var InsertAfterOperatorSchema = z16.object({
50222
50222
  });
50223
50223
  var ReplaceOperatorSchema = z16.object({ $replace: z16.any() });
50224
50224
  var RemoveOperatorSchema = z16.object({
50225
- $remove: z16.array(z16.string())
50225
+ $remove: z16.array(z16.union([z16.string(), z16.object({ id: z16.string() })]))
50226
50226
  });
50227
50227
 
50228
50228
  // src/config/loader.ts
@@ -50836,10 +50836,13 @@ function hasOperator(obj) {
50836
50836
  }
50837
50837
  return null;
50838
50838
  }
50839
- function findIndexById(arr, id) {
50840
- return arr.findIndex(
50841
- (item) => isRecord2(item) && item["id"] === id
50842
- );
50839
+ function findIndexByIdOrValue(arr, target) {
50840
+ return arr.findIndex((item) => {
50841
+ if (typeof item === "string") {
50842
+ return item === target;
50843
+ }
50844
+ return isRecord2(item) && item["id"] === target;
50845
+ });
50843
50846
  }
50844
50847
  function applyArrayMergeOperator(baseArray, operatorObj, path) {
50845
50848
  const op = hasOperator(operatorObj);
@@ -50857,7 +50860,7 @@ function applyArrayMergeOperator(baseArray, operatorObj, path) {
50857
50860
  const spec = operatorObj["$insert_after"];
50858
50861
  const target = spec["target"];
50859
50862
  const items = spec["items"];
50860
- const idx = findIndexById(baseArray, target);
50863
+ const idx = findIndexByIdOrValue(baseArray, target);
50861
50864
  if (idx === -1) {
50862
50865
  throw new MergeError(
50863
50866
  `$insert_after target "${target}" not found in base at ${path}`
@@ -50872,7 +50875,28 @@ function applyArrayMergeOperator(baseArray, operatorObj, path) {
50872
50875
  }
50873
50876
  case "$remove": {
50874
50877
  const removeList = operatorObj["$remove"];
50875
- const idsToRemove = new Set(removeList.map((r3) => r3["id"]));
50878
+ if (removeList.length === 0) {
50879
+ return baseArray;
50880
+ }
50881
+ if (typeof removeList[0] === "string") {
50882
+ const valuesToRemove = new Set(removeList);
50883
+ const result2 = baseArray.filter((item) => {
50884
+ if (typeof item === "string" && valuesToRemove.has(item)) {
50885
+ valuesToRemove.delete(item);
50886
+ return false;
50887
+ }
50888
+ return true;
50889
+ });
50890
+ if (valuesToRemove.size > 0) {
50891
+ throw new MergeError(
50892
+ `$remove values not found in base at ${path}: ${[...valuesToRemove].join(", ")}`
50893
+ );
50894
+ }
50895
+ return result2;
50896
+ }
50897
+ const idsToRemove = new Set(
50898
+ removeList.map((r3) => r3["id"])
50899
+ );
50876
50900
  const result = baseArray.filter((item) => {
50877
50901
  if (isRecord2(item) && typeof item["id"] === "string") {
50878
50902
  const itemId = item["id"];
@@ -50989,7 +51013,9 @@ function deepMergeEntities(base, project, path, hasExtends) {
50989
51013
  }
50990
51014
  return result;
50991
51015
  }
51016
+ var OPERATOR_KEYS = /* @__PURE__ */ new Set(["$append", "$prepend", "$insert_after", "$replace", "$remove"]);
50992
51017
  function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
51018
+ let result;
50993
51019
  if (isRecord2(projectMap) && !Array.isArray(projectMap)) {
50994
51020
  const op = hasOperator(projectMap);
50995
51021
  if (op) {
@@ -50998,11 +51024,15 @@ function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
50998
51024
  `Merge operator used without extends at ${path}`
50999
51025
  );
51000
51026
  }
51001
- return applyMapMergeOperator(baseMap, projectMap, path);
51027
+ result = applyMapMergeOperator(baseMap, projectMap, path);
51028
+ } else {
51029
+ result = { ...baseMap };
51002
51030
  }
51031
+ } else {
51032
+ result = { ...baseMap };
51003
51033
  }
51004
- const result = { ...baseMap };
51005
51034
  for (const [key, projVal] of Object.entries(projectMap)) {
51035
+ if (OPERATOR_KEYS.has(key)) continue;
51006
51036
  const baseVal = result[key];
51007
51037
  if (baseVal !== void 0 && isRecord2(baseVal) && isRecord2(projVal)) {
51008
51038
  result[key] = deepMergeEntities(