@kosha-ai/server 0.0.2 → 0.0.4
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/admin-proxy.d.ts +32 -0
- package/dist/admin-proxy.d.ts.map +1 -0
- package/dist/admin-proxy.js +88 -0
- package/dist/auth/api-key.guard.d.ts +10 -0
- package/dist/auth/api-key.guard.d.ts.map +1 -1
- package/dist/auth/api-key.guard.js +36 -5
- package/dist/auth/auth.factory.d.ts +5 -0
- package/dist/auth/auth.factory.d.ts.map +1 -1
- package/dist/auth/auth.factory.js +31 -2
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -1
- package/dist/configurations/configurations.controller.d.ts +32 -28
- package/dist/configurations/configurations.controller.d.ts.map +1 -1
- package/dist/configurations/configurations.service.d.ts +41 -35
- package/dist/configurations/configurations.service.d.ts.map +1 -1
- package/dist/configurations/configurations.service.js +12 -0
- package/dist/connect/connect.controller.d.ts +8 -10
- package/dist/connect/connect.controller.d.ts.map +1 -1
- package/dist/connect/connect.controller.js +8 -6
- package/dist/connect/connect.service.d.ts +2 -1
- package/dist/connect/connect.service.d.ts.map +1 -1
- package/dist/connect/connect.service.js +8 -3
- package/dist/connections/connections.controller.d.ts +16 -16
- package/dist/connections/connections.controller.d.ts.map +1 -1
- package/dist/connections/connections.controller.js +14 -12
- package/dist/connections/connections.service.d.ts +12 -12
- package/dist/generated/prisma/internal/class.js +4 -4
- package/dist/generated/prisma/internal/prismaNamespace.d.ts +1 -0
- package/dist/generated/prisma/internal/prismaNamespace.d.ts.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespace.js +1 -0
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +1 -0
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.js +1 -0
- package/dist/generated/prisma/models/Configuration.d.ts +56 -2
- package/dist/generated/prisma/models/Configuration.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/integration.registry.d.ts.map +1 -1
- package/package.json +4 -4
- package/prisma/migrations/20260916000000_add_configuration_slug/migration.sql +15 -0
- package/prisma/schema.prisma +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurations.service.d.ts","sourceRoot":"","sources":["../../src/configurations/configurations.service.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,WAAW,wBAAwB;IACvC,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAKD,qBACa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAH5B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,mBAAmB,EACP,MAAM,EAAE,mBAAmB;IAGpE;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAK3C,IAAI,CAAC,cAAc,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"configurations.service.d.ts","sourceRoot":"","sources":["../../src/configurations/configurations.service.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,WAAW,wBAAwB;IACvC,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAKD,qBACa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAH5B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,mBAAmB,EACP,MAAM,EAAE,mBAAmB;IAGpE;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAK3C,IAAI,CAAC,cAAc,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IASrB,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAYtC,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiD9D,MAAM,CACV,cAAc,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2B3B,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAK/C;;;OAGG;IACG,sBAAsB,CAAC,eAAe,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoBpD,OAAO,CAAC,cAAc;IAetB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;CAiCzB"}
|
|
@@ -63,11 +63,16 @@ let ConfigurationsService = class ConfigurationsService {
|
|
|
63
63
|
}
|
|
64
64
|
const scopes = this.validateScopes(input.provider, input.scopes ?? []);
|
|
65
65
|
const settings = this.validateSettings(input.provider, input.settings);
|
|
66
|
+
const slug = slugify(input.slug ?? input.name);
|
|
67
|
+
if (!slug) {
|
|
68
|
+
throw new BadRequestException('slug must contain at least one letter or digit');
|
|
69
|
+
}
|
|
66
70
|
return this.prisma.configuration.create({
|
|
67
71
|
data: {
|
|
68
72
|
organizationId,
|
|
69
73
|
providerId: provider.id,
|
|
70
74
|
name: input.name.trim(),
|
|
75
|
+
slug,
|
|
71
76
|
authType: provider.authType,
|
|
72
77
|
environment: input.environment ?? 'LIVE',
|
|
73
78
|
clientId: input.clientId,
|
|
@@ -173,6 +178,13 @@ ConfigurationsService = __decorate([
|
|
|
173
178
|
IntegrationRegistry, Object])
|
|
174
179
|
], ConfigurationsService);
|
|
175
180
|
export { ConfigurationsService };
|
|
181
|
+
/** Lowercase, digits and single dashes. Empty if the input has no word chars. */
|
|
182
|
+
function slugify(value) {
|
|
183
|
+
return value
|
|
184
|
+
.toLowerCase()
|
|
185
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
186
|
+
.replace(/^-+|-+$/g, '');
|
|
187
|
+
}
|
|
176
188
|
function describeTypeMismatch(field, value) {
|
|
177
189
|
switch (field.type) {
|
|
178
190
|
case 'number':
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import { type UserSession } from '@thallesp/nestjs-better-auth';
|
|
2
2
|
import type { Response } from 'express';
|
|
3
3
|
import { type ApiKeyRequest } from '../auth/api-key.guard.js';
|
|
4
|
-
import { ConnectService } from './connect.service.js';
|
|
4
|
+
import { ConnectService, type CreateConnectSessionInput } from './connect.service.js';
|
|
5
5
|
export declare class ConnectController {
|
|
6
6
|
private readonly connect;
|
|
7
7
|
private readonly logger;
|
|
8
8
|
constructor(connect: ConnectService);
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* The organization's backend asks for a connect link for one of its own
|
|
11
|
+
* users, over `x-api-key`; the admin UI may do the same over its cookie
|
|
12
|
+
* session. `AllowAnonymous` disables the session guard so `OrgAuthGuard`
|
|
13
|
+
* can authenticate either way.
|
|
13
14
|
*/
|
|
14
|
-
createSession(request: ApiKeyRequest, body:
|
|
15
|
-
endUserExternalId: string;
|
|
16
|
-
configurationId: string;
|
|
17
|
-
redirectUrl?: string;
|
|
18
|
-
}): Promise<import("./connect.service.js").ConnectSessionResult>;
|
|
15
|
+
createSession(request: ApiKeyRequest, body: CreateConnectSessionInput): Promise<import("./connect.service.js").ConnectSessionResult>;
|
|
19
16
|
/**
|
|
20
17
|
* Admin-only: runs the same flow with the signed-in admin standing in for an
|
|
21
18
|
* end user, so an operator can verify a configuration without wiring up
|
|
22
19
|
* their backend first.
|
|
23
20
|
*/
|
|
24
21
|
createTestSession(session: UserSession, body: {
|
|
25
|
-
configurationId
|
|
22
|
+
configurationId?: string;
|
|
23
|
+
slug?: string;
|
|
26
24
|
redirectUrl?: string;
|
|
27
25
|
}): Promise<import("./connect.service.js").ConnectSessionResult>;
|
|
28
26
|
/** The URL the end user's browser opens. Redirects to the provider. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.controller.d.ts","sourceRoot":"","sources":["../../src/connect/connect.controller.ts"],"names":[],"mappings":"AAaA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"connect.controller.d.ts","sourceRoot":"","sources":["../../src/connect/connect.controller.ts"],"names":[],"mappings":"AAaA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,KAAK,aAAa,EAAgB,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EACL,cAAc,EACd,KAAK,yBAAyB,EAC/B,MAAM,sBAAsB,CAAC;AAE9B,qBACa,iBAAiB;IAGhB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;gBAEhC,OAAO,EAAE,cAAc;IAEpD;;;;;OAKG;IAIH,aAAa,CACJ,OAAO,EAAE,aAAa,EACrB,IAAI,EAAE,yBAAyB;IAKzC;;;;OAIG;IAEH,iBAAiB,CACJ,OAAO,EAAE,WAAW,EAE/B,IAAI,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAUzE,uEAAuE;IAGjE,KAAK,CAAiB,KAAK,EAAE,MAAM,EAAS,GAAG,EAAE,QAAQ;IAY/D,kDAAkD;IAG5C,QAAQ,CACU,WAAW,EAAE,MAAM,EAC1B,IAAI,EAAE,MAAM,GAAG,SAAS,EACvB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,aAAa,EAAE,MAAM,GAAG,SAAS,EACrB,wBAAwB,EAAE,MAAM,GAAG,SAAS,EACjE,GAAG,EAAE,QAAQ;CA+CvB"}
|
|
@@ -2,9 +2,9 @@ var ConnectController_1;
|
|
|
2
2
|
import { __decorate, __metadata, __param } from "tslib";
|
|
3
3
|
import { BadRequestException, Body, Controller, Get, Logger, Param, Post, Query, Req, Res, UseGuards, } from '@nestjs/common';
|
|
4
4
|
import { AllowAnonymous, Session, } from '@thallesp/nestjs-better-auth';
|
|
5
|
-
import {
|
|
5
|
+
import { OrgAuthGuard } from '../auth/api-key.guard.js';
|
|
6
6
|
import { getActiveOrganizationId } from '../common/active-organization.js';
|
|
7
|
-
import { ConnectService } from './connect.service.js';
|
|
7
|
+
import { ConnectService, } from './connect.service.js';
|
|
8
8
|
let ConnectController = ConnectController_1 = class ConnectController {
|
|
9
9
|
connect;
|
|
10
10
|
logger = new Logger(ConnectController_1.name);
|
|
@@ -12,9 +12,10 @@ let ConnectController = ConnectController_1 = class ConnectController {
|
|
|
12
12
|
this.connect = connect;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* The organization's backend asks for a connect link for one of its own
|
|
16
|
+
* users, over `x-api-key`; the admin UI may do the same over its cookie
|
|
17
|
+
* session. `AllowAnonymous` disables the session guard so `OrgAuthGuard`
|
|
18
|
+
* can authenticate either way.
|
|
18
19
|
*/
|
|
19
20
|
createSession(request, body) {
|
|
20
21
|
return this.connect.createSession(request.organizationId, body);
|
|
@@ -28,6 +29,7 @@ let ConnectController = ConnectController_1 = class ConnectController {
|
|
|
28
29
|
return this.connect.createSession(getActiveOrganizationId(session), {
|
|
29
30
|
endUserExternalId: `kosha-admin:${session.user.id}`,
|
|
30
31
|
configurationId: body?.configurationId,
|
|
32
|
+
configurationSlug: body?.slug,
|
|
31
33
|
redirectUrl: body?.redirectUrl,
|
|
32
34
|
});
|
|
33
35
|
}
|
|
@@ -79,7 +81,7 @@ let ConnectController = ConnectController_1 = class ConnectController {
|
|
|
79
81
|
__decorate([
|
|
80
82
|
Post('sessions'),
|
|
81
83
|
AllowAnonymous(),
|
|
82
|
-
UseGuards(
|
|
84
|
+
UseGuards(OrgAuthGuard),
|
|
83
85
|
__param(0, Req()),
|
|
84
86
|
__param(1, Body()),
|
|
85
87
|
__metadata("design:type", Function),
|
|
@@ -6,7 +6,8 @@ import { IntegrationRegistry } from '../integrations/integration.registry.js';
|
|
|
6
6
|
import { PrismaService } from '../prisma/prisma.service.js';
|
|
7
7
|
export interface CreateConnectSessionInput {
|
|
8
8
|
endUserExternalId: string;
|
|
9
|
-
configurationId
|
|
9
|
+
configurationId?: string;
|
|
10
|
+
configurationSlug?: string;
|
|
10
11
|
redirectUrl?: string;
|
|
11
12
|
}
|
|
12
13
|
export interface ConnectSessionResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.service.d.ts","sourceRoot":"","sources":["../../src/connect/connect.service.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAoB,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAK5D,MAAM,WAAW,yBAAyB;IACxC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"connect.service.d.ts","sourceRoot":"","sources":["../../src/connect/connect.service.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAoB,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAK5D,MAAM,WAAW,yBAAyB;IACxC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAMD;;;;;;GAMG;AACH,qBACa,cAAc;IAIvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM;IAP/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmC;gBAGvC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,aAAa,EACrB,cAAc,EAAE,qBAAqB,EACrC,QAAQ,EAAE,mBAAmB,EACP,MAAM,EAAE,mBAAmB;IAGpE;;;OAGG;IACG,aAAa,CACjB,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,oBAAoB,CAAC;IAyDhC;;;;OAIG;IACG,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoDhE,qDAAqD;IAC/C,cAAc,CAClB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,cAAc,CAAC;IAkG1B,8EAA8E;IACxE,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB5E,sEAAsE;YACxD,OAAO;CActB"}
|
|
@@ -43,12 +43,16 @@ let ConnectService = ConnectService_1 = class ConnectService {
|
|
|
43
43
|
if (!input?.endUserExternalId?.trim()) {
|
|
44
44
|
throw new BadRequestException('endUserExternalId is required');
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const configurationId = input.configurationId?.trim();
|
|
47
|
+
const configurationSlug = input.configurationSlug?.trim();
|
|
48
|
+
if (!configurationId && !configurationSlug) {
|
|
49
|
+
throw new BadRequestException('configurationId or configurationSlug is required');
|
|
48
50
|
}
|
|
49
51
|
const configuration = await this.prisma.configuration.findFirst({
|
|
50
52
|
where: {
|
|
51
|
-
|
|
53
|
+
...(configurationId
|
|
54
|
+
? { id: configurationId }
|
|
55
|
+
: { slug: configurationSlug }),
|
|
52
56
|
organizationId,
|
|
53
57
|
isEnabled: true,
|
|
54
58
|
},
|
|
@@ -188,6 +192,7 @@ let ConnectService = ConnectService_1 = class ConnectService {
|
|
|
188
192
|
lastUsedAt: new Date(),
|
|
189
193
|
},
|
|
190
194
|
update: {
|
|
195
|
+
endUserId,
|
|
191
196
|
status: 'ACTIVE',
|
|
192
197
|
label: identity.label,
|
|
193
198
|
errorMessage: null,
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ApiKeyRequest } from '../auth/api-key.guard.js';
|
|
2
2
|
import { ConnectionsService } from './connections.service.js';
|
|
3
3
|
export declare class ConnectionsController {
|
|
4
4
|
private readonly connections;
|
|
5
5
|
constructor(connections: ConnectionsService);
|
|
6
|
-
list(
|
|
6
|
+
list(request: ApiKeyRequest, endUserExternalId?: string): import("../generated/prisma/internal/prismaNamespace.js").PrismaPromise<({
|
|
7
7
|
configuration: {
|
|
8
|
-
id: string;
|
|
9
8
|
name: string;
|
|
9
|
+
id: string;
|
|
10
10
|
provider: {
|
|
11
|
-
key: string;
|
|
12
11
|
name: string;
|
|
12
|
+
key: string;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
endUser: {
|
|
16
16
|
name: string | null;
|
|
17
|
-
externalId: string;
|
|
18
17
|
email: string | null;
|
|
18
|
+
externalId: string;
|
|
19
19
|
};
|
|
20
20
|
} & {
|
|
21
21
|
id: string;
|
|
22
|
-
organizationId: string;
|
|
23
|
-
scopes: string[];
|
|
24
|
-
metadata: import("@prisma/client/runtime/client").JsonValue | null;
|
|
25
22
|
createdAt: Date;
|
|
26
23
|
updatedAt: Date;
|
|
27
24
|
status: import("../generated/prisma/enums.js").ConnectionStatus;
|
|
25
|
+
metadata: import("@prisma/client/runtime/client").JsonValue | null;
|
|
26
|
+
scopes: string[];
|
|
27
|
+
organizationId: string;
|
|
28
28
|
endUserId: string;
|
|
29
29
|
configurationId: string;
|
|
30
30
|
label: string | null;
|
|
@@ -33,28 +33,28 @@ export declare class ConnectionsController {
|
|
|
33
33
|
lastUsedAt: Date | null;
|
|
34
34
|
errorMessage: string | null;
|
|
35
35
|
})[]>;
|
|
36
|
-
get(
|
|
36
|
+
get(request: ApiKeyRequest, id: string): Promise<{
|
|
37
37
|
configuration: {
|
|
38
|
-
id: string;
|
|
39
38
|
name: string;
|
|
39
|
+
id: string;
|
|
40
40
|
provider: {
|
|
41
|
-
key: string;
|
|
42
41
|
name: string;
|
|
42
|
+
key: string;
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
45
|
endUser: {
|
|
46
46
|
name: string | null;
|
|
47
|
-
externalId: string;
|
|
48
47
|
email: string | null;
|
|
48
|
+
externalId: string;
|
|
49
49
|
};
|
|
50
50
|
} & {
|
|
51
51
|
id: string;
|
|
52
|
-
organizationId: string;
|
|
53
|
-
scopes: string[];
|
|
54
|
-
metadata: import("@prisma/client/runtime/client").JsonValue | null;
|
|
55
52
|
createdAt: Date;
|
|
56
53
|
updatedAt: Date;
|
|
57
54
|
status: import("../generated/prisma/enums.js").ConnectionStatus;
|
|
55
|
+
metadata: import("@prisma/client/runtime/client").JsonValue | null;
|
|
56
|
+
scopes: string[];
|
|
57
|
+
organizationId: string;
|
|
58
58
|
endUserId: string;
|
|
59
59
|
configurationId: string;
|
|
60
60
|
label: string | null;
|
|
@@ -63,7 +63,7 @@ export declare class ConnectionsController {
|
|
|
63
63
|
lastUsedAt: Date | null;
|
|
64
64
|
errorMessage: string | null;
|
|
65
65
|
}>;
|
|
66
|
-
revoke(
|
|
66
|
+
revoke(request: ApiKeyRequest, id: string): Promise<{
|
|
67
67
|
id: string;
|
|
68
68
|
status: "REVOKED";
|
|
69
69
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connections.controller.d.ts","sourceRoot":"","sources":["../../src/connections/connections.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connections.controller.d.ts","sourceRoot":"","sources":["../../src/connections/connections.controller.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,aAAa,EAAgB,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,qBAGa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,kBAAkB;IAG5D,IAAI,CACK,OAAO,EAAE,aAAa,EACD,iBAAiB,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAQxD,GAAG,CAAQ,OAAO,EAAE,aAAa,EAAe,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAK1D,MAAM,CAAQ,OAAO,EAAE,aAAa,EAAe,EAAE,EAAE,MAAM;;;;CAG9D"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
-
import { Controller, Delete, Get, Param, Query } from '@nestjs/common';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { Controller, Delete, Get, Param, Query, Req, UseGuards, } from '@nestjs/common';
|
|
3
|
+
import { AllowAnonymous } from '@thallesp/nestjs-better-auth';
|
|
4
|
+
import { OrgAuthGuard } from '../auth/api-key.guard.js';
|
|
5
5
|
import { ConnectionsService } from './connections.service.js';
|
|
6
6
|
let ConnectionsController = class ConnectionsController {
|
|
7
7
|
connections;
|
|
8
8
|
constructor(connections) {
|
|
9
9
|
this.connections = connections;
|
|
10
10
|
}
|
|
11
|
-
list(
|
|
12
|
-
return this.connections.list(
|
|
11
|
+
list(request, endUserExternalId) {
|
|
12
|
+
return this.connections.list(request.organizationId, {
|
|
13
13
|
endUserExternalId,
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
get(
|
|
17
|
-
return this.connections.get(
|
|
16
|
+
get(request, id) {
|
|
17
|
+
return this.connections.get(request.organizationId, id);
|
|
18
18
|
}
|
|
19
|
-
revoke(
|
|
20
|
-
return this.connections.revoke(
|
|
19
|
+
revoke(request, id) {
|
|
20
|
+
return this.connections.revoke(request.organizationId, id);
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
__decorate([
|
|
24
24
|
Get(),
|
|
25
|
-
__param(0,
|
|
25
|
+
__param(0, Req()),
|
|
26
26
|
__param(1, Query('endUserExternalId')),
|
|
27
27
|
__metadata("design:type", Function),
|
|
28
28
|
__metadata("design:paramtypes", [Object, String]),
|
|
@@ -30,7 +30,7 @@ __decorate([
|
|
|
30
30
|
], ConnectionsController.prototype, "list", null);
|
|
31
31
|
__decorate([
|
|
32
32
|
Get(':id'),
|
|
33
|
-
__param(0,
|
|
33
|
+
__param(0, Req()),
|
|
34
34
|
__param(1, Param('id')),
|
|
35
35
|
__metadata("design:type", Function),
|
|
36
36
|
__metadata("design:paramtypes", [Object, String]),
|
|
@@ -38,7 +38,7 @@ __decorate([
|
|
|
38
38
|
], ConnectionsController.prototype, "get", null);
|
|
39
39
|
__decorate([
|
|
40
40
|
Delete(':id'),
|
|
41
|
-
__param(0,
|
|
41
|
+
__param(0, Req()),
|
|
42
42
|
__param(1, Param('id')),
|
|
43
43
|
__metadata("design:type", Function),
|
|
44
44
|
__metadata("design:paramtypes", [Object, String]),
|
|
@@ -46,6 +46,8 @@ __decorate([
|
|
|
46
46
|
], ConnectionsController.prototype, "revoke", null);
|
|
47
47
|
ConnectionsController = __decorate([
|
|
48
48
|
Controller('connections'),
|
|
49
|
+
AllowAnonymous(),
|
|
50
|
+
UseGuards(OrgAuthGuard),
|
|
49
51
|
__metadata("design:paramtypes", [ConnectionsService])
|
|
50
52
|
], ConnectionsController);
|
|
51
53
|
export { ConnectionsController };
|
|
@@ -6,26 +6,26 @@ export declare class ConnectionsService {
|
|
|
6
6
|
endUserExternalId?: string;
|
|
7
7
|
}): import("../generated/prisma/internal/prismaNamespace.js").PrismaPromise<({
|
|
8
8
|
configuration: {
|
|
9
|
-
id: string;
|
|
10
9
|
name: string;
|
|
10
|
+
id: string;
|
|
11
11
|
provider: {
|
|
12
|
-
key: string;
|
|
13
12
|
name: string;
|
|
13
|
+
key: string;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
endUser: {
|
|
17
17
|
name: string | null;
|
|
18
|
-
externalId: string;
|
|
19
18
|
email: string | null;
|
|
19
|
+
externalId: string;
|
|
20
20
|
};
|
|
21
21
|
} & {
|
|
22
22
|
id: string;
|
|
23
|
-
organizationId: string;
|
|
24
|
-
scopes: string[];
|
|
25
|
-
metadata: import("@prisma/client/runtime/client").JsonValue | null;
|
|
26
23
|
createdAt: Date;
|
|
27
24
|
updatedAt: Date;
|
|
28
25
|
status: import("../generated/prisma/enums.js").ConnectionStatus;
|
|
26
|
+
metadata: import("@prisma/client/runtime/client").JsonValue | null;
|
|
27
|
+
scopes: string[];
|
|
28
|
+
organizationId: string;
|
|
29
29
|
endUserId: string;
|
|
30
30
|
configurationId: string;
|
|
31
31
|
label: string | null;
|
|
@@ -36,26 +36,26 @@ export declare class ConnectionsService {
|
|
|
36
36
|
})[]>;
|
|
37
37
|
get(organizationId: string, id: string): Promise<{
|
|
38
38
|
configuration: {
|
|
39
|
-
id: string;
|
|
40
39
|
name: string;
|
|
40
|
+
id: string;
|
|
41
41
|
provider: {
|
|
42
|
-
key: string;
|
|
43
42
|
name: string;
|
|
43
|
+
key: string;
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
46
|
endUser: {
|
|
47
47
|
name: string | null;
|
|
48
|
-
externalId: string;
|
|
49
48
|
email: string | null;
|
|
49
|
+
externalId: string;
|
|
50
50
|
};
|
|
51
51
|
} & {
|
|
52
52
|
id: string;
|
|
53
|
-
organizationId: string;
|
|
54
|
-
scopes: string[];
|
|
55
|
-
metadata: import("@prisma/client/runtime/client").JsonValue | null;
|
|
56
53
|
createdAt: Date;
|
|
57
54
|
updatedAt: Date;
|
|
58
55
|
status: import("../generated/prisma/enums.js").ConnectionStatus;
|
|
56
|
+
metadata: import("@prisma/client/runtime/client").JsonValue | null;
|
|
57
|
+
scopes: string[];
|
|
58
|
+
organizationId: string;
|
|
59
59
|
endUserId: string;
|
|
60
60
|
configurationId: string;
|
|
61
61
|
label: string | null;
|