@brydio/manifest 0.1.0-alpha.39 → 0.1.0-alpha.40

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": "@brydio/manifest",
3
- "version": "0.1.0-alpha.39",
3
+ "version": "0.1.0-alpha.40",
4
4
  "description": "The shape of a Brydio app's manifest, its collections' schemas, and the checks that say what is wrong with one.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/nakel-ola/brydio-sdk",
11
11
  "directory": "packages/manifest"
12
12
  },
13
- "gitHead": "4b20d567d9361683e104ec609d231111bd93bcbf",
13
+ "gitHead": "5ed892628acced988a9686e371721619ff50798c",
14
14
  "exports": {
15
15
  ".": {
16
16
  "types": "./src/index.d.ts",
@@ -12,7 +12,7 @@ import { type ZodType } from 'zod';
12
12
  * and everything downstream — the store, the generated tools, the screen's
13
13
  * form — reads that shape, never the manifest's spelling.
14
14
  */
15
- export type FieldKind = 'string' | 'text' | 'enum' | 'member' | 'project' | 'date' | 'number' | 'boolean' | 'string[]' | 'token' | 'canvas';
15
+ export type FieldKind = 'string' | 'text' | 'enum' | 'member' | 'project' | 'date' | 'number' | 'boolean' | 'string[]' | 'token' | 'canvas' | 'ref';
16
16
  export interface FieldType {
17
17
  kind: FieldKind;
18
18
  /** Written with a trailing `?`: may be left out on create. */
@@ -96,6 +96,10 @@ export declare class FieldTypeInvalid extends Error {
96
96
  readonly code: 'data_field_type_unknown' | 'data_enum_empty' | 'data_enum_too_many' | 'data_enum_value_invalid' | 'data_enum_duplicate' | 'data_default_not_allowed' | 'data_default_on_required' | 'data_default_invalid' | 'data_labels_not_allowed' | 'data_label_invalid' | 'data_label_unknown_value' | 'data_field_key_unknown' | 'data_coedit_not_text';
97
97
  constructor(code: 'data_field_type_unknown' | 'data_enum_empty' | 'data_enum_too_many' | 'data_enum_value_invalid' | 'data_enum_duplicate' | 'data_default_not_allowed' | 'data_default_on_required' | 'data_default_invalid' | 'data_labels_not_allowed' | 'data_label_invalid' | 'data_label_unknown_value' | 'data_field_key_unknown' | 'data_coedit_not_text', message: string);
98
98
  }
99
+ /** The longest record id a `ref` field holds. */
100
+ export declare const REF_CHARS = 128;
101
+ /** What a record id looks like: letters, digits, `_` and `-`; never words. */
102
+ export declare const REF_FORMAT: RegExp;
99
103
  /**
100
104
  * One field's manifest spelling, as a type.
101
105
  *
@@ -65,10 +65,12 @@ const STRUCTURED = new Set([
65
65
  'number',
66
66
  'boolean',
67
67
  'token',
68
+ // Another of the app's records, by id (DW06): an id, never words, so a list can name it.
69
+ 'ref',
68
70
  ]);
69
71
  /** Only the words in these may one day be searched (A3-F01-S02). */
70
72
  const SEARCHABLE = new Set(['string', 'text', 'string[]']);
71
- const SCALARS = new Set(['string', 'text', 'member', 'project', 'date', 'number', 'boolean', 'token', 'canvas']);
73
+ const SCALARS = new Set(['string', 'text', 'member', 'project', 'date', 'number', 'boolean', 'token', 'canvas', 'ref']);
72
74
  /** A field type the manifest wrote that Brydio does not have, or a bad list. */
73
75
  export class FieldTypeInvalid extends Error {
74
76
  code;
@@ -78,6 +80,10 @@ export class FieldTypeInvalid extends Error {
78
80
  this.name = 'FieldTypeInvalid';
79
81
  }
80
82
  }
83
+ /** The longest record id a `ref` field holds. */
84
+ export const REF_CHARS = 128;
85
+ /** What a record id looks like: letters, digits, `_` and `-`; never words. */
86
+ export const REF_FORMAT = /^[A-Za-z0-9_-]+$/;
81
87
  /**
82
88
  * One field's manifest spelling, as a type.
83
89
  *
@@ -262,6 +268,8 @@ export function valueSchema(type) {
262
268
  return z.array(z.string().max(FIELD_LIMITS.stringChars)).max(type.maxEntries ?? FIELD_LIMITS.listEntries);
263
269
  case 'canvas':
264
270
  return z.object({ elements: z.number().int().min(0), text: z.string().max(CANVAS_SUMMARY_CHARS) }).strict();
271
+ case 'ref':
272
+ return z.string().min(1).max(REF_CHARS).regex(REF_FORMAT);
265
273
  }
266
274
  }
267
275
  /**
@@ -299,6 +307,8 @@ export function valueProblem(field, type, value) {
299
307
  : `${field} must be a list of short texts, each at most ${FIELD_LIMITS.stringChars.toLocaleString('en-GB')} characters.`;
300
308
  case 'canvas':
301
309
  return `${field} is a drawing: it is changed on its board, never written.`;
310
+ case 'ref':
311
+ return `${field} must be the id of one of this app's records.`;
302
312
  }
303
313
  }
304
314
  /** A type in a few words, for a tool's description: every allowed value named. */
@@ -326,6 +336,8 @@ export function describeType(type) {
326
336
  return 'a list of short texts';
327
337
  case 'canvas':
328
338
  return 'a drawing, read only: how many shapes it has and the words on it';
339
+ case 'ref':
340
+ return "the id of another of this app's records";
329
341
  }
330
342
  }
331
343
  /** ", read as \"todo\" is To do, \"done\" is Done", for a choice with labels. */