@kernhq/module-quire 0.2.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/LICENSE +662 -0
- package/README.md +71 -0
- package/dist/client/rank.d.ts +42 -0
- package/dist/client/rank.d.ts.map +1 -0
- package/dist/client/rank.js +97 -0
- package/dist/client/rank.js.map +1 -0
- package/dist/contract/capabilities.d.ts +35 -0
- package/dist/contract/capabilities.d.ts.map +1 -0
- package/dist/contract/capabilities.js +35 -0
- package/dist/contract/capabilities.js.map +1 -0
- package/dist/contract/events.d.ts +58 -0
- package/dist/contract/events.d.ts.map +1 -0
- package/dist/contract/events.js +18 -0
- package/dist/contract/events.js.map +1 -0
- package/dist/contract/index.d.ts +6 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +6 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/models.d.ts +95 -0
- package/dist/contract/models.d.ts.map +1 -0
- package/dist/contract/models.js +82 -0
- package/dist/contract/models.js.map +1 -0
- package/dist/contract/permissions.d.ts +51 -0
- package/dist/contract/permissions.d.ts.map +1 -0
- package/dist/contract/permissions.js +59 -0
- package/dist/contract/permissions.js.map +1 -0
- package/dist/contract/router.d.ts +713 -0
- package/dist/contract/router.d.ts.map +1 -0
- package/dist/contract/router.js +109 -0
- package/dist/contract/router.js.map +1 -0
- package/dist/server/_impl.d.ts +815 -0
- package/dist/server/_impl.d.ts.map +1 -0
- package/dist/server/_impl.js +189 -0
- package/dist/server/_impl.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +87 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/schema.d.ts +540 -0
- package/dist/server/schema.d.ts.map +1 -0
- package/dist/server/schema.js +86 -0
- package/dist/server/schema.js.map +1 -0
- package/dist/server/services/access.d.ts +78 -0
- package/dist/server/services/access.d.ts.map +1 -0
- package/dist/server/services/access.js +96 -0
- package/dist/server/services/access.js.map +1 -0
- package/dist/server/services/index.d.ts +15 -0
- package/dist/server/services/index.d.ts.map +1 -0
- package/dist/server/services/index.js +22 -0
- package/dist/server/services/index.js.map +1 -0
- package/dist/server/services/pages.d.ts +190 -0
- package/dist/server/services/pages.d.ts.map +1 -0
- package/dist/server/services/pages.js +242 -0
- package/dist/server/services/pages.js.map +1 -0
- package/dist/server/services/spaces.d.ts +95 -0
- package/dist/server/services/spaces.d.ts.map +1 -0
- package/dist/server/services/spaces.js +100 -0
- package/dist/server/services/spaces.js.map +1 -0
- package/migrations/0000_init.sql +43 -0
- package/migrations/0001_rls.sql +17 -0
- package/migrations/meta/0000_snapshot.json +358 -0
- package/migrations/meta/_journal.json +20 -0
- package/package.json +78 -0
- package/src/client/index.ts +67 -0
- package/src/client/rank.test.ts +92 -0
- package/src/client/rank.ts +100 -0
- package/src/contract/capabilities.ts +36 -0
- package/src/contract/events.ts +22 -0
- package/src/contract/index.ts +5 -0
- package/src/contract/models.ts +93 -0
- package/src/contract/permissions.ts +59 -0
- package/src/contract/router.ts +121 -0
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module's tables, in its own Postgres schema.
|
|
3
|
+
*
|
|
4
|
+
* `pgSchema` directly rather than `moduleSchema` from @kernhq/kernel, so drizzle-kit can load this
|
|
5
|
+
* file standalone — the same reason the tracker does it.
|
|
6
|
+
*
|
|
7
|
+
* Two rules, neither optional:
|
|
8
|
+
*
|
|
9
|
+
* - every tenant table carries `workspace_id` and an index that starts with it;
|
|
10
|
+
* - every tenant table gets a row-level security policy, hand-written in the migration, because
|
|
11
|
+
* drizzle-kit does not generate one.
|
|
12
|
+
*/
|
|
13
|
+
export declare const schema: import("drizzle-orm/pg-core").PgSchema<"mod_quire">;
|
|
14
|
+
export declare const spaces: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
15
|
+
name: "spaces";
|
|
16
|
+
schema: "mod_quire";
|
|
17
|
+
columns: {
|
|
18
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
19
|
+
name: "id";
|
|
20
|
+
tableName: "spaces";
|
|
21
|
+
dataType: "string";
|
|
22
|
+
columnType: "PgUUID";
|
|
23
|
+
data: string;
|
|
24
|
+
driverParam: string;
|
|
25
|
+
notNull: true;
|
|
26
|
+
hasDefault: true;
|
|
27
|
+
isPrimaryKey: true;
|
|
28
|
+
isAutoincrement: false;
|
|
29
|
+
hasRuntimeDefault: false;
|
|
30
|
+
enumValues: undefined;
|
|
31
|
+
baseColumn: never;
|
|
32
|
+
identity: undefined;
|
|
33
|
+
generated: undefined;
|
|
34
|
+
}, {}, {}>;
|
|
35
|
+
workspaceId: import("drizzle-orm/pg-core").PgColumn<{
|
|
36
|
+
name: "workspace_id";
|
|
37
|
+
tableName: "spaces";
|
|
38
|
+
dataType: "string";
|
|
39
|
+
columnType: "PgUUID";
|
|
40
|
+
data: string;
|
|
41
|
+
driverParam: string;
|
|
42
|
+
notNull: true;
|
|
43
|
+
hasDefault: false;
|
|
44
|
+
isPrimaryKey: false;
|
|
45
|
+
isAutoincrement: false;
|
|
46
|
+
hasRuntimeDefault: false;
|
|
47
|
+
enumValues: undefined;
|
|
48
|
+
baseColumn: never;
|
|
49
|
+
identity: undefined;
|
|
50
|
+
generated: undefined;
|
|
51
|
+
}, {}, {}>;
|
|
52
|
+
key: import("drizzle-orm/pg-core").PgColumn<{
|
|
53
|
+
name: "key";
|
|
54
|
+
tableName: "spaces";
|
|
55
|
+
dataType: "string";
|
|
56
|
+
columnType: "PgText";
|
|
57
|
+
data: string;
|
|
58
|
+
driverParam: string;
|
|
59
|
+
notNull: true;
|
|
60
|
+
hasDefault: false;
|
|
61
|
+
isPrimaryKey: false;
|
|
62
|
+
isAutoincrement: false;
|
|
63
|
+
hasRuntimeDefault: false;
|
|
64
|
+
enumValues: [string, ...string[]];
|
|
65
|
+
baseColumn: never;
|
|
66
|
+
identity: undefined;
|
|
67
|
+
generated: undefined;
|
|
68
|
+
}, {}, {}>;
|
|
69
|
+
name: import("drizzle-orm/pg-core").PgColumn<{
|
|
70
|
+
name: "name";
|
|
71
|
+
tableName: "spaces";
|
|
72
|
+
dataType: "string";
|
|
73
|
+
columnType: "PgText";
|
|
74
|
+
data: string;
|
|
75
|
+
driverParam: string;
|
|
76
|
+
notNull: true;
|
|
77
|
+
hasDefault: false;
|
|
78
|
+
isPrimaryKey: false;
|
|
79
|
+
isAutoincrement: false;
|
|
80
|
+
hasRuntimeDefault: false;
|
|
81
|
+
enumValues: [string, ...string[]];
|
|
82
|
+
baseColumn: never;
|
|
83
|
+
identity: undefined;
|
|
84
|
+
generated: undefined;
|
|
85
|
+
}, {}, {}>;
|
|
86
|
+
description: import("drizzle-orm/pg-core").PgColumn<{
|
|
87
|
+
name: "description";
|
|
88
|
+
tableName: "spaces";
|
|
89
|
+
dataType: "string";
|
|
90
|
+
columnType: "PgText";
|
|
91
|
+
data: string;
|
|
92
|
+
driverParam: string;
|
|
93
|
+
notNull: true;
|
|
94
|
+
hasDefault: true;
|
|
95
|
+
isPrimaryKey: false;
|
|
96
|
+
isAutoincrement: false;
|
|
97
|
+
hasRuntimeDefault: false;
|
|
98
|
+
enumValues: [string, ...string[]];
|
|
99
|
+
baseColumn: never;
|
|
100
|
+
identity: undefined;
|
|
101
|
+
generated: undefined;
|
|
102
|
+
}, {}, {}>;
|
|
103
|
+
icon: import("drizzle-orm/pg-core").PgColumn<{
|
|
104
|
+
name: "icon";
|
|
105
|
+
tableName: "spaces";
|
|
106
|
+
dataType: "string";
|
|
107
|
+
columnType: "PgText";
|
|
108
|
+
data: string;
|
|
109
|
+
driverParam: string;
|
|
110
|
+
notNull: false;
|
|
111
|
+
hasDefault: false;
|
|
112
|
+
isPrimaryKey: false;
|
|
113
|
+
isAutoincrement: false;
|
|
114
|
+
hasRuntimeDefault: false;
|
|
115
|
+
enumValues: [string, ...string[]];
|
|
116
|
+
baseColumn: never;
|
|
117
|
+
identity: undefined;
|
|
118
|
+
generated: undefined;
|
|
119
|
+
}, {}, {}>;
|
|
120
|
+
visibility: import("drizzle-orm/pg-core").PgColumn<{
|
|
121
|
+
name: "visibility";
|
|
122
|
+
tableName: "spaces";
|
|
123
|
+
dataType: "string";
|
|
124
|
+
columnType: "PgText";
|
|
125
|
+
data: string;
|
|
126
|
+
driverParam: string;
|
|
127
|
+
notNull: true;
|
|
128
|
+
hasDefault: true;
|
|
129
|
+
isPrimaryKey: false;
|
|
130
|
+
isAutoincrement: false;
|
|
131
|
+
hasRuntimeDefault: false;
|
|
132
|
+
enumValues: [string, ...string[]];
|
|
133
|
+
baseColumn: never;
|
|
134
|
+
identity: undefined;
|
|
135
|
+
generated: undefined;
|
|
136
|
+
}, {}, {}>;
|
|
137
|
+
homepageId: import("drizzle-orm/pg-core").PgColumn<{
|
|
138
|
+
name: "homepage_id";
|
|
139
|
+
tableName: "spaces";
|
|
140
|
+
dataType: "string";
|
|
141
|
+
columnType: "PgUUID";
|
|
142
|
+
data: string;
|
|
143
|
+
driverParam: string;
|
|
144
|
+
notNull: false;
|
|
145
|
+
hasDefault: false;
|
|
146
|
+
isPrimaryKey: false;
|
|
147
|
+
isAutoincrement: false;
|
|
148
|
+
hasRuntimeDefault: false;
|
|
149
|
+
enumValues: undefined;
|
|
150
|
+
baseColumn: never;
|
|
151
|
+
identity: undefined;
|
|
152
|
+
generated: undefined;
|
|
153
|
+
}, {}, {}>;
|
|
154
|
+
createdBy: import("drizzle-orm/pg-core").PgColumn<{
|
|
155
|
+
name: "created_by";
|
|
156
|
+
tableName: "spaces";
|
|
157
|
+
dataType: "string";
|
|
158
|
+
columnType: "PgUUID";
|
|
159
|
+
data: string;
|
|
160
|
+
driverParam: string;
|
|
161
|
+
notNull: false;
|
|
162
|
+
hasDefault: false;
|
|
163
|
+
isPrimaryKey: false;
|
|
164
|
+
isAutoincrement: false;
|
|
165
|
+
hasRuntimeDefault: false;
|
|
166
|
+
enumValues: undefined;
|
|
167
|
+
baseColumn: never;
|
|
168
|
+
identity: undefined;
|
|
169
|
+
generated: undefined;
|
|
170
|
+
}, {}, {}>;
|
|
171
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
172
|
+
name: string;
|
|
173
|
+
tableName: "spaces";
|
|
174
|
+
dataType: "date";
|
|
175
|
+
columnType: "PgTimestamp";
|
|
176
|
+
data: Date;
|
|
177
|
+
driverParam: string;
|
|
178
|
+
notNull: true;
|
|
179
|
+
hasDefault: true;
|
|
180
|
+
isPrimaryKey: false;
|
|
181
|
+
isAutoincrement: false;
|
|
182
|
+
hasRuntimeDefault: false;
|
|
183
|
+
enumValues: undefined;
|
|
184
|
+
baseColumn: never;
|
|
185
|
+
identity: undefined;
|
|
186
|
+
generated: undefined;
|
|
187
|
+
}, {}, {}>;
|
|
188
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
189
|
+
name: string;
|
|
190
|
+
tableName: "spaces";
|
|
191
|
+
dataType: "date";
|
|
192
|
+
columnType: "PgTimestamp";
|
|
193
|
+
data: Date;
|
|
194
|
+
driverParam: string;
|
|
195
|
+
notNull: true;
|
|
196
|
+
hasDefault: true;
|
|
197
|
+
isPrimaryKey: false;
|
|
198
|
+
isAutoincrement: false;
|
|
199
|
+
hasRuntimeDefault: false;
|
|
200
|
+
enumValues: undefined;
|
|
201
|
+
baseColumn: never;
|
|
202
|
+
identity: undefined;
|
|
203
|
+
generated: undefined;
|
|
204
|
+
}, {}, {}>;
|
|
205
|
+
archivedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
206
|
+
name: string;
|
|
207
|
+
tableName: "spaces";
|
|
208
|
+
dataType: "date";
|
|
209
|
+
columnType: "PgTimestamp";
|
|
210
|
+
data: Date;
|
|
211
|
+
driverParam: string;
|
|
212
|
+
notNull: false;
|
|
213
|
+
hasDefault: false;
|
|
214
|
+
isPrimaryKey: false;
|
|
215
|
+
isAutoincrement: false;
|
|
216
|
+
hasRuntimeDefault: false;
|
|
217
|
+
enumValues: undefined;
|
|
218
|
+
baseColumn: never;
|
|
219
|
+
identity: undefined;
|
|
220
|
+
generated: undefined;
|
|
221
|
+
}, {}, {}>;
|
|
222
|
+
};
|
|
223
|
+
dialect: "pg";
|
|
224
|
+
}>;
|
|
225
|
+
export declare const pages: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
226
|
+
name: "pages";
|
|
227
|
+
schema: "mod_quire";
|
|
228
|
+
columns: {
|
|
229
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
230
|
+
name: "id";
|
|
231
|
+
tableName: "pages";
|
|
232
|
+
dataType: "string";
|
|
233
|
+
columnType: "PgUUID";
|
|
234
|
+
data: string;
|
|
235
|
+
driverParam: string;
|
|
236
|
+
notNull: true;
|
|
237
|
+
hasDefault: true;
|
|
238
|
+
isPrimaryKey: true;
|
|
239
|
+
isAutoincrement: false;
|
|
240
|
+
hasRuntimeDefault: false;
|
|
241
|
+
enumValues: undefined;
|
|
242
|
+
baseColumn: never;
|
|
243
|
+
identity: undefined;
|
|
244
|
+
generated: undefined;
|
|
245
|
+
}, {}, {}>;
|
|
246
|
+
workspaceId: import("drizzle-orm/pg-core").PgColumn<{
|
|
247
|
+
name: "workspace_id";
|
|
248
|
+
tableName: "pages";
|
|
249
|
+
dataType: "string";
|
|
250
|
+
columnType: "PgUUID";
|
|
251
|
+
data: string;
|
|
252
|
+
driverParam: string;
|
|
253
|
+
notNull: true;
|
|
254
|
+
hasDefault: false;
|
|
255
|
+
isPrimaryKey: false;
|
|
256
|
+
isAutoincrement: false;
|
|
257
|
+
hasRuntimeDefault: false;
|
|
258
|
+
enumValues: undefined;
|
|
259
|
+
baseColumn: never;
|
|
260
|
+
identity: undefined;
|
|
261
|
+
generated: undefined;
|
|
262
|
+
}, {}, {}>;
|
|
263
|
+
spaceId: import("drizzle-orm/pg-core").PgColumn<{
|
|
264
|
+
name: "space_id";
|
|
265
|
+
tableName: "pages";
|
|
266
|
+
dataType: "string";
|
|
267
|
+
columnType: "PgUUID";
|
|
268
|
+
data: string;
|
|
269
|
+
driverParam: string;
|
|
270
|
+
notNull: true;
|
|
271
|
+
hasDefault: false;
|
|
272
|
+
isPrimaryKey: false;
|
|
273
|
+
isAutoincrement: false;
|
|
274
|
+
hasRuntimeDefault: false;
|
|
275
|
+
enumValues: undefined;
|
|
276
|
+
baseColumn: never;
|
|
277
|
+
identity: undefined;
|
|
278
|
+
generated: undefined;
|
|
279
|
+
}, {}, {}>;
|
|
280
|
+
parentId: import("drizzle-orm/pg-core").PgColumn<{
|
|
281
|
+
name: "parent_id";
|
|
282
|
+
tableName: "pages";
|
|
283
|
+
dataType: "string";
|
|
284
|
+
columnType: "PgUUID";
|
|
285
|
+
data: string;
|
|
286
|
+
driverParam: string;
|
|
287
|
+
notNull: false;
|
|
288
|
+
hasDefault: false;
|
|
289
|
+
isPrimaryKey: false;
|
|
290
|
+
isAutoincrement: false;
|
|
291
|
+
hasRuntimeDefault: false;
|
|
292
|
+
enumValues: undefined;
|
|
293
|
+
baseColumn: never;
|
|
294
|
+
identity: undefined;
|
|
295
|
+
generated: undefined;
|
|
296
|
+
}, {}, {}>;
|
|
297
|
+
position: import("drizzle-orm/pg-core").PgColumn<{
|
|
298
|
+
name: "position";
|
|
299
|
+
tableName: "pages";
|
|
300
|
+
dataType: "string";
|
|
301
|
+
columnType: "PgText";
|
|
302
|
+
data: string;
|
|
303
|
+
driverParam: string;
|
|
304
|
+
notNull: true;
|
|
305
|
+
hasDefault: false;
|
|
306
|
+
isPrimaryKey: false;
|
|
307
|
+
isAutoincrement: false;
|
|
308
|
+
hasRuntimeDefault: false;
|
|
309
|
+
enumValues: [string, ...string[]];
|
|
310
|
+
baseColumn: never;
|
|
311
|
+
identity: undefined;
|
|
312
|
+
generated: undefined;
|
|
313
|
+
}, {}, {}>;
|
|
314
|
+
kind: import("drizzle-orm/pg-core").PgColumn<{
|
|
315
|
+
name: "kind";
|
|
316
|
+
tableName: "pages";
|
|
317
|
+
dataType: "string";
|
|
318
|
+
columnType: "PgText";
|
|
319
|
+
data: string;
|
|
320
|
+
driverParam: string;
|
|
321
|
+
notNull: true;
|
|
322
|
+
hasDefault: true;
|
|
323
|
+
isPrimaryKey: false;
|
|
324
|
+
isAutoincrement: false;
|
|
325
|
+
hasRuntimeDefault: false;
|
|
326
|
+
enumValues: [string, ...string[]];
|
|
327
|
+
baseColumn: never;
|
|
328
|
+
identity: undefined;
|
|
329
|
+
generated: undefined;
|
|
330
|
+
}, {}, {}>;
|
|
331
|
+
title: import("drizzle-orm/pg-core").PgColumn<{
|
|
332
|
+
name: "title";
|
|
333
|
+
tableName: "pages";
|
|
334
|
+
dataType: "string";
|
|
335
|
+
columnType: "PgText";
|
|
336
|
+
data: string;
|
|
337
|
+
driverParam: string;
|
|
338
|
+
notNull: true;
|
|
339
|
+
hasDefault: true;
|
|
340
|
+
isPrimaryKey: false;
|
|
341
|
+
isAutoincrement: false;
|
|
342
|
+
hasRuntimeDefault: false;
|
|
343
|
+
enumValues: [string, ...string[]];
|
|
344
|
+
baseColumn: never;
|
|
345
|
+
identity: undefined;
|
|
346
|
+
generated: undefined;
|
|
347
|
+
}, {}, {}>;
|
|
348
|
+
icon: import("drizzle-orm/pg-core").PgColumn<{
|
|
349
|
+
name: "icon";
|
|
350
|
+
tableName: "pages";
|
|
351
|
+
dataType: "string";
|
|
352
|
+
columnType: "PgText";
|
|
353
|
+
data: string;
|
|
354
|
+
driverParam: string;
|
|
355
|
+
notNull: false;
|
|
356
|
+
hasDefault: false;
|
|
357
|
+
isPrimaryKey: false;
|
|
358
|
+
isAutoincrement: false;
|
|
359
|
+
hasRuntimeDefault: false;
|
|
360
|
+
enumValues: [string, ...string[]];
|
|
361
|
+
baseColumn: never;
|
|
362
|
+
identity: undefined;
|
|
363
|
+
generated: undefined;
|
|
364
|
+
}, {}, {}>;
|
|
365
|
+
coverUrl: import("drizzle-orm/pg-core").PgColumn<{
|
|
366
|
+
name: "cover_url";
|
|
367
|
+
tableName: "pages";
|
|
368
|
+
dataType: "string";
|
|
369
|
+
columnType: "PgText";
|
|
370
|
+
data: string;
|
|
371
|
+
driverParam: string;
|
|
372
|
+
notNull: false;
|
|
373
|
+
hasDefault: false;
|
|
374
|
+
isPrimaryKey: false;
|
|
375
|
+
isAutoincrement: false;
|
|
376
|
+
hasRuntimeDefault: false;
|
|
377
|
+
enumValues: [string, ...string[]];
|
|
378
|
+
baseColumn: never;
|
|
379
|
+
identity: undefined;
|
|
380
|
+
generated: undefined;
|
|
381
|
+
}, {}, {}>;
|
|
382
|
+
publishedVersionId: import("drizzle-orm/pg-core").PgColumn<{
|
|
383
|
+
name: "published_version_id";
|
|
384
|
+
tableName: "pages";
|
|
385
|
+
dataType: "string";
|
|
386
|
+
columnType: "PgUUID";
|
|
387
|
+
data: string;
|
|
388
|
+
driverParam: string;
|
|
389
|
+
notNull: false;
|
|
390
|
+
hasDefault: false;
|
|
391
|
+
isPrimaryKey: false;
|
|
392
|
+
isAutoincrement: false;
|
|
393
|
+
hasRuntimeDefault: false;
|
|
394
|
+
enumValues: undefined;
|
|
395
|
+
baseColumn: never;
|
|
396
|
+
identity: undefined;
|
|
397
|
+
generated: undefined;
|
|
398
|
+
}, {}, {}>;
|
|
399
|
+
hasUnpublishedChanges: import("drizzle-orm/pg-core").PgColumn<{
|
|
400
|
+
name: "has_unpublished_changes";
|
|
401
|
+
tableName: "pages";
|
|
402
|
+
dataType: "boolean";
|
|
403
|
+
columnType: "PgBoolean";
|
|
404
|
+
data: boolean;
|
|
405
|
+
driverParam: boolean;
|
|
406
|
+
notNull: true;
|
|
407
|
+
hasDefault: true;
|
|
408
|
+
isPrimaryKey: false;
|
|
409
|
+
isAutoincrement: false;
|
|
410
|
+
hasRuntimeDefault: false;
|
|
411
|
+
enumValues: undefined;
|
|
412
|
+
baseColumn: never;
|
|
413
|
+
identity: undefined;
|
|
414
|
+
generated: undefined;
|
|
415
|
+
}, {}, {}>;
|
|
416
|
+
text: import("drizzle-orm/pg-core").PgColumn<{
|
|
417
|
+
name: "text";
|
|
418
|
+
tableName: "pages";
|
|
419
|
+
dataType: "string";
|
|
420
|
+
columnType: "PgText";
|
|
421
|
+
data: string;
|
|
422
|
+
driverParam: string;
|
|
423
|
+
notNull: true;
|
|
424
|
+
hasDefault: true;
|
|
425
|
+
isPrimaryKey: false;
|
|
426
|
+
isAutoincrement: false;
|
|
427
|
+
hasRuntimeDefault: false;
|
|
428
|
+
enumValues: [string, ...string[]];
|
|
429
|
+
baseColumn: never;
|
|
430
|
+
identity: undefined;
|
|
431
|
+
generated: undefined;
|
|
432
|
+
}, {}, {}>;
|
|
433
|
+
createdBy: import("drizzle-orm/pg-core").PgColumn<{
|
|
434
|
+
name: "created_by";
|
|
435
|
+
tableName: "pages";
|
|
436
|
+
dataType: "string";
|
|
437
|
+
columnType: "PgUUID";
|
|
438
|
+
data: string;
|
|
439
|
+
driverParam: string;
|
|
440
|
+
notNull: false;
|
|
441
|
+
hasDefault: false;
|
|
442
|
+
isPrimaryKey: false;
|
|
443
|
+
isAutoincrement: false;
|
|
444
|
+
hasRuntimeDefault: false;
|
|
445
|
+
enumValues: undefined;
|
|
446
|
+
baseColumn: never;
|
|
447
|
+
identity: undefined;
|
|
448
|
+
generated: undefined;
|
|
449
|
+
}, {}, {}>;
|
|
450
|
+
updatedBy: import("drizzle-orm/pg-core").PgColumn<{
|
|
451
|
+
name: "updated_by";
|
|
452
|
+
tableName: "pages";
|
|
453
|
+
dataType: "string";
|
|
454
|
+
columnType: "PgUUID";
|
|
455
|
+
data: string;
|
|
456
|
+
driverParam: string;
|
|
457
|
+
notNull: false;
|
|
458
|
+
hasDefault: false;
|
|
459
|
+
isPrimaryKey: false;
|
|
460
|
+
isAutoincrement: false;
|
|
461
|
+
hasRuntimeDefault: false;
|
|
462
|
+
enumValues: undefined;
|
|
463
|
+
baseColumn: never;
|
|
464
|
+
identity: undefined;
|
|
465
|
+
generated: undefined;
|
|
466
|
+
}, {}, {}>;
|
|
467
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
468
|
+
name: string;
|
|
469
|
+
tableName: "pages";
|
|
470
|
+
dataType: "date";
|
|
471
|
+
columnType: "PgTimestamp";
|
|
472
|
+
data: Date;
|
|
473
|
+
driverParam: string;
|
|
474
|
+
notNull: true;
|
|
475
|
+
hasDefault: true;
|
|
476
|
+
isPrimaryKey: false;
|
|
477
|
+
isAutoincrement: false;
|
|
478
|
+
hasRuntimeDefault: false;
|
|
479
|
+
enumValues: undefined;
|
|
480
|
+
baseColumn: never;
|
|
481
|
+
identity: undefined;
|
|
482
|
+
generated: undefined;
|
|
483
|
+
}, {}, {}>;
|
|
484
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
485
|
+
name: string;
|
|
486
|
+
tableName: "pages";
|
|
487
|
+
dataType: "date";
|
|
488
|
+
columnType: "PgTimestamp";
|
|
489
|
+
data: Date;
|
|
490
|
+
driverParam: string;
|
|
491
|
+
notNull: true;
|
|
492
|
+
hasDefault: true;
|
|
493
|
+
isPrimaryKey: false;
|
|
494
|
+
isAutoincrement: false;
|
|
495
|
+
hasRuntimeDefault: false;
|
|
496
|
+
enumValues: undefined;
|
|
497
|
+
baseColumn: never;
|
|
498
|
+
identity: undefined;
|
|
499
|
+
generated: undefined;
|
|
500
|
+
}, {}, {}>;
|
|
501
|
+
archivedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
502
|
+
name: string;
|
|
503
|
+
tableName: "pages";
|
|
504
|
+
dataType: "date";
|
|
505
|
+
columnType: "PgTimestamp";
|
|
506
|
+
data: Date;
|
|
507
|
+
driverParam: string;
|
|
508
|
+
notNull: false;
|
|
509
|
+
hasDefault: false;
|
|
510
|
+
isPrimaryKey: false;
|
|
511
|
+
isAutoincrement: false;
|
|
512
|
+
hasRuntimeDefault: false;
|
|
513
|
+
enumValues: undefined;
|
|
514
|
+
baseColumn: never;
|
|
515
|
+
identity: undefined;
|
|
516
|
+
generated: undefined;
|
|
517
|
+
}, {}, {}>;
|
|
518
|
+
deletedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
519
|
+
name: string;
|
|
520
|
+
tableName: "pages";
|
|
521
|
+
dataType: "date";
|
|
522
|
+
columnType: "PgTimestamp";
|
|
523
|
+
data: Date;
|
|
524
|
+
driverParam: string;
|
|
525
|
+
notNull: false;
|
|
526
|
+
hasDefault: false;
|
|
527
|
+
isPrimaryKey: false;
|
|
528
|
+
isAutoincrement: false;
|
|
529
|
+
hasRuntimeDefault: false;
|
|
530
|
+
enumValues: undefined;
|
|
531
|
+
baseColumn: never;
|
|
532
|
+
identity: undefined;
|
|
533
|
+
generated: undefined;
|
|
534
|
+
}, {}, {}>;
|
|
535
|
+
};
|
|
536
|
+
dialect: "pg";
|
|
537
|
+
}>;
|
|
538
|
+
/** Every tenant table, so the RLS migration can be checked against one list rather than memory. */
|
|
539
|
+
export declare const TENANT_TABLES: readonly ["spaces", "pages"];
|
|
540
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/server/schema.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,MAAM,qDAAwB,CAAA;AAM3C,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBlB,CAAA;AAED,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8CjB,CAAA;AAED,mGAAmG;AACnG,eAAO,MAAM,aAAa,8BAA+B,CAAA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { sql } from 'drizzle-orm';
|
|
2
|
+
import { boolean, index, pgSchema, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
|
|
3
|
+
/**
|
|
4
|
+
* This module's tables, in its own Postgres schema.
|
|
5
|
+
*
|
|
6
|
+
* `pgSchema` directly rather than `moduleSchema` from @kernhq/kernel, so drizzle-kit can load this
|
|
7
|
+
* file standalone — the same reason the tracker does it.
|
|
8
|
+
*
|
|
9
|
+
* Two rules, neither optional:
|
|
10
|
+
*
|
|
11
|
+
* - every tenant table carries `workspace_id` and an index that starts with it;
|
|
12
|
+
* - every tenant table gets a row-level security policy, hand-written in the migration, because
|
|
13
|
+
* drizzle-kit does not generate one.
|
|
14
|
+
*/
|
|
15
|
+
export const schema = pgSchema('mod_quire');
|
|
16
|
+
const id = () => uuid('id').primaryKey().default(sql `uuidv7()`);
|
|
17
|
+
const ws = () => uuid('workspace_id').notNull();
|
|
18
|
+
const ts = (name) => timestamp(name, { withTimezone: true });
|
|
19
|
+
export const spaces = schema.table('spaces', {
|
|
20
|
+
id: id(),
|
|
21
|
+
workspaceId: ws(),
|
|
22
|
+
key: text('key').notNull(),
|
|
23
|
+
name: text('name').notNull(),
|
|
24
|
+
description: text('description').notNull().default(''),
|
|
25
|
+
icon: text('icon'),
|
|
26
|
+
visibility: text('visibility').notNull().default('open'),
|
|
27
|
+
/**
|
|
28
|
+
* No foreign key to `pages`: the space is created before it can have a home page, and pages
|
|
29
|
+
* point at their space, so a constraint in both directions makes either one impossible to
|
|
30
|
+
* insert first.
|
|
31
|
+
*/
|
|
32
|
+
homepageId: uuid('homepage_id'),
|
|
33
|
+
createdBy: uuid('created_by'),
|
|
34
|
+
createdAt: ts('created_at').notNull().defaultNow(),
|
|
35
|
+
updatedAt: ts('updated_at').notNull().defaultNow(),
|
|
36
|
+
archivedAt: ts('archived_at'),
|
|
37
|
+
}, (t) => [
|
|
38
|
+
uniqueIndex('spaces_ws_key_uq').on(t.workspaceId, t.key),
|
|
39
|
+
index('spaces_ws_idx').on(t.workspaceId, t.createdAt),
|
|
40
|
+
]);
|
|
41
|
+
export const pages = schema.table('pages', {
|
|
42
|
+
id: id(),
|
|
43
|
+
workspaceId: ws(),
|
|
44
|
+
spaceId: uuid('space_id').notNull(),
|
|
45
|
+
parentId: uuid('parent_id'),
|
|
46
|
+
/**
|
|
47
|
+
* A fractional index as text, not an integer. Moving a page between two siblings must not
|
|
48
|
+
* renumber the rest: two people reordering at once would write different numbers for the same
|
|
49
|
+
* rows, and the tree would disagree with itself until someone reloaded.
|
|
50
|
+
*
|
|
51
|
+
* **The column is `COLLATE "C"` in the migration, and has to stay that way.** The keys are
|
|
52
|
+
* base-62 fractions whose alphabet is ordered by code point, so `ORDER BY position` is only the
|
|
53
|
+
* order the algorithm intended under byte comparison. This database is `en_US.UTF-8`, where
|
|
54
|
+
* `'U' < 'c'` is false — three pages created in order come back reversed. drizzle-kit does not
|
|
55
|
+
* carry the collation in its snapshot, so if you ever regenerate this migration, put it back.
|
|
56
|
+
*/
|
|
57
|
+
position: text('position').notNull(),
|
|
58
|
+
kind: text('kind').notNull().default('page'),
|
|
59
|
+
/**
|
|
60
|
+
* Mirrored out of the collaborative document, where the title is a Y.Text so two people renaming
|
|
61
|
+
* at once merge instead of clobbering. This column exists so the tree can be queried and sorted
|
|
62
|
+
* without decoding a CRDT; the document is the truth.
|
|
63
|
+
*/
|
|
64
|
+
title: text('title').notNull().default(''),
|
|
65
|
+
icon: text('icon'),
|
|
66
|
+
coverUrl: text('cover_url'),
|
|
67
|
+
/** The version a reader without edit rights is served. Null until a `page` is first published. */
|
|
68
|
+
publishedVersionId: uuid('published_version_id'),
|
|
69
|
+
/** Whether the live document has moved on since `published_version_id` was written. */
|
|
70
|
+
hasUnpublishedChanges: boolean('has_unpublished_changes').notNull().default(false),
|
|
71
|
+
/** Flattened prose, kept for search; the collab service publishes it as the document changes. */
|
|
72
|
+
text: text('text').notNull().default(''),
|
|
73
|
+
createdBy: uuid('created_by'),
|
|
74
|
+
updatedBy: uuid('updated_by'),
|
|
75
|
+
createdAt: ts('created_at').notNull().defaultNow(),
|
|
76
|
+
updatedAt: ts('updated_at').notNull().defaultNow(),
|
|
77
|
+
archivedAt: ts('archived_at'),
|
|
78
|
+
deletedAt: ts('deleted_at'),
|
|
79
|
+
}, (t) => [
|
|
80
|
+
index('pages_ws_space_idx').on(t.workspaceId, t.spaceId, t.position),
|
|
81
|
+
index('pages_ws_parent_idx').on(t.workspaceId, t.parentId, t.position),
|
|
82
|
+
index('pages_ws_updated_idx').on(t.workspaceId, t.updatedAt),
|
|
83
|
+
]);
|
|
84
|
+
/** Every tenant table, so the RLS migration can be checked against one list rather than memory. */
|
|
85
|
+
export const TENANT_TABLES = ['spaces', 'pages'];
|
|
86
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/server/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAElG;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAA;AAE3C,MAAM,EAAE,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC,OAA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