Files
quixos-protocol/test/fixtures/query-aggregation.ts
T
Timothy J. Aveni a05f58f7fe Build query-backed task tracker default template
Add shared colored tags, native tag/status filters, cursor-paged task and
completion views, estimated-hour aggregates and repeat-after-completion actions.
Keep task views independently renderable and isolate component styling.

Cover immutable fresh-template/additive checks, real PostgreSQL/orch package
actions and query watches, and wide/narrow browser layouts. Accept documented
hyphenated query budget names in the capability lexer.

Template publication/default selection pending installation AWS SSO renewal;
no live workspace data or deployment configuration changed.
2026-09-17 23:40:14 -07:00

72 lines
3.4 KiB
TypeScript

import assert from "node:assert/strict";
import { compileCapabilityResourceSource } from "../../src/capability-language/index.js";
import type { InterfaceRevision } from "../../src/capability-model/types.js";
import { compileQuery } from "../../src/query/compile.js";
const source = { repository: "https://example.test/aggregation.git", commit: "a".repeat(40) };
const interfaces: InterfaceRevision[] = [];
function resource(text: string) {
const result = compileCapabilityResourceSource(`external atom TaskObject id "task";\n${text}`, {
source,
environment: {
interfaces: new Map(interfaces.map((i) => [i.displayName, i])),
interfaceClosure: interfaces,
},
});
assert.ok(result.ok, JSON.stringify(result.diagnostics));
if (result.resource.kind === "interface") interfaces.push(result.resource.revision);
return result.resource;
}
resource(`interface Person id "person" revision "person@1" {
queryable value name id "name" : string { get id "name:get"; }
}`);
resource(`interface Tag id "tag" revision "tag@1" {
queryable value color id "color" : string { get id "color:get"; }
queryable relation tasks id "tag-tasks" : many atom TaskObject { resolve id "tag-tasks:resolve"; }
}`);
resource(`import interface Tag; import interface Person;
interface Task id "task" revision "task@1" {
queryable value estimatedHours id "hours" : optional<double> { get id "hours:get"; }
queryable value cost id "cost" : int64 { get id "cost:get"; }
queryable rpc value score id "score" : optional<double> { get id "score:get"; }
queryable relation tags id "tags" : many-unique interface Tag { resolve id "tags:resolve"; }
queryable relation assignee id "assignee" : optional-one interface Person { resolve id "assignee:resolve"; }
}`);
resource(`import interface Task;
interface Tasks id "tasks" revision "tasks@1" {
queryable relation tasks id "tasks" : many-unique interface Task { resolve id "tasks:resolve"; }
queryable relation copies id "copies" : many interface Task ordered { resolve id "copies:resolve"; }
queryable relation slots id "slots" : many interface Task keyed "int64" { resolve id "slots:resolve"; }
}`);
const pkg = resource(`import interface Tasks; import interface Task;
package Reports id "reports" revision "reports@1" {
query Report id "report" root Tasks document "report.graphql" operation "Report" {
max rows 50;
max result-bytes 1048576;
max rpc-calls 100;
max deadline-ms 10000;
view TaskObject as Task;
allow Task.score aggregate "Bounded aggregation fixture";
allow Task.score predicate "Bounded aggregation fixture";
allow Task.score order "Bounded aggregation fixture";
allow Task.score group "Bounded aggregation fixture";
allow Task.score distinct "Bounded aggregation fixture";
}
}`);
if (pkg.kind !== "package") throw new Error("package expected");
const declaration = pkg.revision.queries![0]!;
export const compileAggregationDocument = (document: string) =>
compileQuery(declaration, interfaces, async () => document);
export const aggregationBindingSchema = (checked: Awaited<ReturnType<typeof compileQuery>>) => ({
format: "quixos-bindings" as const,
version: 1 as const,
interfaces,
packages: [{ ...pkg.revision, checkedQueries: [checked] }],
});
export const compileAggregation = (body: string, variables = "") =>
compileQuery(
declaration,
interfaces,
async () => `query Report${variables} { root { _qx { relations { tasks { ${body} } } } } }`,
);