@shipfox/api-workspaces 2.0.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/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-type$colon$emit.log +1 -0
- package/.turbo/turbo-type.log +1 -0
- package/CHANGELOG.md +97 -0
- package/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +58 -0
- package/dist/config.js.map +1 -0
- package/dist/core/entities/index.d.ts +4 -0
- package/dist/core/entities/index.d.ts.map +1 -0
- package/dist/core/entities/index.js +3 -0
- package/dist/core/entities/index.js.map +1 -0
- package/dist/core/entities/invitation.d.ts +14 -0
- package/dist/core/entities/invitation.d.ts.map +1 -0
- package/dist/core/entities/invitation.js +3 -0
- package/dist/core/entities/invitation.js.map +1 -0
- package/dist/core/entities/membership.d.ts +10 -0
- package/dist/core/entities/membership.d.ts.map +1 -0
- package/dist/core/entities/membership.js +3 -0
- package/dist/core/entities/membership.js.map +1 -0
- package/dist/core/entities/workspace.d.ts +10 -0
- package/dist/core/entities/workspace.d.ts.map +1 -0
- package/dist/core/entities/workspace.js +3 -0
- package/dist/core/entities/workspace.js.map +1 -0
- package/dist/core/errors.d.ts +52 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +104 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/invitations.d.ts +51 -0
- package/dist/core/invitations.d.ts.map +1 -0
- package/dist/core/invitations.js +136 -0
- package/dist/core/invitations.js.map +1 -0
- package/dist/core/memberships.d.ts +9 -0
- package/dist/core/memberships.d.ts.map +1 -0
- package/dist/core/memberships.js +13 -0
- package/dist/core/memberships.js.map +1 -0
- package/dist/core/workspaces.d.ts +40 -0
- package/dist/core/workspaces.d.ts.map +1 -0
- package/dist/core/workspaces.js +85 -0
- package/dist/core/workspaces.js.map +1 -0
- package/dist/db/db.d.ts +1253 -0
- package/dist/db/db.d.ts.map +1 -0
- package/dist/db/db.js +24 -0
- package/dist/db/db.js.map +1 -0
- package/dist/db/index.d.ts +10 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +10 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/invitations.d.ts +47 -0
- package/dist/db/invitations.d.ts.map +1 -0
- package/dist/db/invitations.js +107 -0
- package/dist/db/invitations.js.map +1 -0
- package/dist/db/memberships.d.ts +44 -0
- package/dist/db/memberships.d.ts.map +1 -0
- package/dist/db/memberships.js +75 -0
- package/dist/db/memberships.js.map +1 -0
- package/dist/db/schema/common.d.ts +2 -0
- package/dist/db/schema/common.d.ts.map +1 -0
- package/dist/db/schema/common.js +4 -0
- package/dist/db/schema/common.js.map +1 -0
- package/dist/db/schema/invitations.d.ts +199 -0
- package/dist/db/schema/invitations.d.ts.map +1 -0
- package/dist/db/schema/invitations.js +47 -0
- package/dist/db/schema/invitations.js.map +1 -0
- package/dist/db/schema/memberships.d.ts +131 -0
- package/dist/db/schema/memberships.d.ts.map +1 -0
- package/dist/db/schema/memberships.js +35 -0
- package/dist/db/schema/memberships.js.map +1 -0
- package/dist/db/schema/outbox.d.ts +195 -0
- package/dist/db/schema/outbox.d.ts.map +1 -0
- package/dist/db/schema/outbox.js +5 -0
- package/dist/db/schema/outbox.js.map +1 -0
- package/dist/db/schema/workspaces.d.ts +115 -0
- package/dist/db/schema/workspaces.d.ts.map +1 -0
- package/dist/db/schema/workspaces.js +32 -0
- package/dist/db/schema/workspaces.js.map +1 -0
- package/dist/db/workspaces.d.ts +20 -0
- package/dist/db/workspaces.d.ts.map +1 -0
- package/dist/db/workspaces.js +53 -0
- package/dist/db/workspaces.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +3 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/instance.d.ts +8 -0
- package/dist/metrics/instance.d.ts.map +1 -0
- package/dist/metrics/instance.js +41 -0
- package/dist/metrics/instance.js.map +1 -0
- package/dist/metrics/service.d.ts +2 -0
- package/dist/metrics/service.d.ts.map +1 -0
- package/dist/metrics/service.js +26 -0
- package/dist/metrics/service.js.map +1 -0
- package/dist/presentation/dto/index.d.ts +4 -0
- package/dist/presentation/dto/index.d.ts.map +1 -0
- package/dist/presentation/dto/index.js +5 -0
- package/dist/presentation/dto/index.js.map +1 -0
- package/dist/presentation/dto/invitation.d.ts +4 -0
- package/dist/presentation/dto/invitation.d.ts.map +1 -0
- package/dist/presentation/dto/invitation.js +15 -0
- package/dist/presentation/dto/invitation.js.map +1 -0
- package/dist/presentation/dto/membership.d.ts +5 -0
- package/dist/presentation/dto/membership.d.ts.map +1 -0
- package/dist/presentation/dto/membership.js +23 -0
- package/dist/presentation/dto/membership.js.map +1 -0
- package/dist/presentation/dto/workspace.d.ts +4 -0
- package/dist/presentation/dto/workspace.d.ts.map +1 -0
- package/dist/presentation/dto/workspace.js +12 -0
- package/dist/presentation/dto/workspace.js.map +1 -0
- package/dist/presentation/e2eRoutes/create-invitation.d.ts +2 -0
- package/dist/presentation/e2eRoutes/create-invitation.d.ts.map +1 -0
- package/dist/presentation/e2eRoutes/create-invitation.js +39 -0
- package/dist/presentation/e2eRoutes/create-invitation.js.map +1 -0
- package/dist/presentation/e2eRoutes/create-workspace.d.ts +2 -0
- package/dist/presentation/e2eRoutes/create-workspace.d.ts.map +1 -0
- package/dist/presentation/e2eRoutes/create-workspace.js +27 -0
- package/dist/presentation/e2eRoutes/create-workspace.js.map +1 -0
- package/dist/presentation/e2eRoutes/index.d.ts +3 -0
- package/dist/presentation/e2eRoutes/index.d.ts.map +1 -0
- package/dist/presentation/e2eRoutes/index.js +11 -0
- package/dist/presentation/e2eRoutes/index.js.map +1 -0
- package/dist/presentation/index.d.ts +2 -0
- package/dist/presentation/index.d.ts.map +1 -0
- package/dist/presentation/index.js +3 -0
- package/dist/presentation/index.js.map +1 -0
- package/dist/presentation/routes/index.d.ts +3 -0
- package/dist/presentation/routes/index.d.ts.map +1 -0
- package/dist/presentation/routes/index.js +23 -0
- package/dist/presentation/routes/index.js.map +1 -0
- package/dist/presentation/routes/invitations/accept.d.ts +2 -0
- package/dist/presentation/routes/invitations/accept.d.ts.map +1 -0
- package/dist/presentation/routes/invitations/accept.js +67 -0
- package/dist/presentation/routes/invitations/accept.js.map +1 -0
- package/dist/presentation/routes/invitations/create.d.ts +2 -0
- package/dist/presentation/routes/invitations/create.d.ts.map +1 -0
- package/dist/presentation/routes/invitations/create.js +66 -0
- package/dist/presentation/routes/invitations/create.js.map +1 -0
- package/dist/presentation/routes/invitations/index.d.ts +4 -0
- package/dist/presentation/routes/invitations/index.d.ts.map +1 -0
- package/dist/presentation/routes/invitations/index.js +19 -0
- package/dist/presentation/routes/invitations/index.js.map +1 -0
- package/dist/presentation/routes/invitations/list.d.ts +2 -0
- package/dist/presentation/routes/invitations/list.d.ts.map +1 -0
- package/dist/presentation/routes/invitations/list.js +58 -0
- package/dist/presentation/routes/invitations/list.js.map +1 -0
- package/dist/presentation/routes/invitations/preview.d.ts +2 -0
- package/dist/presentation/routes/invitations/preview.d.ts.map +1 -0
- package/dist/presentation/routes/invitations/preview.js +47 -0
- package/dist/presentation/routes/invitations/preview.js.map +1 -0
- package/dist/presentation/routes/invitations/revoke.d.ts +2 -0
- package/dist/presentation/routes/invitations/revoke.d.ts.map +1 -0
- package/dist/presentation/routes/invitations/revoke.js +66 -0
- package/dist/presentation/routes/invitations/revoke.js.map +1 -0
- package/dist/presentation/routes/members/index.d.ts +3 -0
- package/dist/presentation/routes/members/index.d.ts.map +1 -0
- package/dist/presentation/routes/members/index.js +8 -0
- package/dist/presentation/routes/members/index.js.map +1 -0
- package/dist/presentation/routes/members/list.d.ts +2 -0
- package/dist/presentation/routes/members/list.d.ts.map +1 -0
- package/dist/presentation/routes/members/list.js +58 -0
- package/dist/presentation/routes/members/list.js.map +1 -0
- package/dist/presentation/routes/members/remove.d.ts +2 -0
- package/dist/presentation/routes/members/remove.d.ts.map +1 -0
- package/dist/presentation/routes/members/remove.js +71 -0
- package/dist/presentation/routes/members/remove.js.map +1 -0
- package/dist/presentation/routes/workspaces/create.d.ts +2 -0
- package/dist/presentation/routes/workspaces/create.d.ts.map +1 -0
- package/dist/presentation/routes/workspaces/create.js +36 -0
- package/dist/presentation/routes/workspaces/create.js.map +1 -0
- package/dist/presentation/routes/workspaces/index.d.ts +3 -0
- package/dist/presentation/routes/workspaces/index.d.ts.map +1 -0
- package/dist/presentation/routes/workspaces/index.js +4 -0
- package/dist/presentation/routes/workspaces/index.js.map +1 -0
- package/dist/presentation/routes/workspaces/list.d.ts +2 -0
- package/dist/presentation/routes/workspaces/list.d.ts.map +1 -0
- package/dist/presentation/routes/workspaces/list.js +32 -0
- package/dist/presentation/routes/workspaces/list.js.map +1 -0
- package/dist/presentation/subscribers/index.d.ts +2 -0
- package/dist/presentation/subscribers/index.d.ts.map +1 -0
- package/dist/presentation/subscribers/index.js +3 -0
- package/dist/presentation/subscribers/index.js.map +1 -0
- package/dist/presentation/subscribers/on-invitation-send-requested.d.ts +3 -0
- package/dist/presentation/subscribers/on-invitation-send-requested.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-invitation-send-requested.js +16 -0
- package/dist/presentation/subscribers/on-invitation-send-requested.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -0
- package/drizzle/0000_initial.sql +9 -0
- package/drizzle/0001_memberships_invitations.sql +30 -0
- package/drizzle/0002_membership_user_snapshots.sql +40 -0
- package/drizzle/0003_outgoing_enchantress.sql +16 -0
- package/drizzle/meta/0000_snapshot.json +80 -0
- package/drizzle/meta/0001_snapshot.json +705 -0
- package/drizzle/meta/0003_snapshot.json +442 -0
- package/drizzle/meta/_journal.json +34 -0
- package/drizzle.config.ts +7 -0
- package/package.json +71 -0
- package/src/config.ts +51 -0
- package/src/core/entities/index.ts +3 -0
- package/src/core/entities/invitation.ts +13 -0
- package/src/core/entities/membership.ts +9 -0
- package/src/core/entities/workspace.ts +10 -0
- package/src/core/errors.ts +118 -0
- package/src/core/index.ts +35 -0
- package/src/core/invitations.test.ts +251 -0
- package/src/core/invitations.ts +191 -0
- package/src/core/memberships.test.ts +77 -0
- package/src/core/memberships.ts +17 -0
- package/src/core/workspaces.test.ts +72 -0
- package/src/core/workspaces.ts +126 -0
- package/src/db/db.ts +24 -0
- package/src/db/index.ts +43 -0
- package/src/db/invitations.test.ts +204 -0
- package/src/db/invitations.ts +235 -0
- package/src/db/memberships.test.ts +107 -0
- package/src/db/memberships.ts +139 -0
- package/src/db/schema/common.ts +5 -0
- package/src/db/schema/invitations.ts +47 -0
- package/src/db/schema/memberships.ts +39 -0
- package/src/db/schema/outbox.ts +4 -0
- package/src/db/schema/workspaces.ts +33 -0
- package/src/db/workspaces.test.ts +114 -0
- package/src/db/workspaces.ts +81 -0
- package/src/index.test.ts +25 -0
- package/src/index.ts +43 -0
- package/src/metrics/index.ts +1 -0
- package/src/metrics/instance.test.ts +74 -0
- package/src/metrics/instance.ts +57 -0
- package/src/metrics/service.ts +26 -0
- package/src/presentation/dto/index.ts +3 -0
- package/src/presentation/dto/invitation.ts +16 -0
- package/src/presentation/dto/membership.ts +27 -0
- package/src/presentation/dto/workspace.ts +13 -0
- package/src/presentation/e2eRoutes/create-invitation.ts +44 -0
- package/src/presentation/e2eRoutes/create-workspace.ts +30 -0
- package/src/presentation/e2eRoutes/index.ts +8 -0
- package/src/presentation/index.ts +1 -0
- package/src/presentation/routes/index.ts +23 -0
- package/src/presentation/routes/invitations/accept.test.ts +154 -0
- package/src/presentation/routes/invitations/accept.ts +70 -0
- package/src/presentation/routes/invitations/create.test.ts +99 -0
- package/src/presentation/routes/invitations/create.ts +60 -0
- package/src/presentation/routes/invitations/index.ts +17 -0
- package/src/presentation/routes/invitations/list.test.ts +94 -0
- package/src/presentation/routes/invitations/list.ts +53 -0
- package/src/presentation/routes/invitations/preview.test.ts +140 -0
- package/src/presentation/routes/invitations/preview.ts +46 -0
- package/src/presentation/routes/invitations/revoke.test.ts +99 -0
- package/src/presentation/routes/invitations/revoke.ts +64 -0
- package/src/presentation/routes/members/index.ts +5 -0
- package/src/presentation/routes/members/list.test.ts +95 -0
- package/src/presentation/routes/members/list.ts +53 -0
- package/src/presentation/routes/members/remove.test.ts +110 -0
- package/src/presentation/routes/members/remove.ts +66 -0
- package/src/presentation/routes/workspaces/create.test.ts +87 -0
- package/src/presentation/routes/workspaces/create.ts +36 -0
- package/src/presentation/routes/workspaces/index.ts +2 -0
- package/src/presentation/routes/workspaces/list.test.ts +56 -0
- package/src/presentation/routes/workspaces/list.ts +29 -0
- package/src/presentation/subscribers/index.ts +1 -0
- package/src/presentation/subscribers/invitation-send-requested.test.ts +64 -0
- package/src/presentation/subscribers/on-invitation-send-requested.ts +15 -0
- package/test/env.ts +8 -0
- package/test/factories/index.ts +3 -0
- package/test/factories/membership.ts +24 -0
- package/test/factories/user.ts +15 -0
- package/test/factories/workspace.ts +18 -0
- package/test/globalSetup.ts +15 -0
- package/test/index.ts +3 -0
- package/test/routes.ts +255 -0
- package/test/setup.ts +17 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/tsconfig.test.json +8 -0
- package/vitest.config.ts +11 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "86af97dc-249d-4cc9-98bc-52681d4ca30f",
|
|
3
|
+
"prevId": "71580355-da9f-475d-ab24-8d5e8cb5bb47",
|
|
4
|
+
"version": "7",
|
|
5
|
+
"dialect": "postgresql",
|
|
6
|
+
"tables": {
|
|
7
|
+
"public.workspaces_invitations": {
|
|
8
|
+
"name": "workspaces_invitations",
|
|
9
|
+
"schema": "",
|
|
10
|
+
"columns": {
|
|
11
|
+
"id": {
|
|
12
|
+
"name": "id",
|
|
13
|
+
"type": "uuid",
|
|
14
|
+
"primaryKey": true,
|
|
15
|
+
"notNull": true,
|
|
16
|
+
"default": "uuidv7()"
|
|
17
|
+
},
|
|
18
|
+
"workspace_id": {
|
|
19
|
+
"name": "workspace_id",
|
|
20
|
+
"type": "uuid",
|
|
21
|
+
"primaryKey": false,
|
|
22
|
+
"notNull": true
|
|
23
|
+
},
|
|
24
|
+
"email": {
|
|
25
|
+
"name": "email",
|
|
26
|
+
"type": "text",
|
|
27
|
+
"primaryKey": false,
|
|
28
|
+
"notNull": true
|
|
29
|
+
},
|
|
30
|
+
"hashed_token": {
|
|
31
|
+
"name": "hashed_token",
|
|
32
|
+
"type": "text",
|
|
33
|
+
"primaryKey": false,
|
|
34
|
+
"notNull": true
|
|
35
|
+
},
|
|
36
|
+
"expires_at": {
|
|
37
|
+
"name": "expires_at",
|
|
38
|
+
"type": "timestamp with time zone",
|
|
39
|
+
"primaryKey": false,
|
|
40
|
+
"notNull": true
|
|
41
|
+
},
|
|
42
|
+
"accepted_at": {
|
|
43
|
+
"name": "accepted_at",
|
|
44
|
+
"type": "timestamp with time zone",
|
|
45
|
+
"primaryKey": false,
|
|
46
|
+
"notNull": false
|
|
47
|
+
},
|
|
48
|
+
"accepted_by_user_id": {
|
|
49
|
+
"name": "accepted_by_user_id",
|
|
50
|
+
"type": "uuid",
|
|
51
|
+
"primaryKey": false,
|
|
52
|
+
"notNull": false
|
|
53
|
+
},
|
|
54
|
+
"invited_by_user_id": {
|
|
55
|
+
"name": "invited_by_user_id",
|
|
56
|
+
"type": "uuid",
|
|
57
|
+
"primaryKey": false,
|
|
58
|
+
"notNull": true
|
|
59
|
+
},
|
|
60
|
+
"invited_by_display": {
|
|
61
|
+
"name": "invited_by_display",
|
|
62
|
+
"type": "text",
|
|
63
|
+
"primaryKey": false,
|
|
64
|
+
"notNull": false
|
|
65
|
+
},
|
|
66
|
+
"created_at": {
|
|
67
|
+
"name": "created_at",
|
|
68
|
+
"type": "timestamp with time zone",
|
|
69
|
+
"primaryKey": false,
|
|
70
|
+
"notNull": true,
|
|
71
|
+
"default": "now()"
|
|
72
|
+
},
|
|
73
|
+
"updated_at": {
|
|
74
|
+
"name": "updated_at",
|
|
75
|
+
"type": "timestamp with time zone",
|
|
76
|
+
"primaryKey": false,
|
|
77
|
+
"notNull": true,
|
|
78
|
+
"default": "now()"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"indexes": {
|
|
82
|
+
"workspaces_invitations_hashed_token_unique": {
|
|
83
|
+
"name": "workspaces_invitations_hashed_token_unique",
|
|
84
|
+
"columns": [
|
|
85
|
+
{
|
|
86
|
+
"expression": "hashed_token",
|
|
87
|
+
"isExpression": false,
|
|
88
|
+
"asc": true,
|
|
89
|
+
"nulls": "last"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"isUnique": true,
|
|
93
|
+
"concurrently": false,
|
|
94
|
+
"method": "btree",
|
|
95
|
+
"with": {}
|
|
96
|
+
},
|
|
97
|
+
"workspaces_invitations_workspace_email_idx": {
|
|
98
|
+
"name": "workspaces_invitations_workspace_email_idx",
|
|
99
|
+
"columns": [
|
|
100
|
+
{
|
|
101
|
+
"expression": "workspace_id",
|
|
102
|
+
"isExpression": false,
|
|
103
|
+
"asc": true,
|
|
104
|
+
"nulls": "last"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"expression": "email",
|
|
108
|
+
"isExpression": false,
|
|
109
|
+
"asc": true,
|
|
110
|
+
"nulls": "last"
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
"isUnique": false,
|
|
114
|
+
"concurrently": false,
|
|
115
|
+
"method": "btree",
|
|
116
|
+
"with": {}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"foreignKeys": {
|
|
120
|
+
"workspaces_invitations_workspace_id_workspaces_id_fk": {
|
|
121
|
+
"name": "workspaces_invitations_workspace_id_workspaces_id_fk",
|
|
122
|
+
"tableFrom": "workspaces_invitations",
|
|
123
|
+
"tableTo": "workspaces",
|
|
124
|
+
"columnsFrom": ["workspace_id"],
|
|
125
|
+
"columnsTo": ["id"],
|
|
126
|
+
"onDelete": "cascade",
|
|
127
|
+
"onUpdate": "no action"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"compositePrimaryKeys": {},
|
|
131
|
+
"uniqueConstraints": {},
|
|
132
|
+
"policies": {},
|
|
133
|
+
"checkConstraints": {},
|
|
134
|
+
"isRLSEnabled": false
|
|
135
|
+
},
|
|
136
|
+
"public.workspaces_memberships": {
|
|
137
|
+
"name": "workspaces_memberships",
|
|
138
|
+
"schema": "",
|
|
139
|
+
"columns": {
|
|
140
|
+
"id": {
|
|
141
|
+
"name": "id",
|
|
142
|
+
"type": "uuid",
|
|
143
|
+
"primaryKey": true,
|
|
144
|
+
"notNull": true,
|
|
145
|
+
"default": "uuidv7()"
|
|
146
|
+
},
|
|
147
|
+
"user_id": {
|
|
148
|
+
"name": "user_id",
|
|
149
|
+
"type": "uuid",
|
|
150
|
+
"primaryKey": false,
|
|
151
|
+
"notNull": true
|
|
152
|
+
},
|
|
153
|
+
"user_email": {
|
|
154
|
+
"name": "user_email",
|
|
155
|
+
"type": "text",
|
|
156
|
+
"primaryKey": false,
|
|
157
|
+
"notNull": true
|
|
158
|
+
},
|
|
159
|
+
"user_name": {
|
|
160
|
+
"name": "user_name",
|
|
161
|
+
"type": "text",
|
|
162
|
+
"primaryKey": false,
|
|
163
|
+
"notNull": false
|
|
164
|
+
},
|
|
165
|
+
"workspace_id": {
|
|
166
|
+
"name": "workspace_id",
|
|
167
|
+
"type": "uuid",
|
|
168
|
+
"primaryKey": false,
|
|
169
|
+
"notNull": true
|
|
170
|
+
},
|
|
171
|
+
"created_at": {
|
|
172
|
+
"name": "created_at",
|
|
173
|
+
"type": "timestamp with time zone",
|
|
174
|
+
"primaryKey": false,
|
|
175
|
+
"notNull": true,
|
|
176
|
+
"default": "now()"
|
|
177
|
+
},
|
|
178
|
+
"updated_at": {
|
|
179
|
+
"name": "updated_at",
|
|
180
|
+
"type": "timestamp with time zone",
|
|
181
|
+
"primaryKey": false,
|
|
182
|
+
"notNull": true,
|
|
183
|
+
"default": "now()"
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"indexes": {
|
|
187
|
+
"workspaces_memberships_user_workspace_unique": {
|
|
188
|
+
"name": "workspaces_memberships_user_workspace_unique",
|
|
189
|
+
"columns": [
|
|
190
|
+
{
|
|
191
|
+
"expression": "user_id",
|
|
192
|
+
"isExpression": false,
|
|
193
|
+
"asc": true,
|
|
194
|
+
"nulls": "last"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"expression": "workspace_id",
|
|
198
|
+
"isExpression": false,
|
|
199
|
+
"asc": true,
|
|
200
|
+
"nulls": "last"
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
"isUnique": true,
|
|
204
|
+
"concurrently": false,
|
|
205
|
+
"method": "btree",
|
|
206
|
+
"with": {}
|
|
207
|
+
},
|
|
208
|
+
"workspaces_memberships_workspace_id_idx": {
|
|
209
|
+
"name": "workspaces_memberships_workspace_id_idx",
|
|
210
|
+
"columns": [
|
|
211
|
+
{
|
|
212
|
+
"expression": "workspace_id",
|
|
213
|
+
"isExpression": false,
|
|
214
|
+
"asc": true,
|
|
215
|
+
"nulls": "last"
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
"isUnique": false,
|
|
219
|
+
"concurrently": false,
|
|
220
|
+
"method": "btree",
|
|
221
|
+
"with": {}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
"foreignKeys": {
|
|
225
|
+
"workspaces_memberships_workspace_id_workspaces_id_fk": {
|
|
226
|
+
"name": "workspaces_memberships_workspace_id_workspaces_id_fk",
|
|
227
|
+
"tableFrom": "workspaces_memberships",
|
|
228
|
+
"tableTo": "workspaces",
|
|
229
|
+
"columnsFrom": ["workspace_id"],
|
|
230
|
+
"columnsTo": ["id"],
|
|
231
|
+
"onDelete": "cascade",
|
|
232
|
+
"onUpdate": "no action"
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
"compositePrimaryKeys": {},
|
|
236
|
+
"uniqueConstraints": {},
|
|
237
|
+
"policies": {},
|
|
238
|
+
"checkConstraints": {},
|
|
239
|
+
"isRLSEnabled": false
|
|
240
|
+
},
|
|
241
|
+
"public.workspaces_outbox": {
|
|
242
|
+
"name": "workspaces_outbox",
|
|
243
|
+
"schema": "",
|
|
244
|
+
"columns": {
|
|
245
|
+
"id": {
|
|
246
|
+
"name": "id",
|
|
247
|
+
"type": "uuid",
|
|
248
|
+
"primaryKey": true,
|
|
249
|
+
"notNull": true,
|
|
250
|
+
"default": "uuidv7()"
|
|
251
|
+
},
|
|
252
|
+
"event_type": {
|
|
253
|
+
"name": "event_type",
|
|
254
|
+
"type": "text",
|
|
255
|
+
"primaryKey": false,
|
|
256
|
+
"notNull": true
|
|
257
|
+
},
|
|
258
|
+
"ordering_key": {
|
|
259
|
+
"name": "ordering_key",
|
|
260
|
+
"type": "text",
|
|
261
|
+
"primaryKey": false,
|
|
262
|
+
"notNull": false
|
|
263
|
+
},
|
|
264
|
+
"payload": {
|
|
265
|
+
"name": "payload",
|
|
266
|
+
"type": "jsonb",
|
|
267
|
+
"primaryKey": false,
|
|
268
|
+
"notNull": true
|
|
269
|
+
},
|
|
270
|
+
"created_at": {
|
|
271
|
+
"name": "created_at",
|
|
272
|
+
"type": "timestamp with time zone",
|
|
273
|
+
"primaryKey": false,
|
|
274
|
+
"notNull": true,
|
|
275
|
+
"default": "now()"
|
|
276
|
+
},
|
|
277
|
+
"dispatched_at": {
|
|
278
|
+
"name": "dispatched_at",
|
|
279
|
+
"type": "timestamp with time zone",
|
|
280
|
+
"primaryKey": false,
|
|
281
|
+
"notNull": false
|
|
282
|
+
},
|
|
283
|
+
"dispatch_attempts": {
|
|
284
|
+
"name": "dispatch_attempts",
|
|
285
|
+
"type": "integer",
|
|
286
|
+
"primaryKey": false,
|
|
287
|
+
"notNull": true,
|
|
288
|
+
"default": 0
|
|
289
|
+
},
|
|
290
|
+
"next_dispatch_at": {
|
|
291
|
+
"name": "next_dispatch_at",
|
|
292
|
+
"type": "timestamp with time zone",
|
|
293
|
+
"primaryKey": false,
|
|
294
|
+
"notNull": true,
|
|
295
|
+
"default": "now()"
|
|
296
|
+
},
|
|
297
|
+
"last_dispatch_error": {
|
|
298
|
+
"name": "last_dispatch_error",
|
|
299
|
+
"type": "jsonb",
|
|
300
|
+
"primaryKey": false,
|
|
301
|
+
"notNull": false
|
|
302
|
+
},
|
|
303
|
+
"last_dispatch_failed_at": {
|
|
304
|
+
"name": "last_dispatch_failed_at",
|
|
305
|
+
"type": "timestamp with time zone",
|
|
306
|
+
"primaryKey": false,
|
|
307
|
+
"notNull": false
|
|
308
|
+
},
|
|
309
|
+
"dead_lettered_at": {
|
|
310
|
+
"name": "dead_lettered_at",
|
|
311
|
+
"type": "timestamp with time zone",
|
|
312
|
+
"primaryKey": false,
|
|
313
|
+
"notNull": false
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
"indexes": {
|
|
317
|
+
"workspaces_outbox_pending_idx": {
|
|
318
|
+
"name": "workspaces_outbox_pending_idx",
|
|
319
|
+
"columns": [
|
|
320
|
+
{
|
|
321
|
+
"expression": "next_dispatch_at",
|
|
322
|
+
"isExpression": false,
|
|
323
|
+
"asc": true,
|
|
324
|
+
"nulls": "last"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"expression": "created_at",
|
|
328
|
+
"isExpression": false,
|
|
329
|
+
"asc": true,
|
|
330
|
+
"nulls": "last"
|
|
331
|
+
}
|
|
332
|
+
],
|
|
333
|
+
"isUnique": false,
|
|
334
|
+
"where": "\"dispatched_at\" IS NULL AND \"dead_lettered_at\" IS NULL",
|
|
335
|
+
"concurrently": false,
|
|
336
|
+
"method": "btree",
|
|
337
|
+
"with": {}
|
|
338
|
+
},
|
|
339
|
+
"workspaces_outbox_dispatched_retention_idx": {
|
|
340
|
+
"name": "workspaces_outbox_dispatched_retention_idx",
|
|
341
|
+
"columns": [
|
|
342
|
+
{
|
|
343
|
+
"expression": "dispatched_at",
|
|
344
|
+
"isExpression": false,
|
|
345
|
+
"asc": true,
|
|
346
|
+
"nulls": "last"
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"expression": "id",
|
|
350
|
+
"isExpression": false,
|
|
351
|
+
"asc": true,
|
|
352
|
+
"nulls": "last"
|
|
353
|
+
}
|
|
354
|
+
],
|
|
355
|
+
"isUnique": false,
|
|
356
|
+
"where": "\"dispatched_at\" IS NOT NULL",
|
|
357
|
+
"concurrently": false,
|
|
358
|
+
"method": "btree",
|
|
359
|
+
"with": {}
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
"foreignKeys": {},
|
|
363
|
+
"compositePrimaryKeys": {},
|
|
364
|
+
"uniqueConstraints": {},
|
|
365
|
+
"policies": {},
|
|
366
|
+
"checkConstraints": {},
|
|
367
|
+
"isRLSEnabled": false
|
|
368
|
+
},
|
|
369
|
+
"public.workspaces": {
|
|
370
|
+
"name": "workspaces",
|
|
371
|
+
"schema": "",
|
|
372
|
+
"columns": {
|
|
373
|
+
"id": {
|
|
374
|
+
"name": "id",
|
|
375
|
+
"type": "uuid",
|
|
376
|
+
"primaryKey": true,
|
|
377
|
+
"notNull": true,
|
|
378
|
+
"default": "uuidv7()"
|
|
379
|
+
},
|
|
380
|
+
"name": {
|
|
381
|
+
"name": "name",
|
|
382
|
+
"type": "text",
|
|
383
|
+
"primaryKey": false,
|
|
384
|
+
"notNull": true
|
|
385
|
+
},
|
|
386
|
+
"status": {
|
|
387
|
+
"name": "status",
|
|
388
|
+
"type": "workspaces_workspace_status",
|
|
389
|
+
"typeSchema": "public",
|
|
390
|
+
"primaryKey": false,
|
|
391
|
+
"notNull": true,
|
|
392
|
+
"default": "'active'"
|
|
393
|
+
},
|
|
394
|
+
"settings": {
|
|
395
|
+
"name": "settings",
|
|
396
|
+
"type": "jsonb",
|
|
397
|
+
"primaryKey": false,
|
|
398
|
+
"notNull": true,
|
|
399
|
+
"default": "'{}'::jsonb"
|
|
400
|
+
},
|
|
401
|
+
"created_at": {
|
|
402
|
+
"name": "created_at",
|
|
403
|
+
"type": "timestamp with time zone",
|
|
404
|
+
"primaryKey": false,
|
|
405
|
+
"notNull": true,
|
|
406
|
+
"default": "now()"
|
|
407
|
+
},
|
|
408
|
+
"updated_at": {
|
|
409
|
+
"name": "updated_at",
|
|
410
|
+
"type": "timestamp with time zone",
|
|
411
|
+
"primaryKey": false,
|
|
412
|
+
"notNull": true,
|
|
413
|
+
"default": "now()"
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
"indexes": {},
|
|
417
|
+
"foreignKeys": {},
|
|
418
|
+
"compositePrimaryKeys": {},
|
|
419
|
+
"uniqueConstraints": {},
|
|
420
|
+
"policies": {},
|
|
421
|
+
"checkConstraints": {},
|
|
422
|
+
"isRLSEnabled": false
|
|
423
|
+
}
|
|
424
|
+
},
|
|
425
|
+
"enums": {
|
|
426
|
+
"public.workspaces_workspace_status": {
|
|
427
|
+
"name": "workspaces_workspace_status",
|
|
428
|
+
"schema": "public",
|
|
429
|
+
"values": ["active", "suspended", "deleted"]
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
"schemas": {},
|
|
433
|
+
"sequences": {},
|
|
434
|
+
"roles": {},
|
|
435
|
+
"policies": {},
|
|
436
|
+
"views": {},
|
|
437
|
+
"_meta": {
|
|
438
|
+
"columns": {},
|
|
439
|
+
"schemas": {},
|
|
440
|
+
"tables": {}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "7",
|
|
3
|
+
"dialect": "postgresql",
|
|
4
|
+
"entries": [
|
|
5
|
+
{
|
|
6
|
+
"idx": 0,
|
|
7
|
+
"version": "7",
|
|
8
|
+
"when": 1777229181112,
|
|
9
|
+
"tag": "0000_initial",
|
|
10
|
+
"breakpoints": true
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"idx": 1,
|
|
14
|
+
"version": "7",
|
|
15
|
+
"when": 1777289648915,
|
|
16
|
+
"tag": "0001_memberships_invitations",
|
|
17
|
+
"breakpoints": true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"idx": 2,
|
|
21
|
+
"version": "7",
|
|
22
|
+
"when": 1777297640000,
|
|
23
|
+
"tag": "0002_membership_user_snapshots",
|
|
24
|
+
"breakpoints": true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"idx": 3,
|
|
28
|
+
"version": "7",
|
|
29
|
+
"when": 1782352229611,
|
|
30
|
+
"tag": "0003_outgoing_enchantress",
|
|
31
|
+
"breakpoints": true
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shipfox/api-workspaces",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/ShipfoxHQ/shipfox.git",
|
|
8
|
+
"directory": "libs/api/workspaces"
|
|
9
|
+
},
|
|
10
|
+
"private": false,
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.js",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"imports": {
|
|
15
|
+
"#test/*": "./test/*",
|
|
16
|
+
"#*": {
|
|
17
|
+
"workspace-source": "./src/*",
|
|
18
|
+
"development": "./src/*",
|
|
19
|
+
"default": "./dist/*"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"development": {
|
|
25
|
+
"types": "./src/index.ts",
|
|
26
|
+
"default": "./src/index.ts"
|
|
27
|
+
},
|
|
28
|
+
"default": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"drizzle-orm": "^0.45.2",
|
|
36
|
+
"zod": "^4.4.3",
|
|
37
|
+
"@shipfox/api-workspaces-dto": "2.0.0",
|
|
38
|
+
"@shipfox/api-auth-context": "2.0.0",
|
|
39
|
+
"@shipfox/node-email": "0.2.1",
|
|
40
|
+
"@shipfox/node-drizzle": "0.2.1",
|
|
41
|
+
"@shipfox/config": "1.2.1",
|
|
42
|
+
"@shipfox/node-fastify": "0.2.1",
|
|
43
|
+
"@shipfox/node-mailer": "0.1.2",
|
|
44
|
+
"@shipfox/node-module": "0.2.0",
|
|
45
|
+
"@shipfox/node-outbox": "0.2.1",
|
|
46
|
+
"@shipfox/node-opentelemetry": "0.5.0",
|
|
47
|
+
"@shipfox/node-postgres": "0.4.1",
|
|
48
|
+
"@shipfox/node-tokens": "0.2.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/pg": "^8.15.5",
|
|
52
|
+
"drizzle-kit": "^0.31.10",
|
|
53
|
+
"fastify": "^5.3.3",
|
|
54
|
+
"fastify-type-provider-zod": "^6.0.0",
|
|
55
|
+
"fishery": "^2.2.2",
|
|
56
|
+
"@shipfox/swc": "1.2.5",
|
|
57
|
+
"@shipfox/typescript": "1.1.6",
|
|
58
|
+
"@shipfox/ts-config": "1.3.8",
|
|
59
|
+
"@shipfox/biome": "1.8.1",
|
|
60
|
+
"@shipfox/vitest": "1.2.2"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "shipfox-swc",
|
|
64
|
+
"check": "shipfox-biome-check",
|
|
65
|
+
"check:fix": "shipfox-biome-check --write",
|
|
66
|
+
"test": "shipfox-vitest-run",
|
|
67
|
+
"test:watch": "shipfox-vitest-watch",
|
|
68
|
+
"type": "shipfox-tsc-check",
|
|
69
|
+
"type:emit": "shipfox-tsc-emit"
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {createConfig, num, str} from '@shipfox/config';
|
|
2
|
+
import {createConsoleMailer, createSmtpMailer, type Mailer} from '@shipfox/node-mailer';
|
|
3
|
+
|
|
4
|
+
export const config = createConfig({
|
|
5
|
+
CLIENT_BASE_URL: str({
|
|
6
|
+
desc: 'Base URL of the client app. Used to build links in workspace invitation emails.',
|
|
7
|
+
default: 'http://localhost:5173',
|
|
8
|
+
}),
|
|
9
|
+
MAILER_TRANSPORT: str({
|
|
10
|
+
desc: 'How emails are delivered. Use console to print them to the log, or smtp to send them through an SMTP server.',
|
|
11
|
+
choices: ['console', 'smtp'],
|
|
12
|
+
default: 'console',
|
|
13
|
+
}),
|
|
14
|
+
MAILER_FROM: str({
|
|
15
|
+
desc: 'Sender address shown on outgoing emails.',
|
|
16
|
+
default: 'noreply@shipfox.local',
|
|
17
|
+
}),
|
|
18
|
+
SMTP_HOST: str({
|
|
19
|
+
desc: 'Hostname of the SMTP server. Required when MAILER_TRANSPORT is smtp.',
|
|
20
|
+
default: undefined,
|
|
21
|
+
}),
|
|
22
|
+
SMTP_PORT: num({
|
|
23
|
+
desc: 'Port of the SMTP server.',
|
|
24
|
+
default: 587,
|
|
25
|
+
}),
|
|
26
|
+
SMTP_USER: str({
|
|
27
|
+
desc: 'Username for SMTP authentication. Leave it unset if the server needs no login.',
|
|
28
|
+
default: undefined,
|
|
29
|
+
}),
|
|
30
|
+
SMTP_PASSWORD: str({
|
|
31
|
+
desc: 'Password for SMTP authentication. Leave it unset if the server needs no login.',
|
|
32
|
+
default: undefined,
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
function createMailer(): Mailer {
|
|
37
|
+
if (config.MAILER_TRANSPORT === 'smtp') {
|
|
38
|
+
if (!config.SMTP_HOST) throw new Error('SMTP_HOST is required when MAILER_TRANSPORT=smtp');
|
|
39
|
+
return createSmtpMailer({
|
|
40
|
+
host: config.SMTP_HOST,
|
|
41
|
+
port: config.SMTP_PORT,
|
|
42
|
+
...(config.SMTP_USER ? {user: config.SMTP_USER} : {}),
|
|
43
|
+
...(config.SMTP_PASSWORD ? {password: config.SMTP_PASSWORD} : {}),
|
|
44
|
+
from: config.MAILER_FROM,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return createConsoleMailer({from: config.MAILER_FROM});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const mailer = createMailer();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface Invitation {
|
|
2
|
+
id: string;
|
|
3
|
+
workspaceId: string;
|
|
4
|
+
email: string;
|
|
5
|
+
hashedToken: string;
|
|
6
|
+
expiresAt: Date;
|
|
7
|
+
acceptedAt: Date | null;
|
|
8
|
+
acceptedByUserId: string | null;
|
|
9
|
+
invitedByUserId: string;
|
|
10
|
+
invitedByDisplay: string | null;
|
|
11
|
+
createdAt: Date;
|
|
12
|
+
updatedAt: Date;
|
|
13
|
+
}
|