@fabrika/check 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/check",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,11 +46,11 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@babel/parser": "8.0.7",
49
- "@fabrika/app": "0.5.4",
50
- "@fabrika/auth-core": "0.5.4",
51
- "@fabrika/db": "0.5.4",
52
- "@fabrika/operations-contract": "0.5.4",
53
- "@fabrika/platform-node": "0.5.4",
49
+ "@fabrika/app": "0.5.5",
50
+ "@fabrika/auth-core": "0.5.5",
51
+ "@fabrika/db": "0.5.5",
52
+ "@fabrika/operations-contract": "0.5.5",
53
+ "@fabrika/platform-node": "0.5.5",
54
54
  "zod": "^3.25.76"
55
55
  }
56
56
  }
@@ -386,6 +386,7 @@ class SurfaceReader {
386
386
  challenge: formChallenge(options.get('challenge')),
387
387
  then: optionalText(options.get('then'), 'then'),
388
388
  ...crossOriginOption(options.get('crossOrigin')),
389
+ ...formFiles(options.get('files')),
389
390
  unknownOptions: optionKeys(options, 'form'),
390
391
  }
391
392
  }
@@ -1047,14 +1048,39 @@ function importDeclaration(name: string, value: LiteralValue): ImportDeclaration
1047
1048
  }
1048
1049
 
1049
1050
  /** A form's `rate`, as `buildArtifact` reads it: per-minute counts, each optional. */
1050
- function formRate(value: LiteralValue | undefined): { perClient?: number; perForm?: number } | undefined {
1051
+ function formRate(value: LiteralValue | undefined): { perClient?: number; perForm?: number; bytesPerHour?: number } | undefined {
1051
1052
  if (value === undefined) {
1052
1053
  return undefined
1053
1054
  }
1054
- const fields = strictFields(value, 'rate', [], ['perClient', 'perForm'])
1055
+ const fields = strictFields(value, 'rate', [], ['perClient', 'perForm', 'bytesPerHour'])
1055
1056
  const perClient = optionalNumber(fields.get('perClient'), 'perClient')
1056
1057
  const perForm = optionalNumber(fields.get('perForm'), 'perForm')
1057
- return { ...(perClient === undefined ? {} : { perClient }), ...(perForm === undefined ? {} : { perForm }) }
1058
+ const bytesPerHour = optionalNumber(fields.get('bytesPerHour'), 'bytesPerHour')
1059
+ return {
1060
+ ...(perClient === undefined ? {} : { perClient }),
1061
+ ...(perForm === undefined ? {} : { perForm }),
1062
+ ...(bytesPerHour === undefined ? {} : { bytesPerHour }),
1063
+ }
1064
+ }
1065
+
1066
+ /** A form's `files`: each file field's collection and whether a submission must carry it; `buildArtifact` checks them. */
1067
+ function formFiles(value: LiteralValue | undefined): { readonly files?: Record<string, { collection: string; required?: boolean }> } {
1068
+ if (value === undefined) {
1069
+ return {}
1070
+ }
1071
+ if (value.kind !== 'object') {
1072
+ throw new Refused(value.at, `files is a ${describeKind(value)}`, "files: { photo: { collection: '<collection>' } }")
1073
+ }
1074
+ const files: Record<string, { collection: string; required?: boolean }> = {}
1075
+ for (const [field, entry] of value.entries) {
1076
+ const fields = strictFields(entry, `file '${field}'`, ['collection'], ['required'])
1077
+ const required = fields.get('required')
1078
+ files[field] = {
1079
+ collection: text(fields.get('collection'), entry, 'collection'),
1080
+ ...(required === undefined ? {} : { required: boolean(required, 'required') }),
1081
+ }
1082
+ }
1083
+ return { files }
1058
1084
  }
1059
1085
 
1060
1086
  /** A form's `challenge`: a provider of the closed list and the names of the application variables with its secret and site key. */