@brydio/manifest 0.1.0-alpha.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.
@@ -0,0 +1,381 @@
1
+ import { z } from 'zod';
2
+ import { FieldTypeInvalid, type FieldType } from './field-types.js';
3
+ export { COLOUR_TOKENS, FIELD_LIMITS, parseFieldType, RESERVED_FIELDS, structuredFields, type FieldKind, type FieldType, } from './field-types.js';
4
+ /** Most custom tools one app may declare (A3-F08). */
5
+ export declare const MAX_CUSTOM_TOOLS = 20;
6
+ /** A tool name the model and a policy row can both use as it is. */
7
+ export declare const CUSTOM_TOOL_NAME: RegExp;
8
+ /**
9
+ * A tool the app writes itself (A3-F08-S01): a handler file in its bundle,
10
+ * run on Brydio's side in a box, taking `input` in the field-type grammar.
11
+ */
12
+ declare const customToolSchema: z.ZodObject<{
13
+ name: z.ZodString;
14
+ description: z.ZodString;
15
+ handler: z.ZodString;
16
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
17
+ write: z.ZodOptional<z.ZodBoolean>;
18
+ collection: z.ZodOptional<z.ZodString>;
19
+ }, z.core.$strip>;
20
+ export type CustomToolSpec = z.infer<typeof customToolSchema>;
21
+ declare const extensionShape: {
22
+ placements: z.ZodOptional<z.ZodArray<z.ZodObject<{
23
+ kind: z.ZodEnum<{
24
+ "project-tab": "project-tab";
25
+ "project-sidebar": "project-sidebar";
26
+ "workspace-sidebar": "workspace-sidebar";
27
+ }>;
28
+ screen: z.ZodString;
29
+ label: z.ZodOptional<z.ZodString>;
30
+ icon: z.ZodOptional<z.ZodString>;
31
+ }, z.core.$strip>>>;
32
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
33
+ schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
34
+ search: z.ZodOptional<z.ZodArray<z.ZodString>>;
35
+ label: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strip>>>;
37
+ tools: z.ZodOptional<z.ZodObject<{
38
+ generated: z.ZodOptional<z.ZodBoolean>;
39
+ custom: z.ZodOptional<z.ZodArray<z.ZodObject<{
40
+ name: z.ZodString;
41
+ description: z.ZodString;
42
+ handler: z.ZodString;
43
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
44
+ write: z.ZodOptional<z.ZodBoolean>;
45
+ collection: z.ZodOptional<z.ZodString>;
46
+ }, z.core.$strip>>>;
47
+ }, z.core.$strip>>;
48
+ screens: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
49
+ entry: z.ZodString;
50
+ }, z.core.$strip>>>;
51
+ grants: z.ZodOptional<z.ZodObject<{
52
+ tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
53
+ collections: z.ZodOptional<z.ZodArray<z.ZodString>>;
54
+ host: z.ZodOptional<z.ZodArray<z.ZodString>>;
55
+ }, z.core.$strip>>;
56
+ /**
57
+ * How records move when the schema changes between versions (A3-F07).
58
+ * Checked against the previous version when a version is published, and
59
+ * again when a workspace's pin moves; here only its shape.
60
+ */
61
+ migrations: z.ZodOptional<z.ZodArray<z.ZodObject<{
62
+ version: z.ZodString;
63
+ steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
64
+ op: z.ZodLiteral<"add">;
65
+ collection: z.ZodString;
66
+ field: z.ZodString;
67
+ default: z.ZodOptional<z.ZodUnknown>;
68
+ }, z.core.$strip>, z.ZodObject<{
69
+ op: z.ZodLiteral<"rename">;
70
+ collection: z.ZodString;
71
+ from: z.ZodString;
72
+ to: z.ZodString;
73
+ }, z.core.$strip>, z.ZodObject<{
74
+ op: z.ZodLiteral<"drop">;
75
+ collection: z.ZodString;
76
+ field: z.ZodString;
77
+ }, z.core.$strip>, z.ZodObject<{
78
+ op: z.ZodLiteral<"dropCollection">;
79
+ collection: z.ZodString;
80
+ }, z.core.$strip>, z.ZodObject<{
81
+ op: z.ZodLiteral<"replace">;
82
+ collection: z.ZodString;
83
+ field: z.ZodString;
84
+ from: z.ZodString;
85
+ to: z.ZodString;
86
+ }, z.core.$strip>], "op">>;
87
+ }, z.core.$strip>>>;
88
+ /**
89
+ * The `@brydio/app` version the bundle was built against, written by
90
+ * `brydio build` and never by hand. Optional, so a bundle from before it
91
+ * still loads; `POST /apps/publish` requires it and checks it (A5-F04-S03).
92
+ */
93
+ sdk: z.ZodOptional<z.ZodString>;
94
+ };
95
+ /** One problem with an app's additions, named down to the field. */
96
+ export interface DataProblem {
97
+ code: DataProblemCode;
98
+ collection?: string;
99
+ field?: string;
100
+ message: string;
101
+ }
102
+ export type DataProblemCode = FieldTypeInvalid['code'] | 'data_too_many_collections' | 'data_too_many_fields' | 'data_collection_name_format' | 'data_field_name_format' | 'data_field_reserved' | 'data_label_format' | 'data_label_taken' | 'data_project_field_twice' | 'data_search_unknown_field' | 'data_search_not_text' | 'grant_collection_missing' | 'grant_tool_missing' | 'custom_name_taken' | 'custom_collection_unknown' | 'custom_input_invalid' | 'placement_screen_unknown';
103
+ type Additions = z.infer<z.ZodObject<typeof extensionShape>>;
104
+ /**
105
+ * Everything wrong with an app's additions that a type cannot say.
106
+ *
107
+ * Exported on its own so E5's validator can fold the codes into its import
108
+ * report; the zod schemas below run it too, so a parse never accepts what
109
+ * this refuses.
110
+ */
111
+ export declare function dataProblems(additions: Additions, options?: {
112
+ grants?: boolean;
113
+ }): DataProblem[];
114
+ /** The additions alone, for code that has the rest of the manifest already. */
115
+ export declare const manifestExtensionsSchema: z.ZodObject<{
116
+ placements: z.ZodOptional<z.ZodArray<z.ZodObject<{
117
+ kind: z.ZodEnum<{
118
+ "project-tab": "project-tab";
119
+ "project-sidebar": "project-sidebar";
120
+ "workspace-sidebar": "workspace-sidebar";
121
+ }>;
122
+ screen: z.ZodString;
123
+ label: z.ZodOptional<z.ZodString>;
124
+ icon: z.ZodOptional<z.ZodString>;
125
+ }, z.core.$strip>>>;
126
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
127
+ schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
128
+ search: z.ZodOptional<z.ZodArray<z.ZodString>>;
129
+ label: z.ZodOptional<z.ZodString>;
130
+ }, z.core.$strip>>>;
131
+ tools: z.ZodOptional<z.ZodObject<{
132
+ generated: z.ZodOptional<z.ZodBoolean>;
133
+ custom: z.ZodOptional<z.ZodArray<z.ZodObject<{
134
+ name: z.ZodString;
135
+ description: z.ZodString;
136
+ handler: z.ZodString;
137
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
138
+ write: z.ZodOptional<z.ZodBoolean>;
139
+ collection: z.ZodOptional<z.ZodString>;
140
+ }, z.core.$strip>>>;
141
+ }, z.core.$strip>>;
142
+ screens: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
143
+ entry: z.ZodString;
144
+ }, z.core.$strip>>>;
145
+ grants: z.ZodOptional<z.ZodObject<{
146
+ tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
147
+ collections: z.ZodOptional<z.ZodArray<z.ZodString>>;
148
+ host: z.ZodOptional<z.ZodArray<z.ZodString>>;
149
+ }, z.core.$strip>>;
150
+ migrations: z.ZodOptional<z.ZodArray<z.ZodObject<{
151
+ version: z.ZodString;
152
+ steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
153
+ op: z.ZodLiteral<"add">;
154
+ collection: z.ZodString;
155
+ field: z.ZodString;
156
+ default: z.ZodOptional<z.ZodUnknown>;
157
+ }, z.core.$strip>, z.ZodObject<{
158
+ op: z.ZodLiteral<"rename">;
159
+ collection: z.ZodString;
160
+ from: z.ZodString;
161
+ to: z.ZodString;
162
+ }, z.core.$strip>, z.ZodObject<{
163
+ op: z.ZodLiteral<"drop">;
164
+ collection: z.ZodString;
165
+ field: z.ZodString;
166
+ }, z.core.$strip>, z.ZodObject<{
167
+ op: z.ZodLiteral<"dropCollection">;
168
+ collection: z.ZodString;
169
+ }, z.core.$strip>, z.ZodObject<{
170
+ op: z.ZodLiteral<"replace">;
171
+ collection: z.ZodString;
172
+ field: z.ZodString;
173
+ from: z.ZodString;
174
+ to: z.ZodString;
175
+ }, z.core.$strip>], "op">>;
176
+ }, z.core.$strip>>>;
177
+ sdk: z.ZodOptional<z.ZodString>;
178
+ }, z.core.$strip>;
179
+ /**
180
+ * The additions as code reads a manifest that was checked whole when it was
181
+ * published. Everything but the grants cross-check: what is granted is the
182
+ * install's record to answer (A3-F06), not the stored manifest's.
183
+ */
184
+ export declare const storedExtensionsSchema: z.ZodObject<{
185
+ placements: z.ZodOptional<z.ZodArray<z.ZodObject<{
186
+ kind: z.ZodEnum<{
187
+ "project-tab": "project-tab";
188
+ "project-sidebar": "project-sidebar";
189
+ "workspace-sidebar": "workspace-sidebar";
190
+ }>;
191
+ screen: z.ZodString;
192
+ label: z.ZodOptional<z.ZodString>;
193
+ icon: z.ZodOptional<z.ZodString>;
194
+ }, z.core.$strip>>>;
195
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
196
+ schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
197
+ search: z.ZodOptional<z.ZodArray<z.ZodString>>;
198
+ label: z.ZodOptional<z.ZodString>;
199
+ }, z.core.$strip>>>;
200
+ tools: z.ZodOptional<z.ZodObject<{
201
+ generated: z.ZodOptional<z.ZodBoolean>;
202
+ custom: z.ZodOptional<z.ZodArray<z.ZodObject<{
203
+ name: z.ZodString;
204
+ description: z.ZodString;
205
+ handler: z.ZodString;
206
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
207
+ write: z.ZodOptional<z.ZodBoolean>;
208
+ collection: z.ZodOptional<z.ZodString>;
209
+ }, z.core.$strip>>>;
210
+ }, z.core.$strip>>;
211
+ screens: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
212
+ entry: z.ZodString;
213
+ }, z.core.$strip>>>;
214
+ grants: z.ZodOptional<z.ZodObject<{
215
+ tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
216
+ collections: z.ZodOptional<z.ZodArray<z.ZodString>>;
217
+ host: z.ZodOptional<z.ZodArray<z.ZodString>>;
218
+ }, z.core.$strip>>;
219
+ migrations: z.ZodOptional<z.ZodArray<z.ZodObject<{
220
+ version: z.ZodString;
221
+ steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
222
+ op: z.ZodLiteral<"add">;
223
+ collection: z.ZodString;
224
+ field: z.ZodString;
225
+ default: z.ZodOptional<z.ZodUnknown>;
226
+ }, z.core.$strip>, z.ZodObject<{
227
+ op: z.ZodLiteral<"rename">;
228
+ collection: z.ZodString;
229
+ from: z.ZodString;
230
+ to: z.ZodString;
231
+ }, z.core.$strip>, z.ZodObject<{
232
+ op: z.ZodLiteral<"drop">;
233
+ collection: z.ZodString;
234
+ field: z.ZodString;
235
+ }, z.core.$strip>, z.ZodObject<{
236
+ op: z.ZodLiteral<"dropCollection">;
237
+ collection: z.ZodString;
238
+ }, z.core.$strip>, z.ZodObject<{
239
+ op: z.ZodLiteral<"replace">;
240
+ collection: z.ZodString;
241
+ field: z.ZodString;
242
+ from: z.ZodString;
243
+ to: z.ZodString;
244
+ }, z.core.$strip>], "op">>;
245
+ }, z.core.$strip>>>;
246
+ sdk: z.ZodOptional<z.ZodString>;
247
+ }, z.core.$strip>;
248
+ /** E5's manifest with the additions: the whole `.brydio/app.json` of an app. */
249
+ export declare const appManifestSchema: z.ZodObject<{
250
+ name: z.ZodString;
251
+ version: z.ZodString;
252
+ displayName: z.ZodOptional<z.ZodString>;
253
+ summary: z.ZodOptional<z.ZodString>;
254
+ description: z.ZodOptional<z.ZodString>;
255
+ author: z.ZodOptional<z.ZodObject<{
256
+ name: z.ZodString;
257
+ email: z.ZodOptional<z.ZodString>;
258
+ url: z.ZodOptional<z.ZodString>;
259
+ }, z.core.$strip>>;
260
+ homepage: z.ZodOptional<z.ZodString>;
261
+ repository: z.ZodOptional<z.ZodString>;
262
+ license: z.ZodOptional<z.ZodString>;
263
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
264
+ links: z.ZodOptional<z.ZodObject<{
265
+ privacy: z.ZodOptional<z.ZodString>;
266
+ terms: z.ZodOptional<z.ZodString>;
267
+ support: z.ZodOptional<z.ZodString>;
268
+ }, z.core.$strip>>;
269
+ icon: z.ZodOptional<z.ZodString>;
270
+ brandColor: z.ZodOptional<z.ZodString>;
271
+ brandColorDark: z.ZodOptional<z.ZodString>;
272
+ defaultPrompts: z.ZodOptional<z.ZodArray<z.ZodString>>;
273
+ skills: z.ZodOptional<z.ZodString>;
274
+ servers: z.ZodOptional<z.ZodString>;
275
+ integrations: z.ZodOptional<z.ZodString>;
276
+ requires: z.ZodOptional<z.ZodObject<{
277
+ servers: z.ZodDefault<z.ZodArray<z.ZodString>>;
278
+ integrations: z.ZodDefault<z.ZodArray<z.ZodString>>;
279
+ builtin: z.ZodDefault<z.ZodArray<z.ZodString>>;
280
+ }, z.core.$strip>>;
281
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
282
+ placements: z.ZodOptional<z.ZodArray<z.ZodObject<{
283
+ kind: z.ZodEnum<{
284
+ "project-tab": "project-tab";
285
+ "project-sidebar": "project-sidebar";
286
+ "workspace-sidebar": "workspace-sidebar";
287
+ }>;
288
+ screen: z.ZodString;
289
+ label: z.ZodOptional<z.ZodString>;
290
+ icon: z.ZodOptional<z.ZodString>;
291
+ }, z.core.$strip>>>;
292
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
293
+ schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
294
+ search: z.ZodOptional<z.ZodArray<z.ZodString>>;
295
+ label: z.ZodOptional<z.ZodString>;
296
+ }, z.core.$strip>>>;
297
+ tools: z.ZodOptional<z.ZodObject<{
298
+ generated: z.ZodOptional<z.ZodBoolean>;
299
+ custom: z.ZodOptional<z.ZodArray<z.ZodObject<{
300
+ name: z.ZodString;
301
+ description: z.ZodString;
302
+ handler: z.ZodString;
303
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
304
+ write: z.ZodOptional<z.ZodBoolean>;
305
+ collection: z.ZodOptional<z.ZodString>;
306
+ }, z.core.$strip>>>;
307
+ }, z.core.$strip>>;
308
+ screens: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
309
+ entry: z.ZodString;
310
+ }, z.core.$strip>>>;
311
+ grants: z.ZodOptional<z.ZodObject<{
312
+ tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
313
+ collections: z.ZodOptional<z.ZodArray<z.ZodString>>;
314
+ host: z.ZodOptional<z.ZodArray<z.ZodString>>;
315
+ }, z.core.$strip>>;
316
+ migrations: z.ZodOptional<z.ZodArray<z.ZodObject<{
317
+ version: z.ZodString;
318
+ steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
319
+ op: z.ZodLiteral<"add">;
320
+ collection: z.ZodString;
321
+ field: z.ZodString;
322
+ default: z.ZodOptional<z.ZodUnknown>;
323
+ }, z.core.$strip>, z.ZodObject<{
324
+ op: z.ZodLiteral<"rename">;
325
+ collection: z.ZodString;
326
+ from: z.ZodString;
327
+ to: z.ZodString;
328
+ }, z.core.$strip>, z.ZodObject<{
329
+ op: z.ZodLiteral<"drop">;
330
+ collection: z.ZodString;
331
+ field: z.ZodString;
332
+ }, z.core.$strip>, z.ZodObject<{
333
+ op: z.ZodLiteral<"dropCollection">;
334
+ collection: z.ZodString;
335
+ }, z.core.$strip>, z.ZodObject<{
336
+ op: z.ZodLiteral<"replace">;
337
+ collection: z.ZodString;
338
+ field: z.ZodString;
339
+ from: z.ZodString;
340
+ to: z.ZodString;
341
+ }, z.core.$strip>], "op">>;
342
+ }, z.core.$strip>>>;
343
+ sdk: z.ZodOptional<z.ZodString>;
344
+ }, z.core.$strip>;
345
+ export type ManifestExtensions = z.infer<typeof manifestExtensionsSchema>;
346
+ export type AppManifestWithData = z.infer<typeof appManifestSchema>;
347
+ /**
348
+ * A collection as the store and the tools read it: parsed once, with the
349
+ * names everything else would otherwise work out for itself.
350
+ */
351
+ export interface CollectionSpec {
352
+ name: string;
353
+ /** Singular: `issue`. */
354
+ label: string;
355
+ /** For the list tools: `issues`. */
356
+ plural: string;
357
+ fields: Record<string, FieldType>;
358
+ /** In declaration order. */
359
+ structured: string[];
360
+ sortable: string[];
361
+ search: string[];
362
+ /** The one `project` field, whose value is copied to `app_document.project_id`. */
363
+ projectField: string | null;
364
+ }
365
+ /**
366
+ * The singular a collection's tools are named with: the manifest's, else the
367
+ * collection's name with a trailing "s" taken off (`issues` → `issue`).
368
+ */
369
+ export declare function labelOf(collection: string, label?: string): string;
370
+ /**
371
+ * Every collection an app declares, parsed. Throws on a manifest that
372
+ * `dataProblems` would refuse: callers read manifests that were validated
373
+ * when they were stored, and a bad one here is a bug, not input.
374
+ */
375
+ export declare function collectionsOf(manifest: {
376
+ data?: ManifestExtensions['data'];
377
+ }): CollectionSpec[];
378
+ /** One collection by name, or null when the app keeps no such thing. */
379
+ export declare function collectionOf(manifest: {
380
+ data?: ManifestExtensions['data'];
381
+ }, collection: string): CollectionSpec | null;