@kosha-ai/server 0.4.0 → 0.4.2
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/configurations/configurations.service.d.ts.map +1 -1
- package/dist/configurations/configurations.service.js +10 -3
- package/dist/connect/connect.service.js +1 -1
- package/dist/egress/host-rules.service.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/integrations/integrations.controller.js +1 -1
- package/dist/kosha.module.d.ts.map +1 -1
- package/dist/kosha.module.js +2 -0
- package/dist/proxy/proxy.module.d.ts.map +1 -1
- package/dist/proxy/proxy.module.js +4 -0
- package/dist/proxy/proxy.service.d.ts.map +1 -1
- package/dist/proxy/proxy.service.js +5 -0
- package/dist/query/dto/run-query.dto.d.ts +5 -0
- package/dist/query/dto/run-query.dto.d.ts.map +1 -0
- package/dist/query/dto/run-query.dto.js +26 -0
- package/dist/query/query.controller.d.ts +15 -0
- package/dist/query/query.controller.d.ts.map +1 -0
- package/dist/query/query.controller.js +52 -0
- package/dist/query/query.module.d.ts +3 -0
- package/dist/query/query.module.d.ts.map +1 -0
- package/dist/query/query.module.js +19 -0
- package/dist/query/query.service.d.ts +32 -0
- package/dist/query/query.service.d.ts.map +1 -0
- package/dist/query/query.service.js +83 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurations.service.d.ts","sourceRoot":"","sources":["../../src/configurations/configurations.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configurations.service.d.ts","sourceRoot":"","sources":["../../src/configurations/configurations.service.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EACL,aAAa,EACb,KA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,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,sBAAsB,CAAC;IAkBlC,yDAAyD;IACnD,MAAM,CACV,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC;IAMhB;;;OAGG;IACG,kBAAkB,CACtB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,4BAA4B,CAAC;IAmBxC;;;;OAIG;YACW,aAAa;IAuB3B;;;;;OAKG;IACH,OAAO,CAAC,eAAe;CA2BxB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { BadRequestException, ConflictException, Injectable, NotFoundException, } from '@nestjs/common';
|
|
3
|
-
import { assertPublicUrl } from '@kosha-ai/integration-sdk';
|
|
3
|
+
import { assertPublicHost, assertPublicUrl, assertResolvableHost, } from '@kosha-ai/integration-sdk';
|
|
4
4
|
import { CryptoService } from '../crypto/crypto.service.js';
|
|
5
5
|
import { EnvironmentsService } from '../environments/environments.service.js';
|
|
6
6
|
import { IntegrationRegistry } from '../integrations/integration.registry.js';
|
|
@@ -106,10 +106,17 @@ let ConfigurationsService = class ConfigurationsService {
|
|
|
106
106
|
async checkedFields(integration, fields) {
|
|
107
107
|
for (const field of integration.configFields ?? []) {
|
|
108
108
|
const value = fields?.[field.key];
|
|
109
|
-
if (
|
|
109
|
+
if (typeof value !== 'string')
|
|
110
|
+
continue;
|
|
111
|
+
if (field.type !== 'url' && field.type !== 'host')
|
|
110
112
|
continue;
|
|
111
113
|
try {
|
|
112
|
-
|
|
114
|
+
if (field.type === 'url')
|
|
115
|
+
await assertPublicUrl(value);
|
|
116
|
+
else if (integration.key === 'postgres')
|
|
117
|
+
await assertResolvableHost(value);
|
|
118
|
+
else
|
|
119
|
+
await assertPublicHost(value);
|
|
113
120
|
}
|
|
114
121
|
catch (error) {
|
|
115
122
|
throw new BadRequestException(error instanceof Error ? error.message : `${field.label} is invalid`);
|
|
@@ -282,7 +282,7 @@ let ConnectService = ConnectService_1 = class ConnectService {
|
|
|
282
282
|
async proveCredential(integration, key, fields) {
|
|
283
283
|
// A provider with no fixed host is reached at whatever the configuration
|
|
284
284
|
// named, which is also what it will be proxied to later.
|
|
285
|
-
const baseUrl = integration.api
|
|
285
|
+
const baseUrl = integration.api?.resolveBaseUrl?.({
|
|
286
286
|
credential: { accessToken: key },
|
|
287
287
|
fields,
|
|
288
288
|
});
|
|
@@ -32,9 +32,9 @@ let HostRulesService = class HostRulesService {
|
|
|
32
32
|
}
|
|
33
33
|
rules() {
|
|
34
34
|
// The registry is fixed for the life of the process.
|
|
35
|
-
this.compiled ??= this.registry.list().flatMap((integration) => (integration.api
|
|
35
|
+
this.compiled ??= this.registry.list().flatMap((integration) => (integration.api?.egress ?? []).map((rule) => ({
|
|
36
36
|
headers: rule.headers?.bind(rule) ??
|
|
37
|
-
((credential) => integration.api
|
|
37
|
+
((credential) => integration.api?.authHeaders(credential) ?? {}),
|
|
38
38
|
hosts: rule.hosts.map((host) => host.toLowerCase()),
|
|
39
39
|
providerKey: integration.key,
|
|
40
40
|
})));
|
package/dist/index.d.ts
CHANGED
|
@@ -36,5 +36,7 @@ export { HostRulesService, type ResolvedHostRule, } from './egress/host-rules.se
|
|
|
36
36
|
export { ProxyModule } from './proxy/proxy.module.js';
|
|
37
37
|
export { ProxyService, type ProxyRequest, type ProxyResult, } from './proxy/proxy.service.js';
|
|
38
38
|
export { splitUpstreamTarget } from './proxy/proxy.controller.js';
|
|
39
|
+
export { QueryModule } from './query/query.module.js';
|
|
40
|
+
export { QueryService, type QueryRequest, type QueryTarget, } from './query/query.service.js';
|
|
39
41
|
export { HealthController, type HealthResponse, } from './health/health.controller.js';
|
|
40
42
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,aAAa,EACb,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,QAAQ,EACR,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,GACpB,MAAM,iCA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,OAAO,EACL,YAAY,EACZ,KAAK,YAAY,GAClB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAC/F,OAAO,EACL,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,GAC5B,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EACL,kBAAkB,EAClB,KAAK,kBAAkB,GACxB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,aAAa,EACb,KAAK,KAAK,EACV,KAAK,cAAc,EACnB,KAAK,WAAW,GACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,KAAK,gBAAgB,GACtB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACL,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACL,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,gBAAgB,EAChB,KAAK,cAAc,GACpB,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -36,4 +36,6 @@ export { HostRulesService, } from './egress/host-rules.service.js';
|
|
|
36
36
|
export { ProxyModule } from './proxy/proxy.module.js';
|
|
37
37
|
export { ProxyService, } from './proxy/proxy.service.js';
|
|
38
38
|
export { splitUpstreamTarget } from './proxy/proxy.controller.js';
|
|
39
|
+
export { QueryModule } from './query/query.module.js';
|
|
40
|
+
export { QueryService, } from './query/query.service.js';
|
|
39
41
|
export { HealthController, } from './health/health.controller.js';
|
|
@@ -38,7 +38,7 @@ function toSummary(integration) {
|
|
|
38
38
|
logo: integration.logo,
|
|
39
39
|
docsUrl: integration.docsUrl,
|
|
40
40
|
authType: integration.auth.type,
|
|
41
|
-
apiBaseUrl: integration.api
|
|
41
|
+
apiBaseUrl: integration.api?.baseUrl,
|
|
42
42
|
scopesAvailable: integration.auth.scopesAvailable,
|
|
43
43
|
scopesRequested: integration.auth.scopesRequested,
|
|
44
44
|
pkce: integration.auth.pkce,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kosha.module.d.ts","sourceRoot":"","sources":["../src/kosha.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAGvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"kosha.module.d.ts","sourceRoot":"","sources":["../src/kosha.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAGvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAiB5D;;;;GAIG;AACH,qBACa,WAAW;IACtB,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa;CAiCnD"}
|
package/dist/kosha.module.js
CHANGED
|
@@ -17,6 +17,7 @@ import { IntegrationsModule } from './integrations/integrations.module.js';
|
|
|
17
17
|
import { PrismaModule } from './prisma/prisma.module.js';
|
|
18
18
|
import { PrismaService } from './prisma/prisma.service.js';
|
|
19
19
|
import { ProxyModule } from './proxy/proxy.module.js';
|
|
20
|
+
import { QueryModule } from './query/query.module.js';
|
|
20
21
|
/**
|
|
21
22
|
* An app that needs nothing custom never imports this directly — `kosha start`
|
|
22
23
|
* builds it from `kosha.config.ts`. Apps that add their own controllers import
|
|
@@ -44,6 +45,7 @@ let KoshaModule = KoshaModule_1 = class KoshaModule {
|
|
|
44
45
|
ConnectionsModule,
|
|
45
46
|
EnvironmentConnectionsModule,
|
|
46
47
|
ProxyModule,
|
|
48
|
+
QueryModule,
|
|
47
49
|
// Only when asked for: the broker opens a second listener, and an app
|
|
48
50
|
// that has not enabled it should not have one at all.
|
|
49
51
|
...(resolved.egress.enabled ? [EgressModule] : []),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.module.d.ts","sourceRoot":"","sources":["../../src/proxy/proxy.module.ts"],"names":[],"mappings":"AAOA,
|
|
1
|
+
{"version":3,"file":"proxy.module.d.ts","sourceRoot":"","sources":["../../src/proxy/proxy.module.ts"],"names":[],"mappings":"AAOA,qBASa,WAAW;CAAG"}
|
|
@@ -12,6 +12,10 @@ ProxyModule = __decorate([
|
|
|
12
12
|
imports: [CredentialsModule, EnvironmentsModule],
|
|
13
13
|
controllers: [ProxyController],
|
|
14
14
|
providers: [ProxyService, ProxyRepository],
|
|
15
|
+
// QueryModule reuses this: the two Prisma reads it does (who `owner`
|
|
16
|
+
// names, which account holds the envelope) have nothing proxy-specific
|
|
17
|
+
// about them.
|
|
18
|
+
exports: [ProxyRepository],
|
|
15
19
|
})
|
|
16
20
|
], ProxyModule);
|
|
17
21
|
export { ProxyModule };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.service.d.ts","sourceRoot":"","sources":["../../src/proxy/proxy.service.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAoBxD,MAAM,WAAW,Y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,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAoBxD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IACvD,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,yFAAyF;AACzF,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBACa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAJR,KAAK,EAAE,eAAe,EACtB,YAAY,EAAE,mBAAmB,EACjC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,kBAAkB;IAGzC,OAAO,CACX,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,WAAW,CAAC;IA2HvB,OAAO,CAAC,cAAc;CAevB"}
|
|
@@ -43,6 +43,11 @@ let ProxyService = class ProxyService {
|
|
|
43
43
|
const integration = this.registry.find(target.provider);
|
|
44
44
|
if (!integration)
|
|
45
45
|
throw new NotFoundException('Connection not found');
|
|
46
|
+
// A query-shaped integration (e.g. a direct database connection) has no
|
|
47
|
+
// REST API to forward to at all; see QueryService for its counterpart.
|
|
48
|
+
if (!integration.api) {
|
|
49
|
+
throw new NotFoundException(`${target.provider} has no HTTP proxy.`);
|
|
50
|
+
}
|
|
46
51
|
// Depends only on the provider, so a bad header is refused before any read.
|
|
47
52
|
const tokenKind = requestedTokenKind(integration, request.headers);
|
|
48
53
|
// Independent reads, so they go together: the configuration this slug
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-query.dto.d.ts","sourceRoot":"","sources":["../../../src/query/dto/run-query.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,WAAW;IAStB,GAAG,EAAG,MAAM,CAAC;IAQb,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
3
|
+
import { IsArray, IsOptional, IsString, MinLength } from 'class-validator';
|
|
4
|
+
export class RunQueryDto {
|
|
5
|
+
sql;
|
|
6
|
+
params;
|
|
7
|
+
}
|
|
8
|
+
__decorate([
|
|
9
|
+
ApiProperty({
|
|
10
|
+
example: 'SELECT id, name FROM users WHERE id = $1',
|
|
11
|
+
description: 'Run inside a read-only transaction that is always rolled back — a ' +
|
|
12
|
+
'write statement is rejected by the database itself.',
|
|
13
|
+
}),
|
|
14
|
+
IsString(),
|
|
15
|
+
MinLength(1),
|
|
16
|
+
__metadata("design:type", String)
|
|
17
|
+
], RunQueryDto.prototype, "sql", void 0);
|
|
18
|
+
__decorate([
|
|
19
|
+
ApiPropertyOptional({
|
|
20
|
+
example: [42],
|
|
21
|
+
description: 'Positional parameters for the SQL above, e.g. $1, $2.',
|
|
22
|
+
}),
|
|
23
|
+
IsOptional(),
|
|
24
|
+
IsArray(),
|
|
25
|
+
__metadata("design:type", Array)
|
|
26
|
+
], RunQueryDto.prototype, "params", void 0);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ApiKeyRequest } from '../auth/api-key.guard.js';
|
|
2
|
+
import { RunQueryDto } from './dto/run-query.dto.js';
|
|
3
|
+
import { QueryService } from './query.service.js';
|
|
4
|
+
export declare class QueryController {
|
|
5
|
+
private readonly query;
|
|
6
|
+
constructor(query: QueryService);
|
|
7
|
+
/**
|
|
8
|
+
* Addressed the same way `/api/proxy/...` is: the provider, the
|
|
9
|
+
* configuration slug it chose, and its own id for the person. There is no
|
|
10
|
+
* upstream path to reconstruct here — the SQL is the body — so this is
|
|
11
|
+
* simpler than `ProxyController`.
|
|
12
|
+
*/
|
|
13
|
+
run(request: ApiKeyRequest, provider: string, configurationSlug: string, owner: string, body: RunQueryDto): Promise<import("@kosha-ai/integration-sdk").QueryResult>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=query.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.controller.d.ts","sourceRoot":"","sources":["../../src/query/query.controller.ts"],"names":[],"mappings":"AAWA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,qBAEa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,YAAY;IAEhD;;;;;OAKG;IAaG,GAAG,CACA,OAAO,EAAE,aAAa,EACV,QAAQ,EAAE,MAAM,EACP,iBAAiB,EAAE,MAAM,EACrC,KAAK,EAAE,MAAM,EACrB,IAAI,EAAE,WAAW;CAe5B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
+
import { BadRequestException, Body, Controller, Param, Post, Req, UseGuards, } from '@nestjs/common';
|
|
3
|
+
import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger';
|
|
4
|
+
import { AllowAnonymous } from '@thallesp/nestjs-better-auth';
|
|
5
|
+
import { ApiKeyGuard } from '../auth/api-key.guard.js';
|
|
6
|
+
import { RunQueryDto } from './dto/run-query.dto.js';
|
|
7
|
+
import { QueryService } from './query.service.js';
|
|
8
|
+
let QueryController = class QueryController {
|
|
9
|
+
query;
|
|
10
|
+
constructor(query) {
|
|
11
|
+
this.query = query;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Addressed the same way `/api/proxy/...` is: the provider, the
|
|
15
|
+
* configuration slug it chose, and its own id for the person. There is no
|
|
16
|
+
* upstream path to reconstruct here — the SQL is the body — so this is
|
|
17
|
+
* simpler than `ProxyController`.
|
|
18
|
+
*/
|
|
19
|
+
async run(request, provider, configurationSlug, owner, body) {
|
|
20
|
+
if (!request.environmentId) {
|
|
21
|
+
throw new BadRequestException('This route needs an API key, which is what names the environment');
|
|
22
|
+
}
|
|
23
|
+
return this.query.run(request.organizationId, request.environmentId, { provider, configurationSlug, owner }, { sql: body.sql, params: body.params });
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
__decorate([
|
|
27
|
+
Post(':provider/:configurationSlug/:owner'),
|
|
28
|
+
AllowAnonymous(),
|
|
29
|
+
UseGuards(ApiKeyGuard),
|
|
30
|
+
ApiSecurity('x-api-key'),
|
|
31
|
+
ApiOperation({
|
|
32
|
+
summary: 'Run a read-only query against a connected provider',
|
|
33
|
+
description: 'The environment comes from the API key. `owner` is the app’s own id ' +
|
|
34
|
+
'for the person who connected. Every call runs inside a read-only ' +
|
|
35
|
+
'transaction that is always rolled back — a write statement is ' +
|
|
36
|
+
'rejected by the database itself, not by Kosha parsing the SQL.',
|
|
37
|
+
}),
|
|
38
|
+
__param(0, Req()),
|
|
39
|
+
__param(1, Param('provider')),
|
|
40
|
+
__param(2, Param('configurationSlug')),
|
|
41
|
+
__param(3, Param('owner')),
|
|
42
|
+
__param(4, Body()),
|
|
43
|
+
__metadata("design:type", Function),
|
|
44
|
+
__metadata("design:paramtypes", [Object, String, String, String, RunQueryDto]),
|
|
45
|
+
__metadata("design:returntype", Promise)
|
|
46
|
+
], QueryController.prototype, "run", null);
|
|
47
|
+
QueryController = __decorate([
|
|
48
|
+
ApiTags('query'),
|
|
49
|
+
Controller('query'),
|
|
50
|
+
__metadata("design:paramtypes", [QueryService])
|
|
51
|
+
], QueryController);
|
|
52
|
+
export { QueryController };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.module.d.ts","sourceRoot":"","sources":["../../src/query/query.module.ts"],"names":[],"mappings":"AAOA,qBAOa,WAAW;CAAG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { Module } from '@nestjs/common';
|
|
3
|
+
import { CredentialsModule } from '../credentials/credentials.module.js';
|
|
4
|
+
import { EnvironmentsModule } from '../environments/environments.module.js';
|
|
5
|
+
import { ProxyModule } from '../proxy/proxy.module.js';
|
|
6
|
+
import { QueryController } from './query.controller.js';
|
|
7
|
+
import { QueryService } from './query.service.js';
|
|
8
|
+
let QueryModule = class QueryModule {
|
|
9
|
+
};
|
|
10
|
+
QueryModule = __decorate([
|
|
11
|
+
Module({
|
|
12
|
+
// ProxyModule only for its exported ProxyRepository — the two Prisma reads
|
|
13
|
+
// it does are provider-agnostic.
|
|
14
|
+
imports: [CredentialsModule, EnvironmentsModule, ProxyModule],
|
|
15
|
+
controllers: [QueryController],
|
|
16
|
+
providers: [QueryService],
|
|
17
|
+
})
|
|
18
|
+
], QueryModule);
|
|
19
|
+
export { QueryModule };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { QueryResult } from '@kosha-ai/integration-sdk';
|
|
2
|
+
import { CredentialsService } from '../credentials/credentials.service.js';
|
|
3
|
+
import { EnvironmentsService } from '../environments/environments.service.js';
|
|
4
|
+
import { IntegrationRegistry } from '../integrations/integration.registry.js';
|
|
5
|
+
import { ProviderStore } from '../integrations/provider-store.js';
|
|
6
|
+
import { ProxyRepository } from '../proxy/proxy.repository.js';
|
|
7
|
+
/** What the URL names: which provider, which of its configurations, whose credential. */
|
|
8
|
+
export interface QueryTarget {
|
|
9
|
+
provider: string;
|
|
10
|
+
configurationSlug: string;
|
|
11
|
+
owner: string;
|
|
12
|
+
}
|
|
13
|
+
export interface QueryRequest {
|
|
14
|
+
sql: string;
|
|
15
|
+
params?: unknown[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The direct-connection counterpart to `ProxyService`: a query-shaped
|
|
19
|
+
* integration (declares `query`, not `api`) has no REST API to forward an
|
|
20
|
+
* HTTP request to, so the credential is handed to the integration's own
|
|
21
|
+
* `query.run` instead of signing a `fetch`.
|
|
22
|
+
*/
|
|
23
|
+
export declare class QueryService {
|
|
24
|
+
private readonly proxy;
|
|
25
|
+
private readonly environments;
|
|
26
|
+
private readonly store;
|
|
27
|
+
private readonly registry;
|
|
28
|
+
private readonly resolver;
|
|
29
|
+
constructor(proxy: ProxyRepository, environments: EnvironmentsService, store: ProviderStore, registry: IntegrationRegistry, resolver: CredentialsService);
|
|
30
|
+
run(organizationId: string, environmentId: string, target: QueryTarget, request: QueryRequest): Promise<QueryResult>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=query.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.service.d.ts","sourceRoot":"","sources":["../../src/query/query.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,yFAAyF;AACzF,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB;AAED;;;;;GAKG;AACH,qBACa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAJR,KAAK,EAAE,eAAe,EACtB,YAAY,EAAE,mBAAmB,EACjC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,kBAAkB;IAGzC,GAAG,CACP,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,WAAW,CAAC;CAwDxB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
3
|
+
import { CredentialsService } from '../credentials/credentials.service.js';
|
|
4
|
+
import { EnvironmentsService } from '../environments/environments.service.js';
|
|
5
|
+
import { IntegrationRegistry } from '../integrations/integration.registry.js';
|
|
6
|
+
import { ProviderStore } from '../integrations/provider-store.js';
|
|
7
|
+
import { ProxyRepository } from '../proxy/proxy.repository.js';
|
|
8
|
+
/**
|
|
9
|
+
* The direct-connection counterpart to `ProxyService`: a query-shaped
|
|
10
|
+
* integration (declares `query`, not `api`) has no REST API to forward an
|
|
11
|
+
* HTTP request to, so the credential is handed to the integration's own
|
|
12
|
+
* `query.run` instead of signing a `fetch`.
|
|
13
|
+
*/
|
|
14
|
+
let QueryService = class QueryService {
|
|
15
|
+
proxy;
|
|
16
|
+
environments;
|
|
17
|
+
store;
|
|
18
|
+
registry;
|
|
19
|
+
resolver;
|
|
20
|
+
constructor(proxy, environments, store, registry, resolver) {
|
|
21
|
+
this.proxy = proxy;
|
|
22
|
+
this.environments = environments;
|
|
23
|
+
this.store = store;
|
|
24
|
+
this.registry = registry;
|
|
25
|
+
this.resolver = resolver;
|
|
26
|
+
}
|
|
27
|
+
async run(organizationId, environmentId, target, request) {
|
|
28
|
+
const environment = await this.environments.get(organizationId, environmentId);
|
|
29
|
+
// Every miss below answers the same 404: a caller learns nothing about
|
|
30
|
+
// what exists in another environment, or under another owner.
|
|
31
|
+
const integration = this.registry.find(target.provider);
|
|
32
|
+
if (!integration)
|
|
33
|
+
throw new NotFoundException('Connection not found');
|
|
34
|
+
if (!integration.query) {
|
|
35
|
+
throw new NotFoundException(`${target.provider} has no query capability.`);
|
|
36
|
+
}
|
|
37
|
+
const [configuration, userId] = await Promise.all([
|
|
38
|
+
this.store.findConfigurationBySlugWithCredentials(integration, environment.id, target.configurationSlug),
|
|
39
|
+
this.proxy.findUserId(environment.slug, target.owner),
|
|
40
|
+
]);
|
|
41
|
+
if (!configuration || !userId) {
|
|
42
|
+
throw new NotFoundException('Connection not found');
|
|
43
|
+
}
|
|
44
|
+
const connection = await this.store.findConnection(integration, environment.id, configuration.id, userId);
|
|
45
|
+
if (!connection)
|
|
46
|
+
throw new NotFoundException('Connection not found');
|
|
47
|
+
const account = await this.proxy.findAccount(connection.accountId);
|
|
48
|
+
if (!account)
|
|
49
|
+
throw new NotFoundException('Connection not found');
|
|
50
|
+
const credential = await this.resolver.resolve(account, integration, configuration);
|
|
51
|
+
return integration.query.run({
|
|
52
|
+
credential: {
|
|
53
|
+
accessToken: credential.accessToken,
|
|
54
|
+
tokenType: credential.tokenType,
|
|
55
|
+
},
|
|
56
|
+
fields: configuration.fields,
|
|
57
|
+
metadata: asMetadata(connection.metadata),
|
|
58
|
+
sql: request.sql,
|
|
59
|
+
params: request.params,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
QueryService = __decorate([
|
|
64
|
+
Injectable(),
|
|
65
|
+
__metadata("design:paramtypes", [ProxyRepository,
|
|
66
|
+
EnvironmentsService,
|
|
67
|
+
ProviderStore,
|
|
68
|
+
IntegrationRegistry,
|
|
69
|
+
CredentialsService])
|
|
70
|
+
], QueryService);
|
|
71
|
+
export { QueryService };
|
|
72
|
+
/**
|
|
73
|
+
* Stored metadata is free-form JSON, so it may be an array, a number or null.
|
|
74
|
+
* Only an object is a metadata bag; anything else is treated as absent rather
|
|
75
|
+
* than handed to an integration that expects to index it.
|
|
76
|
+
*/
|
|
77
|
+
function asMetadata(metadata) {
|
|
78
|
+
return metadata !== null &&
|
|
79
|
+
typeof metadata === 'object' &&
|
|
80
|
+
!Array.isArray(metadata)
|
|
81
|
+
? metadata
|
|
82
|
+
: undefined;
|
|
83
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kosha-ai/server",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Kosha server: OAuth handshake, encrypted credential storage, token refresh, and an authenticated request proxy for third-party integrations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kosha",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"rxjs": "^7.8.0",
|
|
110
110
|
"tslib": "^2.3.0",
|
|
111
111
|
"zod": "4.5.4",
|
|
112
|
-
"@kosha-ai/integration-sdk": "0.4.
|
|
112
|
+
"@kosha-ai/integration-sdk": "0.4.2"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
115
|
"@nestjs/testing": "^11.0.0",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"@types/node-forge": "^1.3.14",
|
|
118
118
|
"@types/pg": "^8.23.1",
|
|
119
119
|
"prisma": "^7.10.0",
|
|
120
|
-
"@kosha-ai/integration-
|
|
121
|
-
"@kosha-ai/integration-
|
|
120
|
+
"@kosha-ai/integration-slack": "0.4.2",
|
|
121
|
+
"@kosha-ai/integration-github": "0.4.2"
|
|
122
122
|
}
|
|
123
123
|
}
|