fakeplane 0.0.0-stage → 0.1.0
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/LICENSE +202 -0
- package/NOTICE +12 -0
- package/README.md +225 -2
- package/demo/agents/careful.mjs +89 -0
- package/demo/agents/naive.mjs +50 -0
- package/demo/scenarios/large-refund-escalation.yaml +38 -0
- package/demo/scenarios/refund-ambiguous-timeout.yaml +40 -0
- package/demo/scenarios/refund-duplicate-webhook.yaml +40 -0
- package/dist/agent.d.ts +28 -0
- package/dist/agent.js +113 -0
- package/dist/agent.js.map +1 -0
- package/dist/assertions.d.ts +21 -0
- package/dist/assertions.js +180 -0
- package/dist/assertions.js.map +1 -0
- package/dist/backends/common.d.ts +13 -0
- package/dist/backends/common.js +37 -0
- package/dist/backends/common.js.map +1 -0
- package/dist/backends/generic.d.ts +79 -0
- package/dist/backends/generic.js +227 -0
- package/dist/backends/generic.js.map +1 -0
- package/dist/backends/graphql.d.ts +22 -0
- package/dist/backends/graphql.js +248 -0
- package/dist/backends/graphql.js.map +1 -0
- package/dist/backends/index.d.ts +24 -0
- package/dist/backends/index.js +27 -0
- package/dist/backends/index.js.map +1 -0
- package/dist/backends/linear.d.ts +123 -0
- package/dist/backends/linear.js +451 -0
- package/dist/backends/linear.js.map +1 -0
- package/dist/backends/slack.d.ts +92 -0
- package/dist/backends/slack.js +221 -0
- package/dist/backends/slack.js.map +1 -0
- package/dist/backends/zendesk.d.ts +94 -0
- package/dist/backends/zendesk.js +455 -0
- package/dist/backends/zendesk.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +340 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/matchers.d.ts +11 -0
- package/dist/matchers.js +156 -0
- package/dist/matchers.js.map +1 -0
- package/dist/mcp.d.ts +43 -0
- package/dist/mcp.js +116 -0
- package/dist/mcp.js.map +1 -0
- package/dist/pii.d.ts +17 -0
- package/dist/pii.js +79 -0
- package/dist/pii.js.map +1 -0
- package/dist/report.d.ts +13 -0
- package/dist/report.js +97 -0
- package/dist/report.js.map +1 -0
- package/dist/runner.d.ts +56 -0
- package/dist/runner.js +114 -0
- package/dist/runner.js.map +1 -0
- package/dist/scenario.d.ts +270 -0
- package/dist/scenario.js +270 -0
- package/dist/scenario.js.map +1 -0
- package/dist/server.d.ts +40 -0
- package/dist/server.js +241 -0
- package/dist/server.js.map +1 -0
- package/dist/trace.d.ts +42 -0
- package/dist/trace.js +432 -0
- package/dist/trace.js.map +1 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +13 -0
- package/dist/util.js +89 -0
- package/dist/util.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/world.d.ts +149 -0
- package/dist/world.js +187 -0
- package/dist/world.js.map +1 -0
- package/package.json +68 -4
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { ApiError } from "../types.js";
|
|
2
|
+
import { matchValue } from "../matchers.js";
|
|
3
|
+
import { isPlainObject, renderTemplate } from "../util.js";
|
|
4
|
+
import { IDEMPOTENCY_KEY, obj, required, str } from "./common.js";
|
|
5
|
+
export class GenericBackend {
|
|
6
|
+
world;
|
|
7
|
+
name = "generic";
|
|
8
|
+
mounts = [{ prefix: "/generic", strip: true }];
|
|
9
|
+
collections = new Map();
|
|
10
|
+
customRoutes;
|
|
11
|
+
customTools;
|
|
12
|
+
exposeCollectionTools;
|
|
13
|
+
constructor(world, seed = {}) {
|
|
14
|
+
this.world = world;
|
|
15
|
+
for (const [name, records] of Object.entries(seed.collections ?? {})) {
|
|
16
|
+
const map = new Map();
|
|
17
|
+
for (const r of records) {
|
|
18
|
+
const id = String(r.id ?? `${name}_${world.next(`generic.${name}`)}`);
|
|
19
|
+
map.set(id, { ...r, id: r.id ?? id });
|
|
20
|
+
}
|
|
21
|
+
this.collections.set(name, map);
|
|
22
|
+
}
|
|
23
|
+
this.customRoutes = seed.routes ?? [];
|
|
24
|
+
this.customTools = seed.tools ?? [];
|
|
25
|
+
this.exposeCollectionTools = seed.collection_tools ?? this.collections.size > 0;
|
|
26
|
+
}
|
|
27
|
+
coll(name, create = false) {
|
|
28
|
+
const key = String(name ?? "");
|
|
29
|
+
let c = this.collections.get(key);
|
|
30
|
+
if (!c && create) {
|
|
31
|
+
c = new Map();
|
|
32
|
+
this.collections.set(key, c);
|
|
33
|
+
}
|
|
34
|
+
if (!c)
|
|
35
|
+
throw new ApiError(404, "not_found", `Collection ${key} not found`);
|
|
36
|
+
return c;
|
|
37
|
+
}
|
|
38
|
+
record(collection, id) {
|
|
39
|
+
const r = this.coll(collection).get(String(id));
|
|
40
|
+
if (!r)
|
|
41
|
+
throw new ApiError(404, "not_found", `${String(collection)}/${String(id)} not found`);
|
|
42
|
+
return r;
|
|
43
|
+
}
|
|
44
|
+
create(ctx, collection, data) {
|
|
45
|
+
const c = this.coll(collection, true);
|
|
46
|
+
const id = String(data.id ?? `${collection}_${this.world.next(`generic.${collection}`)}`);
|
|
47
|
+
if (c.has(id))
|
|
48
|
+
throw new ApiError(409, "conflict", `${collection}/${id} already exists`);
|
|
49
|
+
const rec = { ...data, id: data.id ?? id, created_at: ctx.now() };
|
|
50
|
+
c.set(id, rec);
|
|
51
|
+
ctx.effect(`generic.${collection}.create`, { ...rec }, collection);
|
|
52
|
+
return { ...rec };
|
|
53
|
+
}
|
|
54
|
+
update(ctx, collection, id, data) {
|
|
55
|
+
const rec = this.record(collection, id);
|
|
56
|
+
Object.assign(rec, data, { id: rec.id, updated_at: ctx.now() });
|
|
57
|
+
ctx.effect(`generic.${collection}.update`, { id, changes: data }, `${collection}:${id}`);
|
|
58
|
+
return { ...rec };
|
|
59
|
+
}
|
|
60
|
+
remove(ctx, collection, id) {
|
|
61
|
+
this.record(collection, id);
|
|
62
|
+
this.coll(collection).delete(id);
|
|
63
|
+
ctx.effect(`generic.${collection}.delete`, { id }, `${collection}:${id}`);
|
|
64
|
+
return { id, deleted: true };
|
|
65
|
+
}
|
|
66
|
+
operations() {
|
|
67
|
+
const b = "generic";
|
|
68
|
+
const expose = this.exposeCollectionTools;
|
|
69
|
+
const collectionOps = [
|
|
70
|
+
{
|
|
71
|
+
id: "generic.list",
|
|
72
|
+
backend: b,
|
|
73
|
+
write: false,
|
|
74
|
+
tool: expose ? { name: "generic_list", description: `List records in a collection (${[...this.collections.keys()].join(", ")}). Optional exact-match filter.`, inputSchema: obj({ collection: str("Collection name"), where: { type: "object", description: "Field filter" } }, ["collection"]) } : undefined,
|
|
75
|
+
run: (input) => [...this.coll(required(input, "collection")).values()].filter((r) => !input.where || matchValue(r, input.where).ok).map((r) => ({ ...r })),
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "generic.get",
|
|
79
|
+
backend: b,
|
|
80
|
+
write: false,
|
|
81
|
+
tool: expose ? { name: "generic_get", description: "Get one record by id.", inputSchema: obj({ collection: str("Collection name"), id: str("Record id") }, ["collection", "id"]) } : undefined,
|
|
82
|
+
run: (input) => ({ ...this.record(required(input, "collection"), required(input, "id")) }),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "generic.create",
|
|
86
|
+
backend: b,
|
|
87
|
+
write: true,
|
|
88
|
+
tool: expose ? { name: "generic_create", description: "Create a record.", inputSchema: obj({ collection: str("Collection name"), data: { type: "object", description: "Record fields" }, idempotency_key: IDEMPOTENCY_KEY }, ["collection", "data"]) } : undefined,
|
|
89
|
+
run: (input, ctx) => this.create(ctx, String(required(input, "collection")), input.data ?? {}),
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: "generic.update",
|
|
93
|
+
backend: b,
|
|
94
|
+
write: true,
|
|
95
|
+
tool: expose ? { name: "generic_update", description: "Merge fields into a record.", inputSchema: obj({ collection: str("Collection name"), id: str("Record id"), data: { type: "object", description: "Fields to set" }, idempotency_key: IDEMPOTENCY_KEY }, ["collection", "id", "data"]) } : undefined,
|
|
96
|
+
run: (input, ctx) => this.update(ctx, String(required(input, "collection")), String(required(input, "id")), input.data ?? {}),
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: "generic.delete",
|
|
100
|
+
backend: b,
|
|
101
|
+
write: true,
|
|
102
|
+
tool: expose ? { name: "generic_delete", description: "Delete a record.", inputSchema: obj({ collection: str("Collection name"), id: str("Record id"), idempotency_key: IDEMPOTENCY_KEY }, ["collection", "id"]) } : undefined,
|
|
103
|
+
run: (input, ctx) => this.remove(ctx, String(required(input, "collection")), String(required(input, "id"))),
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
const routeOps = this.customRoutes.map((route) => {
|
|
107
|
+
const method = (route.method ?? "GET").toUpperCase();
|
|
108
|
+
const name = route.name ?? `${method} ${route.path}`;
|
|
109
|
+
const write = method !== "GET" || route.effect !== undefined;
|
|
110
|
+
return {
|
|
111
|
+
id: `generic.route.${name}`,
|
|
112
|
+
backend: b,
|
|
113
|
+
write,
|
|
114
|
+
run: (input, ctx) => {
|
|
115
|
+
const flat = { ...(isPlainObject(input.body) ? input.body : {}), params: input.params, query: input.query };
|
|
116
|
+
applyRejects(route.reject, flat);
|
|
117
|
+
const id = `${slugify(name)}_${this.world.next(`generic.route.${name}`)}`;
|
|
118
|
+
if (write)
|
|
119
|
+
ctx.effect(`generic.${route.effect ?? slugify(name)}`, isPlainObject(input.body) ? { ...input.body, params: input.params } : { body: input.body, params: input.params });
|
|
120
|
+
const vars = { ...input, input: flat, id, now: ctx.now() };
|
|
121
|
+
return route.response === undefined ? { ok: true, id } : renderTemplate(route.response, vars);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
const toolOps = this.customTools.map((tool) => {
|
|
126
|
+
const write = tool.write ?? (tool.effect !== undefined || ["create", "update", "delete"].includes(tool.action ?? ""));
|
|
127
|
+
return {
|
|
128
|
+
id: `generic.tool.${tool.name}`,
|
|
129
|
+
backend: b,
|
|
130
|
+
write,
|
|
131
|
+
tool: {
|
|
132
|
+
name: tool.name,
|
|
133
|
+
description: tool.description ?? `Custom tool ${tool.name}`,
|
|
134
|
+
inputSchema: withIdempotency(tool.inputSchema ?? { type: "object", properties: {}, additionalProperties: true }, write),
|
|
135
|
+
},
|
|
136
|
+
run: (input = {}, ctx) => {
|
|
137
|
+
applyRejects(tool.reject, input);
|
|
138
|
+
const { idempotency_key: _k, ...data } = input;
|
|
139
|
+
const idField = tool.id_field ?? "id";
|
|
140
|
+
let result;
|
|
141
|
+
if (tool.collection) {
|
|
142
|
+
const action = tool.action ?? "get";
|
|
143
|
+
if (action === "list")
|
|
144
|
+
result = [...this.coll(tool.collection, true).values()].filter((r) => matchValue(r, data).ok).map((r) => ({ ...r }));
|
|
145
|
+
else if (action === "get")
|
|
146
|
+
result = { ...this.record(tool.collection, required(data, idField)) };
|
|
147
|
+
else if (action === "create")
|
|
148
|
+
result = this.create(ctx, tool.collection, data);
|
|
149
|
+
else if (action === "update") {
|
|
150
|
+
const { [idField]: id, ...rest } = data;
|
|
151
|
+
result = this.update(ctx, tool.collection, String(required(data, idField)), rest);
|
|
152
|
+
void id;
|
|
153
|
+
}
|
|
154
|
+
else
|
|
155
|
+
result = this.remove(ctx, tool.collection, String(required(data, idField)));
|
|
156
|
+
if (tool.effect)
|
|
157
|
+
ctx.effect(`generic.${tool.effect}`, data);
|
|
158
|
+
}
|
|
159
|
+
else if (write) {
|
|
160
|
+
ctx.effect(`generic.${tool.effect ?? tool.name}`, data);
|
|
161
|
+
}
|
|
162
|
+
const callNo = this.world.next(`generic.tool.${tool.name}`);
|
|
163
|
+
const canned = tool.responses?.length ? tool.responses[Math.min(callNo, tool.responses.length) - 1] : tool.response;
|
|
164
|
+
if (canned !== undefined) {
|
|
165
|
+
return renderTemplate(canned, { input: data, result, now: ctx.now(), id: `${tool.name}_${callNo}` });
|
|
166
|
+
}
|
|
167
|
+
return result ?? { ok: true };
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
return [...collectionOps, ...routeOps, ...toolOps];
|
|
172
|
+
}
|
|
173
|
+
/** Custom routes, which are also served at their literal path outside `/generic`. */
|
|
174
|
+
fallbackRoutes() {
|
|
175
|
+
return this.customRoutes.map((route) => {
|
|
176
|
+
const method = (route.method ?? "GET").toUpperCase();
|
|
177
|
+
const name = route.name ?? `${method} ${route.path}`;
|
|
178
|
+
return {
|
|
179
|
+
method,
|
|
180
|
+
path: route.path,
|
|
181
|
+
op: `generic.route.${name}`,
|
|
182
|
+
toInput: (r) => ({ params: r.params, query: r.query, body: r.body }),
|
|
183
|
+
toResponse: (res) => ({ status: route.status ?? (method === "POST" ? 201 : 200), body: res }),
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
routes() {
|
|
188
|
+
return [
|
|
189
|
+
...this.fallbackRoutes(),
|
|
190
|
+
{ method: "GET", path: "/:collection", op: "generic.list", toInput: (r) => ({ collection: r.params.collection, where: Object.keys(r.query).length ? r.query : undefined }), toResponse: (res) => ({ body: { data: res } }) },
|
|
191
|
+
{ method: "GET", path: "/:collection/:id", op: "generic.get", toInput: (r) => ({ collection: r.params.collection, id: r.params.id }) },
|
|
192
|
+
{ method: "POST", path: "/:collection", op: "generic.create", toInput: (r) => ({ collection: r.params.collection, data: r.body ?? {} }), toResponse: (res) => ({ status: 201, body: res }) },
|
|
193
|
+
{ method: "PATCH", path: "/:collection/:id", op: "generic.update", toInput: (r) => ({ collection: r.params.collection, id: r.params.id, data: r.body ?? {} }) },
|
|
194
|
+
{ method: "PUT", path: "/:collection/:id", op: "generic.update", toInput: (r) => ({ collection: r.params.collection, id: r.params.id, data: r.body ?? {} }) },
|
|
195
|
+
{ method: "DELETE", path: "/:collection/:id", op: "generic.delete", toInput: (r) => ({ collection: r.params.collection, id: r.params.id }) },
|
|
196
|
+
];
|
|
197
|
+
}
|
|
198
|
+
errorResponse(err) {
|
|
199
|
+
const headers = err.retryAfter !== undefined ? { "Retry-After": String(err.retryAfter) } : {};
|
|
200
|
+
return { status: err.status, body: { error: { code: err.code, message: err.message } }, headers };
|
|
201
|
+
}
|
|
202
|
+
snapshot() {
|
|
203
|
+
const out = {};
|
|
204
|
+
for (const [name, c] of this.collections)
|
|
205
|
+
out[name] = Object.fromEntries([...c].map(([id, r]) => [id, { ...r }]));
|
|
206
|
+
return { collections: out };
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function applyRejects(rules, input) {
|
|
210
|
+
for (const rule of rules ?? []) {
|
|
211
|
+
if (matchValue(input, rule.when).ok) {
|
|
212
|
+
throw new ApiError(rule.status ?? 422, rule.code ?? "rejected", rule.message ?? "Request rejected");
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function withIdempotency(schema, write) {
|
|
217
|
+
if (!write || schema.type !== "object")
|
|
218
|
+
return schema;
|
|
219
|
+
return { ...schema, properties: { ...(schema.properties ?? {}), idempotency_key: IDEMPOTENCY_KEY } };
|
|
220
|
+
}
|
|
221
|
+
function slugify(s) {
|
|
222
|
+
return s
|
|
223
|
+
.toLowerCase()
|
|
224
|
+
.replace(/[^a-z0-9]+/g, "_")
|
|
225
|
+
.replace(/^_|_$/g, "");
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=generic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../../src/backends/generic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAoC,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAgDlE,MAAM,OAAO,cAAc;IAS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AAC,MAAM,IAAI,GAAG,EAAE,IAAI,CAAC,IAAI,IAAI,UAAU,EAAE,IAAI,CAAC,OAAO,IAAI,kBAAkB,CAAC,CAAC;QACtG,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,MAAkB,EAAE,KAAc;IACzD,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IACtD,OAAO,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,eAAe,EAAE,eAAe,EAAE,EAAE,CAAC;AACvG,CAAC;AAED,SAAS,OAAO,CAAC,CAAS;IACxB,OAAO,CAAC;SACL,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A deliberately small GraphQL reader: enough to route root fields to fake
|
|
3
|
+
* operations, resolve arguments (literals and variables), and project results
|
|
4
|
+
* onto the requested selection set. No schema validation, no directives.
|
|
5
|
+
*/
|
|
6
|
+
export interface GqlField {
|
|
7
|
+
alias?: string;
|
|
8
|
+
name: string;
|
|
9
|
+
args: Record<string, unknown>;
|
|
10
|
+
/** undefined = leaf; "*" = contains fragments, return everything at this level. */
|
|
11
|
+
selection?: GqlField[] | "*";
|
|
12
|
+
}
|
|
13
|
+
export interface GqlOperation {
|
|
14
|
+
type: "query" | "mutation" | "subscription";
|
|
15
|
+
name?: string;
|
|
16
|
+
fields: GqlField[];
|
|
17
|
+
}
|
|
18
|
+
export declare class GraphQLSyntaxError extends Error {
|
|
19
|
+
}
|
|
20
|
+
export declare function parseOperation(query: string, variables?: Record<string, unknown>, operationName?: string): GqlOperation;
|
|
21
|
+
/** Keep only the fields the query asked for. */
|
|
22
|
+
export declare function project(value: unknown, selection: GqlField[] | "*" | undefined): unknown;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A deliberately small GraphQL reader: enough to route root fields to fake
|
|
3
|
+
* operations, resolve arguments (literals and variables), and project results
|
|
4
|
+
* onto the requested selection set. No schema validation, no directives.
|
|
5
|
+
*/
|
|
6
|
+
function tokenize(src) {
|
|
7
|
+
const tokens = [];
|
|
8
|
+
let i = 0;
|
|
9
|
+
while (i < src.length) {
|
|
10
|
+
const c = src[i];
|
|
11
|
+
if (c === "#") {
|
|
12
|
+
while (i < src.length && src[i] !== "\n")
|
|
13
|
+
i++;
|
|
14
|
+
}
|
|
15
|
+
else if (/[\s,\uFEFF]/.test(c)) {
|
|
16
|
+
i++;
|
|
17
|
+
}
|
|
18
|
+
else if (src.startsWith("...", i)) {
|
|
19
|
+
tokens.push({ kind: "spread", value: "..." });
|
|
20
|
+
i += 3;
|
|
21
|
+
}
|
|
22
|
+
else if ("!$():=@[]{}|&".includes(c)) {
|
|
23
|
+
tokens.push({ kind: "punct", value: c });
|
|
24
|
+
i++;
|
|
25
|
+
}
|
|
26
|
+
else if (/[A-Za-z_]/.test(c)) {
|
|
27
|
+
const m = /^[A-Za-z_][A-Za-z0-9_]*/.exec(src.slice(i));
|
|
28
|
+
tokens.push({ kind: "name", value: m[0] });
|
|
29
|
+
i += m[0].length;
|
|
30
|
+
}
|
|
31
|
+
else if (/[-0-9]/.test(c)) {
|
|
32
|
+
const m = /^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(src.slice(i));
|
|
33
|
+
if (!m)
|
|
34
|
+
throw new GraphQLSyntaxError(`Unexpected character ${c}`);
|
|
35
|
+
tokens.push({ kind: "number", value: m[0] });
|
|
36
|
+
i += m[0].length;
|
|
37
|
+
}
|
|
38
|
+
else if (src.startsWith('"""', i)) {
|
|
39
|
+
const end = src.indexOf('"""', i + 3);
|
|
40
|
+
if (end < 0)
|
|
41
|
+
throw new GraphQLSyntaxError("Unterminated block string");
|
|
42
|
+
tokens.push({ kind: "string", value: dedentBlock(src.slice(i + 3, end)) });
|
|
43
|
+
i = end + 3;
|
|
44
|
+
}
|
|
45
|
+
else if (c === '"') {
|
|
46
|
+
let j = i + 1;
|
|
47
|
+
let out = "";
|
|
48
|
+
while (j < src.length && src[j] !== '"') {
|
|
49
|
+
if (src[j] === "\\") {
|
|
50
|
+
const n = src[j + 1];
|
|
51
|
+
if (n === "u") {
|
|
52
|
+
out += String.fromCharCode(parseInt(src.slice(j + 2, j + 6), 16));
|
|
53
|
+
j += 6;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
out += { n: "\n", t: "\t", r: "\r", b: "\b", f: "\f" }[n] ?? n;
|
|
57
|
+
j += 2;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
out += src[j++];
|
|
61
|
+
}
|
|
62
|
+
if (j >= src.length)
|
|
63
|
+
throw new GraphQLSyntaxError("Unterminated string");
|
|
64
|
+
tokens.push({ kind: "string", value: out });
|
|
65
|
+
i = j + 1;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
throw new GraphQLSyntaxError(`Unexpected character ${c}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return tokens;
|
|
72
|
+
}
|
|
73
|
+
function dedentBlock(raw) {
|
|
74
|
+
const lines = raw.replace(/\r\n/g, "\n").split("\n");
|
|
75
|
+
const indent = Math.min(...lines.slice(1).filter((l) => l.trim()).map((l) => /^\s*/.exec(l)[0].length), Infinity);
|
|
76
|
+
return lines
|
|
77
|
+
.map((l, idx) => (idx === 0 || !Number.isFinite(indent) ? l : l.slice(indent)))
|
|
78
|
+
.join("\n")
|
|
79
|
+
.trim();
|
|
80
|
+
}
|
|
81
|
+
export class GraphQLSyntaxError extends Error {
|
|
82
|
+
}
|
|
83
|
+
export function parseOperation(query, variables = {}, operationName) {
|
|
84
|
+
const tokens = tokenize(query);
|
|
85
|
+
let pos = 0;
|
|
86
|
+
const peek = () => tokens[pos];
|
|
87
|
+
const next = () => {
|
|
88
|
+
const t = tokens[pos++];
|
|
89
|
+
if (!t)
|
|
90
|
+
throw new GraphQLSyntaxError("Unexpected end of query");
|
|
91
|
+
return t;
|
|
92
|
+
};
|
|
93
|
+
const expect = (value) => {
|
|
94
|
+
const t = next();
|
|
95
|
+
if (t.value !== value)
|
|
96
|
+
throw new GraphQLSyntaxError(`Expected ${value}, got ${t.value}`);
|
|
97
|
+
};
|
|
98
|
+
const parseValue = () => {
|
|
99
|
+
const t = next();
|
|
100
|
+
if (t.kind === "punct" && t.value === "$")
|
|
101
|
+
return variables[next().value];
|
|
102
|
+
if (t.kind === "number")
|
|
103
|
+
return Number(t.value);
|
|
104
|
+
if (t.kind === "string")
|
|
105
|
+
return t.value;
|
|
106
|
+
if (t.kind === "name")
|
|
107
|
+
return t.value === "true" ? true : t.value === "false" ? false : t.value === "null" ? null : t.value;
|
|
108
|
+
if (t.value === "[") {
|
|
109
|
+
const list = [];
|
|
110
|
+
while (peek()?.value !== "]")
|
|
111
|
+
list.push(parseValue());
|
|
112
|
+
next();
|
|
113
|
+
return list;
|
|
114
|
+
}
|
|
115
|
+
if (t.value === "{") {
|
|
116
|
+
const o = {};
|
|
117
|
+
while (peek()?.value !== "}") {
|
|
118
|
+
const key = next().value;
|
|
119
|
+
expect(":");
|
|
120
|
+
o[key] = parseValue();
|
|
121
|
+
}
|
|
122
|
+
next();
|
|
123
|
+
return o;
|
|
124
|
+
}
|
|
125
|
+
throw new GraphQLSyntaxError(`Unexpected ${t.value}`);
|
|
126
|
+
};
|
|
127
|
+
const parseArgs = () => {
|
|
128
|
+
const args = {};
|
|
129
|
+
if (peek()?.value !== "(")
|
|
130
|
+
return args;
|
|
131
|
+
next();
|
|
132
|
+
while (peek()?.value !== ")") {
|
|
133
|
+
const key = next().value;
|
|
134
|
+
expect(":");
|
|
135
|
+
args[key] = parseValue();
|
|
136
|
+
}
|
|
137
|
+
next();
|
|
138
|
+
return args;
|
|
139
|
+
};
|
|
140
|
+
const skipDirectives = () => {
|
|
141
|
+
while (peek()?.value === "@") {
|
|
142
|
+
next();
|
|
143
|
+
next();
|
|
144
|
+
parseArgs();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const parseSelection = () => {
|
|
148
|
+
expect("{");
|
|
149
|
+
const fields = [];
|
|
150
|
+
let star = false;
|
|
151
|
+
while (peek()?.value !== "}") {
|
|
152
|
+
if (peek()?.kind === "spread") {
|
|
153
|
+
next();
|
|
154
|
+
star = true;
|
|
155
|
+
if (peek()?.value === "on") {
|
|
156
|
+
next();
|
|
157
|
+
next();
|
|
158
|
+
}
|
|
159
|
+
else if (peek()?.kind === "name")
|
|
160
|
+
next();
|
|
161
|
+
skipDirectives();
|
|
162
|
+
if (peek()?.value === "{")
|
|
163
|
+
parseSelection();
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
let name = next().value;
|
|
167
|
+
let alias;
|
|
168
|
+
if (peek()?.value === ":") {
|
|
169
|
+
next();
|
|
170
|
+
alias = name;
|
|
171
|
+
name = next().value;
|
|
172
|
+
}
|
|
173
|
+
const args = parseArgs();
|
|
174
|
+
skipDirectives();
|
|
175
|
+
const selection = peek()?.value === "{" ? parseSelection() : undefined;
|
|
176
|
+
fields.push({ alias, name, args, selection });
|
|
177
|
+
}
|
|
178
|
+
next();
|
|
179
|
+
return star ? "*" : fields;
|
|
180
|
+
};
|
|
181
|
+
const skipVariableDefs = () => {
|
|
182
|
+
if (peek()?.value !== "(")
|
|
183
|
+
return;
|
|
184
|
+
let depth = 0;
|
|
185
|
+
do {
|
|
186
|
+
const t = next();
|
|
187
|
+
if (t.value === "(")
|
|
188
|
+
depth++;
|
|
189
|
+
if (t.value === ")")
|
|
190
|
+
depth--;
|
|
191
|
+
} while (depth > 0);
|
|
192
|
+
};
|
|
193
|
+
const ops = [];
|
|
194
|
+
while (pos < tokens.length) {
|
|
195
|
+
const t = peek();
|
|
196
|
+
if (t.value === "{") {
|
|
197
|
+
const sel = parseSelection();
|
|
198
|
+
ops.push({ type: "query", fields: sel === "*" ? [] : sel });
|
|
199
|
+
}
|
|
200
|
+
else if (t.value === "fragment") {
|
|
201
|
+
next();
|
|
202
|
+
next();
|
|
203
|
+
next();
|
|
204
|
+
next();
|
|
205
|
+
skipDirectives();
|
|
206
|
+
parseSelection();
|
|
207
|
+
}
|
|
208
|
+
else if (t.value === "query" || t.value === "mutation" || t.value === "subscription") {
|
|
209
|
+
next();
|
|
210
|
+
const name = peek()?.kind === "name" ? next().value : undefined;
|
|
211
|
+
skipVariableDefs();
|
|
212
|
+
skipDirectives();
|
|
213
|
+
const sel = parseSelection();
|
|
214
|
+
ops.push({ type: t.value, name, fields: sel === "*" ? [] : sel });
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
throw new GraphQLSyntaxError(`Unexpected ${t.value}`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (ops.length === 0)
|
|
221
|
+
throw new GraphQLSyntaxError("No operation in document");
|
|
222
|
+
if (operationName) {
|
|
223
|
+
const op = ops.find((o) => o.name === operationName);
|
|
224
|
+
if (!op)
|
|
225
|
+
throw new GraphQLSyntaxError(`Unknown operation ${operationName}`);
|
|
226
|
+
return op;
|
|
227
|
+
}
|
|
228
|
+
return ops[0];
|
|
229
|
+
}
|
|
230
|
+
/** Keep only the fields the query asked for. */
|
|
231
|
+
export function project(value, selection) {
|
|
232
|
+
if (selection === undefined || selection === "*" || value === null || value === undefined)
|
|
233
|
+
return value;
|
|
234
|
+
if (Array.isArray(value))
|
|
235
|
+
return value.map((v) => project(v, selection));
|
|
236
|
+
if (typeof value !== "object")
|
|
237
|
+
return value;
|
|
238
|
+
const src = value;
|
|
239
|
+
const out = {};
|
|
240
|
+
for (const f of selection) {
|
|
241
|
+
if (f.name === "__typename")
|
|
242
|
+
out[f.alias ?? f.name] = src.__typename ?? null;
|
|
243
|
+
else
|
|
244
|
+
out[f.alias ?? f.name] = project(src[f.name] ?? null, f.selection);
|
|
245
|
+
}
|
|
246
|
+
return out;
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=graphql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../src/backends/graphql.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH,SAAS,QAAQ,CAAC,GAAW;IAC3B,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI;gBAAE,CAAC,EAAE,CAAC;QAChD,CAAC;aAAM,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YACjC,CAAC,EAAE,CAAC;QACN,CAAC;aAAM,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC;YACpC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YAC9C,CAAC,IAAI,CAAC,CAAC;QACT,CAAC;aAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YACvC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;YACzC,CAAC,EAAE,CAAC;QACN,CAAC;aAAM,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,GAAG,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,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CAAC;IACxC,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;QAC1B,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY;YAAE,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC;;YACxE,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { World, type FaultSpec } from "../world.js";
|
|
2
|
+
import { GenericBackend, type GenericSeed } from "./generic.js";
|
|
3
|
+
import { LinearBackend, type LinearSeed } from "./linear.js";
|
|
4
|
+
import { SlackBackend, type SlackSeed } from "./slack.js";
|
|
5
|
+
import { ZendeskBackend, type ZendeskSeed } from "./zendesk.js";
|
|
6
|
+
export { GenericBackend, LinearBackend, SlackBackend, ZendeskBackend };
|
|
7
|
+
export type { GenericSeed, LinearSeed, SlackSeed, ZendeskSeed };
|
|
8
|
+
export declare const BACKEND_NAMES: readonly ["zendesk", "slack", "linear", "generic"];
|
|
9
|
+
export type BackendName = (typeof BACKEND_NAMES)[number];
|
|
10
|
+
export interface Seed {
|
|
11
|
+
zendesk?: ZendeskSeed;
|
|
12
|
+
slack?: SlackSeed;
|
|
13
|
+
linear?: LinearSeed;
|
|
14
|
+
generic?: GenericSeed;
|
|
15
|
+
}
|
|
16
|
+
export interface CreateWorldOptions {
|
|
17
|
+
scenario?: string;
|
|
18
|
+
clock?: string;
|
|
19
|
+
seed?: Seed;
|
|
20
|
+
faults?: FaultSpec[];
|
|
21
|
+
/** Backends to enable. Defaults to those present in `seed`, or all four when the seed is empty. */
|
|
22
|
+
backends?: BackendName[];
|
|
23
|
+
}
|
|
24
|
+
export declare function createWorld(options?: CreateWorldOptions): World;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { World } from "../world.js";
|
|
2
|
+
import { GenericBackend } from "./generic.js";
|
|
3
|
+
import { LinearBackend } from "./linear.js";
|
|
4
|
+
import { SlackBackend } from "./slack.js";
|
|
5
|
+
import { ZendeskBackend } from "./zendesk.js";
|
|
6
|
+
export { GenericBackend, LinearBackend, SlackBackend, ZendeskBackend };
|
|
7
|
+
export const BACKEND_NAMES = ["zendesk", "slack", "linear", "generic"];
|
|
8
|
+
export function createWorld(options = {}) {
|
|
9
|
+
const seed = options.seed ?? {};
|
|
10
|
+
const world = new World({ scenario: options.scenario, clock: options.clock, faults: options.faults });
|
|
11
|
+
const seeded = BACKEND_NAMES.filter((n) => seed[n] !== undefined);
|
|
12
|
+
const enabled = options.backends ?? (seeded.length ? seeded : [...BACKEND_NAMES]);
|
|
13
|
+
for (const name of enabled) {
|
|
14
|
+
if (name === "zendesk")
|
|
15
|
+
world.addBackend(new ZendeskBackend(world, seed.zendesk));
|
|
16
|
+
else if (name === "slack")
|
|
17
|
+
world.addBackend(new SlackBackend(world, seed.slack));
|
|
18
|
+
else if (name === "linear")
|
|
19
|
+
world.addBackend(new LinearBackend(world, seed.linear));
|
|
20
|
+
else if (name === "generic")
|
|
21
|
+
world.addBackend(new GenericBackend(world, seed.generic));
|
|
22
|
+
else
|
|
23
|
+
throw new Error(`Unknown backend ${String(name)}`);
|
|
24
|
+
}
|
|
25
|
+
return world;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backends/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAkB,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,cAAc,EAAoB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,aAAa,EAAmB,MAAM,aAAa,CA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