docs(config): explain package settings and generated JSON contracts

This commit is contained in:
2026-11-12 12:12:22 +08:00
parent fe80df375c
commit cda4db5ec8
5 changed files with 87 additions and 0 deletions
+5
View File
@@ -53,6 +53,11 @@ test('compiler freezes protocol 2 conditional changes and transports the exact o
const calls=[],{port,request,compiled}=setup(async input=>{calls.push(input);return{status:200,body:{protocol_version:2,request_id:requestId,status:'applied',operation_ids:[operationId],model:chunk(false)}}});
assert.equal(compiled.protocolVersion,2);assert.equal(request.protocolVersion,2);
const body=JSON.parse(request.body);assert.deepEqual(body.operations,[{id:operationId,changes:intent.changes}]);assert.equal(Object.hasOwn(body,'document'),false);
// 严格 JSON 夹具的旁注:protocol_version=2 是请求协议,不是组件 dataVersion 或文档格式版本。
// request_id 使用本测试冻结请求 ID;expected_versions 只含参与根 canvas 的已确认版本 3。
// operations[0].id 是逻辑操作 ID;target.incarnation=1 防止相同元素 ID 的新生命期接收旧修改。
// changes 是 data.title 从 a 到 renamed 的条件修改;beforePresent/afterPresent 显式区分缺失字段和有值字段。
// 深比较覆盖整个编译请求形状;这个静态样例本身不证明真实后端已接受或持久化请求。
assert.deepEqual(body,JSON.parse(await readFile(new URL('./fixtures/foundry-model-operation-v2.json',import.meta.url),'utf8')));
const originalBytes=' \n'+request.body+' ',frozen={...request,body:originalBytes};
assert.equal((await port.submit(frozen,new AbortController().signal)).outcome,'applied');