@adminiumjs/add-on-contracts 0.3.39 → 0.3.40
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/add-on-block.d.ts +9 -2
- package/dist/add-on-block.d.ts.map +1 -1
- package/dist/add-on-block.js +18 -2
- package/dist/add-on-block.js.map +1 -1
- package/dist/forms/check.d.ts +82 -0
- package/dist/forms/check.d.ts.map +1 -0
- package/dist/forms/check.js +298 -0
- package/dist/forms/check.js.map +1 -0
- package/dist/forms/definition.d.ts +1462 -0
- package/dist/forms/definition.d.ts.map +1 -0
- package/dist/forms/definition.js +451 -0
- package/dist/forms/definition.js.map +1 -0
- package/dist/forms/index.d.ts +17 -0
- package/dist/forms/index.d.ts.map +1 -0
- package/dist/forms/index.js +18 -0
- package/dist/forms/index.js.map +1 -0
- package/dist/forms/parse.d.ts +30 -0
- package/dist/forms/parse.d.ts.map +1 -0
- package/dist/forms/parse.js +93 -0
- package/dist/forms/parse.js.map +1 -0
- package/dist/forms/scales.d.ts +25 -0
- package/dist/forms/scales.d.ts.map +1 -0
- package/dist/forms/scales.js +9 -0
- package/dist/forms/scales.js.map +1 -0
- package/dist/forms/settings.d.ts +77 -0
- package/dist/forms/settings.d.ts.map +1 -0
- package/dist/forms/settings.js +68 -0
- package/dist/forms/settings.js.map +1 -0
- package/dist/forms/summary.d.ts +60 -0
- package/dist/forms/summary.d.ts.map +1 -0
- package/dist/forms/summary.js +91 -0
- package/dist/forms/summary.js.map +1 -0
- package/dist/forms/websites.d.ts +54 -0
- package/dist/forms/websites.d.ts.map +1 -0
- package/dist/forms/websites.js +97 -0
- package/dist/forms/websites.js.map +1 -0
- package/dist/forms/words.d.ts +49 -0
- package/dist/forms/words.d.ts.map +1 -0
- package/dist/forms/words.js +31 -0
- package/dist/forms/words.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/data-types.d.ts +47 -0
- package/dist/runtime/data-types.d.ts.map +1 -1
- package/dist/runtime/data.d.ts +2 -0
- package/dist/runtime/data.d.ts.map +1 -1
- package/dist/runtime/data.js +2 -0
- package/dist/runtime/data.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/index.js.map +1 -1
- package/package.json +13 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/forms/definition.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC;AAEpC,qFAAqF;AACrF,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,6DAA6D;AAC7D,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,gDAAgD;AAChD,eAAO,MAAM,mBAAmB,4GAA6G,CAAC;AAC9I,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,mFAAmF;AACnF,eAAO,MAAM,aAAa,yDAAgG,CAAC;AAE3H;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,oCAAqC,CAAC;AACrE,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,qFAAqF;AACrF,eAAO,MAAM,eAAe,wCAAyC,CAAC;AACtE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,C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;;;;;;;;;;;;;;;4BAG3B,CAAC;AA4LH;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAE/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
/**
|
|
3
|
+
* A FORM'S DEFINITION: what the forms add-on's builder writes and the engine
|
|
4
|
+
* draws, checks and stores answers against.
|
|
5
|
+
*
|
|
6
|
+
* The engine reads every form for a stranger (no add-on code runs for one),
|
|
7
|
+
* so this one schema is the whole of what a form may say: the eleven question
|
|
8
|
+
* kinds and their own checks, "show if" on an earlier answer, sections, a
|
|
9
|
+
* version of every text per language, the agreement tick with its wording's
|
|
10
|
+
* version, the hidden source field, and the ending. The builder previews with
|
|
11
|
+
* it and the engine parses with it at publish and at every draw, so the two
|
|
12
|
+
* can never disagree.
|
|
13
|
+
*
|
|
14
|
+
* A refusal is a CODE at a path, never a sentence: the dashboard and the
|
|
15
|
+
* stranger's page word it in the reader's language. The codes this file adds
|
|
16
|
+
* are in {@link FORM_DEFINITION_CODES}; the rest are Zod's own
|
|
17
|
+
* (`invalid_type`, `too_big`, …).
|
|
18
|
+
*
|
|
19
|
+
* Pure: no I/O.
|
|
20
|
+
*/
|
|
21
|
+
import { z } from 'zod';
|
|
22
|
+
import { FORM_FILES_MAX, SCALE_OF } from './scales.js';
|
|
23
|
+
import { FORM_LANGUAGES, FORM_WORDS_MAX, formLanguageSchema, wordsSchema } from './words.js';
|
|
24
|
+
export { FORM_FILES_MAX, SCALE_OF };
|
|
25
|
+
/** The version of this vocabulary. A form says which one it was written in (`v`). */
|
|
26
|
+
export const FORMS_VOCABULARY_VERSION = 1;
|
|
27
|
+
/** The most questions, sections and choices a form holds. */
|
|
28
|
+
export const FORM_QUESTIONS_MAX = 60;
|
|
29
|
+
export const FORM_SECTIONS_MAX = 12;
|
|
30
|
+
export const FORM_CHOICES_MIN = 2;
|
|
31
|
+
export const FORM_CHOICES_MAX = 30;
|
|
32
|
+
/** The eleven kinds of question (comp E4.3). */
|
|
33
|
+
export const FORM_QUESTION_KINDS = ['short', 'long', 'one', 'several', 'date', 'number', 'score', 'stars', 'file', 'tick', 'hidden'];
|
|
34
|
+
/** The kinds a "show if" may name: the ones whose answer is a pick or a number. */
|
|
35
|
+
export const SHOW_IF_KINDS = ['one', 'several', 'score', 'stars', 'number'];
|
|
36
|
+
/**
|
|
37
|
+
* The two purposes a tick may give consent for. A closed list on purpose: the
|
|
38
|
+
* unsubscribe page, the audience and the stop list know these two and no
|
|
39
|
+
* others (the manifest's `CONSENT_PURPOSES` is the same list).
|
|
40
|
+
*/
|
|
41
|
+
export const FORM_TICK_PURPOSES = ['newsletter', 'surveys'];
|
|
42
|
+
/** The kinds of file a file question may take: pictures, PDF and plain text only. */
|
|
43
|
+
export const FORM_FILE_KINDS = ['pdf', 'jpg', 'png', 'text'];
|
|
44
|
+
/** Codes this file refuses a definition with, beside Zod's own. */
|
|
45
|
+
export const FORM_DEFINITION_CODES = [
|
|
46
|
+
/** Two questions, sections, choices of one question or hidden fields share an id (or a parameter). */
|
|
47
|
+
'id-duplicate',
|
|
48
|
+
'languages-duplicate',
|
|
49
|
+
/** The default language is not one the form lists. */
|
|
50
|
+
'default-language',
|
|
51
|
+
/** A listed language has no version of this text (the path ends in the language). */
|
|
52
|
+
'words-missing',
|
|
53
|
+
/** A text has a version in a language the form does not list. */
|
|
54
|
+
'words-unlisted',
|
|
55
|
+
'section-unknown',
|
|
56
|
+
/** Questions without a section come first, then each section's in the sections' order. */
|
|
57
|
+
'section-order',
|
|
58
|
+
/** A "show if" names no question of the form. */
|
|
59
|
+
'show-if-unknown',
|
|
60
|
+
/** A "show if" names its own question or a later one. */
|
|
61
|
+
'show-if-forward',
|
|
62
|
+
/** A "show if" names a question whose kind it cannot test. */
|
|
63
|
+
'show-if-kind',
|
|
64
|
+
/** A "show if" gives no test, more than one, or one its question's kind does not take. */
|
|
65
|
+
'show-if-test',
|
|
66
|
+
/** A "show if" names a choice its question does not have. */
|
|
67
|
+
'show-if-choice',
|
|
68
|
+
/** A "show if" names a number its question can never hold. */
|
|
69
|
+
'show-if-range',
|
|
70
|
+
/** A hidden field is never shown, so it has no "show if". */
|
|
71
|
+
'hidden-show-if',
|
|
72
|
+
/** A hidden field is filled from the page's address, so nobody can be asked for it. */
|
|
73
|
+
'hidden-required',
|
|
74
|
+
/** An agreement is given freely: a tick is never required. */
|
|
75
|
+
'tick-required',
|
|
76
|
+
/** Two ticks give consent for one purpose. */
|
|
77
|
+
'tick-purpose-twice',
|
|
78
|
+
/**
|
|
79
|
+
* A tick that waits for the click in a confirmation mail, on a form that
|
|
80
|
+
* asks for no e-mail address (a short answer that checks for one): the
|
|
81
|
+
* mail has nowhere to go, so the yes could never be proved.
|
|
82
|
+
*/
|
|
83
|
+
'tick-confirm-email',
|
|
84
|
+
/** `recommend` marks a survey's score; a form has none. */
|
|
85
|
+
'recommend-on-form',
|
|
86
|
+
'recommend-twice',
|
|
87
|
+
/** Surveys take no files. */
|
|
88
|
+
'survey-file',
|
|
89
|
+
/** Surveys sign nobody up. */
|
|
90
|
+
'survey-tick',
|
|
91
|
+
/** A several-choice question's least and most picks do not fit its choices. */
|
|
92
|
+
'several-picks',
|
|
93
|
+
/** A number question's least is above its most. */
|
|
94
|
+
'number-bounds',
|
|
95
|
+
'file-kinds-duplicate',
|
|
96
|
+
/** A question marked as the e-mail address checks for one. */
|
|
97
|
+
'role-email-check',
|
|
98
|
+
/** The page an ending sends to is not an https address. */
|
|
99
|
+
'ending-https',
|
|
100
|
+
];
|
|
101
|
+
export const questionIdSchema = z.string().regex(/^q[a-z0-9]{1,15}$/, 'a question id is q and 1 to 15 lower-case letters or digits');
|
|
102
|
+
export const sectionIdSchema = z.string().regex(/^s[a-z0-9]{1,15}$/, 'a section id is s and 1 to 15 lower-case letters or digits');
|
|
103
|
+
/** A choice's id: what an answer stores, so a column a form fills may take it as it is. */
|
|
104
|
+
export const choiceIdSchema = z.string().regex(/^[a-z0-9][a-z0-9_-]{0,39}$/, 'a choice id is 1 to 40 lower-case letters, digits, _ or -');
|
|
105
|
+
/** The one test a "show if" makes of an earlier answer. */
|
|
106
|
+
export const showIfSchema = z
|
|
107
|
+
.object({
|
|
108
|
+
question: questionIdSchema,
|
|
109
|
+
/** A pick of a one-choice question, or a score, a star count or a number. */
|
|
110
|
+
is: z.union([choiceIdSchema, z.number()]).optional(),
|
|
111
|
+
/** A several-choice question's picks include this choice. */
|
|
112
|
+
includes: choiceIdSchema.optional(),
|
|
113
|
+
atLeast: z.number().optional(),
|
|
114
|
+
atMost: z.number().optional(),
|
|
115
|
+
})
|
|
116
|
+
.strict();
|
|
117
|
+
export const choiceSchema = z.object({ id: choiceIdSchema, label: wordsSchema(FORM_WORDS_MAX.choice) }).strict();
|
|
118
|
+
/** What every question has. */
|
|
119
|
+
const base = {
|
|
120
|
+
id: questionIdSchema,
|
|
121
|
+
label: wordsSchema(FORM_WORDS_MAX.label),
|
|
122
|
+
help: wordsSchema(FORM_WORDS_MAX.help).optional(),
|
|
123
|
+
required: z.boolean().default(false),
|
|
124
|
+
/** The section it sits in; absent, it sits before the first. */
|
|
125
|
+
section: sectionIdSchema.optional(),
|
|
126
|
+
showIf: showIfSchema.optional(),
|
|
127
|
+
};
|
|
128
|
+
/** A bound a number question may say: a sensible magnitude, so a stored answer fits any number column. */
|
|
129
|
+
const NUMBER_MAGNITUDE = 1e12;
|
|
130
|
+
const bound = z.number().min(-NUMBER_MAGNITUDE).max(NUMBER_MAGNITUDE);
|
|
131
|
+
export const shortQuestionSchema = z
|
|
132
|
+
.object({
|
|
133
|
+
...base,
|
|
134
|
+
kind: z.literal('short'),
|
|
135
|
+
/** The answer must be an e-mail address, or a phone number. */
|
|
136
|
+
check: z.enum(['email', 'phone']).optional(),
|
|
137
|
+
maxLength: z.number().int().min(1).max(500).default(200),
|
|
138
|
+
/** What the answer is of the person: the engine keeps the name and the e-mail address on the answer itself. */
|
|
139
|
+
role: z.enum(['name', 'email', 'company']).optional(),
|
|
140
|
+
})
|
|
141
|
+
.strict();
|
|
142
|
+
export const longQuestionSchema = z.object({ ...base, kind: z.literal('long'), maxLength: z.number().int().min(1).max(5000).default(2000) }).strict();
|
|
143
|
+
const choices = z.array(choiceSchema).min(FORM_CHOICES_MIN).max(FORM_CHOICES_MAX);
|
|
144
|
+
export const oneQuestionSchema = z.object({ ...base, kind: z.literal('one'), choices }).strict();
|
|
145
|
+
export const severalQuestionSchema = z
|
|
146
|
+
.object({
|
|
147
|
+
...base,
|
|
148
|
+
kind: z.literal('several'),
|
|
149
|
+
choices,
|
|
150
|
+
/** The fewest and the most picks an answer may make. */
|
|
151
|
+
min: z.number().int().min(1).max(FORM_CHOICES_MAX).optional(),
|
|
152
|
+
max: z.number().int().min(1).max(FORM_CHOICES_MAX).optional(),
|
|
153
|
+
})
|
|
154
|
+
.strict();
|
|
155
|
+
export const dateQuestionSchema = z
|
|
156
|
+
.object({
|
|
157
|
+
...base,
|
|
158
|
+
kind: z.literal('date'),
|
|
159
|
+
/** The earliest day an answer may name, counted in the business's time zone. */
|
|
160
|
+
from: z.enum(['any', 'today', 'tomorrow']).default('any'),
|
|
161
|
+
})
|
|
162
|
+
.strict();
|
|
163
|
+
export const numberQuestionSchema = z.object({ ...base, kind: z.literal('number'), min: bound.optional(), max: bound.optional(), whole: z.boolean().optional() }).strict();
|
|
164
|
+
export const scoreQuestionSchema = z
|
|
165
|
+
.object({
|
|
166
|
+
...base,
|
|
167
|
+
kind: z.literal('score'),
|
|
168
|
+
/** "How likely are you to recommend us?": the survey's one score its results call the recommend score. */
|
|
169
|
+
recommend: z.boolean().optional(),
|
|
170
|
+
})
|
|
171
|
+
.strict();
|
|
172
|
+
export const starsQuestionSchema = z.object({ ...base, kind: z.literal('stars') }).strict();
|
|
173
|
+
export const fileQuestionSchema = z
|
|
174
|
+
.object({
|
|
175
|
+
...base,
|
|
176
|
+
kind: z.literal('file'),
|
|
177
|
+
/** The largest file taken, in megabytes, per file. */
|
|
178
|
+
maxMb: z.number().int().min(1).max(10),
|
|
179
|
+
kinds: z.array(z.enum(FORM_FILE_KINDS)).min(1).max(FORM_FILE_KINDS.length),
|
|
180
|
+
/** Up to {@link FORM_FILES_MAX} files; absent, one. */
|
|
181
|
+
many: z.boolean().optional(),
|
|
182
|
+
})
|
|
183
|
+
.strict();
|
|
184
|
+
/**
|
|
185
|
+
* The agreement tick. Its `label` IS the wording the visitor agrees to, and
|
|
186
|
+
* its version is what the consent log keeps with the yes. It is never ticked
|
|
187
|
+
* before the visitor ticks it, so the vocabulary has no default value for it.
|
|
188
|
+
*/
|
|
189
|
+
export const tickQuestionSchema = z
|
|
190
|
+
.object({
|
|
191
|
+
...base,
|
|
192
|
+
label: wordsSchema(FORM_WORDS_MAX.wording),
|
|
193
|
+
kind: z.literal('tick'),
|
|
194
|
+
purpose: z.enum(FORM_TICK_PURPOSES),
|
|
195
|
+
wordingVersion: z.number().int().min(1),
|
|
196
|
+
wordingChangedAt: z.iso.date(),
|
|
197
|
+
/** A yes waits for the click in a confirmation mail (on by default). */
|
|
198
|
+
confirm: z.boolean().default(true),
|
|
199
|
+
})
|
|
200
|
+
.strict();
|
|
201
|
+
/** The hidden source field: filled from the page address's query (`?from=flyer`), never shown. */
|
|
202
|
+
export const hiddenQuestionSchema = z
|
|
203
|
+
.object({
|
|
204
|
+
...base,
|
|
205
|
+
kind: z.literal('hidden'),
|
|
206
|
+
param: z.string().regex(/^[a-z][a-z0-9_]{0,31}$/, 'a parameter is 1 to 32 lower-case letters, digits or _'),
|
|
207
|
+
})
|
|
208
|
+
.strict();
|
|
209
|
+
export const formQuestionSchema = z.discriminatedUnion('kind', [
|
|
210
|
+
shortQuestionSchema,
|
|
211
|
+
longQuestionSchema,
|
|
212
|
+
oneQuestionSchema,
|
|
213
|
+
severalQuestionSchema,
|
|
214
|
+
dateQuestionSchema,
|
|
215
|
+
numberQuestionSchema,
|
|
216
|
+
scoreQuestionSchema,
|
|
217
|
+
starsQuestionSchema,
|
|
218
|
+
fileQuestionSchema,
|
|
219
|
+
tickQuestionSchema,
|
|
220
|
+
hiddenQuestionSchema,
|
|
221
|
+
]);
|
|
222
|
+
export const formSectionSchema = z.object({ id: sectionIdSchema, title: wordsSchema(FORM_WORDS_MAX.section) }).strict();
|
|
223
|
+
/** Whether a text is an https address with a host and no user name or password in it. */
|
|
224
|
+
export function isHttpsAddress(text) {
|
|
225
|
+
if (!URL.canParse(text))
|
|
226
|
+
return false;
|
|
227
|
+
const url = new URL(text);
|
|
228
|
+
return url.protocol === 'https:' && url.hostname !== '' && url.username === '' && url.password === '';
|
|
229
|
+
}
|
|
230
|
+
/** What a visitor sees after sending: the owner's words, or another page. */
|
|
231
|
+
export const formEndingSchema = z.discriminatedUnion('kind', [
|
|
232
|
+
z.object({ kind: z.literal('words'), words: wordsSchema(FORM_WORDS_MAX.ending) }).strict(),
|
|
233
|
+
z.object({ kind: z.literal('page'), url: z.string().min(1).max(2048) }).strict(),
|
|
234
|
+
]);
|
|
235
|
+
const definitionShape = z
|
|
236
|
+
.object({
|
|
237
|
+
v: z.literal(FORMS_VOCABULARY_VERSION),
|
|
238
|
+
kind: z.enum(['form', 'survey']),
|
|
239
|
+
languages: z.array(formLanguageSchema).min(1).max(FORM_LANGUAGES.length),
|
|
240
|
+
defaultLanguage: formLanguageSchema,
|
|
241
|
+
title: wordsSchema(FORM_WORDS_MAX.title),
|
|
242
|
+
intro: wordsSchema(FORM_WORDS_MAX.intro).optional(),
|
|
243
|
+
sections: z.array(formSectionSchema).max(FORM_SECTIONS_MAX).optional(),
|
|
244
|
+
questions: z.array(formQuestionSchema).min(1).max(FORM_QUESTIONS_MAX),
|
|
245
|
+
ending: formEndingSchema,
|
|
246
|
+
})
|
|
247
|
+
.strict();
|
|
248
|
+
/** The kinds of test each kind of question takes in a "show if". */
|
|
249
|
+
const TESTS_OF = {
|
|
250
|
+
one: ['is'],
|
|
251
|
+
several: ['includes'],
|
|
252
|
+
score: ['is', 'atLeast', 'atMost'],
|
|
253
|
+
stars: ['is', 'atLeast', 'atMost'],
|
|
254
|
+
number: ['is', 'atLeast', 'atMost'],
|
|
255
|
+
};
|
|
256
|
+
/** Every text of the definition, with its path, to hold against the form's languages. */
|
|
257
|
+
function textsOf(d) {
|
|
258
|
+
const out = [{ words: d.title, path: ['title'] }];
|
|
259
|
+
if (d.intro !== undefined)
|
|
260
|
+
out.push({ words: d.intro, path: ['intro'] });
|
|
261
|
+
(d.sections ?? []).forEach((section, s) => out.push({ words: section.title, path: ['sections', s, 'title'] }));
|
|
262
|
+
d.questions.forEach((question, q) => {
|
|
263
|
+
out.push({ words: question.label, path: ['questions', q, 'label'] });
|
|
264
|
+
if (question.help !== undefined)
|
|
265
|
+
out.push({ words: question.help, path: ['questions', q, 'help'] });
|
|
266
|
+
if (question.kind === 'one' || question.kind === 'several') {
|
|
267
|
+
question.choices.forEach((choice, c) => out.push({ words: choice.label, path: ['questions', q, 'choices', c, 'label'] }));
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
if (d.ending.kind === 'words')
|
|
271
|
+
out.push({ words: d.ending.words, path: ['ending', 'words'] });
|
|
272
|
+
return out;
|
|
273
|
+
}
|
|
274
|
+
/** The rules across a definition's parts, each a code at a path. */
|
|
275
|
+
function definitionIssues(d, report) {
|
|
276
|
+
// Languages: listed once, the default among them, and every text in exactly those.
|
|
277
|
+
const listed = new Set(d.languages);
|
|
278
|
+
if (listed.size !== d.languages.length)
|
|
279
|
+
report('languages-duplicate', ['languages']);
|
|
280
|
+
if (!listed.has(d.defaultLanguage))
|
|
281
|
+
report('default-language', ['defaultLanguage']);
|
|
282
|
+
for (const { words, path } of textsOf(d)) {
|
|
283
|
+
for (const language of listed)
|
|
284
|
+
if (words[language] === undefined)
|
|
285
|
+
report('words-missing', [...path, language]);
|
|
286
|
+
for (const language of Object.keys(words))
|
|
287
|
+
if (!listed.has(language))
|
|
288
|
+
report('words-unlisted', [...path, language]);
|
|
289
|
+
}
|
|
290
|
+
// Sections: unique, named by their questions, and drawn in order.
|
|
291
|
+
const sections = d.sections ?? [];
|
|
292
|
+
const sectionAt = new Map();
|
|
293
|
+
sections.forEach((section, s) => {
|
|
294
|
+
if (sectionAt.has(section.id))
|
|
295
|
+
report('id-duplicate', ['sections', s, 'id']);
|
|
296
|
+
else
|
|
297
|
+
sectionAt.set(section.id, s);
|
|
298
|
+
});
|
|
299
|
+
let lastSection = -1;
|
|
300
|
+
d.questions.forEach((question, q) => {
|
|
301
|
+
if (question.section === undefined) {
|
|
302
|
+
if (lastSection !== -1)
|
|
303
|
+
report('section-order', ['questions', q, 'section']);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const at = sectionAt.get(question.section);
|
|
307
|
+
if (at === undefined) {
|
|
308
|
+
report('section-unknown', ['questions', q, 'section']);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (at < lastSection)
|
|
312
|
+
report('section-order', ['questions', q, 'section']);
|
|
313
|
+
lastSection = Math.max(lastSection, at);
|
|
314
|
+
});
|
|
315
|
+
// Questions: ids, choices and hidden parameters unique.
|
|
316
|
+
const questionAt = new Map();
|
|
317
|
+
const params = new Set();
|
|
318
|
+
d.questions.forEach((question, q) => {
|
|
319
|
+
if (questionAt.has(question.id))
|
|
320
|
+
report('id-duplicate', ['questions', q, 'id']);
|
|
321
|
+
else
|
|
322
|
+
questionAt.set(question.id, q);
|
|
323
|
+
if (question.kind === 'one' || question.kind === 'several') {
|
|
324
|
+
const seen = new Set();
|
|
325
|
+
question.choices.forEach((choice, c) => {
|
|
326
|
+
if (seen.has(choice.id))
|
|
327
|
+
report('id-duplicate', ['questions', q, 'choices', c, 'id']);
|
|
328
|
+
seen.add(choice.id);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
if (question.kind === 'hidden') {
|
|
332
|
+
if (params.has(question.param))
|
|
333
|
+
report('id-duplicate', ['questions', q, 'param']);
|
|
334
|
+
params.add(question.param);
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
// Each kind's own rules.
|
|
338
|
+
const asksEmail = d.questions.some((question) => question.kind === 'short' && question.check === 'email');
|
|
339
|
+
const purposes = new Set();
|
|
340
|
+
let recommends = 0;
|
|
341
|
+
d.questions.forEach((question, q) => {
|
|
342
|
+
const at = (...rest) => ['questions', q, ...rest];
|
|
343
|
+
switch (question.kind) {
|
|
344
|
+
case 'short':
|
|
345
|
+
if (question.role === 'email' && question.check !== 'email')
|
|
346
|
+
report('role-email-check', at('role'));
|
|
347
|
+
break;
|
|
348
|
+
case 'several': {
|
|
349
|
+
const most = question.max ?? question.choices.length;
|
|
350
|
+
if (most > question.choices.length || (question.min ?? 1) > most)
|
|
351
|
+
report('several-picks', at(question.max === undefined ? 'min' : 'max'));
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
case 'number':
|
|
355
|
+
if (question.min !== undefined && question.max !== undefined && question.min > question.max)
|
|
356
|
+
report('number-bounds', at('min'));
|
|
357
|
+
break;
|
|
358
|
+
case 'score':
|
|
359
|
+
if (question.recommend === true) {
|
|
360
|
+
if (d.kind === 'form')
|
|
361
|
+
report('recommend-on-form', at('recommend'));
|
|
362
|
+
else if (++recommends > 1)
|
|
363
|
+
report('recommend-twice', at('recommend'));
|
|
364
|
+
}
|
|
365
|
+
break;
|
|
366
|
+
case 'file':
|
|
367
|
+
if (new Set(question.kinds).size !== question.kinds.length)
|
|
368
|
+
report('file-kinds-duplicate', at('kinds'));
|
|
369
|
+
if (d.kind === 'survey')
|
|
370
|
+
report('survey-file', at('kind'));
|
|
371
|
+
break;
|
|
372
|
+
case 'tick':
|
|
373
|
+
if (question.required)
|
|
374
|
+
report('tick-required', at('required'));
|
|
375
|
+
if (purposes.has(question.purpose))
|
|
376
|
+
report('tick-purpose-twice', at('purpose'));
|
|
377
|
+
purposes.add(question.purpose);
|
|
378
|
+
if (d.kind === 'survey')
|
|
379
|
+
report('survey-tick', at('kind'));
|
|
380
|
+
else if (question.confirm && !asksEmail)
|
|
381
|
+
report('tick-confirm-email', at('confirm'));
|
|
382
|
+
break;
|
|
383
|
+
case 'hidden':
|
|
384
|
+
if (question.required)
|
|
385
|
+
report('hidden-required', at('required'));
|
|
386
|
+
if (question.showIf !== undefined)
|
|
387
|
+
report('hidden-show-if', at('showIf'));
|
|
388
|
+
break;
|
|
389
|
+
default:
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
// "Show if": one test, of an earlier question it can test, naming what that question can hold.
|
|
394
|
+
d.questions.forEach((question, q) => {
|
|
395
|
+
const showIf = question.showIf;
|
|
396
|
+
if (showIf === undefined || question.kind === 'hidden')
|
|
397
|
+
return;
|
|
398
|
+
const at = (...rest) => ['questions', q, 'showIf', ...rest];
|
|
399
|
+
const target = questionAt.get(showIf.question);
|
|
400
|
+
if (target === undefined) {
|
|
401
|
+
report('show-if-unknown', at('question'));
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (target >= q) {
|
|
405
|
+
report('show-if-forward', at('question'));
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
const named = d.questions[target];
|
|
409
|
+
if (!SHOW_IF_KINDS.includes(named.kind)) {
|
|
410
|
+
report('show-if-kind', at('question'));
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
const given = ['is', 'includes', 'atLeast', 'atMost'].filter((test) => showIf[test] !== undefined);
|
|
414
|
+
const takes = TESTS_OF[named.kind];
|
|
415
|
+
if (given.length !== 1 || !takes.includes(given[0])) {
|
|
416
|
+
report('show-if-test', at());
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const test = given[0];
|
|
420
|
+
const value = showIf[test];
|
|
421
|
+
if (named.kind === 'one' || named.kind === 'several') {
|
|
422
|
+
if (typeof value !== 'string' || !named.choices.some((choice) => choice.id === value))
|
|
423
|
+
report('show-if-choice', at(test));
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (typeof value !== 'number') {
|
|
427
|
+
report('show-if-test', at(test));
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (named.kind === 'score' || named.kind === 'stars') {
|
|
431
|
+
const scale = SCALE_OF[named.kind];
|
|
432
|
+
if (!Number.isInteger(value) || value < scale.min || value > scale.max)
|
|
433
|
+
report('show-if-range', at(test));
|
|
434
|
+
}
|
|
435
|
+
else if (named.kind === 'number' && ((named.min !== undefined && value < named.min) || (named.max !== undefined && value > named.max))) {
|
|
436
|
+
report('show-if-range', at(test));
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
if (d.ending.kind === 'page' && !isHttpsAddress(d.ending.url))
|
|
440
|
+
report('ending-https', ['ending', 'url']);
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* A form's definition. Its defaults filled in (`required: false`, a short
|
|
444
|
+
* answer's 200 characters, a tick's confirmation on), and every rule across
|
|
445
|
+
* its parts held: a value that parses here is one the engine can draw in each
|
|
446
|
+
* of its languages and check an answer against.
|
|
447
|
+
*/
|
|
448
|
+
export const formDefinitionSchema = definitionShape.superRefine((d, ctx) => {
|
|
449
|
+
definitionIssues(d, (code, path) => ctx.addIssue({ code: 'custom', message: code, path, params: { code } }));
|
|
450
|
+
});
|
|
451
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/forms/definition.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,WAAW,EAAiC,MAAM,YAAY,CAAC;AAE5H,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC;AAEpC,qFAAqF;AACrF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAE1C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AACrC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAEnC,gDAAgD;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAU,CAAC;AAG9I,mFAAmF;AACnF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAA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AAE,EAAE;IACzE,gBAAgB,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/G,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@adminium/add-on-contracts/forms` — the forms vocabulary: a form's
|
|
3
|
+
* definition and settings, the check an answer is held to, which questions
|
|
4
|
+
* are shown, and the results counted.
|
|
5
|
+
*
|
|
6
|
+
* Both the engine and the forms add-on import it, so the builder's preview,
|
|
7
|
+
* the page a stranger fills and the server's check can never disagree. Pure:
|
|
8
|
+
* no I/O, no `node:` import.
|
|
9
|
+
*/
|
|
10
|
+
export { FORM_LANGUAGES, FORM_WORDS_MAX, formLanguageSchema, wordsSchema, type FormLanguage, type Words } from './words.js';
|
|
11
|
+
export { FORMS_VOCABULARY_VERSION, FORM_CHOICES_MAX, FORM_CHOICES_MIN, FORM_DEFINITION_CODES, FORM_FILES_MAX, FORM_FILE_KINDS, FORM_QUESTIONS_MAX, FORM_QUESTION_KINDS, FORM_SECTIONS_MAX, FORM_TICK_PURPOSES, SCALE_OF, SHOW_IF_KINDS, choiceIdSchema, choiceSchema, dateQuestionSchema, fileQuestionSchema, formDefinitionSchema, formEndingSchema, formQuestionSchema, formSectionSchema, hiddenQuestionSchema, isHttpsAddress, longQuestionSchema, numberQuestionSchema, oneQuestionSchema, questionIdSchema, scoreQuestionSchema, sectionIdSchema, severalQuestionSchema, shortQuestionSchema, showIfSchema, starsQuestionSchema, tickQuestionSchema, type FormChoice, type FormDefinition, type FormDefinitionCode, type FormDefinitionInput, type FormFileKind, type FormQuestion, type FormQuestionKind, type FormQuestionOf, type FormTickPurpose, type ShowIf, } from './definition.js';
|
|
12
|
+
export { FORM_PER_HOUR_DEFAULT, FORM_PER_HOUR_MAX, FORM_TELL_MAX, SURVEY_STOP_AFTER_DAYS_DEFAULT, formBecomesSchema, formColumnRefSchema, formSettingsSchema, formTellSchema, keepsNames, type FormBecomes, type FormSettings, type FormSettingsInput, } from './settings.js';
|
|
13
|
+
export { FORM_SETTINGS_CODES, parseForm, type Form, type FormIssue, type FormSettingsCode, type ParsedForm } from './parse.js';
|
|
14
|
+
export { ANSWER_NAME_MAX, EMAIL_MAX, FORM_ANSWER_CODES, HIDDEN_VALUE_MAX, UPLOAD_ID, WHOLE_ANSWER, checkAnswer, cleanText, isEmailAddress, isPhoneNumber, visibleQuestions, type CheckedAnswer, type FormAnswerCode, type FormAnswerValue, type FormAnswerValues, } from './check.js';
|
|
15
|
+
export { recommendScoreOf, summarise, type FormSummary, type QuestionSummary } from './summary.js';
|
|
16
|
+
export { WEBSITES_MAX, WEBSITE_LINE_CODES, WEBSITE_LINE_MAX, WEBSITE_ORIGIN_MAX, checkWebsiteLine, checkWebsiteLines, isWebsiteOrigin, type WebsiteCheckContext, type WebsiteLine, type WebsiteLineCode, } from './websites.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/forms/index.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AACH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAE5H,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,aAAa,EACb,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,E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BAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
/**
|
|
3
|
+
* `@adminium/add-on-contracts/forms` — the forms vocabulary: a form's
|
|
4
|
+
* definition and settings, the check an answer is held to, which questions
|
|
5
|
+
* are shown, and the results counted.
|
|
6
|
+
*
|
|
7
|
+
* Both the engine and the forms add-on import it, so the builder's preview,
|
|
8
|
+
* the page a stranger fills and the server's check can never disagree. Pure:
|
|
9
|
+
* no I/O, no `node:` import.
|
|
10
|
+
*/
|
|
11
|
+
export { FORM_LANGUAGES, FORM_WORDS_MAX, formLanguageSchema, wordsSchema } from './words.js';
|
|
12
|
+
export { FORMS_VOCABULARY_VERSION, FORM_CHOICES_MAX, FORM_CHOICES_MIN, FORM_DEFINITION_CODES, FORM_FILES_MAX, FORM_FILE_KINDS, FORM_QUESTIONS_MAX, FORM_QUESTION_KINDS, FORM_SECTIONS_MAX, FORM_TICK_PURPOSES, SCALE_OF, SHOW_IF_KINDS, choiceIdSchema, choiceSchema, dateQuestionSchema, fileQuestionSchema, formDefinitionSchema, formEndingSchema, formQuestionSchema, formSectionSchema, hiddenQuestionSchema, isHttpsAddress, longQuestionSchema, numberQuestionSchema, oneQuestionSchema, questionIdSchema, scoreQuestionSchema, sectionIdSchema, severalQuestionSchema, shortQuestionSchema, showIfSchema, starsQuestionSchema, tickQuestionSchema, } from './definition.js';
|
|
13
|
+
export { FORM_PER_HOUR_DEFAULT, FORM_PER_HOUR_MAX, FORM_TELL_MAX, SURVEY_STOP_AFTER_DAYS_DEFAULT, formBecomesSchema, formColumnRefSchema, formSettingsSchema, formTellSchema, keepsNames, } from './settings.js';
|
|
14
|
+
export { FORM_SETTINGS_CODES, parseForm } from './parse.js';
|
|
15
|
+
export { ANSWER_NAME_MAX, EMAIL_MAX, FORM_ANSWER_CODES, HIDDEN_VALUE_MAX, UPLOAD_ID, WHOLE_ANSWER, checkAnswer, cleanText, isEmailAddress, isPhoneNumber, visibleQuestions, } from './check.js';
|
|
16
|
+
export { recommendScoreOf, summarise } from './summary.js';
|
|
17
|
+
export { WEBSITES_MAX, WEBSITE_LINE_CODES, WEBSITE_LINE_MAX, WEBSITE_ORIGIN_MAX, checkWebsiteLine, checkWebsiteLines, isWebsiteOrigin, } from './websites.js';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/forms/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC;;;;;;;;GAQG;AACH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,WAAW,EAAiC,MAAM,YAAY,CAAC;AAE5H,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,aAAa,EACb,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,GAWnB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,8BAA8B,EAC9B,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,UAAU,GAIX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAqE,MAAM,YAAY,CAAC;AAE/H,OAAO,EACL,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,WAAW,EACX,SAAS,EACT,cAAc,EACd,aAAa,EACb,gBAAgB,GAKjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAA0C,MAAM,cAAc,CAAC;AAEnG,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAIhB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type FormDefinition } from './definition.js';
|
|
2
|
+
import { type FormSettings } from './settings.js';
|
|
3
|
+
/** A form as the engine holds it. */
|
|
4
|
+
export interface Form {
|
|
5
|
+
definition: FormDefinition;
|
|
6
|
+
settings: FormSettings;
|
|
7
|
+
}
|
|
8
|
+
/** Codes the settings are refused with, beside the definition's and Zod's own. */
|
|
9
|
+
export declare const FORM_SETTINGS_CODES: readonly ["survey-settings-missing", "survey-settings-on-form", "survey-anonymous-names", "becomes-question-unknown", "becomes-question-kind", "becomes-column-twice", "becomes-anonymous", "tell-duplicate", "tell-when-question", "tell-when-range"];
|
|
10
|
+
export type FormSettingsCode = (typeof FORM_SETTINGS_CODES)[number];
|
|
11
|
+
export interface FormIssue {
|
|
12
|
+
/** Where: under `definition` or `settings`. */
|
|
13
|
+
path: (string | number)[];
|
|
14
|
+
/** What: one of this vocabulary's codes, or Zod's own. */
|
|
15
|
+
code: string;
|
|
16
|
+
}
|
|
17
|
+
export type ParsedForm = {
|
|
18
|
+
ok: true;
|
|
19
|
+
form: Form;
|
|
20
|
+
} | {
|
|
21
|
+
ok: false;
|
|
22
|
+
issues: FormIssue[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A form from its stored definition and settings, or every reason it is not
|
|
26
|
+
* one. The definition's issues come first; the rules across the two are
|
|
27
|
+
* checked only when both parse.
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseForm(definition: unknown, settings: unknown): ParsedForm;
|
|
30
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/forms/parse.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkC,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAkC,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAElF,qCAAqC;AACrC,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,cAAc,CAAC;IAC3B,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,wPAoBtB,CAAC;AACX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,MAAM,WAAW,SAAS;IACxB,+CAA+C;IAC/C,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC1B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,EAAE,CAAA;CAAE,CAAC;AAkDvF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,UAAU,CAO5E"}
|