@panneau/protocol 5.0.0-alpha.3 → 5.0.0-alpha.32

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 (147) hide show
  1. package/dist/addresses.d.ts +23 -0
  2. package/dist/addresses.d.ts.map +1 -0
  3. package/dist/addresses.js +52 -0
  4. package/dist/addresses.js.map +1 -0
  5. package/dist/compound.d.ts +20 -0
  6. package/dist/compound.d.ts.map +1 -0
  7. package/dist/compound.js +27 -0
  8. package/dist/compound.js.map +1 -0
  9. package/dist/conditions.d.ts +1 -1
  10. package/dist/conformance/index.d.ts +6 -0
  11. package/dist/conformance/index.d.ts.map +1 -1
  12. package/dist/conformance/index.js +801 -11
  13. package/dist/conformance/index.js.map +1 -1
  14. package/dist/constants.d.ts +108 -2
  15. package/dist/constants.d.ts.map +1 -1
  16. package/dist/constants.js +181 -3
  17. package/dist/constants.js.map +1 -1
  18. package/dist/context.d.ts +15 -0
  19. package/dist/context.d.ts.map +1 -0
  20. package/dist/context.js +34 -0
  21. package/dist/context.js.map +1 -0
  22. package/dist/currencies.d.ts +22 -0
  23. package/dist/currencies.d.ts.map +1 -0
  24. package/dist/currencies.js +231 -0
  25. package/dist/currencies.js.map +1 -0
  26. package/dist/index.d.ts +4 -4
  27. package/dist/index.js +19 -8
  28. package/dist/libraries.d.ts +33 -0
  29. package/dist/libraries.d.ts.map +1 -0
  30. package/dist/libraries.js +59 -0
  31. package/dist/libraries.js.map +1 -0
  32. package/dist/links.d.ts +38 -0
  33. package/dist/links.d.ts.map +1 -0
  34. package/dist/links.js +65 -0
  35. package/dist/links.js.map +1 -0
  36. package/dist/lint.d.ts +4 -3
  37. package/dist/lint.d.ts.map +1 -1
  38. package/dist/lint.js +168 -7
  39. package/dist/lint.js.map +1 -1
  40. package/dist/mock/auth.d.ts +71 -0
  41. package/dist/mock/auth.d.ts.map +1 -0
  42. package/dist/mock/auth.js +346 -0
  43. package/dist/mock/auth.js.map +1 -0
  44. package/dist/mock/example.d.ts +3 -2
  45. package/dist/mock/example.d.ts.map +1 -1
  46. package/dist/mock/example.js +241 -144
  47. package/dist/mock/example.js.map +1 -1
  48. package/dist/mock/index.d.ts +79 -7
  49. package/dist/mock/index.d.ts.map +1 -1
  50. package/dist/mock/index.js +603 -38
  51. package/dist/mock/index.js.map +1 -1
  52. package/dist/openapi.d.ts.map +1 -1
  53. package/dist/openapi.js +392 -144
  54. package/dist/openapi.js.map +1 -1
  55. package/dist/problem.d.ts +1 -1
  56. package/dist/query.d.ts +18 -0
  57. package/dist/query.d.ts.map +1 -1
  58. package/dist/query.js +34 -8
  59. package/dist/query.js.map +1 -1
  60. package/dist/resourceTypes.d.ts +39 -0
  61. package/dist/resourceTypes.d.ts.map +1 -0
  62. package/dist/resourceTypes.js +34 -0
  63. package/dist/resourceTypes.js.map +1 -0
  64. package/dist/rules.d.ts +18 -5
  65. package/dist/rules.d.ts.map +1 -1
  66. package/dist/rules.js +233 -15
  67. package/dist/rules.js.map +1 -1
  68. package/dist/runtime/index.d.ts +20 -10
  69. package/dist/runtime/index.d.ts.map +1 -1
  70. package/dist/runtime/index.js +13 -3
  71. package/dist/schemas/action.d.ts +118 -10
  72. package/dist/schemas/action.d.ts.map +1 -1
  73. package/dist/schemas/action.js +20 -3
  74. package/dist/schemas/action.js.map +1 -1
  75. package/dist/schemas/api.d.ts +334 -42
  76. package/dist/schemas/api.d.ts.map +1 -1
  77. package/dist/schemas/api.js +194 -34
  78. package/dist/schemas/api.js.map +1 -1
  79. package/dist/schemas/boot.d.ts +25 -1
  80. package/dist/schemas/boot.d.ts.map +1 -1
  81. package/dist/schemas/boot.js +2 -1
  82. package/dist/schemas/boot.js.map +1 -1
  83. package/dist/schemas/common.d.ts +1 -0
  84. package/dist/schemas/common.d.ts.map +1 -1
  85. package/dist/schemas/common.js +2 -1
  86. package/dist/schemas/common.js.map +1 -1
  87. package/dist/schemas/definition.d.ts +341 -28
  88. package/dist/schemas/definition.d.ts.map +1 -1
  89. package/dist/schemas/definition.js +65 -19
  90. package/dist/schemas/definition.js.map +1 -1
  91. package/dist/schemas/field.d.ts +357 -2
  92. package/dist/schemas/field.d.ts.map +1 -1
  93. package/dist/schemas/field.js +160 -20
  94. package/dist/schemas/field.js.map +1 -1
  95. package/dist/schemas/index.d.ts +1429 -80
  96. package/dist/schemas/index.d.ts.map +1 -1
  97. package/dist/schemas/index.js +60 -10
  98. package/dist/schemas/index.js.map +1 -1
  99. package/dist/schemas/jsonRules.d.ts +83 -0
  100. package/dist/schemas/jsonRules.d.ts.map +1 -0
  101. package/dist/schemas/jsonRules.js +46 -0
  102. package/dist/schemas/jsonRules.js.map +1 -0
  103. package/dist/schemas/layout.d.ts +2 -1
  104. package/dist/schemas/layout.d.ts.map +1 -1
  105. package/dist/schemas/layout.js +2 -1
  106. package/dist/schemas/layout.js.map +1 -1
  107. package/dist/schemas/list.d.ts +23 -2
  108. package/dist/schemas/list.d.ts.map +1 -1
  109. package/dist/schemas/list.js +15 -6
  110. package/dist/schemas/list.js.map +1 -1
  111. package/dist/schemas/resource.d.ts +263 -17
  112. package/dist/schemas/resource.d.ts.map +1 -1
  113. package/dist/schemas/resource.js +19 -4
  114. package/dist/schemas/resource.js.map +1 -1
  115. package/dist/schemas/theme.d.ts +4 -0
  116. package/dist/schemas/theme.d.ts.map +1 -1
  117. package/dist/schemas/theme.js +1 -0
  118. package/dist/schemas/theme.js.map +1 -1
  119. package/dist/schemas/widget.d.ts +109 -0
  120. package/dist/schemas/widget.d.ts.map +1 -0
  121. package/dist/schemas/widget.js +74 -0
  122. package/dist/schemas/widget.js.map +1 -0
  123. package/dist/search.d.ts +51 -0
  124. package/dist/search.d.ts.map +1 -0
  125. package/dist/search.js +53 -0
  126. package/dist/search.js.map +1 -0
  127. package/dist/themes.d.ts +1 -1
  128. package/dist/transforms.d.ts +17 -0
  129. package/dist/transforms.d.ts.map +1 -0
  130. package/dist/transforms.js +34 -0
  131. package/dist/transforms.js.map +1 -0
  132. package/dist/validate.d.ts +5 -3
  133. package/dist/validate.d.ts.map +1 -1
  134. package/dist/validate.js +36 -2
  135. package/dist/validate.js.map +1 -1
  136. package/dist/values.d.ts +5 -1
  137. package/dist/values.d.ts.map +1 -1
  138. package/dist/values.js +16 -2
  139. package/dist/values.js.map +1 -1
  140. package/dist/widgets.d.ts +42 -0
  141. package/dist/widgets.d.ts.map +1 -0
  142. package/dist/widgets.js +130 -0
  143. package/dist/widgets.js.map +1 -0
  144. package/package.json +6 -3
  145. package/schema/boot.schema.json +716 -20
  146. package/schema/definition.schema.json +713 -20
  147. package/schema/openapi.json +5659 -2229
package/dist/rules.js CHANGED
@@ -1,11 +1,27 @@
1
1
  import { PORTABLE_RULES } from "./constants.js";
2
+ import { isCurrencyCode } from "./currencies.js";
3
+ import { getAddressRequiredParts, isPostalCode } from "./addresses.js";
4
+ import { getNestedShape } from "./compound.js";
2
5
  import { getValue, isFilled, isRecord } from "./values.js";
3
6
  import { evaluateCondition } from "./conditions.js";
7
+ import { getLinkTypes } from "./links.js";
8
+ import { matchesRatio, renderedCropSize } from "./transforms.js";
4
9
  //#region src/rules.ts
5
10
  var EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
11
+ /** An international phone number in E.164: `+`, then 7 to 15 digits, without a leading zero. */
12
+ var TEL = /^\+[1-9]\d{6,14}$/;
13
+ /** The same number, with an optional extension after `;ext=` (RFC 3966): `+15145550199;ext=123`. */
14
+ var TEL_EXTENSION = /^\+[1-9]\d{6,14}(?:;ext=\d{1,10})?$/;
6
15
  function isKnownRule(rule) {
7
16
  return PORTABLE_RULES.includes(rule.rule);
8
17
  }
18
+ /**
19
+ * Whether a rule applies in a mode: a rule with a `mode` applies only in that mode, and not when the
20
+ * mode isn't known.
21
+ */
22
+ function appliesIn(rule, mode) {
23
+ return rule.mode === void 0 || rule.mode === mode;
24
+ }
9
25
  function failure(rule) {
10
26
  const result = { rule: rule.rule };
11
27
  if ("value" in rule && rule.value !== void 0) result.value = rule.value;
@@ -14,6 +30,7 @@ function failure(rule) {
14
30
  }
15
31
  function sizeOf(value) {
16
32
  if (typeof value === "number") return value;
33
+ if (isRecord(value) && "currency" in value && typeof value.amount === "number") return value.amount;
17
34
  if (typeof value === "string" || Array.isArray(value)) return value.length;
18
35
  return null;
19
36
  }
@@ -23,25 +40,83 @@ function matchesMime(mime, patterns) {
23
40
  return mime === pattern;
24
41
  });
25
42
  }
43
+ /** The files of a value, with their MIME type and size: stored files, or chosen ones (`File`). */
26
44
  function mediaList(value) {
27
- return (Array.isArray(value) ? value : [value]).filter(isRecord);
45
+ return (Array.isArray(value) ? value : [value]).filter(isRecord).map((media) => typeof Blob !== "undefined" && media instanceof Blob ? {
46
+ mime: media.type === "" ? void 0 : media.type,
47
+ size: media.size
48
+ } : media);
49
+ }
50
+ /**
51
+ * Whether each image of a value has the crop the `crop` rule asks for (decision 0031): a crop when
52
+ * it is required, and one of the ratios once rendered. An id alone has no crop.
53
+ */
54
+ function hasCrop(value, rule) {
55
+ return (Array.isArray(value) ? value : [value]).every((entry) => {
56
+ const transform = isRecord(entry) && isRecord(entry.transform) ? entry.transform : {};
57
+ const size = renderedCropSize(transform);
58
+ if (size === null) return rule.required !== true;
59
+ const ratios = rule.ratios ?? [];
60
+ return ratios.length === 0 || ratios.some((ratio) => matchesRatio(size.width, size.height, ratio));
61
+ });
62
+ }
63
+ /**
64
+ * Whether an `embed` value comes from one of the providers, compared without case (decision 0058).
65
+ * A value without a `provider` (an app without `GET /embeds`) is left to the backend.
66
+ */
67
+ function hasProvider(value, providers) {
68
+ if (!isRecord(value) || typeof value.provider !== "string") return true;
69
+ const provider = value.provider.toLowerCase();
70
+ return providers.some((allowed) => typeof allowed === "string" && allowed.toLowerCase() === provider);
71
+ }
72
+ var DAY = /^\d{4}-\d{2}-\d{2}$/;
73
+ var DATE_TIME = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/;
74
+ /** A bound of a `daterange`: a day or a date-time, `null` when empty, `undefined` when invalid. */
75
+ function rangeBound(value) {
76
+ if (value === null || value === void 0 || value === "") return null;
77
+ if (typeof value !== "string" || !(DAY.test(value) || DATE_TIME.test(value))) return;
78
+ return toTime(value) !== null ? value : void 0;
79
+ }
80
+ /**
81
+ * What a `daterange` value fails (decision 0053): a bound that is missing or invalid where the range
82
+ * isn't open (`start`, `end`), or an end before the start (`order`). `null` when it is valid.
83
+ */
84
+ function checkDateRange(value, open) {
85
+ if (!isRecord(value)) return "start";
86
+ const start = rangeBound(value.start);
87
+ const end = rangeBound(value.end);
88
+ const openStart = open === "start" || open === "both";
89
+ const openEnd = open === "end" || open === "both";
90
+ if (start === void 0 || start === null && !openStart) return "start";
91
+ if (end === void 0 || end === null && !openEnd) return "end";
92
+ if (start === null || end === null) return null;
93
+ return (DAY.test(start) && DAY.test(end) ? end < start : toTime(end) < toTime(start)) ? "order" : null;
94
+ }
95
+ /** Whether a `money` value has an integer amount, and a currency that the rule allows. */
96
+ function isMoney(value, currencies) {
97
+ if (!isRecord(value) || !Number.isSafeInteger(value.amount)) return false;
98
+ return Array.isArray(currencies) && currencies.length > 0 ? currencies.includes(value.currency) : isCurrencyCode(value.currency);
28
99
  }
29
100
  function toTime(value) {
30
101
  if (typeof value !== "string" && typeof value !== "number") return null;
31
102
  const time = new Date(value).getTime();
32
103
  return Number.isNaN(time) ? null : time;
33
104
  }
34
- /** Checks one value against a field's rules. Returns the rules that fail. */
35
- function checkRules(rules, value, root = {}) {
105
+ /**
106
+ * Checks one value against a field's rules. Returns the rules that fail. Rules limited to a `mode`
107
+ * only apply when it is given.
108
+ */
109
+ function checkRules(rules, value, root = {}, mode) {
36
110
  const failures = [];
37
111
  const filled = isFilled(value);
38
- rules.filter(isKnownRule).forEach((rule) => {
112
+ rules.filter((rule) => isKnownRule(rule) && appliesIn(rule, mode)).forEach((rule) => {
39
113
  if (rule.rule === "required") {
40
114
  if (!filled) failures.push(failure(rule));
41
115
  return;
42
116
  }
43
117
  if (!filled) return;
44
118
  let valid = true;
119
+ let detail = null;
45
120
  switch (rule.rule) {
46
121
  case "min":
47
122
  case "max": {
@@ -59,6 +134,24 @@ function checkRules(rules, value, root = {}) {
59
134
  case "url":
60
135
  valid = typeof value !== "string" || URL.canParse(value);
61
136
  break;
137
+ case "json":
138
+ valid = isRecord(value) || Array.isArray(value);
139
+ break;
140
+ case "tel":
141
+ valid = typeof value !== "string" || (rule.extension === true ? TEL_EXTENSION : TEL).test(value);
142
+ break;
143
+ case "postalCode": {
144
+ const country = isRecord(rule.value) ? getValue(root, String(rule.value.field)) : rule.value;
145
+ valid = typeof value !== "string" || isPostalCode(value, typeof country === "string" ? country : null);
146
+ break;
147
+ }
148
+ case "daterange":
149
+ detail = checkDateRange(value, rule.open);
150
+ valid = detail === null;
151
+ break;
152
+ case "money":
153
+ valid = isMoney(value, rule.currencies);
154
+ break;
62
155
  case "in": {
63
156
  const allowed = rule.value;
64
157
  valid = (Array.isArray(value) ? value : [value]).every((item) => allowed.includes(item));
@@ -70,6 +163,12 @@ function checkRules(rules, value, root = {}) {
70
163
  case "maxSize":
71
164
  valid = mediaList(value).every((media) => typeof media.size !== "number" || media.size <= rule.value);
72
165
  break;
166
+ case "crop":
167
+ valid = !isRecord(rule.value) || hasCrop(value, rule.value);
168
+ break;
169
+ case "providers":
170
+ valid = hasProvider(value, rule.value);
171
+ break;
73
172
  case "before":
74
173
  case "after": {
75
174
  const bound = rule.value;
@@ -79,15 +178,126 @@ function checkRules(rules, value, root = {}) {
79
178
  break;
80
179
  }
81
180
  }
82
- if (!valid) failures.push(failure(rule));
181
+ if (!valid) failures.push(detail !== null ? {
182
+ ...failure(rule),
183
+ value: detail
184
+ } : failure(rule));
83
185
  });
84
186
  return failures;
85
187
  }
86
188
  function addFailures(context, path, failures) {
87
189
  if (failures.length > 0) context.failures[path] = [...context.failures[path] ?? [], ...failures];
88
190
  }
191
+ /** A string setting of a field. */
192
+ function stringSetting(field, key) {
193
+ const value = field.settings?.[key];
194
+ return typeof value === "string" && value !== "" ? value : void 0;
195
+ }
196
+ /**
197
+ * The rule each type implies: its values are checked whatever rules the field lists. `tel`,
198
+ * `daterange` and `money` carry settings of their field: the extension, the open bounds, the
199
+ * allowed currencies.
200
+ */
201
+ var IMPLIED_RULES = {
202
+ json: () => ({ rule: "json" }),
203
+ tel: (field) => field.settings?.extension === true ? {
204
+ rule: "tel",
205
+ extension: true
206
+ } : { rule: "tel" },
207
+ daterange: (field) => {
208
+ const open = stringSetting(field, "open");
209
+ return {
210
+ rule: "daterange",
211
+ ...open !== void 0 ? { open } : {}
212
+ };
213
+ },
214
+ money: (field) => {
215
+ const currency = stringSetting(field, "currency");
216
+ const listed = field.settings?.currencies;
217
+ const currencies = currency !== void 0 ? [currency] : Array.isArray(listed) ? listed.filter((code) => typeof code === "string") : [];
218
+ return {
219
+ rule: "money",
220
+ ...currencies.length > 0 ? { currencies } : {}
221
+ };
222
+ }
223
+ };
224
+ /**
225
+ * The rules of a field that apply in the mode, with the one its type implies: `json` for the
226
+ * `json` type, `tel` for `tel`, `daterange` for `daterange` and `money` for `money`. A rule of
227
+ * the same name on the field wins.
228
+ */
229
+ function rulesOf(field, mode) {
230
+ const rules = (field.rules ?? []).filter((rule) => appliesIn(rule, mode));
231
+ const implied = IMPLIED_RULES[field.type]?.(field);
232
+ return implied !== void 0 && !rules.some((rule) => rule.rule === implied.rule) ? [...rules, implied] : rules;
233
+ }
234
+ /** The parts that make an address filled: a country or a point alone don't. */
235
+ var ADDRESS_TEXT_PARTS = [
236
+ "street",
237
+ "unit",
238
+ "city",
239
+ "region",
240
+ "postalCode"
241
+ ];
242
+ /**
243
+ * The checks of the parts of an `address` (decision 0054): a filled address, with a part other
244
+ * than its country, has its required parts, and a postal code of its country.
245
+ */
246
+ function checkAddress(field, value, path, context) {
247
+ if (!isRecord(value) || !ADDRESS_TEXT_PARTS.some((part) => isFilled(value[part]))) return;
248
+ getAddressRequiredParts(field).forEach((part) => {
249
+ if (!isFilled(value[part])) addFailures(context, `${path}.${part}`, [{ rule: "required" }]);
250
+ });
251
+ const { postalCode, country } = value;
252
+ if (typeof postalCode === "string" && isFilled(postalCode) && !isPostalCode(postalCode, typeof country === "string" ? country : null)) addFailures(context, `${path}.postalCode`, [{ rule: "postalCode" }]);
253
+ }
254
+ /** Whether a string is an email address. */
255
+ var isEmail = (text) => EMAIL.test(text);
256
+ /** Whether the `url` of a link of a type is valid: the `rule` it fails, or `null`. */
257
+ function checkLinkUrl(type, url, pattern) {
258
+ switch (type) {
259
+ case "url": return /^https?:\/\//i.test(url) && URL.canParse(url) ? null : "url";
260
+ case "email": return /^mailto:/i.test(url) && isEmail(url.slice(7).split("?")[0] ?? "") ? null : "email";
261
+ case "tel": return /^tel:/i.test(url) && TEL.test(url.slice(4)) ? null : "tel";
262
+ default: return pattern === void 0 || new RegExp(pattern).test(url) ? null : "pattern";
263
+ }
264
+ }
265
+ /**
266
+ * The checks of the parts of a `link` (decision 0055): a type of the field, the URL of its type,
267
+ * its page or its file, and its label when the field requires one.
268
+ */
269
+ function checkLink(field, value, path, context) {
270
+ if (!isRecord(value)) return;
271
+ const types = getLinkTypes(field);
272
+ const type = types.find((candidate) => candidate.id === value.type);
273
+ if (type === void 0) {
274
+ addFailures(context, `${path}.type`, [{
275
+ rule: "in",
276
+ value: types.map((candidate) => candidate.id)
277
+ }]);
278
+ return;
279
+ }
280
+ if (type.id === "page" || type.id === "file") {
281
+ if (!isFilled(value[type.id])) addFailures(context, `${path}.${type.id}`, [{ rule: "required" }]);
282
+ } else if (typeof value.url !== "string" || !isFilled(value.url)) addFailures(context, `${path}.url`, [{ rule: "required" }]);
283
+ else {
284
+ const failed = checkLinkUrl(type.id, value.url.trim(), type.pattern);
285
+ if (failed !== null) addFailures(context, `${path}.url`, [failed === "pattern" ? {
286
+ rule: "pattern",
287
+ value: type.pattern
288
+ } : { rule: failed }]);
289
+ }
290
+ const label = value.label;
291
+ const hasLabel = isRecord(label) ? Object.values(label).some(isFilled) : isFilled(label);
292
+ if (field.settings?.label === "required" && !hasLabel) addFailures(context, `${path}.label`, [{ rule: "required" }]);
293
+ }
294
+ /** The checks of the parts of a value that the field's type implies. */
295
+ function checkParts(field, value, path, context) {
296
+ if (field.type === "address") checkAddress(field, value, path, context);
297
+ else if (field.type === "link") checkLink(field, value, path, context);
298
+ }
89
299
  function checkFieldValue(field, value, path, context) {
90
- const rules = field.rules ?? [];
300
+ const rules = rulesOf(field, context.mode);
91
301
  if (field.localized === true) {
92
302
  const localized = isRecord(value) ? value : {};
93
303
  const required = rules.filter((rule) => rule.rule === "required");
@@ -97,17 +307,20 @@ function checkFieldValue(field, value, path, context) {
97
307
  if (locales === void 0 || locales.length === 0) {
98
308
  if (!Object.values(localized).some(isFilled)) addFailures(context, path, required.map(failure));
99
309
  } else locales.forEach((locale) => {
100
- addFailures(context, `${path}.${locale}`, checkRules(required, localized[locale], context.root));
310
+ addFailures(context, `${path}.${locale}`, checkRules(required, localized[locale], context.root, context.mode));
101
311
  });
102
312
  }
103
313
  Object.entries(localized).forEach(([locale, localeValue]) => {
104
- addFailures(context, `${path}.${locale}`, checkRules(others, localeValue, context.root));
314
+ addFailures(context, `${path}.${locale}`, checkRules(others, localeValue, context.root, context.mode));
315
+ checkParts(field, localeValue, `${path}.${locale}`, context);
105
316
  });
106
317
  return;
107
318
  }
108
- addFailures(context, path, checkRules(rules, value, context.root));
109
- if (field.type === "group" && field.fields !== void 0 && isRecord(value)) checkFields(field.fields, value, `${path}.`, context);
110
- if (field.type === "repeater" && Array.isArray(value)) value.forEach((item, index) => {
319
+ addFailures(context, path, checkRules(rules, value, context.root, context.mode));
320
+ checkParts(field, value, path, context);
321
+ const shape = getNestedShape(field);
322
+ if (shape === "group" && field.fields !== void 0 && isRecord(value)) checkFields(field.fields, value, `${path}.`, context);
323
+ if (shape === "repeater" && Array.isArray(value)) value.forEach((item, index) => {
111
324
  if (!isRecord(item)) return;
112
325
  const blockFields = field.types !== void 0 ? field.types.find((type) => type.id === item.type)?.fields : field.fields;
113
326
  if (blockFields !== void 0) checkFields(blockFields, item, `${path}.${index}.`, context);
@@ -115,10 +328,10 @@ function checkFieldValue(field, value, path, context) {
115
328
  }
116
329
  function checkFields(fields, values, prefix, context) {
117
330
  fields.forEach((field) => {
118
- if (field.readOnly === true) return;
331
+ if (field.readOnly === true || field.notInForm === true) return;
119
332
  if (context.mode === "create" && field.updateOnly === true) return;
120
333
  if (context.mode === "update" && field.createOnly === true) return;
121
- if (field.visibleWhen !== void 0 && !evaluateCondition(field.visibleWhen, values)) return;
334
+ if (field.visibleWhen !== void 0 && !evaluateCondition(field.visibleWhen, prefix === "" ? context.root : values)) return;
122
335
  if (context.partial === true && prefix === "" && !(field.name in values)) return;
123
336
  checkFieldValue(field, values[field.name], `${prefix}${field.name}`, context);
124
337
  });
@@ -126,12 +339,17 @@ function checkFields(fields, values, prefix, context) {
126
339
  /**
127
340
  * Checks form values against the portable rules of their fields. Returns the failures keyed by
128
341
  * the dot path of the value (`title.fr`, `blocks.2.image`), the same keys as validation errors.
129
- * Hidden and read-only fields are skipped. Rules this version doesn't know are ignored.
342
+ * Hidden and read-only fields, and fields that forms leave out (`notInForm`), are skipped. Rules
343
+ * this version doesn't know are ignored.
130
344
  */
131
345
  function checkValues(fields, values, options = {}) {
346
+ const root = options.partial === true && options.item !== void 0 ? {
347
+ ...options.item,
348
+ ...values
349
+ } : values;
132
350
  const context = {
133
351
  ...options,
134
- root: values,
352
+ root,
135
353
  failures: {}
136
354
  };
137
355
  checkFields(fields, values, "", context);
package/dist/rules.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rules.js","names":[],"sources":["../src/rules.ts"],"sourcesContent":["import { evaluateCondition } from './conditions';\nimport { PORTABLE_RULES } from './constants';\nimport type { Field, Rule } from './schemas/field';\nimport { getValue, isFilled, isRecord } from './values';\n\n/** A rule that a value doesn't satisfy. */\nexport interface RuleFailure {\n rule: string;\n /** The rule's parameter (`max: 120` gives `120`). */\n value?: unknown;\n /** The message set on the rule, if any. */\n message?: string;\n}\n\nexport interface CheckOptions {\n /**\n * Locales a `required` localized field must be filled in. Without it, one filled locale is\n * enough.\n */\n locales?: string[];\n /** `create` skips `updateOnly` fields; `update` skips `createOnly` fields. */\n mode?: 'create' | 'update';\n /** Only check the fields present in the values (partial updates). */\n partial?: boolean;\n}\n\ninterface Context extends CheckOptions {\n /** The whole form, for `visibleWhen` and date rules that reference other fields. */\n root: Record<string, unknown>;\n failures: Record<string, RuleFailure[]>;\n}\n\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nfunction isKnownRule(rule: Rule): boolean {\n return (PORTABLE_RULES as readonly string[]).includes(rule.rule);\n}\n\nfunction failure(rule: Rule): RuleFailure {\n const result: RuleFailure = { rule: rule.rule };\n if ('value' in rule && rule.value !== undefined) {\n result.value = rule.value;\n }\n if (rule.message !== undefined) {\n result.message = rule.message;\n }\n return result;\n}\n\nfunction sizeOf(value: unknown): number | null {\n if (typeof value === 'number') {\n return value;\n }\n if (typeof value === 'string' || Array.isArray(value)) {\n return value.length;\n }\n return null;\n}\n\nfunction matchesMime(mime: string, patterns: string[]): boolean {\n return patterns.some((pattern) => {\n if (pattern.endsWith('/*')) {\n return mime.startsWith(pattern.slice(0, -1));\n }\n return mime === pattern;\n });\n}\n\nfunction mediaList(value: unknown): Record<string, unknown>[] {\n const list = Array.isArray(value) ? value : [value];\n return list.filter(isRecord);\n}\n\nfunction toTime(value: unknown): number | null {\n if (typeof value !== 'string' && typeof value !== 'number') {\n return null;\n }\n const time = new Date(value).getTime();\n return Number.isNaN(time) ? null : time;\n}\n\n/** Checks one value against a field's rules. Returns the rules that fail. */\nexport function checkRules(\n rules: Rule[],\n value: unknown,\n root: Record<string, unknown> = {},\n): RuleFailure[] {\n const failures: RuleFailure[] = [];\n const filled = isFilled(value);\n rules.filter(isKnownRule).forEach((rule) => {\n if (rule.rule === 'required') {\n if (!filled) {\n failures.push(failure(rule));\n }\n return;\n }\n if (!filled) {\n return;\n }\n let valid = true;\n switch (rule.rule) {\n case 'min':\n case 'max': {\n const size = sizeOf(value);\n const limit = rule.value as number;\n valid = size === null || (rule.rule === 'min' ? size >= limit : size <= limit);\n break;\n }\n case 'pattern':\n valid =\n typeof value !== 'string' ||\n new RegExp(rule.value as string, (rule as { flags?: string }).flags).test(\n value,\n );\n break;\n case 'email':\n valid = typeof value !== 'string' || EMAIL.test(value);\n break;\n case 'url':\n valid = typeof value !== 'string' || URL.canParse(value);\n break;\n case 'in': {\n const allowed = rule.value as unknown[];\n const values = Array.isArray(value) ? value : [value];\n valid = values.every((item) => allowed.includes(item));\n break;\n }\n case 'accept':\n valid = mediaList(value).every(\n (media) =>\n typeof media.mime !== 'string' ||\n matchesMime(media.mime, rule.value as string[]),\n );\n break;\n case 'maxSize':\n valid = mediaList(value).every(\n (media) =>\n typeof media.size !== 'number' || media.size <= (rule.value as number),\n );\n break;\n case 'before':\n case 'after': {\n const bound = rule.value as string | { field: string };\n const boundTime = toTime(\n typeof bound === 'string' ? bound : getValue(root, bound.field),\n );\n const time = toTime(value);\n if (boundTime !== null && time !== null) {\n valid = rule.rule === 'before' ? time < boundTime : time > boundTime;\n }\n break;\n }\n }\n if (!valid) {\n failures.push(failure(rule));\n }\n });\n return failures;\n}\n\nfunction addFailures(context: Context, path: string, failures: RuleFailure[]) {\n if (failures.length > 0) {\n context.failures[path] = [...(context.failures[path] ?? []), ...failures];\n }\n}\n\nfunction checkFieldValue(field: Field, value: unknown, path: string, context: Context) {\n const rules = field.rules ?? [];\n if (field.localized === true) {\n const localized = isRecord(value) ? value : {};\n const required = rules.filter((rule) => rule.rule === 'required');\n const others = rules.filter((rule) => rule.rule !== 'required');\n if (required.length > 0) {\n const locales = context.locales;\n if (locales === undefined || locales.length === 0) {\n if (!Object.values(localized).some(isFilled)) {\n addFailures(context, path, required.map(failure));\n }\n } else {\n locales.forEach((locale) => {\n addFailures(\n context,\n `${path}.${locale}`,\n checkRules(required, localized[locale], context.root),\n );\n });\n }\n }\n Object.entries(localized).forEach(([locale, localeValue]) => {\n addFailures(\n context,\n `${path}.${locale}`,\n checkRules(others, localeValue, context.root),\n );\n });\n return;\n }\n\n addFailures(context, path, checkRules(rules, value, context.root));\n\n if (field.type === 'group' && field.fields !== undefined && isRecord(value)) {\n checkFields(field.fields, value, `${path}.`, context);\n }\n if (field.type === 'repeater' && Array.isArray(value)) {\n value.forEach((item, index) => {\n if (!isRecord(item)) {\n return;\n }\n const blockFields =\n field.types !== undefined\n ? field.types.find((type) => type.id === item.type)?.fields\n : field.fields;\n if (blockFields !== undefined) {\n checkFields(blockFields, item, `${path}.${index}.`, context);\n }\n });\n }\n}\n\nfunction checkFields(\n fields: Field[],\n values: Record<string, unknown>,\n prefix: string,\n context: Context,\n) {\n fields.forEach((field) => {\n if (field.readOnly === true) {\n return;\n }\n if (context.mode === 'create' && field.updateOnly === true) {\n return;\n }\n if (context.mode === 'update' && field.createOnly === true) {\n return;\n }\n if (field.visibleWhen !== undefined && !evaluateCondition(field.visibleWhen, values)) {\n return;\n }\n if (context.partial === true && prefix === '' && !(field.name in values)) {\n return;\n }\n checkFieldValue(field, values[field.name], `${prefix}${field.name}`, context);\n });\n}\n\n/**\n * Checks form values against the portable rules of their fields. Returns the failures keyed by\n * the dot path of the value (`title.fr`, `blocks.2.image`), the same keys as validation errors.\n * Hidden and read-only fields are skipped. Rules this version doesn't know are ignored.\n */\nexport function checkValues(\n fields: Field[],\n values: Record<string, unknown>,\n options: CheckOptions = {},\n): Record<string, RuleFailure[]> {\n const context: Context = { ...options, root: values, failures: {} };\n checkFields(fields, values, '', context);\n return context.failures;\n}\n"],"mappings":";;;;AAgCA,IAAM,QAAQ;AAEd,SAAS,YAAY,MAAqB;CACtC,OAAQ,eAAqC,SAAS,KAAK,IAAI;AACnE;AAEA,SAAS,QAAQ,MAAyB;CACtC,MAAM,SAAsB,EAAE,MAAM,KAAK,KAAK;CAC9C,IAAI,WAAW,QAAQ,KAAK,UAAU,KAAA,GAClC,OAAO,QAAQ,KAAK;CAExB,IAAI,KA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,IAAI,QAAQ,SAAS,YAAY,MAAM,eAAe,MAClD;EAEJ,IAAI,QAAQ,SAAS,YAAY,MAAM,eAAe,MAClD;EAEJ,IAAI,MAAM,gBAAgB,KAAA,KAAa,CAAC,kBAAkB,MAAM,aAAa,MAAM,GAC/E;EAEJ,IAAI,QAAQ,YAAY,QAAQ,WAAW,MAAM,EAAE,MAAM,QAAQ,SAC7D;EAEJ,gBAAgB,OAAO,OAAO,MAAM,OAAO,GAAG,SAAS,MAAM,QAAQ,OAAO;CAChF,CAAC;AACL;;;;;;AAOA,SAAgB,YACZ,QACA,QACA,UAAwB,CAAC,GACI;CAC7B,MAAM,UAAmB;EAAE,GAAG;EAAS,MAAM;EAAQ,UAAU,CAAC;CAAE;CAClE,YAAY,QAAQ,QAAQ,IAAI,OAAO;CACvC,OAAO,QAAQ;AACnB"}
1
+ {"version":3,"file":"rules.js","names":[],"sources":["../src/rules.ts"],"sourcesContent":["import { getAddressRequiredParts, isPostalCode } from './addresses';\nimport { getNestedShape } from './compound';\nimport { evaluateCondition } from './conditions';\nimport { PORTABLE_RULES } from './constants';\nimport { isCurrencyCode } from './currencies';\nimport { getLinkTypes } from './links';\nimport type { Field, Rule } from './schemas/field';\nimport { matchesRatio, renderedCropSize } from './transforms';\nimport { getValue, isFilled, isRecord } from './values';\n\n/** A rule that a value doesn't satisfy. */\nexport interface RuleFailure {\n rule: string;\n /**\n * The rule's parameter (`max: 120` gives `120`). For `daterange`, what fails: `start` or `end`\n * (a bound missing where the range isn't open), or `order` (the end is before the start).\n */\n value?: unknown;\n /** The message set on the rule, if any. */\n message?: string;\n}\n\nexport interface CheckOptions {\n /**\n * Locales a `required` localized field must be filled in. Without it, one filled locale is\n * enough.\n */\n locales?: string[];\n /** `create` skips `updateOnly` fields; `update` skips `createOnly` fields. */\n mode?: 'create' | 'update';\n /** Only check the fields present in the values (partial updates). */\n partial?: boolean;\n /**\n * The values of the item being updated. With `partial`, conditions (`visibleWhen`) and rules\n * that read other fields read them for the fields that aren't in the values: a field shown\n * when `status` is `published`, sent alone, is checked on a published item (decision 0043).\n */\n item?: Record<string, unknown>;\n}\n\ninterface Context extends CheckOptions {\n /** The whole form, for `visibleWhen` and date rules that reference other fields. */\n root: Record<string, unknown>;\n failures: Record<string, RuleFailure[]>;\n}\n\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n/** An international phone number in E.164: `+`, then 7 to 15 digits, without a leading zero. */\nconst TEL = /^\\+[1-9]\\d{6,14}$/;\n/** The same number, with an optional extension after `;ext=` (RFC 3966): `+15145550199;ext=123`. */\nconst TEL_EXTENSION = /^\\+[1-9]\\d{6,14}(?:;ext=\\d{1,10})?$/;\n\nfunction isKnownRule(rule: Rule): boolean {\n return (PORTABLE_RULES as readonly string[]).includes(rule.rule);\n}\n\n/**\n * Whether a rule applies in a mode: a rule with a `mode` applies only in that mode, and not when the\n * mode isn't known.\n */\nfunction appliesIn(rule: Rule, mode: CheckOptions['mode']): boolean {\n return rule.mode === undefined || rule.mode === mode;\n}\n\nfunction failure(rule: Rule): RuleFailure {\n const result: RuleFailure = { rule: rule.rule };\n if ('value' in rule && rule.value !== undefined) {\n result.value = rule.value;\n }\n if (rule.message !== undefined) {\n result.message = rule.message;\n }\n return result;\n}\n\nfunction sizeOf(value: unknown): number | null {\n if (typeof value === 'number') {\n return value;\n }\n // A `money` value: `min` and `max` apply to its amount, in minor units (decision 0053).\n if (isRecord(value) && 'currency' in value && typeof value.amount === 'number') {\n return value.amount;\n }\n if (typeof value === 'string' || Array.isArray(value)) {\n return value.length;\n }\n return null;\n}\n\nfunction matchesMime(mime: string, patterns: string[]): boolean {\n return patterns.some((pattern) => {\n if (pattern.endsWith('/*')) {\n return mime.startsWith(pattern.slice(0, -1));\n }\n return mime === pattern;\n });\n}\n\n/** The files of a value, with their MIME type and size: stored files, or chosen ones (`File`). */\nfunction mediaList(value: unknown): Record<string, unknown>[] {\n const list = Array.isArray(value) ? value : [value];\n return list\n .filter(isRecord)\n .map((media) =>\n typeof Blob !== 'undefined' && media instanceof Blob\n ? { mime: media.type === '' ? undefined : media.type, size: media.size }\n : media,\n );\n}\n\n/**\n * Whether each image of a value has the crop the `crop` rule asks for (decision 0031): a crop when\n * it is required, and one of the ratios once rendered. An id alone has no crop.\n */\nfunction hasCrop(value: unknown, rule: { ratios?: string[]; required?: boolean }): boolean {\n const entries = Array.isArray(value) ? value : [value];\n return entries.every((entry) => {\n const transform = isRecord(entry) && isRecord(entry.transform) ? entry.transform : {};\n const size = renderedCropSize(transform);\n if (size === null) {\n return rule.required !== true;\n }\n const ratios = rule.ratios ?? [];\n return (\n ratios.length === 0 ||\n ratios.some((ratio) => matchesRatio(size.width, size.height, ratio))\n );\n });\n}\n\n/**\n * Whether an `embed` value comes from one of the providers, compared without case (decision 0058).\n * A value without a `provider` (an app without `GET /embeds`) is left to the backend.\n */\nfunction hasProvider(value: unknown, providers: readonly string[]): boolean {\n if (!isRecord(value) || typeof value.provider !== 'string') {\n return true;\n }\n const provider = value.provider.toLowerCase();\n return providers.some(\n (allowed) => typeof allowed === 'string' && allowed.toLowerCase() === provider,\n );\n}\n\nconst DAY = /^\\d{4}-\\d{2}-\\d{2}$/;\nconst DATE_TIME = /^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}/;\n\n/** A bound of a `daterange`: a day or a date-time, `null` when empty, `undefined` when invalid. */\nfunction rangeBound(value: unknown): string | null | undefined {\n if (value === null || value === undefined || value === '') {\n return null;\n }\n if (typeof value !== 'string' || !(DAY.test(value) || DATE_TIME.test(value))) {\n return undefined;\n }\n return toTime(value) !== null ? value : undefined;\n}\n\n/**\n * What a `daterange` value fails (decision 0053): a bound that is missing or invalid where the range\n * isn't open (`start`, `end`), or an end before the start (`order`). `null` when it is valid.\n */\nfunction checkDateRange(value: unknown, open: unknown): 'start' | 'end' | 'order' | null {\n if (!isRecord(value)) {\n return 'start';\n }\n const start = rangeBound(value.start);\n const end = rangeBound(value.end);\n const openStart = open === 'start' || open === 'both';\n const openEnd = open === 'end' || open === 'both';\n if (start === undefined || (start === null && !openStart)) {\n return 'start';\n }\n if (end === undefined || (end === null && !openEnd)) {\n return 'end';\n }\n if (start === null || end === null) {\n return null;\n }\n // Days compare as days; a date-time compares as its instant.\n const before =\n DAY.test(start) && DAY.test(end)\n ? end < start\n : (toTime(end) as number) < (toTime(start) as number);\n return before ? 'order' : null;\n}\n\n/** Whether a `money` value has an integer amount, and a currency that the rule allows. */\nfunction isMoney(value: unknown, currencies: unknown): boolean {\n if (!isRecord(value) || !Number.isSafeInteger(value.amount)) {\n return false;\n }\n return Array.isArray(currencies) && currencies.length > 0\n ? currencies.includes(value.currency)\n : isCurrencyCode(value.currency);\n}\n\nfunction toTime(value: unknown): number | null {\n if (typeof value !== 'string' && typeof value !== 'number') {\n return null;\n }\n const time = new Date(value).getTime();\n return Number.isNaN(time) ? null : time;\n}\n\n/**\n * Checks one value against a field's rules. Returns the rules that fail. Rules limited to a `mode`\n * only apply when it is given.\n */\nexport function checkRules(\n rules: Rule[],\n value: unknown,\n root: Record<string, unknown> = {},\n mode?: CheckOptions['mode'],\n): RuleFailure[] {\n const failures: RuleFailure[] = [];\n const filled = isFilled(value);\n const applying = rules.filter((rule) => isKnownRule(rule) && appliesIn(rule, mode));\n applying.forEach((rule) => {\n if (rule.rule === 'required') {\n if (!filled) {\n failures.push(failure(rule));\n }\n return;\n }\n if (!filled) {\n return;\n }\n let valid = true;\n // What fails, when the rule says more than its parameter (`daterange`).\n let detail: string | null = null;\n switch (rule.rule) {\n case 'min':\n case 'max': {\n const size = sizeOf(value);\n const limit = rule.value as number;\n valid = size === null || (rule.rule === 'min' ? size >= limit : size <= limit);\n break;\n }\n case 'pattern':\n valid =\n typeof value !== 'string' ||\n new RegExp(rule.value as string, (rule as { flags?: string }).flags).test(\n value,\n );\n break;\n case 'email':\n valid = typeof value !== 'string' || EMAIL.test(value);\n break;\n case 'url':\n valid = typeof value !== 'string' || URL.canParse(value);\n break;\n case 'json':\n // Text that doesn't parse stays a string in the form: only objects and arrays pass\n valid = isRecord(value) || Array.isArray(value);\n break;\n case 'tel':\n valid =\n typeof value !== 'string' ||\n ((rule as { extension?: boolean }).extension === true\n ? TEL_EXTENSION\n : TEL\n ).test(value);\n break;\n case 'postalCode': {\n // The country is a code, or another field of the form (decision 0054)\n const country = isRecord(rule.value)\n ? getValue(root, String(rule.value.field))\n : rule.value;\n valid =\n typeof value !== 'string' ||\n isPostalCode(value, typeof country === 'string' ? country : null);\n break;\n }\n case 'daterange':\n detail = checkDateRange(value, (rule as { open?: unknown }).open);\n valid = detail === null;\n break;\n case 'money':\n valid = isMoney(value, (rule as { currencies?: unknown }).currencies);\n break;\n case 'in': {\n const allowed = rule.value as unknown[];\n const values = Array.isArray(value) ? value : [value];\n valid = values.every((item) => allowed.includes(item));\n break;\n }\n case 'accept':\n valid = mediaList(value).every(\n (media) =>\n typeof media.mime !== 'string' ||\n matchesMime(media.mime, rule.value as string[]),\n );\n break;\n case 'maxSize':\n valid = mediaList(value).every(\n (media) =>\n typeof media.size !== 'number' || media.size <= (rule.value as number),\n );\n break;\n case 'crop':\n valid = !isRecord(rule.value) || hasCrop(value, rule.value);\n break;\n case 'providers':\n valid = hasProvider(value, rule.value as string[]);\n break;\n case 'before':\n case 'after': {\n const bound = rule.value as string | { field: string };\n const boundTime = toTime(\n typeof bound === 'string' ? bound : getValue(root, bound.field),\n );\n const time = toTime(value);\n if (boundTime !== null && time !== null) {\n valid = rule.rule === 'before' ? time < boundTime : time > boundTime;\n }\n break;\n }\n }\n if (!valid) {\n failures.push(detail !== null ? { ...failure(rule), value: detail } : failure(rule));\n }\n });\n return failures;\n}\n\nfunction addFailures(context: Context, path: string, failures: RuleFailure[]) {\n if (failures.length > 0) {\n context.failures[path] = [...(context.failures[path] ?? []), ...failures];\n }\n}\n\n/** A string setting of a field. */\nfunction stringSetting(field: Field, key: string): string | undefined {\n const value = field.settings?.[key];\n return typeof value === 'string' && value !== '' ? value : undefined;\n}\n\n/**\n * The rule each type implies: its values are checked whatever rules the field lists. `tel`,\n * `daterange` and `money` carry settings of their field: the extension, the open bounds, the\n * allowed currencies.\n */\nconst IMPLIED_RULES: Readonly<Record<string, (field: Field) => Rule>> = {\n json: () => ({ rule: 'json' }),\n tel: (field) =>\n field.settings?.extension === true ? { rule: 'tel', extension: true } : { rule: 'tel' },\n daterange: (field) => {\n const open = stringSetting(field, 'open');\n return { rule: 'daterange', ...(open !== undefined ? { open } : {}) } as Rule;\n },\n money: (field) => {\n const currency = stringSetting(field, 'currency');\n const listed = field.settings?.currencies;\n const currencies =\n currency !== undefined\n ? [currency]\n : Array.isArray(listed)\n ? listed.filter((code): code is string => typeof code === 'string')\n : [];\n return { rule: 'money', ...(currencies.length > 0 ? { currencies } : {}) } as Rule;\n },\n};\n\n/**\n * The rules of a field that apply in the mode, with the one its type implies: `json` for the\n * `json` type, `tel` for `tel`, `daterange` for `daterange` and `money` for `money`. A rule of\n * the same name on the field wins.\n */\nfunction rulesOf(field: Field, mode: CheckOptions['mode']): Rule[] {\n const rules = (field.rules ?? []).filter((rule) => appliesIn(rule, mode));\n const implied = IMPLIED_RULES[field.type]?.(field);\n return implied !== undefined && !rules.some((rule) => rule.rule === implied.rule)\n ? [...rules, implied]\n : rules;\n}\n\n/** The parts that make an address filled: a country or a point alone don't. */\nconst ADDRESS_TEXT_PARTS = ['street', 'unit', 'city', 'region', 'postalCode'] as const;\n\n/**\n * The checks of the parts of an `address` (decision 0054): a filled address, with a part other\n * than its country, has its required parts, and a postal code of its country.\n */\nfunction checkAddress(field: Field, value: unknown, path: string, context: Context) {\n if (!isRecord(value) || !ADDRESS_TEXT_PARTS.some((part) => isFilled(value[part]))) {\n return;\n }\n getAddressRequiredParts(field).forEach((part) => {\n if (!isFilled(value[part])) {\n addFailures(context, `${path}.${part}`, [{ rule: 'required' }]);\n }\n });\n const { postalCode, country } = value;\n if (\n typeof postalCode === 'string' &&\n isFilled(postalCode) &&\n !isPostalCode(postalCode, typeof country === 'string' ? country : null)\n ) {\n addFailures(context, `${path}.postalCode`, [{ rule: 'postalCode' }]);\n }\n}\n\n/** Whether a string is an email address. */\nconst isEmail = (text: string) => EMAIL.test(text);\n\n/** Whether the `url` of a link of a type is valid: the `rule` it fails, or `null`. */\nfunction checkLinkUrl(type: string, url: string, pattern: string | undefined): string | null {\n switch (type) {\n case 'url':\n return /^https?:\\/\\//i.test(url) && URL.canParse(url) ? null : 'url';\n case 'email':\n // `mailto:` and an address, with a query (`?subject=`) if any\n return /^mailto:/i.test(url) && isEmail(url.slice(7).split('?')[0] ?? '')\n ? null\n : 'email';\n case 'tel':\n return /^tel:/i.test(url) && TEL.test(url.slice(4)) ? null : 'tel';\n default:\n return pattern === undefined || new RegExp(pattern).test(url) ? null : 'pattern';\n }\n}\n\n/**\n * The checks of the parts of a `link` (decision 0055): a type of the field, the URL of its type,\n * its page or its file, and its label when the field requires one.\n */\nfunction checkLink(field: Field, value: unknown, path: string, context: Context) {\n if (!isRecord(value)) {\n return;\n }\n const types = getLinkTypes(field);\n const type = types.find((candidate) => candidate.id === value.type);\n if (type === undefined) {\n addFailures(context, `${path}.type`, [\n { rule: 'in', value: types.map((candidate) => candidate.id) },\n ]);\n return;\n }\n if (type.id === 'page' || type.id === 'file') {\n if (!isFilled(value[type.id])) {\n addFailures(context, `${path}.${type.id}`, [{ rule: 'required' }]);\n }\n } else if (typeof value.url !== 'string' || !isFilled(value.url)) {\n addFailures(context, `${path}.url`, [{ rule: 'required' }]);\n } else {\n const failed = checkLinkUrl(type.id, value.url.trim(), type.pattern);\n if (failed !== null) {\n addFailures(context, `${path}.url`, [\n failed === 'pattern' ? { rule: 'pattern', value: type.pattern } : { rule: failed },\n ]);\n }\n }\n const label = value.label;\n const hasLabel = isRecord(label) ? Object.values(label).some(isFilled) : isFilled(label);\n if (field.settings?.label === 'required' && !hasLabel) {\n addFailures(context, `${path}.label`, [{ rule: 'required' }]);\n }\n}\n\n/** The checks of the parts of a value that the field's type implies. */\nfunction checkParts(field: Field, value: unknown, path: string, context: Context) {\n if (field.type === 'address') {\n checkAddress(field, value, path, context);\n } else if (field.type === 'link') {\n checkLink(field, value, path, context);\n }\n}\n\nfunction checkFieldValue(field: Field, value: unknown, path: string, context: Context) {\n const rules = rulesOf(field, context.mode);\n if (field.localized === true) {\n const localized = isRecord(value) ? value : {};\n const required = rules.filter((rule) => rule.rule === 'required');\n const others = rules.filter((rule) => rule.rule !== 'required');\n if (required.length > 0) {\n const locales = context.locales;\n if (locales === undefined || locales.length === 0) {\n if (!Object.values(localized).some(isFilled)) {\n addFailures(context, path, required.map(failure));\n }\n } else {\n locales.forEach((locale) => {\n addFailures(\n context,\n `${path}.${locale}`,\n checkRules(required, localized[locale], context.root, context.mode),\n );\n });\n }\n }\n Object.entries(localized).forEach(([locale, localeValue]) => {\n addFailures(\n context,\n `${path}.${locale}`,\n checkRules(others, localeValue, context.root, context.mode),\n );\n checkParts(field, localeValue, `${path}.${locale}`, context);\n });\n return;\n }\n\n addFailures(context, path, checkRules(rules, value, context.root, context.mode));\n checkParts(field, value, path, context);\n\n // Compound fields of plugins check their `fields` as groups and repeaters do (decision 0065).\n const shape = getNestedShape(field);\n if (shape === 'group' && field.fields !== undefined && isRecord(value)) {\n checkFields(field.fields, value, `${path}.`, context);\n }\n if (shape === 'repeater' && Array.isArray(value)) {\n value.forEach((item, index) => {\n if (!isRecord(item)) {\n return;\n }\n const blockFields =\n field.types !== undefined\n ? field.types.find((type) => type.id === item.type)?.fields\n : field.fields;\n if (blockFields !== undefined) {\n checkFields(blockFields, item, `${path}.${index}.`, context);\n }\n });\n }\n}\n\nfunction checkFields(\n fields: Field[],\n values: Record<string, unknown>,\n prefix: string,\n context: Context,\n) {\n fields.forEach((field) => {\n if (field.readOnly === true || field.notInForm === true) {\n return;\n }\n if (context.mode === 'create' && field.updateOnly === true) {\n return;\n }\n if (context.mode === 'update' && field.createOnly === true) {\n return;\n }\n if (\n field.visibleWhen !== undefined &&\n !evaluateCondition(field.visibleWhen, prefix === '' ? context.root : values)\n ) {\n return;\n }\n if (context.partial === true && prefix === '' && !(field.name in values)) {\n return;\n }\n checkFieldValue(field, values[field.name], `${prefix}${field.name}`, context);\n });\n}\n\n/**\n * Checks form values against the portable rules of their fields. Returns the failures keyed by\n * the dot path of the value (`title.fr`, `blocks.2.image`), the same keys as validation errors.\n * Hidden and read-only fields, and fields that forms leave out (`notInForm`), are skipped. Rules\n * this version doesn't know are ignored.\n */\nexport function checkValues(\n fields: Field[],\n values: Record<string, unknown>,\n options: CheckOptions = {},\n): Record<string, RuleFailure[]> {\n const root =\n options.partial === true && options.item !== undefined\n ? { ...options.item, ...values }\n : values;\n const context: Context = { ...options, root, failures: {} };\n checkFields(fields, values, '', context);\n return context.failures;\n}\n"],"mappings":";;;;;;;;;AA8CA,IAAM,QAAQ;;AAEd,IAAM,MAAM;;AAEZ,IAAM,gBAAgB;AAEtB,SAAS,YAAY,MAAqB;CACtC,OAAQ,eAAqC,SAAS,KAAK,IAAI;AACnE;;;;;AAMA,SAAS,UAAU,MAAY,MAAqC;CAChE,OAAO,KAAK,SAAS,KAAA,KAAa,KAAK,SAAS;AACpD;AAEA,SAAS,QAAQ,MAAyB;CACtC,MAAM,SAAsB,EAAE,MAAM,KAAK,KAAK;CAC9C,IAAI,WAAW,QAAQ,KAAK,UAAU,KAAA,GAClC,OAAO,QAAQ,KAAK;CAExB,IAAI,KAAK,YAAY,KAAA,GACjB,OAAO,UAAU,KAAK;CAE1B,OAAO;AACX;AAEA,SAAS,OAAO,OAA+B;CAC3C,IAAI,OAAO,UAAU,UACjB,OAAO;CAGX,IAAI,SAAS,KAAK,KAAK,cAAc,SAAS,OAAO,MAAM,WAAW,UAClE,OAAO,MAAM;CAEjB,IAAI,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAChD,OAAO,MAAM;CAEjB,OAAO;AACX;AAEA,SAAS,YAAY,MAAc,UAA6B;CAC5D,OAAO,SAAS,MAAM,YAAY;EAC9B,IAAI,QAAQ,SAA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,MAAM,OAAO,GAAG,SAAS,MAAM,QAAQ,OAAO;CAChF,CAAC;AACL;;;;;;;AAQA,SAAgB,YACZ,QACA,QACA,UAAwB,CAAC,GACI;CAC7B,MAAM,OACF,QAAQ,YAAY,QAAQ,QAAQ,SAAS,KAAA,IACvC;EAAE,GAAG,QAAQ;EAAM,GAAG;CAAO,IAC7B;CACV,MAAM,UAAmB;EAAE,GAAG;EAAS;EAAM,UAAU,CAAC;CAAE;CAC1D,YAAY,QAAQ,QAAQ,IAAI,OAAO;CACvC,OAAO,QAAQ;AACnB"}
@@ -1,11 +1,21 @@
1
- export { PROBLEM_CONTENT_TYPE, PROTOCOL_VERSION } from '../version';
2
- export * from '../constants';
3
- export { type CheckOptions, type RuleFailure, checkRules, checkValues } from '../rules';
4
- export { evaluateCondition } from '../conditions';
5
- export { lintDefinition } from '../lint';
6
- export type { ValidationIssue } from '../validate';
7
- export { type FilterRange, type FilterValue, type ListQuery, fromSearchParams, isFilterRange, matchesFilterRange, toSearchParams, } from '../query';
8
- export { getValue, isFilled } from '../values';
9
- export { isProblem } from '../problem';
10
- export { type PartialTheme, mergeThemes } from '../themes';
1
+ export { PROBLEM_CONTENT_TYPE, PROTOCOL_VERSION } from '../version.js';
2
+ export * from '../constants.js';
3
+ export { type CurrencyCode, CURRENCY_CODES, fromMinorUnits, getCurrencyDigits, isCurrencyCode, toMinorUnits, } from '../currencies.js';
4
+ export { type CheckOptions, type RuleFailure, checkRules, checkValues } from '../rules.js';
5
+ export { evaluateCondition } from '../conditions.js';
6
+ export { type NestedShape, getNestedShape, isBuiltInFieldType, isCompoundField } from '../compound.js';
7
+ export { POSTAL_CODE_COUNTRIES, getAddressRequiredParts, isAddressPart, isPostalCode, normalizePostalCode, } from '../addresses.js';
8
+ export { type LinkNewTab, type LinkType, getLinkNewTab, getLinkTypes, isBuiltInLinkType, isExternalUrl, resolveLinkNewTab, } from '../links.js';
9
+ export { type ItemImageResource, type MediaLibrariesDefinition, getImageUrl, getItemImageField, getMediaLibraries, } from '../libraries.js';
10
+ export { ITEM_TYPE_KEY, getCreatableTypes, getItemType, getResourceType, getTypeFields, hasResourceTypes, } from '../resourceTypes.js';
11
+ export { matchesRatio, parseRatio, renderedCropSize } from '../transforms.js';
12
+ export { lintDefinition } from '../lint.js';
13
+ export type { ValidationIssue } from '../validate.js';
14
+ export { type FilterRange, type FilterValue, type CursorPageMeta, type ListQuery, isCursorPage, fromSearchParams, isFilterRange, matchesFilterRange, toSearchParams, } from '../query.js';
15
+ export { type ReadSearchQueryResult, type SearchQuery, type SearchableResource, SEARCH_DEFAULT_LIMIT, SEARCH_MAX_LENGTH, SEARCH_MAX_LIMIT, SEARCH_MIN_LENGTH, isSearchableResource, readSearchQuery, toSearchQueryParams, } from '../search.js';
16
+ export { getValue, isFilled } from '../values.js';
17
+ export { type ContextValues, contextBefore, formatContextHeader, parseContextHeader, } from '../context.js';
18
+ export { isProblem } from '../problem.js';
19
+ export { type PartialTheme, mergeThemes } from '../themes.js';
20
+ export { type BuiltInWidgetType, type WidgetResource, type WidgetSeriesPeriod, BUILT_IN_WIDGET_TYPES, RESOURCE_WIDGET_TYPES, WIDGET_LIST_MAX_ITEMS, WIDGET_RESERVED_QUERY_PARAMS, WIDGET_SERIES_PERIODS, checkWidgetData, getWidgetResource, isBuiltInWidgetType, } from '../widgets.js';
11
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACpE,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,Y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ACTIONS, BUILT_IN_FIELD_TYPES, BUILT_IN_LAYOUT_NODE_TYPES, BUILT_IN_LIST_LAYOUTS, PORTABLE_RULES } from "../constants.js";
2
+ import { ADDRESS_PARTS, AUTH_ERROR_CODES, AUTH_ERROR_PARAM, AUTH_PAGE_PATHS, BOOT_CONFIG_ELEMENT_ID, BUILT_IN_ACTIONS, BUILT_IN_FIELD_TYPES, BUILT_IN_ITEM_ACTIONS, BUILT_IN_LAYOUT_NODE_TYPES, BUILT_IN_LINK_ACTIONS, BUILT_IN_LINK_TYPES, BUILT_IN_LIST_LAYOUTS, CONTEXT_HEADER, CONTEXT_PROBLEM_TYPE, DATE_RANGE_OPEN_BOUNDS, DEFAULT_ADDRESS_REQUIRED_PARTS, DURATION_UNITS, EMAIL_UNVERIFIED_PROBLEM_TYPE, IDS_FILTER, IDS_FILTER_LIMIT, ITEM_ACTION_ABILITIES, PASSWORD_CONFIRMATION_PROBLEM_TYPE, PORTABLE_RULES, RESERVED_ROUTE_SEGMENTS, RICH_TEXT_STYLE_ELEMENTS, TWO_FACTOR_REQUIRED_PROBLEM_TYPE, UNDO_LIMIT, isBuiltInItemAction, isBuiltInLink } from "../constants.js";
3
+ import { CURRENCY_CODES, fromMinorUnits, getCurrencyDigits, isCurrencyCode, toMinorUnits } from "../currencies.js";
4
+ import { POSTAL_CODE_COUNTRIES, getAddressRequiredParts, isAddressPart, isPostalCode, normalizePostalCode } from "../addresses.js";
5
+ import { getNestedShape, isBuiltInFieldType, isCompoundField } from "../compound.js";
3
6
  import { getValue, isFilled } from "../values.js";
4
7
  import { evaluateCondition } from "../conditions.js";
8
+ import { getLinkNewTab, getLinkTypes, isBuiltInLinkType, isExternalUrl, resolveLinkNewTab } from "../links.js";
9
+ import { matchesRatio, parseRatio, renderedCropSize } from "../transforms.js";
5
10
  import { checkRules, checkValues } from "../rules.js";
11
+ import { getImageUrl, getItemImageField, getMediaLibraries } from "../libraries.js";
12
+ import { ITEM_TYPE_KEY, getCreatableTypes, getItemType, getResourceType, getTypeFields, hasResourceTypes } from "../resourceTypes.js";
13
+ import { fromSearchParams, isCursorPage, isFilterRange, matchesFilterRange, toSearchParams } from "../query.js";
14
+ import { BUILT_IN_WIDGET_TYPES, RESOURCE_WIDGET_TYPES, WIDGET_LIST_MAX_ITEMS, WIDGET_RESERVED_QUERY_PARAMS, WIDGET_SERIES_PERIODS, checkWidgetData, getWidgetResource, isBuiltInWidgetType } from "../widgets.js";
6
15
  import { lintDefinition } from "../lint.js";
7
- import { fromSearchParams, isFilterRange, matchesFilterRange, toSearchParams } from "../query.js";
16
+ import { SEARCH_DEFAULT_LIMIT, SEARCH_MAX_LENGTH, SEARCH_MAX_LIMIT, SEARCH_MIN_LENGTH, isSearchableResource, readSearchQuery, toSearchQueryParams } from "../search.js";
17
+ import { contextBefore, formatContextHeader, parseContextHeader } from "../context.js";
8
18
  import { isProblem } from "../problem.js";
9
19
  import { mergeThemes } from "../themes.js";
10
- export { BOOT_CONFIG_ELEMENT_ID, BUILT_IN_ACTIONS, BUILT_IN_FIELD_TYPES, BUILT_IN_LAYOUT_NODE_TYPES, BUILT_IN_LIST_LAYOUTS, PORTABLE_RULES, PROBLEM_CONTENT_TYPE, PROTOCOL_VERSION, checkRules, checkValues, evaluateCondition, fromSearchParams, getValue, isFilled, isFilterRange, isProblem, lintDefinition, matchesFilterRange, mergeThemes, toSearchParams };
20
+ export { ADDRESS_PARTS, AUTH_ERROR_CODES, AUTH_ERROR_PARAM, AUTH_PAGE_PATHS, BOOT_CONFIG_ELEMENT_ID, BUILT_IN_ACTIONS, BUILT_IN_FIELD_TYPES, BUILT_IN_ITEM_ACTIONS, BUILT_IN_LAYOUT_NODE_TYPES, BUILT_IN_LINK_ACTIONS, BUILT_IN_LINK_TYPES, BUILT_IN_LIST_LAYOUTS, BUILT_IN_WIDGET_TYPES, CONTEXT_HEADER, CONTEXT_PROBLEM_TYPE, CURRENCY_CODES, DATE_RANGE_OPEN_BOUNDS, DEFAULT_ADDRESS_REQUIRED_PARTS, DURATION_UNITS, EMAIL_UNVERIFIED_PROBLEM_TYPE, IDS_FILTER, IDS_FILTER_LIMIT, ITEM_ACTION_ABILITIES, ITEM_TYPE_KEY, PASSWORD_CONFIRMATION_PROBLEM_TYPE, PORTABLE_RULES, POSTAL_CODE_COUNTRIES, PROBLEM_CONTENT_TYPE, PROTOCOL_VERSION, RESERVED_ROUTE_SEGMENTS, RESOURCE_WIDGET_TYPES, RICH_TEXT_STYLE_ELEMENTS, SEARCH_DEFAULT_LIMIT, SEARCH_MAX_LENGTH, SEARCH_MAX_LIMIT, SEARCH_MIN_LENGTH, TWO_FACTOR_REQUIRED_PROBLEM_TYPE, UNDO_LIMIT, WIDGET_LIST_MAX_ITEMS, WIDGET_RESERVED_QUERY_PARAMS, WIDGET_SERIES_PERIODS, checkRules, checkValues, checkWidgetData, contextBefore, evaluateCondition, formatContextHeader, fromMinorUnits, fromSearchParams, getAddressRequiredParts, getCreatableTypes, getCurrencyDigits, getImageUrl, getItemImageField, getItemType, getLinkNewTab, getLinkTypes, getMediaLibraries, getNestedShape, getResourceType, getTypeFields, getValue, getWidgetResource, hasResourceTypes, isAddressPart, isBuiltInFieldType, isBuiltInItemAction, isBuiltInLink, isBuiltInLinkType, isBuiltInWidgetType, isCompoundField, isCurrencyCode, isCursorPage, isExternalUrl, isFilled, isFilterRange, isPostalCode, isProblem, isSearchableResource, lintDefinition, matchesFilterRange, matchesRatio, mergeThemes, normalizePostalCode, parseContextHeader, parseRatio, readSearchQuery, renderedCropSize, resolveLinkNewTab, toMinorUnits, toSearchParams, toSearchQueryParams };