@shipfox/api-workspaces 10.0.0 → 10.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.
Files changed (56) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +29 -0
  3. package/README.md +7 -1
  4. package/dist/core/admin-workspaces.d.ts +16 -0
  5. package/dist/core/admin-workspaces.d.ts.map +1 -1
  6. package/dist/core/admin-workspaces.js +52 -0
  7. package/dist/core/admin-workspaces.js.map +1 -1
  8. package/dist/core/errors.d.ts +12 -0
  9. package/dist/core/errors.d.ts.map +1 -1
  10. package/dist/core/errors.js +24 -0
  11. package/dist/core/errors.js.map +1 -1
  12. package/dist/core/index.d.ts +2 -2
  13. package/dist/core/index.d.ts.map +1 -1
  14. package/dist/core/index.js +2 -2
  15. package/dist/core/index.js.map +1 -1
  16. package/dist/db/admin-workspace-commands.d.ts +17 -0
  17. package/dist/db/admin-workspace-commands.d.ts.map +1 -0
  18. package/dist/db/admin-workspace-commands.js +86 -0
  19. package/dist/db/admin-workspace-commands.js.map +1 -0
  20. package/dist/db/db.d.ts +256 -0
  21. package/dist/db/db.d.ts.map +1 -1
  22. package/dist/db/db.js +2 -0
  23. package/dist/db/db.js.map +1 -1
  24. package/dist/db/index.d.ts +1 -0
  25. package/dist/db/index.d.ts.map +1 -1
  26. package/dist/db/index.js +1 -0
  27. package/dist/db/index.js.map +1 -1
  28. package/dist/db/schema/admin-command-results.d.ts +135 -0
  29. package/dist/db/schema/admin-command-results.d.ts.map +1 -0
  30. package/dist/db/schema/admin-command-results.js +18 -0
  31. package/dist/db/schema/admin-command-results.js.map +1 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +7 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/presentation/routes/admin-workspaces.d.ts.map +1 -1
  36. package/dist/presentation/routes/admin-workspaces.js +119 -14
  37. package/dist/presentation/routes/admin-workspaces.js.map +1 -1
  38. package/dist/tsconfig.test.tsbuildinfo +1 -1
  39. package/drizzle/0002_wide_enchantress.sql +11 -0
  40. package/drizzle/meta/0002_snapshot.json +555 -0
  41. package/drizzle/meta/_journal.json +7 -0
  42. package/package.json +6 -6
  43. package/src/core/admin-workspaces.ts +102 -0
  44. package/src/core/errors.ts +28 -0
  45. package/src/core/index.ts +8 -0
  46. package/src/db/admin-workspace-commands.ts +169 -0
  47. package/src/db/db.ts +2 -0
  48. package/src/db/index.ts +1 -0
  49. package/src/db/schema/admin-command-results.ts +30 -0
  50. package/src/index.test.ts +3 -1
  51. package/src/index.ts +17 -2
  52. package/src/presentation/routes/admin-workspaces.test.ts +273 -3
  53. package/src/presentation/routes/admin-workspaces.ts +143 -13
  54. package/test/globalSetup.ts +3 -1
  55. package/tsconfig.build.tsbuildinfo +1 -1
  56. package/vitest.config.ts +3 -0
@@ -0,0 +1,11 @@
1
+ CREATE TABLE "workspaces_admin_command_results" (
2
+ "id" uuid PRIMARY KEY DEFAULT uuidv7() NOT NULL,
3
+ "actor_id" uuid NOT NULL,
4
+ "idempotency_key_fingerprint" text NOT NULL,
5
+ "command" text NOT NULL,
6
+ "request_fingerprint" text NOT NULL,
7
+ "result" jsonb NOT NULL,
8
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
9
+ );
10
+ --> statement-breakpoint
11
+ CREATE UNIQUE INDEX "workspaces_admin_command_results_actor_key_unique" ON "workspaces_admin_command_results" USING btree ("actor_id","idempotency_key_fingerprint");
@@ -0,0 +1,555 @@
1
+ {
2
+ "id": "496634ce-3e5f-4c06-a9ff-857afa65422c",
3
+ "prevId": "8af7d61b-bfa2-426e-81bc-6523c4c0a368",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.workspaces_admin_command_results": {
8
+ "name": "workspaces_admin_command_results",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "uuid",
14
+ "primaryKey": true,
15
+ "notNull": true,
16
+ "default": "uuidv7()"
17
+ },
18
+ "actor_id": {
19
+ "name": "actor_id",
20
+ "type": "uuid",
21
+ "primaryKey": false,
22
+ "notNull": true
23
+ },
24
+ "idempotency_key_fingerprint": {
25
+ "name": "idempotency_key_fingerprint",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": true
29
+ },
30
+ "command": {
31
+ "name": "command",
32
+ "type": "text",
33
+ "primaryKey": false,
34
+ "notNull": true
35
+ },
36
+ "request_fingerprint": {
37
+ "name": "request_fingerprint",
38
+ "type": "text",
39
+ "primaryKey": false,
40
+ "notNull": true
41
+ },
42
+ "result": {
43
+ "name": "result",
44
+ "type": "jsonb",
45
+ "primaryKey": false,
46
+ "notNull": true
47
+ },
48
+ "created_at": {
49
+ "name": "created_at",
50
+ "type": "timestamp with time zone",
51
+ "primaryKey": false,
52
+ "notNull": true,
53
+ "default": "now()"
54
+ }
55
+ },
56
+ "indexes": {
57
+ "workspaces_admin_command_results_actor_key_unique": {
58
+ "name": "workspaces_admin_command_results_actor_key_unique",
59
+ "columns": [
60
+ {
61
+ "expression": "actor_id",
62
+ "isExpression": false,
63
+ "asc": true,
64
+ "nulls": "last"
65
+ },
66
+ {
67
+ "expression": "idempotency_key_fingerprint",
68
+ "isExpression": false,
69
+ "asc": true,
70
+ "nulls": "last"
71
+ }
72
+ ],
73
+ "isUnique": true,
74
+ "concurrently": false,
75
+ "method": "btree",
76
+ "with": {}
77
+ }
78
+ },
79
+ "foreignKeys": {},
80
+ "compositePrimaryKeys": {},
81
+ "uniqueConstraints": {},
82
+ "policies": {},
83
+ "checkConstraints": {},
84
+ "isRLSEnabled": false
85
+ },
86
+ "public.workspaces_invitations": {
87
+ "name": "workspaces_invitations",
88
+ "schema": "",
89
+ "columns": {
90
+ "id": {
91
+ "name": "id",
92
+ "type": "uuid",
93
+ "primaryKey": true,
94
+ "notNull": true,
95
+ "default": "uuidv7()"
96
+ },
97
+ "workspace_id": {
98
+ "name": "workspace_id",
99
+ "type": "uuid",
100
+ "primaryKey": false,
101
+ "notNull": true
102
+ },
103
+ "email": {
104
+ "name": "email",
105
+ "type": "text",
106
+ "primaryKey": false,
107
+ "notNull": true
108
+ },
109
+ "hashed_token": {
110
+ "name": "hashed_token",
111
+ "type": "text",
112
+ "primaryKey": false,
113
+ "notNull": true
114
+ },
115
+ "expires_at": {
116
+ "name": "expires_at",
117
+ "type": "timestamp with time zone",
118
+ "primaryKey": false,
119
+ "notNull": true
120
+ },
121
+ "revoked_at": {
122
+ "name": "revoked_at",
123
+ "type": "timestamp with time zone",
124
+ "primaryKey": false,
125
+ "notNull": false
126
+ },
127
+ "accepted_at": {
128
+ "name": "accepted_at",
129
+ "type": "timestamp with time zone",
130
+ "primaryKey": false,
131
+ "notNull": false
132
+ },
133
+ "accepted_by_user_id": {
134
+ "name": "accepted_by_user_id",
135
+ "type": "uuid",
136
+ "primaryKey": false,
137
+ "notNull": false
138
+ },
139
+ "invited_by_user_id": {
140
+ "name": "invited_by_user_id",
141
+ "type": "uuid",
142
+ "primaryKey": false,
143
+ "notNull": true
144
+ },
145
+ "invited_by_display": {
146
+ "name": "invited_by_display",
147
+ "type": "text",
148
+ "primaryKey": false,
149
+ "notNull": false
150
+ },
151
+ "created_at": {
152
+ "name": "created_at",
153
+ "type": "timestamp with time zone",
154
+ "primaryKey": false,
155
+ "notNull": true,
156
+ "default": "now()"
157
+ },
158
+ "updated_at": {
159
+ "name": "updated_at",
160
+ "type": "timestamp with time zone",
161
+ "primaryKey": false,
162
+ "notNull": true,
163
+ "default": "now()"
164
+ }
165
+ },
166
+ "indexes": {
167
+ "workspaces_invitations_hashed_token_unique": {
168
+ "name": "workspaces_invitations_hashed_token_unique",
169
+ "columns": [
170
+ {
171
+ "expression": "hashed_token",
172
+ "isExpression": false,
173
+ "asc": true,
174
+ "nulls": "last"
175
+ }
176
+ ],
177
+ "isUnique": true,
178
+ "concurrently": false,
179
+ "method": "btree",
180
+ "with": {}
181
+ },
182
+ "workspaces_invitations_workspace_email_idx": {
183
+ "name": "workspaces_invitations_workspace_email_idx",
184
+ "columns": [
185
+ {
186
+ "expression": "workspace_id",
187
+ "isExpression": false,
188
+ "asc": true,
189
+ "nulls": "last"
190
+ },
191
+ {
192
+ "expression": "email",
193
+ "isExpression": false,
194
+ "asc": true,
195
+ "nulls": "last"
196
+ }
197
+ ],
198
+ "isUnique": false,
199
+ "concurrently": false,
200
+ "method": "btree",
201
+ "with": {}
202
+ }
203
+ },
204
+ "foreignKeys": {
205
+ "workspaces_invitations_workspace_id_workspaces_workspaces_id_fk": {
206
+ "name": "workspaces_invitations_workspace_id_workspaces_workspaces_id_fk",
207
+ "tableFrom": "workspaces_invitations",
208
+ "tableTo": "workspaces_workspaces",
209
+ "columnsFrom": ["workspace_id"],
210
+ "columnsTo": ["id"],
211
+ "onDelete": "cascade",
212
+ "onUpdate": "no action"
213
+ }
214
+ },
215
+ "compositePrimaryKeys": {},
216
+ "uniqueConstraints": {},
217
+ "policies": {},
218
+ "checkConstraints": {},
219
+ "isRLSEnabled": false
220
+ },
221
+ "public.workspaces_memberships": {
222
+ "name": "workspaces_memberships",
223
+ "schema": "",
224
+ "columns": {
225
+ "id": {
226
+ "name": "id",
227
+ "type": "uuid",
228
+ "primaryKey": true,
229
+ "notNull": true,
230
+ "default": "uuidv7()"
231
+ },
232
+ "user_id": {
233
+ "name": "user_id",
234
+ "type": "uuid",
235
+ "primaryKey": false,
236
+ "notNull": true
237
+ },
238
+ "user_email": {
239
+ "name": "user_email",
240
+ "type": "text",
241
+ "primaryKey": false,
242
+ "notNull": true
243
+ },
244
+ "user_name": {
245
+ "name": "user_name",
246
+ "type": "text",
247
+ "primaryKey": false,
248
+ "notNull": false
249
+ },
250
+ "workspace_id": {
251
+ "name": "workspace_id",
252
+ "type": "uuid",
253
+ "primaryKey": false,
254
+ "notNull": true
255
+ },
256
+ "created_at": {
257
+ "name": "created_at",
258
+ "type": "timestamp with time zone",
259
+ "primaryKey": false,
260
+ "notNull": true,
261
+ "default": "now()"
262
+ },
263
+ "updated_at": {
264
+ "name": "updated_at",
265
+ "type": "timestamp with time zone",
266
+ "primaryKey": false,
267
+ "notNull": true,
268
+ "default": "now()"
269
+ }
270
+ },
271
+ "indexes": {
272
+ "workspaces_memberships_user_workspace_unique": {
273
+ "name": "workspaces_memberships_user_workspace_unique",
274
+ "columns": [
275
+ {
276
+ "expression": "user_id",
277
+ "isExpression": false,
278
+ "asc": true,
279
+ "nulls": "last"
280
+ },
281
+ {
282
+ "expression": "workspace_id",
283
+ "isExpression": false,
284
+ "asc": true,
285
+ "nulls": "last"
286
+ }
287
+ ],
288
+ "isUnique": true,
289
+ "concurrently": false,
290
+ "method": "btree",
291
+ "with": {}
292
+ },
293
+ "workspaces_memberships_workspace_id_idx": {
294
+ "name": "workspaces_memberships_workspace_id_idx",
295
+ "columns": [
296
+ {
297
+ "expression": "workspace_id",
298
+ "isExpression": false,
299
+ "asc": true,
300
+ "nulls": "last"
301
+ }
302
+ ],
303
+ "isUnique": false,
304
+ "concurrently": false,
305
+ "method": "btree",
306
+ "with": {}
307
+ }
308
+ },
309
+ "foreignKeys": {
310
+ "workspaces_memberships_workspace_id_workspaces_workspaces_id_fk": {
311
+ "name": "workspaces_memberships_workspace_id_workspaces_workspaces_id_fk",
312
+ "tableFrom": "workspaces_memberships",
313
+ "tableTo": "workspaces_workspaces",
314
+ "columnsFrom": ["workspace_id"],
315
+ "columnsTo": ["id"],
316
+ "onDelete": "cascade",
317
+ "onUpdate": "no action"
318
+ }
319
+ },
320
+ "compositePrimaryKeys": {},
321
+ "uniqueConstraints": {},
322
+ "policies": {},
323
+ "checkConstraints": {},
324
+ "isRLSEnabled": false
325
+ },
326
+ "public.workspaces_outbox": {
327
+ "name": "workspaces_outbox",
328
+ "schema": "",
329
+ "columns": {
330
+ "id": {
331
+ "name": "id",
332
+ "type": "uuid",
333
+ "primaryKey": true,
334
+ "notNull": true,
335
+ "default": "uuidv7()"
336
+ },
337
+ "event_type": {
338
+ "name": "event_type",
339
+ "type": "text",
340
+ "primaryKey": false,
341
+ "notNull": true
342
+ },
343
+ "ordering_key": {
344
+ "name": "ordering_key",
345
+ "type": "text",
346
+ "primaryKey": false,
347
+ "notNull": false
348
+ },
349
+ "payload": {
350
+ "name": "payload",
351
+ "type": "jsonb",
352
+ "primaryKey": false,
353
+ "notNull": true
354
+ },
355
+ "created_at": {
356
+ "name": "created_at",
357
+ "type": "timestamp with time zone",
358
+ "primaryKey": false,
359
+ "notNull": true,
360
+ "default": "now()"
361
+ },
362
+ "dispatched_at": {
363
+ "name": "dispatched_at",
364
+ "type": "timestamp with time zone",
365
+ "primaryKey": false,
366
+ "notNull": false
367
+ },
368
+ "dispatch_attempts": {
369
+ "name": "dispatch_attempts",
370
+ "type": "integer",
371
+ "primaryKey": false,
372
+ "notNull": true,
373
+ "default": 0
374
+ },
375
+ "next_dispatch_at": {
376
+ "name": "next_dispatch_at",
377
+ "type": "timestamp with time zone",
378
+ "primaryKey": false,
379
+ "notNull": true,
380
+ "default": "now()"
381
+ },
382
+ "last_dispatch_error": {
383
+ "name": "last_dispatch_error",
384
+ "type": "jsonb",
385
+ "primaryKey": false,
386
+ "notNull": false
387
+ },
388
+ "last_dispatch_failed_at": {
389
+ "name": "last_dispatch_failed_at",
390
+ "type": "timestamp with time zone",
391
+ "primaryKey": false,
392
+ "notNull": false
393
+ },
394
+ "dead_lettered_at": {
395
+ "name": "dead_lettered_at",
396
+ "type": "timestamp with time zone",
397
+ "primaryKey": false,
398
+ "notNull": false
399
+ }
400
+ },
401
+ "indexes": {
402
+ "workspaces_outbox_pending_idx": {
403
+ "name": "workspaces_outbox_pending_idx",
404
+ "columns": [
405
+ {
406
+ "expression": "next_dispatch_at",
407
+ "isExpression": false,
408
+ "asc": true,
409
+ "nulls": "last"
410
+ },
411
+ {
412
+ "expression": "created_at",
413
+ "isExpression": false,
414
+ "asc": true,
415
+ "nulls": "last"
416
+ }
417
+ ],
418
+ "isUnique": false,
419
+ "where": "\"dispatched_at\" IS NULL AND \"dead_lettered_at\" IS NULL",
420
+ "concurrently": false,
421
+ "method": "btree",
422
+ "with": {}
423
+ },
424
+ "workspaces_outbox_dispatched_retention_idx": {
425
+ "name": "workspaces_outbox_dispatched_retention_idx",
426
+ "columns": [
427
+ {
428
+ "expression": "dispatched_at",
429
+ "isExpression": false,
430
+ "asc": true,
431
+ "nulls": "last"
432
+ },
433
+ {
434
+ "expression": "id",
435
+ "isExpression": false,
436
+ "asc": true,
437
+ "nulls": "last"
438
+ }
439
+ ],
440
+ "isUnique": false,
441
+ "where": "\"dispatched_at\" IS NOT NULL",
442
+ "concurrently": false,
443
+ "method": "btree",
444
+ "with": {}
445
+ }
446
+ },
447
+ "foreignKeys": {},
448
+ "compositePrimaryKeys": {},
449
+ "uniqueConstraints": {},
450
+ "policies": {},
451
+ "checkConstraints": {},
452
+ "isRLSEnabled": false
453
+ },
454
+ "public.workspaces_workspaces": {
455
+ "name": "workspaces_workspaces",
456
+ "schema": "",
457
+ "columns": {
458
+ "id": {
459
+ "name": "id",
460
+ "type": "uuid",
461
+ "primaryKey": true,
462
+ "notNull": true,
463
+ "default": "uuidv7()"
464
+ },
465
+ "name": {
466
+ "name": "name",
467
+ "type": "text",
468
+ "primaryKey": false,
469
+ "notNull": true
470
+ },
471
+ "status": {
472
+ "name": "status",
473
+ "type": "workspaces_workspace_status",
474
+ "typeSchema": "public",
475
+ "primaryKey": false,
476
+ "notNull": true,
477
+ "default": "'active'"
478
+ },
479
+ "settings": {
480
+ "name": "settings",
481
+ "type": "jsonb",
482
+ "primaryKey": false,
483
+ "notNull": true,
484
+ "default": "'{}'::jsonb"
485
+ },
486
+ "created_by": {
487
+ "name": "created_by",
488
+ "type": "uuid",
489
+ "primaryKey": false,
490
+ "notNull": false
491
+ },
492
+ "created_at": {
493
+ "name": "created_at",
494
+ "type": "timestamp with time zone",
495
+ "primaryKey": false,
496
+ "notNull": true,
497
+ "default": "now()"
498
+ },
499
+ "updated_at": {
500
+ "name": "updated_at",
501
+ "type": "timestamp with time zone",
502
+ "primaryKey": false,
503
+ "notNull": true,
504
+ "default": "now()"
505
+ }
506
+ },
507
+ "indexes": {
508
+ "workspaces_name_id_idx": {
509
+ "name": "workspaces_name_id_idx",
510
+ "columns": [
511
+ {
512
+ "expression": "name",
513
+ "isExpression": false,
514
+ "asc": true,
515
+ "nulls": "last"
516
+ },
517
+ {
518
+ "expression": "id",
519
+ "isExpression": false,
520
+ "asc": true,
521
+ "nulls": "last"
522
+ }
523
+ ],
524
+ "isUnique": false,
525
+ "concurrently": false,
526
+ "method": "btree",
527
+ "with": {}
528
+ }
529
+ },
530
+ "foreignKeys": {},
531
+ "compositePrimaryKeys": {},
532
+ "uniqueConstraints": {},
533
+ "policies": {},
534
+ "checkConstraints": {},
535
+ "isRLSEnabled": false
536
+ }
537
+ },
538
+ "enums": {
539
+ "public.workspaces_workspace_status": {
540
+ "name": "workspaces_workspace_status",
541
+ "schema": "public",
542
+ "values": ["active", "suspended", "deleted"]
543
+ }
544
+ },
545
+ "schemas": {},
546
+ "sequences": {},
547
+ "roles": {},
548
+ "policies": {},
549
+ "views": {},
550
+ "_meta": {
551
+ "columns": {},
552
+ "schemas": {},
553
+ "tables": {}
554
+ }
555
+ }
@@ -15,6 +15,13 @@
15
15
  "when": 1785217735221,
16
16
  "tag": "0001_complex_beast",
17
17
  "breakpoints": true
18
+ },
19
+ {
20
+ "idx": 2,
21
+ "version": "7",
22
+ "when": 1785225824871,
23
+ "tag": "0002_wide_enchantress",
24
+ "breakpoints": true
18
25
  }
19
26
  ]
20
27
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shipfox/api-workspaces",
3
3
  "license": "MIT",
4
- "version": "10.0.0",
4
+ "version": "10.2.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ShipfoxHQ/shipfox.git",
@@ -25,11 +25,11 @@
25
25
  "drizzle-orm": "^0.45.2",
26
26
  "zod": "^4.4.3",
27
27
  "@shipfox/api-common-dto": "9.2.0",
28
- "@shipfox/api-auth-context": "10.0.0",
29
- "@shipfox/api-auth-dto": "10.0.0",
30
- "@shipfox/api-projects-dto": "10.0.0",
31
- "@shipfox/api-runners-dto": "10.0.0",
32
- "@shipfox/api-workspaces-dto": "10.0.0",
28
+ "@shipfox/api-auth-dto": "10.2.0",
29
+ "@shipfox/api-auth-context": "10.2.0",
30
+ "@shipfox/api-projects-dto": "10.1.0",
31
+ "@shipfox/api-runners-dto": "10.2.0",
32
+ "@shipfox/api-workspaces-dto": "10.2.0",
33
33
  "@shipfox/config": "1.2.4",
34
34
  "@shipfox/inter-module": "0.2.2",
35
35
  "@shipfox/node-drizzle": "0.3.4",