@kernhq/module-quire 0.5.0 → 0.6.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.
Files changed (38) hide show
  1. package/dist/contract/properties.d.ts +2 -0
  2. package/dist/contract/properties.d.ts.map +1 -1
  3. package/dist/contract/properties.js.map +1 -1
  4. package/dist/contract/router.d.ts +1101 -0
  5. package/dist/contract/router.d.ts.map +1 -1
  6. package/dist/contract/router.js +88 -0
  7. package/dist/contract/router.js.map +1 -1
  8. package/dist/server/_impl.d.ts +1182 -0
  9. package/dist/server/_impl.d.ts.map +1 -1
  10. package/dist/server/_impl.js +113 -0
  11. package/dist/server/_impl.js.map +1 -1
  12. package/dist/server/schema.d.ts +51 -0
  13. package/dist/server/schema.d.ts.map +1 -1
  14. package/dist/server/schema.js +15 -0
  15. package/dist/server/schema.js.map +1 -1
  16. package/dist/server/services/access.d.ts +3 -0
  17. package/dist/server/services/access.d.ts.map +1 -1
  18. package/dist/server/services/databases.d.ts +330 -0
  19. package/dist/server/services/databases.d.ts.map +1 -0
  20. package/dist/server/services/databases.js +515 -0
  21. package/dist/server/services/databases.js.map +1 -0
  22. package/dist/server/services/index.d.ts +3 -0
  23. package/dist/server/services/index.d.ts.map +1 -1
  24. package/dist/server/services/index.js +3 -0
  25. package/dist/server/services/index.js.map +1 -1
  26. package/dist/server/services/query.d.ts +13 -0
  27. package/dist/server/services/query.d.ts.map +1 -0
  28. package/dist/server/services/query.js +154 -0
  29. package/dist/server/services/query.js.map +1 -0
  30. package/dist/server/services/versions.d.ts +6 -0
  31. package/dist/server/services/versions.d.ts.map +1 -1
  32. package/migrations/0005_rows_are_pages.sql +6 -0
  33. package/migrations/meta/0004_snapshot.json +1 -1
  34. package/migrations/meta/0005_snapshot.json +1191 -0
  35. package/migrations/meta/_journal.json +7 -0
  36. package/package.json +1 -1
  37. package/src/contract/properties.ts +2 -0
  38. package/src/contract/router.ts +115 -0
@@ -36,6 +36,13 @@
36
36
  "when": 1787601921354,
37
37
  "tag": "0004_databases",
38
38
  "breakpoints": true
39
+ },
40
+ {
41
+ "idx": 5,
42
+ "version": "7",
43
+ "when": 1787634247157,
44
+ "tag": "0005_rows_are_pages",
45
+ "breakpoints": true
39
46
  }
40
47
  ]
41
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kernhq/module-quire",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Kern Quire: collaborative documents, spaces and page trees",
5
5
  "homepage": "https://kernaio.com",
6
6
  "license": "AGPL-3.0-only",
@@ -135,11 +135,13 @@ export const Filter = z.object({
135
135
  operator: FilterOperator,
136
136
  value: z.unknown().optional(),
137
137
  })
138
+ export type Filter = z.infer<typeof Filter>
138
139
 
139
140
  export const Sort = z.object({
140
141
  propertyKey: z.string(),
141
142
  direction: z.enum(['asc', 'desc']).default('asc'),
142
143
  })
144
+ export type Sort = z.infer<typeof Sort>
143
145
 
144
146
  export const ViewConfig = z.object({
145
147
  filters: z.array(Filter).default([]),
@@ -12,6 +12,16 @@ import {
12
12
  Space,
13
13
  SpaceVisibility,
14
14
  } from './models.js'
15
+ import {
16
+ Database,
17
+ Property,
18
+ PropertyConfig,
19
+ PropertyType,
20
+ Row,
21
+ View,
22
+ ViewConfig,
23
+ ViewKind,
24
+ } from './properties.js'
15
25
 
16
26
  const ws = z.object({ workspaceId: WorkspaceId })
17
27
  const t = (...tags: string[]) => ({ tags })
@@ -187,6 +197,111 @@ export const quireContract = {
187
197
  .output(CommentThread),
188
198
  },
189
199
 
200
+ databases: {
201
+ get: baseContract
202
+ .route({ method: 'GET', path: '/databases/{databaseId}', ...t('databases') })
203
+ .input(ws.extend({ databaseId: Id }))
204
+ .output(Database),
205
+ /** Turn a page into a database. It arrives with one column and one view, never empty. */
206
+ create: baseContract
207
+ .route({ method: 'POST', path: '/databases', ...t('databases') })
208
+ .input(
209
+ ws.extend({
210
+ spaceId: Id,
211
+ pageId: Id,
212
+ name: z.string().max(120).default(''),
213
+ inline: z.boolean().default(false),
214
+ }),
215
+ )
216
+ .output(Database),
217
+ /** The rows a view selects, filtered and ordered in SQL so a page of rows is a full page. */
218
+ rows: baseContract
219
+ .route({ method: 'GET', path: '/databases/{databaseId}/rows', ...t('databases') })
220
+ .input(ws.extend({ databaseId: Id, viewId: Id.nullable().default(null) }).extend(PageInput.shape))
221
+ .output(page(Row)),
222
+ addRow: baseContract
223
+ .route({ method: 'POST', path: '/databases/{databaseId}/rows', ...t('databases') })
224
+ .input(
225
+ ws.extend({
226
+ databaseId: Id,
227
+ title: z.string().max(300).default(''),
228
+ props: z.record(z.string(), z.unknown()).default({}),
229
+ }),
230
+ )
231
+ .output(Row),
232
+ updateRow: baseContract
233
+ .route({ method: 'PATCH', path: '/rows/{rowId}', ...t('databases') })
234
+ .input(
235
+ ws.extend({
236
+ rowId: Id,
237
+ title: z.string().max(300).optional(),
238
+ props: z.record(z.string(), z.unknown()).optional(),
239
+ }),
240
+ )
241
+ .output(Row),
242
+
243
+ addProperty: baseContract
244
+ .route({ method: 'POST', path: '/databases/{databaseId}/properties', ...t('databases') })
245
+ .input(
246
+ ws.extend({
247
+ databaseId: Id,
248
+ name: z.string().min(1).max(120),
249
+ type: PropertyType,
250
+ config: PropertyConfig.default({}),
251
+ }),
252
+ )
253
+ .output(Property),
254
+ updateProperty: baseContract
255
+ .route({ method: 'PATCH', path: '/properties/{propertyId}', ...t('databases') })
256
+ .input(
257
+ ws.extend({
258
+ propertyId: Id,
259
+ name: z.string().min(1).max(120).optional(),
260
+ type: PropertyType.optional(),
261
+ config: PropertyConfig.optional(),
262
+ hidden: z.boolean().optional(),
263
+ }),
264
+ )
265
+ .output(Property),
266
+ removeProperty: baseContract
267
+ .route({ method: 'DELETE', path: '/properties/{propertyId}', ...t('databases') })
268
+ .input(ws.extend({ propertyId: Id }))
269
+ .output(Ok),
270
+
271
+ addView: baseContract
272
+ .route({ method: 'POST', path: '/databases/{databaseId}/views', ...t('databases') })
273
+ .input(
274
+ ws.extend({
275
+ databaseId: Id,
276
+ name: z.string().min(1).max(120),
277
+ kind: ViewKind.default('table'),
278
+ config: ViewConfig.partial().default({}),
279
+ }),
280
+ )
281
+ .output(View),
282
+ updateView: baseContract
283
+ .route({ method: 'PATCH', path: '/views/{viewId}', ...t('databases') })
284
+ .input(
285
+ ws.extend({
286
+ viewId: Id,
287
+ name: z.string().min(1).max(120).optional(),
288
+ kind: ViewKind.optional(),
289
+ config: ViewConfig.partial().optional(),
290
+ }),
291
+ )
292
+ .output(View),
293
+ removeView: baseContract
294
+ .route({ method: 'DELETE', path: '/views/{viewId}', ...t('databases') })
295
+ .input(ws.extend({ viewId: Id }))
296
+ .output(Ok),
297
+
298
+ /** Both ends at once, because a link visible from one side only is the "wrong rollup" bug. */
299
+ setRelation: baseContract
300
+ .route({ method: 'POST', path: '/rows/{rowId}/relations', ...t('databases') })
301
+ .input(ws.extend({ rowId: Id, propertyId: Id, toPageIds: z.array(Id).max(200) }))
302
+ .output(Ok),
303
+ },
304
+
190
305
  publishing: {
191
306
  /** Make what is written now the version readers are served. Only meaningful for a `page`. */
192
307
  publish: baseContract