@tryghost/metafield-types 0.2.0 → 0.4.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.
package/build/index.js CHANGED
@@ -1,8 +1,11 @@
1
1
  import { z } from 'zod';
2
- import { FIELD_PARTS, FIELD_TYPE_IDS } from './structure.js';
2
+ import { KeySchema, NamespaceSchema } from './identity.js';
3
+ import { FIELD_STRUCTURES, FIELD_TYPE_IDS, MAX_OPTIONS, MIN_OPTIONS, OPTION_SEPARATOR, optionKey, optionText, typesOfShape, } from './structure.js';
4
+ import { shaped } from './shapes.js';
5
+ export { FIELD_READING, LEAVES, SHAPES, editableValue, formShows, formTextOf, heldTextOf, formWrite, heldValue, leafFromText, shaped, shapedType, textOfValue, valueFromText, } from './shapes.js';
3
6
  // Re-exported so a caller that needs both halves still has one import. The split is
4
7
  // about what a bundle pays for, not about where the catalog lives.
5
- export { FIELD_KINDS, FIELD_PARTS, FIELD_TYPE_IDS, PART_TYPE_IDS, partTypesOf, partsOf, } from './structure.js';
8
+ export { FIELD_STRUCTURES, FIELD_TYPE_IDS, LIST_SOURCES, MAX_OPTIONS, MIN_OPTIONS, OPTION_SEPARATOR, TEXT_SIZES, choice, country, editableAnswers, inOptionOrder, isFieldType, isRecordValue, matchField, matchLeaf, matchShape, partsOf, text, keysOf, } from './structure.js';
6
9
  /**
7
10
  * The shared catalog of member metafield types.
8
11
  *
@@ -12,17 +15,18 @@ export { FIELD_KINDS, FIELD_PARTS, FIELD_TYPE_IDS, PART_TYPE_IDS, partTypesOf, p
12
15
  * last statement lives here and nowhere else, so that Ghost core, which enforces it, and
13
16
  * admin, which gives instant feedback against it, cannot disagree about what is valid.
14
17
  *
15
- * A type is one of two things. Most are a value in their own right, declared as the
16
- * schema that value must satisfy. An address is a *record*: a set of named parts, each a
17
- * value in the same sense, from which the whole type's schema is derived. Nothing stops a
18
- * part being a record itself.
18
+ * A type is composed of leaves, each one value with its own rule. Most types are a single
19
+ * leaf. An address is a *record*: a set of named parts, each a leaf, from which the whole
20
+ * type's rule is derived. A part is always a leaf, never a record itself.
19
21
  *
20
22
  * ## What a write may say
21
23
  *
22
- * A value is text, and so is every part of one. A write names what it means to change: a
23
- * name it does not mention is left as it was, and a name given an empty string is being
24
- * cleared. That is why every part accepts empty regardless of its own rule — emptying is
25
- * a statement about the write, not about the part.
24
+ * A value is a leaf's value, and so is every part of one. A write names what it means to
25
+ * change: a name it does not mention is left as it was, and a name given `null` is being
26
+ * cleared, whatever kind of leaf it holds. That is why every part accepts `null` regardless of
27
+ * its own rule: clearing is a statement about the write, not about the part. A value is never
28
+ * empty, so text of nothing but spaces, or a list picking nothing, is refused rather than being
29
+ * a second way of holding nothing.
26
30
  *
27
31
  * A name nobody recognizes is an error rather than a silent drop, at both depths. A
28
32
  * misspelled field key is refused by the values service, which alone knows which fields a
@@ -53,9 +57,9 @@ export { FIELD_KINDS, FIELD_PARTS, FIELD_TYPE_IDS, PART_TYPE_IDS, partTypesOf, p
53
57
  * answer and a disagreement between them is a file that silently stops round-tripping.
54
58
  *
55
59
  * The line is whether more than one renderer must agree on a string, not presentation
56
- * against validity — the sentences above are presentation. Admin is the only renderer
57
- * today, so a part's label lives there, held against this file by a type. A Portal
58
- * collection form, which cannot reach admin's packages, moves the labels here.
60
+ * against validity — the sentences above are presentation. Admin and Portal each label a
61
+ * record's parts in their own words, and each is held against the catalog by a type, so a
62
+ * part added there fails to compile in both until it has a label.
59
63
  */
60
64
  export const FieldTypeSchema = z.enum(FIELD_TYPE_IDS);
61
65
  /**
@@ -74,6 +78,158 @@ export const MEMBER_ACCESS = {
74
78
  read: 'read',
75
79
  write: 'write',
76
80
  };
81
+ /**
82
+ * Whether a field is in use. An archived field keeps its definition and the values members
83
+ * hold for it, so it can be restored, but it takes no new values and members no longer see it.
84
+ */
85
+ export const FIELD_STATUSES = ['active', 'archived'];
86
+ export const FieldStatusSchema = z.enum(FIELD_STATUSES);
87
+ export const FIELD_STATUS = {
88
+ active: 'active',
89
+ archived: 'archived',
90
+ };
91
+ /**
92
+ * A set field's settings as stored or sent back: their shape alone, which every read checks. A
93
+ * write checks the rules `SetSettingsSchema` layers on top, so a rule tightened later never hides
94
+ * a field set up under the old one, the way a value's rule never hides what a member already holds.
95
+ */
96
+ export const SetSettingsShape = z.object({
97
+ options: z.array(z.string({ error: 'Enter text for each option.' }), {
98
+ error: 'Give the list its options.',
99
+ }),
100
+ multiple: z.boolean({ error: 'Say whether members can pick more than one option.' }),
101
+ }, { error: 'Give the list its options.' });
102
+ /**
103
+ * Why an option's text, once tidied, can't be written, or null when it can. Its text is all that
104
+ * names it, so each bound is on the text as it is matched, and the separator a CSV cell joins
105
+ * options with can't appear in one.
106
+ */
107
+ function optionProblem(option) {
108
+ if (option.length === 0) {
109
+ return 'Enter text for each option.';
110
+ }
111
+ if (option.length > 255) {
112
+ return 'Use 255 characters or fewer for each option.';
113
+ }
114
+ if (option.includes(OPTION_SEPARATOR)) {
115
+ return `Options can't contain ${OPTION_SEPARATOR}.`;
116
+ }
117
+ return null;
118
+ }
119
+ /**
120
+ * What a set field is set up with: its shape, with each option's text tidied and the rules a write
121
+ * must meet on top. Options are a set as well, so the same option, compared by `optionKey`, can't
122
+ * be offered twice: the option that repeats an earlier one is refused, so a form shows the problem
123
+ * beside the option to change. They are listed in the order they are shown.
124
+ */
125
+ export const SetSettingsSchema = SetSettingsShape.transform(({ options, multiple }) => ({
126
+ options: options.map(optionText),
127
+ multiple,
128
+ })).check((ctx) => {
129
+ const { options } = ctx.value;
130
+ const offered = new Set();
131
+ options.forEach((option, index) => {
132
+ const key = optionKey(option);
133
+ const problem = optionProblem(option) ?? (offered.has(key) ? 'This option already exists.' : null);
134
+ offered.add(key);
135
+ if (problem) {
136
+ ctx.issues.push({
137
+ code: 'custom',
138
+ message: problem,
139
+ input: option,
140
+ path: ['options', index],
141
+ });
142
+ }
143
+ });
144
+ const listProblem = options.length < MIN_OPTIONS
145
+ ? `Give the list at least ${MIN_OPTIONS} options.`
146
+ : options.length > MAX_OPTIONS
147
+ ? `Give the list ${MAX_OPTIONS} options or fewer.`
148
+ : null;
149
+ if (listProblem) {
150
+ ctx.issues.push({ code: 'custom', message: listProblem, input: options, path: ['options'] });
151
+ }
152
+ });
153
+ /**
154
+ * A field whose type has nothing to set up has no settings, so a write that gives it some is
155
+ * refused.
156
+ */
157
+ const NO_SETTINGS = z.undefined({ error: 'Only a list field has settings.' }).optional();
158
+ const TYPE_ERROR = { error: 'Choose a type of custom field.' };
159
+ /**
160
+ * What a field holds beside its type, `base`, with its type and the settings that type's shape
161
+ * takes, held as `settings` says for each shape: a set's options, and nothing for any other shape.
162
+ * One variant per shape, so a field's settings are always read against its type. Writes give the
163
+ * rules, reads the shape alone, and Ghost's table its column.
164
+ */
165
+ export const withTypedSettings = (base, settings) => {
166
+ // Keyed by shape, so a shape added to the catalog fails to compile here until it has a variant.
167
+ const variants = {
168
+ scalar: z.object({ ...base, type: z.enum(typesOfShape('scalar')), settings: settings.scalar }),
169
+ record: z.object({ ...base, type: z.enum(typesOfShape('record')), settings: settings.record }),
170
+ set: z.object({ ...base, type: z.enum(typesOfShape('set')), settings: settings.set }),
171
+ };
172
+ return z.discriminatedUnion('type', [variants.scalar, variants.record, variants.set], TYPE_ERROR);
173
+ };
174
+ /**
175
+ * Each shape's settings in one place: a set's options and whether a member picks several, and
176
+ * nothing for any other shape. A list's defaults have no options, which a list's write rules
177
+ * refuse, so an edit of a list read with its defaults always writes the settings it is given.
178
+ * Keyed by shape, so a shape added to the catalog fails to compile until it has an entry.
179
+ */
180
+ export const SHAPE_SETTINGS = {
181
+ scalar: { written: NO_SETTINGS, read: NO_SETTINGS, defaults: undefined },
182
+ record: { written: NO_SETTINGS, read: NO_SETTINGS, defaults: undefined },
183
+ set: {
184
+ written: SetSettingsSchema,
185
+ read: SetSettingsShape,
186
+ defaults: { options: [], multiple: false },
187
+ },
188
+ };
189
+ /** Each shape's settings as a write states them, checked against the rules. */
190
+ export const WRITTEN_SETTINGS = {
191
+ scalar: SHAPE_SETTINGS.scalar.written,
192
+ record: SHAPE_SETTINGS.record.written,
193
+ set: SHAPE_SETTINGS.set.written,
194
+ };
195
+ /** Each shape's settings as they are read back, checked for their shape alone. */
196
+ export const READ_SETTINGS = {
197
+ scalar: SHAPE_SETTINGS.scalar.read,
198
+ record: SHAPE_SETTINGS.record.read,
199
+ set: SHAPE_SETTINGS.set.read,
200
+ };
201
+ /**
202
+ * Where a refusal points within what was sent: the path to the refused value, with its parts and
203
+ * positions joined by dots, such as `settings.options.2` for a field's third option. Ghost names
204
+ * a refusal's `property` this way, and a form files the problems it finds under the same keys, so
205
+ * each lands beside the input that set the value.
206
+ */
207
+ export function refusedProperty(path) {
208
+ return path.map(String).join('.');
209
+ }
210
+ /**
211
+ * A field's type and settings as a write states them, checked together and against the rules:
212
+ * the settings must be what that type is set up with, so a list carries its options and
213
+ * nothing else carries any.
214
+ */
215
+ export const TypedSettingsInputSchema = withTypedSettings({}, WRITTEN_SETTINGS);
216
+ /** A field's type and settings as they are read back: paired, but checked for their shape alone. */
217
+ export const TypedSettingsSchema = withTypedSettings({}, READ_SETTINGS);
218
+ /**
219
+ * A field definition as the Admin and Members APIs return it. Ghost writes every definition through
220
+ * this and Admin reads every one through it, so both ends are checked against one shape. Portal
221
+ * uses the type without the check, because zod would add to every page view on every site. Dates
222
+ * are ISO strings, as JSON carries them.
223
+ */
224
+ export const MetafieldDefinitionSchema = withTypedSettings({
225
+ namespace: NamespaceSchema,
226
+ key: KeySchema,
227
+ name: z.string(),
228
+ status: FieldStatusSchema,
229
+ access: z.object({ member: MemberAccessSchema }),
230
+ created_at: z.iso.datetime(),
231
+ updated_at: z.iso.datetime().nullable(),
232
+ }, READ_SETTINGS);
77
233
  /**
78
234
  * Where a change to a member's values was made, as a member's activity feed names it.
79
235
  * Shared so a place added on the server is one Admin has to be told how to describe.
@@ -86,7 +242,7 @@ export const METAFIELD_CHANGE_SOURCES = [
86
242
  'checkout',
87
243
  ];
88
244
  /** Whether a source is one this build knows how to name; a newer server can send others. */
89
- export const isMetafieldChangeSource = (source) => METAFIELD_CHANGE_SOURCES.includes(source);
245
+ export const isMetafieldChangeSource = (source) => METAFIELD_CHANGE_SOURCES.some((known) => known === source);
90
246
  /** A field as an activity feed entry names it: its name is copied so the entry outlives a rename. */
91
247
  export const MetafieldChangeEventFieldSchema = z.object({
92
248
  namespace: z.string(),
@@ -101,103 +257,172 @@ export const MAX_LONG_TEXT_BYTES = 65535;
101
257
  // TextEncoder rather than Buffer: this package runs in the browser too.
102
258
  const byteLength = (value) => new TextEncoder().encode(value).length;
103
259
  /**
104
- * Every value and every part is built from this, so no two types can disagree about
105
- * whitespace: a value of nothing but spaces is nothing, whichever field it was typed
106
- * into. Trimming first also makes each bound measure the value rather than its padding.
107
- *
108
- * Builders are named after what a value is rather than taking a size, so that a bound
109
- * lives with everything else true of that thing instead of as a number at the call site.
260
+ * Every text leaf's rule is built from this, so no two leaves can disagree about whitespace.
261
+ * Trimming first also makes each bound measure the value rather than its padding.
110
262
  */
111
- const text = () => z.string({ error: 'Enter text.' }).trim();
112
- const longText = () => text().refine((value) => byteLength(value) <= MAX_LONG_TEXT_BYTES, {
113
- error: 'This text is too long to save. Shorten it a little.',
114
- });
115
- /**
116
- * The types a composite's parts can declare, each defined once with its rule. A country
117
- * code and a postal code both store short text, but they are different things — the
118
- * part's type is what a control or a filter dispatches on, the way a field's own type
119
- * is for a scalar.
120
- */
121
- export const PART_TYPES = {
122
- short_text: text().max(255, { error: 'Use 255 characters or fewer.' }),
123
- // A postal code, bounded well under a street address because no country's is long. The
124
- // bound is a sanity limit rather than a format: postal codes vary too much between
125
- // countries to check the shape of one without knowing which country it is for, and the
126
- // country is a sibling part rather than something this can see.
127
- postal_code: text().max(32, { error: 'Use 32 characters or fewer.' }),
128
- // The shape of an ISO 3166-1 alpha-2 code, deliberately not checked against the list of
129
- // them. Membership of that list is contested, and a closed list here would make Ghost
130
- // the arbiter of it for every member of every site. The collection form can offer
131
- // countries to pick from without this deciding which ones exist.
132
- //
133
- // Case is normalized so that `gb` and `GB` are not two values for one place, which a
134
- // filter for either would silently half-miss.
263
+ const trimmed = () => z.string({ error: 'Enter text.' }).trim();
264
+ /** Text that holds something: text of nothing but spaces is refused, since a write clears with `null`. */
265
+ const filled = () => trimmed().min(1, { error: 'Enter a value, or send null to clear it.' });
266
+ /** Each text size's bound. Each message is a literal, so it can be a translation key. */
267
+ const TEXT_RULES = {
268
+ line: () => filled().max(255, { error: 'Use 255 characters or fewer.' }),
269
+ // A sanity limit rather than a format, used for postal codes: they vary too much between
270
+ // countries to check the shape of one without knowing the country, and the country is a
271
+ // sibling part rather than something this can see.
272
+ code: () => filled().max(32, { error: 'Use 32 characters or fewer.' }),
273
+ long: () => filled().refine((value) => byteLength(value) <= MAX_LONG_TEXT_BYTES, {
274
+ error: 'This text is too long to save. Shorten it a little.',
275
+ }),
276
+ };
277
+ /** Which keys each list accepts. */
278
+ const LIST_RULES = {
279
+ // The shape of an ISO 3166-1 alpha-2 code, deliberately not checked against the list of them.
280
+ // Membership of that list is contested, and a closed list here would make Ghost the arbiter of
281
+ // it for every member of every site. Clients offer countries to pick from without this deciding
282
+ // which ones exist.
135
283
  //
136
- // Checked as two ASCII letters on the way in rather than by length on the way out,
137
- // because uppercasing does not preserve length: `ß` becomes `SS` and `aß` becomes `ASS`.
138
- country_code: text()
284
+ // Case is normalized so that `gb` and `GB` are not two values for one place, which a filter for
285
+ // either would silently half-miss. Checked as two ASCII letters on the way in rather than by
286
+ // length on the way out, because uppercasing does not preserve length: `ß` becomes `SS`.
287
+ countries: () => filled()
139
288
  .regex(/^[A-Za-z]{2}$/, { error: 'Enter a 2-letter country code, like US.' })
140
289
  .toUpperCase(),
141
- // Every part type declared next door needs a rule here, and nothing here may
142
- // invent one that is not declared there.
143
290
  };
144
- const partSchemas = PART_TYPES;
291
+ /** Each kind of leaf's rule. Keyed by kind, so a kind added to the catalog fails to compile here. */
292
+ const LEAF_RULES = {
293
+ text: ({ size }) => TEXT_RULES[size](),
294
+ choice: ({ from }) => LIST_RULES[from](),
295
+ };
296
+ /** A leaf's rule, whichever kind of leaf it is. */
297
+ const leafRule = (leaf) => LEAF_RULES[leaf.leaf](leaf);
298
+ /**
299
+ * A part as a write may name it: absent to leave it alone, `null` to clear it, or a value of its
300
+ * own leaf. Every part clears the same way, whatever its leaf's rule, so none can be set but never
301
+ * removed.
302
+ */
303
+ const part = (leaf) => leafRule(leaf).nullable().optional();
304
+ /** What each record type says when a write names none of its parts. */
305
+ const RECORD_EMPTY = {
306
+ address: 'Enter at least one part of the address.',
307
+ };
308
+ /**
309
+ * A record type's rule, derived from its parts.
310
+ *
311
+ * A record's parts are all optional, because none of an address's exists everywhere: there is no
312
+ * postal code in Ireland or Hong Kong, and no city in an Irish townland address. What holds instead
313
+ * is that a value names at least one part. The check is on each part being a string because an
314
+ * optional part that is explicitly undefined survives parsing as a key holding undefined, and a
315
+ * bare presence check would let `{line1: undefined}` through as if it named something.
316
+ *
317
+ * A record is strict, so a part nobody declared is refused rather than dropped, in zod's wording,
318
+ * which names the offending key.
319
+ */
320
+ function recordRule(type) {
321
+ return z
322
+ .strictObject(Object.fromEntries(Object.entries(FIELD_STRUCTURES[type].parts).map(([name, leaf]) => [name, part(leaf)])))
323
+ .refine((value) => Object.values(value).some((entry) => entry !== undefined), {
324
+ error: RECORD_EMPTY[type],
325
+ });
326
+ }
145
327
  /**
146
- * A part as a write may name it: absent, empty, or a value of its own kind.
328
+ * A set field's rule, from its own options: the text of each option picked, picking any option
329
+ * once however often it is named, and only one of them when the field takes one. A failure is
330
+ * reported against the whole field rather than at a position in the list, which a client would
331
+ * read as an option named by a number.
147
332
  *
148
- * A rule that is a bound would admit empty on its own; one that is a format would not,
149
- * and would leave its part the only one that could be set but never removed.
333
+ * Checked when an answer is given and never again: a publisher can change the options later, and
334
+ * an answer keeps what was picked.
150
335
  */
151
- const clearable = (schema) => text()
152
- .pipe(z.union([z.literal(''), schema]))
153
- .optional();
336
+ function setRule({ options, multiple }) {
337
+ const offered = new Set(options);
338
+ return z
339
+ .array(z.unknown(), { error: 'Choose from the options this field offers.' })
340
+ .transform((picked, ctx) => {
341
+ const texts = picked.filter((option) => typeof option === 'string');
342
+ if (texts.length < picked.length) {
343
+ ctx.issues.push({
344
+ code: 'custom',
345
+ message: 'Choose from the options this field offers.',
346
+ input: picked,
347
+ });
348
+ return z.NEVER;
349
+ }
350
+ return [...new Set(texts.map(optionText))];
351
+ })
352
+ .check((ctx) => {
353
+ if (ctx.value.length === 0) {
354
+ // A list holding nothing is no answer, which a write gives as `null`.
355
+ ctx.issues.push({
356
+ code: 'custom',
357
+ message: 'Choose at least one option, or send null to clear it.',
358
+ input: ctx.value,
359
+ });
360
+ }
361
+ else if (ctx.value.some((option) => !offered.has(option))) {
362
+ ctx.issues.push({
363
+ code: 'custom',
364
+ message: 'Choose from the options this field offers.',
365
+ input: ctx.value,
366
+ });
367
+ }
368
+ else if (!multiple && ctx.value.length > 1) {
369
+ ctx.issues.push({ code: 'custom', message: 'Choose one option.', input: ctx.value });
370
+ }
371
+ });
372
+ }
154
373
  /**
155
- * Every type states its kind alongside its schema, so no type can exist that nothing knows
156
- * how to compare. The `Record<FieldType, …>` is what makes that exhaustive: an id added to
157
- * `FIELD_TYPE_IDS` fails to compile until it is declared here.
374
+ * `build` run once per type, for a rule that comes from the type alone: Ghost checks every value an
375
+ * import writes through these rules, and Admin every keystroke.
158
376
  */
159
- function defineFieldTypes(declarations) {
160
- return declarations;
377
+ function oncePerType(build) {
378
+ const built = new Map();
379
+ return (type) => {
380
+ const rule = built.get(type) ?? build(type);
381
+ built.set(type, rule);
382
+ return rule;
383
+ };
161
384
  }
385
+ const scalarRule = oncePerType((type) => leafRule(FIELD_STRUCTURES[type].leaf));
386
+ const recordRuleOf = oncePerType(recordRule);
162
387
  /**
163
- * Every part is optional, because none of an address's exists everywhere: there is no
164
- * postal code in Ireland or Hong Kong, and no city in an Irish townland address. Which
165
- * parts a value needs is a per-country question, and only the collection form knows the
166
- * country. What holds instead is that a value must name at least one part.
167
- *
168
- * The type check below is load-bearing rather than defensive. An optional part that is
169
- * explicitly undefined survives parsing as a key holding undefined, and a bare presence
170
- * check would let `{line1: undefined}` through as if it named something.
171
- */
172
- function record(type, { error }) {
173
- // The parts, and what each holds, are declared in `./structure`; this turns each
174
- // into the rule a write must satisfy. Reading them from there is what stops the
175
- // structure a renderer draws and the rules a server enforces from drifting apart.
176
- const declared = FIELD_PARTS[type];
177
- // Restated for the type system, which loses the key-to-part mapping through
178
- // `Object.fromEntries`. Without it the parsed value widens to a string-keyed record,
179
- // and a caller could name a part that compiles and is then refused at runtime.
180
- const shape = Object.fromEntries(Object.entries(declared).map(([key, partType]) => [key, clearable(partSchemas[partType])]));
181
- // Strict, so a part nobody declared is refused rather than dropped. That refusal keeps
182
- // zod's wording, which names the offending key.
183
- const value = z
184
- .strictObject(shape)
185
- .refine((parts) => Object.values(parts).some((entry) => typeof entry === 'string'), { error });
186
- return { kind: 'record', value };
388
+ * Each shape's strict rule for a write, from what a field's type is composed of and, for a set,
389
+ * the options the field offers. Keyed by shape, so a shape added to the catalog fails to compile
390
+ * here until it has a rule.
391
+ */
392
+ const WRITE_RULES = {
393
+ scalar: ({ type }) => scalarRule(type),
394
+ record: ({ type }) => recordRuleOf(type),
395
+ set: ({ settings }) => setRule(settings),
396
+ };
397
+ function writeRuleOf({ shape, field, }) {
398
+ return WRITE_RULES[shape](field);
399
+ }
400
+ /** A field's rule, from what its type is composed of and, for a set, the options the field offers. */
401
+ function ruleOf(field) {
402
+ return writeRuleOf(shaped(field));
403
+ }
404
+ /**
405
+ * Strict, for a write, under the field's rule today: only options the field offers now, one answer
406
+ * when it takes one, and each part valid under its leaf's rule. What a held value reads as is
407
+ * lenient instead, and is `FIELD_READING`'s to say.
408
+ */
409
+ export function accept(of, raw) {
410
+ const result = writeRuleOf(of).brand().safeParse(raw);
411
+ return result.success
412
+ ? { success: true, accepted: acceptedAs(of.shape, result.data) }
413
+ : { success: false, issues: result.error.issues };
414
+ }
415
+ function acceptedAs(shape, value) {
416
+ return { shape, value };
417
+ }
418
+ /**
419
+ * The rule a write to one field must satisfy, which parses to the write it accepts: a record's
420
+ * part named as `null` clears it. It takes the field rather than its type so that a
421
+ * rule depending on the field's own setup, such as the options a list field offers, changes here
422
+ * and nowhere else; such a rule is built from the field rather than kept per type. Throws for a
423
+ * type this build doesn't know.
424
+ */
425
+ export function valueSchemaFor(field) {
426
+ return ruleOf(field);
187
427
  }
188
- export const FIELD_TYPES = defineFieldTypes({
189
- short_text: { kind: 'text', value: PART_TYPES.short_text },
190
- long_text: { kind: 'text', value: longText() },
191
- // An address is a delivery address, so its bounds are what a courier will accept
192
- // rather than what the column could hold. Modeled on Stripe's Address object.
193
- //
194
- // Who the parcel is addressed to is not here. A parcel needs a name as well as an
195
- // address, but that is a fact about posting parcels rather than about either type,
196
- // and the name is often not the account name — gift subscriptions, workplace
197
- // deliveries, c/o. A site that needs one keeps it in a field of its own, which is
198
- // also how Stripe hands it back: beside the address rather than inside it.
199
- address: record('address', { error: 'Enter at least one part of the address.' }),
200
- });
201
- /** Named for the admin types built on it, which speak of an address rather than a record. */
202
- export const AddressValue = FIELD_TYPES.address.value;
203
428
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAiC,MAAM,gBAAgB,CAAC;AAE5F,oFAAoF;AACpF,mEAAmE;AACnE,OAAO,EACL,WAAW,EACX,WAAW,EACX,cAAc,EACd,aAAa,EACb,WAAW,EACX,OAAO,GAKR,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC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