@kosha-ai/server 0.1.0 → 1.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/dist/auth/api-key.guard.d.ts +7 -2
- package/dist/auth/api-key.guard.d.ts.map +1 -1
- package/dist/auth/api-key.guard.js +28 -8
- package/dist/auth/auth.factory.d.ts +15 -1
- package/dist/auth/auth.factory.d.ts.map +1 -1
- package/dist/auth/auth.factory.js +48 -2
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +24 -6
- package/dist/configurations/configurations.controller.d.ts +11 -136
- package/dist/configurations/configurations.controller.d.ts.map +1 -1
- package/dist/configurations/configurations.controller.js +58 -25
- package/dist/configurations/configurations.module.d.ts.map +1 -1
- package/dist/configurations/configurations.module.js +4 -1
- package/dist/configurations/configurations.repository.d.ts +43 -0
- package/dist/configurations/configurations.repository.d.ts.map +1 -0
- package/dist/configurations/configurations.repository.js +76 -0
- package/dist/configurations/configurations.service.d.ts +38 -194
- package/dist/configurations/configurations.service.d.ts.map +1 -1
- package/dist/configurations/configurations.service.js +118 -110
- package/dist/configurations/dto/create-configuration.dto.d.ts +8 -0
- package/dist/configurations/dto/create-configuration.dto.d.ts.map +1 -0
- package/dist/configurations/dto/create-configuration.dto.js +54 -0
- package/dist/configurations/dto/update-configuration.dto.d.ts +7 -0
- package/dist/configurations/dto/update-configuration.dto.d.ts.map +1 -0
- package/dist/configurations/dto/update-configuration.dto.js +39 -0
- package/dist/connect/connect.controller.d.ts +6 -8
- package/dist/connect/connect.controller.d.ts.map +1 -1
- package/dist/connect/connect.controller.js +45 -15
- package/dist/connect/connect.module.d.ts.map +1 -1
- package/dist/connect/connect.module.js +4 -2
- package/dist/connect/connect.repository.d.ts +78 -0
- package/dist/connect/connect.repository.d.ts.map +1 -0
- package/dist/connect/connect.repository.js +146 -0
- package/dist/connect/connect.service.d.ts +28 -19
- package/dist/connect/connect.service.d.ts.map +1 -1
- package/dist/connect/connect.service.js +149 -163
- package/dist/connect/dto/create-connect-session.dto.d.ts +8 -0
- package/dist/connect/dto/create-connect-session.dto.d.ts.map +1 -0
- package/dist/connect/dto/create-connect-session.dto.js +55 -0
- package/dist/connect/dto/create-test-session.dto.d.ts +10 -0
- package/dist/connect/dto/create-test-session.dto.d.ts.map +1 -0
- package/dist/connect/dto/create-test-session.dto.js +34 -0
- package/dist/connections/connections.controller.d.ts +8 -61
- package/dist/connections/connections.controller.d.ts.map +1 -1
- package/dist/connections/connections.controller.js +31 -9
- package/dist/connections/connections.module.d.ts.map +1 -1
- package/dist/connections/connections.module.js +4 -1
- package/dist/connections/connections.repository.d.ts +24 -0
- package/dist/connections/connections.repository.d.ts.map +1 -0
- package/dist/connections/connections.repository.js +66 -0
- package/dist/connections/connections.service.d.ts +24 -69
- package/dist/connections/connections.service.d.ts.map +1 -1
- package/dist/connections/connections.service.js +59 -56
- package/dist/connections/dto/list-connections.dto.d.ts +5 -0
- package/dist/connections/dto/list-connections.dto.d.ts.map +1 -0
- package/dist/connections/dto/list-connections.dto.js +25 -0
- package/dist/connections/environment-connections.controller.d.ts +26 -0
- package/dist/connections/environment-connections.controller.d.ts.map +1 -0
- package/dist/connections/environment-connections.controller.js +81 -0
- package/dist/connections/environment-connections.module.d.ts +11 -0
- package/dist/connections/environment-connections.module.d.ts.map +1 -0
- package/dist/connections/environment-connections.module.js +21 -0
- package/dist/credentials/credentials.module.js +3 -3
- package/dist/credentials/credentials.repository.d.ts +8 -0
- package/dist/credentials/credentials.repository.d.ts.map +1 -0
- package/dist/credentials/credentials.repository.js +21 -0
- package/dist/credentials/credentials.service.d.ts +19 -29
- package/dist/credentials/credentials.service.d.ts.map +1 -1
- package/dist/credentials/credentials.service.js +84 -57
- package/dist/crypto/credential-envelope.d.ts +56 -0
- package/dist/crypto/credential-envelope.d.ts.map +1 -0
- package/dist/crypto/credential-envelope.js +70 -0
- package/dist/crypto/crypto.service.d.ts +8 -0
- package/dist/crypto/crypto.service.d.ts.map +1 -1
- package/dist/crypto/crypto.service.js +12 -0
- package/dist/egress/dto/mint-grant.dto.d.ts +7 -0
- package/dist/egress/dto/mint-grant.dto.d.ts.map +1 -0
- package/dist/egress/dto/mint-grant.dto.js +44 -0
- package/dist/egress/egress.controller.d.ts +2 -8
- package/dist/egress/egress.controller.d.ts.map +1 -1
- package/dist/egress/egress.controller.js +27 -6
- package/dist/egress/egress.listener.d.ts +3 -1
- package/dist/egress/egress.listener.d.ts.map +1 -1
- package/dist/egress/egress.listener.js +12 -8
- package/dist/egress/egress.module.d.ts.map +1 -1
- package/dist/egress/egress.module.js +10 -2
- package/dist/egress/egress.repository.d.ts +58 -0
- package/dist/egress/egress.repository.d.ts.map +1 -0
- package/dist/egress/egress.repository.js +116 -0
- package/dist/egress/grants.service.d.ts +23 -78
- package/dist/egress/grants.service.d.ts.map +1 -1
- package/dist/egress/grants.service.js +44 -104
- package/dist/environments/dto/create-environment.dto.d.ts +6 -0
- package/dist/environments/dto/create-environment.dto.d.ts.map +1 -0
- package/dist/environments/dto/create-environment.dto.js +34 -0
- package/dist/environments/dto/update-environment.dto.d.ts +5 -0
- package/dist/environments/dto/update-environment.dto.d.ts.map +1 -0
- package/dist/environments/dto/update-environment.dto.js +24 -0
- package/dist/environments/environments.controller.d.ts +53 -0
- package/dist/environments/environments.controller.d.ts.map +1 -0
- package/dist/environments/environments.controller.js +101 -0
- package/dist/environments/environments.module.d.ts +3 -0
- package/dist/environments/environments.module.d.ts.map +1 -0
- package/dist/environments/environments.module.js +15 -0
- package/dist/environments/environments.repository.d.ts +37 -0
- package/dist/environments/environments.repository.d.ts.map +1 -0
- package/dist/environments/environments.repository.js +82 -0
- package/dist/environments/environments.service.d.ts +43 -0
- package/dist/environments/environments.service.d.ts.map +1 -0
- package/dist/environments/environments.service.js +124 -0
- package/dist/generated/prisma/browser.d.ts +14 -37
- package/dist/generated/prisma/browser.d.ts.map +1 -1
- package/dist/generated/prisma/client.d.ts +14 -37
- package/dist/generated/prisma/client.d.ts.map +1 -1
- package/dist/generated/prisma/commonInputTypes.d.ts +104 -145
- package/dist/generated/prisma/commonInputTypes.d.ts.map +1 -1
- package/dist/generated/prisma/enums.d.ts +1 -21
- package/dist/generated/prisma/enums.d.ts.map +1 -1
- package/dist/generated/prisma/enums.js +1 -18
- package/dist/generated/prisma/internal/class.d.ts +20 -53
- 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 +215 -519
- package/dist/generated/prisma/internal/prismaNamespace.d.ts.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespace.js +38 -90
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +37 -92
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.js +38 -90
- package/dist/generated/prisma/models/Account.d.ts +344 -26
- package/dist/generated/prisma/models/Account.d.ts.map +1 -1
- package/dist/generated/prisma/models/Configuration.d.ts +218 -851
- package/dist/generated/prisma/models/Configuration.d.ts.map +1 -1
- package/dist/generated/prisma/models/EgressGrant.d.ts +131 -134
- package/dist/generated/prisma/models/EgressGrant.d.ts.map +1 -1
- package/dist/generated/prisma/models/Environment.d.ts +1644 -0
- package/dist/generated/prisma/models/Environment.d.ts.map +1 -0
- package/dist/generated/prisma/models/Invitation.d.ts +42 -1
- package/dist/generated/prisma/models/Invitation.d.ts.map +1 -1
- package/dist/generated/prisma/models/Organization.d.ts +122 -408
- package/dist/generated/prisma/models/Organization.d.ts.map +1 -1
- package/dist/generated/prisma/models/Session.d.ts +36 -1
- package/dist/generated/prisma/models/Session.d.ts.map +1 -1
- package/dist/generated/prisma/models/Team.d.ts +1498 -0
- package/dist/generated/prisma/models/Team.d.ts.map +1 -0
- package/dist/generated/prisma/models/TeamMember.d.ts +1281 -0
- package/dist/generated/prisma/models/TeamMember.d.ts.map +1 -0
- package/dist/generated/prisma/models/User.d.ts +338 -2
- package/dist/generated/prisma/models/User.d.ts.map +1 -1
- package/dist/generated/prisma/models.d.ts +3 -6
- package/dist/generated/prisma/models.d.ts.map +1 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/integrations/integrations.controller.d.ts +2 -1
- package/dist/integrations/integrations.controller.d.ts.map +1 -1
- package/dist/integrations/integrations.module.d.ts.map +1 -1
- package/dist/integrations/integrations.module.js +0 -2
- package/dist/kosha.module.d.ts.map +1 -1
- package/dist/kosha.module.js +9 -3
- package/dist/proxy/proxy.controller.d.ts +8 -3
- package/dist/proxy/proxy.controller.d.ts.map +1 -1
- package/dist/proxy/proxy.controller.js +26 -10
- package/dist/proxy/proxy.module.d.ts.map +1 -1
- package/dist/proxy/proxy.module.js +5 -2
- package/dist/proxy/proxy.repository.d.ts +24 -0
- package/dist/proxy/proxy.repository.d.ts.map +1 -0
- package/dist/proxy/proxy.repository.js +47 -0
- package/dist/proxy/proxy.service.d.ts +17 -5
- package/dist/proxy/proxy.service.d.ts.map +1 -1
- package/dist/proxy/proxy.service.js +58 -27
- package/package.json +7 -4
- package/prisma/migrations/20260929101936_init/migration.sql +345 -0
- package/prisma/migrations/20260930102529_connection_config/migration.sql +2 -0
- package/prisma/schema.prisma +93 -198
- package/dist/generated/prisma/models/ConnectSession.d.ts +0 -1606
- package/dist/generated/prisma/models/ConnectSession.d.ts.map +0 -1
- package/dist/generated/prisma/models/Connection.d.ts +0 -1949
- package/dist/generated/prisma/models/Connection.d.ts.map +0 -1
- package/dist/generated/prisma/models/ConnectionCredential.d.ts +0 -1293
- package/dist/generated/prisma/models/ConnectionCredential.d.ts.map +0 -1
- package/dist/generated/prisma/models/EndUser.d.ts +0 -1666
- package/dist/generated/prisma/models/EndUser.d.ts.map +0 -1
- package/dist/generated/prisma/models/EndUser.js +0 -1
- package/dist/generated/prisma/models/OAuthState.d.ts +0 -1404
- package/dist/generated/prisma/models/OAuthState.d.ts.map +0 -1
- package/dist/generated/prisma/models/OAuthState.js +0 -1
- package/dist/generated/prisma/models/Provider.d.ts +0 -1462
- package/dist/generated/prisma/models/Provider.d.ts.map +0 -1
- package/dist/generated/prisma/models/Provider.js +0 -1
- package/dist/integrations/provider-sync.service.d.ts +0 -24
- package/dist/integrations/provider-sync.service.d.ts.map +0 -1
- package/dist/integrations/provider-sync.service.js +0 -74
- package/prisma/migrations/20260908000000_init/migration.sql +0 -209
- package/prisma/migrations/20260908161813_add_connect_domain/migration.sql +0 -173
- package/prisma/migrations/20260916000000_add_configuration_slug/migration.sql +0 -15
- package/prisma/migrations/20260921000000_add_egress_grant/migration.sql +0 -31
- /package/dist/generated/prisma/models/{ConnectSession.js → Environment.js} +0 -0
- /package/dist/generated/prisma/models/{Connection.js → Team.js} +0 -0
- /package/dist/generated/prisma/models/{ConnectionCredential.js → TeamMember.js} +0 -0
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
-
import { Controller, Delete, Get, Param, Query, Req, UseGuards, } from '@nestjs/common';
|
|
2
|
+
import { BadRequestException, Controller, Delete, Get, Param, Query, Req, UseGuards, } from '@nestjs/common';
|
|
3
|
+
import { ApiOkResponse, ApiOperation, ApiSecurity, ApiTags, } from '@nestjs/swagger';
|
|
3
4
|
import { AllowAnonymous } from '@thallesp/nestjs-better-auth';
|
|
4
5
|
import { OrgAuthGuard } from '../auth/api-key.guard.js';
|
|
5
6
|
import { ConnectionsService } from './connections.service.js';
|
|
7
|
+
import { ListConnectionsDto } from './dto/list-connections.dto.js';
|
|
8
|
+
/**
|
|
9
|
+
* The environment comes from the API key, so a caller only ever sees the
|
|
10
|
+
* connections of the environment its key reaches.
|
|
11
|
+
*/
|
|
6
12
|
let ConnectionsController = class ConnectionsController {
|
|
7
13
|
connections;
|
|
8
14
|
constructor(connections) {
|
|
9
15
|
this.connections = connections;
|
|
10
16
|
}
|
|
11
|
-
list(request,
|
|
12
|
-
return this.connections.list(request.organizationId,
|
|
13
|
-
endUserExternalId,
|
|
14
|
-
});
|
|
17
|
+
list(request, filters) {
|
|
18
|
+
return this.connections.list(request.organizationId, environmentOf(request), filters);
|
|
15
19
|
}
|
|
16
20
|
get(request, id) {
|
|
17
|
-
return this.connections.get(request.organizationId, id);
|
|
21
|
+
return this.connections.get(request.organizationId, environmentOf(request), id);
|
|
18
22
|
}
|
|
19
23
|
revoke(request, id) {
|
|
20
|
-
return this.connections.revoke(request.organizationId, id);
|
|
24
|
+
return this.connections.revoke(request.organizationId, environmentOf(request), id);
|
|
21
25
|
}
|
|
22
26
|
};
|
|
23
27
|
__decorate([
|
|
24
28
|
Get(),
|
|
29
|
+
ApiOperation({
|
|
30
|
+
summary: 'List the connections in this environment',
|
|
31
|
+
description: 'Grouped by the tenant that owns them, so a consuming app’s customers sit together.',
|
|
32
|
+
}),
|
|
33
|
+
ApiOkResponse({ description: 'Connections. Never carries a credential.' }),
|
|
25
34
|
__param(0, Req()),
|
|
26
|
-
__param(1, Query(
|
|
35
|
+
__param(1, Query()),
|
|
27
36
|
__metadata("design:type", Function),
|
|
28
|
-
__metadata("design:paramtypes", [Object,
|
|
37
|
+
__metadata("design:paramtypes", [Object, ListConnectionsDto]),
|
|
29
38
|
__metadata("design:returntype", void 0)
|
|
30
39
|
], ConnectionsController.prototype, "list", null);
|
|
31
40
|
__decorate([
|
|
32
41
|
Get(':id'),
|
|
42
|
+
ApiOperation({ summary: 'Get one connection' }),
|
|
33
43
|
__param(0, Req()),
|
|
34
44
|
__param(1, Param('id')),
|
|
35
45
|
__metadata("design:type", Function),
|
|
@@ -38,6 +48,10 @@ __decorate([
|
|
|
38
48
|
], ConnectionsController.prototype, "get", null);
|
|
39
49
|
__decorate([
|
|
40
50
|
Delete(':id'),
|
|
51
|
+
ApiOperation({
|
|
52
|
+
summary: 'Revoke a connection',
|
|
53
|
+
description: 'Deletes the credential. The row is the credential, so keeping it would only leave ciphertext nobody can use.',
|
|
54
|
+
}),
|
|
41
55
|
__param(0, Req()),
|
|
42
56
|
__param(1, Param('id')),
|
|
43
57
|
__metadata("design:type", Function),
|
|
@@ -45,9 +59,17 @@ __decorate([
|
|
|
45
59
|
__metadata("design:returntype", void 0)
|
|
46
60
|
], ConnectionsController.prototype, "revoke", null);
|
|
47
61
|
ConnectionsController = __decorate([
|
|
62
|
+
ApiTags('connections'),
|
|
63
|
+
ApiSecurity('x-api-key'),
|
|
48
64
|
Controller('connections'),
|
|
49
65
|
AllowAnonymous(),
|
|
50
66
|
UseGuards(OrgAuthGuard),
|
|
51
67
|
__metadata("design:paramtypes", [ConnectionsService])
|
|
52
68
|
], ConnectionsController);
|
|
53
69
|
export { ConnectionsController };
|
|
70
|
+
function environmentOf(request) {
|
|
71
|
+
if (!request.environmentId) {
|
|
72
|
+
throw new BadRequestException('This route needs an API key, which is what names the environment');
|
|
73
|
+
}
|
|
74
|
+
return request.environmentId;
|
|
75
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connections.module.d.ts","sourceRoot":"","sources":["../../src/connections/connections.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connections.module.d.ts","sourceRoot":"","sources":["../../src/connections/connections.module.ts"],"names":[],"mappings":"AAMA,qBAMa,iBAAiB;CAAG"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { Module } from '@nestjs/common';
|
|
3
|
+
import { EnvironmentsModule } from '../environments/environments.module.js';
|
|
3
4
|
import { ConnectionsController } from './connections.controller.js';
|
|
5
|
+
import { ConnectionsRepository } from './connections.repository.js';
|
|
4
6
|
import { ConnectionsService } from './connections.service.js';
|
|
5
7
|
let ConnectionsModule = class ConnectionsModule {
|
|
6
8
|
};
|
|
7
9
|
ConnectionsModule = __decorate([
|
|
8
10
|
Module({
|
|
11
|
+
imports: [EnvironmentsModule],
|
|
9
12
|
controllers: [ConnectionsController],
|
|
10
|
-
providers: [ConnectionsService],
|
|
13
|
+
providers: [ConnectionsService, ConnectionsRepository],
|
|
11
14
|
exports: [ConnectionsService],
|
|
12
15
|
})
|
|
13
16
|
], ConnectionsModule);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Account } from '../generated/prisma/client.js';
|
|
2
|
+
import { PrismaService } from '../prisma/prisma.service.js';
|
|
3
|
+
/** A credential as the admin lists it. Never carries the envelope. */
|
|
4
|
+
export type ListedConnection = Omit<Account, 'accessToken' | 'refreshToken' | 'idToken' | 'password' | 'scope'> & {
|
|
5
|
+
user: {
|
|
6
|
+
externalId: string | null;
|
|
7
|
+
} | null;
|
|
8
|
+
};
|
|
9
|
+
export declare class ConnectionsRepository {
|
|
10
|
+
private readonly prisma;
|
|
11
|
+
constructor(prisma: PrismaService);
|
|
12
|
+
findMany(environmentId: string, filters?: {
|
|
13
|
+
organizationExternalId?: string;
|
|
14
|
+
providerId?: string;
|
|
15
|
+
}): Promise<ListedConnection[]>;
|
|
16
|
+
findById(environmentId: string, id: string): Promise<ListedConnection | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Revoking deletes the row. The row is the credential — there is no separate
|
|
19
|
+
* connection to keep — so marking it revoked would leave ciphertext behind
|
|
20
|
+
* for no one to use.
|
|
21
|
+
*/
|
|
22
|
+
delete(environmentId: string, id: string): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=connections.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.repository.d.ts","sourceRoot":"","sources":["../../src/connections/connections.repository.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAU,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,sEAAsE;AACtE,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,OAAO,EACP,aAAa,GAAG,cAAc,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,CAClE,GAAG;IACF,IAAI,EAAE;QAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CAC5C,CAAC;AAyBF,qBACa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,QAAQ,CACN,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE;QAAE,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO,GACrE,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAe9B,QAAQ,CACN,aAAa,EAAE,MAAM,EACrB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAQnC;;;;OAIG;IACG,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAK/D"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
|
+
import { PrismaService } from '../prisma/prisma.service.js';
|
|
4
|
+
/**
|
|
5
|
+
* `accessToken` holds the encrypted envelope, so every read here leaves it
|
|
6
|
+
* out. A listing has no reason to carry ciphertext to a browser.
|
|
7
|
+
*/
|
|
8
|
+
const WITHOUT_SECRETS = {
|
|
9
|
+
accessToken: true,
|
|
10
|
+
refreshToken: true,
|
|
11
|
+
idToken: true,
|
|
12
|
+
password: true,
|
|
13
|
+
scope: true,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A Kosha login and a provider credential share this table. Naming an
|
|
17
|
+
* environment is what separates them: a login carries none, so filtering on a
|
|
18
|
+
* specific environment can never reach one. That is the predicate every read
|
|
19
|
+
* and delete here goes through, so nothing about connections can touch
|
|
20
|
+
* somebody's ability to sign in.
|
|
21
|
+
*/
|
|
22
|
+
function connectionsIn(environmentId) {
|
|
23
|
+
return { environmentId };
|
|
24
|
+
}
|
|
25
|
+
let ConnectionsRepository = class ConnectionsRepository {
|
|
26
|
+
prisma;
|
|
27
|
+
constructor(prisma) {
|
|
28
|
+
this.prisma = prisma;
|
|
29
|
+
}
|
|
30
|
+
findMany(environmentId, filters = {}) {
|
|
31
|
+
return this.prisma.account.findMany({
|
|
32
|
+
where: {
|
|
33
|
+
...connectionsIn(environmentId),
|
|
34
|
+
...(filters.organizationExternalId
|
|
35
|
+
? { organizationExternalId: filters.organizationExternalId }
|
|
36
|
+
: {}),
|
|
37
|
+
...(filters.providerId ? { providerId: filters.providerId } : {}),
|
|
38
|
+
},
|
|
39
|
+
omit: WITHOUT_SECRETS,
|
|
40
|
+
include: { user: { select: { externalId: true } } },
|
|
41
|
+
orderBy: [{ organizationExternalId: 'asc' }, { createdAt: 'desc' }],
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
findById(environmentId, id) {
|
|
45
|
+
return this.prisma.account.findFirst({
|
|
46
|
+
where: { id, ...connectionsIn(environmentId) },
|
|
47
|
+
omit: WITHOUT_SECRETS,
|
|
48
|
+
include: { user: { select: { externalId: true } } },
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Revoking deletes the row. The row is the credential — there is no separate
|
|
53
|
+
* connection to keep — so marking it revoked would leave ciphertext behind
|
|
54
|
+
* for no one to use.
|
|
55
|
+
*/
|
|
56
|
+
async delete(environmentId, id) {
|
|
57
|
+
await this.prisma.account.deleteMany({
|
|
58
|
+
where: { id, ...connectionsIn(environmentId) },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
ConnectionsRepository = __decorate([
|
|
63
|
+
Injectable(),
|
|
64
|
+
__metadata("design:paramtypes", [PrismaService])
|
|
65
|
+
], ConnectionsRepository);
|
|
66
|
+
export { ConnectionsRepository };
|
|
@@ -1,76 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnvironmentsService } from '../environments/environments.service.js';
|
|
2
|
+
import { ConnectionsRepository, type ListedConnection } from './connections.repository.js';
|
|
3
|
+
export interface ListConnectionsFilters {
|
|
4
|
+
organizationExternalId?: string;
|
|
5
|
+
configurationId?: string;
|
|
6
|
+
}
|
|
2
7
|
export declare class ConnectionsService {
|
|
3
|
-
private readonly
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
configuration: {
|
|
9
|
-
name: string;
|
|
10
|
-
id: string;
|
|
11
|
-
provider: {
|
|
12
|
-
name: string;
|
|
13
|
-
key: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
endUser: {
|
|
17
|
-
name: string | null;
|
|
18
|
-
email: string | null;
|
|
19
|
-
externalId: string;
|
|
20
|
-
};
|
|
21
|
-
} & {
|
|
22
|
-
id: string;
|
|
23
|
-
createdAt: Date;
|
|
24
|
-
updatedAt: Date;
|
|
25
|
-
status: import("../generated/prisma/enums.js").ConnectionStatus;
|
|
26
|
-
metadata: import("@prisma/client/runtime/client").JsonValue | null;
|
|
27
|
-
scopes: string[];
|
|
28
|
-
organizationId: string;
|
|
29
|
-
endUserId: string;
|
|
30
|
-
configurationId: string;
|
|
31
|
-
label: string | null;
|
|
32
|
-
externalAccountId: string | null;
|
|
33
|
-
lastSyncedAt: Date | null;
|
|
34
|
-
lastUsedAt: Date | null;
|
|
35
|
-
errorMessage: string | null;
|
|
36
|
-
})[]>;
|
|
37
|
-
get(organizationId: string, id: string): Promise<{
|
|
38
|
-
configuration: {
|
|
39
|
-
name: string;
|
|
40
|
-
id: string;
|
|
41
|
-
provider: {
|
|
42
|
-
name: string;
|
|
43
|
-
key: string;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
endUser: {
|
|
47
|
-
name: string | null;
|
|
48
|
-
email: string | null;
|
|
49
|
-
externalId: string;
|
|
50
|
-
};
|
|
51
|
-
} & {
|
|
52
|
-
id: string;
|
|
53
|
-
createdAt: Date;
|
|
54
|
-
updatedAt: Date;
|
|
55
|
-
status: import("../generated/prisma/enums.js").ConnectionStatus;
|
|
56
|
-
metadata: import("@prisma/client/runtime/client").JsonValue | null;
|
|
57
|
-
scopes: string[];
|
|
58
|
-
organizationId: string;
|
|
59
|
-
endUserId: string;
|
|
60
|
-
configurationId: string;
|
|
61
|
-
label: string | null;
|
|
62
|
-
externalAccountId: string | null;
|
|
63
|
-
lastSyncedAt: Date | null;
|
|
64
|
-
lastUsedAt: Date | null;
|
|
65
|
-
errorMessage: string | null;
|
|
66
|
-
}>;
|
|
8
|
+
private readonly connections;
|
|
9
|
+
private readonly environments;
|
|
10
|
+
constructor(connections: ConnectionsRepository, environments: EnvironmentsService);
|
|
11
|
+
list(organizationId: string, environmentId: string, filters?: ListConnectionsFilters): Promise<ListedConnection[]>;
|
|
12
|
+
get(organizationId: string, environmentId: string, id: string): Promise<ListedConnection>;
|
|
67
13
|
/**
|
|
68
|
-
* Deletes the
|
|
69
|
-
*
|
|
14
|
+
* Deletes the credential. The row is the credential, so there is no history
|
|
15
|
+
* to preserve by keeping it — only ciphertext nobody can use.
|
|
70
16
|
*/
|
|
71
|
-
revoke(organizationId: string, id: string): Promise<{
|
|
17
|
+
revoke(organizationId: string, environmentId: string, id: string): Promise<{
|
|
18
|
+
id: string;
|
|
19
|
+
revoked: true;
|
|
20
|
+
}>;
|
|
21
|
+
listForMember(organizationId: string, userId: string, environmentId: string, filters?: ListConnectionsFilters): Promise<ListedConnection[]>;
|
|
22
|
+
getForMember(organizationId: string, userId: string, environmentId: string, id: string): Promise<ListedConnection>;
|
|
23
|
+
revokeForMember(organizationId: string, userId: string, environmentId: string, id: string): Promise<{
|
|
72
24
|
id: string;
|
|
73
|
-
|
|
25
|
+
revoked: true;
|
|
74
26
|
}>;
|
|
27
|
+
private listIn;
|
|
28
|
+
private getIn;
|
|
29
|
+
private revokeIn;
|
|
75
30
|
}
|
|
76
31
|
//# sourceMappingURL=connections.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connections.service.d.ts","sourceRoot":"","sources":["../../src/connections/connections.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"connections.service.d.ts","sourceRoot":"","sources":["../../src/connections/connections.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EACL,qBAAqB,EACrB,KAAK,gBAAgB,EACtB,MAAM,6BAA6B,CAAC;AAErC,MAAM,WAAW,sBAAsB;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,qBACa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,WAAW,EAAE,qBAAqB,EAClC,YAAY,EAAE,mBAAmB;IAgB9C,IAAI,CACR,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAKxB,GAAG,CACP,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,gBAAgB,CAAC;IAK5B;;;OAGG;IACG,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;IAKhE,aAAa,CACjB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAKxB,YAAY,CAChB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,gBAAgB,CAAC;IAKtB,eAAe,CACnB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,EAAE,EAAE,MAAM;;;;IAMZ,OAAO,CAAC,MAAM;YAUA,KAAK;YASL,QAAQ;CAIvB"}
|
|
@@ -1,71 +1,74 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
3
|
-
import {
|
|
3
|
+
import { EnvironmentsService } from '../environments/environments.service.js';
|
|
4
|
+
import { ConnectionsRepository, } from './connections.repository.js';
|
|
4
5
|
let ConnectionsService = class ConnectionsService {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
connections;
|
|
7
|
+
environments;
|
|
8
|
+
constructor(connections, environments) {
|
|
9
|
+
this.connections = connections;
|
|
10
|
+
this.environments = environments;
|
|
8
11
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
/*
|
|
13
|
+
* Two audiences, two authorization rules, one set of reads.
|
|
14
|
+
*
|
|
15
|
+
* A consuming app's backend sends an API key, and a key names exactly one
|
|
16
|
+
* environment — it is not a person and has no teams, so there is nothing to
|
|
17
|
+
* check beyond the organization. A signed-in operator names the environment
|
|
18
|
+
* in the route instead, and their teams decide whether they may reach it.
|
|
19
|
+
*
|
|
20
|
+
* Separate methods rather than one with an optional userId, because which
|
|
21
|
+
* check runs is the whole security of it and must not depend on whether an
|
|
22
|
+
* argument happened to be passed.
|
|
23
|
+
*/
|
|
24
|
+
async list(organizationId, environmentId, filters = {}) {
|
|
25
|
+
await this.environments.get(organizationId, environmentId);
|
|
26
|
+
return this.listIn(environmentId, filters);
|
|
27
|
+
}
|
|
28
|
+
async get(organizationId, environmentId, id) {
|
|
29
|
+
await this.environments.get(organizationId, environmentId);
|
|
30
|
+
return this.getIn(environmentId, id);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Deletes the credential. The row is the credential, so there is no history
|
|
34
|
+
* to preserve by keeping it — only ciphertext nobody can use.
|
|
35
|
+
*/
|
|
36
|
+
async revoke(organizationId, environmentId, id) {
|
|
37
|
+
await this.get(organizationId, environmentId, id);
|
|
38
|
+
return this.revokeIn(environmentId, id);
|
|
29
39
|
}
|
|
30
|
-
async
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
async listForMember(organizationId, userId, environmentId, filters = {}) {
|
|
41
|
+
await this.environments.getForMember(organizationId, userId, environmentId);
|
|
42
|
+
return this.listIn(environmentId, filters);
|
|
43
|
+
}
|
|
44
|
+
async getForMember(organizationId, userId, environmentId, id) {
|
|
45
|
+
await this.environments.getForMember(organizationId, userId, environmentId);
|
|
46
|
+
return this.getIn(environmentId, id);
|
|
47
|
+
}
|
|
48
|
+
async revokeForMember(organizationId, userId, environmentId, id) {
|
|
49
|
+
await this.getForMember(organizationId, userId, environmentId, id);
|
|
50
|
+
return this.revokeIn(environmentId, id);
|
|
51
|
+
}
|
|
52
|
+
listIn(environmentId, filters) {
|
|
53
|
+
return this.connections.findMany(environmentId, {
|
|
54
|
+
organizationExternalId: filters.organizationExternalId,
|
|
55
|
+
providerId: filters.configurationId,
|
|
43
56
|
});
|
|
44
|
-
|
|
57
|
+
}
|
|
58
|
+
async getIn(environmentId, id) {
|
|
59
|
+
const connection = await this.connections.findById(environmentId, id);
|
|
60
|
+
if (!connection)
|
|
45
61
|
throw new NotFoundException('Connection not found');
|
|
46
|
-
}
|
|
47
62
|
return connection;
|
|
48
63
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*/
|
|
53
|
-
async revoke(organizationId, id) {
|
|
54
|
-
await this.get(organizationId, id);
|
|
55
|
-
await this.prisma.$transaction([
|
|
56
|
-
this.prisma.connectionCredential.deleteMany({
|
|
57
|
-
where: { connectionId: id },
|
|
58
|
-
}),
|
|
59
|
-
this.prisma.connection.update({
|
|
60
|
-
where: { id },
|
|
61
|
-
data: { status: 'REVOKED', errorMessage: null },
|
|
62
|
-
}),
|
|
63
|
-
]);
|
|
64
|
-
return { id, status: 'REVOKED' };
|
|
64
|
+
async revokeIn(environmentId, id) {
|
|
65
|
+
await this.connections.delete(environmentId, id);
|
|
66
|
+
return { id, revoked: true };
|
|
65
67
|
}
|
|
66
68
|
};
|
|
67
69
|
ConnectionsService = __decorate([
|
|
68
70
|
Injectable(),
|
|
69
|
-
__metadata("design:paramtypes", [
|
|
71
|
+
__metadata("design:paramtypes", [ConnectionsRepository,
|
|
72
|
+
EnvironmentsService])
|
|
70
73
|
], ConnectionsService);
|
|
71
74
|
export { ConnectionsService };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-connections.dto.d.ts","sourceRoot":"","sources":["../../../src/connections/dto/list-connections.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,kBAAkB;IAQ7B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAOhC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
3
|
+
import { IsOptional, IsString, MaxLength } from 'class-validator';
|
|
4
|
+
export class ListConnectionsDto {
|
|
5
|
+
organizationExternalId;
|
|
6
|
+
configurationId;
|
|
7
|
+
}
|
|
8
|
+
__decorate([
|
|
9
|
+
ApiPropertyOptional({
|
|
10
|
+
example: 'org_codemancers',
|
|
11
|
+
description: 'Only connections owned by this tenant of the consuming app.',
|
|
12
|
+
}),
|
|
13
|
+
IsOptional(),
|
|
14
|
+
IsString(),
|
|
15
|
+
MaxLength(255),
|
|
16
|
+
__metadata("design:type", String)
|
|
17
|
+
], ListConnectionsDto.prototype, "organizationExternalId", void 0);
|
|
18
|
+
__decorate([
|
|
19
|
+
ApiPropertyOptional({
|
|
20
|
+
description: 'Only connections to this configuration.',
|
|
21
|
+
}),
|
|
22
|
+
IsOptional(),
|
|
23
|
+
IsString(),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], ListConnectionsDto.prototype, "configurationId", void 0);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type UserSession } from '@thallesp/nestjs-better-auth';
|
|
2
|
+
import { ConnectionsService } from './connections.service.js';
|
|
3
|
+
import { ListConnectionsDto } from './dto/list-connections.dto.js';
|
|
4
|
+
/**
|
|
5
|
+
* The admin's view of connections, nested under the environment they belong
|
|
6
|
+
* to — the same shape as `ConfigurationsController`.
|
|
7
|
+
*
|
|
8
|
+
* Separate from `ConnectionsController` because the two have different
|
|
9
|
+
* audiences and different authorization rules. That one serves a consuming
|
|
10
|
+
* app's backend over `x-api-key`, where the key names the environment. This
|
|
11
|
+
* serves a signed-in operator, whose teams decide which environments they may
|
|
12
|
+
* reach. Keeping them apart means the rule is chosen by the route rather than
|
|
13
|
+
* by a branch inside a handler, so a later route cannot quietly pick up the
|
|
14
|
+
* wrong one.
|
|
15
|
+
*/
|
|
16
|
+
export declare class EnvironmentConnectionsController {
|
|
17
|
+
private readonly connections;
|
|
18
|
+
constructor(connections: ConnectionsService);
|
|
19
|
+
list(session: UserSession, environmentId: string, filters: ListConnectionsDto): Promise<import("./connections.repository.js").ListedConnection[]>;
|
|
20
|
+
get(session: UserSession, environmentId: string, id: string): Promise<import("./connections.repository.js").ListedConnection>;
|
|
21
|
+
revoke(session: UserSession, environmentId: string, id: string): Promise<{
|
|
22
|
+
id: string;
|
|
23
|
+
revoked: true;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=environment-connections.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-connections.controller.d.ts","sourceRoot":"","sources":["../../src/connections/environment-connections.controller.ts"],"names":[],"mappings":"AAOA,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;;;;;;;;;;GAWG;AACH,qBAEa,gCAAgC;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,kBAAkB;IAS5D,IAAI,CACS,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EACpC,OAAO,EAAE,kBAAkB;IAetC,GAAG,CACU,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EAChC,EAAE,EAAE,MAAM;IAiBzB,MAAM,CACO,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EAChC,EAAE,EAAE,MAAM;;;;CAS1B"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
+
import { Controller, Delete, Get, Param, Query } from '@nestjs/common';
|
|
3
|
+
import { ApiNotFoundResponse, ApiOkResponse, ApiOperation, ApiTags, } from '@nestjs/swagger';
|
|
4
|
+
import { Session } from '@thallesp/nestjs-better-auth';
|
|
5
|
+
import { getActiveOrganizationId } from '../common/active-organization.js';
|
|
6
|
+
import { ConnectionsService } from './connections.service.js';
|
|
7
|
+
import { ListConnectionsDto } from './dto/list-connections.dto.js';
|
|
8
|
+
/**
|
|
9
|
+
* The admin's view of connections, nested under the environment they belong
|
|
10
|
+
* to — the same shape as `ConfigurationsController`.
|
|
11
|
+
*
|
|
12
|
+
* Separate from `ConnectionsController` because the two have different
|
|
13
|
+
* audiences and different authorization rules. That one serves a consuming
|
|
14
|
+
* app's backend over `x-api-key`, where the key names the environment. This
|
|
15
|
+
* serves a signed-in operator, whose teams decide which environments they may
|
|
16
|
+
* reach. Keeping them apart means the rule is chosen by the route rather than
|
|
17
|
+
* by a branch inside a handler, so a later route cannot quietly pick up the
|
|
18
|
+
* wrong one.
|
|
19
|
+
*/
|
|
20
|
+
let EnvironmentConnectionsController = class EnvironmentConnectionsController {
|
|
21
|
+
connections;
|
|
22
|
+
constructor(connections) {
|
|
23
|
+
this.connections = connections;
|
|
24
|
+
}
|
|
25
|
+
list(session, environmentId, filters) {
|
|
26
|
+
return this.connections.listForMember(getActiveOrganizationId(session), session.user.id, environmentId, filters);
|
|
27
|
+
}
|
|
28
|
+
get(session, environmentId, id) {
|
|
29
|
+
return this.connections.getForMember(getActiveOrganizationId(session), session.user.id, environmentId, id);
|
|
30
|
+
}
|
|
31
|
+
revoke(session, environmentId, id) {
|
|
32
|
+
return this.connections.revokeForMember(getActiveOrganizationId(session), session.user.id, environmentId, id);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
__decorate([
|
|
36
|
+
Get(),
|
|
37
|
+
ApiOperation({
|
|
38
|
+
summary: 'List the connections in one environment',
|
|
39
|
+
description: 'Grouped by the tenant that owns them. Never carries a credential.',
|
|
40
|
+
}),
|
|
41
|
+
ApiOkResponse({ description: 'Connections in this environment.' }),
|
|
42
|
+
__param(0, Session()),
|
|
43
|
+
__param(1, Param('environmentId')),
|
|
44
|
+
__param(2, Query()),
|
|
45
|
+
__metadata("design:type", Function),
|
|
46
|
+
__metadata("design:paramtypes", [Object, String, ListConnectionsDto]),
|
|
47
|
+
__metadata("design:returntype", void 0)
|
|
48
|
+
], EnvironmentConnectionsController.prototype, "list", null);
|
|
49
|
+
__decorate([
|
|
50
|
+
Get(':id'),
|
|
51
|
+
ApiOperation({ summary: 'Get one connection' }),
|
|
52
|
+
ApiNotFoundResponse({
|
|
53
|
+
description: 'No such connection in an environment you can reach.',
|
|
54
|
+
}),
|
|
55
|
+
__param(0, Session()),
|
|
56
|
+
__param(1, Param('environmentId')),
|
|
57
|
+
__param(2, Param('id')),
|
|
58
|
+
__metadata("design:type", Function),
|
|
59
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
60
|
+
__metadata("design:returntype", void 0)
|
|
61
|
+
], EnvironmentConnectionsController.prototype, "get", null);
|
|
62
|
+
__decorate([
|
|
63
|
+
Delete(':id'),
|
|
64
|
+
ApiOperation({
|
|
65
|
+
summary: 'Revoke a connection',
|
|
66
|
+
description: 'Deletes the credential. Kosha logins carry no environment and are untouched.',
|
|
67
|
+
}),
|
|
68
|
+
ApiOkResponse({ description: 'The revoked connection id.' }),
|
|
69
|
+
__param(0, Session()),
|
|
70
|
+
__param(1, Param('environmentId')),
|
|
71
|
+
__param(2, Param('id')),
|
|
72
|
+
__metadata("design:type", Function),
|
|
73
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
74
|
+
__metadata("design:returntype", void 0)
|
|
75
|
+
], EnvironmentConnectionsController.prototype, "revoke", null);
|
|
76
|
+
EnvironmentConnectionsController = __decorate([
|
|
77
|
+
ApiTags('connections'),
|
|
78
|
+
Controller('environments/:environmentId/connections'),
|
|
79
|
+
__metadata("design:paramtypes", [ConnectionsService])
|
|
80
|
+
], EnvironmentConnectionsController);
|
|
81
|
+
export { EnvironmentConnectionsController };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The admin's connections routes, beside the machine-facing ones.
|
|
3
|
+
*
|
|
4
|
+
* A module rather than a second controller inside `ConnectionsModule`: the two
|
|
5
|
+
* serve different audiences under different authentication, and keeping them
|
|
6
|
+
* in separate modules is what a Rails namespace would be. The service and
|
|
7
|
+
* repository are shared, so nothing is duplicated but the routing.
|
|
8
|
+
*/
|
|
9
|
+
export declare class EnvironmentConnectionsModule {
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=environment-connections.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-connections.module.d.ts","sourceRoot":"","sources":["../../src/connections/environment-connections.module.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,qBAIa,4BAA4B;CAAG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { Module } from '@nestjs/common';
|
|
3
|
+
import { ConnectionsModule } from './connections.module.js';
|
|
4
|
+
import { EnvironmentConnectionsController } from './environment-connections.controller.js';
|
|
5
|
+
/**
|
|
6
|
+
* The admin's connections routes, beside the machine-facing ones.
|
|
7
|
+
*
|
|
8
|
+
* A module rather than a second controller inside `ConnectionsModule`: the two
|
|
9
|
+
* serve different audiences under different authentication, and keeping them
|
|
10
|
+
* in separate modules is what a Rails namespace would be. The service and
|
|
11
|
+
* repository are shared, so nothing is duplicated but the routing.
|
|
12
|
+
*/
|
|
13
|
+
let EnvironmentConnectionsModule = class EnvironmentConnectionsModule {
|
|
14
|
+
};
|
|
15
|
+
EnvironmentConnectionsModule = __decorate([
|
|
16
|
+
Module({
|
|
17
|
+
imports: [ConnectionsModule],
|
|
18
|
+
controllers: [EnvironmentConnectionsController],
|
|
19
|
+
})
|
|
20
|
+
], EnvironmentConnectionsModule);
|
|
21
|
+
export { EnvironmentConnectionsModule };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { Module } from '@nestjs/common';
|
|
3
3
|
import { ConfigurationsModule } from '../configurations/configurations.module.js';
|
|
4
|
-
import {
|
|
4
|
+
import { CredentialsRepository } from './credentials.repository.js';
|
|
5
5
|
import { CredentialsService } from './credentials.service.js';
|
|
6
6
|
let CredentialsModule = class CredentialsModule {
|
|
7
7
|
};
|
|
8
8
|
CredentialsModule = __decorate([
|
|
9
9
|
Module({
|
|
10
|
-
imports: [
|
|
11
|
-
providers: [CredentialsService],
|
|
10
|
+
imports: [ConfigurationsModule],
|
|
11
|
+
providers: [CredentialsService, CredentialsRepository],
|
|
12
12
|
exports: [CredentialsService],
|
|
13
13
|
})
|
|
14
14
|
], CredentialsModule);
|