agent-contracts 0.22.6 → 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 +58 -19
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.js +58 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
50840
|
-
return arr.findIndex(
|
|
50841
|
-
(
|
|
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 =
|
|
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
|
-
|
|
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"];
|
|
@@ -51063,24 +51087,39 @@ function mergeDsl(base, project) {
|
|
|
51063
51087
|
|
|
51064
51088
|
// src/resolver/resolve.ts
|
|
51065
51089
|
import { dirname as dirname3, resolve as resolvePath } from "path";
|
|
51066
|
-
async function
|
|
51067
|
-
const
|
|
51068
|
-
const projectResult = await loadDsl(absPath);
|
|
51069
|
-
const projectData = projectResult.data;
|
|
51070
|
-
const extendsValue = projectData["extends"];
|
|
51090
|
+
async function resolveExtendsChain(data, filePath, seen) {
|
|
51091
|
+
const extendsValue = data["extends"];
|
|
51071
51092
|
if (typeof extendsValue !== "string") {
|
|
51072
|
-
return {
|
|
51073
|
-
data: projectData,
|
|
51074
|
-
projectPath: projectResult.filePath
|
|
51075
|
-
};
|
|
51093
|
+
return { data, basePaths: [] };
|
|
51076
51094
|
}
|
|
51077
|
-
const projectDir = dirname3(
|
|
51095
|
+
const projectDir = dirname3(filePath);
|
|
51078
51096
|
const baseResult = await resolveBase(extendsValue, projectDir);
|
|
51079
|
-
const
|
|
51097
|
+
const basePath = baseResult.filePath;
|
|
51098
|
+
if (seen.has(basePath)) {
|
|
51099
|
+
throw new BaseResolveError(
|
|
51100
|
+
`Circular extends detected: ${basePath}`
|
|
51101
|
+
);
|
|
51102
|
+
}
|
|
51103
|
+
seen.add(basePath);
|
|
51104
|
+
const { data: resolvedBase, basePaths: ancestorPaths } = await resolveExtendsChain(baseResult.data, basePath, seen);
|
|
51105
|
+
const merged = mergeDsl(resolvedBase, data);
|
|
51080
51106
|
return {
|
|
51081
51107
|
data: merged,
|
|
51108
|
+
basePaths: [...ancestorPaths, basePath]
|
|
51109
|
+
};
|
|
51110
|
+
}
|
|
51111
|
+
async function resolve4(projectDirOrFile) {
|
|
51112
|
+
const absPath = resolvePath(projectDirOrFile);
|
|
51113
|
+
const projectResult = await loadDsl(absPath);
|
|
51114
|
+
const { data, basePaths } = await resolveExtendsChain(
|
|
51115
|
+
projectResult.data,
|
|
51116
|
+
projectResult.filePath,
|
|
51117
|
+
/* @__PURE__ */ new Set()
|
|
51118
|
+
);
|
|
51119
|
+
return {
|
|
51120
|
+
data,
|
|
51082
51121
|
projectPath: projectResult.filePath,
|
|
51083
|
-
|
|
51122
|
+
basePaths
|
|
51084
51123
|
};
|
|
51085
51124
|
}
|
|
51086
51125
|
|