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/index.js
CHANGED
|
@@ -49856,12 +49856,18 @@ var MergeError = class extends Error {
|
|
|
49856
49856
|
function isRecord2(v2) {
|
|
49857
49857
|
return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
|
|
49858
49858
|
}
|
|
49859
|
-
function hasOperator(obj) {
|
|
49859
|
+
function hasOperator(obj, path) {
|
|
49860
49860
|
const ops = ["$append", "$prepend", "$insert_after", "$replace", "$remove"];
|
|
49861
|
+
const found = [];
|
|
49861
49862
|
for (const op of ops) {
|
|
49862
|
-
if (op in obj)
|
|
49863
|
+
if (op in obj) found.push(op);
|
|
49863
49864
|
}
|
|
49864
|
-
|
|
49865
|
+
if (found.length > 1) {
|
|
49866
|
+
throw new MergeError(
|
|
49867
|
+
`Multiple merge operators in the same object at ${path ?? "unknown"}: ${found.join(", ")}`
|
|
49868
|
+
);
|
|
49869
|
+
}
|
|
49870
|
+
return found.length === 1 ? found[0] : null;
|
|
49865
49871
|
}
|
|
49866
49872
|
function findIndexByIdOrValue(arr, target) {
|
|
49867
49873
|
return arr.findIndex((item) => {
|
|
@@ -49872,7 +49878,7 @@ function findIndexByIdOrValue(arr, target) {
|
|
|
49872
49878
|
});
|
|
49873
49879
|
}
|
|
49874
49880
|
function applyArrayMergeOperator(baseArray, operatorObj, path) {
|
|
49875
|
-
const op = hasOperator(operatorObj);
|
|
49881
|
+
const op = hasOperator(operatorObj, path);
|
|
49876
49882
|
if (!op) return baseArray;
|
|
49877
49883
|
switch (op) {
|
|
49878
49884
|
case "$append": {
|
|
@@ -49946,9 +49952,13 @@ function applyArrayMergeOperator(baseArray, operatorObj, path) {
|
|
|
49946
49952
|
}
|
|
49947
49953
|
}
|
|
49948
49954
|
function orderedInsertAfter(base, afterKey, entries) {
|
|
49955
|
+
const entryKeys = new Set(Object.keys(entries));
|
|
49949
49956
|
const result = {};
|
|
49950
49957
|
let inserted = false;
|
|
49951
49958
|
for (const key of Object.keys(base)) {
|
|
49959
|
+
if (inserted && entryKeys.has(key)) {
|
|
49960
|
+
continue;
|
|
49961
|
+
}
|
|
49952
49962
|
result[key] = base[key];
|
|
49953
49963
|
if (key === afterKey) {
|
|
49954
49964
|
for (const [ek, ev] of Object.entries(entries)) {
|
|
@@ -49957,13 +49967,10 @@ function orderedInsertAfter(base, afterKey, entries) {
|
|
|
49957
49967
|
inserted = true;
|
|
49958
49968
|
}
|
|
49959
49969
|
}
|
|
49960
|
-
if (!inserted) {
|
|
49961
|
-
return result;
|
|
49962
|
-
}
|
|
49963
49970
|
return result;
|
|
49964
49971
|
}
|
|
49965
49972
|
function applyMapMergeOperator(baseMap, operatorObj, path) {
|
|
49966
|
-
const op = hasOperator(operatorObj);
|
|
49973
|
+
const op = hasOperator(operatorObj, path);
|
|
49967
49974
|
if (!op) return baseMap;
|
|
49968
49975
|
switch (op) {
|
|
49969
49976
|
case "$append": {
|
|
@@ -50014,7 +50021,7 @@ function deepMergeEntities(base, project, path, hasExtends) {
|
|
|
50014
50021
|
for (const key of Object.keys(project)) {
|
|
50015
50022
|
const baseVal = result[key];
|
|
50016
50023
|
const projVal = project[key];
|
|
50017
|
-
if (isRecord2(projVal) && hasOperator(projVal)) {
|
|
50024
|
+
if (isRecord2(projVal) && hasOperator(projVal, `${path}.${key}`)) {
|
|
50018
50025
|
if (!hasExtends) {
|
|
50019
50026
|
throw new MergeError(
|
|
50020
50027
|
`Merge operator used without extends at ${path}.${key}`
|
|
@@ -50040,20 +50047,26 @@ function deepMergeEntities(base, project, path, hasExtends) {
|
|
|
50040
50047
|
}
|
|
50041
50048
|
return result;
|
|
50042
50049
|
}
|
|
50050
|
+
var OPERATOR_KEYS = /* @__PURE__ */ new Set(["$append", "$prepend", "$insert_after", "$replace", "$remove"]);
|
|
50043
50051
|
function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
|
|
50052
|
+
let result;
|
|
50044
50053
|
if (isRecord2(projectMap) && !Array.isArray(projectMap)) {
|
|
50045
|
-
const op = hasOperator(projectMap);
|
|
50054
|
+
const op = hasOperator(projectMap, path);
|
|
50046
50055
|
if (op) {
|
|
50047
50056
|
if (!hasExtends) {
|
|
50048
50057
|
throw new MergeError(
|
|
50049
50058
|
`Merge operator used without extends at ${path}`
|
|
50050
50059
|
);
|
|
50051
50060
|
}
|
|
50052
|
-
|
|
50061
|
+
result = applyMapMergeOperator(baseMap, projectMap, path);
|
|
50062
|
+
} else {
|
|
50063
|
+
result = { ...baseMap };
|
|
50053
50064
|
}
|
|
50065
|
+
} else {
|
|
50066
|
+
result = { ...baseMap };
|
|
50054
50067
|
}
|
|
50055
|
-
const result = { ...baseMap };
|
|
50056
50068
|
for (const [key, projVal] of Object.entries(projectMap)) {
|
|
50069
|
+
if (OPERATOR_KEYS.has(key)) continue;
|
|
50057
50070
|
const baseVal = result[key];
|
|
50058
50071
|
if (baseVal !== void 0 && isRecord2(baseVal) && isRecord2(projVal)) {
|
|
50059
50072
|
result[key] = deepMergeEntities(
|