@quazardous/qdadm 2.51.0 → 2.53.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.
Files changed (129) hide show
  1. package/dist/node/cards/tools/cardsTool.d.ts +32 -0
  2. package/dist/node/cards/tools/cardsTool.js +151 -0
  3. package/dist/node/cards/tools/cli.d.ts +2 -0
  4. package/dist/node/cards/tools/cli.js +38 -0
  5. package/dist/node/cards/validate.d.ts +35 -0
  6. package/dist/node/cards/validate.js +94 -0
  7. package/dist/styles/qdadm.css +1 -1
  8. package/package.json +7 -2
  9. package/src/board/QdBoardBlock.vue +67 -0
  10. package/src/board/QdDomainBoard.vue +64 -0
  11. package/src/board/blocks/BreakdownBlock.vue +44 -0
  12. package/src/board/blocks/KpiBlock.vue +31 -0
  13. package/src/board/blocks/TimelineBlock.vue +63 -0
  14. package/src/board/blocks/TopBlock.vue +57 -0
  15. package/src/board/blocks/schemas.ts +107 -0
  16. package/src/board/index.ts +31 -0
  17. package/src/board/registry.ts +33 -0
  18. package/src/board/types.ts +32 -0
  19. package/src/cards/QdCard.vue +175 -0
  20. package/src/cards/QdCardView.vue +53 -0
  21. package/src/cards/QdCardsGallery.vue +103 -0
  22. package/src/cards/QdFavoritesCard.vue +50 -0
  23. package/src/cards/QdRecentCard.vue +44 -0
  24. package/src/cards/builtin/agenda/AgendaCard.vue +37 -0
  25. package/src/cards/builtin/agenda/meta.json +60 -0
  26. package/src/cards/builtin/agenda/schema.json +48 -0
  27. package/src/cards/builtin/bullet/BulletCard.vue +76 -0
  28. package/src/cards/builtin/bullet/meta.json +38 -0
  29. package/src/cards/builtin/bullet/schema.json +18 -0
  30. package/src/cards/builtin/cards-index.json +1694 -0
  31. package/src/cards/builtin/compare/CompareCard.vue +47 -0
  32. package/src/cards/builtin/compare/meta.json +79 -0
  33. package/src/cards/builtin/compare/schema.json +40 -0
  34. package/src/cards/builtin/favorites/FavoritesCard.vue +50 -0
  35. package/src/cards/builtin/favorites/meta.json +33 -0
  36. package/src/cards/builtin/favorites/schema.json +20 -0
  37. package/src/cards/builtin/feed/FeedCard.vue +39 -0
  38. package/src/cards/builtin/feed/meta.json +64 -0
  39. package/src/cards/builtin/feed/schema.json +54 -0
  40. package/src/cards/builtin/funnel/FunnelCard.vue +44 -0
  41. package/src/cards/builtin/funnel/meta.json +53 -0
  42. package/src/cards/builtin/funnel/schema.json +37 -0
  43. package/src/cards/builtin/goal/GoalCard.vue +73 -0
  44. package/src/cards/builtin/goal/meta.json +43 -0
  45. package/src/cards/builtin/goal/schema.json +12 -0
  46. package/src/cards/builtin/heat/HeatCard.vue +46 -0
  47. package/src/cards/builtin/heat/meta.json +101 -0
  48. package/src/cards/builtin/heat/schema.json +39 -0
  49. package/src/cards/builtin/index.ts +71 -0
  50. package/src/cards/builtin/metric/MetricCard.vue +82 -0
  51. package/src/cards/builtin/metric/meta.json +109 -0
  52. package/src/cards/builtin/metric/schema.json +35 -0
  53. package/src/cards/builtin/pills.ts +36 -0
  54. package/src/cards/builtin/queue/QueueCard.vue +65 -0
  55. package/src/cards/builtin/queue/meta.json +47 -0
  56. package/src/cards/builtin/queue/schema.json +32 -0
  57. package/src/cards/builtin/ranking/RankingCard.vue +37 -0
  58. package/src/cards/builtin/ranking/meta.json +71 -0
  59. package/src/cards/builtin/ranking/schema.json +35 -0
  60. package/src/cards/builtin/recent/RecentCard.vue +41 -0
  61. package/src/cards/builtin/recent/meta.json +32 -0
  62. package/src/cards/builtin/recent/schema.json +21 -0
  63. package/src/cards/builtin/shared.ts +83 -0
  64. package/src/cards/builtin/split/SplitCard.vue +52 -0
  65. package/src/cards/builtin/split/meta.json +72 -0
  66. package/src/cards/builtin/split/schema.json +40 -0
  67. package/src/cards/builtin/trend/TrendCard.vue +75 -0
  68. package/src/cards/builtin/trend/meta.json +81 -0
  69. package/src/cards/builtin/trend/schema.json +58 -0
  70. package/src/cards/index.ts +29 -0
  71. package/src/cards/registry.ts +57 -0
  72. package/src/cards/tools/cardsTool.ts +181 -0
  73. package/src/cards/tools/cli.ts +35 -0
  74. package/src/cards/types.ts +111 -0
  75. package/src/cards/validate.ts +111 -0
  76. package/src/components/edit/FormActions.vue +9 -5
  77. package/src/components/edit/FormPage.vue +17 -2
  78. package/src/components/layout/AppLayout.vue +4 -0
  79. package/src/components/layout/BaseLayout.vue +4 -0
  80. package/src/components/layout/CardParamsForm.vue +157 -0
  81. package/src/components/layout/CardsDashboard.vue +276 -57
  82. package/src/components/layout/PageHeader.vue +22 -1
  83. package/src/components/layout/QdFavoriteStar.vue +71 -0
  84. package/src/components/layout/Zone.vue +2 -1
  85. package/src/components/lists/ListPage.vue +9 -1
  86. package/src/components/lists/QdSaveSearch.vue +79 -0
  87. package/src/components/pages/NotFoundPage.vue +5 -2
  88. package/src/components/run/QdRunBar.vue +99 -0
  89. package/src/components/show/ShowPage.vue +10 -1
  90. package/src/composables/useBreadcrumb.ts +1 -1
  91. package/src/composables/useCardsArrangement.ts +297 -27
  92. package/src/composables/useEntityItemFormPage.ts +39 -3
  93. package/src/composables/useEntityItemFormPage.types.ts +8 -0
  94. package/src/composables/useEntityItemShowPage.ts +22 -0
  95. package/src/composables/useListPage.ts +71 -0
  96. package/src/composables/useListPage.types.ts +6 -0
  97. package/src/composables/useUnsavedChangesGuard.ts +17 -1
  98. package/src/domain/QdBadge.vue +36 -0
  99. package/src/domain/QdDomainBar.vue +213 -0
  100. package/src/domain/QdDomainBarZone.vue +19 -0
  101. package/src/domain/index.ts +6 -0
  102. package/src/domain/registry.ts +122 -0
  103. package/src/favorites/index.ts +7 -0
  104. package/src/favorites/store.ts +172 -0
  105. package/src/favorites/useFavorites.ts +217 -0
  106. package/src/i18n/defaults/core.en.generated.ts +132 -0
  107. package/src/i18n/defaults/core.en.yml +132 -0
  108. package/src/i18n/defaults/core.fr.generated.ts +132 -0
  109. package/src/i18n/defaults/core.fr.yml +132 -0
  110. package/src/index.ts +23 -0
  111. package/src/kernel/Kernel.routing.ts +4 -15
  112. package/src/kernel/Kernel.types.ts +5 -1
  113. package/src/kernel/Kernel.vue.ts +2 -2
  114. package/src/kernel/KernelContext.routing.ts +10 -1
  115. package/src/kernel/KernelContext.ts +7 -0
  116. package/src/kernel/KernelContext.types.ts +2 -0
  117. package/src/kernel/homeRoute.ts +45 -0
  118. package/src/module/moduleRegistry.ts +4 -0
  119. package/src/run/index.ts +6 -0
  120. package/src/run/run.ts +162 -0
  121. package/src/run/useRun.ts +207 -0
  122. package/src/styles/_cards-dashboard.scss +190 -0
  123. package/src/styles/_qd-board.scss +359 -0
  124. package/src/styles/_qd-cards.scss +1197 -0
  125. package/src/styles/_qd-domain-bar.scss +159 -0
  126. package/src/styles/_qd-run.scss +135 -0
  127. package/src/styles/index.scss +4 -0
  128. package/src/zones/ZoneRegistry.ts +16 -0
  129. package/src/zones/index.ts +1 -0
@@ -0,0 +1,32 @@
1
+ import { type CardSchema } from '../validate.js';
2
+ export interface CardFolder {
3
+ /** The folder's name, which is the card's type */
4
+ type: string;
5
+ dir: string;
6
+ meta: Record<string, unknown> | null;
7
+ schema: CardSchema | null;
8
+ /** The body's file name, or null */
9
+ component: string | null;
10
+ }
11
+ export interface CardsOutputs {
12
+ /** Where the index (JSON) is written */
13
+ index?: string;
14
+ /** Where the bestiary (Markdown) is written */
15
+ bestiary?: string;
16
+ /** The bestiary's first heading (default "Cards") */
17
+ title?: string;
18
+ }
19
+ /** The card folders under `dir`, sorted by type */
20
+ export declare function readCards(dir: string): CardFolder[];
21
+ /** The index: every card's sheet and schema, for agents and tools */
22
+ export declare function buildIndex(cards: CardFolder[]): string;
23
+ /** The bestiary: the same sheets, written for a reader choosing a card */
24
+ export declare function renderBestiary(cards: CardFolder[], title?: string): string;
25
+ /** Write the index and the bestiary from the card folders */
26
+ export declare function writeCardsIndex(dir: string, outputs: CardsOutputs): void;
27
+ /**
28
+ * What is wrong with the card folders, as sentences; empty when all is well.
29
+ * A card without a sheet or a schema, a sheet missing a field, an example
30
+ * that fails its own schema, an index or a bestiary out of date.
31
+ */
32
+ export declare function checkCards(dir: string, outputs?: CardsOutputs): string[];
@@ -0,0 +1,151 @@
1
+ /**
2
+ * The cards' tooling (#5339), for qdadm's cards and an app's own: read the
3
+ * card folders, write the index and the bestiary, and check them.
4
+ *
5
+ * A card is a folder: `meta.json` (its sheet), `schema.json` (the JSON
6
+ * Schema of its data) and its body (a .vue file).
7
+ *
8
+ * import { writeCardsIndex, checkCards } from '@quazardous/qdadm/cards/tools'
9
+ * writeCardsIndex('src/cards', { index: 'src/cards/cards-index.json', bestiary: 'docs/cards.md' })
10
+ * expect(checkCards('src/cards', { index: …, bestiary: … })).toEqual([])
11
+ *
12
+ * Node only: it reads and writes files.
13
+ */
14
+ import fs from 'node:fs';
15
+ import path from 'node:path';
16
+ import { validateCardData } from '../validate.js';
17
+ const SHEET_FIELDS = ['type', 'title', 'question', 'readings', 'strengths', 'avoid', 'sizes', 'options', 'action', 'example'];
18
+ function readJson(file) {
19
+ if (!fs.existsSync(file))
20
+ return null;
21
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
22
+ }
23
+ /** The card folders under `dir`, sorted by type */
24
+ export function readCards(dir) {
25
+ return fs
26
+ .readdirSync(dir, { withFileTypes: true })
27
+ .filter((e) => e.isDirectory())
28
+ .map((e) => {
29
+ const folder = path.join(dir, e.name);
30
+ const files = fs.readdirSync(folder);
31
+ return {
32
+ type: e.name,
33
+ dir: folder,
34
+ meta: readJson(path.join(folder, 'meta.json')),
35
+ schema: readJson(path.join(folder, 'schema.json')),
36
+ component: files.find((f) => f.endsWith('.vue')) ?? null,
37
+ };
38
+ })
39
+ .filter((c) => c.meta || c.schema || c.component)
40
+ .sort((a, b) => a.type.localeCompare(b.type));
41
+ }
42
+ /** The index: every card's sheet and schema, for agents and tools */
43
+ export function buildIndex(cards) {
44
+ const index = {
45
+ generatedBy: 'qdadm-cards index',
46
+ cards: cards.filter((c) => c.meta).map((c) => ({ ...c.meta, schema: c.schema })),
47
+ };
48
+ return JSON.stringify(index, null, 2) + '\n';
49
+ }
50
+ const list = (items) => (Array.isArray(items) ? items.map((i) => `- ${String(i)}`).join('\n') : '');
51
+ /** The bestiary: the same sheets, written for a reader choosing a card */
52
+ export function renderBestiary(cards, title = 'Cards') {
53
+ const out = [
54
+ '<!-- Generated by `qdadm-cards index` from each card\'s meta.json and schema.json: do not edit by hand. -->',
55
+ '',
56
+ `# ${title}`,
57
+ '',
58
+ 'Each card answers one question. Pick the card by its question, then give it data of the shape its schema says: the card draws it, the envelope is the same for all.',
59
+ '',
60
+ '## The envelope',
61
+ '',
62
+ '| Field | What it says |',
63
+ '|---|---|',
64
+ '| `title` | What the card counts |',
65
+ '| `status` | `critical`, `watch`, `good` or `info`: a side bar, a hue and a word |',
66
+ '| `source`, `freshness` | Where the data comes from, and when it was read |',
67
+ '| `to` | The surface: the whole card opens the domain\'s board |',
68
+ '| `action` | `{ verb, count, mode, to \\| run \\| onClick }`: the one gesture. `mode: next` opens the most urgent item, `list` the filtered list; `run` walks the items behind the card with the run bar |',
69
+ '| `state` | `ready`, or `loading`, `unreachable` (with `error`), `empty` (with `emptyText`): drawn instead of the body |',
70
+ '| `size` | `s`, `m` or `l`: 1, 2 or 3 columns, among the card\'s sizes |',
71
+ '',
72
+ 'Data that does not fit the schema draws the `invalid` state with the path and the reason; the rest of the board keeps working.',
73
+ '',
74
+ ];
75
+ for (const c of cards) {
76
+ const m = c.meta;
77
+ if (!m)
78
+ continue;
79
+ const options = (m.options ?? {});
80
+ const example = m.example;
81
+ const required = (c.schema?.required ?? []).map((r) => `\`${r}\``).join(', ');
82
+ out.push(`## \`${c.type}\`: ${String(m.question)}`, '', `**Readings**`, '', list(m.readings), '', `**Strengths**`, '', list(m.strengths), '', `**Avoid it**`, '', list(m.avoid), '', `**Sizes**: ${m.sizes?.join(', ') ?? 's'}. **Main action**: ${String(m.action)}`, '');
83
+ if (Object.keys(options).length) {
84
+ out.push('| Option | Type | Default | What it does |', '|---|---|---|---|');
85
+ for (const [name, o] of Object.entries(options)) {
86
+ const type = Array.isArray(o.enum) ? o.enum.map((v) => `\`${String(v)}\``).join(' \\| ') : String(o.type ?? '');
87
+ out.push(`| \`${name}\` | ${type} | ${o.default === undefined ? '' : `\`${JSON.stringify(o.default)}\``} | ${String(o.description ?? '')} |`);
88
+ }
89
+ out.push('');
90
+ }
91
+ out.push(`**Data**: required ${required || 'nothing'}; the full shape is in \`${c.type}/schema.json\`.`, '');
92
+ if (example) {
93
+ out.push('**Example**', '', '```json', JSON.stringify({ type: c.type, data: example.data, options: example.options ?? {} }, null, 2), '```', '');
94
+ }
95
+ }
96
+ return out.join('\n').replace(/\n{3,}/g, '\n\n');
97
+ }
98
+ /** Write the index and the bestiary from the card folders */
99
+ export function writeCardsIndex(dir, outputs) {
100
+ const cards = readCards(dir);
101
+ if (outputs.index)
102
+ fs.writeFileSync(outputs.index, buildIndex(cards));
103
+ if (outputs.bestiary)
104
+ fs.writeFileSync(outputs.bestiary, renderBestiary(cards, outputs.title));
105
+ }
106
+ /**
107
+ * What is wrong with the card folders, as sentences; empty when all is well.
108
+ * A card without a sheet or a schema, a sheet missing a field, an example
109
+ * that fails its own schema, an index or a bestiary out of date.
110
+ */
111
+ export function checkCards(dir, outputs = {}) {
112
+ const problems = [];
113
+ const cards = readCards(dir);
114
+ for (const c of cards) {
115
+ if (!c.meta) {
116
+ problems.push(`${c.type}: no meta.json (the card's sheet)`);
117
+ continue;
118
+ }
119
+ if (!c.schema)
120
+ problems.push(`${c.type}: no schema.json`);
121
+ if (!c.component)
122
+ problems.push(`${c.type}: no .vue body`);
123
+ for (const field of SHEET_FIELDS) {
124
+ if (c.meta[field] === undefined)
125
+ problems.push(`${c.type}: the sheet has no "${field}"`);
126
+ }
127
+ if (c.meta.type !== undefined && c.meta.type !== c.type)
128
+ problems.push(`${c.type}: the sheet says type "${String(c.meta.type)}"`);
129
+ const example = c.meta.example;
130
+ if (example && c.schema) {
131
+ for (const p of validateCardData(example.data, c.schema, 'example.data'))
132
+ problems.push(`${c.type}: ${p.path} ${p.message}`);
133
+ }
134
+ if (example?.options) {
135
+ const optionsSchema = { type: 'object', properties: (c.meta.options ?? {}), additionalProperties: false };
136
+ for (const p of validateCardData(example.options, optionsSchema, 'example.options'))
137
+ problems.push(`${c.type}: ${p.path} ${p.message}`);
138
+ }
139
+ }
140
+ const stale = (file, expected, what) => {
141
+ if (!fs.existsSync(file))
142
+ problems.push(`${what} ${file} is missing: run qdadm-cards index`);
143
+ else if (fs.readFileSync(file, 'utf8') !== expected)
144
+ problems.push(`${what} ${file} is out of date: run qdadm-cards index`);
145
+ };
146
+ if (outputs.index)
147
+ stale(outputs.index, buildIndex(cards), 'the index');
148
+ if (outputs.bestiary)
149
+ stale(outputs.bestiary, renderBestiary(cards, outputs.title), 'the bestiary');
150
+ return problems;
151
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * qdadm-cards (#5339): the index and the bestiary of a folder of cards.
4
+ *
5
+ * qdadm-cards index <dir> [--index <file>] [--bestiary <file>] [--title <text>]
6
+ * qdadm-cards check <dir> [--index <file>] [--bestiary <file>] [--title <text>]
7
+ *
8
+ * `check` exits 1 and lists what is wrong: a card without a sheet or a
9
+ * schema, an example that fails its schema, an index or a bestiary out of date.
10
+ */
11
+ import { writeCardsIndex, checkCards } from './cardsTool.js';
12
+ const [command, dir, ...rest] = process.argv.slice(2);
13
+ const outputs = {};
14
+ for (let i = 0; i < rest.length; i += 2) {
15
+ const value = rest[i + 1];
16
+ if (rest[i] === '--index')
17
+ outputs.index = value;
18
+ else if (rest[i] === '--bestiary')
19
+ outputs.bestiary = value;
20
+ else if (rest[i] === '--title')
21
+ outputs.title = value;
22
+ }
23
+ if (!dir || (command !== 'index' && command !== 'check')) {
24
+ console.error('usage: qdadm-cards index|check <dir> [--index <file>] [--bestiary <file>] [--title <text>]');
25
+ process.exit(2);
26
+ }
27
+ if (command === 'index') {
28
+ writeCardsIndex(dir, outputs);
29
+ console.log(`qdadm-cards: wrote ${[outputs.index, outputs.bestiary].filter(Boolean).join(' and ') || 'nothing (no --index nor --bestiary)'}`);
30
+ }
31
+ else {
32
+ const problems = checkCards(dir, outputs);
33
+ for (const p of problems)
34
+ console.error(`✗ ${p}`);
35
+ if (problems.length)
36
+ process.exit(1);
37
+ console.log('qdadm-cards: all cards check out');
38
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * A card's data against its JSON Schema (#5339): the subset cards need, with
3
+ * no dependency, so the browser and the node tooling share it.
4
+ *
5
+ * Supported: type (one or a list), enum, const, required, properties,
6
+ * additionalProperties (false or a schema), items, minItems, maxItems,
7
+ * minimum, maximum, minLength, maxLength, anyOf. Other keywords are ignored.
8
+ */
9
+ export interface CardSchema {
10
+ type?: string | string[];
11
+ enum?: unknown[];
12
+ const?: unknown;
13
+ required?: string[];
14
+ properties?: Record<string, CardSchema>;
15
+ additionalProperties?: boolean | CardSchema;
16
+ items?: CardSchema;
17
+ minItems?: number;
18
+ maxItems?: number;
19
+ minimum?: number;
20
+ maximum?: number;
21
+ minLength?: number;
22
+ maxLength?: number;
23
+ anyOf?: CardSchema[];
24
+ title?: string;
25
+ description?: string;
26
+ default?: unknown;
27
+ [key: string]: unknown;
28
+ }
29
+ export interface SchemaProblem {
30
+ /** Where, as `data.items[0].age` */
31
+ path: string;
32
+ message: string;
33
+ }
34
+ /** The problems of `value` against `schema`; empty when it fits */
35
+ export declare function validateCardData(value: unknown, schema: CardSchema, path?: string): SchemaProblem[];
@@ -0,0 +1,94 @@
1
+ /**
2
+ * A card's data against its JSON Schema (#5339): the subset cards need, with
3
+ * no dependency, so the browser and the node tooling share it.
4
+ *
5
+ * Supported: type (one or a list), enum, const, required, properties,
6
+ * additionalProperties (false or a schema), items, minItems, maxItems,
7
+ * minimum, maximum, minLength, maxLength, anyOf. Other keywords are ignored.
8
+ */
9
+ function typeOf(value) {
10
+ if (value === null)
11
+ return 'null';
12
+ if (Array.isArray(value))
13
+ return 'array';
14
+ if (typeof value === 'number')
15
+ return Number.isInteger(value) ? 'integer' : 'number';
16
+ return typeof value;
17
+ }
18
+ function matchesType(value, type) {
19
+ const actual = typeOf(value);
20
+ if (type === 'number')
21
+ return actual === 'number' || actual === 'integer';
22
+ return actual === type;
23
+ }
24
+ /** The problems of `value` against `schema`; empty when it fits */
25
+ export function validateCardData(value, schema, path = 'data') {
26
+ const problems = [];
27
+ check(value, schema, path, problems);
28
+ return problems;
29
+ }
30
+ function check(value, schema, path, out) {
31
+ if (!schema || typeof schema !== 'object')
32
+ return;
33
+ if (schema.anyOf) {
34
+ const fits = schema.anyOf.some((s) => validateCardData(value, s, path).length === 0);
35
+ if (!fits)
36
+ out.push({ path, message: 'matches none of the allowed shapes' });
37
+ return;
38
+ }
39
+ if (schema.type !== undefined) {
40
+ const types = Array.isArray(schema.type) ? schema.type : [schema.type];
41
+ if (!types.some((t) => matchesType(value, t))) {
42
+ out.push({ path, message: `expected ${types.join(' or ')}, got ${typeOf(value)}` });
43
+ return;
44
+ }
45
+ }
46
+ if ('const' in schema && value !== schema.const)
47
+ out.push({ path, message: `must be ${JSON.stringify(schema.const)}` });
48
+ if (schema.enum && !schema.enum.some((e) => e === value)) {
49
+ out.push({ path, message: `must be one of ${schema.enum.map((e) => JSON.stringify(e)).join(', ')}` });
50
+ }
51
+ if (typeof value === 'number') {
52
+ if (schema.minimum !== undefined && value < schema.minimum)
53
+ out.push({ path, message: `must be ≥ ${schema.minimum}` });
54
+ if (schema.maximum !== undefined && value > schema.maximum)
55
+ out.push({ path, message: `must be ≤ ${schema.maximum}` });
56
+ }
57
+ if (typeof value === 'string') {
58
+ if (schema.minLength !== undefined && value.length < schema.minLength)
59
+ out.push({ path, message: `must have at least ${schema.minLength} characters` });
60
+ if (schema.maxLength !== undefined && value.length > schema.maxLength)
61
+ out.push({ path, message: `must have at most ${schema.maxLength} characters` });
62
+ }
63
+ if (Array.isArray(value)) {
64
+ if (schema.minItems !== undefined && value.length < schema.minItems)
65
+ out.push({ path, message: `must have at least ${schema.minItems} items` });
66
+ if (schema.maxItems !== undefined && value.length > schema.maxItems)
67
+ out.push({ path, message: `must have at most ${schema.maxItems} items` });
68
+ if (schema.items)
69
+ value.forEach((item, i) => check(item, schema.items, `${path}[${i}]`, out));
70
+ return;
71
+ }
72
+ if (value && typeof value === 'object') {
73
+ const record = value;
74
+ for (const key of schema.required ?? []) {
75
+ if (record[key] === undefined)
76
+ out.push({ path: `${path}.${key}`, message: 'is required' });
77
+ }
78
+ const props = schema.properties ?? {};
79
+ for (const [key, sub] of Object.entries(props)) {
80
+ if (record[key] !== undefined)
81
+ check(record[key], sub, `${path}.${key}`, out);
82
+ }
83
+ if (schema.additionalProperties !== undefined && schema.additionalProperties !== true) {
84
+ for (const key of Object.keys(record)) {
85
+ if (key in props)
86
+ continue;
87
+ if (schema.additionalProperties === false)
88
+ out.push({ path: `${path}.${key}`, message: 'is not allowed' });
89
+ else
90
+ check(record[key], schema.additionalProperties, `${path}.${key}`, out);
91
+ }
92
+ }
93
+ }
94
+ }