@fieldia/core 0.21.0 → 0.22.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 (127) hide show
  1. package/README.md +116 -1
  2. package/package.json +1 -1
  3. package/schema/page.schema.json +149 -1
  4. package/src/index.d.mts +2 -2
  5. package/src/index.d.ts +2 -2
  6. package/src/index.js +3 -1
  7. package/src/index.js.map +1 -1
  8. package/src/index.mjs +2 -2
  9. package/src/index.mjs.map +1 -1
  10. package/src/lib/format/check-page.d.mts +3 -2
  11. package/src/lib/format/check-page.d.ts +3 -2
  12. package/src/lib/format/check-page.js +9 -4
  13. package/src/lib/format/check-page.js.map +1 -1
  14. package/src/lib/format/check-page.mjs +10 -5
  15. package/src/lib/format/check-page.mjs.map +1 -1
  16. package/src/lib/format/field.d.mts +85 -0
  17. package/src/lib/format/field.d.ts +85 -0
  18. package/src/lib/format/field.js +14 -1
  19. package/src/lib/format/field.js.map +1 -1
  20. package/src/lib/format/field.mjs +13 -0
  21. package/src/lib/format/field.mjs.map +1 -1
  22. package/src/lib/format/layout.d.mts +142 -17
  23. package/src/lib/format/layout.d.ts +142 -17
  24. package/src/lib/format/layout.js +18 -1
  25. package/src/lib/format/layout.js.map +1 -1
  26. package/src/lib/format/layout.mjs +17 -0
  27. package/src/lib/format/layout.mjs.map +1 -1
  28. package/src/lib/format/layout.types.d.mts +6 -2
  29. package/src/lib/format/layout.types.d.ts +6 -2
  30. package/src/lib/format/page.d.mts +69 -10
  31. package/src/lib/format/page.d.ts +69 -10
  32. package/src/lib/format/page.js +4 -1
  33. package/src/lib/format/page.js.map +1 -1
  34. package/src/lib/format/page.mjs +5 -2
  35. package/src/lib/format/page.mjs.map +1 -1
  36. package/src/lib/format/references.d.mts +7 -0
  37. package/src/lib/format/references.d.ts +7 -0
  38. package/src/lib/format/references.js +46 -0
  39. package/src/lib/format/references.js.map +1 -1
  40. package/src/lib/format/references.mjs +46 -0
  41. package/src/lib/format/references.mjs.map +1 -1
  42. package/src/lib/format/translate.js +3 -2
  43. package/src/lib/format/translate.js.map +1 -1
  44. package/src/lib/format/translate.mjs +3 -2
  45. package/src/lib/format/translate.mjs.map +1 -1
  46. package/src/lib/format/upgrade.d.mts +41 -0
  47. package/src/lib/format/upgrade.d.ts +41 -0
  48. package/src/lib/format/upgrade.js +41 -0
  49. package/src/lib/format/upgrade.js.map +1 -0
  50. package/src/lib/format/upgrade.mjs +37 -0
  51. package/src/lib/format/upgrade.mjs.map +1 -0
  52. package/src/lib/format/validate.d.mts +2 -1
  53. package/src/lib/format/validate.d.ts +2 -1
  54. package/src/lib/format/validate.js +4 -2
  55. package/src/lib/format/validate.js.map +1 -1
  56. package/src/lib/format/validate.mjs +4 -2
  57. package/src/lib/format/validate.mjs.map +1 -1
  58. package/src/lib/format/version.d.mts +16 -1
  59. package/src/lib/format/version.d.ts +16 -1
  60. package/src/lib/format/version.js +39 -2
  61. package/src/lib/format/version.js.map +1 -1
  62. package/src/lib/format/version.mjs +36 -1
  63. package/src/lib/format/version.mjs.map +1 -1
  64. package/src/lib/record/data-source.d.mts +224 -10
  65. package/src/lib/record/data-source.d.ts +224 -10
  66. package/src/lib/record/data-source.js +29 -0
  67. package/src/lib/record/data-source.js.map +1 -1
  68. package/src/lib/record/data-source.mjs +25 -0
  69. package/src/lib/record/data-source.mjs.map +1 -1
  70. package/src/lib/record/form.d.mts +144 -5
  71. package/src/lib/record/form.d.ts +144 -5
  72. package/src/lib/record/form.js +792 -42
  73. package/src/lib/record/form.js.map +1 -1
  74. package/src/lib/record/form.mjs +791 -43
  75. package/src/lib/record/form.mjs.map +1 -1
  76. package/src/lib/record/locales/ar.js +10 -0
  77. package/src/lib/record/locales/ar.js.map +1 -1
  78. package/src/lib/record/locales/ar.mjs +10 -0
  79. package/src/lib/record/locales/ar.mjs.map +1 -1
  80. package/src/lib/record/locales/de.js +10 -0
  81. package/src/lib/record/locales/de.js.map +1 -1
  82. package/src/lib/record/locales/de.mjs +10 -0
  83. package/src/lib/record/locales/de.mjs.map +1 -1
  84. package/src/lib/record/locales/fr.js +10 -0
  85. package/src/lib/record/locales/fr.js.map +1 -1
  86. package/src/lib/record/locales/fr.mjs +10 -0
  87. package/src/lib/record/locales/fr.mjs.map +1 -1
  88. package/src/lib/record/memory-data-source.d.mts +40 -3
  89. package/src/lib/record/memory-data-source.d.ts +40 -3
  90. package/src/lib/record/memory-data-source.js +164 -20
  91. package/src/lib/record/memory-data-source.js.map +1 -1
  92. package/src/lib/record/memory-data-source.mjs +164 -20
  93. package/src/lib/record/memory-data-source.mjs.map +1 -1
  94. package/src/lib/record/messages.d.mts +21 -0
  95. package/src/lib/record/messages.d.ts +21 -0
  96. package/src/lib/record/messages.js +10 -0
  97. package/src/lib/record/messages.js.map +1 -1
  98. package/src/lib/record/messages.mjs +10 -0
  99. package/src/lib/record/messages.mjs.map +1 -1
  100. package/src/lib/record/run.d.mts +50 -7
  101. package/src/lib/record/run.d.ts +50 -7
  102. package/src/lib/record/run.js +67 -20
  103. package/src/lib/record/run.js.map +1 -1
  104. package/src/lib/record/run.mjs +67 -20
  105. package/src/lib/record/run.mjs.map +1 -1
  106. package/src/lib/record/upload-to.d.mts +50 -0
  107. package/src/lib/record/upload-to.d.ts +50 -0
  108. package/src/lib/record/upload-to.js +117 -0
  109. package/src/lib/record/upload-to.js.map +1 -0
  110. package/src/lib/record/upload-to.mjs +114 -0
  111. package/src/lib/record/upload-to.mjs.map +1 -0
  112. package/src/lib/record/uploads.d.mts +152 -0
  113. package/src/lib/record/uploads.d.ts +152 -0
  114. package/src/lib/record/uploads.js +345 -0
  115. package/src/lib/record/uploads.js.map +1 -0
  116. package/src/lib/record/uploads.mjs +337 -0
  117. package/src/lib/record/uploads.mjs.map +1 -0
  118. package/src/lib/record/values.d.mts +6 -0
  119. package/src/lib/record/values.d.ts +6 -0
  120. package/src/lib/record/values.js.map +1 -1
  121. package/src/lib/record/values.mjs.map +1 -1
  122. package/src/runtime.d.mts +10 -6
  123. package/src/runtime.d.ts +10 -6
  124. package/src/runtime.js +19 -2
  125. package/src/runtime.js.map +1 -1
  126. package/src/runtime.mjs +7 -3
  127. package/src/runtime.mjs.map +1 -1
package/README.md CHANGED
@@ -28,6 +28,24 @@ 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.2"`, `FORMAT_VERSION`; a page in 0.1 is read as it is).
32
+ One in an older format is brought up to date as it is read — by `checkPage`,
33
+ `validatePage` and `createForm`, so by the viewer and the designer too — and
34
+ `upgradePage` does it for the pages your app keeps. One newer than this Fieldia
35
+ is refused with words that say so ("this page is in format 0.2, newer than this
36
+ Fieldia reads (0.1): update Fieldia to show it"):
37
+
38
+ ```ts
39
+ import { upgradePage } from '@fieldia/core';
40
+
41
+ const page = upgradePage(stored); // the same object when it is already current; a copy brought up step by step if not
42
+ if (page !== stored) await save(page);
43
+ ```
44
+
45
+ A release that renames or reshapes a setting adds a step to `PAGE_UPGRADES`,
46
+ with a page before and after it that the tests run. What each release changed is
47
+ in the [changelog](https://github.com/fieldia-dev/fieldia/blob/main/CHANGELOG.md).
48
+
31
49
  A page's `look` sets its accent, font, spacing, corners, labels and light or
32
50
  dark scheme, and, under `parts`, a look for each kind of part over it — the
33
51
  settings each kind has are `PART_LOOKS`:
@@ -45,6 +63,100 @@ settings each kind has are `PART_LOOKS`:
45
63
  }
46
64
  ```
47
65
 
66
+ ## Files stored as they are picked
67
+
68
+ Give the data source `upload(file, request)` and a file or picture field sends
69
+ each file to your store as soon as it is picked; the record keeps only the link
70
+ it returns — `{ url, name, size, type, fileId }`. `form.upload(field, files)`
71
+ does it for a widget of your own: `state.uploads` shows each on its way (its
72
+ `status` and the bytes `sent` of `total`), three at a time, in the order picked,
73
+ and `form.uploading(field)` gives one field's own;
74
+ `form.cancelUpload(id)` and `form.retryUpload(id)` stop one and send a failed
75
+ one again. A file picked in a table's cell goes as its line's (`request.line`). `form.save()` waits for those still going, stops under the field for
76
+ one that failed, and stores bytes still in the record (a signature drawn) first.
77
+ A saved form placed in a record keeps to the same: its files are stored for the
78
+ record (`model` and `recordId` are the record's, `field` is where it sits:
79
+ `consent.deed`), and the record's save waits for them. A file picked while a save
80
+ is on its way stays a change, to save next. A draft never keeps a file's bytes
81
+ where the source has `upload`; without it, a draft keeps them, as before.
82
+
83
+ ```ts
84
+ import { uploadTo } from '@fieldia/core';
85
+
86
+ // A POST of a form with the file under `file`; its link from the answer's JSON `url`.
87
+ const dataSource = { ...yourDataSource, upload: uploadTo({ url: '/api/files', headers: { 'X-CSRF-Token': token } }) };
88
+ // Or a PUT to an address your server signs (Azure Blob's SAS): the link kept without the signature.
89
+ const toAzure = uploadTo({ method: 'PUT', url: (file) => signedAddress(file.name), headers: { 'x-ms-blob-type': 'BlockBlob' } });
90
+ ```
91
+
92
+ To refuse a file, throw `saveRefused({ kind: 'rule', message })`: the field shows
93
+ your words and offers no Retry; any other error offers Retry. Stop with an
94
+ `AbortError` when `request.signal` aborts. `createMemoryDataSource({ storage:
95
+ { bytesPerSecond, fails } })` is a store as slow, or as unreliable, as a real
96
+ one. Without `upload`, files travel inside the record as base64, as before.
97
+ See [files stored as they are picked](https://fieldia.dev/data/#upload).
98
+
99
+ ## Two people, one record
100
+
101
+ A source that keeps versions returns each record with its version, and what this
102
+ person may do with it, through `loadedRecord`. The form sends the version back
103
+ with each save; a source that finds the record changed since throws a
104
+ `ConflictError` naming who changed it and when:
105
+
106
+ ```ts
107
+ import { ConflictError, loadedRecord } from '@fieldia/core';
108
+
109
+ async load({ model, id }) {
110
+ const row = await api.read(model, id);
111
+ return loadedRecord(row.values, {
112
+ version: { token: row.etag, by: row.changedBy, at: row.changedAt },
113
+ can: { edit: row.isMine, delete: false, readonlyFields: ['commission'], reason: 'Only Mona can change it.' },
114
+ });
115
+ },
116
+ async save({ model, id, changes, version }) {
117
+ const response = await api.write(model, id, changes.values, { ifMatch: version?.token });
118
+ if (response.status === 409) throw new ConflictError({ version: response.body.version, theirs: response.body.values });
119
+ return { id, version: response.body.version };
120
+ },
121
+ ```
122
+
123
+ The form keeps it in its state — `version`, `can`, and after a refused save
124
+ `conflict` (who, when, the fields they changed and those both changed) — and
125
+ offers the two ways on: `form.reloadTheirs()` loads the record as they left it
126
+ and sets this person's changes aside in `setAside`, each put back with
127
+ `form.putBack(field)`; `form.keepMine()` saves them over the record as it is
128
+ now, their values kept wherever this person changed nothing (read again first
129
+ when the conflict did not carry the record, so `values` never wipes theirs; when
130
+ it cannot be read, nothing is saved and `conflict.unread` says so). A second save
131
+ while one is on its way waits for it and carries the version it got back.
132
+ Every way a form's values go — `openRecord` (the pager, an action's answer
133
+ naming a record, Duplicate's copy), a reload (the step, an answer's
134
+ `reload: true`, `form.load()` again), a `reset` step, the host's `close` (yours
135
+ too: the form takes it once, where it is made) — goes through one check,
136
+ `form.leave()`. It first waits for a save on its way and files on theirs
137
+ (`state.leaving` meanwhile, so the page can say so; a second way out joins that
138
+ wait), then looks at the record as it is now. A save's answer lands only on the
139
+ record it was started for: one shown in its place meanwhile never gets its
140
+ values. It asks only about the person's work at risk (`workAtRisk(state)`):
141
+ each change of theirs the last finished save of the record did not send —
142
+ typed while it was on its way, while the run that saved went on, or since
143
+ (`state.unsent`, told against the record as that save left it; a value set by
144
+ a step, a rule, a compute or your app is never theirs) — a file the store holds
145
+ that no save sent, files still on their way, and changes Reload set aside. Then
146
+ it asks "Discard your changes?" through the host's `ask(message, { discard:
147
+ true })`, or `confirm`; Cancel keeps the person where they are, and with
148
+ neither to ask with the work is kept. Before a record's first save, every way
149
+ out behaves as it did in 0.20: a change not saved goes where a step leaves the
150
+ record. `form.leaveNow()` says whether a way out can go at once. Call
151
+ `form.leave()` before your app's own ways out — a route change, an unmount —
152
+ and `unsavedWork(state)` (any change, file or change set aside) for a browser's
153
+ `beforeunload`. What `can` does
154
+ not allow is kept to before any source is asked: fields locked or hidden (and
155
+ left out of what a save sends), a save refused with the source's `reason`, the
156
+ gear menu's Archive, Duplicate and Delete and the buttons whose steps would do
157
+ them hidden. `createMemoryDataSource({ versions: { by: 'Sara' }, can })` does
158
+ it all in memory, and `changeElsewhere` changes a record as someone else would.
159
+
48
160
  ## A saved form placed in another
49
161
 
50
162
  A block made once — an address, a contact person, a consent — is a page of its
@@ -162,7 +274,10 @@ const form = createForm({
162
274
 
163
275
  Without a host, `say` says nothing, `ask` asks the form's `confirm` option — or
164
276
  goes on as though answered Yes, so a form run from code is never held by a
165
- question — and `open`, `close` and a `goTo` of a tab stop with `cannot`.
277
+ question — and `open`, `close` and a `goTo` of a tab stop with `cannot`. The one
278
+ exception is "Discard your changes?" (`form.leave()`, with the person's work at
279
+ risk): without a host or `confirm`, the work is kept and the way out does not
280
+ happen.
166
281
 
167
282
  An `open` step reads `record` and `values` against this form; a field named
168
283
  alone goes whole, a link with its name. Once the page is saved, `into` reads
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fieldia/core",
3
- "version": "0.21.0",
3
+ "version": "0.22.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",
@@ -4,7 +4,10 @@
4
4
  "properties": {
5
5
  "fieldia": {
6
6
  "type": "string",
7
- "const": "0.1"
7
+ "enum": [
8
+ "0.1",
9
+ "0.2"
10
+ ]
8
11
  },
9
12
  "id": {
10
13
  "type": "string",
@@ -998,6 +1001,9 @@
998
1001
  "exclusiveMinimum": 0,
999
1002
  "maximum": 9007199254740991
1000
1003
  },
1004
+ "shrink": {
1005
+ "$ref": "#/$defs/Shrink"
1006
+ },
1001
1007
  "multiple": {
1002
1008
  "type": "boolean"
1003
1009
  },
@@ -1082,6 +1088,9 @@
1082
1088
  "exclusiveMinimum": 0,
1083
1089
  "maximum": 9007199254740991
1084
1090
  },
1091
+ "shrink": {
1092
+ "$ref": "#/$defs/Shrink"
1093
+ },
1085
1094
  "multiple": {
1086
1095
  "type": "boolean"
1087
1096
  },
@@ -1742,6 +1751,30 @@
1742
1751
  ],
1743
1752
  "additionalProperties": false
1744
1753
  },
1754
+ "Shrink": {
1755
+ "anyOf": [
1756
+ {
1757
+ "type": "boolean",
1758
+ "const": false
1759
+ },
1760
+ {
1761
+ "type": "object",
1762
+ "properties": {
1763
+ "maxSide": {
1764
+ "type": "integer",
1765
+ "minimum": 160,
1766
+ "maximum": 16384
1767
+ },
1768
+ "quality": {
1769
+ "type": "number",
1770
+ "minimum": 0.3,
1771
+ "maximum": 1
1772
+ }
1773
+ },
1774
+ "additionalProperties": false
1775
+ }
1776
+ ]
1777
+ },
1745
1778
  "FilterItem": {
1746
1779
  "anyOf": [
1747
1780
  {
@@ -3060,6 +3093,9 @@
3060
3093
  "exclusiveMinimum": 0,
3061
3094
  "maximum": 9007199254740991
3062
3095
  },
3096
+ "shrink": {
3097
+ "$ref": "#/$defs/Shrink"
3098
+ },
3063
3099
  "multiple": {
3064
3100
  "type": "boolean"
3065
3101
  },
@@ -3144,6 +3180,9 @@
3144
3180
  "exclusiveMinimum": 0,
3145
3181
  "maximum": 9007199254740991
3146
3182
  },
3183
+ "shrink": {
3184
+ "$ref": "#/$defs/Shrink"
3185
+ },
3147
3186
  "multiple": {
3148
3187
  "type": "boolean"
3149
3188
  },
@@ -4238,6 +4277,9 @@
4238
4277
  "exclusiveMinimum": 0,
4239
4278
  "maximum": 9007199254740991
4240
4279
  },
4280
+ "shrink": {
4281
+ "$ref": "#/$defs/Shrink"
4282
+ },
4241
4283
  "multiple": {
4242
4284
  "type": "boolean"
4243
4285
  },
@@ -4322,6 +4364,9 @@
4322
4364
  "exclusiveMinimum": 0,
4323
4365
  "maximum": 9007199254740991
4324
4366
  },
4367
+ "shrink": {
4368
+ "$ref": "#/$defs/Shrink"
4369
+ },
4325
4370
  "multiple": {
4326
4371
  "type": "boolean"
4327
4372
  },
@@ -8752,6 +8797,9 @@
8752
8797
  "map": {
8753
8798
  "$ref": "#/$defs/ListMap"
8754
8799
  },
8800
+ "calendar": {
8801
+ "$ref": "#/$defs/ListCalendar"
8802
+ },
8755
8803
  "cells": {
8756
8804
  "type": "object",
8757
8805
  "propertyNames": {
@@ -8935,6 +8983,106 @@
8935
8983
  },
8936
8984
  "additionalProperties": false
8937
8985
  },
8986
+ "ListCalendar": {
8987
+ "type": "object",
8988
+ "properties": {
8989
+ "start": {
8990
+ "type": "string",
8991
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
8992
+ },
8993
+ "end": {
8994
+ "type": "string",
8995
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
8996
+ },
8997
+ "title": {
8998
+ "type": "string",
8999
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
9000
+ },
9001
+ "colour": {
9002
+ "type": "string",
9003
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
9004
+ },
9005
+ "resource": {
9006
+ "type": "string",
9007
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
9008
+ },
9009
+ "views": {
9010
+ "minItems": 1,
9011
+ "type": "array",
9012
+ "items": {
9013
+ "type": "string",
9014
+ "enum": [
9015
+ "day",
9016
+ "week",
9017
+ "month",
9018
+ "agenda"
9019
+ ]
9020
+ }
9021
+ },
9022
+ "view": {
9023
+ "type": "string",
9024
+ "enum": [
9025
+ "day",
9026
+ "week",
9027
+ "month",
9028
+ "agenda"
9029
+ ]
9030
+ },
9031
+ "opens": {
9032
+ "type": "string",
9033
+ "enum": [
9034
+ "list",
9035
+ "calendar"
9036
+ ]
9037
+ },
9038
+ "firstDay": {
9039
+ "type": "integer",
9040
+ "minimum": 0,
9041
+ "maximum": 6
9042
+ },
9043
+ "hours": {
9044
+ "type": "object",
9045
+ "properties": {
9046
+ "start": {
9047
+ "type": "integer",
9048
+ "minimum": 0,
9049
+ "maximum": 23
9050
+ },
9051
+ "end": {
9052
+ "type": "integer",
9053
+ "minimum": 1,
9054
+ "maximum": 24
9055
+ }
9056
+ },
9057
+ "required": [
9058
+ "start",
9059
+ "end"
9060
+ ],
9061
+ "additionalProperties": false
9062
+ },
9063
+ "slot": {
9064
+ "anyOf": [
9065
+ {
9066
+ "type": "number",
9067
+ "const": 15
9068
+ },
9069
+ {
9070
+ "type": "number",
9071
+ "const": 30
9072
+ },
9073
+ {
9074
+ "type": "number",
9075
+ "const": 60
9076
+ }
9077
+ ]
9078
+ }
9079
+ },
9080
+ "required": [
9081
+ "start",
9082
+ "title"
9083
+ ],
9084
+ "additionalProperties": false
9085
+ },
8938
9086
  "ListCell": {
8939
9087
  "type": "object",
8940
9088
  "properties": {
package/src/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from './runtime.mjs';
2
- export { FieldSchema, FieldsSchema, LineFieldSchema, LineKindsSchema, OptionSchema, PropertyDefinitionSchema, FilterConditionSchema, FilterItemSchema, MoneyLookSchema, PERIODS, } from './lib/format/field.mjs';
3
- export { ModifierSchema, RolesSchema, CellRulesSchema, ToneWhenSchema, LayoutNodeSchema, RootLayoutSchema, ListNodeSchema, ListCellSchema } from './lib/format/layout.mjs';
2
+ export { FieldSchema, FieldsSchema, LineFieldSchema, LineKindsSchema, OptionSchema, PropertyDefinitionSchema, FilterConditionSchema, FilterItemSchema, MoneyLookSchema, ShrinkSchema, PERIODS, } from './lib/format/field.mjs';
3
+ export { ModifierSchema, RolesSchema, CellRulesSchema, ToneWhenSchema, LayoutNodeSchema, RootLayoutSchema, ListNodeSchema, ListCellSchema, ListCalendarSchema } from './lib/format/layout.mjs';
4
4
  export { PageSchema } from './lib/format/page.mjs';
5
5
  export { ActionStepSchema, PageEventsSchema } from './lib/format/actions.mjs';
6
6
  export { validatePage } from './lib/format/validate.mjs';
package/src/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from './runtime';
2
- export { FieldSchema, FieldsSchema, LineFieldSchema, LineKindsSchema, OptionSchema, PropertyDefinitionSchema, FilterConditionSchema, FilterItemSchema, MoneyLookSchema, PERIODS, } from './lib/format/field';
3
- export { ModifierSchema, RolesSchema, CellRulesSchema, ToneWhenSchema, LayoutNodeSchema, RootLayoutSchema, ListNodeSchema, ListCellSchema } from './lib/format/layout';
2
+ export { FieldSchema, FieldsSchema, LineFieldSchema, LineKindsSchema, OptionSchema, PropertyDefinitionSchema, FilterConditionSchema, FilterItemSchema, MoneyLookSchema, ShrinkSchema, PERIODS, } from './lib/format/field';
3
+ export { ModifierSchema, RolesSchema, CellRulesSchema, ToneWhenSchema, LayoutNodeSchema, RootLayoutSchema, ListNodeSchema, ListCellSchema, ListCalendarSchema } from './lib/format/layout';
4
4
  export { PageSchema } from './lib/format/page';
5
5
  export { ActionStepSchema, PageEventsSchema } from './lib/format/actions';
6
6
  export { validatePage } from './lib/format/validate';
package/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pageJsonSchema = exports.StateDotOptionsSchema = exports.PathPickerOptionsSchema = exports.AddressSearchOptionsSchema = exports.validatePage = exports.PageEventsSchema = exports.ActionStepSchema = exports.PageSchema = exports.ListCellSchema = exports.ListNodeSchema = exports.RootLayoutSchema = exports.LayoutNodeSchema = exports.ToneWhenSchema = exports.CellRulesSchema = exports.RolesSchema = exports.ModifierSchema = exports.PERIODS = exports.MoneyLookSchema = exports.FilterItemSchema = exports.FilterConditionSchema = exports.PropertyDefinitionSchema = exports.OptionSchema = exports.LineKindsSchema = exports.LineFieldSchema = exports.FieldsSchema = exports.FieldSchema = void 0;
3
+ exports.pageJsonSchema = exports.StateDotOptionsSchema = exports.PathPickerOptionsSchema = exports.AddressSearchOptionsSchema = exports.validatePage = exports.PageEventsSchema = exports.ActionStepSchema = exports.PageSchema = exports.ListCalendarSchema = exports.ListCellSchema = exports.ListNodeSchema = exports.RootLayoutSchema = exports.LayoutNodeSchema = exports.ToneWhenSchema = exports.CellRulesSchema = exports.RolesSchema = exports.ModifierSchema = exports.PERIODS = exports.ShrinkSchema = exports.MoneyLookSchema = exports.FilterItemSchema = exports.FilterConditionSchema = exports.PropertyDefinitionSchema = exports.OptionSchema = exports.LineKindsSchema = exports.LineFieldSchema = exports.FieldsSchema = exports.FieldSchema = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  tslib_1.__exportStar(require("./runtime"), exports);
6
6
  var field_1 = require("./lib/format/field");
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "PropertyDefinitionSchema", { enumerable: true, g
13
13
  Object.defineProperty(exports, "FilterConditionSchema", { enumerable: true, get: function () { return field_1.FilterConditionSchema; } });
14
14
  Object.defineProperty(exports, "FilterItemSchema", { enumerable: true, get: function () { return field_1.FilterItemSchema; } });
15
15
  Object.defineProperty(exports, "MoneyLookSchema", { enumerable: true, get: function () { return field_1.MoneyLookSchema; } });
16
+ Object.defineProperty(exports, "ShrinkSchema", { enumerable: true, get: function () { return field_1.ShrinkSchema; } });
16
17
  Object.defineProperty(exports, "PERIODS", { enumerable: true, get: function () { return field_1.PERIODS; } });
17
18
  var layout_1 = require("./lib/format/layout");
18
19
  Object.defineProperty(exports, "ModifierSchema", { enumerable: true, get: function () { return layout_1.ModifierSchema; } });
@@ -23,6 +24,7 @@ Object.defineProperty(exports, "LayoutNodeSchema", { enumerable: true, get: func
23
24
  Object.defineProperty(exports, "RootLayoutSchema", { enumerable: true, get: function () { return layout_1.RootLayoutSchema; } });
24
25
  Object.defineProperty(exports, "ListNodeSchema", { enumerable: true, get: function () { return layout_1.ListNodeSchema; } });
25
26
  Object.defineProperty(exports, "ListCellSchema", { enumerable: true, get: function () { return layout_1.ListCellSchema; } });
27
+ Object.defineProperty(exports, "ListCalendarSchema", { enumerable: true, get: function () { return layout_1.ListCalendarSchema; } });
26
28
  var page_1 = require("./lib/format/page");
27
29
  Object.defineProperty(exports, "PageSchema", { enumerable: true, get: function () { return page_1.PageSchema; } });
28
30
  var actions_1 = require("./lib/format/actions");
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/core/src/index.ts"],"names":[],"mappings":";;;;AAAA,oDAA0B;AAC1B,4CAW4B;AAV1B,oGAAA,WAAW,OAAA;AACX,qGAAA,YAAY,OAAA;AACZ,wGAAA,eAAe,OAAA;AACf,wGAAA,eAAe,OAAA;AACf,qGAAA,YAAY,OAAA;AACZ,iHAAA,wBAAwB,OAAA;AACxB,8GAAA,qBAAqB,OAAA;AACrB,yGAAA,gBAAgB,OAAA;AAChB,wGAAA,eAAe,OAAA;AACf,gGAAA,OAAO,OAAA;AAET,8CAAuK;AAA9J,wGAAA,cAAc,OAAA;AAAE,qGAAA,WAAW,OAAA;AAAE,yGAAA,eAAe,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,0GAAA,gBAAgB,OAAA;AAAE,0GAAA,gBAAgB,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,wGAAA,cAAc,OAAA;AACzI,0CAA+C;AAAtC,kGAAA,UAAU,OAAA;AACnB,gDAA0E;AAAjE,2GAAA,gBAAgB,OAAA;AAAE,2GAAA,gBAAgB,OAAA;AAC3C,kDAAqD;AAA5C,wGAAA,YAAY,OAAA;AACrB,8DAAyE;AAAhE,4HAAA,0BAA0B,OAAA;AACnC,8DAA6F;AAApF,yHAAA,uBAAuB,OAAA;AAAE,uHAAA,qBAAqB,OAAA;AACvD,wDAA0D;AAAjD,6GAAA,cAAc,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/core/src/index.ts"],"names":[],"mappings":";;;;AAAA,oDAA0B;AAC1B,4CAY4B;AAX1B,oGAAA,WAAW,OAAA;AACX,qGAAA,YAAY,OAAA;AACZ,wGAAA,eAAe,OAAA;AACf,wGAAA,eAAe,OAAA;AACf,qGAAA,YAAY,OAAA;AACZ,iHAAA,wBAAwB,OAAA;AACxB,8GAAA,qBAAqB,OAAA;AACrB,yGAAA,gBAAgB,OAAA;AAChB,wGAAA,eAAe,OAAA;AACf,qGAAA,YAAY,OAAA;AACZ,gGAAA,OAAO,OAAA;AAET,8CAA2L;AAAlL,wGAAA,cAAc,OAAA;AAAE,qGAAA,WAAW,OAAA;AAAE,yGAAA,eAAe,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,0GAAA,gBAAgB,OAAA;AAAE,0GAAA,gBAAgB,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,4GAAA,kBAAkB,OAAA;AAC7J,0CAA+C;AAAtC,kGAAA,UAAU,OAAA;AACnB,gDAA0E;AAAjE,2GAAA,gBAAgB,OAAA;AAAE,2GAAA,gBAAgB,OAAA;AAC3C,kDAAqD;AAA5C,wGAAA,YAAY,OAAA;AACrB,8DAAyE;AAAhE,4HAAA,0BAA0B,OAAA;AACnC,8DAA6F;AAApF,yHAAA,uBAAuB,OAAA;AAAE,uHAAA,qBAAqB,OAAA;AACvD,wDAA0D;AAAjD,6GAAA,cAAc,OAAA"}
package/src/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from './runtime.mjs';
2
- export { FieldSchema, FieldsSchema, LineFieldSchema, LineKindsSchema, OptionSchema, PropertyDefinitionSchema, FilterConditionSchema, FilterItemSchema, MoneyLookSchema, PERIODS, } from './lib/format/field.mjs';
3
- export { ModifierSchema, RolesSchema, CellRulesSchema, ToneWhenSchema, LayoutNodeSchema, RootLayoutSchema, ListNodeSchema, ListCellSchema } from './lib/format/layout.mjs';
2
+ export { FieldSchema, FieldsSchema, LineFieldSchema, LineKindsSchema, OptionSchema, PropertyDefinitionSchema, FilterConditionSchema, FilterItemSchema, MoneyLookSchema, ShrinkSchema, PERIODS, } from './lib/format/field.mjs';
3
+ export { ModifierSchema, RolesSchema, CellRulesSchema, ToneWhenSchema, LayoutNodeSchema, RootLayoutSchema, ListNodeSchema, ListCellSchema, ListCalendarSchema } from './lib/format/layout.mjs';
4
4
  export { PageSchema } from './lib/format/page.mjs';
5
5
  export { ActionStepSchema, PageEventsSchema } from './lib/format/actions.mjs';
6
6
  export { validatePage } from './lib/format/validate.mjs';
package/src/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../libs/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,OAAO,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,OAAO,GACR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACvK,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../libs/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,OAAO,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,OAAO,GACR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC3L,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
@@ -5,10 +5,11 @@ import { type PageValidation } from './references.mjs';
5
5
  * condition in it, the same as `validatePage` finds them. It leaves out the
6
6
  * key-by-key check of the format, and so the validation library, which an app
7
7
  * showing forms need not carry; run `validatePage` where pages are made or
8
- * tested. A page that passes is handed back as it is. A line's own form —
8
+ * tested. A page that passes is handed back as it is — one in an older
9
+ * format, brought up to date (`upgradePage`). A line's own form —
9
10
  * a page of a table's line fields — is checked with `parent`, the fields of
10
11
  * the record the line is on, which its conditions read as `parent`.
11
12
  */
12
- export declare function checkPage(input: unknown, options?: {
13
+ export declare function checkPage(given: unknown, options?: {
13
14
  parent?: Record<string, Field | LineField>;
14
15
  }): PageValidation;
@@ -5,10 +5,11 @@ import { type PageValidation } from './references';
5
5
  * condition in it, the same as `validatePage` finds them. It leaves out the
6
6
  * key-by-key check of the format, and so the validation library, which an app
7
7
  * showing forms need not carry; run `validatePage` where pages are made or
8
- * tested. A page that passes is handed back as it is. A line's own form —
8
+ * tested. A page that passes is handed back as it is — one in an older
9
+ * format, brought up to date (`upgradePage`). A line's own form —
9
10
  * a page of a table's line fields — is checked with `parent`, the fields of
10
11
  * the record the line is on, which its conditions read as `parent`.
11
12
  */
12
- export declare function checkPage(input: unknown, options?: {
13
+ export declare function checkPage(given: unknown, options?: {
13
14
  parent?: Record<string, Field | LineField>;
14
15
  }): PageValidation;
@@ -4,6 +4,7 @@ exports.checkPage = checkPage;
4
4
  const names_1 = require("./names");
5
5
  const references_1 = require("./references");
6
6
  const version_1 = require("./version");
7
+ const upgrade_1 = require("./upgrade");
7
8
  const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
8
9
  const LAYOUTS = ['sheet', 'sections', 'tabs', 'wizard'];
9
10
  /**
@@ -11,17 +12,21 @@ const LAYOUTS = ['sheet', 'sections', 'tabs', 'wizard'];
11
12
  * condition in it, the same as `validatePage` finds them. It leaves out the
12
13
  * key-by-key check of the format, and so the validation library, which an app
13
14
  * showing forms need not carry; run `validatePage` where pages are made or
14
- * tested. A page that passes is handed back as it is. A line's own form —
15
+ * tested. A page that passes is handed back as it is — one in an older
16
+ * format, brought up to date (`upgradePage`). A line's own form —
15
17
  * a page of a table's line fields — is checked with `parent`, the fields of
16
18
  * the record the line is on, which its conditions read as `parent`.
17
19
  */
18
- function checkPage(input, options = {}) {
20
+ function checkPage(given, options = {}) {
21
+ // A page in an older format is read as the current one (upgradePage); one newer than this Fieldia is said to be.
22
+ const input = (0, upgrade_1.upgradePage)(given);
19
23
  if (!isObject(input))
20
24
  return { ok: false, issues: [{ path: '(page)', message: 'a page is a JSON object' }] };
21
25
  const issues = [];
22
26
  const say = (path, message) => issues.push({ path, message });
23
- if (input['fieldia'] !== version_1.FORMAT_VERSION)
24
- say('fieldia', `this build reads format ${version_1.FORMAT_VERSION}`);
27
+ const format = (0, version_1.formatProblem)(input['fieldia']);
28
+ if (format)
29
+ say('fieldia', format);
25
30
  if (typeof input['id'] !== 'string' || !input['id'])
26
31
  say('id', 'a page needs an id');
27
32
  const data = input['data'];
@@ -1 +1 @@
1
- {"version":3,"file":"check-page.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/format/check-page.ts"],"names":[],"mappings":";;AAkBA,8BAiCC;AAnDD,mCAAsC;AAGtC,6CAAmF;AACnF,uCAA2C;AAE3C,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,I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,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC1E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,uCAAwC,KAAe,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC;IACjI,CAAC;AACH,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { FIELD_TYPES } from './names.mjs';
2
2
  import { ReferenceCheck } from './references.mjs';
3
- import { FORMAT_VERSION } from './version.mjs';
3
+ import { formatProblem } from './version.mjs';
4
+ import { upgradePage } from './upgrade.mjs';
4
5
  const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
5
6
  const LAYOUTS = ['sheet', 'sections', 'tabs', 'wizard'];
6
7
  /**
@@ -8,17 +9,21 @@ const LAYOUTS = ['sheet', 'sections', 'tabs', 'wizard'];
8
9
  * condition in it, the same as `validatePage` finds them. It leaves out the
9
10
  * key-by-key check of the format, and so the validation library, which an app
10
11
  * showing forms need not carry; run `validatePage` where pages are made or
11
- * tested. A page that passes is handed back as it is. A line's own form —
12
+ * tested. A page that passes is handed back as it is — one in an older
13
+ * format, brought up to date (`upgradePage`). A line's own form —
12
14
  * a page of a table's line fields — is checked with `parent`, the fields of
13
15
  * the record the line is on, which its conditions read as `parent`.
14
16
  */
15
- export function checkPage(input, options = {}) {
17
+ export function checkPage(given, options = {}) {
18
+ // A page in an older format is read as the current one (upgradePage); one newer than this Fieldia is said to be.
19
+ const input = upgradePage(given);
16
20
  if (!isObject(input))
17
21
  return { ok: false, issues: [{ path: '(page)', message: 'a page is a JSON object' }] };
18
22
  const issues = [];
19
23
  const say = (path, message) => issues.push({ path, message });
20
- if (input['fieldia'] !== FORMAT_VERSION)
21
- say('fieldia', `this build reads format ${FORMAT_VERSION}`);
24
+ const format = formatProblem(input['fieldia']);
25
+ if (format)
26
+ say('fieldia', format);
22
27
  if (typeof input['id'] !== 'string' || !input['id'])
23
28
  say('id', 'a page needs an id');
24
29
  const data = input['data'];
@@ -1 +1 @@
1
- {"version":3,"file":"check-page.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/format/check-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAuC,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC5I,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,UAA0D,EAAE;IACpG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC,EAAE,CAAC;IAC7G,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,OAAe,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAC9E,IAAI,KAAK,CAAC,SAAS,CAAC,KAAK,cAAc;QAAE,GAAG,CAAC,SAAS,EAAE,2BAA2B,cAAc,EAAE,CAAC,CAAC;IACrG,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;QAAE,GAAG,CAAC,IAAI,EAAE,oBAA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