agent-contracts 0.22.8 → 0.23.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.
- package/dist/cli.js +25 -12
- package/dist/cli.js.map +1 -1
- package/dist/index.js +25 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -50829,12 +50829,18 @@ var MergeError = class extends Error {
|
|
|
50829
50829
|
function isRecord2(v2) {
|
|
50830
50830
|
return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
|
|
50831
50831
|
}
|
|
50832
|
-
function hasOperator(obj) {
|
|
50832
|
+
function hasOperator(obj, path) {
|
|
50833
50833
|
const ops = ["$append", "$prepend", "$insert_after", "$replace", "$remove"];
|
|
50834
|
+
const found = [];
|
|
50834
50835
|
for (const op of ops) {
|
|
50835
|
-
if (op in obj)
|
|
50836
|
+
if (op in obj) found.push(op);
|
|
50836
50837
|
}
|
|
50837
|
-
|
|
50838
|
+
if (found.length > 1) {
|
|
50839
|
+
throw new MergeError(
|
|
50840
|
+
`Multiple merge operators in the same object at ${path ?? "unknown"}: ${found.join(", ")}`
|
|
50841
|
+
);
|
|
50842
|
+
}
|
|
50843
|
+
return found.length === 1 ? found[0] : null;
|
|
50838
50844
|
}
|
|
50839
50845
|
function findIndexByIdOrValue(arr, target) {
|
|
50840
50846
|
return arr.findIndex((item) => {
|
|
@@ -50845,7 +50851,7 @@ function findIndexByIdOrValue(arr, target) {
|
|
|
50845
50851
|
});
|
|
50846
50852
|
}
|
|
50847
50853
|
function applyArrayMergeOperator(baseArray, operatorObj, path) {
|
|
50848
|
-
const op = hasOperator(operatorObj);
|
|
50854
|
+
const op = hasOperator(operatorObj, path);
|
|
50849
50855
|
if (!op) return baseArray;
|
|
50850
50856
|
switch (op) {
|
|
50851
50857
|
case "$append": {
|
|
@@ -50919,9 +50925,13 @@ function applyArrayMergeOperator(baseArray, operatorObj, path) {
|
|
|
50919
50925
|
}
|
|
50920
50926
|
}
|
|
50921
50927
|
function orderedInsertAfter(base, afterKey, entries) {
|
|
50928
|
+
const entryKeys = new Set(Object.keys(entries));
|
|
50922
50929
|
const result = {};
|
|
50923
50930
|
let inserted = false;
|
|
50924
50931
|
for (const key of Object.keys(base)) {
|
|
50932
|
+
if (inserted && entryKeys.has(key)) {
|
|
50933
|
+
continue;
|
|
50934
|
+
}
|
|
50925
50935
|
result[key] = base[key];
|
|
50926
50936
|
if (key === afterKey) {
|
|
50927
50937
|
for (const [ek, ev] of Object.entries(entries)) {
|
|
@@ -50930,13 +50940,10 @@ function orderedInsertAfter(base, afterKey, entries) {
|
|
|
50930
50940
|
inserted = true;
|
|
50931
50941
|
}
|
|
50932
50942
|
}
|
|
50933
|
-
if (!inserted) {
|
|
50934
|
-
return result;
|
|
50935
|
-
}
|
|
50936
50943
|
return result;
|
|
50937
50944
|
}
|
|
50938
50945
|
function applyMapMergeOperator(baseMap, operatorObj, path) {
|
|
50939
|
-
const op = hasOperator(operatorObj);
|
|
50946
|
+
const op = hasOperator(operatorObj, path);
|
|
50940
50947
|
if (!op) return baseMap;
|
|
50941
50948
|
switch (op) {
|
|
50942
50949
|
case "$append": {
|
|
@@ -50987,7 +50994,7 @@ function deepMergeEntities(base, project, path, hasExtends) {
|
|
|
50987
50994
|
for (const key of Object.keys(project)) {
|
|
50988
50995
|
const baseVal = result[key];
|
|
50989
50996
|
const projVal = project[key];
|
|
50990
|
-
if (isRecord2(projVal) && hasOperator(projVal)) {
|
|
50997
|
+
if (isRecord2(projVal) && hasOperator(projVal, `${path}.${key}`)) {
|
|
50991
50998
|
if (!hasExtends) {
|
|
50992
50999
|
throw new MergeError(
|
|
50993
51000
|
`Merge operator used without extends at ${path}.${key}`
|
|
@@ -51013,20 +51020,26 @@ function deepMergeEntities(base, project, path, hasExtends) {
|
|
|
51013
51020
|
}
|
|
51014
51021
|
return result;
|
|
51015
51022
|
}
|
|
51023
|
+
var OPERATOR_KEYS = /* @__PURE__ */ new Set(["$append", "$prepend", "$insert_after", "$replace", "$remove"]);
|
|
51016
51024
|
function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
|
|
51025
|
+
let result;
|
|
51017
51026
|
if (isRecord2(projectMap) && !Array.isArray(projectMap)) {
|
|
51018
|
-
const op = hasOperator(projectMap);
|
|
51027
|
+
const op = hasOperator(projectMap, path);
|
|
51019
51028
|
if (op) {
|
|
51020
51029
|
if (!hasExtends) {
|
|
51021
51030
|
throw new MergeError(
|
|
51022
51031
|
`Merge operator used without extends at ${path}`
|
|
51023
51032
|
);
|
|
51024
51033
|
}
|
|
51025
|
-
|
|
51034
|
+
result = applyMapMergeOperator(baseMap, projectMap, path);
|
|
51035
|
+
} else {
|
|
51036
|
+
result = { ...baseMap };
|
|
51026
51037
|
}
|
|
51038
|
+
} else {
|
|
51039
|
+
result = { ...baseMap };
|
|
51027
51040
|
}
|
|
51028
|
-
const result = { ...baseMap };
|
|
51029
51041
|
for (const [key, projVal] of Object.entries(projectMap)) {
|
|
51042
|
+
if (OPERATOR_KEYS.has(key)) continue;
|
|
51030
51043
|
const baseVal = result[key];
|
|
51031
51044
|
if (baseVal !== void 0 && isRecord2(baseVal) && isRecord2(projVal)) {
|
|
51032
51045
|
result[key] = deepMergeEntities(
|