@minion-stack/db 0.3.0 → 0.4.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 (41) hide show
  1. package/dist/crypto.d.ts +19 -0
  2. package/dist/crypto.d.ts.map +1 -0
  3. package/dist/crypto.js +65 -0
  4. package/dist/crypto.js.map +1 -0
  5. package/dist/crypto.test.d.ts +2 -0
  6. package/dist/crypto.test.d.ts.map +1 -0
  7. package/dist/crypto.test.js +23 -0
  8. package/dist/crypto.test.js.map +1 -0
  9. package/dist/pg/crypto.d.ts +1 -7
  10. package/dist/pg/crypto.d.ts.map +1 -1
  11. package/dist/pg/crypto.js +4 -41
  12. package/dist/pg/crypto.js.map +1 -1
  13. package/dist/pg/schema/gateway.d.ts +262 -0
  14. package/dist/pg/schema/gateway.d.ts.map +1 -0
  15. package/dist/pg/schema/gateway.js +36 -0
  16. package/dist/pg/schema/gateway.js.map +1 -0
  17. package/dist/pg/schema/index.d.ts +2 -0
  18. package/dist/pg/schema/index.d.ts.map +1 -1
  19. package/dist/pg/schema/index.js +2 -0
  20. package/dist/pg/schema/index.js.map +1 -1
  21. package/dist/pg/schema/join.d.ts +406 -0
  22. package/dist/pg/schema/join.d.ts.map +1 -0
  23. package/dist/pg/schema/join.js +37 -0
  24. package/dist/pg/schema/join.js.map +1 -0
  25. package/dist/pg/schema/profiles.d.ts +17 -0
  26. package/dist/pg/schema/profiles.d.ts.map +1 -1
  27. package/dist/pg/schema/profiles.js +3 -0
  28. package/dist/pg/schema/profiles.js.map +1 -1
  29. package/dist/schema/flows.d.ts +36 -0
  30. package/dist/schema/flows.d.ts.map +1 -1
  31. package/dist/schema/flows.js +2 -0
  32. package/dist/schema/flows.js.map +1 -1
  33. package/package.json +5 -1
  34. package/src/crypto.test.ts +33 -0
  35. package/src/crypto.ts +73 -0
  36. package/src/pg/crypto.ts +4 -44
  37. package/src/pg/schema/gateway.ts +37 -0
  38. package/src/pg/schema/index.ts +2 -0
  39. package/src/pg/schema/join.ts +38 -0
  40. package/src/pg/schema/profiles.ts +3 -0
  41. package/src/schema/flows.ts +2 -0
@@ -0,0 +1,406 @@
1
+ export declare const joinRequest: import("drizzle-orm/pg-core").PgTableWithColumns<{
2
+ name: "join_request";
3
+ schema: undefined;
4
+ columns: {
5
+ id: import("drizzle-orm/pg-core").PgColumn<{
6
+ name: "id";
7
+ tableName: "join_request";
8
+ dataType: "string";
9
+ columnType: "PgUUID";
10
+ data: string;
11
+ driverParam: string;
12
+ notNull: true;
13
+ hasDefault: true;
14
+ isPrimaryKey: true;
15
+ isAutoincrement: false;
16
+ hasRuntimeDefault: false;
17
+ enumValues: undefined;
18
+ baseColumn: never;
19
+ identity: undefined;
20
+ generated: undefined;
21
+ }, {}, {}>;
22
+ supabaseId: import("drizzle-orm/pg-core").PgColumn<{
23
+ name: "supabase_id";
24
+ tableName: "join_request";
25
+ dataType: "string";
26
+ columnType: "PgUUID";
27
+ data: string;
28
+ driverParam: string;
29
+ notNull: true;
30
+ hasDefault: false;
31
+ isPrimaryKey: false;
32
+ isAutoincrement: false;
33
+ hasRuntimeDefault: false;
34
+ enumValues: undefined;
35
+ baseColumn: never;
36
+ identity: undefined;
37
+ generated: undefined;
38
+ }, {}, {}>;
39
+ userId: import("drizzle-orm/pg-core").PgColumn<{
40
+ name: "user_id";
41
+ tableName: "join_request";
42
+ dataType: "string";
43
+ columnType: "PgText";
44
+ data: string;
45
+ driverParam: string;
46
+ notNull: true;
47
+ hasDefault: false;
48
+ isPrimaryKey: false;
49
+ isAutoincrement: false;
50
+ hasRuntimeDefault: false;
51
+ enumValues: [string, ...string[]];
52
+ baseColumn: never;
53
+ identity: undefined;
54
+ generated: undefined;
55
+ }, {}, {}>;
56
+ email: import("drizzle-orm/pg-core").PgColumn<{
57
+ name: "email";
58
+ tableName: "join_request";
59
+ dataType: "string";
60
+ columnType: "PgText";
61
+ data: string;
62
+ driverParam: string;
63
+ notNull: true;
64
+ hasDefault: false;
65
+ isPrimaryKey: false;
66
+ isAutoincrement: false;
67
+ hasRuntimeDefault: false;
68
+ enumValues: [string, ...string[]];
69
+ baseColumn: never;
70
+ identity: undefined;
71
+ generated: undefined;
72
+ }, {}, {}>;
73
+ displayName: import("drizzle-orm/pg-core").PgColumn<{
74
+ name: "display_name";
75
+ tableName: "join_request";
76
+ dataType: "string";
77
+ columnType: "PgText";
78
+ data: string;
79
+ driverParam: string;
80
+ notNull: false;
81
+ hasDefault: false;
82
+ isPrimaryKey: false;
83
+ isAutoincrement: false;
84
+ hasRuntimeDefault: false;
85
+ enumValues: [string, ...string[]];
86
+ baseColumn: never;
87
+ identity: undefined;
88
+ generated: undefined;
89
+ }, {}, {}>;
90
+ message: import("drizzle-orm/pg-core").PgColumn<{
91
+ name: "message";
92
+ tableName: "join_request";
93
+ dataType: "string";
94
+ columnType: "PgText";
95
+ data: string;
96
+ driverParam: string;
97
+ notNull: false;
98
+ hasDefault: false;
99
+ isPrimaryKey: false;
100
+ isAutoincrement: false;
101
+ hasRuntimeDefault: false;
102
+ enumValues: [string, ...string[]];
103
+ baseColumn: never;
104
+ identity: undefined;
105
+ generated: undefined;
106
+ }, {}, {}>;
107
+ status: import("drizzle-orm/pg-core").PgColumn<{
108
+ name: "status";
109
+ tableName: "join_request";
110
+ dataType: "string";
111
+ columnType: "PgText";
112
+ data: "pending" | "approved" | "denied";
113
+ driverParam: string;
114
+ notNull: true;
115
+ hasDefault: true;
116
+ isPrimaryKey: false;
117
+ isAutoincrement: false;
118
+ hasRuntimeDefault: false;
119
+ enumValues: ["pending", "approved", "denied"];
120
+ baseColumn: never;
121
+ identity: undefined;
122
+ generated: undefined;
123
+ }, {}, {}>;
124
+ organizationId: import("drizzle-orm/pg-core").PgColumn<{
125
+ name: "organization_id";
126
+ tableName: "join_request";
127
+ dataType: "string";
128
+ columnType: "PgText";
129
+ data: string;
130
+ driverParam: string;
131
+ notNull: true;
132
+ hasDefault: false;
133
+ isPrimaryKey: false;
134
+ isAutoincrement: false;
135
+ hasRuntimeDefault: false;
136
+ enumValues: [string, ...string[]];
137
+ baseColumn: never;
138
+ identity: undefined;
139
+ generated: undefined;
140
+ }, {}, {}>;
141
+ requestedRole: import("drizzle-orm/pg-core").PgColumn<{
142
+ name: "requested_role";
143
+ tableName: "join_request";
144
+ dataType: "string";
145
+ columnType: "PgText";
146
+ data: "user" | "admin" | "super_admin";
147
+ driverParam: string;
148
+ notNull: true;
149
+ hasDefault: true;
150
+ isPrimaryKey: false;
151
+ isAutoincrement: false;
152
+ hasRuntimeDefault: false;
153
+ enumValues: ["user", "admin", "super_admin"];
154
+ baseColumn: never;
155
+ identity: undefined;
156
+ generated: undefined;
157
+ }, {}, {}>;
158
+ reviewedBy: import("drizzle-orm/pg-core").PgColumn<{
159
+ name: "reviewed_by";
160
+ tableName: "join_request";
161
+ dataType: "string";
162
+ columnType: "PgText";
163
+ data: string;
164
+ driverParam: string;
165
+ notNull: false;
166
+ hasDefault: false;
167
+ isPrimaryKey: false;
168
+ isAutoincrement: false;
169
+ hasRuntimeDefault: false;
170
+ enumValues: [string, ...string[]];
171
+ baseColumn: never;
172
+ identity: undefined;
173
+ generated: undefined;
174
+ }, {}, {}>;
175
+ reviewedAt: import("drizzle-orm/pg-core").PgColumn<{
176
+ name: "reviewed_at";
177
+ tableName: "join_request";
178
+ dataType: "date";
179
+ columnType: "PgTimestamp";
180
+ data: Date;
181
+ driverParam: string;
182
+ notNull: false;
183
+ hasDefault: false;
184
+ isPrimaryKey: false;
185
+ isAutoincrement: false;
186
+ hasRuntimeDefault: false;
187
+ enumValues: undefined;
188
+ baseColumn: never;
189
+ identity: undefined;
190
+ generated: undefined;
191
+ }, {}, {}>;
192
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
193
+ name: "created_at";
194
+ tableName: "join_request";
195
+ dataType: "date";
196
+ columnType: "PgTimestamp";
197
+ data: Date;
198
+ driverParam: string;
199
+ notNull: true;
200
+ hasDefault: true;
201
+ isPrimaryKey: false;
202
+ isAutoincrement: false;
203
+ hasRuntimeDefault: false;
204
+ enumValues: undefined;
205
+ baseColumn: never;
206
+ identity: undefined;
207
+ generated: undefined;
208
+ }, {}, {}>;
209
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
210
+ name: "updated_at";
211
+ tableName: "join_request";
212
+ dataType: "date";
213
+ columnType: "PgTimestamp";
214
+ data: Date;
215
+ driverParam: string;
216
+ notNull: true;
217
+ hasDefault: true;
218
+ isPrimaryKey: false;
219
+ isAutoincrement: false;
220
+ hasRuntimeDefault: false;
221
+ enumValues: undefined;
222
+ baseColumn: never;
223
+ identity: undefined;
224
+ generated: undefined;
225
+ }, {}, {}>;
226
+ };
227
+ dialect: "pg";
228
+ }>;
229
+ export declare const joinLink: import("drizzle-orm/pg-core").PgTableWithColumns<{
230
+ name: "join_link";
231
+ schema: undefined;
232
+ columns: {
233
+ id: import("drizzle-orm/pg-core").PgColumn<{
234
+ name: "id";
235
+ tableName: "join_link";
236
+ dataType: "string";
237
+ columnType: "PgUUID";
238
+ data: string;
239
+ driverParam: string;
240
+ notNull: true;
241
+ hasDefault: true;
242
+ isPrimaryKey: true;
243
+ isAutoincrement: false;
244
+ hasRuntimeDefault: false;
245
+ enumValues: undefined;
246
+ baseColumn: never;
247
+ identity: undefined;
248
+ generated: undefined;
249
+ }, {}, {}>;
250
+ token: import("drizzle-orm/pg-core").PgColumn<{
251
+ name: "token";
252
+ tableName: "join_link";
253
+ dataType: "string";
254
+ columnType: "PgText";
255
+ data: string;
256
+ driverParam: string;
257
+ notNull: true;
258
+ hasDefault: false;
259
+ isPrimaryKey: false;
260
+ isAutoincrement: false;
261
+ hasRuntimeDefault: false;
262
+ enumValues: [string, ...string[]];
263
+ baseColumn: never;
264
+ identity: undefined;
265
+ generated: undefined;
266
+ }, {}, {}>;
267
+ organizationId: import("drizzle-orm/pg-core").PgColumn<{
268
+ name: "organization_id";
269
+ tableName: "join_link";
270
+ dataType: "string";
271
+ columnType: "PgText";
272
+ data: string;
273
+ driverParam: string;
274
+ notNull: true;
275
+ hasDefault: false;
276
+ isPrimaryKey: false;
277
+ isAutoincrement: false;
278
+ hasRuntimeDefault: false;
279
+ enumValues: [string, ...string[]];
280
+ baseColumn: never;
281
+ identity: undefined;
282
+ generated: undefined;
283
+ }, {}, {}>;
284
+ role: import("drizzle-orm/pg-core").PgColumn<{
285
+ name: "role";
286
+ tableName: "join_link";
287
+ dataType: "string";
288
+ columnType: "PgText";
289
+ data: "user" | "admin" | "super_admin";
290
+ driverParam: string;
291
+ notNull: true;
292
+ hasDefault: false;
293
+ isPrimaryKey: false;
294
+ isAutoincrement: false;
295
+ hasRuntimeDefault: false;
296
+ enumValues: ["user", "admin", "super_admin"];
297
+ baseColumn: never;
298
+ identity: undefined;
299
+ generated: undefined;
300
+ }, {}, {}>;
301
+ createdBy: import("drizzle-orm/pg-core").PgColumn<{
302
+ name: "created_by";
303
+ tableName: "join_link";
304
+ dataType: "string";
305
+ columnType: "PgText";
306
+ data: string;
307
+ driverParam: string;
308
+ notNull: true;
309
+ hasDefault: false;
310
+ isPrimaryKey: false;
311
+ isAutoincrement: false;
312
+ hasRuntimeDefault: false;
313
+ enumValues: [string, ...string[]];
314
+ baseColumn: never;
315
+ identity: undefined;
316
+ generated: undefined;
317
+ }, {}, {}>;
318
+ expiresAt: import("drizzle-orm/pg-core").PgColumn<{
319
+ name: "expires_at";
320
+ tableName: "join_link";
321
+ dataType: "date";
322
+ columnType: "PgTimestamp";
323
+ data: Date;
324
+ driverParam: string;
325
+ notNull: false;
326
+ hasDefault: false;
327
+ isPrimaryKey: false;
328
+ isAutoincrement: false;
329
+ hasRuntimeDefault: false;
330
+ enumValues: undefined;
331
+ baseColumn: never;
332
+ identity: undefined;
333
+ generated: undefined;
334
+ }, {}, {}>;
335
+ maxUses: import("drizzle-orm/pg-core").PgColumn<{
336
+ name: "max_uses";
337
+ tableName: "join_link";
338
+ dataType: "number";
339
+ columnType: "PgInteger";
340
+ data: number;
341
+ driverParam: string | number;
342
+ notNull: false;
343
+ hasDefault: false;
344
+ isPrimaryKey: false;
345
+ isAutoincrement: false;
346
+ hasRuntimeDefault: false;
347
+ enumValues: undefined;
348
+ baseColumn: never;
349
+ identity: undefined;
350
+ generated: undefined;
351
+ }, {}, {}>;
352
+ usesCount: import("drizzle-orm/pg-core").PgColumn<{
353
+ name: "uses_count";
354
+ tableName: "join_link";
355
+ dataType: "number";
356
+ columnType: "PgInteger";
357
+ data: number;
358
+ driverParam: string | number;
359
+ notNull: true;
360
+ hasDefault: true;
361
+ isPrimaryKey: false;
362
+ isAutoincrement: false;
363
+ hasRuntimeDefault: false;
364
+ enumValues: undefined;
365
+ baseColumn: never;
366
+ identity: undefined;
367
+ generated: undefined;
368
+ }, {}, {}>;
369
+ revoked: import("drizzle-orm/pg-core").PgColumn<{
370
+ name: "revoked";
371
+ tableName: "join_link";
372
+ dataType: "boolean";
373
+ columnType: "PgBoolean";
374
+ data: boolean;
375
+ driverParam: boolean;
376
+ notNull: true;
377
+ hasDefault: true;
378
+ isPrimaryKey: false;
379
+ isAutoincrement: false;
380
+ hasRuntimeDefault: false;
381
+ enumValues: undefined;
382
+ baseColumn: never;
383
+ identity: undefined;
384
+ generated: undefined;
385
+ }, {}, {}>;
386
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
387
+ name: "created_at";
388
+ tableName: "join_link";
389
+ dataType: "date";
390
+ columnType: "PgTimestamp";
391
+ data: Date;
392
+ driverParam: string;
393
+ notNull: true;
394
+ hasDefault: true;
395
+ isPrimaryKey: false;
396
+ isAutoincrement: false;
397
+ hasRuntimeDefault: false;
398
+ enumValues: undefined;
399
+ baseColumn: never;
400
+ identity: undefined;
401
+ generated: undefined;
402
+ }, {}, {}>;
403
+ };
404
+ dialect: "pg";
405
+ }>;
406
+ //# sourceMappingURL=join.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../../src/pg/schema/join.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBtB,CAAC;AAEH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYnB,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { pgTable, uuid, text, integer, boolean, timestamp } from 'drizzle-orm/pg-core';
2
+ // Partial unique index (one open request per user/org) is created in the
3
+ // hand-written migration (Task 5), since the WHERE-predicate form isn't
4
+ // expressed cleanly here. Keep this table definition free of an index callback.
5
+ export const joinRequest = pgTable('join_request', {
6
+ id: uuid('id').primaryKey().defaultRandom(),
7
+ // GoTrue auth.users.id (== profiles.id). The requester's Supabase identity.
8
+ supabaseId: uuid('supabase_id').notNull(),
9
+ // Bridged hub id (profiles.legacy_user_id ?? supabaseId) — the value used as the
10
+ // Turso `member.user_id` key when the request is approved. Distinct from supabase_id.
11
+ userId: text('user_id').notNull(),
12
+ email: text('email').notNull(),
13
+ displayName: text('display_name'),
14
+ message: text('message'),
15
+ status: text('status', { enum: ['pending', 'approved', 'denied'] }).notNull().default('pending'),
16
+ // Turso organization id (cross-DB reference; orgs live in Turso, so no PG FK).
17
+ organizationId: text('organization_id').notNull(),
18
+ requestedRole: text('requested_role', { enum: ['user', 'admin', 'super_admin'] }).notNull().default('user'),
19
+ reviewedBy: text('reviewed_by'),
20
+ reviewedAt: timestamp('reviewed_at', { withTimezone: true }),
21
+ createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
22
+ updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
23
+ });
24
+ export const joinLink = pgTable('join_link', {
25
+ id: uuid('id').primaryKey().defaultRandom(),
26
+ token: text('token').notNull().unique(),
27
+ // Turso organization id (cross-DB reference; orgs live in Turso, so no PG FK).
28
+ organizationId: text('organization_id').notNull(),
29
+ role: text('role', { enum: ['user', 'admin', 'super_admin'] }).notNull(),
30
+ createdBy: text('created_by').notNull(),
31
+ expiresAt: timestamp('expires_at', { withTimezone: true }),
32
+ maxUses: integer('max_uses'),
33
+ usesCount: integer('uses_count').notNull().default(0),
34
+ revoked: boolean('revoked').notNull().default(false),
35
+ createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
36
+ });
37
+ //# sourceMappingURL=join.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"join.js","sourceRoot":"","sources":["../../../src/pg/schema/join.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEvF,yEAAyE;AACzE,wEAAwE;AACxE,gFAAgF;AAChF,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE;IACjD,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC,aAAa,EAAE;IAC3C,4EAA4E;IAC5E,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE;IACzC,iFAAiF;IACjF,sFAAsF;IACtF,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE;IACjC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE;IAC9B,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC;IACjC,OAAO,EAAE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E;IACxE,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IACvC,SAAS,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAC1D,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACpD,SAAS,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;CAClF,CAAC,CAAC"}
@@ -94,6 +94,23 @@ export declare const profiles: import("drizzle-orm/pg-core").PgTableWithColumns<
94
94
  identity: undefined;
95
95
  generated: undefined;
96
96
  }, {}, {}>;
97
+ legacyUserId: import("drizzle-orm/pg-core").PgColumn<{
98
+ name: "legacy_user_id";
99
+ tableName: "profiles";
100
+ dataType: "string";
101
+ columnType: "PgText";
102
+ data: string;
103
+ driverParam: string;
104
+ notNull: false;
105
+ hasDefault: false;
106
+ isPrimaryKey: false;
107
+ isAutoincrement: false;
108
+ hasRuntimeDefault: false;
109
+ enumValues: [string, ...string[]];
110
+ baseColumn: never;
111
+ identity: undefined;
112
+ generated: undefined;
113
+ }, {}, {}>;
97
114
  createdAt: import("drizzle-orm/pg-core").PgColumn<{
98
115
  name: "created_at";
99
116
  tableName: "profiles";
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../../src/pg/schema/profiles.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUnB,CAAC"}
1
+ {"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../../src/pg/schema/profiles.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAanB,CAAC"}
@@ -14,6 +14,9 @@ export const profiles = pgTable('profiles', {
14
14
  .notNull()
15
15
  .default('user'),
16
16
  personalAgentId: text('personal_agent_id'),
17
+ // Better Auth `user.id` (text) this profile was migrated from. Null for
18
+ // users created natively in Supabase. Lets Phase 2 remap legacy FKs.
19
+ legacyUserId: text('legacy_user_id'),
17
20
  createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
18
21
  updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
19
22
  });
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../../src/pg/schema/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE;IAC1C,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,mBAAmB;IAChD,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE;IAC9B,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC;IACjC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;SAC5C,OAAO,EAAE;SACT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EAAE;CAClF,CAAC,CAAC"}
@@ -150,6 +150,42 @@ export declare const flows: import("drizzle-orm/sqlite-core").SQLiteTableWithCol
150
150
  identity: undefined;
151
151
  generated: undefined;
152
152
  }, {}, {}>;
153
+ active: import("drizzle-orm/sqlite-core").SQLiteColumn<{
154
+ name: "active";
155
+ tableName: "flows";
156
+ dataType: "boolean";
157
+ columnType: "SQLiteBoolean";
158
+ data: boolean;
159
+ driverParam: number;
160
+ notNull: true;
161
+ hasDefault: true;
162
+ isPrimaryKey: false;
163
+ isAutoincrement: false;
164
+ hasRuntimeDefault: false;
165
+ enumValues: undefined;
166
+ baseColumn: never;
167
+ identity: undefined;
168
+ generated: undefined;
169
+ }, {}, {}>;
170
+ config: import("drizzle-orm/sqlite-core").SQLiteColumn<{
171
+ name: "config";
172
+ tableName: "flows";
173
+ dataType: "string";
174
+ columnType: "SQLiteText";
175
+ data: string;
176
+ driverParam: string;
177
+ notNull: true;
178
+ hasDefault: true;
179
+ isPrimaryKey: false;
180
+ isAutoincrement: false;
181
+ hasRuntimeDefault: false;
182
+ enumValues: [string, ...string[]];
183
+ baseColumn: never;
184
+ identity: undefined;
185
+ generated: undefined;
186
+ }, {}, {
187
+ length: number | undefined;
188
+ }>;
153
189
  };
154
190
  dialect: "sqlite";
155
191
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../../src/schema/flows.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAShB,CAAC"}
1
+ {"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../../src/schema/flows.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWhB,CAAC"}
@@ -8,5 +8,7 @@ export const flows = sqliteTable('flows', {
8
8
  tenantId: text('tenant_id'), // tenant scope — null for pre-migration rows
9
9
  createdAt: integer('created_at').notNull(),
10
10
  updatedAt: integer('updated_at').notNull(),
11
+ active: integer('active', { mode: 'boolean' }).notNull().default(false),
12
+ config: text('config').notNull().default('{}'),
11
13
  });
12
14
  //# sourceMappingURL=flows.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flows.js","sourceRoot":"","sources":["../../src/schema/flows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAErE,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,EAAE;IACxC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE;IAC3B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE;IAC5B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,4BAA4B;IAC1E,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,4BAA4B;IAC1E,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,0DAA0D;IACnF,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE,6CAA6C;IAC1E,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IAC1C,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;CAC3C,CAAC,CAAC"}
1
+ {"version":3,"file":"flows.js","sourceRoot":"","sources":["../../src/schema/flows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAErE,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,EAAE;IACxC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE;IAC3B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE;IAC5B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,4BAA4B;IAC1E,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,4BAA4B;IAC1E,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,0DAA0D;IACnF,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE,6CAA6C;IAC1E,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IAC1C,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IAC1C,MAAM,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACvE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CAC/C,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minion-stack/db",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Drizzle ORM schema for the Minion shared database (LibSQL/Turso).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,6 +28,10 @@
28
28
  "types": "./dist/pg/schema/index.d.ts",
29
29
  "import": "./dist/pg/schema/index.js"
30
30
  },
31
+ "./crypto": {
32
+ "types": "./dist/crypto.d.ts",
33
+ "import": "./dist/crypto.js"
34
+ },
31
35
  "./relations": {
32
36
  "types": "./dist/relations.d.ts",
33
37
  "import": "./dist/relations.js"
@@ -0,0 +1,33 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import {
3
+ sealSecret,
4
+ openSecret,
5
+ encrypt,
6
+ decrypt,
7
+ encryptToken,
8
+ decryptToken,
9
+ } from "./crypto.js";
10
+
11
+ describe("canonical crypto", () => {
12
+ it("seal/open roundtrips", () => {
13
+ const { ciphertext, iv } = sealSecret("hunter2");
14
+ expect(ciphertext).not.toContain("hunter2");
15
+ expect(openSecret(ciphertext, iv)).toBe("hunter2");
16
+ });
17
+
18
+ it("encrypt/decrypt are aliases of seal/open", () => {
19
+ const { ciphertext, iv } = encrypt("s3cret");
20
+ expect(decrypt(ciphertext, iv)).toBe("s3cret");
21
+ });
22
+
23
+ it("encryptToken returns { encrypted, iv } and decryptToken roundtrips", () => {
24
+ const { encrypted, iv } = encryptToken("tok-abc");
25
+ expect(decryptToken(encrypted, iv)).toBe("tok-abc");
26
+ });
27
+
28
+ it("openSecret throws on a tampered ciphertext (GCM auth)", () => {
29
+ const { ciphertext, iv } = sealSecret("x");
30
+ const tampered = (ciphertext[0] === "a" ? "b" : "a") + ciphertext.slice(1);
31
+ expect(() => openSecret(tampered, iv)).toThrow();
32
+ });
33
+ });