@kosha-ai/server 0.0.1
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 +21 -0
- package/dist/auth/api-key.guard.d.ts +18 -0
- package/dist/auth/api-key.guard.d.ts.map +1 -0
- package/dist/auth/api-key.guard.js +33 -0
- package/dist/auth/auth.factory.d.ts +35 -0
- package/dist/auth/auth.factory.d.ts.map +1 -0
- package/dist/auth/auth.factory.js +29 -0
- package/dist/bootstrap.d.ts +13 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +33 -0
- package/dist/common/active-organization.d.ts +3 -0
- package/dist/common/active-organization.d.ts.map +1 -0
- package/dist/common/active-organization.js +8 -0
- package/dist/config/kosha-config.d.ts +80 -0
- package/dist/config/kosha-config.d.ts.map +1 -0
- package/dist/config/kosha-config.js +69 -0
- package/dist/config/tokens.d.ts +4 -0
- package/dist/config/tokens.d.ts.map +1 -0
- package/dist/config/tokens.js +3 -0
- package/dist/configurations/configurations.controller.d.ts +143 -0
- package/dist/configurations/configurations.controller.d.ts.map +1 -0
- package/dist/configurations/configurations.controller.js +76 -0
- package/dist/configurations/configurations.module.d.ts +3 -0
- package/dist/configurations/configurations.module.d.ts.map +1 -0
- package/dist/configurations/configurations.module.js +14 -0
- package/dist/configurations/configurations.service.d.ts +210 -0
- package/dist/configurations/configurations.service.d.ts.map +1 -0
- package/dist/configurations/configurations.service.js +204 -0
- package/dist/connect/connect.controller.d.ts +33 -0
- package/dist/connect/connect.controller.d.ts.map +1 -0
- package/dist/connect/connect.controller.js +123 -0
- package/dist/connect/connect.module.d.ts +3 -0
- package/dist/connect/connect.module.d.ts.map +1 -0
- package/dist/connect/connect.module.js +16 -0
- package/dist/connect/connect.service.d.ts +54 -0
- package/dist/connect/connect.service.d.ts.map +1 -0
- package/dist/connect/connect.service.js +248 -0
- package/dist/connections/connections.controller.d.ts +71 -0
- package/dist/connections/connections.controller.d.ts.map +1 -0
- package/dist/connections/connections.controller.js +51 -0
- package/dist/connections/connections.module.d.ts +3 -0
- package/dist/connections/connections.module.d.ts.map +1 -0
- package/dist/connections/connections.module.js +14 -0
- package/dist/connections/connections.service.d.ts +76 -0
- package/dist/connections/connections.service.d.ts.map +1 -0
- package/dist/connections/connections.service.js +71 -0
- package/dist/crypto/crypto.module.d.ts +3 -0
- package/dist/crypto/crypto.module.d.ts.map +1 -0
- package/dist/crypto/crypto.module.js +13 -0
- package/dist/crypto/crypto.service.d.ts +21 -0
- package/dist/crypto/crypto.service.d.ts.map +1 -0
- package/dist/crypto/crypto.service.js +77 -0
- package/dist/generated/prisma/browser.d.ts +88 -0
- package/dist/generated/prisma/browser.d.ts.map +1 -0
- package/dist/generated/prisma/browser.js +17 -0
- package/dist/generated/prisma/client.d.ts +107 -0
- package/dist/generated/prisma/client.d.ts.map +1 -0
- package/dist/generated/prisma/client.js +34 -0
- package/dist/generated/prisma/commonInputTypes.d.ts +478 -0
- package/dist/generated/prisma/commonInputTypes.d.ts.map +1 -0
- package/dist/generated/prisma/commonInputTypes.js +10 -0
- package/dist/generated/prisma/enums.d.ts +22 -0
- package/dist/generated/prisma/enums.d.ts.map +1 -0
- package/dist/generated/prisma/enums.js +27 -0
- package/dist/generated/prisma/internal/class.d.ts +287 -0
- package/dist/generated/prisma/internal/class.d.ts.map +1 -0
- package/dist/generated/prisma/internal/class.js +49 -0
- package/dist/generated/prisma/internal/prismaNamespace.d.ts +1905 -0
- package/dist/generated/prisma/internal/prismaNamespace.d.ts.map +1 -0
- package/dist/generated/prisma/internal/prismaNamespace.js +299 -0
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +277 -0
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts.map +1 -0
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.js +270 -0
- package/dist/generated/prisma/models/Account.d.ts +1459 -0
- package/dist/generated/prisma/models/Account.d.ts.map +1 -0
- package/dist/generated/prisma/models/Account.js +1 -0
- package/dist/generated/prisma/models/Apikey.d.ts +1552 -0
- package/dist/generated/prisma/models/Apikey.d.ts.map +1 -0
- package/dist/generated/prisma/models/Apikey.js +1 -0
- package/dist/generated/prisma/models/Configuration.d.ts +1964 -0
- package/dist/generated/prisma/models/Configuration.d.ts.map +1 -0
- package/dist/generated/prisma/models/Configuration.js +1 -0
- package/dist/generated/prisma/models/ConnectSession.d.ts +1606 -0
- package/dist/generated/prisma/models/ConnectSession.d.ts.map +1 -0
- package/dist/generated/prisma/models/ConnectSession.js +1 -0
- package/dist/generated/prisma/models/Connection.d.ts +1949 -0
- package/dist/generated/prisma/models/Connection.d.ts.map +1 -0
- package/dist/generated/prisma/models/Connection.js +1 -0
- package/dist/generated/prisma/models/ConnectionCredential.d.ts +1293 -0
- package/dist/generated/prisma/models/ConnectionCredential.d.ts.map +1 -0
- package/dist/generated/prisma/models/ConnectionCredential.js +1 -0
- package/dist/generated/prisma/models/EndUser.d.ts +1539 -0
- package/dist/generated/prisma/models/EndUser.d.ts.map +1 -0
- package/dist/generated/prisma/models/EndUser.js +1 -0
- package/dist/generated/prisma/models/Invitation.d.ts +1404 -0
- package/dist/generated/prisma/models/Invitation.d.ts.map +1 -0
- package/dist/generated/prisma/models/Invitation.js +1 -0
- package/dist/generated/prisma/models/Member.d.ts +1281 -0
- package/dist/generated/prisma/models/Member.d.ts.map +1 -0
- package/dist/generated/prisma/models/Member.js +1 -0
- package/dist/generated/prisma/models/OAuthState.d.ts +1404 -0
- package/dist/generated/prisma/models/OAuthState.d.ts.map +1 -0
- package/dist/generated/prisma/models/OAuthState.js +1 -0
- package/dist/generated/prisma/models/Organization.d.ts +1807 -0
- package/dist/generated/prisma/models/Organization.d.ts.map +1 -0
- package/dist/generated/prisma/models/Organization.js +1 -0
- package/dist/generated/prisma/models/Provider.d.ts +1462 -0
- package/dist/generated/prisma/models/Provider.d.ts.map +1 -0
- package/dist/generated/prisma/models/Provider.js +1 -0
- package/dist/generated/prisma/models/Session.d.ts +1316 -0
- package/dist/generated/prisma/models/Session.d.ts.map +1 -0
- package/dist/generated/prisma/models/Session.js +1 -0
- package/dist/generated/prisma/models/User.d.ts +1593 -0
- package/dist/generated/prisma/models/User.d.ts.map +1 -0
- package/dist/generated/prisma/models/User.js +1 -0
- package/dist/generated/prisma/models/Verification.d.ts +1026 -0
- package/dist/generated/prisma/models/Verification.d.ts.map +1 -0
- package/dist/generated/prisma/models/Verification.js +1 -0
- package/dist/generated/prisma/models.d.ts +17 -0
- package/dist/generated/prisma/models.d.ts.map +1 -0
- package/dist/generated/prisma/models.js +1 -0
- package/dist/health/health.controller.d.ts +12 -0
- package/dist/health/health.controller.d.ts.map +1 -0
- package/dist/health/health.controller.js +36 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/integrations/integration.registry.d.ts +19 -0
- package/dist/integrations/integration.registry.d.ts.map +1 -0
- package/dist/integrations/integration.registry.js +45 -0
- package/dist/integrations/integrations.controller.d.ts +26 -0
- package/dist/integrations/integrations.controller.d.ts.map +1 -0
- package/dist/integrations/integrations.controller.js +47 -0
- package/dist/integrations/integrations.module.d.ts +6 -0
- package/dist/integrations/integrations.module.d.ts.map +1 -0
- package/dist/integrations/integrations.module.js +26 -0
- package/dist/integrations/provider-sync.service.d.ts +24 -0
- package/dist/integrations/provider-sync.service.d.ts.map +1 -0
- package/dist/integrations/provider-sync.service.js +74 -0
- package/dist/kosha.module.d.ts +11 -0
- package/dist/kosha.module.d.ts.map +1 -0
- package/dist/kosha.module.js +48 -0
- package/dist/prisma/prisma.module.d.ts +11 -0
- package/dist/prisma/prisma.module.d.ts.map +1 -0
- package/dist/prisma/prisma.module.js +24 -0
- package/dist/prisma/prisma.service.d.ts +10 -0
- package/dist/prisma/prisma.service.d.ts.map +1 -0
- package/dist/prisma/prisma.service.js +25 -0
- package/dist/proxy/proxy.controller.d.ts +17 -0
- package/dist/proxy/proxy.controller.d.ts.map +1 -0
- package/dist/proxy/proxy.controller.js +64 -0
- package/dist/proxy/proxy.module.d.ts +3 -0
- package/dist/proxy/proxy.module.d.ts.map +1 -0
- package/dist/proxy/proxy.module.js +16 -0
- package/dist/proxy/proxy.service.d.ts +40 -0
- package/dist/proxy/proxy.service.d.ts.map +1 -0
- package/dist/proxy/proxy.service.js +186 -0
- package/package.json +118 -0
- package/prisma/migrations/20260908000000_init/migration.sql +209 -0
- package/prisma/migrations/20260908161813_add_connect_domain/migration.sql +173 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +347 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
// The generated client is committed into src/ and compiled into dist/ so
|
|
2
|
+
// that installing @kosha-ai/server needs no `prisma generate` step and no
|
|
3
|
+
// DATABASE_URL. Consumers get a ready client; only migrations need the CLI.
|
|
4
|
+
generator client {
|
|
5
|
+
provider = "prisma-client"
|
|
6
|
+
output = "../src/generated/prisma"
|
|
7
|
+
runtime = "nodejs"
|
|
8
|
+
moduleFormat = "esm"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
datasource db {
|
|
12
|
+
provider = "postgresql"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
model User {
|
|
16
|
+
id String @id @default(cuid())
|
|
17
|
+
email String @unique
|
|
18
|
+
name String?
|
|
19
|
+
emailVerified Boolean @default(false)
|
|
20
|
+
image String?
|
|
21
|
+
createdAt DateTime @default(now())
|
|
22
|
+
updatedAt DateTime @updatedAt
|
|
23
|
+
|
|
24
|
+
sessions Session[]
|
|
25
|
+
accounts Account[]
|
|
26
|
+
members Member[]
|
|
27
|
+
invitations Invitation[]
|
|
28
|
+
|
|
29
|
+
@@map("user")
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
model Session {
|
|
33
|
+
id String @id
|
|
34
|
+
expiresAt DateTime
|
|
35
|
+
token String @unique
|
|
36
|
+
createdAt DateTime @default(now())
|
|
37
|
+
updatedAt DateTime @updatedAt
|
|
38
|
+
ipAddress String?
|
|
39
|
+
userAgent String?
|
|
40
|
+
userId String
|
|
41
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
42
|
+
activeOrganizationId String?
|
|
43
|
+
|
|
44
|
+
@@index([userId])
|
|
45
|
+
@@map("session")
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
model Account {
|
|
49
|
+
id String @id
|
|
50
|
+
accountId String
|
|
51
|
+
providerId String
|
|
52
|
+
userId String
|
|
53
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
54
|
+
accessToken String?
|
|
55
|
+
refreshToken String?
|
|
56
|
+
idToken String?
|
|
57
|
+
accessTokenExpiresAt DateTime?
|
|
58
|
+
refreshTokenExpiresAt DateTime?
|
|
59
|
+
scope String?
|
|
60
|
+
password String?
|
|
61
|
+
createdAt DateTime @default(now())
|
|
62
|
+
updatedAt DateTime @updatedAt
|
|
63
|
+
|
|
64
|
+
@@index([userId])
|
|
65
|
+
@@map("account")
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
model Verification {
|
|
69
|
+
id String @id
|
|
70
|
+
identifier String
|
|
71
|
+
value String
|
|
72
|
+
expiresAt DateTime
|
|
73
|
+
createdAt DateTime @default(now())
|
|
74
|
+
updatedAt DateTime @updatedAt
|
|
75
|
+
|
|
76
|
+
@@index([identifier])
|
|
77
|
+
@@map("verification")
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
model Organization {
|
|
81
|
+
id String @id
|
|
82
|
+
name String
|
|
83
|
+
slug String @unique
|
|
84
|
+
logo String?
|
|
85
|
+
metadata String?
|
|
86
|
+
createdAt DateTime @default(now())
|
|
87
|
+
|
|
88
|
+
members Member[]
|
|
89
|
+
invitations Invitation[]
|
|
90
|
+
|
|
91
|
+
configurations Configuration[]
|
|
92
|
+
endUsers EndUser[]
|
|
93
|
+
connections Connection[]
|
|
94
|
+
connectSessions ConnectSession[]
|
|
95
|
+
|
|
96
|
+
@@map("organization")
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
model Member {
|
|
100
|
+
id String @id
|
|
101
|
+
organizationId String
|
|
102
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
103
|
+
userId String
|
|
104
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
105
|
+
role String @default("member")
|
|
106
|
+
createdAt DateTime @default(now())
|
|
107
|
+
|
|
108
|
+
@@index([organizationId])
|
|
109
|
+
@@index([userId])
|
|
110
|
+
@@map("member")
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
model Invitation {
|
|
114
|
+
id String @id
|
|
115
|
+
organizationId String
|
|
116
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
117
|
+
email String
|
|
118
|
+
role String?
|
|
119
|
+
status String @default("pending")
|
|
120
|
+
expiresAt DateTime
|
|
121
|
+
createdAt DateTime @default(now())
|
|
122
|
+
inviterId String
|
|
123
|
+
user User @relation(fields: [inviterId], references: [id], onDelete: Cascade)
|
|
124
|
+
|
|
125
|
+
@@index([organizationId])
|
|
126
|
+
@@index([email])
|
|
127
|
+
@@map("invitation")
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
model Apikey {
|
|
131
|
+
id String @id
|
|
132
|
+
configId String @default("default")
|
|
133
|
+
name String?
|
|
134
|
+
start String?
|
|
135
|
+
referenceId String
|
|
136
|
+
prefix String?
|
|
137
|
+
key String
|
|
138
|
+
refillInterval Int?
|
|
139
|
+
refillAmount Int?
|
|
140
|
+
lastRefillAt DateTime?
|
|
141
|
+
enabled Boolean? @default(true)
|
|
142
|
+
rateLimitEnabled Boolean? @default(true)
|
|
143
|
+
rateLimitTimeWindow Int? @default(86400000)
|
|
144
|
+
rateLimitMax Int? @default(10)
|
|
145
|
+
requestCount Int? @default(0)
|
|
146
|
+
remaining Int?
|
|
147
|
+
lastRequest DateTime?
|
|
148
|
+
expiresAt DateTime?
|
|
149
|
+
createdAt DateTime
|
|
150
|
+
updatedAt DateTime
|
|
151
|
+
permissions String?
|
|
152
|
+
metadata String?
|
|
153
|
+
|
|
154
|
+
@@index([configId])
|
|
155
|
+
@@index([referenceId])
|
|
156
|
+
@@index([key])
|
|
157
|
+
@@map("apikey")
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
enum AuthType {
|
|
161
|
+
OAUTH2
|
|
162
|
+
OAUTH1
|
|
163
|
+
API_KEY
|
|
164
|
+
BASIC
|
|
165
|
+
CUSTOM
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/// Catalogue of providers Kosha can talk to. Derived state: every row is
|
|
169
|
+
/// upserted at boot from the installed integration packages, and rows whose
|
|
170
|
+
/// package is gone are deactivated rather than deleted.
|
|
171
|
+
model Provider {
|
|
172
|
+
id String @id @default(cuid())
|
|
173
|
+
key String @unique
|
|
174
|
+
name String
|
|
175
|
+
authType AuthType
|
|
176
|
+
authorizationUrl String?
|
|
177
|
+
tokenUrl String?
|
|
178
|
+
revokeUrl String?
|
|
179
|
+
apiBaseUrl String?
|
|
180
|
+
scopesAvailable String[]
|
|
181
|
+
docsUrl String?
|
|
182
|
+
logoUrl String?
|
|
183
|
+
isActive Boolean @default(true)
|
|
184
|
+
createdAt DateTime @default(now())
|
|
185
|
+
updatedAt DateTime @updatedAt
|
|
186
|
+
|
|
187
|
+
configurations Configuration[]
|
|
188
|
+
|
|
189
|
+
@@map("provider")
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
enum ConnectionEnvironment {
|
|
193
|
+
SANDBOX
|
|
194
|
+
LIVE
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
enum ConnectionStatus {
|
|
198
|
+
PENDING
|
|
199
|
+
ACTIVE
|
|
200
|
+
ERROR
|
|
201
|
+
REVOKED
|
|
202
|
+
EXPIRED
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/// One organization's setup of one provider: which OAuth app, which scopes,
|
|
206
|
+
/// which environment. `metadata` holds the integration's own `configFields`.
|
|
207
|
+
model Configuration {
|
|
208
|
+
id String @id @default(cuid())
|
|
209
|
+
organizationId String
|
|
210
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
211
|
+
providerId String
|
|
212
|
+
provider Provider @relation(fields: [providerId], references: [id], onDelete: Restrict)
|
|
213
|
+
|
|
214
|
+
name String
|
|
215
|
+
environment ConnectionEnvironment @default(LIVE)
|
|
216
|
+
authType AuthType
|
|
217
|
+
clientId String?
|
|
218
|
+
encryptedClientSecret String?
|
|
219
|
+
redirectUri String?
|
|
220
|
+
scopes String[]
|
|
221
|
+
isEnabled Boolean @default(true)
|
|
222
|
+
metadata Json?
|
|
223
|
+
createdAt DateTime @default(now())
|
|
224
|
+
updatedAt DateTime @updatedAt
|
|
225
|
+
|
|
226
|
+
connections Connection[]
|
|
227
|
+
oauthStates OAuthState[]
|
|
228
|
+
|
|
229
|
+
@@unique([organizationId, providerId, name])
|
|
230
|
+
@@index([organizationId])
|
|
231
|
+
@@map("configuration")
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/// The organization's own users, identified by the organization's id for them
|
|
235
|
+
/// — never by a Kosha auth user.
|
|
236
|
+
model EndUser {
|
|
237
|
+
id String @id @default(cuid())
|
|
238
|
+
organizationId String
|
|
239
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
240
|
+
externalId String
|
|
241
|
+
email String?
|
|
242
|
+
name String?
|
|
243
|
+
metadata Json?
|
|
244
|
+
createdAt DateTime @default(now())
|
|
245
|
+
updatedAt DateTime @updatedAt
|
|
246
|
+
|
|
247
|
+
connections Connection[]
|
|
248
|
+
connectSessions ConnectSession[]
|
|
249
|
+
|
|
250
|
+
@@unique([organizationId, externalId])
|
|
251
|
+
@@index([organizationId])
|
|
252
|
+
@@map("end_user")
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/// The authorized link between an EndUser and a Configuration. An end user may
|
|
256
|
+
/// hold several connections against the same configuration (two GitHub
|
|
257
|
+
/// accounts), so uniqueness is per provider account, not per end user.
|
|
258
|
+
model Connection {
|
|
259
|
+
id String @id @default(cuid())
|
|
260
|
+
organizationId String
|
|
261
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
262
|
+
endUserId String
|
|
263
|
+
endUser EndUser @relation(fields: [endUserId], references: [id], onDelete: Cascade)
|
|
264
|
+
configurationId String
|
|
265
|
+
configuration Configuration @relation(fields: [configurationId], references: [id], onDelete: Restrict)
|
|
266
|
+
|
|
267
|
+
label String?
|
|
268
|
+
externalAccountId String?
|
|
269
|
+
status ConnectionStatus @default(PENDING)
|
|
270
|
+
scopes String[]
|
|
271
|
+
lastSyncedAt DateTime?
|
|
272
|
+
lastUsedAt DateTime?
|
|
273
|
+
errorMessage String?
|
|
274
|
+
metadata Json?
|
|
275
|
+
createdAt DateTime @default(now())
|
|
276
|
+
updatedAt DateTime @updatedAt
|
|
277
|
+
|
|
278
|
+
credential ConnectionCredential?
|
|
279
|
+
|
|
280
|
+
// A provider account cannot be linked twice under one configuration. A NULL
|
|
281
|
+
// externalAccountId (still pending) is exempt: Postgres treats NULLs as
|
|
282
|
+
// distinct.
|
|
283
|
+
@@unique([configurationId, externalAccountId])
|
|
284
|
+
@@index([organizationId])
|
|
285
|
+
@@index([configurationId])
|
|
286
|
+
@@index([endUserId])
|
|
287
|
+
@@map("connection")
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/// Tokens, split out from Connection so they have their own access path.
|
|
291
|
+
/// Every token column is AES-256-GCM ciphertext.
|
|
292
|
+
model ConnectionCredential {
|
|
293
|
+
id String @id @default(cuid())
|
|
294
|
+
connectionId String @unique
|
|
295
|
+
connection Connection @relation(fields: [connectionId], references: [id], onDelete: Cascade)
|
|
296
|
+
|
|
297
|
+
accessToken String
|
|
298
|
+
refreshToken String?
|
|
299
|
+
idToken String?
|
|
300
|
+
tokenType String?
|
|
301
|
+
expiresAt DateTime?
|
|
302
|
+
refreshTokenExpiresAt DateTime?
|
|
303
|
+
|
|
304
|
+
createdAt DateTime @default(now())
|
|
305
|
+
updatedAt DateTime @updatedAt
|
|
306
|
+
|
|
307
|
+
@@map("connection_credential")
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/// Short-lived token handed to the organization's frontend to drive one
|
|
311
|
+
/// connect flow.
|
|
312
|
+
model ConnectSession {
|
|
313
|
+
id String @id @default(cuid())
|
|
314
|
+
organizationId String
|
|
315
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
316
|
+
endUserId String?
|
|
317
|
+
endUser EndUser? @relation(fields: [endUserId], references: [id], onDelete: Cascade)
|
|
318
|
+
|
|
319
|
+
token String @unique
|
|
320
|
+
allowedConfigurationIds String[]
|
|
321
|
+
redirectUrl String?
|
|
322
|
+
status String @default("pending")
|
|
323
|
+
expiresAt DateTime
|
|
324
|
+
createdAt DateTime @default(now())
|
|
325
|
+
|
|
326
|
+
oauthStates OAuthState[]
|
|
327
|
+
|
|
328
|
+
@@index([organizationId])
|
|
329
|
+
@@map("connect_session")
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/// CSRF state and PKCE verifier for one OAuth redirect attempt.
|
|
333
|
+
model OAuthState {
|
|
334
|
+
id String @id @default(cuid())
|
|
335
|
+
state String @unique
|
|
336
|
+
connectSessionId String
|
|
337
|
+
connectSession ConnectSession @relation(fields: [connectSessionId], references: [id], onDelete: Cascade)
|
|
338
|
+
configurationId String
|
|
339
|
+
configuration Configuration @relation(fields: [configurationId], references: [id], onDelete: Cascade)
|
|
340
|
+
|
|
341
|
+
codeVerifier String?
|
|
342
|
+
status String @default("pending")
|
|
343
|
+
expiresAt DateTime
|
|
344
|
+
createdAt DateTime @default(now())
|
|
345
|
+
|
|
346
|
+
@@map("oauth_state")
|
|
347
|
+
}
|