@kernhq/module-quire 0.4.1 → 0.5.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.
@@ -3,5 +3,6 @@ export * from './events.js';
3
3
  export * from './models.js';
4
4
  export * from './notifications.js';
5
5
  export * from './permissions.js';
6
+ export * from './properties.js';
6
7
  export * from './router.js';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA"}
@@ -3,5 +3,6 @@ export * from './events.js';
3
3
  export * from './models.js';
4
4
  export * from './notifications.js';
5
5
  export * from './permissions.js';
6
+ export * from './properties.js';
6
7
  export * from './router.js';
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,483 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * What a column can be.
4
+ *
5
+ * The set is closed on purpose. A property type is not just a input widget: it decides how a value
6
+ * sorts, what a filter can ask of it, and whether a rollup can add it up. An open set would mean a
7
+ * table view that can display something no filter can find.
8
+ */
9
+ export declare const PropertyType: z.ZodEnum<{
10
+ number: "number";
11
+ date: "date";
12
+ email: "email";
13
+ text: "text";
14
+ select: "select";
15
+ multi_select: "multi_select";
16
+ status: "status";
17
+ person: "person";
18
+ files: "files";
19
+ checkbox: "checkbox";
20
+ url: "url";
21
+ phone: "phone";
22
+ relation: "relation";
23
+ rollup: "rollup";
24
+ formula: "formula";
25
+ created_time: "created_time";
26
+ created_by: "created_by";
27
+ edited_time: "edited_time";
28
+ edited_by: "edited_by";
29
+ }>;
30
+ export type PropertyType = z.infer<typeof PropertyType>;
31
+ /** A choice in a select, a multi-select or a status. */
32
+ export declare const SelectOption: z.ZodObject<{
33
+ id: z.ZodString;
34
+ label: z.ZodString;
35
+ colour: z.ZodDefault<z.ZodString>;
36
+ group: z.ZodOptional<z.ZodEnum<{
37
+ todo: "todo";
38
+ doing: "doing";
39
+ done: "done";
40
+ }>>;
41
+ }, z.core.$strip>;
42
+ export type SelectOption = z.infer<typeof SelectOption>;
43
+ /** How a rollup reduces the values it gathers from the other side of a relation. */
44
+ export declare const RollupFunction: z.ZodEnum<{
45
+ count: "count";
46
+ count_values: "count_values";
47
+ count_unique: "count_unique";
48
+ sum: "sum";
49
+ average: "average";
50
+ min: "min";
51
+ max: "max";
52
+ range: "range";
53
+ show_original: "show_original";
54
+ checked: "checked";
55
+ unchecked: "unchecked";
56
+ percent_checked: "percent_checked";
57
+ }>;
58
+ export type RollupFunction = z.infer<typeof RollupFunction>;
59
+ /**
60
+ * Everything a type needs beyond its name.
61
+ *
62
+ * One permissive object rather than a discriminated union per type: the union would have to be
63
+ * exhaustive at every boundary, and a column's configuration is read by code that already knows
64
+ * which type it is holding. What matters is that adding a type never needs a migration.
65
+ */
66
+ export declare const PropertyConfig: z.ZodObject<{
67
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
68
+ id: z.ZodString;
69
+ label: z.ZodString;
70
+ colour: z.ZodDefault<z.ZodString>;
71
+ group: z.ZodOptional<z.ZodEnum<{
72
+ todo: "todo";
73
+ doing: "doing";
74
+ done: "done";
75
+ }>>;
76
+ }, z.core.$strip>>>;
77
+ format: z.ZodOptional<z.ZodString>;
78
+ precision: z.ZodOptional<z.ZodNumber>;
79
+ includeTime: z.ZodOptional<z.ZodBoolean>;
80
+ isRange: z.ZodOptional<z.ZodBoolean>;
81
+ relationDatabaseId: z.ZodOptional<z.ZodUUID>;
82
+ relationPropertyId: z.ZodOptional<z.ZodUUID>;
83
+ rollupRelationPropertyId: z.ZodOptional<z.ZodUUID>;
84
+ rollupTargetPropertyId: z.ZodOptional<z.ZodUUID>;
85
+ rollupFunction: z.ZodOptional<z.ZodEnum<{
86
+ count: "count";
87
+ count_values: "count_values";
88
+ count_unique: "count_unique";
89
+ sum: "sum";
90
+ average: "average";
91
+ min: "min";
92
+ max: "max";
93
+ range: "range";
94
+ show_original: "show_original";
95
+ checked: "checked";
96
+ unchecked: "unchecked";
97
+ percent_checked: "percent_checked";
98
+ }>>;
99
+ expression: z.ZodOptional<z.ZodString>;
100
+ multiple: z.ZodOptional<z.ZodBoolean>;
101
+ }, z.core.$strip>;
102
+ export type PropertyConfig = z.infer<typeof PropertyConfig>;
103
+ export declare const Property: z.ZodObject<{
104
+ id: z.ZodUUID;
105
+ databaseId: z.ZodUUID;
106
+ key: z.ZodString;
107
+ name: z.ZodString;
108
+ type: z.ZodEnum<{
109
+ number: "number";
110
+ date: "date";
111
+ email: "email";
112
+ text: "text";
113
+ select: "select";
114
+ multi_select: "multi_select";
115
+ status: "status";
116
+ person: "person";
117
+ files: "files";
118
+ checkbox: "checkbox";
119
+ url: "url";
120
+ phone: "phone";
121
+ relation: "relation";
122
+ rollup: "rollup";
123
+ formula: "formula";
124
+ created_time: "created_time";
125
+ created_by: "created_by";
126
+ edited_time: "edited_time";
127
+ edited_by: "edited_by";
128
+ }>;
129
+ config: z.ZodObject<{
130
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
131
+ id: z.ZodString;
132
+ label: z.ZodString;
133
+ colour: z.ZodDefault<z.ZodString>;
134
+ group: z.ZodOptional<z.ZodEnum<{
135
+ todo: "todo";
136
+ doing: "doing";
137
+ done: "done";
138
+ }>>;
139
+ }, z.core.$strip>>>;
140
+ format: z.ZodOptional<z.ZodString>;
141
+ precision: z.ZodOptional<z.ZodNumber>;
142
+ includeTime: z.ZodOptional<z.ZodBoolean>;
143
+ isRange: z.ZodOptional<z.ZodBoolean>;
144
+ relationDatabaseId: z.ZodOptional<z.ZodUUID>;
145
+ relationPropertyId: z.ZodOptional<z.ZodUUID>;
146
+ rollupRelationPropertyId: z.ZodOptional<z.ZodUUID>;
147
+ rollupTargetPropertyId: z.ZodOptional<z.ZodUUID>;
148
+ rollupFunction: z.ZodOptional<z.ZodEnum<{
149
+ count: "count";
150
+ count_values: "count_values";
151
+ count_unique: "count_unique";
152
+ sum: "sum";
153
+ average: "average";
154
+ min: "min";
155
+ max: "max";
156
+ range: "range";
157
+ show_original: "show_original";
158
+ checked: "checked";
159
+ unchecked: "unchecked";
160
+ percent_checked: "percent_checked";
161
+ }>>;
162
+ expression: z.ZodOptional<z.ZodString>;
163
+ multiple: z.ZodOptional<z.ZodBoolean>;
164
+ }, z.core.$strip>;
165
+ position: z.ZodString;
166
+ hidden: z.ZodBoolean;
167
+ }, z.core.$strip>;
168
+ export type Property = z.infer<typeof Property>;
169
+ /**
170
+ * A cell.
171
+ *
172
+ * Deliberately loose: the shape depends on the column's type, and the server validates a value
173
+ * against its own property before it is written. Typing it here as a union would put the same
174
+ * exhaustive switch in every consumer that only ever renders one type at a time.
175
+ */
176
+ export declare const PropertyValue: z.ZodUnknown;
177
+ export declare const ViewKind: z.ZodEnum<{
178
+ table: "table";
179
+ board: "board";
180
+ calendar: "calendar";
181
+ gallery: "gallery";
182
+ list: "list";
183
+ timeline: "timeline";
184
+ }>;
185
+ export type ViewKind = z.infer<typeof ViewKind>;
186
+ /** How a filter compares. Which of these a column accepts depends on its type. */
187
+ export declare const FilterOperator: z.ZodEnum<{
188
+ equals: "equals";
189
+ not_equals: "not_equals";
190
+ contains: "contains";
191
+ not_contains: "not_contains";
192
+ starts_with: "starts_with";
193
+ ends_with: "ends_with";
194
+ is_empty: "is_empty";
195
+ is_not_empty: "is_not_empty";
196
+ greater_than: "greater_than";
197
+ less_than: "less_than";
198
+ on_or_before: "on_or_before";
199
+ on_or_after: "on_or_after";
200
+ is_any_of: "is_any_of";
201
+ is_none_of: "is_none_of";
202
+ }>;
203
+ export type FilterOperator = z.infer<typeof FilterOperator>;
204
+ export declare const Filter: z.ZodObject<{
205
+ propertyKey: z.ZodString;
206
+ operator: z.ZodEnum<{
207
+ equals: "equals";
208
+ not_equals: "not_equals";
209
+ contains: "contains";
210
+ not_contains: "not_contains";
211
+ starts_with: "starts_with";
212
+ ends_with: "ends_with";
213
+ is_empty: "is_empty";
214
+ is_not_empty: "is_not_empty";
215
+ greater_than: "greater_than";
216
+ less_than: "less_than";
217
+ on_or_before: "on_or_before";
218
+ on_or_after: "on_or_after";
219
+ is_any_of: "is_any_of";
220
+ is_none_of: "is_none_of";
221
+ }>;
222
+ value: z.ZodOptional<z.ZodUnknown>;
223
+ }, z.core.$strip>;
224
+ export declare const Sort: z.ZodObject<{
225
+ propertyKey: z.ZodString;
226
+ direction: z.ZodDefault<z.ZodEnum<{
227
+ asc: "asc";
228
+ desc: "desc";
229
+ }>>;
230
+ }, z.core.$strip>;
231
+ export declare const ViewConfig: z.ZodObject<{
232
+ filters: z.ZodDefault<z.ZodArray<z.ZodObject<{
233
+ propertyKey: z.ZodString;
234
+ operator: z.ZodEnum<{
235
+ equals: "equals";
236
+ not_equals: "not_equals";
237
+ contains: "contains";
238
+ not_contains: "not_contains";
239
+ starts_with: "starts_with";
240
+ ends_with: "ends_with";
241
+ is_empty: "is_empty";
242
+ is_not_empty: "is_not_empty";
243
+ greater_than: "greater_than";
244
+ less_than: "less_than";
245
+ on_or_before: "on_or_before";
246
+ on_or_after: "on_or_after";
247
+ is_any_of: "is_any_of";
248
+ is_none_of: "is_none_of";
249
+ }>;
250
+ value: z.ZodOptional<z.ZodUnknown>;
251
+ }, z.core.$strip>>>;
252
+ filterMode: z.ZodDefault<z.ZodEnum<{
253
+ and: "and";
254
+ or: "or";
255
+ }>>;
256
+ sorts: z.ZodDefault<z.ZodArray<z.ZodObject<{
257
+ propertyKey: z.ZodString;
258
+ direction: z.ZodDefault<z.ZodEnum<{
259
+ asc: "asc";
260
+ desc: "desc";
261
+ }>>;
262
+ }, z.core.$strip>>>;
263
+ groupBy: z.ZodDefault<z.ZodNullable<z.ZodString>>;
264
+ dateProperty: z.ZodDefault<z.ZodNullable<z.ZodString>>;
265
+ visibleProperties: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
266
+ columnWidths: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
267
+ cardSize: z.ZodDefault<z.ZodEnum<{
268
+ small: "small";
269
+ medium: "medium";
270
+ large: "large";
271
+ }>>;
272
+ coverProperty: z.ZodDefault<z.ZodNullable<z.ZodString>>;
273
+ }, z.core.$strip>;
274
+ export type ViewConfig = z.infer<typeof ViewConfig>;
275
+ export declare const View: z.ZodObject<{
276
+ id: z.ZodUUID;
277
+ databaseId: z.ZodUUID;
278
+ name: z.ZodString;
279
+ kind: z.ZodEnum<{
280
+ table: "table";
281
+ board: "board";
282
+ calendar: "calendar";
283
+ gallery: "gallery";
284
+ list: "list";
285
+ timeline: "timeline";
286
+ }>;
287
+ config: z.ZodObject<{
288
+ filters: z.ZodDefault<z.ZodArray<z.ZodObject<{
289
+ propertyKey: z.ZodString;
290
+ operator: z.ZodEnum<{
291
+ equals: "equals";
292
+ not_equals: "not_equals";
293
+ contains: "contains";
294
+ not_contains: "not_contains";
295
+ starts_with: "starts_with";
296
+ ends_with: "ends_with";
297
+ is_empty: "is_empty";
298
+ is_not_empty: "is_not_empty";
299
+ greater_than: "greater_than";
300
+ less_than: "less_than";
301
+ on_or_before: "on_or_before";
302
+ on_or_after: "on_or_after";
303
+ is_any_of: "is_any_of";
304
+ is_none_of: "is_none_of";
305
+ }>;
306
+ value: z.ZodOptional<z.ZodUnknown>;
307
+ }, z.core.$strip>>>;
308
+ filterMode: z.ZodDefault<z.ZodEnum<{
309
+ and: "and";
310
+ or: "or";
311
+ }>>;
312
+ sorts: z.ZodDefault<z.ZodArray<z.ZodObject<{
313
+ propertyKey: z.ZodString;
314
+ direction: z.ZodDefault<z.ZodEnum<{
315
+ asc: "asc";
316
+ desc: "desc";
317
+ }>>;
318
+ }, z.core.$strip>>>;
319
+ groupBy: z.ZodDefault<z.ZodNullable<z.ZodString>>;
320
+ dateProperty: z.ZodDefault<z.ZodNullable<z.ZodString>>;
321
+ visibleProperties: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
322
+ columnWidths: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
323
+ cardSize: z.ZodDefault<z.ZodEnum<{
324
+ small: "small";
325
+ medium: "medium";
326
+ large: "large";
327
+ }>>;
328
+ coverProperty: z.ZodDefault<z.ZodNullable<z.ZodString>>;
329
+ }, z.core.$strip>;
330
+ position: z.ZodString;
331
+ isDefault: z.ZodBoolean;
332
+ }, z.core.$strip>;
333
+ export type View = z.infer<typeof View>;
334
+ export declare const Database: z.ZodObject<{
335
+ id: z.ZodUUID;
336
+ workspaceId: z.ZodString;
337
+ spaceId: z.ZodUUID;
338
+ pageId: z.ZodUUID;
339
+ name: z.ZodString;
340
+ description: z.ZodString;
341
+ inline: z.ZodBoolean;
342
+ properties: z.ZodArray<z.ZodObject<{
343
+ id: z.ZodUUID;
344
+ databaseId: z.ZodUUID;
345
+ key: z.ZodString;
346
+ name: z.ZodString;
347
+ type: z.ZodEnum<{
348
+ number: "number";
349
+ date: "date";
350
+ email: "email";
351
+ text: "text";
352
+ select: "select";
353
+ multi_select: "multi_select";
354
+ status: "status";
355
+ person: "person";
356
+ files: "files";
357
+ checkbox: "checkbox";
358
+ url: "url";
359
+ phone: "phone";
360
+ relation: "relation";
361
+ rollup: "rollup";
362
+ formula: "formula";
363
+ created_time: "created_time";
364
+ created_by: "created_by";
365
+ edited_time: "edited_time";
366
+ edited_by: "edited_by";
367
+ }>;
368
+ config: z.ZodObject<{
369
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
370
+ id: z.ZodString;
371
+ label: z.ZodString;
372
+ colour: z.ZodDefault<z.ZodString>;
373
+ group: z.ZodOptional<z.ZodEnum<{
374
+ todo: "todo";
375
+ doing: "doing";
376
+ done: "done";
377
+ }>>;
378
+ }, z.core.$strip>>>;
379
+ format: z.ZodOptional<z.ZodString>;
380
+ precision: z.ZodOptional<z.ZodNumber>;
381
+ includeTime: z.ZodOptional<z.ZodBoolean>;
382
+ isRange: z.ZodOptional<z.ZodBoolean>;
383
+ relationDatabaseId: z.ZodOptional<z.ZodUUID>;
384
+ relationPropertyId: z.ZodOptional<z.ZodUUID>;
385
+ rollupRelationPropertyId: z.ZodOptional<z.ZodUUID>;
386
+ rollupTargetPropertyId: z.ZodOptional<z.ZodUUID>;
387
+ rollupFunction: z.ZodOptional<z.ZodEnum<{
388
+ count: "count";
389
+ count_values: "count_values";
390
+ count_unique: "count_unique";
391
+ sum: "sum";
392
+ average: "average";
393
+ min: "min";
394
+ max: "max";
395
+ range: "range";
396
+ show_original: "show_original";
397
+ checked: "checked";
398
+ unchecked: "unchecked";
399
+ percent_checked: "percent_checked";
400
+ }>>;
401
+ expression: z.ZodOptional<z.ZodString>;
402
+ multiple: z.ZodOptional<z.ZodBoolean>;
403
+ }, z.core.$strip>;
404
+ position: z.ZodString;
405
+ hidden: z.ZodBoolean;
406
+ }, z.core.$strip>>;
407
+ views: z.ZodArray<z.ZodObject<{
408
+ id: z.ZodUUID;
409
+ databaseId: z.ZodUUID;
410
+ name: z.ZodString;
411
+ kind: z.ZodEnum<{
412
+ table: "table";
413
+ board: "board";
414
+ calendar: "calendar";
415
+ gallery: "gallery";
416
+ list: "list";
417
+ timeline: "timeline";
418
+ }>;
419
+ config: z.ZodObject<{
420
+ filters: z.ZodDefault<z.ZodArray<z.ZodObject<{
421
+ propertyKey: z.ZodString;
422
+ operator: z.ZodEnum<{
423
+ equals: "equals";
424
+ not_equals: "not_equals";
425
+ contains: "contains";
426
+ not_contains: "not_contains";
427
+ starts_with: "starts_with";
428
+ ends_with: "ends_with";
429
+ is_empty: "is_empty";
430
+ is_not_empty: "is_not_empty";
431
+ greater_than: "greater_than";
432
+ less_than: "less_than";
433
+ on_or_before: "on_or_before";
434
+ on_or_after: "on_or_after";
435
+ is_any_of: "is_any_of";
436
+ is_none_of: "is_none_of";
437
+ }>;
438
+ value: z.ZodOptional<z.ZodUnknown>;
439
+ }, z.core.$strip>>>;
440
+ filterMode: z.ZodDefault<z.ZodEnum<{
441
+ and: "and";
442
+ or: "or";
443
+ }>>;
444
+ sorts: z.ZodDefault<z.ZodArray<z.ZodObject<{
445
+ propertyKey: z.ZodString;
446
+ direction: z.ZodDefault<z.ZodEnum<{
447
+ asc: "asc";
448
+ desc: "desc";
449
+ }>>;
450
+ }, z.core.$strip>>>;
451
+ groupBy: z.ZodDefault<z.ZodNullable<z.ZodString>>;
452
+ dateProperty: z.ZodDefault<z.ZodNullable<z.ZodString>>;
453
+ visibleProperties: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
454
+ columnWidths: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
455
+ cardSize: z.ZodDefault<z.ZodEnum<{
456
+ small: "small";
457
+ medium: "medium";
458
+ large: "large";
459
+ }>>;
460
+ coverProperty: z.ZodDefault<z.ZodNullable<z.ZodString>>;
461
+ }, z.core.$strip>;
462
+ position: z.ZodString;
463
+ isDefault: z.ZodBoolean;
464
+ }, z.core.$strip>>;
465
+ createdAt: z.ZodISODateTime;
466
+ updatedAt: z.ZodISODateTime;
467
+ }, z.core.$strip>;
468
+ export type Database = z.infer<typeof Database>;
469
+ /** A row: the page, plus its cells and whatever the server computed from them. */
470
+ export declare const Row: z.ZodObject<{
471
+ id: z.ZodUUID;
472
+ databaseId: z.ZodUUID;
473
+ title: z.ZodString;
474
+ icon: z.ZodNullable<z.ZodString>;
475
+ props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
476
+ computed: z.ZodRecord<z.ZodString, z.ZodUnknown>;
477
+ createdBy: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UserId", "out">>;
478
+ updatedBy: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UserId", "out">>;
479
+ createdAt: z.ZodISODateTime;
480
+ updatedAt: z.ZodISODateTime;
481
+ }, z.core.$strip>;
482
+ export type Row = z.infer<typeof Row>;
483
+ //# sourceMappingURL=properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../src/contract/properties.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;EAoBvB,CAAA;AACF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAEvD,wDAAwD;AACxD,eAAO,MAAM,YAAY;;;;;;;;;iBAMvB,CAAA;AACF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAEvD,oFAAoF;AACpF,eAAO,MAAM,cAAc;;;;;;;;;;;;;EAazB,CAAA;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAE3D;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmBzB,CAAA;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAE3D,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBASnB,CAAA;AACF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,cAAc,CAAA;AAExC,eAAO,MAAM,QAAQ;;;;;;;EAAwE,CAAA;AAC7F,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE/C,kFAAkF;AAClF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;EAezB,CAAA;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAE3D,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;iBAIjB,CAAA;AAEF,eAAO,MAAM,IAAI;;;;;;iBAGf,CAAA;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAarB,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA;AAEnD,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQf,CAAA;AACF,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAA;AAEvC,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAYnB,CAAA;AACF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE/C,kFAAkF;AAClF,eAAO,MAAM,GAAG;;;;;;;;;;;iBAWd,CAAA;AACF,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAA"}
@@ -0,0 +1,175 @@
1
+ import { Id, Timestamp, UserId } from '@kernhq/contracts';
2
+ import { z } from 'zod';
3
+ /**
4
+ * What a column can be.
5
+ *
6
+ * The set is closed on purpose. A property type is not just a input widget: it decides how a value
7
+ * sorts, what a filter can ask of it, and whether a rollup can add it up. An open set would mean a
8
+ * table view that can display something no filter can find.
9
+ */
10
+ export const PropertyType = z.enum([
11
+ 'text',
12
+ 'number',
13
+ 'select',
14
+ 'multi_select',
15
+ 'status',
16
+ 'date',
17
+ 'person',
18
+ 'files',
19
+ 'checkbox',
20
+ 'url',
21
+ 'email',
22
+ 'phone',
23
+ 'relation',
24
+ 'rollup',
25
+ 'formula',
26
+ 'created_time',
27
+ 'created_by',
28
+ 'edited_time',
29
+ 'edited_by',
30
+ ]);
31
+ /** A choice in a select, a multi-select or a status. */
32
+ export const SelectOption = z.object({
33
+ id: z.string().min(1).max(64),
34
+ label: z.string().min(1).max(120),
35
+ colour: z.string().max(32).default('slate'),
36
+ /** status only: which band of the workflow this sits in */
37
+ group: z.enum(['todo', 'doing', 'done']).optional(),
38
+ });
39
+ /** How a rollup reduces the values it gathers from the other side of a relation. */
40
+ export const RollupFunction = z.enum([
41
+ 'count',
42
+ 'count_values',
43
+ 'count_unique',
44
+ 'sum',
45
+ 'average',
46
+ 'min',
47
+ 'max',
48
+ 'range',
49
+ 'show_original',
50
+ 'checked',
51
+ 'unchecked',
52
+ 'percent_checked',
53
+ ]);
54
+ /**
55
+ * Everything a type needs beyond its name.
56
+ *
57
+ * One permissive object rather than a discriminated union per type: the union would have to be
58
+ * exhaustive at every boundary, and a column's configuration is read by code that already knows
59
+ * which type it is holding. What matters is that adding a type never needs a migration.
60
+ */
61
+ export const PropertyConfig = z.object({
62
+ options: z.array(SelectOption).optional(),
63
+ /** number: how it is drawn — plain, a percentage, a currency, a bar */
64
+ format: z.string().max(32).optional(),
65
+ precision: z.number().int().min(0).max(8).optional(),
66
+ /** date: whether the value carries a time, and whether it is a range */
67
+ includeTime: z.boolean().optional(),
68
+ isRange: z.boolean().optional(),
69
+ /** relation: the database on the other side, and the property that points back */
70
+ relationDatabaseId: Id.optional(),
71
+ relationPropertyId: Id.optional(),
72
+ /** rollup: which relation to walk, which property to gather, and how to reduce it */
73
+ rollupRelationPropertyId: Id.optional(),
74
+ rollupTargetPropertyId: Id.optional(),
75
+ rollupFunction: RollupFunction.optional(),
76
+ /** formula: the expression, exactly as somebody typed it */
77
+ expression: z.string().max(4000).optional(),
78
+ /** person: whether more than one may be chosen */
79
+ multiple: z.boolean().optional(),
80
+ });
81
+ export const Property = z.object({
82
+ id: Id,
83
+ databaseId: Id,
84
+ key: z.string().min(1).max(64),
85
+ name: z.string().min(1).max(120),
86
+ type: PropertyType,
87
+ config: PropertyConfig,
88
+ position: z.string(),
89
+ hidden: z.boolean(),
90
+ });
91
+ /**
92
+ * A cell.
93
+ *
94
+ * Deliberately loose: the shape depends on the column's type, and the server validates a value
95
+ * against its own property before it is written. Typing it here as a union would put the same
96
+ * exhaustive switch in every consumer that only ever renders one type at a time.
97
+ */
98
+ export const PropertyValue = z.unknown();
99
+ export const ViewKind = z.enum(['table', 'board', 'calendar', 'gallery', 'list', 'timeline']);
100
+ /** How a filter compares. Which of these a column accepts depends on its type. */
101
+ export const FilterOperator = z.enum([
102
+ 'equals',
103
+ 'not_equals',
104
+ 'contains',
105
+ 'not_contains',
106
+ 'starts_with',
107
+ 'ends_with',
108
+ 'is_empty',
109
+ 'is_not_empty',
110
+ 'greater_than',
111
+ 'less_than',
112
+ 'on_or_before',
113
+ 'on_or_after',
114
+ 'is_any_of',
115
+ 'is_none_of',
116
+ ]);
117
+ export const Filter = z.object({
118
+ propertyKey: z.string(),
119
+ operator: FilterOperator,
120
+ value: z.unknown().optional(),
121
+ });
122
+ export const Sort = z.object({
123
+ propertyKey: z.string(),
124
+ direction: z.enum(['asc', 'desc']).default('asc'),
125
+ });
126
+ export const ViewConfig = z.object({
127
+ filters: z.array(Filter).default([]),
128
+ /** every filter must hold, or any one of them */
129
+ filterMode: z.enum(['and', 'or']).default('and'),
130
+ sorts: z.array(Sort).default([]),
131
+ /** board: which property makes the columns; calendar: which date is plotted */
132
+ groupBy: z.string().nullable().default(null),
133
+ dateProperty: z.string().nullable().default(null),
134
+ visibleProperties: z.array(z.string()).nullable().default(null),
135
+ columnWidths: z.record(z.string(), z.number()).default({}),
136
+ cardSize: z.enum(['small', 'medium', 'large']).default('medium'),
137
+ /** gallery: which files property provides the picture */
138
+ coverProperty: z.string().nullable().default(null),
139
+ });
140
+ export const View = z.object({
141
+ id: Id,
142
+ databaseId: Id,
143
+ name: z.string().min(1).max(120),
144
+ kind: ViewKind,
145
+ config: ViewConfig,
146
+ position: z.string(),
147
+ isDefault: z.boolean(),
148
+ });
149
+ export const Database = z.object({
150
+ id: Id,
151
+ workspaceId: z.string(),
152
+ spaceId: Id,
153
+ pageId: Id,
154
+ name: z.string(),
155
+ description: z.string(),
156
+ inline: z.boolean(),
157
+ properties: z.array(Property),
158
+ views: z.array(View),
159
+ createdAt: Timestamp,
160
+ updatedAt: Timestamp,
161
+ });
162
+ /** A row: the page, plus its cells and whatever the server computed from them. */
163
+ export const Row = z.object({
164
+ id: Id,
165
+ databaseId: Id,
166
+ title: z.string(),
167
+ icon: z.string().nullable(),
168
+ props: z.record(z.string(), PropertyValue),
169
+ computed: z.record(z.string(), PropertyValue),
170
+ createdBy: UserId.nullable(),
171
+ updatedBy: UserId.nullable(),
172
+ createdAt: Timestamp,
173
+ updatedAt: Timestamp,
174
+ });
175
+ //# sourceMappingURL=properties.js.map