@kosha-ai/server 0.2.0 → 0.3.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/dist/auth/auth.factory.d.ts.map +1 -1
- package/dist/auth/auth.factory.js +0 -5
- package/dist/configurations/configurations.controller.d.ts +6 -5
- package/dist/configurations/configurations.controller.d.ts.map +1 -1
- package/dist/configurations/configurations.controller.js +22 -18
- package/dist/configurations/configurations.module.d.ts.map +1 -1
- package/dist/configurations/configurations.module.js +1 -2
- package/dist/configurations/configurations.service.d.ts +24 -36
- package/dist/configurations/configurations.service.d.ts.map +1 -1
- package/dist/configurations/configurations.service.js +71 -151
- package/dist/configurations/dto/create-configuration.dto.d.ts +1 -2
- package/dist/configurations/dto/create-configuration.dto.d.ts.map +1 -1
- package/dist/configurations/dto/create-configuration.dto.js +2 -12
- package/dist/configurations/dto/update-configuration.dto.d.ts +0 -2
- package/dist/configurations/dto/update-configuration.dto.d.ts.map +1 -1
- package/dist/configurations/dto/update-configuration.dto.js +1 -17
- package/dist/connect/connect.controller.d.ts +1 -1
- package/dist/connect/connect.controller.d.ts.map +1 -1
- package/dist/connect/connect.controller.js +7 -6
- package/dist/connect/connect.module.d.ts.map +1 -1
- package/dist/connect/connect.module.js +1 -2
- package/dist/connect/connect.repository.d.ts +23 -23
- package/dist/connect/connect.repository.d.ts.map +1 -1
- package/dist/connect/connect.repository.js +37 -49
- package/dist/connect/connect.service.d.ts +7 -8
- package/dist/connect/connect.service.d.ts.map +1 -1
- package/dist/connect/connect.service.js +54 -51
- package/dist/connect/dto/create-connect-session.dto.d.ts +1 -1
- package/dist/connect/dto/create-connect-session.dto.d.ts.map +1 -1
- package/dist/connect/dto/create-connect-session.dto.js +7 -8
- package/dist/connect/dto/create-test-session.dto.d.ts +1 -0
- package/dist/connect/dto/create-test-session.dto.d.ts.map +1 -1
- package/dist/connect/dto/create-test-session.dto.js +10 -3
- package/dist/connections/connections.controller.d.ts +4 -3
- package/dist/connections/connections.controller.d.ts.map +1 -1
- package/dist/connections/connections.controller.js +13 -11
- package/dist/connections/connections.repository.d.ts +24 -17
- package/dist/connections/connections.repository.d.ts.map +1 -1
- package/dist/connections/connections.repository.js +21 -43
- package/dist/connections/connections.service.d.ts +48 -13
- package/dist/connections/connections.service.d.ts.map +1 -1
- package/dist/connections/connections.service.js +111 -32
- package/dist/connections/dto/list-connections.dto.d.ts +3 -1
- package/dist/connections/dto/list-connections.dto.d.ts.map +1 -1
- package/dist/connections/dto/list-connections.dto.js +26 -4
- package/dist/connections/environment-connections.controller.d.ts +4 -3
- package/dist/connections/environment-connections.controller.d.ts.map +1 -1
- package/dist/connections/environment-connections.controller.js +14 -12
- package/dist/credentials/credentials.module.d.ts.map +1 -1
- package/dist/credentials/credentials.module.js +0 -2
- package/dist/credentials/credentials.repository.d.ts +5 -2
- package/dist/credentials/credentials.repository.d.ts.map +1 -1
- package/dist/credentials/credentials.repository.js +10 -3
- package/dist/credentials/credentials.service.d.ts +8 -4
- package/dist/credentials/credentials.service.d.ts.map +1 -1
- package/dist/credentials/credentials.service.js +27 -16
- package/dist/egress/egress.listener.d.ts +1 -3
- package/dist/egress/egress.listener.d.ts.map +1 -1
- package/dist/egress/egress.listener.js +3 -7
- package/dist/egress/egress.repository.d.ts +13 -6
- package/dist/egress/egress.repository.d.ts.map +1 -1
- package/dist/egress/egress.repository.js +31 -44
- package/dist/generated/prisma/browser.d.ts +0 -5
- package/dist/generated/prisma/browser.d.ts.map +1 -1
- package/dist/generated/prisma/client.d.ts +0 -5
- package/dist/generated/prisma/client.d.ts.map +1 -1
- package/dist/generated/prisma/commonInputTypes.d.ts +0 -55
- package/dist/generated/prisma/commonInputTypes.d.ts.map +1 -1
- package/dist/generated/prisma/internal/class.d.ts +0 -11
- package/dist/generated/prisma/internal/class.d.ts.map +1 -1
- package/dist/generated/prisma/internal/class.js +4 -4
- package/dist/generated/prisma/internal/prismaNamespace.d.ts +1 -114
- package/dist/generated/prisma/internal/prismaNamespace.d.ts.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespace.js +2 -29
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +0 -30
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.js +2 -29
- package/dist/generated/prisma/models/Account.d.ts +26 -344
- package/dist/generated/prisma/models/Account.d.ts.map +1 -1
- package/dist/generated/prisma/models/Environment.d.ts +0 -258
- package/dist/generated/prisma/models/Environment.d.ts.map +1 -1
- package/dist/generated/prisma/models/User.d.ts +2 -60
- package/dist/generated/prisma/models/User.d.ts.map +1 -1
- package/dist/generated/prisma/models.d.ts +0 -1
- package/dist/generated/prisma/models.d.ts.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/integrations/integrations.controller.d.ts +2 -0
- package/dist/integrations/integrations.controller.d.ts.map +1 -1
- package/dist/integrations/integrations.controller.js +1 -0
- package/dist/integrations/integrations.module.d.ts.map +1 -1
- package/dist/integrations/integrations.module.js +3 -1
- package/dist/integrations/provider-store.d.ts +104 -0
- package/dist/integrations/provider-store.d.ts.map +1 -0
- package/dist/integrations/provider-store.js +234 -0
- package/dist/proxy/proxy.controller.d.ts +9 -5
- package/dist/proxy/proxy.controller.d.ts.map +1 -1
- package/dist/proxy/proxy.controller.js +18 -13
- package/dist/proxy/proxy.module.d.ts.map +1 -1
- package/dist/proxy/proxy.module.js +1 -2
- package/dist/proxy/proxy.repository.d.ts +11 -14
- package/dist/proxy/proxy.repository.d.ts.map +1 -1
- package/dist/proxy/proxy.repository.js +17 -27
- package/dist/proxy/proxy.service.d.ts +6 -8
- package/dist/proxy/proxy.service.d.ts.map +1 -1
- package/dist/proxy/proxy.service.js +34 -28
- package/package.json +4 -4
- package/prisma/migrations/{20260929101936_init → 20261008090000_init}/migration.sql +5 -58
- package/prisma/schema.prisma +2 -43
- package/dist/configurations/configurations.repository.d.ts +0 -43
- package/dist/configurations/configurations.repository.d.ts.map +0 -1
- package/dist/configurations/configurations.repository.js +0 -76
- package/dist/generated/prisma/models/Configuration.d.ts +0 -1385
- package/dist/generated/prisma/models/Configuration.d.ts.map +0 -1
- package/dist/generated/prisma/models/Configuration.js +0 -1
- package/prisma/migrations/20260930102529_connection_config/migration.sql +0 -2
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
-- CreateSchema
|
|
2
|
+
CREATE SCHEMA IF NOT EXISTS "public";
|
|
3
|
+
|
|
1
4
|
-- CreateTable
|
|
2
5
|
CREATE TABLE "user" (
|
|
3
6
|
"id" TEXT NOT NULL,
|
|
@@ -7,7 +10,6 @@ CREATE TABLE "user" (
|
|
|
7
10
|
"image" TEXT,
|
|
8
11
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
9
12
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
10
|
-
"externalId" TEXT,
|
|
11
13
|
|
|
12
14
|
CONSTRAINT "user_pkey" PRIMARY KEY ("id")
|
|
13
15
|
);
|
|
@@ -33,7 +35,7 @@ CREATE TABLE "account" (
|
|
|
33
35
|
"id" TEXT NOT NULL,
|
|
34
36
|
"accountId" TEXT NOT NULL,
|
|
35
37
|
"providerId" TEXT NOT NULL,
|
|
36
|
-
"userId" TEXT,
|
|
38
|
+
"userId" TEXT NOT NULL,
|
|
37
39
|
"accessToken" TEXT,
|
|
38
40
|
"refreshToken" TEXT,
|
|
39
41
|
"idToken" TEXT,
|
|
@@ -43,8 +45,6 @@ CREATE TABLE "account" (
|
|
|
43
45
|
"password" TEXT,
|
|
44
46
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
45
47
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
46
|
-
"environmentId" TEXT,
|
|
47
|
-
"organizationExternalId" TEXT,
|
|
48
48
|
|
|
49
49
|
CONSTRAINT "account_pkey" PRIMARY KEY ("id")
|
|
50
50
|
);
|
|
@@ -163,23 +163,6 @@ CREATE TABLE "environment" (
|
|
|
163
163
|
CONSTRAINT "environment_pkey" PRIMARY KEY ("id")
|
|
164
164
|
);
|
|
165
165
|
|
|
166
|
-
-- CreateTable
|
|
167
|
-
CREATE TABLE "configuration" (
|
|
168
|
-
"id" TEXT NOT NULL,
|
|
169
|
-
"environmentId" TEXT NOT NULL,
|
|
170
|
-
"integrationKey" TEXT NOT NULL,
|
|
171
|
-
"authType" TEXT NOT NULL,
|
|
172
|
-
"name" TEXT NOT NULL,
|
|
173
|
-
"slug" TEXT NOT NULL,
|
|
174
|
-
"credentials" TEXT,
|
|
175
|
-
"settings" JSONB,
|
|
176
|
-
"isEnabled" BOOLEAN NOT NULL DEFAULT true,
|
|
177
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
178
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
179
|
-
|
|
180
|
-
CONSTRAINT "configuration_pkey" PRIMARY KEY ("id")
|
|
181
|
-
);
|
|
182
|
-
|
|
183
166
|
-- CreateTable
|
|
184
167
|
CREATE TABLE "egress_grant" (
|
|
185
168
|
"id" TEXT NOT NULL,
|
|
@@ -200,9 +183,6 @@ CREATE TABLE "egress_grant" (
|
|
|
200
183
|
-- CreateIndex
|
|
201
184
|
CREATE UNIQUE INDEX "user_email_key" ON "user"("email");
|
|
202
185
|
|
|
203
|
-
-- CreateIndex
|
|
204
|
-
CREATE INDEX "user_externalId_idx" ON "user"("externalId");
|
|
205
|
-
|
|
206
186
|
-- CreateIndex
|
|
207
187
|
CREATE UNIQUE INDEX "session_token_key" ON "session"("token");
|
|
208
188
|
|
|
@@ -215,12 +195,6 @@ CREATE INDEX "account_userId_idx" ON "account"("userId");
|
|
|
215
195
|
-- CreateIndex
|
|
216
196
|
CREATE INDEX "account_providerId_idx" ON "account"("providerId");
|
|
217
197
|
|
|
218
|
-
-- CreateIndex
|
|
219
|
-
CREATE INDEX "account_environmentId_organizationExternalId_idx" ON "account"("environmentId", "organizationExternalId");
|
|
220
|
-
|
|
221
|
-
-- CreateIndex
|
|
222
|
-
CREATE UNIQUE INDEX "account_environmentId_organizationExternalId_providerId_key" ON "account"("environmentId", "organizationExternalId", "providerId");
|
|
223
|
-
|
|
224
198
|
-- CreateIndex
|
|
225
199
|
CREATE INDEX "verification_identifier_idx" ON "verification"("identifier");
|
|
226
200
|
|
|
@@ -269,12 +243,6 @@ CREATE INDEX "environment_teamId_idx" ON "environment"("teamId");
|
|
|
269
243
|
-- CreateIndex
|
|
270
244
|
CREATE UNIQUE INDEX "environment_organizationId_slug_key" ON "environment"("organizationId", "slug");
|
|
271
245
|
|
|
272
|
-
-- CreateIndex
|
|
273
|
-
CREATE INDEX "configuration_environmentId_idx" ON "configuration"("environmentId");
|
|
274
|
-
|
|
275
|
-
-- CreateIndex
|
|
276
|
-
CREATE UNIQUE INDEX "configuration_environmentId_slug_key" ON "configuration"("environmentId", "slug");
|
|
277
|
-
|
|
278
246
|
-- CreateIndex
|
|
279
247
|
CREATE INDEX "egress_grant_tokenHash_idx" ON "egress_grant"("tokenHash");
|
|
280
248
|
|
|
@@ -288,10 +256,7 @@ CREATE INDEX "egress_grant_userId_idx" ON "egress_grant"("userId");
|
|
|
288
256
|
ALTER TABLE "session" ADD CONSTRAINT "session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
289
257
|
|
|
290
258
|
-- AddForeignKey
|
|
291
|
-
ALTER TABLE "account" ADD CONSTRAINT "account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE
|
|
292
|
-
|
|
293
|
-
-- AddForeignKey
|
|
294
|
-
ALTER TABLE "account" ADD CONSTRAINT "account_environmentId_fkey" FOREIGN KEY ("environmentId") REFERENCES "environment"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
259
|
+
ALTER TABLE "account" ADD CONSTRAINT "account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
295
260
|
|
|
296
261
|
-- AddForeignKey
|
|
297
262
|
ALTER TABLE "member" ADD CONSTRAINT "member_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@@ -320,26 +285,8 @@ ALTER TABLE "environment" ADD CONSTRAINT "environment_organizationId_fkey" FOREI
|
|
|
320
285
|
-- AddForeignKey
|
|
321
286
|
ALTER TABLE "environment" ADD CONSTRAINT "environment_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "team"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
322
287
|
|
|
323
|
-
-- AddForeignKey
|
|
324
|
-
ALTER TABLE "configuration" ADD CONSTRAINT "configuration_environmentId_fkey" FOREIGN KEY ("environmentId") REFERENCES "environment"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
325
|
-
|
|
326
288
|
-- AddForeignKey
|
|
327
289
|
ALTER TABLE "egress_grant" ADD CONSTRAINT "egress_grant_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
328
290
|
|
|
329
291
|
-- AddForeignKey
|
|
330
292
|
ALTER TABLE "egress_grant" ADD CONSTRAINT "egress_grant_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
331
|
-
|
|
332
|
-
-- A personal connection has no tenant, and Postgres treats NULLs as distinct,
|
|
333
|
-
-- so the unique index above does not constrain one. Prisma cannot declare a
|
|
334
|
-
-- partial index, so it is written here by hand.
|
|
335
|
-
CREATE UNIQUE INDEX "account_personal_connection_key"
|
|
336
|
-
ON "account" ("environmentId", "userId", "providerId")
|
|
337
|
-
WHERE "organizationExternalId" IS NULL;
|
|
338
|
-
|
|
339
|
-
-- A credential belongs to a person or to a tenant. userId is nullable so that
|
|
340
|
-
-- deleting the person who pasted a tenant's key does not delete the key, which
|
|
341
|
-
-- is the tenant's rather than theirs; this check stops that leaving a row
|
|
342
|
-
-- belonging to nobody. Deleting someone who holds personal connections fails
|
|
343
|
-
-- here until those rows are dealt with explicitly.
|
|
344
|
-
ALTER TABLE "account" ADD CONSTRAINT "account_has_an_owner"
|
|
345
|
-
CHECK ("userId" IS NOT NULL OR "organizationExternalId" IS NOT NULL);
|
package/prisma/schema.prisma
CHANGED
|
@@ -21,8 +21,6 @@ model User {
|
|
|
21
21
|
createdAt DateTime @default(now())
|
|
22
22
|
updatedAt DateTime @updatedAt
|
|
23
23
|
|
|
24
|
-
externalId String?
|
|
25
|
-
|
|
26
24
|
sessions Session[]
|
|
27
25
|
accounts Account[]
|
|
28
26
|
members Member[]
|
|
@@ -30,7 +28,6 @@ model User {
|
|
|
30
28
|
teamMembers TeamMember[]
|
|
31
29
|
egressGrants EgressGrant[]
|
|
32
30
|
|
|
33
|
-
@@index([externalId])
|
|
34
31
|
@@map("user")
|
|
35
32
|
}
|
|
36
33
|
|
|
@@ -55,8 +52,8 @@ model Account {
|
|
|
55
52
|
id String @id
|
|
56
53
|
accountId String
|
|
57
54
|
providerId String
|
|
58
|
-
userId String
|
|
59
|
-
user User
|
|
55
|
+
userId String
|
|
56
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
60
57
|
accessToken String?
|
|
61
58
|
refreshToken String?
|
|
62
59
|
idToken String?
|
|
@@ -67,20 +64,8 @@ model Account {
|
|
|
67
64
|
createdAt DateTime @default(now())
|
|
68
65
|
updatedAt DateTime @updatedAt
|
|
69
66
|
|
|
70
|
-
environmentId String?
|
|
71
|
-
environment Environment? @relation(fields: [environmentId], references: [id], onDelete: Cascade)
|
|
72
|
-
organizationExternalId String?
|
|
73
|
-
|
|
74
|
-
/// Per-connection provider parameters, for providers that need any: the
|
|
75
|
-
/// Jira site, the Zendesk subdomain. Non-secret, and held on the connection
|
|
76
|
-
/// rather than on the configuration because one OAuth app serves every
|
|
77
|
-
/// tenant. Null on a Kosha login, like every other column here.
|
|
78
|
-
connectionConfig Json?
|
|
79
|
-
|
|
80
|
-
@@unique([environmentId, organizationExternalId, providerId])
|
|
81
67
|
@@index([userId])
|
|
82
68
|
@@index([providerId])
|
|
83
|
-
@@index([environmentId, organizationExternalId])
|
|
84
69
|
@@map("account")
|
|
85
70
|
}
|
|
86
71
|
|
|
@@ -219,38 +204,12 @@ model Environment {
|
|
|
219
204
|
createdAt DateTime @default(now())
|
|
220
205
|
updatedAt DateTime @updatedAt
|
|
221
206
|
|
|
222
|
-
configurations Configuration[]
|
|
223
|
-
accounts Account[]
|
|
224
|
-
|
|
225
207
|
@@unique([organizationId, slug])
|
|
226
208
|
@@index([organizationId])
|
|
227
209
|
@@index([teamId])
|
|
228
210
|
@@map("environment")
|
|
229
211
|
}
|
|
230
212
|
|
|
231
|
-
model Configuration {
|
|
232
|
-
id String @id @default(cuid())
|
|
233
|
-
environmentId String
|
|
234
|
-
environment Environment @relation(fields: [environmentId], references: [id], onDelete: Cascade)
|
|
235
|
-
|
|
236
|
-
integrationKey String
|
|
237
|
-
authType String
|
|
238
|
-
|
|
239
|
-
name String
|
|
240
|
-
slug String
|
|
241
|
-
|
|
242
|
-
credentials String?
|
|
243
|
-
settings Json?
|
|
244
|
-
|
|
245
|
-
isEnabled Boolean @default(true)
|
|
246
|
-
createdAt DateTime @default(now())
|
|
247
|
-
updatedAt DateTime @updatedAt
|
|
248
|
-
|
|
249
|
-
@@unique([environmentId, slug])
|
|
250
|
-
@@index([environmentId])
|
|
251
|
-
@@map("configuration")
|
|
252
|
-
}
|
|
253
|
-
|
|
254
213
|
model EgressGrant {
|
|
255
214
|
id String @id @default(cuid())
|
|
256
215
|
organizationId String
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { Configuration, Prisma } from '../generated/prisma/client.js';
|
|
2
|
-
import { PrismaService } from '../prisma/prisma.service.js';
|
|
3
|
-
export interface ConfigurationRow {
|
|
4
|
-
environmentId: string;
|
|
5
|
-
integrationKey: string;
|
|
6
|
-
authType: string;
|
|
7
|
-
name: string;
|
|
8
|
-
slug: string;
|
|
9
|
-
credentials: string | null;
|
|
10
|
-
settings: Prisma.InputJsonValue | undefined;
|
|
11
|
-
}
|
|
12
|
-
/** A configuration as a client may see it: everything but the secrets. */
|
|
13
|
-
export type PublicConfiguration = Omit<Configuration, 'credentials'>;
|
|
14
|
-
export interface ConfigurationChanges {
|
|
15
|
-
name?: string;
|
|
16
|
-
/** Null clears the stored secrets; undefined leaves them alone. */
|
|
17
|
-
credentials?: string | null;
|
|
18
|
-
settings?: Prisma.InputJsonValue;
|
|
19
|
-
isEnabled?: boolean;
|
|
20
|
-
}
|
|
21
|
-
export declare class ConfigurationsRepository {
|
|
22
|
-
private readonly prisma;
|
|
23
|
-
constructor(prisma: PrismaService);
|
|
24
|
-
findManyByEnvironment(environmentId: string): Promise<PublicConfiguration[]>;
|
|
25
|
-
findById(environmentId: string, id: string): Promise<PublicConfiguration | null>;
|
|
26
|
-
/** How a caller's slug becomes the row the proxy and connect flows use. */
|
|
27
|
-
findBySlug(environmentId: string, slug: string): Promise<PublicConfiguration | null>;
|
|
28
|
-
/**
|
|
29
|
-
* The one read that keeps the secrets, for the connect and proxy paths.
|
|
30
|
-
* Never reachable from a controller.
|
|
31
|
-
*/
|
|
32
|
-
findAnyById(id: string): Promise<Configuration | null>;
|
|
33
|
-
create(row: ConfigurationRow): Promise<PublicConfiguration>;
|
|
34
|
-
update(id: string, changes: ConfigurationChanges): Promise<PublicConfiguration>;
|
|
35
|
-
delete(id: string): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Credentials pointing at this configuration. `account.providerId` holds the
|
|
38
|
-
* id as a plain string, so this count is what stands in for the foreign key
|
|
39
|
-
* the design gave up.
|
|
40
|
-
*/
|
|
41
|
-
countCredentials(configurationId: string): Promise<number>;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=configurations.repository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configurations.repository.d.ts","sourceRoot":"","sources":["../../src/configurations/configurations.repository.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC,cAAc,GAAG,SAAS,CAAC;CAC7C;AAED,0EAA0E;AAC1E,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAErE,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAWD,qBACa,wBAAwB;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAQ5E,QAAQ,CACN,aAAa,EAAE,MAAM,EACrB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAOtC,2EAA2E;IAC3E,UAAU,CACR,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAOtC;;;OAGG;IACH,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAItD,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO3D,MAAM,CACJ,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC;IAQzB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC;;;;OAIG;IACH,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAK3D"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { Injectable } from '@nestjs/common';
|
|
3
|
-
import { PrismaService } from '../prisma/prisma.service.js';
|
|
4
|
-
/**
|
|
5
|
-
* `credentials` is ciphertext by the time it reaches here, and stays ciphertext
|
|
6
|
-
* on the way out. Nothing in this file can read a secret.
|
|
7
|
-
*
|
|
8
|
-
* Every read that can reach a client leaves the column out entirely. Ciphertext
|
|
9
|
-
* is not plaintext, but there is no reason for a browser to hold it, and the
|
|
10
|
-
* one path that needs the secrets asks for them by name.
|
|
11
|
-
*/
|
|
12
|
-
const WITHOUT_SECRETS = { credentials: true };
|
|
13
|
-
let ConfigurationsRepository = class ConfigurationsRepository {
|
|
14
|
-
prisma;
|
|
15
|
-
constructor(prisma) {
|
|
16
|
-
this.prisma = prisma;
|
|
17
|
-
}
|
|
18
|
-
findManyByEnvironment(environmentId) {
|
|
19
|
-
return this.prisma.configuration.findMany({
|
|
20
|
-
where: { environmentId },
|
|
21
|
-
omit: WITHOUT_SECRETS,
|
|
22
|
-
orderBy: { createdAt: 'desc' },
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
findById(environmentId, id) {
|
|
26
|
-
return this.prisma.configuration.findFirst({
|
|
27
|
-
where: { id, environmentId },
|
|
28
|
-
omit: WITHOUT_SECRETS,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
/** How a caller's slug becomes the row the proxy and connect flows use. */
|
|
32
|
-
findBySlug(environmentId, slug) {
|
|
33
|
-
return this.prisma.configuration.findFirst({
|
|
34
|
-
where: { environmentId, slug },
|
|
35
|
-
omit: WITHOUT_SECRETS,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* The one read that keeps the secrets, for the connect and proxy paths.
|
|
40
|
-
* Never reachable from a controller.
|
|
41
|
-
*/
|
|
42
|
-
findAnyById(id) {
|
|
43
|
-
return this.prisma.configuration.findUnique({ where: { id } });
|
|
44
|
-
}
|
|
45
|
-
create(row) {
|
|
46
|
-
return this.prisma.configuration.create({
|
|
47
|
-
data: row,
|
|
48
|
-
omit: WITHOUT_SECRETS,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
update(id, changes) {
|
|
52
|
-
return this.prisma.configuration.update({
|
|
53
|
-
where: { id },
|
|
54
|
-
data: changes,
|
|
55
|
-
omit: WITHOUT_SECRETS,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
async delete(id) {
|
|
59
|
-
await this.prisma.configuration.delete({ where: { id } });
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Credentials pointing at this configuration. `account.providerId` holds the
|
|
63
|
-
* id as a plain string, so this count is what stands in for the foreign key
|
|
64
|
-
* the design gave up.
|
|
65
|
-
*/
|
|
66
|
-
countCredentials(configurationId) {
|
|
67
|
-
return this.prisma.account.count({
|
|
68
|
-
where: { providerId: configurationId },
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
ConfigurationsRepository = __decorate([
|
|
73
|
-
Injectable(),
|
|
74
|
-
__metadata("design:paramtypes", [PrismaService])
|
|
75
|
-
], ConfigurationsRepository);
|
|
76
|
-
export { ConfigurationsRepository };
|