@marktiderman/genesis-forms 0.4.0 → 0.4.2
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/README.md +31 -4
- package/dist/destinations.cjs.map +1 -1
- package/dist/destinations.js.map +1 -1
- package/dist/index.cjs +230 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +229 -46
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +303 -55
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +29 -2
- package/dist/server.d.ts +29 -2
- package/dist/server.js +301 -56
- package/dist/server.js.map +1 -1
- package/dist/testing.cjs +302 -54
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +302 -54
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -164,8 +164,35 @@ The formula language is small and is parsed and evaluated by this package, never
|
|
|
164
164
|
An unanswered question is blank, and arithmetic with a blank is blank, so a total stays empty until
|
|
165
165
|
its answers are in; dividing by zero is blank too. The functions skip blanks (`sum` of nothing is
|
|
166
166
|
`0`). Text holding a number (`"12"`, `"1,200"`) counts as that number, and yes / no as 1 / 0.
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
|
|
168
|
+
Limits, so a large submission can't make the server slow:
|
|
169
|
+
|
|
170
|
+
- A calculated field that reads a list or table of more than `MAX_FORMULA_ITEMS` (10,000) items
|
|
171
|
+
has no value: it is blank, never `0` or a partial total. The same goes for one that reads an
|
|
172
|
+
answer past `MAX_SETTLE_ITEMS` (50,000) items read by all of a form's formulas together (each
|
|
173
|
+
list or table counted once, however many of its columns are read, in form order; an answer over
|
|
174
|
+
10,000 items counts for none).
|
|
175
|
+
Nothing else reports this, so give a table a `maxRows` well under these if its total matters.
|
|
176
|
+
- A formula is at most `MAX_FORMULA_LENGTH` characters and 64 levels of parentheses, calls, signs
|
|
177
|
+
and `? :` deep, and all of a form's formulas together at most `MAX_FORM_FORMULA_LENGTH` (20,000).
|
|
178
|
+
- Lists are read once per answer, so treat an engine's answers as immutable: pass `setValue` a new
|
|
179
|
+
array (the engine and the built-in renderers never change one in place). `setValue` with the
|
|
180
|
+
array it already holds works it out again. Each engine, and so each `validateSubmission` call,
|
|
181
|
+
keeps its own lists, so the same object passed again after a change is read afresh.
|
|
182
|
+
- `validateSubmission` refuses a submission that would be too much work, with an error under `""`,
|
|
183
|
+
and never cuts one short. It doesn't rely on the host's request size limit. Each limit is an
|
|
184
|
+
option for a host that needs more:
|
|
185
|
+
|
|
186
|
+
| Limit | Default | Option | Counts |
|
|
187
|
+
| --- | --- | --- | --- |
|
|
188
|
+
| `MAX_EVENTS` | 10,000 | `maxEvents` | Events, after `compactEvents`; at most `RAW_EVENTS_PER_EVENT` (10) times as many may be sent |
|
|
189
|
+
| `MAX_SUBMISSION_VALUES` | 200,000 | `maxValues` | JSON values in the answers, answer events and hidden inputs: each number, text, true / false, list item, row and cell. A run of answers to one field (a table sends itself on every keystroke) counts its last only |
|
|
190
|
+
| `MAX_REPLAY_WORK` | 1,000,000 | `maxReplayWork` | Replaying the events: one unit per block each time the path is walked, one per calculated field each time the answers settle, and a formula's size (its numbers, answers and operators) each time it is worked out. The submit after the replay isn't counted |
|
|
191
|
+
|
|
192
|
+
A respondent filling in a long form with formulas uses about 400,000 units of replay work at
|
|
193
|
+
most; the limit stops a log built to make every step work out every formula. After a refusal,
|
|
194
|
+
sending the same body again gets the same answer, so show the `""` message rather than offer
|
|
195
|
+
"Try again".
|
|
169
196
|
|
|
170
197
|
The engine works the values out from the answers on the path (an answer hidden by logic reads as
|
|
171
198
|
blank), again whenever an answer it reads changes, and stores them with the answers, so `engine.answers()` and a
|
|
@@ -203,8 +230,8 @@ await store(result.submission); // answers, hidden, context, ending
|
|
|
203
230
|
```
|
|
204
231
|
|
|
205
232
|
Errors are keyed by field id. The `""` key is for the whole submission: `"Malformed submission."`
|
|
206
|
-
(a body of the wrong shape), a definition that fails `parseForm`, or
|
|
207
|
-
|
|
233
|
+
(a body of the wrong shape), a definition that fails `parseForm`, or a submission past one of the
|
|
234
|
+
limits above (`maxEvents`, `maxValues`, `maxReplayWork`). Events of an unknown type are dropped, so a newer
|
|
208
235
|
client's log still replays. With `settings.clearHiddenValues: false`, a hidden field's value is kept
|
|
209
236
|
only if its format is valid.
|
|
210
237
|
|