@volvel/docs-engine 0.0.0-stage → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/THIRD_PARTY_NOTICES.md +23036 -0
- package/dist/among.d.ts +44 -0
- package/dist/among.js +128 -0
- package/dist/changelog.d.ts +54 -0
- package/dist/changelog.js +88 -0
- package/dist/diataxis.d.ts +52 -0
- package/dist/diataxis.js +155 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +14 -0
- package/dist/ops.d.ts +111 -0
- package/dist/ops.js +529 -0
- package/dist/output.d.ts +57 -0
- package/dist/output.js +56 -0
- package/dist/package.d.ts +34 -0
- package/dist/package.js +129 -0
- package/dist/page.d.ts +75 -0
- package/dist/page.js +189 -0
- package/dist/redirects.d.ts +27 -0
- package/dist/redirects.js +79 -0
- package/dist/schema.d.ts +210 -0
- package/dist/schema.js +238 -0
- package/dist/search-query.d.ts +103 -0
- package/dist/search-query.js +197 -0
- package/dist/search.d.ts +17 -0
- package/dist/search.js +98 -0
- package/dist/set.d.ts +198 -0
- package/dist/set.js +566 -0
- package/dist/stack.d.ts +45 -0
- package/dist/stack.js +73 -0
- package/dist/workspace.d.ts +122 -0
- package/dist/workspace.js +207 -0
- package/package.json +34 -3
- package/README.md +0 -3
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the top of a page may say, as JSON Schema, and a check of a value
|
|
3
|
+
* against it. The schema is the one the console, the control plane, the CLI
|
|
4
|
+
* and the public site all read. The check knows the few keywords the schema
|
|
5
|
+
* uses and says what is wrong in a sentence an author can act on.
|
|
6
|
+
*/
|
|
7
|
+
export interface Schema {
|
|
8
|
+
type?: "object" | "array" | "string" | "number" | "integer" | "boolean";
|
|
9
|
+
description?: string;
|
|
10
|
+
properties?: Record<string, Schema>;
|
|
11
|
+
required?: readonly string[];
|
|
12
|
+
additionalProperties?: false;
|
|
13
|
+
minProperties?: number;
|
|
14
|
+
maxProperties?: number;
|
|
15
|
+
items?: Schema;
|
|
16
|
+
maxItems?: number;
|
|
17
|
+
uniqueItems?: boolean;
|
|
18
|
+
enum?: readonly string[];
|
|
19
|
+
pattern?: string;
|
|
20
|
+
minLength?: number;
|
|
21
|
+
maxLength?: number;
|
|
22
|
+
}
|
|
23
|
+
/** A resource's path, as the platform writes one. */
|
|
24
|
+
export declare const PATH_PATTERN = "^[a-z0-9][a-z0-9_-]*(/[a-z0-9][a-z0-9_-]*)*$";
|
|
25
|
+
/** The kinds of resource a page can say it documents. */
|
|
26
|
+
export declare const ABOUT_KINDS: readonly ["table", "script", "flow", "app", "connection", "query"];
|
|
27
|
+
export type AboutKind = (typeof ABOUT_KINDS)[number];
|
|
28
|
+
export declare const FRONTMATTER_SCHEMA: {
|
|
29
|
+
readonly type: "object";
|
|
30
|
+
readonly description: "What the top of a page of documentation says about it.";
|
|
31
|
+
readonly properties: {
|
|
32
|
+
readonly title: {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
readonly description: "The page's title, as shown at its top, in navigation and in search.";
|
|
35
|
+
readonly minLength: 1;
|
|
36
|
+
readonly maxLength: 120;
|
|
37
|
+
};
|
|
38
|
+
readonly description: {
|
|
39
|
+
readonly type: "string";
|
|
40
|
+
readonly description: "One or two sentences on what the page is for. Shown in navigation, search and link previews.";
|
|
41
|
+
readonly maxLength: 500;
|
|
42
|
+
};
|
|
43
|
+
readonly pages: {
|
|
44
|
+
readonly type: "array";
|
|
45
|
+
readonly description: "For a folder's index page: the order of what is in the folder, by name. A page is named by its file name without .md, and a folder by its own name. What the list leaves out comes after it, by title.";
|
|
46
|
+
readonly items: {
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
readonly pattern: "^[a-z0-9][a-z0-9_-]*$";
|
|
49
|
+
readonly maxLength: 255;
|
|
50
|
+
};
|
|
51
|
+
readonly maxItems: 500;
|
|
52
|
+
};
|
|
53
|
+
readonly icon: {
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
readonly description: "For a folder's index page: the name of the icon shown beside the folder.";
|
|
56
|
+
readonly pattern: "^[a-z0-9][a-z0-9_-]*$";
|
|
57
|
+
readonly maxLength: 40;
|
|
58
|
+
};
|
|
59
|
+
readonly key: {
|
|
60
|
+
readonly type: "string";
|
|
61
|
+
readonly description: "The page's identity, when that is not its path. Say it only when you move a page, as the path it had, so that it stays the same page with its history.";
|
|
62
|
+
readonly pattern: "^[a-z0-9][a-z0-9_-]*(/[a-z0-9][a-z0-9_-]*)*$";
|
|
63
|
+
readonly maxLength: 255;
|
|
64
|
+
};
|
|
65
|
+
readonly topic: {
|
|
66
|
+
readonly type: "string";
|
|
67
|
+
readonly description: "A name for this page that stays the same when the page moves. Help, links and other pages can point at it.";
|
|
68
|
+
readonly pattern: "^[a-z0-9][a-z0-9_-]*$";
|
|
69
|
+
readonly maxLength: 80;
|
|
70
|
+
};
|
|
71
|
+
readonly terms: {
|
|
72
|
+
readonly type: "array";
|
|
73
|
+
readonly description: "Glossary terms this page defines. The page is where each one's definition leads.";
|
|
74
|
+
readonly maxItems: 50;
|
|
75
|
+
readonly items: {
|
|
76
|
+
readonly type: "object";
|
|
77
|
+
readonly properties: {
|
|
78
|
+
readonly id: {
|
|
79
|
+
readonly type: "string";
|
|
80
|
+
readonly description: "The term's name in links: `:term[RMA]{id=rma}`.";
|
|
81
|
+
readonly pattern: "^[a-z0-9][a-z0-9_-]*$";
|
|
82
|
+
readonly maxLength: 80;
|
|
83
|
+
};
|
|
84
|
+
readonly term: {
|
|
85
|
+
readonly type: "string";
|
|
86
|
+
readonly description: "The term as it is written in text.";
|
|
87
|
+
readonly minLength: 1;
|
|
88
|
+
readonly maxLength: 80;
|
|
89
|
+
};
|
|
90
|
+
readonly aliases: {
|
|
91
|
+
readonly type: "array";
|
|
92
|
+
readonly description: "Other ways the term is written.";
|
|
93
|
+
readonly maxItems: 10;
|
|
94
|
+
readonly uniqueItems: true;
|
|
95
|
+
readonly items: {
|
|
96
|
+
readonly type: "string";
|
|
97
|
+
readonly minLength: 1;
|
|
98
|
+
readonly maxLength: 80;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
readonly short: {
|
|
102
|
+
readonly type: "string";
|
|
103
|
+
readonly description: "What it means, in plain text.";
|
|
104
|
+
readonly minLength: 1;
|
|
105
|
+
readonly maxLength: 500;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
readonly required: readonly ["id", "term", "short"];
|
|
109
|
+
readonly additionalProperties: false;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
readonly about: {
|
|
113
|
+
readonly type: "array";
|
|
114
|
+
readonly description: "Resources this page documents. The page is listed where each of them is shown.";
|
|
115
|
+
readonly maxItems: 50;
|
|
116
|
+
readonly items: {
|
|
117
|
+
readonly type: "object";
|
|
118
|
+
readonly description: "One resource, by its kind and path.";
|
|
119
|
+
readonly properties: {
|
|
120
|
+
[k: string]: Schema;
|
|
121
|
+
};
|
|
122
|
+
readonly minProperties: 1;
|
|
123
|
+
readonly maxProperties: 1;
|
|
124
|
+
readonly additionalProperties: false;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
readonly extends: {
|
|
128
|
+
readonly type: "array";
|
|
129
|
+
readonly description: "Topics of the product's own help that this page adds your team's notes to.";
|
|
130
|
+
readonly maxItems: 20;
|
|
131
|
+
readonly uniqueItems: true;
|
|
132
|
+
readonly items: {
|
|
133
|
+
readonly type: "string";
|
|
134
|
+
readonly pattern: "^[a-z0-9][a-z0-9_-]*$";
|
|
135
|
+
readonly maxLength: 80;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
readonly type: {
|
|
139
|
+
readonly type: "string";
|
|
140
|
+
readonly description: "What kind of page this is, by what the reader is doing: tutorial (learning by doing), how-to (getting a task done), reference (looking a fact up) or explanation (understanding why). On a folder's index page it is the kind of every page under the folder, and the index itself has none. A page can say its own.";
|
|
141
|
+
readonly maxLength: 40;
|
|
142
|
+
};
|
|
143
|
+
readonly subjects: {
|
|
144
|
+
readonly type: "array";
|
|
145
|
+
readonly description: "What this page is about, as short names the same in every page that is about it. Pages of other types with a subject in common are shown as related. Five at most are used.";
|
|
146
|
+
readonly maxItems: 20;
|
|
147
|
+
readonly uniqueItems: true;
|
|
148
|
+
readonly items: {
|
|
149
|
+
readonly type: "string";
|
|
150
|
+
readonly pattern: "^[a-z0-9][a-z0-9_-]*$";
|
|
151
|
+
readonly maxLength: 80;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
readonly moved_from: {
|
|
155
|
+
readonly type: "array";
|
|
156
|
+
readonly description: "The paths this page had before it moved. A reader who follows an old address is taken here.";
|
|
157
|
+
readonly maxItems: 20;
|
|
158
|
+
readonly uniqueItems: true;
|
|
159
|
+
readonly items: Schema;
|
|
160
|
+
};
|
|
161
|
+
readonly date: {
|
|
162
|
+
readonly type: "string";
|
|
163
|
+
readonly description: "For a changelog entry: the day it is about, as YYYY-MM-DD. Without it the entry takes a date that begins or ends its file name, else the day the page last changed.";
|
|
164
|
+
readonly pattern: "^\\d{4}-\\d{2}-\\d{2}$";
|
|
165
|
+
readonly maxLength: 10;
|
|
166
|
+
};
|
|
167
|
+
readonly since: {
|
|
168
|
+
readonly type: "string";
|
|
169
|
+
readonly description: "For the product's own pages: the version that brought what the page describes.";
|
|
170
|
+
readonly pattern: "^\\d+\\.\\d+(\\.\\d+)?$";
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
readonly required: readonly ["title"];
|
|
174
|
+
readonly additionalProperties: false;
|
|
175
|
+
};
|
|
176
|
+
export interface TermDefinition {
|
|
177
|
+
id: string;
|
|
178
|
+
term: string;
|
|
179
|
+
aliases?: string[];
|
|
180
|
+
short: string;
|
|
181
|
+
}
|
|
182
|
+
export type About = {
|
|
183
|
+
[Kind in AboutKind]?: string;
|
|
184
|
+
};
|
|
185
|
+
export interface Frontmatter {
|
|
186
|
+
title: string;
|
|
187
|
+
key?: string;
|
|
188
|
+
description?: string;
|
|
189
|
+
pages?: string[];
|
|
190
|
+
icon?: string;
|
|
191
|
+
topic?: string;
|
|
192
|
+
terms?: TermDefinition[];
|
|
193
|
+
about?: About[];
|
|
194
|
+
extends?: string[];
|
|
195
|
+
type?: string;
|
|
196
|
+
subjects?: string[];
|
|
197
|
+
moved_from?: string[];
|
|
198
|
+
since?: string;
|
|
199
|
+
date?: string;
|
|
200
|
+
}
|
|
201
|
+
export interface SchemaProblem {
|
|
202
|
+
/** Where in the value, as it would be written: `terms[1].short`. Empty for the value itself. */
|
|
203
|
+
at: string;
|
|
204
|
+
/** The last name in `at`, to find the line by. */
|
|
205
|
+
key?: string;
|
|
206
|
+
message: string;
|
|
207
|
+
}
|
|
208
|
+
/** Checks a value against a schema. An empty list means it fits. */
|
|
209
|
+
export declare function check(value: unknown, schema: Schema, at?: string, key?: string): SchemaProblem[];
|
|
210
|
+
//# sourceMappingURL=schema.d.ts.map
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the top of a page may say, as JSON Schema, and a check of a value
|
|
3
|
+
* against it. The schema is the one the console, the control plane, the CLI
|
|
4
|
+
* and the public site all read. The check knows the few keywords the schema
|
|
5
|
+
* uses and says what is wrong in a sentence an author can act on.
|
|
6
|
+
*/
|
|
7
|
+
/** A resource's path, as the platform writes one. */
|
|
8
|
+
export const PATH_PATTERN = "^[a-z0-9][a-z0-9_-]*(/[a-z0-9][a-z0-9_-]*)*$";
|
|
9
|
+
const ID_PATTERN = "^[a-z0-9][a-z0-9_-]*$";
|
|
10
|
+
/** The kinds of resource a page can say it documents. */
|
|
11
|
+
export const ABOUT_KINDS = ["table", "script", "flow", "app", "connection", "query"];
|
|
12
|
+
const path = (description) => ({
|
|
13
|
+
type: "string",
|
|
14
|
+
description,
|
|
15
|
+
pattern: PATH_PATTERN,
|
|
16
|
+
maxLength: 255,
|
|
17
|
+
});
|
|
18
|
+
export const FRONTMATTER_SCHEMA = {
|
|
19
|
+
type: "object",
|
|
20
|
+
description: "What the top of a page of documentation says about it.",
|
|
21
|
+
properties: {
|
|
22
|
+
title: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "The page's title, as shown at its top, in navigation and in search.",
|
|
25
|
+
minLength: 1,
|
|
26
|
+
maxLength: 120,
|
|
27
|
+
},
|
|
28
|
+
description: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "One or two sentences on what the page is for. Shown in navigation, search and link previews.",
|
|
31
|
+
maxLength: 500,
|
|
32
|
+
},
|
|
33
|
+
pages: {
|
|
34
|
+
type: "array",
|
|
35
|
+
description: "For a folder's index page: the order of what is in the folder, by name. A page is named by its file name without .md, and a folder by its own name. What the list leaves out comes after it, by title.",
|
|
36
|
+
items: { type: "string", pattern: "^[a-z0-9][a-z0-9_-]*$", maxLength: 255 },
|
|
37
|
+
maxItems: 500,
|
|
38
|
+
},
|
|
39
|
+
icon: {
|
|
40
|
+
type: "string",
|
|
41
|
+
description: "For a folder's index page: the name of the icon shown beside the folder.",
|
|
42
|
+
pattern: ID_PATTERN,
|
|
43
|
+
maxLength: 40,
|
|
44
|
+
},
|
|
45
|
+
key: {
|
|
46
|
+
type: "string",
|
|
47
|
+
description: "The page's identity, when that is not its path. Say it only when you move a page, as the path it had, so that it stays the same page with its history.",
|
|
48
|
+
pattern: PATH_PATTERN,
|
|
49
|
+
maxLength: 255,
|
|
50
|
+
},
|
|
51
|
+
topic: {
|
|
52
|
+
type: "string",
|
|
53
|
+
description: "A name for this page that stays the same when the page moves. Help, links and other pages can point at it.",
|
|
54
|
+
pattern: ID_PATTERN,
|
|
55
|
+
maxLength: 80,
|
|
56
|
+
},
|
|
57
|
+
terms: {
|
|
58
|
+
type: "array",
|
|
59
|
+
description: "Glossary terms this page defines. The page is where each one's definition leads.",
|
|
60
|
+
maxItems: 50,
|
|
61
|
+
items: {
|
|
62
|
+
type: "object",
|
|
63
|
+
properties: {
|
|
64
|
+
id: {
|
|
65
|
+
type: "string",
|
|
66
|
+
description: "The term's name in links: `:term[RMA]{id=rma}`.",
|
|
67
|
+
pattern: ID_PATTERN,
|
|
68
|
+
maxLength: 80,
|
|
69
|
+
},
|
|
70
|
+
term: {
|
|
71
|
+
type: "string",
|
|
72
|
+
description: "The term as it is written in text.",
|
|
73
|
+
minLength: 1,
|
|
74
|
+
maxLength: 80,
|
|
75
|
+
},
|
|
76
|
+
aliases: {
|
|
77
|
+
type: "array",
|
|
78
|
+
description: "Other ways the term is written.",
|
|
79
|
+
maxItems: 10,
|
|
80
|
+
uniqueItems: true,
|
|
81
|
+
items: { type: "string", minLength: 1, maxLength: 80 },
|
|
82
|
+
},
|
|
83
|
+
short: {
|
|
84
|
+
type: "string",
|
|
85
|
+
description: "What it means, in plain text.",
|
|
86
|
+
minLength: 1,
|
|
87
|
+
maxLength: 500,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
required: ["id", "term", "short"],
|
|
91
|
+
additionalProperties: false,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
about: {
|
|
95
|
+
type: "array",
|
|
96
|
+
description: "Resources this page documents. The page is listed where each of them is shown.",
|
|
97
|
+
maxItems: 50,
|
|
98
|
+
items: {
|
|
99
|
+
type: "object",
|
|
100
|
+
description: "One resource, by its kind and path.",
|
|
101
|
+
properties: Object.fromEntries(ABOUT_KINDS.map((kind) => [kind, path(`A ${kind}, by its path.`)])),
|
|
102
|
+
minProperties: 1,
|
|
103
|
+
maxProperties: 1,
|
|
104
|
+
additionalProperties: false,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
extends: {
|
|
108
|
+
type: "array",
|
|
109
|
+
description: "Topics of the product's own help that this page adds your team's notes to.",
|
|
110
|
+
maxItems: 20,
|
|
111
|
+
uniqueItems: true,
|
|
112
|
+
items: { type: "string", pattern: ID_PATTERN, maxLength: 80 },
|
|
113
|
+
},
|
|
114
|
+
type: {
|
|
115
|
+
type: "string",
|
|
116
|
+
description: "What kind of page this is, by what the reader is doing: tutorial (learning by doing), how-to (getting a task done), reference (looking a fact up) or explanation (understanding why). On a folder's index page it is the kind of every page under the folder, and the index itself has none. A page can say its own.",
|
|
117
|
+
maxLength: 40,
|
|
118
|
+
},
|
|
119
|
+
subjects: {
|
|
120
|
+
type: "array",
|
|
121
|
+
description: "What this page is about, as short names the same in every page that is about it. Pages of other types with a subject in common are shown as related. Five at most are used.",
|
|
122
|
+
maxItems: 20,
|
|
123
|
+
uniqueItems: true,
|
|
124
|
+
items: { type: "string", pattern: ID_PATTERN, maxLength: 80 },
|
|
125
|
+
},
|
|
126
|
+
moved_from: {
|
|
127
|
+
type: "array",
|
|
128
|
+
description: "The paths this page had before it moved. A reader who follows an old address is taken here.",
|
|
129
|
+
maxItems: 20,
|
|
130
|
+
uniqueItems: true,
|
|
131
|
+
items: path("A path the page had, without .md."),
|
|
132
|
+
},
|
|
133
|
+
date: {
|
|
134
|
+
type: "string",
|
|
135
|
+
description: "For a changelog entry: the day it is about, as YYYY-MM-DD. Without it the entry takes a date that begins or ends its file name, else the day the page last changed.",
|
|
136
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$",
|
|
137
|
+
maxLength: 10,
|
|
138
|
+
},
|
|
139
|
+
since: {
|
|
140
|
+
type: "string",
|
|
141
|
+
description: "For the product's own pages: the version that brought what the page describes.",
|
|
142
|
+
pattern: "^\\d+\\.\\d+(\\.\\d+)?$",
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
required: ["title"],
|
|
146
|
+
additionalProperties: false,
|
|
147
|
+
};
|
|
148
|
+
const KIND = {
|
|
149
|
+
object: "a set of named values",
|
|
150
|
+
array: "a list",
|
|
151
|
+
string: "text",
|
|
152
|
+
number: "a number",
|
|
153
|
+
integer: "a whole number",
|
|
154
|
+
boolean: "true or false",
|
|
155
|
+
};
|
|
156
|
+
function isA(value, type) {
|
|
157
|
+
switch (type) {
|
|
158
|
+
case "object":
|
|
159
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
160
|
+
case "array":
|
|
161
|
+
return Array.isArray(value);
|
|
162
|
+
case "integer":
|
|
163
|
+
return typeof value === "number" && Number.isInteger(value);
|
|
164
|
+
case "number":
|
|
165
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
166
|
+
default:
|
|
167
|
+
return typeof value === type;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/** Checks a value against a schema. An empty list means it fits. */
|
|
171
|
+
export function check(value, schema, at = "", key) {
|
|
172
|
+
const name = at === "" ? "This" : at;
|
|
173
|
+
const problem = (message) => key === undefined ? { at, message } : { at, key, message };
|
|
174
|
+
if (schema.type && !isA(value, schema.type)) {
|
|
175
|
+
return [problem(`${name} is ${KIND[schema.type]}.`)];
|
|
176
|
+
}
|
|
177
|
+
const out = [];
|
|
178
|
+
if (typeof value === "string") {
|
|
179
|
+
if (schema.minLength !== undefined && value.length < schema.minLength) {
|
|
180
|
+
out.push(problem(`${name} is empty.`));
|
|
181
|
+
}
|
|
182
|
+
if (schema.maxLength !== undefined && value.length > schema.maxLength) {
|
|
183
|
+
out.push(problem(`${name} is ${value.length} characters. It can be ${schema.maxLength} at most.`));
|
|
184
|
+
}
|
|
185
|
+
if (schema.pattern && !new RegExp(schema.pattern).test(value)) {
|
|
186
|
+
out.push(problem(schema.pattern === PATH_PATTERN || schema.pattern === ID_PATTERN
|
|
187
|
+
? `${name} is written in lowercase letters, digits, hyphens and underscores${schema.pattern === PATH_PATTERN ? ", in folders" : ""}. It is "${value}".`
|
|
188
|
+
: `${name} is not written as it should be: "${value}".`));
|
|
189
|
+
}
|
|
190
|
+
if (schema.enum && !schema.enum.includes(value)) {
|
|
191
|
+
out.push(problem(`${name} is one of ${schema.enum.join(", ")}. It is "${value}".`));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (Array.isArray(value)) {
|
|
195
|
+
if (schema.maxItems !== undefined && value.length > schema.maxItems) {
|
|
196
|
+
out.push(problem(`${name} has ${value.length} entries. It can have ${schema.maxItems} at most.`));
|
|
197
|
+
}
|
|
198
|
+
if (schema.uniqueItems &&
|
|
199
|
+
new Set(value.map((one) => JSON.stringify(one))).size !== value.length) {
|
|
200
|
+
out.push(problem(`${name} says the same thing twice.`));
|
|
201
|
+
}
|
|
202
|
+
if (schema.items) {
|
|
203
|
+
value.forEach((one, index) => {
|
|
204
|
+
out.push(...check(one, schema.items, `${at}[${index}]`, key));
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (isA(value, "object")) {
|
|
209
|
+
const record = value;
|
|
210
|
+
const names = Object.keys(record);
|
|
211
|
+
const known = Object.keys(schema.properties ?? {});
|
|
212
|
+
for (const one of names) {
|
|
213
|
+
const inner = schema.properties?.[one];
|
|
214
|
+
const where = at === "" ? one : `${at}.${one}`;
|
|
215
|
+
if (inner)
|
|
216
|
+
out.push(...check(record[one], inner, where, one));
|
|
217
|
+
else if (schema.additionalProperties === false) {
|
|
218
|
+
out.push({
|
|
219
|
+
at: where,
|
|
220
|
+
key: one,
|
|
221
|
+
message: `There is no "${one}" ${at === "" ? "here" : `in ${at}`}. It can have: ${known.join(", ")}.`,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
for (const one of schema.required ?? []) {
|
|
226
|
+
if (record[one] === undefined)
|
|
227
|
+
out.push(problem(`${at === "" ? "It" : at} needs ${at === "" ? `a ${one}` : one}.`));
|
|
228
|
+
}
|
|
229
|
+
if (schema.minProperties !== undefined && names.length < schema.minProperties) {
|
|
230
|
+
out.push(problem(`${name} names nothing. It names one of: ${known.join(", ")}.`));
|
|
231
|
+
}
|
|
232
|
+
if (schema.maxProperties !== undefined && names.length > schema.maxProperties) {
|
|
233
|
+
out.push(problem(`${name} names ${names.length} things (${names.join(", ")}). It names one.`));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return out;
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A page as search knows it, and each part of it under a heading. A page is
|
|
3
|
+
* found by its title, its description and all its words. A part is found by
|
|
4
|
+
* its heading and its words, so that a search can lead to the very section.
|
|
5
|
+
*/
|
|
6
|
+
export interface Indexed {
|
|
7
|
+
id: string;
|
|
8
|
+
kind: "page" | "section";
|
|
9
|
+
/** The page's path. */
|
|
10
|
+
path: string;
|
|
11
|
+
url: string;
|
|
12
|
+
title: string;
|
|
13
|
+
description: string;
|
|
14
|
+
/** The page's top-level folder: what search can be narrowed to. Empty for a page in none. */
|
|
15
|
+
collection: string;
|
|
16
|
+
/** The page's type, stored and never searched. Empty for a page with none. */
|
|
17
|
+
docType: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the page was made by a generator and not written: "1" or "0". Absent in a set
|
|
20
|
+
* that did not say, and in an index built before it was kept.
|
|
21
|
+
*/
|
|
22
|
+
generated?: string;
|
|
23
|
+
headings: string;
|
|
24
|
+
/** For a section: its heading, and what a link to it ends in. */
|
|
25
|
+
heading: string;
|
|
26
|
+
anchor: string;
|
|
27
|
+
/** What is searched: a page's words before its first heading, a section's words. Not stored. */
|
|
28
|
+
text: string;
|
|
29
|
+
/**
|
|
30
|
+
* What is kept to draw a result from: the first words of `text`, clipped.
|
|
31
|
+
* An index built before this one kept `text` and `intro` whole.
|
|
32
|
+
*/
|
|
33
|
+
passage: string;
|
|
34
|
+
}
|
|
35
|
+
/** Whether a page is reference, which a search shows after pages that explain, unless it is asked for by name. */
|
|
36
|
+
export declare function isReference(path: string, type: unknown): boolean;
|
|
37
|
+
export interface SearchHit {
|
|
38
|
+
path: string;
|
|
39
|
+
url: string;
|
|
40
|
+
title: string;
|
|
41
|
+
description: string;
|
|
42
|
+
/** A few words of the page around what was asked for. */
|
|
43
|
+
excerpt: string;
|
|
44
|
+
}
|
|
45
|
+
/** Words, with the ones that were asked for marked. */
|
|
46
|
+
export type Marked = {
|
|
47
|
+
text: string;
|
|
48
|
+
hit?: true;
|
|
49
|
+
}[];
|
|
50
|
+
/** One place on a page where what was asked for is. */
|
|
51
|
+
export interface PlaceHit {
|
|
52
|
+
/** `heading` when the heading itself matched, `text` when the words under it did. */
|
|
53
|
+
type: "heading" | "text";
|
|
54
|
+
/** Where it is: the page's address, with `#anchor` for a section. */
|
|
55
|
+
url: string;
|
|
56
|
+
words: Marked;
|
|
57
|
+
}
|
|
58
|
+
/** A page that was found, and the places on it. */
|
|
59
|
+
export interface PageHit {
|
|
60
|
+
path: string;
|
|
61
|
+
url: string;
|
|
62
|
+
title: Marked;
|
|
63
|
+
description: string;
|
|
64
|
+
collection: string;
|
|
65
|
+
/** The page's type, when it has one. */
|
|
66
|
+
docType?: string;
|
|
67
|
+
/** How well it matched, of the index that found it: to put the answers of several indexes in order. */
|
|
68
|
+
score: number;
|
|
69
|
+
places: PlaceHit[];
|
|
70
|
+
}
|
|
71
|
+
/** How many pages a search shows when it is not told: the server and the help panel answer alike. */
|
|
72
|
+
export declare const RESULT_LIMIT = 12;
|
|
73
|
+
export declare const OPTIONS: {
|
|
74
|
+
fields: string[];
|
|
75
|
+
storeFields: string[];
|
|
76
|
+
searchOptions: {
|
|
77
|
+
boost: {
|
|
78
|
+
title: number;
|
|
79
|
+
heading: number;
|
|
80
|
+
headings: number;
|
|
81
|
+
description: number;
|
|
82
|
+
};
|
|
83
|
+
prefix: boolean;
|
|
84
|
+
fuzzy: number;
|
|
85
|
+
combineWith: "AND";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
/** Marks every word of a text that begins with a term asked for. */
|
|
89
|
+
export declare function mark(text: string, terms: readonly string[]): Marked;
|
|
90
|
+
/** Reads an index back, to ask it questions. */
|
|
91
|
+
export declare function loadSearchIndex(json: string): {
|
|
92
|
+
/** Pages, best first: for a page of results. */
|
|
93
|
+
search(query: string, limit?: number, options?: {
|
|
94
|
+
type?: string;
|
|
95
|
+
}): SearchHit[];
|
|
96
|
+
/** Pages, best first, each with the places on it: for results as they are typed. */
|
|
97
|
+
grouped(query: string, options?: {
|
|
98
|
+
collection?: string;
|
|
99
|
+
type?: string;
|
|
100
|
+
limit?: number;
|
|
101
|
+
}): PageHit[];
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=search-query.d.ts.map
|