Add local-first execution contracts to the capability language
This commit is contained in:
@@ -128,6 +128,23 @@ export async function compileQuery(
|
||||
const member = contract.members.find((entry) => entry.displayName === name);
|
||||
if (!member || member.kind === "operation" || !member.queryRead)
|
||||
return fail("QUERY_FIELD_NOT_QUERYABLE", `${contract.displayName}.${name} is not queryable`, node);
|
||||
if (declaration.placement?.kind === "local") {
|
||||
const getter = member.operations.find(
|
||||
(operation) => operation.displayName === (member.kind === "value" ? "get" : "resolve"),
|
||||
);
|
||||
if (getter?.execution?.kind !== "snapshot" || !getter.execution.targets.includes("browser"))
|
||||
fail(
|
||||
"QUERY_LOCAL_DEPENDENCY",
|
||||
`Local query requires a browser snapshot getter for ${contract.displayName}.${name}; split the remote field or move the query to the server`,
|
||||
node,
|
||||
);
|
||||
if (member.queryRead.execution === "rpc-permitted")
|
||||
fail(
|
||||
"QUERY_LOCAL_DEPENDENCY",
|
||||
`Local query cannot include remote-compute field ${contract.displayName}.${name}`,
|
||||
node,
|
||||
);
|
||||
}
|
||||
const key = `${id}\0${member.id}`;
|
||||
const effect = effects.get(key) ?? {
|
||||
interfaceRevisionId: id,
|
||||
|
||||
Reference in New Issue
Block a user