agent-contracts 0.22.7 → 0.22.8
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 +31 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +31 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -854,7 +854,9 @@ declare const ReplaceOperatorSchema: z.ZodObject<{
|
|
|
854
854
|
}, z.core.$strip>;
|
|
855
855
|
type ReplaceOperator = z.infer<typeof ReplaceOperatorSchema>;
|
|
856
856
|
declare const RemoveOperatorSchema: z.ZodObject<{
|
|
857
|
-
$remove: z.ZodArray<z.ZodString
|
|
857
|
+
$remove: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
858
|
+
id: z.ZodString;
|
|
859
|
+
}, z.core.$strip>]>>;
|
|
858
860
|
}, z.core.$strip>;
|
|
859
861
|
type RemoveOperator = z.infer<typeof RemoveOperatorSchema>;
|
|
860
862
|
type MergeableRecord<T> = Record<string, T> | {
|
|
@@ -869,7 +871,9 @@ type MergeableRecord<T> = Record<string, T> | {
|
|
|
869
871
|
} | {
|
|
870
872
|
$replace: unknown;
|
|
871
873
|
} | {
|
|
872
|
-
$remove: string
|
|
874
|
+
$remove: (string | {
|
|
875
|
+
id: string;
|
|
876
|
+
})[];
|
|
873
877
|
};
|
|
874
878
|
|
|
875
879
|
declare const PolicyWhenSchema: z.ZodObject<{
|
package/dist/index.js
CHANGED
|
@@ -49451,7 +49451,7 @@ var InsertAfterOperatorSchema = z16.object({
|
|
|
49451
49451
|
});
|
|
49452
49452
|
var ReplaceOperatorSchema = z16.object({ $replace: z16.any() });
|
|
49453
49453
|
var RemoveOperatorSchema = z16.object({
|
|
49454
|
-
$remove: z16.array(z16.string())
|
|
49454
|
+
$remove: z16.array(z16.union([z16.string(), z16.object({ id: z16.string() })]))
|
|
49455
49455
|
});
|
|
49456
49456
|
|
|
49457
49457
|
// src/loader/loader.ts
|
|
@@ -49863,10 +49863,13 @@ function hasOperator(obj) {
|
|
|
49863
49863
|
}
|
|
49864
49864
|
return null;
|
|
49865
49865
|
}
|
|
49866
|
-
function
|
|
49867
|
-
return arr.findIndex(
|
|
49868
|
-
(
|
|
49869
|
-
|
|
49866
|
+
function findIndexByIdOrValue(arr, target) {
|
|
49867
|
+
return arr.findIndex((item) => {
|
|
49868
|
+
if (typeof item === "string") {
|
|
49869
|
+
return item === target;
|
|
49870
|
+
}
|
|
49871
|
+
return isRecord2(item) && item["id"] === target;
|
|
49872
|
+
});
|
|
49870
49873
|
}
|
|
49871
49874
|
function applyArrayMergeOperator(baseArray, operatorObj, path) {
|
|
49872
49875
|
const op = hasOperator(operatorObj);
|
|
@@ -49884,7 +49887,7 @@ function applyArrayMergeOperator(baseArray, operatorObj, path) {
|
|
|
49884
49887
|
const spec = operatorObj["$insert_after"];
|
|
49885
49888
|
const target = spec["target"];
|
|
49886
49889
|
const items = spec["items"];
|
|
49887
|
-
const idx =
|
|
49890
|
+
const idx = findIndexByIdOrValue(baseArray, target);
|
|
49888
49891
|
if (idx === -1) {
|
|
49889
49892
|
throw new MergeError(
|
|
49890
49893
|
`$insert_after target "${target}" not found in base at ${path}`
|
|
@@ -49899,7 +49902,28 @@ function applyArrayMergeOperator(baseArray, operatorObj, path) {
|
|
|
49899
49902
|
}
|
|
49900
49903
|
case "$remove": {
|
|
49901
49904
|
const removeList = operatorObj["$remove"];
|
|
49902
|
-
|
|
49905
|
+
if (removeList.length === 0) {
|
|
49906
|
+
return baseArray;
|
|
49907
|
+
}
|
|
49908
|
+
if (typeof removeList[0] === "string") {
|
|
49909
|
+
const valuesToRemove = new Set(removeList);
|
|
49910
|
+
const result2 = baseArray.filter((item) => {
|
|
49911
|
+
if (typeof item === "string" && valuesToRemove.has(item)) {
|
|
49912
|
+
valuesToRemove.delete(item);
|
|
49913
|
+
return false;
|
|
49914
|
+
}
|
|
49915
|
+
return true;
|
|
49916
|
+
});
|
|
49917
|
+
if (valuesToRemove.size > 0) {
|
|
49918
|
+
throw new MergeError(
|
|
49919
|
+
`$remove values not found in base at ${path}: ${[...valuesToRemove].join(", ")}`
|
|
49920
|
+
);
|
|
49921
|
+
}
|
|
49922
|
+
return result2;
|
|
49923
|
+
}
|
|
49924
|
+
const idsToRemove = new Set(
|
|
49925
|
+
removeList.map((r3) => r3["id"])
|
|
49926
|
+
);
|
|
49903
49927
|
const result = baseArray.filter((item) => {
|
|
49904
49928
|
if (isRecord2(item) && typeof item["id"] === "string") {
|
|
49905
49929
|
const itemId = item["id"];
|