@panneau/protocol 5.0.0-alpha.12 → 5.0.0-alpha.13
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/conformance/index.d.ts +6 -0
- package/dist/conformance/index.d.ts.map +1 -1
- package/dist/conformance/index.js +185 -2
- package/dist/conformance/index.js.map +1 -1
- package/dist/constants.d.ts +12 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +22 -2
- package/dist/constants.js.map +1 -1
- package/dist/context.d.ts +15 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +34 -0
- package/dist/context.js.map +1 -0
- package/dist/index.js +6 -5
- package/dist/lint.d.ts.map +1 -1
- package/dist/lint.js +17 -0
- package/dist/lint.js.map +1 -1
- package/dist/mock/index.d.ts +25 -4
- package/dist/mock/index.d.ts.map +1 -1
- package/dist/mock/index.js +129 -29
- package/dist/mock/index.js.map +1 -1
- package/dist/openapi.d.ts.map +1 -1
- package/dist/openapi.js +57 -5
- package/dist/openapi.js.map +1 -1
- package/dist/rules.d.ts +6 -0
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +20 -5
- package/dist/rules.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -2
- package/dist/schemas/action.d.ts +2 -0
- package/dist/schemas/action.d.ts.map +1 -1
- package/dist/schemas/api.d.ts +9 -0
- package/dist/schemas/api.d.ts.map +1 -1
- package/dist/schemas/api.js +5 -3
- package/dist/schemas/api.js.map +1 -1
- package/dist/schemas/definition.d.ts +67 -0
- package/dist/schemas/definition.d.ts.map +1 -1
- package/dist/schemas/definition.js +45 -2
- package/dist/schemas/definition.js.map +1 -1
- package/dist/schemas/field.d.ts +3 -0
- package/dist/schemas/field.d.ts.map +1 -1
- package/dist/schemas/field.js +6 -4
- package/dist/schemas/field.js.map +1 -1
- package/dist/schemas/index.d.ts +102 -0
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +9 -4
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/list.d.ts +15 -0
- package/dist/schemas/list.d.ts.map +1 -1
- package/dist/schemas/list.js +13 -5
- package/dist/schemas/list.js.map +1 -1
- package/dist/schemas/resource.d.ts +11 -0
- package/dist/schemas/resource.d.ts.map +1 -1
- package/package.json +1 -1
- package/schema/boot.schema.json +136 -10
- package/schema/definition.schema.json +136 -10
- package/schema/openapi.json +523 -32
|
@@ -7,6 +7,12 @@ export interface ConformanceOptions {
|
|
|
7
7
|
init?: RequestInit;
|
|
8
8
|
/** Resource to test. Defaults to the first resource of the definition. */
|
|
9
9
|
resource?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Values of the context (decision 0045), sent in `Panneau-Context` with every request: for a
|
|
12
|
+
* backend whose resources need a value of a required param. The checks of the context use
|
|
13
|
+
* them too, and the first choice of each param without one.
|
|
14
|
+
*/
|
|
15
|
+
context?: Record<string, string>;
|
|
10
16
|
/**
|
|
11
17
|
* Enables the checks that write data, on the tested resource. Use a test database: these
|
|
12
18
|
* checks create, update and delete an item.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conformance/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conformance/index.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,kBAAkB;IAC/B,sFAAsF;IACtF,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjE,wEAAwE;IACxE,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;OAGG;IACH,MAAM,CAAC,EAAE;QACL,mCAAmC;QACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,kCAAkC;QAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,2FAA2F;QAC3F,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,CAAC;CACL;AAED,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhE,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,iBAAiB,CAAC;IAC1B,qDAAqD;IACrD,MAAM,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAmFD;;;GAGG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA0jC5F;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAU9D"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { PROBLEM_CONTENT_TYPE } from "../version.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CONTEXT_HEADER, CONTEXT_PROBLEM_TYPE } from "../constants.js";
|
|
3
|
+
import { isEqual, isFilled } from "../values.js";
|
|
3
4
|
import { isCursorPage, toSearchParams } from "../query.js";
|
|
4
5
|
import { isSearchableResource, toSearchQueryParams } from "../search.js";
|
|
6
|
+
import { formatContextHeader } from "../context.js";
|
|
5
7
|
import { Definition } from "../schemas/definition.js";
|
|
6
|
-
import { ActionResult, FieldCheckResponse, ItemResponse, ListResponse, Problem, SearchResponse, UploadSignResponse } from "../schemas/api.js";
|
|
8
|
+
import { ActionResult, ContextOptionsResponse, FieldCheckResponse, ItemResponse, ListResponse, Problem, SearchResponse, UploadSignResponse } from "../schemas/api.js";
|
|
7
9
|
//#region src/conformance/index.ts
|
|
8
10
|
var UNKNOWN = "__panneau_conformance_unknown__";
|
|
9
11
|
function describeIssues(error) {
|
|
@@ -59,6 +61,7 @@ async function runConformance(options) {
|
|
|
59
61
|
const request = async (path, init = {}) => {
|
|
60
62
|
const headers = new Headers(options.init?.headers);
|
|
61
63
|
headers.set("Accept", "application/json");
|
|
64
|
+
if (options.context !== void 0 && Object.keys(options.context).length > 0) headers.set(CONTEXT_HEADER, formatContextHeader(options.context));
|
|
62
65
|
new Headers(init.headers).forEach((value, key) => headers.set(key, value));
|
|
63
66
|
if (init.body !== void 0) headers.set("Content-Type", "application/json");
|
|
64
67
|
const response = await fetcher(`${baseUrl}${path}`, {
|
|
@@ -114,6 +117,56 @@ async function runConformance(options) {
|
|
|
114
117
|
resource = (options.resource !== void 0 ? current.resources.find((candidate) => candidate.id === options.resource) : current.resources[0]) ?? null;
|
|
115
118
|
check.expect(resource !== null, options.resource !== void 0 ? `The definition has no resource "${options.resource}".` : "The definition has no resources.");
|
|
116
119
|
});
|
|
120
|
+
const contextParams = () => definition?.context?.params ?? [];
|
|
121
|
+
let contextValue = null;
|
|
122
|
+
await run("context.options", "GET /context/{param}/options gives the choices of the params of the context", async (check) => {
|
|
123
|
+
const params = contextParams();
|
|
124
|
+
if (params.length === 0) {
|
|
125
|
+
check.skip("The definition has no context.");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const values = {};
|
|
129
|
+
for (const param of params) {
|
|
130
|
+
if (param.fixed === true) continue;
|
|
131
|
+
let first = param.options?.[0]?.value;
|
|
132
|
+
if (param.options === void 0) {
|
|
133
|
+
const reply = await request(`/context/${encodeURIComponent(param.name)}/options`, { headers: { [CONTEXT_HEADER]: formatContextHeader(values) } });
|
|
134
|
+
if (!check.expectStatus(reply, 200)) return;
|
|
135
|
+
first = check.expectSchema(ContextOptionsResponse, reply.body, `The choices of "${param.name}"`)?.data[0]?.value;
|
|
136
|
+
}
|
|
137
|
+
const value = options.context?.[param.name] ?? first;
|
|
138
|
+
if (value === void 0) return;
|
|
139
|
+
values[param.name] = value;
|
|
140
|
+
contextValue ??= {
|
|
141
|
+
name: param.name,
|
|
142
|
+
value
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
await run("context.value", "GET /definition is built for the values of Panneau-Context", async (check) => {
|
|
147
|
+
const chosen = contextValue;
|
|
148
|
+
if (chosen === null) {
|
|
149
|
+
check.skip(contextParams().length === 0 ? "The definition has no context." : "No choice of the first param to send.");
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const reply = await request("/definition", { headers: { [CONTEXT_HEADER]: formatContextHeader({ [chosen.name]: chosen.value }) } });
|
|
153
|
+
if (!check.expectStatus(reply, 200)) return;
|
|
154
|
+
const param = check.expectSchema(Definition, reply.body, "The definition")?.context?.params.find(({ name }) => name === chosen.name);
|
|
155
|
+
check.expect(param?.value === chosen.value, `The definition was built for ${chosen.name}=${String(param?.value ?? null)}, expected ${chosen.value}.`);
|
|
156
|
+
});
|
|
157
|
+
await run("context.refused", "A value of the context that does not exist is a 403 context problem", async (check) => {
|
|
158
|
+
const param = contextParams()[0];
|
|
159
|
+
if (param === void 0) {
|
|
160
|
+
check.skip("The definition has no context.");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const reply = await request("/definition", { headers: { [CONTEXT_HEADER]: formatContextHeader({ [param.name]: UNKNOWN }) } });
|
|
164
|
+
const problem = check.expectProblem(reply, 403);
|
|
165
|
+
if (problem !== null) {
|
|
166
|
+
check.expect(problem.type === CONTEXT_PROBLEM_TYPE, `Expected the type ${CONTEXT_PROBLEM_TYPE}, got ${problem.type}.`);
|
|
167
|
+
check.expect(problem.param === param.name, `Expected the param "${param.name}", got ${String(problem.param ?? "none")}.`);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
117
170
|
const resourcePath = () => `/resources/${encodeURIComponent(resource?.id ?? "")}`;
|
|
118
171
|
await run("list", "GET /resources/{resource} returns a page of items", async (check) => {
|
|
119
172
|
if (resource === null) {
|
|
@@ -328,6 +381,71 @@ async function runConformance(options) {
|
|
|
328
381
|
}
|
|
329
382
|
check.expectProblem(await request(`${resourcePath()}/${UNKNOWN}`), 404);
|
|
330
383
|
});
|
|
384
|
+
const listItems = async (check) => {
|
|
385
|
+
const cursors = resource?.list?.pagination === "cursor";
|
|
386
|
+
const reply = await request(`${resourcePath()}?${cursors ? "" : "page=1&"}perPage=20`);
|
|
387
|
+
if (!check.expectStatus(reply, 200)) return null;
|
|
388
|
+
return check.expectSchema(ListResponse, reply.body, "The list")?.data ?? null;
|
|
389
|
+
};
|
|
390
|
+
await run("abilities.view-any", "The resources the user can’t list answer 403 on their list", async (check) => {
|
|
391
|
+
const denied = (definition?.resources ?? []).filter((candidate) => candidate.abilities?.viewAny === false);
|
|
392
|
+
if (denied.length === 0) {
|
|
393
|
+
check.skip("Every resource can be listed.");
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
for (const candidate of denied) {
|
|
397
|
+
const reply = await request(`/resources/${encodeURIComponent(candidate.id)}`);
|
|
398
|
+
check.expect(reply.status === 403, `${candidate.id} has \`viewAny: false\`, but its list answered ${reply.status}.`);
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
await run("abilities.fields", "Items leave out the values of the fields the user can’t see", async (check) => {
|
|
402
|
+
const hidden = (resource?.fields ?? []).filter((field) => field.abilities?.view === false).map((field) => field.name);
|
|
403
|
+
if (hidden.length === 0) {
|
|
404
|
+
check.skip("The resource has no field with `view: false`.");
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
const items = await listItems(check);
|
|
408
|
+
if (items === null) return;
|
|
409
|
+
if (items.length === 0) {
|
|
410
|
+
check.skip("The list has no items.");
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
items.forEach((item) => {
|
|
414
|
+
const shown = hidden.filter((name) => name in item);
|
|
415
|
+
check.expect(shown.length === 0, `Item ${item.id} has values of fields with \`view: false\`: ${shown.join(", ")}.`);
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
await run("abilities.delete", "An item that can’t be deleted is skipped by a dry run of `delete`", async (check) => {
|
|
419
|
+
const current = resource;
|
|
420
|
+
if (current === null) {
|
|
421
|
+
check.skip("No resource to test.");
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (current.itemActions !== void 0 && !current.itemActions.includes("delete")) {
|
|
425
|
+
check.skip("The resource leaves out `delete` (`itemActions`).");
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const items = await listItems(check);
|
|
429
|
+
const denied = items?.find((item) => item.abilities.delete !== true);
|
|
430
|
+
if (items === null) return;
|
|
431
|
+
if (denied === void 0) {
|
|
432
|
+
check.skip("Every item of the first page can be deleted.");
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const allowed = items.find((item) => item.abilities.delete === true);
|
|
436
|
+
const ids = allowed !== void 0 ? [denied.id, allowed.id] : [denied.id];
|
|
437
|
+
const reply = await request(`${resourcePath()}/actions/delete`, {
|
|
438
|
+
method: "POST",
|
|
439
|
+
body: JSON.stringify({
|
|
440
|
+
selection: { ids },
|
|
441
|
+
dryRun: true
|
|
442
|
+
})
|
|
443
|
+
});
|
|
444
|
+
if (allowed === void 0 && reply.status === 403) return;
|
|
445
|
+
if (!check.expectStatus(reply, 200)) return;
|
|
446
|
+
const result = check.expectSchema(ActionResult, reply.body, "The dry run of `delete`");
|
|
447
|
+
check.expect(result === null || result.summary?.skipped === 1 && result.summary.succeeded === ids.length - 1, `Item ${denied.id} can’t be deleted, but the dry run of \`delete\` doesn’t skip it.`);
|
|
448
|
+
});
|
|
331
449
|
let searched = null;
|
|
332
450
|
const searchSkip = () => {
|
|
333
451
|
const current = definition;
|
|
@@ -420,6 +538,44 @@ async function runConformance(options) {
|
|
|
420
538
|
let createdId = null;
|
|
421
539
|
let createdVersion = null;
|
|
422
540
|
let updatedVersion = null;
|
|
541
|
+
await run("abilities.create", "The resources the user can’t create items of answer 403 to a create", async (check) => {
|
|
542
|
+
const current = definition;
|
|
543
|
+
if (writes === void 0 || current === null) {
|
|
544
|
+
check.skip("Write checks are disabled.");
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
const denied = current.resources.filter((candidate) => candidate.abilities?.create === false);
|
|
548
|
+
if (denied.length === 0) {
|
|
549
|
+
check.skip("The user can create items of every resource.");
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
for (const candidate of denied) {
|
|
553
|
+
const reply = await request(`/resources/${encodeURIComponent(candidate.id)}`, {
|
|
554
|
+
method: "POST",
|
|
555
|
+
body: "{}"
|
|
556
|
+
});
|
|
557
|
+
check.expect(reply.status === 403, `${candidate.id} has \`create: false\`, but a create answered ${reply.status}.`);
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
await run("abilities.update", "An item the user can’t update answers 403 to an update", async (check) => {
|
|
561
|
+
if (writes === void 0 || resource === null) {
|
|
562
|
+
check.skip("Write checks are disabled.");
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
const items = await listItems(check);
|
|
566
|
+
const denied = items?.find((item) => item.abilities.update !== true);
|
|
567
|
+
if (items === null) return;
|
|
568
|
+
if (denied === void 0) {
|
|
569
|
+
check.skip("Every item of the first page can be updated.");
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
const reply = await request(`${resourcePath()}/${encodeURIComponent(denied.id)}`, {
|
|
573
|
+
method: "PATCH",
|
|
574
|
+
body: "{}",
|
|
575
|
+
headers: denied.version !== null ? { "If-Match": `"${denied.version}"` } : {}
|
|
576
|
+
});
|
|
577
|
+
check.expect(reply.status === 403, `Item ${denied.id} can’t be updated, but an update answered ${reply.status}.`);
|
|
578
|
+
});
|
|
423
579
|
await run("create.invalid", "Invalid values are refused with a 422 problem", async (check) => {
|
|
424
580
|
if (writes === void 0 || resource === null) {
|
|
425
581
|
check.skip("Write checks are disabled.");
|
|
@@ -484,6 +640,33 @@ async function runConformance(options) {
|
|
|
484
640
|
});
|
|
485
641
|
check.expect(reply.status === 200, `An update with ${names.join(", ")} set to null got status ${reply.status}, expected 200.`);
|
|
486
642
|
});
|
|
643
|
+
await run("update.single-field", "A PATCH with a single field and If-Match changes that field alone", async (check) => {
|
|
644
|
+
if (createdId === null || writes === void 0 || resource === null) {
|
|
645
|
+
check.skip("No item was created.");
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
const current = await request(itemPath());
|
|
649
|
+
const before = check.expectStatus(current, 200) ? check.expectSchema(ItemResponse, current.body, "The item") : null;
|
|
650
|
+
if (before === null) return;
|
|
651
|
+
const name = Object.keys(writes.update).find((key) => key in writes.create && !isEqual(writes.create[key], before.data[key]));
|
|
652
|
+
if (name === void 0) {
|
|
653
|
+
check.skip("No value of the update of `writes` differs from its value in `create`, to set it back.");
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
const version = before.data.version;
|
|
657
|
+
const reply = await request(itemPath(), {
|
|
658
|
+
method: "PATCH",
|
|
659
|
+
body: JSON.stringify({ [name]: writes.create[name] }),
|
|
660
|
+
headers: version !== null ? { "If-Match": `"${version}"` } : {}
|
|
661
|
+
});
|
|
662
|
+
if (!check.expectStatus(reply, 200)) return;
|
|
663
|
+
const after = check.expectSchema(ItemResponse, reply.body, "The updated item");
|
|
664
|
+
if (after === null) return;
|
|
665
|
+
if (version !== null) check.expect(after.data.version !== version, "The version did not change after an update of a single field.");
|
|
666
|
+
const changed = resource.fields.filter((field) => field.name !== name && field.readOnly !== true && field.settings?.secret !== true && !isEqual(before.data[field.name], after.data[field.name])).map((field) => field.name);
|
|
667
|
+
check.expect(changed.length === 0, `An update of ${name} alone also changed ${changed.join(", ")}.`);
|
|
668
|
+
updatedVersion = after.data.version;
|
|
669
|
+
});
|
|
487
670
|
await run("update.conflict", "A stale If-Match is a 412 problem with the current item", async (check) => {
|
|
488
671
|
if (createdId === null || writes === void 0) {
|
|
489
672
|
check.skip("No item was created.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/conformance/index.ts"],"sourcesContent":["import type { z } from 'zod';\n\nimport { type FilterRange, isCursorPage, toSearchParams } from '../query';\nimport { Definition, type Resource } from '../schemas';\nimport {\n ActionResult,\n FieldCheckResponse,\n ItemResponse,\n ListResponse,\n Problem,\n SearchResponse,\n UploadSignResponse,\n} from '../schemas/api';\nimport {\n SEARCH_DEFAULT_LIMIT,\n SEARCH_MAX_LIMIT,\n type SearchQuery,\n isSearchableResource,\n toSearchQueryParams,\n} from '../search';\nimport { isFilled } from '../values';\nimport { PROBLEM_CONTENT_TYPE } from '../version';\n\nexport interface ConformanceOptions {\n /** Base URL of the API, the same as `api.baseUrl` of the definition, but absolute. */\n baseUrl: string;\n /** The `fetch` to use. Defaults to the global one. */\n fetch?: (input: string, init?: RequestInit) => Promise<Response>;\n /** Merged into every request, for authentication headers or cookies. */\n init?: RequestInit;\n /** Resource to test. Defaults to the first resource of the definition. */\n resource?: string;\n /**\n * Enables the checks that write data, on the tested resource. Use a test database: these\n * checks create, update and delete an item.\n */\n writes?: {\n /** Valid values for a new item. */\n create: Record<string, unknown>;\n /** Valid values for an update. */\n update: Record<string, unknown>;\n /** Values that must be refused with a `422`. Defaults to `{}` when a field is required. */\n invalid?: Record<string, unknown>;\n };\n}\n\nexport type ConformanceStatus = 'passed' | 'failed' | 'skipped';\n\nexport interface ConformanceCheck {\n id: string;\n title: string;\n status: ConformanceStatus;\n /** What went wrong, or why the check was skipped. */\n issues: string[];\n}\n\nexport interface ConformanceReport {\n passed: boolean;\n checks: ConformanceCheck[];\n}\n\ninterface Reply {\n status: number;\n contentType: string;\n etag: string | null;\n body: unknown;\n}\n\nconst UNKNOWN = '__panneau_conformance_unknown__';\n\nfunction describeIssues(error: z.ZodError): string[] {\n return error.issues.slice(0, 10).map((issue) => {\n const path = issue.path.map(String).join('.');\n return path === '' ? issue.message : `${path}: ${issue.message}`;\n });\n}\n\n/** The first text of a value: a string, or the first string of a localized value. */\nfunction textOf(value: unknown): string | null {\n if (typeof value === 'string') {\n return value;\n }\n if (value !== null && typeof value === 'object' && !Array.isArray(value)) {\n for (const entry of Object.values(value)) {\n if (typeof entry === 'string' && entry.trim() !== '') {\n return entry;\n }\n }\n }\n return null;\n}\n\nfunction normalizeEtag(value: string): string {\n return value.replace(/^W\\//, '');\n}\n\nclass Check {\n issues: string[] = [];\n skippedBecause: string | null = null;\n\n expect(condition: boolean, issue: string): boolean {\n if (!condition) {\n this.issues.push(issue);\n }\n return condition;\n }\n\n expectStatus(reply: Reply, status: number): boolean {\n return this.expect(\n reply.status === status,\n `Expected status ${status}, got ${reply.status}.`,\n );\n }\n\n expectSchema<T extends z.ZodType>(schema: T, value: unknown, label: string): z.infer<T> | null {\n const result = schema.safeParse(value);\n if (result.success) {\n return result.data;\n }\n this.issues.push(\n `${label} does not match the schema:`,\n ...describeIssues(result.error).map((issue) => ` ${issue}`),\n );\n return null;\n }\n\n expectProblem(reply: Reply, status: number): Problem | null {\n if (!this.expectStatus(reply, status)) {\n return null;\n }\n this.expect(\n reply.contentType.startsWith(PROBLEM_CONTENT_TYPE),\n `Expected content type ${PROBLEM_CONTENT_TYPE}, got \"${reply.contentType}\".`,\n );\n return this.expectSchema(Problem, reply.body, 'The error');\n }\n\n skip(reason: string) {\n this.skippedBecause = reason;\n }\n}\n\n/**\n * Runs the protocol's conformance checks against a live backend. Read-only checks always run;\n * checks that write data run only with `writes`.\n */\nexport async function runConformance(options: ConformanceOptions): Promise<ConformanceReport> {\n const fetcher = options.fetch ?? ((input: string, init?: RequestInit) => fetch(input, init));\n const baseUrl = options.baseUrl.replace(/\\/$/, '');\n const checks: ConformanceCheck[] = [];\n\n const request = async (path: string, init: RequestInit = {}): Promise<Reply> => {\n const headers = new Headers(options.init?.headers);\n headers.set('Accept', 'application/json');\n new Headers(init.headers).forEach((value, key) => headers.set(key, value));\n if (init.body !== undefined) {\n headers.set('Content-Type', 'application/json');\n }\n const response = await fetcher(`${baseUrl}${path}`, { ...options.init, ...init, headers });\n const text = await response.text();\n const parse = (): unknown => {\n if (text === '') {\n return null;\n }\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n };\n const body = parse();\n return {\n status: response.status,\n contentType: response.headers.get('Content-Type') ?? '',\n etag: response.headers.get('ETag'),\n body,\n };\n };\n\n const run = async (id: string, title: string, body: (check: Check) => Promise<void>) => {\n const check = new Check();\n try {\n await body(check);\n } catch (error) {\n check.issues.push(\n `Request failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const status: ConformanceStatus =\n check.issues.length > 0\n ? 'failed'\n : check.skippedBecause !== null\n ? 'skipped'\n : 'passed';\n checks.push({\n id,\n title,\n status,\n issues:\n status === 'skipped' && check.skippedBecause !== null\n ? [check.skippedBecause]\n : check.issues,\n });\n };\n\n let definition: Definition | null = null;\n let resource: Resource | null = null;\n let firstItemId: string | null = null;\n\n await run('definition', 'GET /definition returns a valid definition', async (check) => {\n const reply = await request('/definition');\n if (check.expectStatus(reply, 200)) {\n definition = check.expectSchema(Definition, reply.body, 'The definition');\n }\n });\n\n await run('definition.resource', 'The definition has the resource to test', async (check) => {\n const current = definition as Definition | null;\n if (current === null) {\n check.skip('No valid definition.');\n return;\n }\n resource =\n (options.resource !== undefined\n ? current.resources.find((candidate) => candidate.id === options.resource)\n : current.resources[0]) ?? null;\n check.expect(\n resource !== null,\n options.resource !== undefined\n ? `The definition has no resource \"${options.resource}\".`\n : 'The definition has no resources.',\n );\n });\n\n const resourcePath = () =>\n `/resources/${encodeURIComponent((resource as Resource | null)?.id ?? '')}`;\n\n await run('list', 'GET /resources/{resource} returns a page of items', async (check) => {\n if (resource === null) {\n check.skip('No resource to test.');\n return;\n }\n // A list paged with cursors has no page numbers (decision 0039).\n const cursors = (resource as Resource).list?.pagination === 'cursor';\n const reply = await request(`${resourcePath()}?${cursors ? '' : 'page=1&'}perPage=2`);\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const list = check.expectSchema(ListResponse, reply.body, 'The list');\n if (list === null) {\n return;\n }\n check.expect(list.data.length <= 2, `perPage=2 returned ${list.data.length} items.`);\n check.expect(list.meta.perPage === 2, `meta.perPage is ${list.meta.perPage}, expected 2.`);\n firstItemId = list.data[0]?.id ?? null;\n const { meta } = list;\n if (!cursors) {\n check.expect(\n !isCursorPage(meta) && meta.page === 1,\n `meta.page is ${String((meta as { page?: unknown }).page)}, expected 1.`,\n );\n return;\n }\n if (!isCursorPage(meta)) {\n check.expect(false, 'The list pages with cursors, but its meta has no nextCursor.');\n return;\n }\n // The next page follows on from the first, and a cursor the backend can't read is a 422.\n if (meta.nextCursor !== null) {\n const next = await request(\n `${resourcePath()}?${toSearchParams({ perPage: 2, cursor: meta.nextCursor })}`,\n );\n if (check.expectStatus(next, 200)) {\n const page = check.expectSchema(ListResponse, next.body, 'The next page');\n const repeated = (page?.data ?? []).filter((item) =>\n list.data.some((first) => first.id === item.id),\n );\n check.expect(\n repeated.length === 0,\n `The page of nextCursor repeats items of the first page: ${repeated.map((item) => item.id).join(', ')}.`,\n );\n }\n }\n const invalid = await request(\n `${resourcePath()}?${toSearchParams({ perPage: 2, cursor: 'panneau-conformance-invalid' })}`,\n );\n const problem = check.expectProblem(invalid, 422);\n check.expect(\n problem === null || (problem.errors?.cursor ?? []).length > 0,\n 'An invalid cursor answers a 422 without errors.cursor.',\n );\n });\n\n await run('list.sort', 'GET /resources/{resource} accepts a sort', async (check) => {\n const sort = (resource as Resource | null)?.list?.sorts?.[0];\n if (sort === undefined) {\n check.skip('The resource declares no sorts.');\n return;\n }\n const reply = await request(`${resourcePath()}?sort=${encodeURIComponent(`-${sort}`)}`);\n if (check.expectStatus(reply, 200)) {\n check.expectSchema(ListResponse, reply.body, 'The sorted list');\n }\n });\n\n await run(\n 'list.filter-range',\n 'GET /resources/{resource} reads the bounds of a range filter',\n async (check) => {\n const filter = (resource as Resource | null)?.list?.filters?.find(\n (candidate) => candidate.type === 'date-range',\n );\n if (filter === undefined) {\n check.skip('The resource declares no date-range filter.');\n return;\n }\n const list = async (range: FilterRange | null, label: string) => {\n const query =\n range !== null ? `?${toSearchParams({ filter: { [filter.id]: range } })}` : '';\n const reply = await request(`${resourcePath()}${query}`);\n if (!check.expectStatus(reply, 200)) {\n return null;\n }\n return check.expectSchema(ListResponse, reply.body, label);\n };\n const all = await list(null, 'The list');\n if (all === null) {\n return;\n }\n // Items of the first page with a value: a range that covers every day includes them.\n const dated = all.data.filter((item) => isFilled(item[filter.id])).length;\n const ranges: [FilterRange, string][] = [\n [{ from: '0001-01-01', to: '9999-12-31' }, 'from 0001-01-01 to 9999-12-31'],\n [{ to: '9999-12-31' }, 'up to 9999-12-31 (an open start)'],\n ];\n // A list paged with cursors may have no total: the first page then counts.\n const totalOf = (reply: ListResponse) =>\n typeof reply.meta.total === 'number' ? reply.meta.total : null;\n for (const [range, label] of ranges) {\n const reply = await list(range, `The list filtered ${label}`);\n const total = reply !== null ? totalOf(reply) : null;\n if (total !== null) {\n check.expect(\n total >= dated,\n `Filtered ${label}, the list has ${total} items; the first page alone has ${dated} with a ${filter.id}.`,\n );\n }\n }\n const future = await list({ from: '9999-12-31' }, 'The list filtered from 9999-12-31');\n if (future !== null) {\n const total = totalOf(future) ?? future.data.length;\n check.expect(\n total === 0,\n `Filtered from 9999-12-31, the list has ${total} items, expected 0.`,\n );\n }\n },\n );\n\n await run(\n 'action.dry-run',\n 'A dry run of an action counts what it would do, and changes nothing',\n async (check) => {\n const action = (resource as Resource | null)?.actions?.find(\n (candidate) =>\n candidate.dryRun === true &&\n candidate.kind === 'server' &&\n candidate.scope.includes('selection'),\n );\n if (action === undefined) {\n check.skip('The resource declares no selection action with dryRun.');\n return;\n }\n const page = async (label: string) => {\n const reply = await request(`${resourcePath()}?page=1&perPage=20`);\n return check.expectStatus(reply, 200)\n ? check.expectSchema(ListResponse, reply.body, label)\n : null;\n };\n const before = await page('The list before the dry run');\n const reply = await request(\n `${resourcePath()}/actions/${encodeURIComponent(action.id)}`,\n {\n method: 'POST',\n body: JSON.stringify({ selection: { query: {} }, dryRun: true }),\n },\n );\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const result = check.expectSchema(ActionResult, reply.body, 'The dry run result');\n if (result !== null && before !== null) {\n check.expect(\n result.summary !== undefined,\n 'A dry run result must have a summary of the items that would succeed and be skipped.',\n );\n if (result.summary !== undefined) {\n const counted =\n result.summary.succeeded + result.summary.failed + result.summary.skipped;\n check.expect(\n counted === before.meta.total,\n `The dry run counts ${counted} items; the list has ${before.meta.total}.`,\n );\n }\n }\n const after = await page('The list after the dry run');\n if (before !== null && after !== null) {\n const versions = (list: typeof before) =>\n JSON.stringify(list.data.map((item) => [item.id, item.version ?? null]));\n check.expect(\n after.meta.total === before.meta.total && versions(after) === versions(before),\n 'A dry run must not change the items.',\n );\n }\n },\n );\n\n await run(\n 'action.delete',\n 'The built-in `delete` answers, with dry runs, without being declared',\n async (check) => {\n const current = resource as Resource | null;\n if (current === null) {\n check.skip('No resource to test.');\n return;\n }\n if (current.itemActions !== undefined && !current.itemActions.includes('delete')) {\n check.skip('The resource leaves out `delete` (`itemActions`).');\n return;\n }\n if (firstItemId === null) {\n check.skip('The list has no items.');\n return;\n }\n // A dry run changes nothing: the check runs without `writes`.\n const reply = await request(`${resourcePath()}/actions/delete`, {\n method: 'POST',\n body: JSON.stringify({ selection: { ids: [firstItemId] }, dryRun: true }),\n });\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const result = check.expectSchema(ActionResult, reply.body, 'The dry run of `delete`');\n if (result !== null) {\n check.expect(\n result.summary !== undefined &&\n result.summary.succeeded +\n result.summary.skipped +\n result.summary.failed ===\n 1,\n 'The dry run of `delete` on one item must count it, as deleted or skipped.',\n );\n }\n check.expectStatus(\n await request(`${resourcePath()}/${encodeURIComponent(firstItemId)}`),\n 200,\n );\n },\n );\n\n await run(\n 'uploads.sign',\n 'POST /uploads/sign signs the first request of a file, and only the keys of open uploads',\n async (check) => {\n const uploads = (definition as Definition | null)?.uploads;\n if (uploads?.mode !== 'presigned') {\n check.skip('The definition has no presigned uploads.');\n return;\n }\n if (uploads.endpoint !== undefined) {\n check.skip('The upload routes are not at {api.baseUrl}/uploads.');\n return;\n }\n const sign = (body: unknown) =>\n request('/uploads/sign', { method: 'POST', body: JSON.stringify(body) });\n const reply = await sign({ method: 'POST', key: 'panneau-conformance.txt' });\n if (check.expectStatus(reply, 200)) {\n const signed = check.expectSchema(\n UploadSignResponse,\n reply.body,\n 'The signed request',\n );\n if (signed !== null) {\n check.expect(\n signed.key !== undefined && signed.upload !== undefined,\n 'The first request of a file must answer the key and the upload the backend chose.',\n );\n }\n }\n check.expectProblem(\n await sign({\n method: 'PUT',\n key: 'not-an-upload-of-this-user',\n uploadId: 'unknown',\n partNumber: 1,\n }),\n 404,\n );\n check.expectProblem(\n await request(`/uploads/${UNKNOWN}/complete`, { method: 'POST' }),\n 404,\n );\n },\n );\n\n await run(\n 'fields.check',\n 'POST /resources/{resource}/fields/{field}/check checks a value of a field with `check`',\n async (check) => {\n const field = resource?.fields.find((candidate) => candidate.check === true);\n if (resource === null || field === undefined) {\n check.skip('The resource has no field with `check`.');\n return;\n }\n const checkPath = (name: string) =>\n `${resourcePath()}/fields/${encodeURIComponent(name)}/check`;\n const locale = field.localized === true ? definition?.locale : undefined;\n const reply = await request(checkPath(field.name), {\n method: 'POST',\n body: JSON.stringify({\n value: 'panneau-conformance',\n ...(locale !== undefined ? { locale } : {}),\n id: null,\n values: {},\n }),\n });\n if (check.expectStatus(reply, 200)) {\n check.expectSchema(FieldCheckResponse, reply.body, 'The check');\n }\n check.expectProblem(\n await request(checkPath(UNKNOWN), { method: 'POST', body: '{\"value\":\"x\"}' }),\n 404,\n );\n },\n );\n\n await run('list.unknown-resource', 'An unknown resource is a 404 problem', async (check) => {\n check.expectProblem(await request(`/resources/${UNKNOWN}`), 404);\n });\n\n await run(\n 'item',\n 'GET /resources/{resource}/{id} returns the item with its ETag',\n async (check) => {\n if (firstItemId === null) {\n check.skip('The list has no items.');\n return;\n }\n const reply = await request(`${resourcePath()}/${encodeURIComponent(firstItemId)}`);\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const item = check.expectSchema(ItemResponse, reply.body, 'The item');\n if (item === null) {\n return;\n }\n check.expect(\n item.data.id === firstItemId,\n `Asked for item \"${firstItemId}\", got \"${item.data.id}\".`,\n );\n if (item.data.version !== null) {\n check.expect(\n reply.etag !== null && normalizeEtag(reply.etag) === `\"${item.data.version}\"`,\n `Expected ETag \"${item.data.version}\" (quoted), got ${reply.etag ?? 'none'}.`,\n );\n }\n },\n );\n\n await run('item.missing', 'A missing item is a 404 problem', async (check) => {\n if (resource === null) {\n check.skip('No resource to test.');\n return;\n }\n check.expectProblem(await request(`${resourcePath()}/${UNKNOWN}`), 404);\n });\n\n // The global search: a word of the title of an item of a searchable resource finds it.\n let searched: { resource: Resource; term: string } | null = null;\n const searchSkip = (): string | null => {\n const current = definition as Definition | null;\n if (current === null) {\n return 'No valid definition.';\n }\n if (current.search?.enabled === false) {\n return 'The definition disables the global search.';\n }\n return searched === null\n ? 'No searchable resource has an item with a title to search for.'\n : null;\n };\n const search = (query: SearchQuery) => request(`/search?${toSearchQueryParams(query)}`);\n\n await run('search', 'GET /search finds items of the searchable resources', async (check) => {\n const current = definition as Definition | null;\n const tested = resource as Resource | null;\n if (current === null || current.search?.enabled === false) {\n check.skip(searchSkip() ?? '');\n return;\n }\n const candidates = current.resources\n .filter(\n (candidate) =>\n isSearchableResource(candidate) && candidate.abilities?.viewAny !== false,\n )\n // The tested resource first\n .sort((a, b) => Number(b.id === tested?.id) - Number(a.id === tested?.id));\n for (const candidate of candidates) {\n if (candidate.itemTitle === undefined || searched !== null) {\n continue;\n }\n const reply = await request(\n `/resources/${encodeURIComponent(candidate.id)}?page=1&perPage=1`,\n );\n const list = ListResponse.safeParse(reply.body);\n const title = list.success ? textOf(list.data.data[0]?.[candidate.itemTitle]) : null;\n const term = title?.split(/\\s+/).find((word) => word.length >= 2);\n if (term !== undefined) {\n searched = { resource: candidate, term };\n }\n }\n const reason = searchSkip();\n if (reason !== null || searched === null) {\n check.skip(reason ?? '');\n return;\n }\n const { resource: target, term } = searched as { resource: Resource; term: string };\n const reply = await search({ q: term });\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const results = check.expectSchema(SearchResponse, reply.body, 'The results');\n if (results === null) {\n return;\n }\n const ids = candidates.map((candidate) => candidate.id);\n for (const group of results.data) {\n check.expect(\n ids.includes(group.resource),\n `Results of \"${group.resource}\", which is not a searchable resource.`,\n );\n check.expect(\n group.items.length <= SEARCH_DEFAULT_LIMIT,\n `\"${group.resource}\" has ${group.items.length} results; without a limit, at most ${SEARCH_DEFAULT_LIMIT}.`,\n );\n }\n const count = results.data.reduce((total, group) => total + group.items.length, 0);\n check.expect(\n count <= SEARCH_MAX_LIMIT,\n `The results have ${count} items, at most ${SEARCH_MAX_LIMIT}.`,\n );\n check.expect(\n results.data.some((group) => group.resource === target.id && group.items.length > 0),\n `Searching \"${term}\", a word of the title of an item of \"${target.id}\", finds none of its items.`,\n );\n });\n\n await run('search.scope', 'GET /search reads limit and resources', async (check) => {\n const reason = searchSkip();\n if (reason !== null || searched === null) {\n check.skip(reason ?? '');\n return;\n }\n const { resource: target, term } = searched as { resource: Resource; term: string };\n const reply = await search({ q: term, limit: 1, resources: [target.id] });\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const results = check.expectSchema(SearchResponse, reply.body, 'The results');\n if (results !== null) {\n check.expect(\n results.data.length === 1 &&\n results.data[0]?.resource === target.id &&\n results.data[0].items.length === 1,\n `With limit=1&resources=${target.id}, expected one item of \"${target.id}\", got ${JSON.stringify(results.data.map((group) => [group.resource, group.items.length]))}.`,\n );\n }\n });\n\n await run(\n 'search.invalid',\n 'An invalid search is a 422 problem, with errors keyed by parameter',\n async (check) => {\n const reason = searchSkip();\n if (reason !== null || searched === null) {\n check.skip(reason ?? '');\n return;\n }\n const { term } = searched as { resource: Resource; term: string };\n const invalid: [string, SearchQuery][] = [\n ['q', { q: term.slice(0, 1) }],\n ['limit', { q: term, limit: 0 }],\n ['limit', { q: term, limit: SEARCH_MAX_LIMIT + 1 }],\n ['resources', { q: term, resources: [UNKNOWN] }],\n ];\n for (const [parameter, query] of invalid) {\n const failure = check.expectProblem(await search(query), 422);\n if (failure !== null) {\n check.expect(\n failure.errors?.[parameter] !== undefined,\n `${toSearchQueryParams(query)}: the 422 problem must have errors.${parameter}.`,\n );\n }\n }\n },\n );\n\n const writes = options.writes;\n let createdId: string | null = null;\n let createdVersion: string | null = null;\n let updatedVersion: string | null = null;\n\n await run('create.invalid', 'Invalid values are refused with a 422 problem', async (check) => {\n if (writes === undefined || resource === null) {\n check.skip('Write checks are disabled.');\n return;\n }\n const hasRequired = resource.fields.some((field) =>\n (field.rules ?? []).some(\n (rule) => rule.rule === 'required' && (rule.mode ?? 'create') === 'create',\n ),\n );\n if (writes.invalid === undefined && !hasRequired) {\n check.skip('No invalid values given, and the resource has no required field.');\n return;\n }\n const reply = await request(resourcePath(), {\n method: 'POST',\n body: JSON.stringify(writes.invalid ?? {}),\n });\n const failure = check.expectProblem(reply, 422);\n if (failure !== null) {\n check.expect(\n failure.errors !== undefined && Object.keys(failure.errors).length > 0,\n 'A 422 problem must list the invalid values in `errors`.',\n );\n }\n });\n\n await run('create', 'POST /resources/{resource} creates an item', async (check) => {\n if (writes === undefined || resource === null) {\n check.skip('Write checks are disabled.');\n return;\n }\n const reply = await request(resourcePath(), {\n method: 'POST',\n body: JSON.stringify(writes.create),\n });\n if (!check.expectStatus(reply, 201)) {\n return;\n }\n const item = check.expectSchema(ItemResponse, reply.body, 'The created item');\n createdId = item?.data.id ?? null;\n createdVersion = item?.data.version ?? null;\n });\n\n const itemPath = () => `${resourcePath()}/${encodeURIComponent(createdId ?? '')}`;\n\n await run('update', 'PATCH /resources/{resource}/{id} updates the item', async (check) => {\n if (createdId === null || writes === undefined) {\n check.skip('No item was created.');\n return;\n }\n const reply = await request(itemPath(), {\n method: 'PATCH',\n body: JSON.stringify(writes.update),\n headers: createdVersion !== null ? { 'If-Match': `\"${createdVersion}\"` } : {},\n });\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const item = check.expectSchema(ItemResponse, reply.body, 'The updated item');\n if (item !== null && createdVersion !== null) {\n check.expect(\n item.data.version !== createdVersion,\n 'The version did not change after an update.',\n );\n }\n updatedVersion = item?.data.version ?? null;\n });\n\n await run(\n 'update.create-rules',\n 'Rules limited to create do not apply to updates',\n async (check) => {\n if (createdId === null || writes === undefined || resource === null) {\n check.skip('No item was created.');\n return;\n }\n // A password: required to create the item, left empty to keep it on an update.\n const names = resource.fields\n .filter(\n (field) =>\n field.readOnly !== true &&\n field.createOnly !== true &&\n (field.rules ?? []).some(\n (rule) => rule.rule === 'required' && rule.mode === 'create',\n ),\n )\n .map((field) => field.name);\n if (names.length === 0) {\n check.skip('The resource has no rule limited to create.');\n return;\n }\n const reply = await request(itemPath(), {\n method: 'PATCH',\n body: JSON.stringify(Object.fromEntries(names.map((name) => [name, null]))),\n headers: updatedVersion !== null ? { 'If-Match': `\"${updatedVersion}\"` } : {},\n });\n check.expect(\n reply.status === 200,\n `An update with ${names.join(', ')} set to null got status ${reply.status}, expected 200.`,\n );\n },\n );\n\n await run(\n 'update.conflict',\n 'A stale If-Match is a 412 problem with the current item',\n async (check) => {\n if (createdId === null || writes === undefined) {\n check.skip('No item was created.');\n return;\n }\n if (createdVersion === null) {\n check.skip('The backend has no versions.');\n return;\n }\n const reply = await request(itemPath(), {\n method: 'PATCH',\n body: JSON.stringify(writes.update),\n headers: { 'If-Match': '\"__panneau_conformance_stale__\"' },\n });\n const failure = check.expectProblem(reply, 412);\n if (failure !== null) {\n check.expect(\n failure.current !== undefined,\n 'A 412 problem must include the current item.',\n );\n }\n },\n );\n\n await run(\n 'duplicate',\n 'POST /resources/{resource}/{id}/duplicate copies an item that allows it',\n async (check) => {\n if (createdId === null) {\n check.skip('No item was created.');\n return;\n }\n const reply = await request(itemPath());\n const created = check.expectStatus(reply, 200)\n ? check.expectSchema(ItemResponse, reply.body, 'The item')\n : null;\n if (created === null) {\n return;\n }\n // The built-in `duplicate` is only shown on items that allow it (decision 0040).\n if (created.data.abilities.duplicate !== true) {\n check.skip(\"The item doesn't allow `duplicate`.\");\n return;\n }\n const copy = await request(`${itemPath()}/duplicate`, { method: 'POST' });\n if (!check.expectStatus(copy, 201)) {\n return;\n }\n const duplicated = check.expectSchema(ItemResponse, copy.body, 'The copy');\n if (duplicated === null) {\n return;\n }\n check.expect(\n copy.etag !== null && normalizeEtag(copy.etag) === `\"${duplicated.data.version}\"`,\n `Expected the ETag of the copy, \"${duplicated.data.version}\" (quoted), got ${copy.etag ?? 'none'}.`,\n );\n check.expect(\n duplicated.data.id !== created.data.id,\n 'The copy has the id of the item it copies.',\n );\n // Clean up the copy\n await request(`${resourcePath()}/${encodeURIComponent(duplicated.data.id)}`, {\n method: 'DELETE',\n });\n },\n );\n\n await run('delete', 'DELETE /resources/{resource}/{id} deletes the item', async (check) => {\n if (createdId === null) {\n check.skip('No item was created.');\n return;\n }\n if (!check.expectStatus(await request(itemPath(), { method: 'DELETE' }), 204)) {\n return;\n }\n check.expectProblem(await request(itemPath()), 404);\n });\n\n return { passed: checks.every((check) => check.status !== 'failed'), checks };\n}\n\n/** Formats a report as text, one line per check. */\nexport function formatReport(report: ConformanceReport): string {\n const symbols: Record<ConformanceStatus, string> = { passed: '✓', failed: '✗', skipped: '-' };\n return report.checks\n .map((check) =>\n [\n `${symbols[check.status]} ${check.title}`,\n ...check.issues.map((issue) => ` ${issue}`),\n ].join('\\n'),\n )\n .join('\\n');\n}\n"],"mappings":";;;;;;;AAoEA,IAAM,UAAU;AAEhB,SAAS,eAAe,OAA6B;CACjD,OAAO,MAAM,OA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,KAAK,IAAI;AAClB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["current"],"sources":["../../src/conformance/index.ts"],"sourcesContent":["import type { z } from 'zod';\n\nimport { CONTEXT_HEADER, CONTEXT_PROBLEM_TYPE } from '../constants';\nimport { formatContextHeader } from '../context';\nimport { type FilterRange, isCursorPage, toSearchParams } from '../query';\nimport { Definition, type Resource } from '../schemas';\nimport {\n ActionResult,\n ContextOptionsResponse,\n FieldCheckResponse,\n type Item,\n ItemResponse,\n ListResponse,\n Problem,\n SearchResponse,\n UploadSignResponse,\n} from '../schemas/api';\nimport {\n SEARCH_DEFAULT_LIMIT,\n SEARCH_MAX_LIMIT,\n type SearchQuery,\n isSearchableResource,\n toSearchQueryParams,\n} from '../search';\nimport { isEqual, isFilled } from '../values';\nimport { PROBLEM_CONTENT_TYPE } from '../version';\n\nexport interface ConformanceOptions {\n /** Base URL of the API, the same as `api.baseUrl` of the definition, but absolute. */\n baseUrl: string;\n /** The `fetch` to use. Defaults to the global one. */\n fetch?: (input: string, init?: RequestInit) => Promise<Response>;\n /** Merged into every request, for authentication headers or cookies. */\n init?: RequestInit;\n /** Resource to test. Defaults to the first resource of the definition. */\n resource?: string;\n /**\n * Values of the context (decision 0045), sent in `Panneau-Context` with every request: for a\n * backend whose resources need a value of a required param. The checks of the context use\n * them too, and the first choice of each param without one.\n */\n context?: Record<string, string>;\n /**\n * Enables the checks that write data, on the tested resource. Use a test database: these\n * checks create, update and delete an item.\n */\n writes?: {\n /** Valid values for a new item. */\n create: Record<string, unknown>;\n /** Valid values for an update. */\n update: Record<string, unknown>;\n /** Values that must be refused with a `422`. Defaults to `{}` when a field is required. */\n invalid?: Record<string, unknown>;\n };\n}\n\nexport type ConformanceStatus = 'passed' | 'failed' | 'skipped';\n\nexport interface ConformanceCheck {\n id: string;\n title: string;\n status: ConformanceStatus;\n /** What went wrong, or why the check was skipped. */\n issues: string[];\n}\n\nexport interface ConformanceReport {\n passed: boolean;\n checks: ConformanceCheck[];\n}\n\ninterface Reply {\n status: number;\n contentType: string;\n etag: string | null;\n body: unknown;\n}\n\nconst UNKNOWN = '__panneau_conformance_unknown__';\n\nfunction describeIssues(error: z.ZodError): string[] {\n return error.issues.slice(0, 10).map((issue) => {\n const path = issue.path.map(String).join('.');\n return path === '' ? issue.message : `${path}: ${issue.message}`;\n });\n}\n\n/** The first text of a value: a string, or the first string of a localized value. */\nfunction textOf(value: unknown): string | null {\n if (typeof value === 'string') {\n return value;\n }\n if (value !== null && typeof value === 'object' && !Array.isArray(value)) {\n for (const entry of Object.values(value)) {\n if (typeof entry === 'string' && entry.trim() !== '') {\n return entry;\n }\n }\n }\n return null;\n}\n\nfunction normalizeEtag(value: string): string {\n return value.replace(/^W\\//, '');\n}\n\nclass Check {\n issues: string[] = [];\n skippedBecause: string | null = null;\n\n expect(condition: boolean, issue: string): boolean {\n if (!condition) {\n this.issues.push(issue);\n }\n return condition;\n }\n\n expectStatus(reply: Reply, status: number): boolean {\n return this.expect(\n reply.status === status,\n `Expected status ${status}, got ${reply.status}.`,\n );\n }\n\n expectSchema<T extends z.ZodType>(schema: T, value: unknown, label: string): z.infer<T> | null {\n const result = schema.safeParse(value);\n if (result.success) {\n return result.data;\n }\n this.issues.push(\n `${label} does not match the schema:`,\n ...describeIssues(result.error).map((issue) => ` ${issue}`),\n );\n return null;\n }\n\n expectProblem(reply: Reply, status: number): Problem | null {\n if (!this.expectStatus(reply, status)) {\n return null;\n }\n this.expect(\n reply.contentType.startsWith(PROBLEM_CONTENT_TYPE),\n `Expected content type ${PROBLEM_CONTENT_TYPE}, got \"${reply.contentType}\".`,\n );\n return this.expectSchema(Problem, reply.body, 'The error');\n }\n\n skip(reason: string) {\n this.skippedBecause = reason;\n }\n}\n\n/**\n * Runs the protocol's conformance checks against a live backend. Read-only checks always run;\n * checks that write data run only with `writes`.\n */\nexport async function runConformance(options: ConformanceOptions): Promise<ConformanceReport> {\n const fetcher = options.fetch ?? ((input: string, init?: RequestInit) => fetch(input, init));\n const baseUrl = options.baseUrl.replace(/\\/$/, '');\n const checks: ConformanceCheck[] = [];\n\n const request = async (path: string, init: RequestInit = {}): Promise<Reply> => {\n const headers = new Headers(options.init?.headers);\n headers.set('Accept', 'application/json');\n if (options.context !== undefined && Object.keys(options.context).length > 0) {\n headers.set(CONTEXT_HEADER, formatContextHeader(options.context));\n }\n new Headers(init.headers).forEach((value, key) => headers.set(key, value));\n if (init.body !== undefined) {\n headers.set('Content-Type', 'application/json');\n }\n const response = await fetcher(`${baseUrl}${path}`, { ...options.init, ...init, headers });\n const text = await response.text();\n const parse = (): unknown => {\n if (text === '') {\n return null;\n }\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n };\n const body = parse();\n return {\n status: response.status,\n contentType: response.headers.get('Content-Type') ?? '',\n etag: response.headers.get('ETag'),\n body,\n };\n };\n\n const run = async (id: string, title: string, body: (check: Check) => Promise<void>) => {\n const check = new Check();\n try {\n await body(check);\n } catch (error) {\n check.issues.push(\n `Request failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const status: ConformanceStatus =\n check.issues.length > 0\n ? 'failed'\n : check.skippedBecause !== null\n ? 'skipped'\n : 'passed';\n checks.push({\n id,\n title,\n status,\n issues:\n status === 'skipped' && check.skippedBecause !== null\n ? [check.skippedBecause]\n : check.issues,\n });\n };\n\n let definition: Definition | null = null;\n let resource: Resource | null = null;\n let firstItemId: string | null = null;\n\n await run('definition', 'GET /definition returns a valid definition', async (check) => {\n const reply = await request('/definition');\n if (check.expectStatus(reply, 200)) {\n definition = check.expectSchema(Definition, reply.body, 'The definition');\n }\n });\n\n await run('definition.resource', 'The definition has the resource to test', async (check) => {\n const current = definition as Definition | null;\n if (current === null) {\n check.skip('No valid definition.');\n return;\n }\n resource =\n (options.resource !== undefined\n ? current.resources.find((candidate) => candidate.id === options.resource)\n : current.resources[0]) ?? null;\n check.expect(\n resource !== null,\n options.resource !== undefined\n ? `The definition has no resource \"${options.resource}\".`\n : 'The definition has no resources.',\n );\n });\n\n // The context (decision 0045): the choices of its params, a definition built for a value,\n // and a value that doesn't exist refused with a 403.\n const contextParams = () => (definition as Definition | null)?.context?.params ?? [];\n let contextValue: { name: string; value: string } | null = null;\n\n await run(\n 'context.options',\n 'GET /context/{param}/options gives the choices of the params of the context',\n async (check) => {\n const params = contextParams();\n if (params.length === 0) {\n check.skip('The definition has no context.');\n return;\n }\n const values: Record<string, string> = {};\n for (const param of params) {\n // The backend sets it from the request: there is nothing to pick\n if (param.fixed === true) {\n continue;\n }\n let first = param.options?.[0]?.value;\n if (param.options === undefined) {\n const reply = await request(\n `/context/${encodeURIComponent(param.name)}/options`,\n { headers: { [CONTEXT_HEADER]: formatContextHeader(values) } },\n );\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const choices = check.expectSchema(\n ContextOptionsResponse,\n reply.body,\n `The choices of \"${param.name}\"`,\n );\n first = choices?.data[0]?.value;\n }\n const value = options.context?.[param.name] ?? first;\n if (value === undefined) {\n return;\n }\n values[param.name] = value;\n contextValue ??= { name: param.name, value };\n }\n },\n );\n\n await run(\n 'context.value',\n 'GET /definition is built for the values of Panneau-Context',\n async (check) => {\n const chosen = contextValue as { name: string; value: string } | null;\n if (chosen === null) {\n check.skip(\n contextParams().length === 0\n ? 'The definition has no context.'\n : 'No choice of the first param to send.',\n );\n return;\n }\n const reply = await request('/definition', {\n headers: { [CONTEXT_HEADER]: formatContextHeader({ [chosen.name]: chosen.value }) },\n });\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const built = check.expectSchema(Definition, reply.body, 'The definition');\n const param = built?.context?.params.find(({ name }) => name === chosen.name);\n check.expect(\n param?.value === chosen.value,\n `The definition was built for ${chosen.name}=${String(param?.value ?? null)}, expected ${chosen.value}.`,\n );\n },\n );\n\n await run(\n 'context.refused',\n 'A value of the context that does not exist is a 403 context problem',\n async (check) => {\n const param = contextParams()[0];\n if (param === undefined) {\n check.skip('The definition has no context.');\n return;\n }\n const reply = await request('/definition', {\n headers: { [CONTEXT_HEADER]: formatContextHeader({ [param.name]: UNKNOWN }) },\n });\n const problem = check.expectProblem(reply, 403);\n if (problem !== null) {\n check.expect(\n problem.type === CONTEXT_PROBLEM_TYPE,\n `Expected the type ${CONTEXT_PROBLEM_TYPE}, got ${problem.type}.`,\n );\n check.expect(\n problem.param === param.name,\n `Expected the param \"${param.name}\", got ${String(problem.param ?? 'none')}.`,\n );\n }\n },\n );\n\n const resourcePath = () =>\n `/resources/${encodeURIComponent((resource as Resource | null)?.id ?? '')}`;\n\n await run('list', 'GET /resources/{resource} returns a page of items', async (check) => {\n if (resource === null) {\n check.skip('No resource to test.');\n return;\n }\n // A list paged with cursors has no page numbers (decision 0039).\n const cursors = (resource as Resource).list?.pagination === 'cursor';\n const reply = await request(`${resourcePath()}?${cursors ? '' : 'page=1&'}perPage=2`);\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const list = check.expectSchema(ListResponse, reply.body, 'The list');\n if (list === null) {\n return;\n }\n check.expect(list.data.length <= 2, `perPage=2 returned ${list.data.length} items.`);\n check.expect(list.meta.perPage === 2, `meta.perPage is ${list.meta.perPage}, expected 2.`);\n firstItemId = list.data[0]?.id ?? null;\n const { meta } = list;\n if (!cursors) {\n check.expect(\n !isCursorPage(meta) && meta.page === 1,\n `meta.page is ${String((meta as { page?: unknown }).page)}, expected 1.`,\n );\n return;\n }\n if (!isCursorPage(meta)) {\n check.expect(false, 'The list pages with cursors, but its meta has no nextCursor.');\n return;\n }\n // The next page follows on from the first, and a cursor the backend can't read is a 422.\n if (meta.nextCursor !== null) {\n const next = await request(\n `${resourcePath()}?${toSearchParams({ perPage: 2, cursor: meta.nextCursor })}`,\n );\n if (check.expectStatus(next, 200)) {\n const page = check.expectSchema(ListResponse, next.body, 'The next page');\n const repeated = (page?.data ?? []).filter((item) =>\n list.data.some((first) => first.id === item.id),\n );\n check.expect(\n repeated.length === 0,\n `The page of nextCursor repeats items of the first page: ${repeated.map((item) => item.id).join(', ')}.`,\n );\n }\n }\n const invalid = await request(\n `${resourcePath()}?${toSearchParams({ perPage: 2, cursor: 'panneau-conformance-invalid' })}`,\n );\n const problem = check.expectProblem(invalid, 422);\n check.expect(\n problem === null || (problem.errors?.cursor ?? []).length > 0,\n 'An invalid cursor answers a 422 without errors.cursor.',\n );\n });\n\n await run('list.sort', 'GET /resources/{resource} accepts a sort', async (check) => {\n const sort = (resource as Resource | null)?.list?.sorts?.[0];\n if (sort === undefined) {\n check.skip('The resource declares no sorts.');\n return;\n }\n const reply = await request(`${resourcePath()}?sort=${encodeURIComponent(`-${sort}`)}`);\n if (check.expectStatus(reply, 200)) {\n check.expectSchema(ListResponse, reply.body, 'The sorted list');\n }\n });\n\n await run(\n 'list.filter-range',\n 'GET /resources/{resource} reads the bounds of a range filter',\n async (check) => {\n const filter = (resource as Resource | null)?.list?.filters?.find(\n (candidate) => candidate.type === 'date-range',\n );\n if (filter === undefined) {\n check.skip('The resource declares no date-range filter.');\n return;\n }\n const list = async (range: FilterRange | null, label: string) => {\n const query =\n range !== null ? `?${toSearchParams({ filter: { [filter.id]: range } })}` : '';\n const reply = await request(`${resourcePath()}${query}`);\n if (!check.expectStatus(reply, 200)) {\n return null;\n }\n return check.expectSchema(ListResponse, reply.body, label);\n };\n const all = await list(null, 'The list');\n if (all === null) {\n return;\n }\n // Items of the first page with a value: a range that covers every day includes them.\n const dated = all.data.filter((item) => isFilled(item[filter.id])).length;\n const ranges: [FilterRange, string][] = [\n [{ from: '0001-01-01', to: '9999-12-31' }, 'from 0001-01-01 to 9999-12-31'],\n [{ to: '9999-12-31' }, 'up to 9999-12-31 (an open start)'],\n ];\n // A list paged with cursors may have no total: the first page then counts.\n const totalOf = (reply: ListResponse) =>\n typeof reply.meta.total === 'number' ? reply.meta.total : null;\n for (const [range, label] of ranges) {\n const reply = await list(range, `The list filtered ${label}`);\n const total = reply !== null ? totalOf(reply) : null;\n if (total !== null) {\n check.expect(\n total >= dated,\n `Filtered ${label}, the list has ${total} items; the first page alone has ${dated} with a ${filter.id}.`,\n );\n }\n }\n const future = await list({ from: '9999-12-31' }, 'The list filtered from 9999-12-31');\n if (future !== null) {\n const total = totalOf(future) ?? future.data.length;\n check.expect(\n total === 0,\n `Filtered from 9999-12-31, the list has ${total} items, expected 0.`,\n );\n }\n },\n );\n\n await run(\n 'action.dry-run',\n 'A dry run of an action counts what it would do, and changes nothing',\n async (check) => {\n const action = (resource as Resource | null)?.actions?.find(\n (candidate) =>\n candidate.dryRun === true &&\n candidate.kind === 'server' &&\n candidate.scope.includes('selection'),\n );\n if (action === undefined) {\n check.skip('The resource declares no selection action with dryRun.');\n return;\n }\n const page = async (label: string) => {\n const reply = await request(`${resourcePath()}?page=1&perPage=20`);\n return check.expectStatus(reply, 200)\n ? check.expectSchema(ListResponse, reply.body, label)\n : null;\n };\n const before = await page('The list before the dry run');\n const reply = await request(\n `${resourcePath()}/actions/${encodeURIComponent(action.id)}`,\n {\n method: 'POST',\n body: JSON.stringify({ selection: { query: {} }, dryRun: true }),\n },\n );\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const result = check.expectSchema(ActionResult, reply.body, 'The dry run result');\n if (result !== null && before !== null) {\n check.expect(\n result.summary !== undefined,\n 'A dry run result must have a summary of the items that would succeed and be skipped.',\n );\n if (result.summary !== undefined) {\n const counted =\n result.summary.succeeded + result.summary.failed + result.summary.skipped;\n check.expect(\n counted === before.meta.total,\n `The dry run counts ${counted} items; the list has ${before.meta.total}.`,\n );\n }\n }\n const after = await page('The list after the dry run');\n if (before !== null && after !== null) {\n const versions = (list: typeof before) =>\n JSON.stringify(list.data.map((item) => [item.id, item.version ?? null]));\n check.expect(\n after.meta.total === before.meta.total && versions(after) === versions(before),\n 'A dry run must not change the items.',\n );\n }\n },\n );\n\n await run(\n 'action.delete',\n 'The built-in `delete` answers, with dry runs, without being declared',\n async (check) => {\n const current = resource as Resource | null;\n if (current === null) {\n check.skip('No resource to test.');\n return;\n }\n if (current.itemActions !== undefined && !current.itemActions.includes('delete')) {\n check.skip('The resource leaves out `delete` (`itemActions`).');\n return;\n }\n if (firstItemId === null) {\n check.skip('The list has no items.');\n return;\n }\n // A dry run changes nothing: the check runs without `writes`.\n const reply = await request(`${resourcePath()}/actions/delete`, {\n method: 'POST',\n body: JSON.stringify({ selection: { ids: [firstItemId] }, dryRun: true }),\n });\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const result = check.expectSchema(ActionResult, reply.body, 'The dry run of `delete`');\n if (result !== null) {\n check.expect(\n result.summary !== undefined &&\n result.summary.succeeded +\n result.summary.skipped +\n result.summary.failed ===\n 1,\n 'The dry run of `delete` on one item must count it, as deleted or skipped.',\n );\n }\n check.expectStatus(\n await request(`${resourcePath()}/${encodeURIComponent(firstItemId)}`),\n 200,\n );\n },\n );\n\n await run(\n 'uploads.sign',\n 'POST /uploads/sign signs the first request of a file, and only the keys of open uploads',\n async (check) => {\n const uploads = (definition as Definition | null)?.uploads;\n if (uploads?.mode !== 'presigned') {\n check.skip('The definition has no presigned uploads.');\n return;\n }\n if (uploads.endpoint !== undefined) {\n check.skip('The upload routes are not at {api.baseUrl}/uploads.');\n return;\n }\n const sign = (body: unknown) =>\n request('/uploads/sign', { method: 'POST', body: JSON.stringify(body) });\n const reply = await sign({ method: 'POST', key: 'panneau-conformance.txt' });\n if (check.expectStatus(reply, 200)) {\n const signed = check.expectSchema(\n UploadSignResponse,\n reply.body,\n 'The signed request',\n );\n if (signed !== null) {\n check.expect(\n signed.key !== undefined && signed.upload !== undefined,\n 'The first request of a file must answer the key and the upload the backend chose.',\n );\n }\n }\n check.expectProblem(\n await sign({\n method: 'PUT',\n key: 'not-an-upload-of-this-user',\n uploadId: 'unknown',\n partNumber: 1,\n }),\n 404,\n );\n check.expectProblem(\n await request(`/uploads/${UNKNOWN}/complete`, { method: 'POST' }),\n 404,\n );\n },\n );\n\n await run(\n 'fields.check',\n 'POST /resources/{resource}/fields/{field}/check checks a value of a field with `check`',\n async (check) => {\n const field = resource?.fields.find((candidate) => candidate.check === true);\n if (resource === null || field === undefined) {\n check.skip('The resource has no field with `check`.');\n return;\n }\n const checkPath = (name: string) =>\n `${resourcePath()}/fields/${encodeURIComponent(name)}/check`;\n const locale = field.localized === true ? definition?.locale : undefined;\n const reply = await request(checkPath(field.name), {\n method: 'POST',\n body: JSON.stringify({\n value: 'panneau-conformance',\n ...(locale !== undefined ? { locale } : {}),\n id: null,\n values: {},\n }),\n });\n if (check.expectStatus(reply, 200)) {\n check.expectSchema(FieldCheckResponse, reply.body, 'The check');\n }\n check.expectProblem(\n await request(checkPath(UNKNOWN), { method: 'POST', body: '{\"value\":\"x\"}' }),\n 404,\n );\n },\n );\n\n await run('list.unknown-resource', 'An unknown resource is a 404 problem', async (check) => {\n check.expectProblem(await request(`/resources/${UNKNOWN}`), 404);\n });\n\n await run(\n 'item',\n 'GET /resources/{resource}/{id} returns the item with its ETag',\n async (check) => {\n if (firstItemId === null) {\n check.skip('The list has no items.');\n return;\n }\n const reply = await request(`${resourcePath()}/${encodeURIComponent(firstItemId)}`);\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const item = check.expectSchema(ItemResponse, reply.body, 'The item');\n if (item === null) {\n return;\n }\n check.expect(\n item.data.id === firstItemId,\n `Asked for item \"${firstItemId}\", got \"${item.data.id}\".`,\n );\n if (item.data.version !== null) {\n check.expect(\n reply.etag !== null && normalizeEtag(reply.etag) === `\"${item.data.version}\"`,\n `Expected ETag \"${item.data.version}\" (quoted), got ${reply.etag ?? 'none'}.`,\n );\n }\n },\n );\n\n await run('item.missing', 'A missing item is a 404 problem', async (check) => {\n if (resource === null) {\n check.skip('No resource to test.');\n return;\n }\n check.expectProblem(await request(`${resourcePath()}/${UNKNOWN}`), 404);\n });\n\n // The API agrees with the abilities of the definition and of the items (decision 0046).\n const listItems = async (check: Check): Promise<Item[] | null> => {\n const cursors = (resource as Resource | null)?.list?.pagination === 'cursor';\n const reply = await request(`${resourcePath()}?${cursors ? '' : 'page=1&'}perPage=20`);\n if (!check.expectStatus(reply, 200)) {\n return null;\n }\n return check.expectSchema(ListResponse, reply.body, 'The list')?.data ?? null;\n };\n\n await run(\n 'abilities.view-any',\n 'The resources the user can’t list answer 403 on their list',\n async (check) => {\n const current = definition as Definition | null;\n const denied = (current?.resources ?? []).filter(\n (candidate) => candidate.abilities?.viewAny === false,\n );\n if (denied.length === 0) {\n check.skip('Every resource can be listed.');\n return;\n }\n for (const candidate of denied) {\n const reply = await request(`/resources/${encodeURIComponent(candidate.id)}`);\n check.expect(\n reply.status === 403,\n `${candidate.id} has \\`viewAny: false\\`, but its list answered ${reply.status}.`,\n );\n }\n },\n );\n\n await run(\n 'abilities.fields',\n 'Items leave out the values of the fields the user can’t see',\n async (check) => {\n const hidden = ((resource as Resource | null)?.fields ?? [])\n .filter((field) => field.abilities?.view === false)\n .map((field) => field.name);\n if (hidden.length === 0) {\n check.skip('The resource has no field with `view: false`.');\n return;\n }\n const items = await listItems(check);\n if (items === null) {\n return;\n }\n if (items.length === 0) {\n check.skip('The list has no items.');\n return;\n }\n items.forEach((item) => {\n const shown = hidden.filter((name) => name in item);\n check.expect(\n shown.length === 0,\n `Item ${item.id} has values of fields with \\`view: false\\`: ${shown.join(', ')}.`,\n );\n });\n },\n );\n\n await run(\n 'abilities.delete',\n 'An item that can’t be deleted is skipped by a dry run of `delete`',\n async (check) => {\n const current = resource as Resource | null;\n if (current === null) {\n check.skip('No resource to test.');\n return;\n }\n if (current.itemActions !== undefined && !current.itemActions.includes('delete')) {\n check.skip('The resource leaves out `delete` (`itemActions`).');\n return;\n }\n const items = await listItems(check);\n const denied = items?.find((item) => item.abilities.delete !== true);\n if (items === null) {\n return;\n }\n if (denied === undefined) {\n check.skip('Every item of the first page can be deleted.');\n return;\n }\n // With an item it can delete too: the only item of an action would be a 403 instead\n const allowed = items.find((item) => item.abilities.delete === true);\n const ids = allowed !== undefined ? [denied.id, allowed.id] : [denied.id];\n const reply = await request(`${resourcePath()}/actions/delete`, {\n method: 'POST',\n body: JSON.stringify({ selection: { ids }, dryRun: true }),\n });\n if (allowed === undefined && reply.status === 403) {\n return;\n }\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const result = check.expectSchema(ActionResult, reply.body, 'The dry run of `delete`');\n check.expect(\n result === null ||\n (result.summary?.skipped === 1 && result.summary.succeeded === ids.length - 1),\n `Item ${denied.id} can’t be deleted, but the dry run of \\`delete\\` doesn’t skip it.`,\n );\n },\n );\n\n // The global search: a word of the title of an item of a searchable resource finds it.\n let searched: { resource: Resource; term: string } | null = null;\n const searchSkip = (): string | null => {\n const current = definition as Definition | null;\n if (current === null) {\n return 'No valid definition.';\n }\n if (current.search?.enabled === false) {\n return 'The definition disables the global search.';\n }\n return searched === null\n ? 'No searchable resource has an item with a title to search for.'\n : null;\n };\n const search = (query: SearchQuery) => request(`/search?${toSearchQueryParams(query)}`);\n\n await run('search', 'GET /search finds items of the searchable resources', async (check) => {\n const current = definition as Definition | null;\n const tested = resource as Resource | null;\n if (current === null || current.search?.enabled === false) {\n check.skip(searchSkip() ?? '');\n return;\n }\n const candidates = current.resources\n .filter(\n (candidate) =>\n isSearchableResource(candidate) && candidate.abilities?.viewAny !== false,\n )\n // The tested resource first\n .sort((a, b) => Number(b.id === tested?.id) - Number(a.id === tested?.id));\n for (const candidate of candidates) {\n if (candidate.itemTitle === undefined || searched !== null) {\n continue;\n }\n const reply = await request(\n `/resources/${encodeURIComponent(candidate.id)}?page=1&perPage=1`,\n );\n const list = ListResponse.safeParse(reply.body);\n const title = list.success ? textOf(list.data.data[0]?.[candidate.itemTitle]) : null;\n const term = title?.split(/\\s+/).find((word) => word.length >= 2);\n if (term !== undefined) {\n searched = { resource: candidate, term };\n }\n }\n const reason = searchSkip();\n if (reason !== null || searched === null) {\n check.skip(reason ?? '');\n return;\n }\n const { resource: target, term } = searched as { resource: Resource; term: string };\n const reply = await search({ q: term });\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const results = check.expectSchema(SearchResponse, reply.body, 'The results');\n if (results === null) {\n return;\n }\n const ids = candidates.map((candidate) => candidate.id);\n for (const group of results.data) {\n check.expect(\n ids.includes(group.resource),\n `Results of \"${group.resource}\", which is not a searchable resource.`,\n );\n check.expect(\n group.items.length <= SEARCH_DEFAULT_LIMIT,\n `\"${group.resource}\" has ${group.items.length} results; without a limit, at most ${SEARCH_DEFAULT_LIMIT}.`,\n );\n }\n const count = results.data.reduce((total, group) => total + group.items.length, 0);\n check.expect(\n count <= SEARCH_MAX_LIMIT,\n `The results have ${count} items, at most ${SEARCH_MAX_LIMIT}.`,\n );\n check.expect(\n results.data.some((group) => group.resource === target.id && group.items.length > 0),\n `Searching \"${term}\", a word of the title of an item of \"${target.id}\", finds none of its items.`,\n );\n });\n\n await run('search.scope', 'GET /search reads limit and resources', async (check) => {\n const reason = searchSkip();\n if (reason !== null || searched === null) {\n check.skip(reason ?? '');\n return;\n }\n const { resource: target, term } = searched as { resource: Resource; term: string };\n const reply = await search({ q: term, limit: 1, resources: [target.id] });\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const results = check.expectSchema(SearchResponse, reply.body, 'The results');\n if (results !== null) {\n check.expect(\n results.data.length === 1 &&\n results.data[0]?.resource === target.id &&\n results.data[0].items.length === 1,\n `With limit=1&resources=${target.id}, expected one item of \"${target.id}\", got ${JSON.stringify(results.data.map((group) => [group.resource, group.items.length]))}.`,\n );\n }\n });\n\n await run(\n 'search.invalid',\n 'An invalid search is a 422 problem, with errors keyed by parameter',\n async (check) => {\n const reason = searchSkip();\n if (reason !== null || searched === null) {\n check.skip(reason ?? '');\n return;\n }\n const { term } = searched as { resource: Resource; term: string };\n const invalid: [string, SearchQuery][] = [\n ['q', { q: term.slice(0, 1) }],\n ['limit', { q: term, limit: 0 }],\n ['limit', { q: term, limit: SEARCH_MAX_LIMIT + 1 }],\n ['resources', { q: term, resources: [UNKNOWN] }],\n ];\n for (const [parameter, query] of invalid) {\n const failure = check.expectProblem(await search(query), 422);\n if (failure !== null) {\n check.expect(\n failure.errors?.[parameter] !== undefined,\n `${toSearchQueryParams(query)}: the 422 problem must have errors.${parameter}.`,\n );\n }\n }\n },\n );\n\n const writes = options.writes;\n let createdId: string | null = null;\n let createdVersion: string | null = null;\n let updatedVersion: string | null = null;\n\n await run(\n 'abilities.create',\n 'The resources the user can’t create items of answer 403 to a create',\n async (check) => {\n const current = definition as Definition | null;\n if (writes === undefined || current === null) {\n check.skip('Write checks are disabled.');\n return;\n }\n const denied = current.resources.filter(\n (candidate) => candidate.abilities?.create === false,\n );\n if (denied.length === 0) {\n check.skip('The user can create items of every resource.');\n return;\n }\n for (const candidate of denied) {\n // Empty values: a backend that wrongly accepts them has nothing to save.\n const reply = await request(`/resources/${encodeURIComponent(candidate.id)}`, {\n method: 'POST',\n body: '{}',\n });\n check.expect(\n reply.status === 403,\n `${candidate.id} has \\`create: false\\`, but a create answered ${reply.status}.`,\n );\n }\n },\n );\n\n await run(\n 'abilities.update',\n 'An item the user can’t update answers 403 to an update',\n async (check) => {\n if (writes === undefined || resource === null) {\n check.skip('Write checks are disabled.');\n return;\n }\n const items = await listItems(check);\n const denied = items?.find((item) => item.abilities.update !== true);\n if (items === null) {\n return;\n }\n if (denied === undefined) {\n check.skip('Every item of the first page can be updated.');\n return;\n }\n // An empty update: a backend that wrongly accepts it changes nothing.\n const reply = await request(`${resourcePath()}/${encodeURIComponent(denied.id)}`, {\n method: 'PATCH',\n body: '{}',\n headers: denied.version !== null ? { 'If-Match': `\"${denied.version}\"` } : {},\n });\n check.expect(\n reply.status === 403,\n `Item ${denied.id} can’t be updated, but an update answered ${reply.status}.`,\n );\n },\n );\n\n await run('create.invalid', 'Invalid values are refused with a 422 problem', async (check) => {\n if (writes === undefined || resource === null) {\n check.skip('Write checks are disabled.');\n return;\n }\n const hasRequired = resource.fields.some((field) =>\n (field.rules ?? []).some(\n (rule) => rule.rule === 'required' && (rule.mode ?? 'create') === 'create',\n ),\n );\n if (writes.invalid === undefined && !hasRequired) {\n check.skip('No invalid values given, and the resource has no required field.');\n return;\n }\n const reply = await request(resourcePath(), {\n method: 'POST',\n body: JSON.stringify(writes.invalid ?? {}),\n });\n const failure = check.expectProblem(reply, 422);\n if (failure !== null) {\n check.expect(\n failure.errors !== undefined && Object.keys(failure.errors).length > 0,\n 'A 422 problem must list the invalid values in `errors`.',\n );\n }\n });\n\n await run('create', 'POST /resources/{resource} creates an item', async (check) => {\n if (writes === undefined || resource === null) {\n check.skip('Write checks are disabled.');\n return;\n }\n const reply = await request(resourcePath(), {\n method: 'POST',\n body: JSON.stringify(writes.create),\n });\n if (!check.expectStatus(reply, 201)) {\n return;\n }\n const item = check.expectSchema(ItemResponse, reply.body, 'The created item');\n createdId = item?.data.id ?? null;\n createdVersion = item?.data.version ?? null;\n });\n\n const itemPath = () => `${resourcePath()}/${encodeURIComponent(createdId ?? '')}`;\n\n await run('update', 'PATCH /resources/{resource}/{id} updates the item', async (check) => {\n if (createdId === null || writes === undefined) {\n check.skip('No item was created.');\n return;\n }\n const reply = await request(itemPath(), {\n method: 'PATCH',\n body: JSON.stringify(writes.update),\n headers: createdVersion !== null ? { 'If-Match': `\"${createdVersion}\"` } : {},\n });\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const item = check.expectSchema(ItemResponse, reply.body, 'The updated item');\n if (item !== null && createdVersion !== null) {\n check.expect(\n item.data.version !== createdVersion,\n 'The version did not change after an update.',\n );\n }\n updatedVersion = item?.data.version ?? null;\n });\n\n await run(\n 'update.create-rules',\n 'Rules limited to create do not apply to updates',\n async (check) => {\n if (createdId === null || writes === undefined || resource === null) {\n check.skip('No item was created.');\n return;\n }\n // A password: required to create the item, left empty to keep it on an update.\n const names = resource.fields\n .filter(\n (field) =>\n field.readOnly !== true &&\n field.createOnly !== true &&\n (field.rules ?? []).some(\n (rule) => rule.rule === 'required' && rule.mode === 'create',\n ),\n )\n .map((field) => field.name);\n if (names.length === 0) {\n check.skip('The resource has no rule limited to create.');\n return;\n }\n const reply = await request(itemPath(), {\n method: 'PATCH',\n body: JSON.stringify(Object.fromEntries(names.map((name) => [name, null]))),\n headers: updatedVersion !== null ? { 'If-Match': `\"${updatedVersion}\"` } : {},\n });\n check.expect(\n reply.status === 200,\n `An update with ${names.join(', ')} set to null got status ${reply.status}, expected 200.`,\n );\n },\n );\n\n await run(\n 'update.single-field',\n 'A PATCH with a single field and If-Match changes that field alone',\n async (check) => {\n if (createdId === null || writes === undefined || resource === null) {\n check.skip('No item was created.');\n return;\n }\n // As a list edits a field in place: the item's version, and the one field\n const current = await request(itemPath());\n const before = check.expectStatus(current, 200)\n ? check.expectSchema(ItemResponse, current.body, 'The item')\n : null;\n if (before === null) {\n return;\n }\n // A value of the update set back to the one it was created with: a real change.\n const name = Object.keys(writes.update).find(\n (key) => key in writes.create && !isEqual(writes.create[key], before.data[key]),\n );\n if (name === undefined) {\n check.skip(\n 'No value of the update of `writes` differs from its value in `create`, to set it back.',\n );\n return;\n }\n const version = before.data.version;\n const reply = await request(itemPath(), {\n method: 'PATCH',\n body: JSON.stringify({ [name]: writes.create[name] }),\n headers: version !== null ? { 'If-Match': `\"${version}\"` } : {},\n });\n if (!check.expectStatus(reply, 200)) {\n return;\n }\n const after = check.expectSchema(ItemResponse, reply.body, 'The updated item');\n if (after === null) {\n return;\n }\n if (version !== null) {\n check.expect(\n after.data.version !== version,\n 'The version did not change after an update of a single field.',\n );\n }\n const changed = resource.fields\n .filter(\n (field) =>\n field.name !== name &&\n field.readOnly !== true &&\n field.settings?.secret !== true &&\n !isEqual(before.data[field.name], after.data[field.name]),\n )\n .map((field) => field.name);\n check.expect(\n changed.length === 0,\n `An update of ${name} alone also changed ${changed.join(', ')}.`,\n );\n updatedVersion = after.data.version;\n },\n );\n\n await run(\n 'update.conflict',\n 'A stale If-Match is a 412 problem with the current item',\n async (check) => {\n if (createdId === null || writes === undefined) {\n check.skip('No item was created.');\n return;\n }\n if (createdVersion === null) {\n check.skip('The backend has no versions.');\n return;\n }\n const reply = await request(itemPath(), {\n method: 'PATCH',\n body: JSON.stringify(writes.update),\n headers: { 'If-Match': '\"__panneau_conformance_stale__\"' },\n });\n const failure = check.expectProblem(reply, 412);\n if (failure !== null) {\n check.expect(\n failure.current !== undefined,\n 'A 412 problem must include the current item.',\n );\n }\n },\n );\n\n await run(\n 'duplicate',\n 'POST /resources/{resource}/{id}/duplicate copies an item that allows it',\n async (check) => {\n if (createdId === null) {\n check.skip('No item was created.');\n return;\n }\n const reply = await request(itemPath());\n const created = check.expectStatus(reply, 200)\n ? check.expectSchema(ItemResponse, reply.body, 'The item')\n : null;\n if (created === null) {\n return;\n }\n // The built-in `duplicate` is only shown on items that allow it (decision 0040).\n if (created.data.abilities.duplicate !== true) {\n check.skip(\"The item doesn't allow `duplicate`.\");\n return;\n }\n const copy = await request(`${itemPath()}/duplicate`, { method: 'POST' });\n if (!check.expectStatus(copy, 201)) {\n return;\n }\n const duplicated = check.expectSchema(ItemResponse, copy.body, 'The copy');\n if (duplicated === null) {\n return;\n }\n check.expect(\n copy.etag !== null && normalizeEtag(copy.etag) === `\"${duplicated.data.version}\"`,\n `Expected the ETag of the copy, \"${duplicated.data.version}\" (quoted), got ${copy.etag ?? 'none'}.`,\n );\n check.expect(\n duplicated.data.id !== created.data.id,\n 'The copy has the id of the item it copies.',\n );\n // Clean up the copy\n await request(`${resourcePath()}/${encodeURIComponent(duplicated.data.id)}`, {\n method: 'DELETE',\n });\n },\n );\n\n await run('delete', 'DELETE /resources/{resource}/{id} deletes the item', async (check) => {\n if (createdId === null) {\n check.skip('No item was created.');\n return;\n }\n if (!check.expectStatus(await request(itemPath(), { method: 'DELETE' }), 204)) {\n return;\n }\n check.expectProblem(await request(itemPath()), 404);\n });\n\n return { passed: checks.every((check) => check.status !== 'failed'), checks };\n}\n\n/** Formats a report as text, one line per check. */\nexport function formatReport(report: ConformanceReport): string {\n const symbols: Record<ConformanceStatus, string> = { passed: '✓', failed: '✗', skipped: '-' };\n return report.checks\n .map((check) =>\n [\n `${symbols[check.status]} ${check.title}`,\n ...check.issues.map((issue) => ` ${issue}`),\n ].join('\\n'),\n )\n .join('\\n');\n}\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I,UAAU,sDAAsD,OAAO,UAAU;EACvF,IAAI,cAAc,MAAM;GACpB,MAAM,KAAK,sBAAsB;GACjC;EACJ;EACA,IAAI,CAAC,MAAM,aAAa,MAAM,QAAQ,SAAS,GAAG,EAAE,QAAQ,SAAS,CAAC,GAAG,GAAG,GACxE;EAEJ,MAAM,cAAc,MAAM,QAAQ,SAAS,CAAC,GAAG,GAAG;CACtD,CAAC;CAED,OAAO;EAAE,QAAQ,OAAO,OAAO,UAAU,MAAM,WAAW,QAAQ;EAAG;CAAO;AAChF;;AAGA,SAAgB,aAAa,QAAmC;CAC5D,MAAM,UAA6C;EAAE,QAAQ;EAAK,QAAQ;EAAK,SAAS;CAAI;CAC5F,OAAO,OAAO,OACT,KAAK,UACF,CACI,GAAG,QAAQ,MAAM,QAAQ,GAAG,MAAM,SAClC,GAAG,MAAM,OAAO,KAAK,UAAU,OAAO,OAAO,CACjD,CAAC,CAAC,KAAK,IAAI,CACf,CAAC,CACA,KAAK,IAAI;AAClB"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -21,10 +21,10 @@ export declare const ITEM_ACTION_ABILITIES: Readonly<Record<BuiltInItemAction, s
|
|
|
21
21
|
/** Whether an action id is one of the built-in item actions. */
|
|
22
22
|
export declare function isBuiltInItemAction(id: string): id is BuiltInItemAction;
|
|
23
23
|
/** Field types every Panneau frontend renders. Plugins add others. */
|
|
24
|
-
export declare const BUILT_IN_FIELD_TYPES: readonly ["text", "textarea", "richtext", "number", "boolean", "date", "datetime", "time", "select", "email", "url", "color", "media", "image", "relation", "group", "repeater", "slug", "tel", "range", "duration", "json", "tags", "embed", "location"];
|
|
24
|
+
export declare const BUILT_IN_FIELD_TYPES: readonly ["text", "textarea", "richtext", "number", "boolean", "date", "datetime", "time", "select", "email", "url", "color", "media", "image", "relation", "group", "repeater", "slug", "tel", "range", "duration", "json", "tags", "embed", "location", "country", "region"];
|
|
25
25
|
export type BuiltInFieldType = (typeof BUILT_IN_FIELD_TYPES)[number];
|
|
26
26
|
/** Validation rules that both frontends and backends check. */
|
|
27
|
-
export declare const PORTABLE_RULES: readonly ["required", "min", "max", "pattern", "email", "url", "json", "in", "accept", "maxSize", "before", "after", "crop"];
|
|
27
|
+
export declare const PORTABLE_RULES: readonly ["required", "min", "max", "pattern", "email", "url", "json", "tel", "in", "accept", "maxSize", "before", "after", "crop"];
|
|
28
28
|
export type PortableRule = (typeof PORTABLE_RULES)[number];
|
|
29
29
|
/** Layout node types every Panneau frontend renders. */
|
|
30
30
|
export declare const BUILT_IN_LAYOUT_NODE_TYPES: readonly ["row", "column", "section", "tabs", "tab", "sidebar", "field", "text", "component"];
|
|
@@ -41,4 +41,14 @@ export declare const BOOT_CONFIG_ELEMENT_ID = "panneau-boot";
|
|
|
41
41
|
export declare const RICH_TEXT_STYLE_ELEMENTS: readonly ["p", "h1", "h2", "h3", "h4", "h5", "h6", "blockquote", "ul", "ol", "li"];
|
|
42
42
|
/** An element a block style of a `richtext` field can apply to. */
|
|
43
43
|
export type RichTextStyleElement = (typeof RICH_TEXT_STYLE_ELEMENTS)[number];
|
|
44
|
+
/**
|
|
45
|
+
* The first segments of the client routes under `basePath` that Panneau keeps for itself
|
|
46
|
+
* (decision 0019). A param of the context can't be named like one: the context is a prefix of
|
|
47
|
+
* the routes, `{basePath}/{name}/{value}/…` (decision 0045).
|
|
48
|
+
*/
|
|
49
|
+
export declare const RESERVED_ROUTE_SEGMENTS: readonly ["resources", "pages", "media", "search", "account", "auth"];
|
|
50
|
+
/** The request header that carries the values of the current context (decision 0045). */
|
|
51
|
+
export declare const CONTEXT_HEADER = "Panneau-Context";
|
|
52
|
+
/** The type of the `403` problem of a value of the context that the user can't use. */
|
|
53
|
+
export declare const CONTEXT_PROBLEM_TYPE = "urn:panneau:problem:context";
|
|
44
54
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants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