@fieldia/core 0.28.0 → 0.29.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 (233) hide show
  1. package/README.md +125 -1
  2. package/package.json +1 -1
  3. package/schema/page.schema.json +263 -6
  4. package/src/index.d.mts +8 -2
  5. package/src/index.d.ts +8 -2
  6. package/src/index.js +29 -2
  7. package/src/index.js.map +1 -1
  8. package/src/index.mjs +11 -2
  9. package/src/index.mjs.map +1 -1
  10. package/src/lib/format/approval-checks.d.mts +8 -0
  11. package/src/lib/format/approval-checks.d.ts +8 -0
  12. package/src/lib/format/approval-checks.js +29 -0
  13. package/src/lib/format/approval-checks.js.map +1 -0
  14. package/src/lib/format/approval-checks.mjs +26 -0
  15. package/src/lib/format/approval-checks.mjs.map +1 -0
  16. package/src/lib/format/approval.d.mts +20 -0
  17. package/src/lib/format/approval.d.ts +20 -0
  18. package/src/lib/format/approval.js +25 -0
  19. package/src/lib/format/approval.js.map +1 -0
  20. package/src/lib/format/approval.mjs +22 -0
  21. package/src/lib/format/approval.mjs.map +1 -0
  22. package/src/lib/format/assist-checks.d.mts +14 -0
  23. package/src/lib/format/assist-checks.d.ts +14 -0
  24. package/src/lib/format/assist-checks.js +68 -0
  25. package/src/lib/format/assist-checks.js.map +1 -0
  26. package/src/lib/format/assist-checks.mjs +64 -0
  27. package/src/lib/format/assist-checks.mjs.map +1 -0
  28. package/src/lib/format/assist.d.mts +41 -0
  29. package/src/lib/format/assist.d.ts +41 -0
  30. package/src/lib/format/assist.js +29 -0
  31. package/src/lib/format/assist.js.map +1 -0
  32. package/src/lib/format/assist.mjs +26 -0
  33. package/src/lib/format/assist.mjs.map +1 -0
  34. package/src/lib/format/editable-checks.d.mts +8 -0
  35. package/src/lib/format/editable-checks.d.ts +8 -0
  36. package/src/lib/format/editable-checks.js +38 -0
  37. package/src/lib/format/editable-checks.js.map +1 -0
  38. package/src/lib/format/editable-checks.mjs +35 -0
  39. package/src/lib/format/editable-checks.mjs.map +1 -0
  40. package/src/lib/format/field.d.mts +86 -0
  41. package/src/lib/format/field.d.ts +86 -0
  42. package/src/lib/format/field.js +56 -10
  43. package/src/lib/format/field.js.map +1 -1
  44. package/src/lib/format/field.mjs +55 -9
  45. package/src/lib/format/field.mjs.map +1 -1
  46. package/src/lib/format/languages-checks.d.mts +8 -0
  47. package/src/lib/format/languages-checks.d.ts +8 -0
  48. package/src/lib/format/languages-checks.js +40 -0
  49. package/src/lib/format/languages-checks.js.map +1 -0
  50. package/src/lib/format/languages-checks.mjs +37 -0
  51. package/src/lib/format/languages-checks.mjs.map +1 -0
  52. package/src/lib/format/later-checks.d.mts +4 -3
  53. package/src/lib/format/later-checks.d.ts +4 -3
  54. package/src/lib/format/later-checks.js +4 -3
  55. package/src/lib/format/later-checks.js.map +1 -1
  56. package/src/lib/format/later-checks.mjs +4 -3
  57. package/src/lib/format/later-checks.mjs.map +1 -1
  58. package/src/lib/format/layout.d.mts +100 -26
  59. package/src/lib/format/layout.d.ts +100 -26
  60. package/src/lib/format/layout.js +19 -3
  61. package/src/lib/format/layout.js.map +1 -1
  62. package/src/lib/format/layout.mjs +17 -1
  63. package/src/lib/format/layout.mjs.map +1 -1
  64. package/src/lib/format/layout.types.d.mts +2 -1
  65. package/src/lib/format/layout.types.d.ts +2 -1
  66. package/src/lib/format/list-editable.d.mts +20 -0
  67. package/src/lib/format/list-editable.d.ts +20 -0
  68. package/src/lib/format/list-editable.js +33 -0
  69. package/src/lib/format/list-editable.js.map +1 -0
  70. package/src/lib/format/list-editable.mjs +28 -0
  71. package/src/lib/format/list-editable.mjs.map +1 -0
  72. package/src/lib/format/page.d.mts +84 -9
  73. package/src/lib/format/page.d.ts +84 -9
  74. package/src/lib/format/page.js +4 -0
  75. package/src/lib/format/page.js.map +1 -1
  76. package/src/lib/format/page.mjs +4 -0
  77. package/src/lib/format/page.mjs.map +1 -1
  78. package/src/lib/format/photos-options.d.mts +29 -0
  79. package/src/lib/format/photos-options.d.ts +29 -0
  80. package/src/lib/format/photos-options.js +49 -0
  81. package/src/lib/format/photos-options.js.map +1 -0
  82. package/src/lib/format/photos-options.mjs +45 -0
  83. package/src/lib/format/photos-options.mjs.map +1 -0
  84. package/src/lib/format/references.js +31 -1
  85. package/src/lib/format/references.js.map +1 -1
  86. package/src/lib/format/references.mjs +31 -1
  87. package/src/lib/format/references.mjs.map +1 -1
  88. package/src/lib/format/scan-checks.d.mts +12 -0
  89. package/src/lib/format/scan-checks.d.ts +12 -0
  90. package/src/lib/format/scan-checks.js +89 -0
  91. package/src/lib/format/scan-checks.js.map +1 -0
  92. package/src/lib/format/scan-checks.mjs +86 -0
  93. package/src/lib/format/scan-checks.mjs.map +1 -0
  94. package/src/lib/format/scan-options.d.mts +84 -0
  95. package/src/lib/format/scan-options.d.ts +84 -0
  96. package/src/lib/format/scan-options.js +58 -0
  97. package/src/lib/format/scan-options.js.map +1 -0
  98. package/src/lib/format/scan-options.mjs +54 -0
  99. package/src/lib/format/scan-options.mjs.map +1 -0
  100. package/src/lib/format/upgrade.d.mts +4 -2
  101. package/src/lib/format/upgrade.d.ts +4 -2
  102. package/src/lib/format/upgrade.js +4 -2
  103. package/src/lib/format/upgrade.js.map +1 -1
  104. package/src/lib/format/upgrade.mjs +4 -2
  105. package/src/lib/format/upgrade.mjs.map +1 -1
  106. package/src/lib/format/version.d.mts +2 -2
  107. package/src/lib/format/version.d.ts +2 -2
  108. package/src/lib/format/version.js +2 -2
  109. package/src/lib/format/version.js.map +1 -1
  110. package/src/lib/format/version.mjs +2 -2
  111. package/src/lib/format/version.mjs.map +1 -1
  112. package/src/lib/record/approvals-part.d.mts +6 -0
  113. package/src/lib/record/approvals-part.d.ts +6 -0
  114. package/src/lib/record/approvals-part.js +14 -0
  115. package/src/lib/record/approvals-part.js.map +1 -0
  116. package/src/lib/record/approvals-part.mjs +7 -0
  117. package/src/lib/record/approvals-part.mjs.map +1 -0
  118. package/src/lib/record/approving.d.mts +45 -0
  119. package/src/lib/record/approving.d.ts +45 -0
  120. package/src/lib/record/approving.js +10 -0
  121. package/src/lib/record/approving.js.map +1 -0
  122. package/src/lib/record/approving.mjs +7 -0
  123. package/src/lib/record/approving.mjs.map +1 -0
  124. package/src/lib/record/check.js +4 -0
  125. package/src/lib/record/check.js.map +1 -1
  126. package/src/lib/record/check.mjs +4 -0
  127. package/src/lib/record/check.mjs.map +1 -1
  128. package/src/lib/record/data-source.d.mts +270 -0
  129. package/src/lib/record/data-source.d.ts +270 -0
  130. package/src/lib/record/data-source.js.map +1 -1
  131. package/src/lib/record/data-source.mjs.map +1 -1
  132. package/src/lib/record/files-part.d.mts +7 -0
  133. package/src/lib/record/files-part.d.ts +7 -0
  134. package/src/lib/record/files-part.js +167 -0
  135. package/src/lib/record/files-part.js.map +1 -0
  136. package/src/lib/record/files-part.mjs +163 -0
  137. package/src/lib/record/files-part.mjs.map +1 -0
  138. package/src/lib/record/filter.d.mts +5 -0
  139. package/src/lib/record/filter.d.ts +5 -0
  140. package/src/lib/record/filter.js +1 -0
  141. package/src/lib/record/filter.js.map +1 -1
  142. package/src/lib/record/filter.mjs +1 -1
  143. package/src/lib/record/filter.mjs.map +1 -1
  144. package/src/lib/record/form-approvals.d.mts +47 -0
  145. package/src/lib/record/form-approvals.d.ts +47 -0
  146. package/src/lib/record/form-approvals.js +186 -0
  147. package/src/lib/record/form-approvals.js.map +1 -0
  148. package/src/lib/record/form-approvals.mjs +180 -0
  149. package/src/lib/record/form-approvals.mjs.map +1 -0
  150. package/src/lib/record/form.d.mts +32 -1
  151. package/src/lib/record/form.d.ts +32 -1
  152. package/src/lib/record/form.js +49 -5
  153. package/src/lib/record/form.js.map +1 -1
  154. package/src/lib/record/form.mjs +49 -5
  155. package/src/lib/record/form.mjs.map +1 -1
  156. package/src/lib/record/languages-part.d.mts +32 -0
  157. package/src/lib/record/languages-part.d.ts +32 -0
  158. package/src/lib/record/languages-part.js +104 -0
  159. package/src/lib/record/languages-part.js.map +1 -0
  160. package/src/lib/record/languages-part.mjs +96 -0
  161. package/src/lib/record/languages-part.mjs.map +1 -0
  162. package/src/lib/record/languages.d.mts +26 -0
  163. package/src/lib/record/languages.d.ts +26 -0
  164. package/src/lib/record/languages.js +20 -0
  165. package/src/lib/record/languages.js.map +1 -0
  166. package/src/lib/record/languages.mjs +15 -0
  167. package/src/lib/record/languages.mjs.map +1 -0
  168. package/src/lib/record/locales/ar.js +5 -0
  169. package/src/lib/record/locales/ar.js.map +1 -1
  170. package/src/lib/record/locales/ar.mjs +5 -0
  171. package/src/lib/record/locales/ar.mjs.map +1 -1
  172. package/src/lib/record/locales/de.js +5 -0
  173. package/src/lib/record/locales/de.js.map +1 -1
  174. package/src/lib/record/locales/de.mjs +5 -0
  175. package/src/lib/record/locales/de.mjs.map +1 -1
  176. package/src/lib/record/locales/fr.js +5 -0
  177. package/src/lib/record/locales/fr.js.map +1 -1
  178. package/src/lib/record/locales/fr.mjs +5 -0
  179. package/src/lib/record/locales/fr.mjs.map +1 -1
  180. package/src/lib/record/memory-approvals.d.mts +47 -0
  181. package/src/lib/record/memory-approvals.d.ts +47 -0
  182. package/src/lib/record/memory-approvals.js +78 -0
  183. package/src/lib/record/memory-approvals.js.map +1 -0
  184. package/src/lib/record/memory-approvals.mjs +75 -0
  185. package/src/lib/record/memory-approvals.mjs.map +1 -0
  186. package/src/lib/record/memory-assist.d.mts +53 -0
  187. package/src/lib/record/memory-assist.d.ts +53 -0
  188. package/src/lib/record/memory-assist.js +519 -0
  189. package/src/lib/record/memory-assist.js.map +1 -0
  190. package/src/lib/record/memory-assist.mjs +513 -0
  191. package/src/lib/record/memory-assist.mjs.map +1 -0
  192. package/src/lib/record/memory-clusters.d.mts +18 -0
  193. package/src/lib/record/memory-clusters.d.ts +18 -0
  194. package/src/lib/record/memory-clusters.js +83 -0
  195. package/src/lib/record/memory-clusters.js.map +1 -0
  196. package/src/lib/record/memory-clusters.mjs +80 -0
  197. package/src/lib/record/memory-clusters.mjs.map +1 -0
  198. package/src/lib/record/memory-data-source.d.mts +43 -3
  199. package/src/lib/record/memory-data-source.d.ts +43 -3
  200. package/src/lib/record/memory-data-source.js +105 -19
  201. package/src/lib/record/memory-data-source.js.map +1 -1
  202. package/src/lib/record/memory-data-source.mjs +105 -19
  203. package/src/lib/record/memory-data-source.mjs.map +1 -1
  204. package/src/lib/record/memory-later.d.mts +1 -1
  205. package/src/lib/record/memory-later.d.ts +1 -1
  206. package/src/lib/record/memory-later.js +4 -1
  207. package/src/lib/record/memory-later.js.map +1 -1
  208. package/src/lib/record/memory-later.mjs +4 -1
  209. package/src/lib/record/memory-later.mjs.map +1 -1
  210. package/src/lib/record/messages.d.mts +14 -0
  211. package/src/lib/record/messages.d.ts +14 -0
  212. package/src/lib/record/messages.js +5 -0
  213. package/src/lib/record/messages.js.map +1 -1
  214. package/src/lib/record/messages.mjs +5 -0
  215. package/src/lib/record/messages.mjs.map +1 -1
  216. package/src/lib/record/uploads.d.mts +35 -9
  217. package/src/lib/record/uploads.d.ts +35 -9
  218. package/src/lib/record/uploads.js +49 -169
  219. package/src/lib/record/uploads.js.map +1 -1
  220. package/src/lib/record/uploads.mjs +42 -164
  221. package/src/lib/record/uploads.mjs.map +1 -1
  222. package/src/lib/record/values.d.mts +23 -0
  223. package/src/lib/record/values.d.ts +23 -0
  224. package/src/lib/record/values.js +4 -0
  225. package/src/lib/record/values.js.map +1 -1
  226. package/src/lib/record/values.mjs +4 -0
  227. package/src/lib/record/values.mjs.map +1 -1
  228. package/src/runtime.d.mts +12 -5
  229. package/src/runtime.d.ts +12 -5
  230. package/src/runtime.js +18 -3
  231. package/src/runtime.js.map +1 -1
  232. package/src/runtime.mjs +7 -1
  233. package/src/runtime.mjs.map +1 -1
package/README.md CHANGED
@@ -28,7 +28,7 @@ list of records — that your app implements;
28
28
  The page format is also a JSON Schema, for editors and other languages:
29
29
  `@fieldia/core/page.schema.json`.
30
30
 
31
- A page says which format it is written in (`"fieldia": "0.7"`, `FORMAT_VERSION`; a page in 0.1, 0.2, 0.3, 0.4, 0.5 or 0.6 is read as it is).
31
+ A page says which format it is written in (`"fieldia": "0.8"`, `FORMAT_VERSION`; a page in 0.1, 0.2, 0.3, 0.4, 0.5, 0.6 or 0.7 is read as it is).
32
32
  One in an older format is brought up to date as it is read — by `checkPage`,
33
33
  `validatePage` and `createForm`, so by the viewer and the designer too — and
34
34
  `upgradePage` does it for the pages your app keeps. One newer than this Fieldia
@@ -204,6 +204,33 @@ carries no options from a question: its own, or one of the app's lists — the s
204
204
  `optionsFrom` as a page's own choice (`{ list, dependsOn }`, its `dependsOn` naming
205
205
  the line's columns or `parent.` and a field).
206
206
 
207
+ ## One text in several languages
208
+
209
+ A line, a paragraph or formatted text may keep its text in several languages, each
210
+ typed by a person — Fieldia never translates it (`translate`), and `requiredIn` says
211
+ which a required answer is typed in (every one when left out):
212
+
213
+ ```json
214
+ "title": { "type": "char", "label": "Title", "translate": ["ar", "en"], "required": true, "size": 80 },
215
+ "description": { "type": "text", "label": "Description", "translate": ["ar", "en"], "required": true, "requiredIn": ["en"] }
216
+ ```
217
+
218
+ Its value is an object of each language's text by its tag — `{ "ar": "شقة…", "en":
219
+ "Nile-view flat" }` — a language not typed yet left out, none typed `null`; a plain
220
+ text loaded for it is read as its first language's. The form checks it in each
221
+ language: "Title is required in Arabic" while it is typed in some (`languagesNeeded`,
222
+ or `languagesNeededQuestion` for a label that asks), "Title is required" in none;
223
+ each language held to the field's `size` and `pattern`, named in the problem ("Title
224
+ (English) is 4 characters too long: shorten it to 80"). `textIn(value, reader,
225
+ languages)` reads it as a reader of a language does — theirs where typed, else the
226
+ field's first typed, said to be another's — `languageName(tag, locale)` names a
227
+ language, `checkTranslated` and `languagesAtFault` check it. They come in the
228
+ languages part (`formLanguagesPart`), which a form with such a field asks for as it
229
+ is made and a save waits for; `languagesOf(field)` and `hasLanguages(page)` say
230
+ whether a page has one. A table's line keeps one language. The memory source finds
231
+ such a text by a search in any of its languages, and reads one text — a link's
232
+ name, a list's order — in its `language` option's.
233
+
207
234
  ## A public form's bot check
208
235
 
209
236
  A page of responses anyone may send — a sign-up, a contact form — can check that
@@ -300,6 +327,10 @@ record (`model` and `recordId` are the record's, `field` is where it sits:
300
327
  `consent.deed`), and the record's save waits for them. A file picked while a save
301
328
  is on its way stays a change, to save next. A draft never keeps a file's bytes
302
329
  where the source has `upload`; without it, a draft keeps them, as before.
330
+ The sending itself — each file made ready and sent, its link put in its field —
331
+ is a part of its own (`formUploadsPart`), which comes with @fieldia/widgets'
332
+ files part, or the first time a form sends a file: `form.upload` gives its ids
333
+ at once, each file waiting its turn until the part is in.
303
334
 
304
335
  ```ts
305
336
  import { uploadTo } from '@fieldia/core';
@@ -317,6 +348,16 @@ your words and offers no Retry; any other error offers Retry. Stop with an
317
348
  one. Without `upload`, files travel inside the record as base64, as before.
318
349
  See [files stored as they are picked](https://fieldia.dev/data/#upload).
319
350
 
351
+ A photo set (`"widget": "photos"`, @fieldia/widgets' README) keeps everything in
352
+ the field's value, so any source that keeps a file value keeps it: the photos in
353
+ the order a person put them (the first the cover), a photo's `caption`, and for a
354
+ photo cropped or turned the photo as it was (`original`, a file value of its
355
+ own) and what was done to it (`edit`: `{ turn: 90, crop: { x, y, width, height }
356
+ }`, fractions of the turned original). A photo cropped is stored at once —
357
+ `form.upload(field, [file], { replaces })`: its link takes the place of the
358
+ bytes the field holds for it, with whatever stands beside them by then (a
359
+ caption typed meanwhile).
360
+
320
361
  ## Lists that add up, and filter by time
321
362
 
322
363
  A list asks its source's optional `totals({ model, filter, totals, groupBy?,
@@ -333,6 +374,20 @@ the span a value falls in as the list counts it, and `dayIn` and `dayStarts`
333
374
  a day in a time zone; `createMemoryDataSource` does it all. See
334
375
  [lists that add up](https://fieldia.dev/lists/#totals).
335
376
 
377
+ ## A map's records counted where they crowd
378
+
379
+ A list's map (@fieldia/map) asks its source's optional `clusters({ model,
380
+ filter, field, longitude?, bbox, zoom, radius, fields, weight?, signal })` for
381
+ the view's bubbles — `{ clusters: [{ lat, lng, count, bbox?, weight? }],
382
+ points?: [{ id, values }], unplaced? }` — instead of loading at most 500 records
383
+ and gathering them itself: every record a search finds, however many, a record
384
+ standing alone with its values for its pin and its card. Answer `false` to let
385
+ the map load the search's records, as it does without the member. The memory
386
+ source has it where its `clusters` option says how it answers:
387
+ `createMemoryDataSource({ records, clusters: gridClusters({ models: ['home'] }) })`
388
+ gathers its records by a grid of squares fixed to the world, as a server does.
389
+ See [lists on a map](https://fieldia.dev/lists/#map).
390
+
336
391
  ## Time zones and booking slots
337
392
 
338
393
  A page may name the time zone its dates and times are in, by its IANA name —
@@ -577,6 +632,60 @@ const form = createForm({ page, dataSource, resume: new URLSearchParams(location
577
632
  form.on('draft', ({ key, later, saved }) => later && console.log('Continue from', saved.link));
578
633
  ```
579
634
 
635
+ ## Approvals on a record
636
+
637
+ A record's page may say its records wait for approval:
638
+
639
+ ```json
640
+ { "approval": { "open": ["notes"] } }
641
+ ```
642
+
643
+ The data source tells where a record stands, `approvals({ model, recordId,
644
+ user })` answering `{ levels, history, mine, together, why }` — each level its
645
+ `id`, `name`, `approvers` (each `{ id, name, decision, at }` in the round asked
646
+ now), `needs` (`any`, the default, or `all`) and `state` (`waiting`, `later`,
647
+ `approved`, `rejected`, `skipped`); `history` oldest first (`{ decision:
648
+ 'requested' | 'approved' | 'rejected', level, by, at, reason }`); `mine` the
649
+ levels this person may decide now — and takes the decisions, `decide({ model,
650
+ recordId, level, decision, reason, user })`, a rejection always with why. Who is
651
+ asked, and in what order, is the app's, or its approval engine's: Fieldia never
652
+ works it out. The form asks as a saved record is shown, after each save and each
653
+ decision, keeping what it told in `state.approval` (`status`: `none`, `needed`,
654
+ `waiting`, `approved`, `rejected`); an answer for a record no longer shown is
655
+ laid on none. While it waits, every field is read-only but those `open` names
656
+ (`form.node(id).readonly`, `form.fieldReadonly`), `form.approvalLock(name)`
657
+ saying why; `"lock": false` locks none. `form.decide(level, decision, reason?)`
658
+ reads and saves what is typed first, then decides, then loads the record again;
659
+ it refuses a level not this person's and a rejection with no reason, in words.
660
+ The memory source's `approvals` option routes records as an engine would (in
661
+ turn or together, any or all, a rejection ending the round), keeping each
662
+ decision; `approvalHistory` is what it starts from.
663
+
664
+ ```ts
665
+ await form.decide('finance', 'rejected', 'Over the quarter’s budget');
666
+ form.getState().approval?.status; // 'rejected'
667
+ ```
668
+
669
+ ## AI help: values proposed, words written, a search read
670
+
671
+ Three optional members answer with the app's own model — Fieldia ships no model
672
+ and no keys. `suggest({ page, values, fields, from: { text?, files? } })` gives
673
+ values for a form (a page's `suggest`: `fields`, `label`, `from`, `fromField`),
674
+ a table's lines to add among them; `rewrite({ field, how, text, values })` a
675
+ text field's words (its node's `options.rewrite`: `"draft"`, `"polish"`, or
676
+ `{ "how", "label" }`); `searchToFilter({ text, fields })` a list's conditions
677
+ (its `searchToFilter`). The viewer shows each value on its field to accept or
678
+ reject first, and Undo after; `checkPage` and `validatePage` check the settings.
679
+ The memory source has each member only where its `assist` option answers it;
680
+ `assistStandIn({ drafts })` is a stand-in for demos and tests — no model, words
681
+ read by their patterns, every answer saying so ("Stand-in AI, no model: …"):
682
+
683
+ ```ts
684
+ import { assistStandIn, createMemoryDataSource } from '@fieldia/core';
685
+
686
+ const dataSource = createMemoryDataSource({ records, assist: assistStandIn({ drafts: { 'enquiry.reply': (values) => `Dear ${values.partner_name},` } }) });
687
+ ```
688
+
580
689
  ## What a page's records are called
581
690
 
582
691
  A page may say what its records are, so Fieldia's own sentences name them as
@@ -744,6 +853,21 @@ fields); `importFields(page, list)` says which fields a file's columns may fill.
744
853
  `createMemoryDataSource` gives `createMany`. See [many records made at
745
854
  once](https://fieldia.dev/data/#import).
746
855
 
856
+ ## A record found by a code a scanner read
857
+
858
+ A link scanned into with the camera (`options.scan` on a many2one or a table's
859
+ link column, drawn by @fieldia/widgets' scan part) finds the record a code names
860
+ through the data source's `search`, with no member of its own:
861
+ `form.search(field, code, 2, { field: 'barcode' })` asks for the records whose
862
+ `barcode` holds the code exactly — the field's own filter kept, the condition
863
+ added to it, the query empty — and `form.searchLine(…)` the same for a line's
864
+ link. Without a field named, the code is searched as a name, the exact name
865
+ first. The page check holds `options.scan` to a kind a code is written into —
866
+ a char, a text, a many2one, or a one2many counted by a column (`field`) and a
867
+ number (`count`) — and the fields a GS1 code fills (`fills`) to fields of the
868
+ page, or of the line, that take a code's part; `ScanOptionSchema`
869
+ gives its shape. See [scanning a code](https://fieldia.dev/fields/#scan).
870
+
747
871
  ## A saved form placed in another
748
872
 
749
873
  A block made once — an address, a contact person, a consent — is a page of its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fieldia/core",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "Headless form model for Fieldia: the page format, modifiers, validation and record state. No DOM.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://fieldia.dev",
@@ -11,7 +11,8 @@
11
11
  "0.4",
12
12
  "0.5",
13
13
  "0.6",
14
- "0.7"
14
+ "0.7",
15
+ "0.8"
15
16
  ]
16
17
  },
17
18
  "id": {
@@ -389,6 +390,12 @@
389
390
  },
390
391
  "continueLater": {
391
392
  "type": "boolean"
393
+ },
394
+ "approval": {
395
+ "$ref": "#/$defs/PageApproval"
396
+ },
397
+ "suggest": {
398
+ "$ref": "#/$defs/PageSuggest"
392
399
  }
393
400
  },
394
401
  "required": [
@@ -452,13 +459,36 @@
452
459
  "patternHint": {
453
460
  "type": "string",
454
461
  "minLength": 1
462
+ },
463
+ "translate": {
464
+ "minItems": 2,
465
+ "type": "array",
466
+ "items": {
467
+ "$ref": "#/$defs/LanguageTag"
468
+ },
469
+ "uniqueItems": true
470
+ },
471
+ "requiredIn": {
472
+ "minItems": 1,
473
+ "type": "array",
474
+ "items": {
475
+ "$ref": "#/$defs/LanguageTag"
476
+ },
477
+ "uniqueItems": true
455
478
  }
456
479
  },
457
480
  "required": [
458
481
  "type",
459
482
  "label"
460
483
  ],
461
- "additionalProperties": false
484
+ "additionalProperties": false,
485
+ "dependentSchemas": {
486
+ "requiredIn": {
487
+ "required": [
488
+ "translate"
489
+ ]
490
+ }
491
+ }
462
492
  },
463
493
  {
464
494
  "type": "object",
@@ -501,13 +531,36 @@
501
531
  "type": "integer",
502
532
  "exclusiveMinimum": 0,
503
533
  "maximum": 9007199254740991
534
+ },
535
+ "translate": {
536
+ "minItems": 2,
537
+ "type": "array",
538
+ "items": {
539
+ "$ref": "#/$defs/LanguageTag"
540
+ },
541
+ "uniqueItems": true
542
+ },
543
+ "requiredIn": {
544
+ "minItems": 1,
545
+ "type": "array",
546
+ "items": {
547
+ "$ref": "#/$defs/LanguageTag"
548
+ },
549
+ "uniqueItems": true
504
550
  }
505
551
  },
506
552
  "required": [
507
553
  "type",
508
554
  "label"
509
555
  ],
510
- "additionalProperties": false
556
+ "additionalProperties": false,
557
+ "dependentSchemas": {
558
+ "requiredIn": {
559
+ "required": [
560
+ "translate"
561
+ ]
562
+ }
563
+ }
511
564
  },
512
565
  {
513
566
  "type": "object",
@@ -545,13 +598,36 @@
545
598
  "items": {
546
599
  "$ref": "#/$defs/SetWhen"
547
600
  }
601
+ },
602
+ "translate": {
603
+ "minItems": 2,
604
+ "type": "array",
605
+ "items": {
606
+ "$ref": "#/$defs/LanguageTag"
607
+ },
608
+ "uniqueItems": true
609
+ },
610
+ "requiredIn": {
611
+ "minItems": 1,
612
+ "type": "array",
613
+ "items": {
614
+ "$ref": "#/$defs/LanguageTag"
615
+ },
616
+ "uniqueItems": true
548
617
  }
549
618
  },
550
619
  "required": [
551
620
  "type",
552
621
  "label"
553
622
  ],
554
- "additionalProperties": false
623
+ "additionalProperties": false,
624
+ "dependentSchemas": {
625
+ "requiredIn": {
626
+ "required": [
627
+ "translate"
628
+ ]
629
+ }
630
+ }
555
631
  },
556
632
  {
557
633
  "type": "object",
@@ -1684,6 +1760,17 @@
1684
1760
  }
1685
1761
  ]
1686
1762
  },
1763
+ "LanguageTag": {
1764
+ "type": "string",
1765
+ "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$",
1766
+ "description": "A language by its BCP 47 tag.",
1767
+ "examples": [
1768
+ "ar",
1769
+ "en",
1770
+ "fr",
1771
+ "pt-BR"
1772
+ ]
1773
+ },
1687
1774
  "MoneyLook": {
1688
1775
  "type": "object",
1689
1776
  "properties": {
@@ -2014,13 +2101,36 @@
2014
2101
  "patternHint": {
2015
2102
  "type": "string",
2016
2103
  "minLength": 1
2104
+ },
2105
+ "translate": {
2106
+ "minItems": 2,
2107
+ "type": "array",
2108
+ "items": {
2109
+ "$ref": "#/$defs/LanguageTag"
2110
+ },
2111
+ "uniqueItems": true
2112
+ },
2113
+ "requiredIn": {
2114
+ "minItems": 1,
2115
+ "type": "array",
2116
+ "items": {
2117
+ "$ref": "#/$defs/LanguageTag"
2118
+ },
2119
+ "uniqueItems": true
2017
2120
  }
2018
2121
  },
2019
2122
  "required": [
2020
2123
  "type",
2021
2124
  "label"
2022
2125
  ],
2023
- "additionalProperties": false
2126
+ "additionalProperties": false,
2127
+ "dependentSchemas": {
2128
+ "requiredIn": {
2129
+ "required": [
2130
+ "translate"
2131
+ ]
2132
+ }
2133
+ }
2024
2134
  },
2025
2135
  {
2026
2136
  "type": "object",
@@ -2063,13 +2173,36 @@
2063
2173
  "type": "integer",
2064
2174
  "exclusiveMinimum": 0,
2065
2175
  "maximum": 9007199254740991
2176
+ },
2177
+ "translate": {
2178
+ "minItems": 2,
2179
+ "type": "array",
2180
+ "items": {
2181
+ "$ref": "#/$defs/LanguageTag"
2182
+ },
2183
+ "uniqueItems": true
2184
+ },
2185
+ "requiredIn": {
2186
+ "minItems": 1,
2187
+ "type": "array",
2188
+ "items": {
2189
+ "$ref": "#/$defs/LanguageTag"
2190
+ },
2191
+ "uniqueItems": true
2066
2192
  }
2067
2193
  },
2068
2194
  "required": [
2069
2195
  "type",
2070
2196
  "label"
2071
2197
  ],
2072
- "additionalProperties": false
2198
+ "additionalProperties": false,
2199
+ "dependentSchemas": {
2200
+ "requiredIn": {
2201
+ "required": [
2202
+ "translate"
2203
+ ]
2204
+ }
2205
+ }
2073
2206
  },
2074
2207
  {
2075
2208
  "type": "object",
@@ -2659,6 +2792,12 @@
2659
2792
  "patternHint": {
2660
2793
  "type": "string",
2661
2794
  "minLength": 1
2795
+ },
2796
+ "translate": {
2797
+ "not": {}
2798
+ },
2799
+ "requiredIn": {
2800
+ "not": {}
2662
2801
  }
2663
2802
  },
2664
2803
  "required": [
@@ -2708,6 +2847,12 @@
2708
2847
  "type": "integer",
2709
2848
  "exclusiveMinimum": 0,
2710
2849
  "maximum": 9007199254740991
2850
+ },
2851
+ "translate": {
2852
+ "not": {}
2853
+ },
2854
+ "requiredIn": {
2855
+ "not": {}
2711
2856
  }
2712
2857
  },
2713
2858
  "required": [
@@ -2752,6 +2897,12 @@
2752
2897
  "items": {
2753
2898
  "$ref": "#/$defs/SetWhen"
2754
2899
  }
2900
+ },
2901
+ "translate": {
2902
+ "not": {}
2903
+ },
2904
+ "requiredIn": {
2905
+ "not": {}
2755
2906
  }
2756
2907
  },
2757
2908
  "required": [
@@ -3859,6 +4010,12 @@
3859
4010
  "patternHint": {
3860
4011
  "type": "string",
3861
4012
  "minLength": 1
4013
+ },
4014
+ "translate": {
4015
+ "not": {}
4016
+ },
4017
+ "requiredIn": {
4018
+ "not": {}
3862
4019
  }
3863
4020
  },
3864
4021
  "required": [
@@ -3908,6 +4065,12 @@
3908
4065
  "type": "integer",
3909
4066
  "exclusiveMinimum": 0,
3910
4067
  "maximum": 9007199254740991
4068
+ },
4069
+ "translate": {
4070
+ "not": {}
4071
+ },
4072
+ "requiredIn": {
4073
+ "not": {}
3911
4074
  }
3912
4075
  },
3913
4076
  "required": [
@@ -3952,6 +4115,12 @@
3952
4115
  "items": {
3953
4116
  "$ref": "#/$defs/SetWhen"
3954
4117
  }
4118
+ },
4119
+ "translate": {
4120
+ "not": {}
4121
+ },
4122
+ "requiredIn": {
4123
+ "not": {}
3955
4124
  }
3956
4125
  },
3957
4126
  "required": [
@@ -9541,6 +9710,9 @@
9541
9710
  "filterSheet": {
9542
9711
  "type": "boolean"
9543
9712
  },
9713
+ "searchToFilter": {
9714
+ "type": "boolean"
9715
+ },
9544
9716
  "parentField": {
9545
9717
  "type": "string",
9546
9718
  "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
@@ -9723,6 +9895,16 @@
9723
9895
  ],
9724
9896
  "additionalProperties": false
9725
9897
  }
9898
+ },
9899
+ "editable": {
9900
+ "anyOf": [
9901
+ {
9902
+ "type": "boolean"
9903
+ },
9904
+ {
9905
+ "$ref": "#/$defs/ListEditable"
9906
+ }
9907
+ ]
9726
9908
  }
9727
9909
  },
9728
9910
  "required": [
@@ -10025,6 +10207,26 @@
10025
10207
  },
10026
10208
  "additionalProperties": false
10027
10209
  },
10210
+ "ListEditable": {
10211
+ "type": "object",
10212
+ "properties": {
10213
+ "fields": {
10214
+ "minItems": 1,
10215
+ "type": "array",
10216
+ "items": {
10217
+ "type": "string",
10218
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
10219
+ }
10220
+ },
10221
+ "add": {
10222
+ "type": "boolean"
10223
+ },
10224
+ "open": {
10225
+ "type": "boolean"
10226
+ }
10227
+ },
10228
+ "additionalProperties": false
10229
+ },
10028
10230
  "PageEvents": {
10029
10231
  "type": "object",
10030
10232
  "properties": {
@@ -10242,6 +10444,61 @@
10242
10444
  }
10243
10445
  },
10244
10446
  "additionalProperties": false
10447
+ },
10448
+ "PageApproval": {
10449
+ "type": "object",
10450
+ "properties": {
10451
+ "open": {
10452
+ "type": "array",
10453
+ "items": {
10454
+ "type": "string",
10455
+ "minLength": 1
10456
+ }
10457
+ },
10458
+ "lock": {
10459
+ "type": "boolean"
10460
+ }
10461
+ },
10462
+ "additionalProperties": false
10463
+ },
10464
+ "PageSuggest": {
10465
+ "type": "object",
10466
+ "properties": {
10467
+ "fields": {
10468
+ "minItems": 1,
10469
+ "type": "array",
10470
+ "items": {
10471
+ "type": "string",
10472
+ "minLength": 1
10473
+ }
10474
+ },
10475
+ "from": {
10476
+ "minItems": 1,
10477
+ "type": "array",
10478
+ "items": {
10479
+ "type": "string",
10480
+ "enum": [
10481
+ "text",
10482
+ "files"
10483
+ ]
10484
+ }
10485
+ },
10486
+ "label": {
10487
+ "type": "string",
10488
+ "minLength": 1,
10489
+ "maxLength": 60
10490
+ },
10491
+ "placeholder": {
10492
+ "type": "string",
10493
+ "minLength": 1,
10494
+ "maxLength": 200
10495
+ },
10496
+ "fromField": {
10497
+ "type": "string",
10498
+ "minLength": 1
10499
+ }
10500
+ },
10501
+ "additionalProperties": false
10245
10502
  }
10246
10503
  }
10247
10504
  }
package/src/index.d.mts CHANGED
@@ -1,11 +1,14 @@
1
1
  export * from './runtime.mjs';
2
2
  export { takingWords, whenWords } from './lib/record/form-limits.mjs';
3
3
  export { isQuestion } from './lib/record/record-words.mjs';
4
+ export { checkTranslated, languageName, languagesAtFault, textIn, textOf } from './lib/record/languages-part.mjs';
4
5
  export { dayWords } from './lib/record/day-words.mjs';
5
6
  export { scheduleSlots, type MemorySchedule } from './lib/record/memory-schedules.mjs';
6
7
  export { alikeRecords, nameLikeness } from './lib/record/memory-duplicates.mjs';
7
- export { FieldSchema, FieldsSchema, LineFieldSchema, LinkedFieldSchema, LineKindsSchema, OptionSchema, PropertyDefinitionSchema, FilterConditionSchema, FilterItemSchema, MoneyLookSchema, ShrinkSchema, PERIODS, TimeZoneSchema, } from './lib/format/field.mjs';
8
- export { ModifierSchema, RolesSchema, CellRulesSchema, ToneWhenSchema, LayoutNodeSchema, RootLayoutSchema, ListNodeSchema, ListCellSchema, ListCalendarSchema, ListCardSchema, ListGallerySchema, FilterRangeSchema, FilterPeriodSchema, RelatedNodeSchema } from './lib/format/layout.mjs';
8
+ export { assistStandIn, polishText, readSignature, standInNumber, type StandInFound, type StandInOptions } from './lib/record/memory-assist.mjs';
9
+ export { gridClusters } from './lib/record/memory-clusters.mjs';
10
+ export { FieldSchema, FieldsSchema, LanguageTagSchema, LineFieldSchema, LinkedFieldSchema, LineKindsSchema, OptionSchema, PropertyDefinitionSchema, FilterConditionSchema, FilterItemSchema, MoneyLookSchema, ShrinkSchema, PERIODS, TimeZoneSchema, } from './lib/format/field.mjs';
11
+ export { ModifierSchema, RolesSchema, CellRulesSchema, ToneWhenSchema, LayoutNodeSchema, RootLayoutSchema, ListNodeSchema, ListCellSchema, ListCalendarSchema, ListCardSchema, ListGallerySchema, ListEditableSchema, FilterRangeSchema, FilterPeriodSchema, RelatedNodeSchema } from './lib/format/layout.mjs';
9
12
  export { PageSchema } from './lib/format/page.mjs';
10
13
  export { ActionStepSchema, PageEventsSchema } from './lib/format/actions.mjs';
11
14
  export { pageWarnings, validatePage } from './lib/format/validate.mjs';
@@ -16,10 +19,13 @@ export { PathPickerOptionsSchema, StateDotOptionsSchema } from './lib/format/pic
16
19
  export { PagePhoneSchema, PhoneOptionsSchema } from './lib/format/phone.mjs';
17
20
  export { SlotsOptionsSchema } from './lib/format/slots-options.mjs';
18
21
  export { SignatureOptionsSchema } from './lib/format/signature-options.mjs';
22
+ export { PhotosOptionsSchema } from './lib/format/photos-options.mjs';
23
+ export { SCAN_FORMATS, ScanFillSchema, ScanOptionSchema, ScanSettingsSchema } from './lib/format/scan-options.mjs';
19
24
  export { PageDuplicatesSchema } from './lib/format/duplicates.mjs';
20
25
  export { PageRecordsSchema } from './lib/format/records.mjs';
21
26
  export { PageEndingSchema } from './lib/format/endings.mjs';
22
27
  export { PageLimitsSchema } from './lib/format/limits.mjs';
28
+ export { PageApprovalSchema } from './lib/format/approval.mjs';
23
29
  export { DUPLICATE_KINDS, comparable } from './lib/format/duplicate-kinds.mjs';
24
30
  export { pageJsonSchema } from './lib/format/json-schema.mjs';
25
31
  export { AUTOFILL, AUTOFILL_CONTACT, AUTOFILL_NAMES, autofillProblem, autofillPurpose } from './lib/format/autofill.mjs';
package/src/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  export * from './runtime';
2
2
  export { takingWords, whenWords } from './lib/record/form-limits';
3
3
  export { isQuestion } from './lib/record/record-words';
4
+ export { checkTranslated, languageName, languagesAtFault, textIn, textOf } from './lib/record/languages-part';
4
5
  export { dayWords } from './lib/record/day-words';
5
6
  export { scheduleSlots, type MemorySchedule } from './lib/record/memory-schedules';
6
7
  export { alikeRecords, nameLikeness } from './lib/record/memory-duplicates';
7
- export { FieldSchema, FieldsSchema, LineFieldSchema, LinkedFieldSchema, LineKindsSchema, OptionSchema, PropertyDefinitionSchema, FilterConditionSchema, FilterItemSchema, MoneyLookSchema, ShrinkSchema, PERIODS, TimeZoneSchema, } from './lib/format/field';
8
- export { ModifierSchema, RolesSchema, CellRulesSchema, ToneWhenSchema, LayoutNodeSchema, RootLayoutSchema, ListNodeSchema, ListCellSchema, ListCalendarSchema, ListCardSchema, ListGallerySchema, FilterRangeSchema, FilterPeriodSchema, RelatedNodeSchema } from './lib/format/layout';
8
+ export { assistStandIn, polishText, readSignature, standInNumber, type StandInFound, type StandInOptions } from './lib/record/memory-assist';
9
+ export { gridClusters } from './lib/record/memory-clusters';
10
+ export { FieldSchema, FieldsSchema, LanguageTagSchema, LineFieldSchema, LinkedFieldSchema, LineKindsSchema, OptionSchema, PropertyDefinitionSchema, FilterConditionSchema, FilterItemSchema, MoneyLookSchema, ShrinkSchema, PERIODS, TimeZoneSchema, } from './lib/format/field';
11
+ export { ModifierSchema, RolesSchema, CellRulesSchema, ToneWhenSchema, LayoutNodeSchema, RootLayoutSchema, ListNodeSchema, ListCellSchema, ListCalendarSchema, ListCardSchema, ListGallerySchema, ListEditableSchema, FilterRangeSchema, FilterPeriodSchema, RelatedNodeSchema } from './lib/format/layout';
9
12
  export { PageSchema } from './lib/format/page';
10
13
  export { ActionStepSchema, PageEventsSchema } from './lib/format/actions';
11
14
  export { pageWarnings, validatePage } from './lib/format/validate';
@@ -16,10 +19,13 @@ export { PathPickerOptionsSchema, StateDotOptionsSchema } from './lib/format/pic
16
19
  export { PagePhoneSchema, PhoneOptionsSchema } from './lib/format/phone';
17
20
  export { SlotsOptionsSchema } from './lib/format/slots-options';
18
21
  export { SignatureOptionsSchema } from './lib/format/signature-options';
22
+ export { PhotosOptionsSchema } from './lib/format/photos-options';
23
+ export { SCAN_FORMATS, ScanFillSchema, ScanOptionSchema, ScanSettingsSchema } from './lib/format/scan-options';
19
24
  export { PageDuplicatesSchema } from './lib/format/duplicates';
20
25
  export { PageRecordsSchema } from './lib/format/records';
21
26
  export { PageEndingSchema } from './lib/format/endings';
22
27
  export { PageLimitsSchema } from './lib/format/limits';
28
+ export { PageApprovalSchema } from './lib/format/approval';
23
29
  export { DUPLICATE_KINDS, comparable } from './lib/format/duplicate-kinds';
24
30
  export { pageJsonSchema } from './lib/format/json-schema';
25
31
  export { AUTOFILL, AUTOFILL_CONTACT, AUTOFILL_NAMES, autofillProblem, autofillPurpose } from './lib/format/autofill';