@kosha-ai/server 0.2.0 → 0.4.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.
Files changed (125) hide show
  1. package/dist/auth/auth.factory.d.ts.map +1 -1
  2. package/dist/auth/auth.factory.js +0 -5
  3. package/dist/configurations/configurations.controller.d.ts +6 -5
  4. package/dist/configurations/configurations.controller.d.ts.map +1 -1
  5. package/dist/configurations/configurations.controller.js +22 -18
  6. package/dist/configurations/configurations.module.d.ts.map +1 -1
  7. package/dist/configurations/configurations.module.js +1 -2
  8. package/dist/configurations/configurations.service.d.ts +29 -35
  9. package/dist/configurations/configurations.service.d.ts.map +1 -1
  10. package/dist/configurations/configurations.service.js +126 -149
  11. package/dist/configurations/dto/create-configuration.dto.d.ts +2 -2
  12. package/dist/configurations/dto/create-configuration.dto.d.ts.map +1 -1
  13. package/dist/configurations/dto/create-configuration.dto.js +6 -6
  14. package/dist/configurations/dto/update-configuration.dto.d.ts +1 -2
  15. package/dist/configurations/dto/update-configuration.dto.d.ts.map +1 -1
  16. package/dist/configurations/dto/update-configuration.dto.js +7 -13
  17. package/dist/connect/connect.controller.d.ts +12 -2
  18. package/dist/connect/connect.controller.d.ts.map +1 -1
  19. package/dist/connect/connect.controller.js +108 -18
  20. package/dist/connect/connect.module.d.ts.map +1 -1
  21. package/dist/connect/connect.module.js +1 -2
  22. package/dist/connect/connect.repository.d.ts +34 -25
  23. package/dist/connect/connect.repository.d.ts.map +1 -1
  24. package/dist/connect/connect.repository.js +45 -52
  25. package/dist/connect/connect.service.d.ts +54 -8
  26. package/dist/connect/connect.service.d.ts.map +1 -1
  27. package/dist/connect/connect.service.js +312 -68
  28. package/dist/connect/dto/connect-credential.dto.d.ts +8 -0
  29. package/dist/connect/dto/connect-credential.dto.d.ts.map +1 -0
  30. package/dist/connect/dto/connect-credential.dto.js +54 -0
  31. package/dist/connect/dto/create-connect-session.dto.d.ts +1 -1
  32. package/dist/connect/dto/create-connect-session.dto.d.ts.map +1 -1
  33. package/dist/connect/dto/create-connect-session.dto.js +7 -8
  34. package/dist/connect/dto/create-test-session.dto.d.ts +8 -0
  35. package/dist/connect/dto/create-test-session.dto.d.ts.map +1 -1
  36. package/dist/connect/dto/create-test-session.dto.js +45 -3
  37. package/dist/connections/connections.controller.d.ts +4 -3
  38. package/dist/connections/connections.controller.d.ts.map +1 -1
  39. package/dist/connections/connections.controller.js +13 -11
  40. package/dist/connections/connections.repository.d.ts +24 -17
  41. package/dist/connections/connections.repository.d.ts.map +1 -1
  42. package/dist/connections/connections.repository.js +21 -43
  43. package/dist/connections/connections.service.d.ts +48 -13
  44. package/dist/connections/connections.service.d.ts.map +1 -1
  45. package/dist/connections/connections.service.js +111 -32
  46. package/dist/connections/dto/list-connections.dto.d.ts +3 -1
  47. package/dist/connections/dto/list-connections.dto.d.ts.map +1 -1
  48. package/dist/connections/dto/list-connections.dto.js +26 -4
  49. package/dist/connections/environment-connections.controller.d.ts +4 -3
  50. package/dist/connections/environment-connections.controller.d.ts.map +1 -1
  51. package/dist/connections/environment-connections.controller.js +14 -12
  52. package/dist/credentials/credentials.module.d.ts.map +1 -1
  53. package/dist/credentials/credentials.module.js +0 -2
  54. package/dist/credentials/credentials.repository.d.ts +5 -2
  55. package/dist/credentials/credentials.repository.d.ts.map +1 -1
  56. package/dist/credentials/credentials.repository.js +10 -3
  57. package/dist/credentials/credentials.service.d.ts +14 -4
  58. package/dist/credentials/credentials.service.d.ts.map +1 -1
  59. package/dist/credentials/credentials.service.js +106 -30
  60. package/dist/crypto/credential-envelope.d.ts +27 -1
  61. package/dist/crypto/credential-envelope.d.ts.map +1 -1
  62. package/dist/crypto/credential-envelope.js +43 -0
  63. package/dist/egress/egress.listener.d.ts +1 -3
  64. package/dist/egress/egress.listener.d.ts.map +1 -1
  65. package/dist/egress/egress.listener.js +3 -7
  66. package/dist/egress/egress.repository.d.ts +13 -6
  67. package/dist/egress/egress.repository.d.ts.map +1 -1
  68. package/dist/egress/egress.repository.js +31 -44
  69. package/dist/generated/prisma/browser.d.ts +0 -5
  70. package/dist/generated/prisma/browser.d.ts.map +1 -1
  71. package/dist/generated/prisma/client.d.ts +0 -5
  72. package/dist/generated/prisma/client.d.ts.map +1 -1
  73. package/dist/generated/prisma/commonInputTypes.d.ts +0 -55
  74. package/dist/generated/prisma/commonInputTypes.d.ts.map +1 -1
  75. package/dist/generated/prisma/internal/class.d.ts +0 -11
  76. package/dist/generated/prisma/internal/class.d.ts.map +1 -1
  77. package/dist/generated/prisma/internal/class.js +4 -4
  78. package/dist/generated/prisma/internal/prismaNamespace.d.ts +1 -114
  79. package/dist/generated/prisma/internal/prismaNamespace.d.ts.map +1 -1
  80. package/dist/generated/prisma/internal/prismaNamespace.js +2 -29
  81. package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +0 -30
  82. package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts.map +1 -1
  83. package/dist/generated/prisma/internal/prismaNamespaceBrowser.js +2 -29
  84. package/dist/generated/prisma/models/Account.d.ts +26 -344
  85. package/dist/generated/prisma/models/Account.d.ts.map +1 -1
  86. package/dist/generated/prisma/models/Environment.d.ts +0 -258
  87. package/dist/generated/prisma/models/Environment.d.ts.map +1 -1
  88. package/dist/generated/prisma/models/User.d.ts +2 -60
  89. package/dist/generated/prisma/models/User.d.ts.map +1 -1
  90. package/dist/generated/prisma/models.d.ts +0 -1
  91. package/dist/generated/prisma/models.d.ts.map +1 -1
  92. package/dist/index.d.ts +1 -2
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/integrations/client-context.d.ts +20 -0
  95. package/dist/integrations/client-context.d.ts.map +1 -0
  96. package/dist/integrations/client-context.js +23 -0
  97. package/dist/integrations/integrations.controller.d.ts +6 -0
  98. package/dist/integrations/integrations.controller.d.ts.map +1 -1
  99. package/dist/integrations/integrations.controller.js +3 -0
  100. package/dist/integrations/integrations.module.d.ts.map +1 -1
  101. package/dist/integrations/integrations.module.js +3 -1
  102. package/dist/integrations/provider-store.d.ts +110 -0
  103. package/dist/integrations/provider-store.d.ts.map +1 -0
  104. package/dist/integrations/provider-store.js +302 -0
  105. package/dist/proxy/proxy.controller.d.ts +17 -5
  106. package/dist/proxy/proxy.controller.d.ts.map +1 -1
  107. package/dist/proxy/proxy.controller.js +46 -17
  108. package/dist/proxy/proxy.module.d.ts.map +1 -1
  109. package/dist/proxy/proxy.module.js +1 -2
  110. package/dist/proxy/proxy.repository.d.ts +11 -14
  111. package/dist/proxy/proxy.repository.d.ts.map +1 -1
  112. package/dist/proxy/proxy.repository.js +17 -27
  113. package/dist/proxy/proxy.service.d.ts +6 -8
  114. package/dist/proxy/proxy.service.d.ts.map +1 -1
  115. package/dist/proxy/proxy.service.js +72 -31
  116. package/package.json +4 -4
  117. package/prisma/migrations/{20260929101936_init → 20261008090000_init}/migration.sql +5 -58
  118. package/prisma/schema.prisma +2 -43
  119. package/dist/configurations/configurations.repository.d.ts +0 -43
  120. package/dist/configurations/configurations.repository.d.ts.map +0 -1
  121. package/dist/configurations/configurations.repository.js +0 -76
  122. package/dist/generated/prisma/models/Configuration.d.ts +0 -1385
  123. package/dist/generated/prisma/models/Configuration.d.ts.map +0 -1
  124. package/dist/generated/prisma/models/Configuration.js +0 -1
  125. package/prisma/migrations/20260930102529_connection_config/migration.sql +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"auth.factory.d.ts","sourceRoot":"","sources":["../../src/auth/auth.factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAIpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAEnF,gFAAgF;AAChF,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE;YAAE,GAAG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EAAE,mBAAmB,GAC1B;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,IAAI,CAAA;CAAE,GAAG,SAAS,CAYhD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,mBAAmB,GAChC,SAAS,CAwEX"}
@@ -41,11 +41,6 @@ export function createAuth(config, prisma, environments) {
41
41
  emailAndPassword: {
42
42
  enabled: config.auth.emailAndPassword?.enabled ?? true,
43
43
  },
44
- user: {
45
- additionalFields: {
46
- externalId: { type: 'string', required: false, input: false },
47
- },
48
- },
49
44
  trustedOrigins: config.auth.trustedOrigins ?? [],
50
45
  advanced: { defaultCookieAttributes: crossSiteCookieAttributes(config) },
51
46
  hooks: {
@@ -10,11 +10,12 @@ import { UpdateConfigurationDto } from './dto/update-configuration.dto.js';
10
10
  export declare class ConfigurationsController {
11
11
  private readonly configurations;
12
12
  constructor(configurations: ConfigurationsService);
13
- list(session: UserSession, environmentId: string): Promise<import("./configurations.repository.js").PublicConfiguration[]>;
14
- get(session: UserSession, environmentId: string, id: string): Promise<import("./configurations.repository.js").PublicConfiguration>;
15
- create(session: UserSession, environmentId: string, body: CreateConfigurationDto): Promise<import("./configurations.repository.js").PublicConfiguration>;
16
- update(session: UserSession, environmentId: string, id: string, body: UpdateConfigurationDto): Promise<import("./configurations.repository.js").PublicConfiguration>;
17
- remove(session: UserSession, environmentId: string, id: string): Promise<{
13
+ list(session: UserSession, environmentId: string): Promise<import("./configurations.service.js").DescribedConfiguration[]>;
14
+ /** The provider names the table the id lives in, so it is part of the path. */
15
+ get(session: UserSession, environmentId: string, provider: string, id: string): Promise<import("./configurations.service.js").DescribedConfiguration>;
16
+ create(session: UserSession, environmentId: string, body: CreateConfigurationDto): Promise<import("./configurations.service.js").DescribedConfiguration>;
17
+ update(session: UserSession, environmentId: string, provider: string, id: string, body: UpdateConfigurationDto): Promise<import("./configurations.service.js").DescribedConfiguration>;
18
+ remove(session: UserSession, environmentId: string, provider: string, id: string): Promise<{
18
19
  id: string;
19
20
  deleted: boolean;
20
21
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"configurations.controller.d.ts","sourceRoot":"","sources":["../../src/configurations/configurations.controller.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAE3E;;;;GAIG;AACH,qBAEa,wBAAwB;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;gBAAd,cAAc,EAAE,qBAAqB;IAKlE,IAAI,CACS,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM;IAY/C,GAAG,CACU,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EAChC,EAAE,EAAE,MAAM;IAqBzB,MAAM,CACO,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EACrC,IAAI,EAAE,sBAAsB;IAatC,MAAM,CACO,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EAChC,EAAE,EAAE,MAAM,EACf,IAAI,EAAE,sBAAsB;IAqBhC,MAAM,CACC,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EAChC,EAAE,EAAE,MAAM;;;;CAU1B"}
1
+ {"version":3,"file":"configurations.controller.d.ts","sourceRoot":"","sources":["../../src/configurations/configurations.controller.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAE3E;;;;GAIG;AACH,qBAEa,wBAAwB;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;gBAAd,cAAc,EAAE,qBAAqB;IAKlE,IAAI,CACS,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM;IAS/C,+EAA+E;IAI/E,GAAG,CACU,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EAC1B,QAAQ,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM;IAsBzB,MAAM,CACO,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EACrC,IAAI,EAAE,sBAAsB;IAatC,MAAM,CACO,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EAC1B,QAAQ,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM,EACf,IAAI,EAAE,sBAAsB;IAsBhC,MAAM,CACC,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EAC1B,QAAQ,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM;;;;CAW1B"}
@@ -19,17 +19,18 @@ let ConfigurationsController = class ConfigurationsController {
19
19
  list(session, environmentId) {
20
20
  return this.configurations.list(getActiveOrganizationId(session), session.user.id, environmentId);
21
21
  }
22
- get(session, environmentId, id) {
23
- return this.configurations.get(getActiveOrganizationId(session), session.user.id, environmentId, id);
22
+ /** The provider names the table the id lives in, so it is part of the path. */
23
+ get(session, environmentId, provider, id) {
24
+ return this.configurations.get(getActiveOrganizationId(session), session.user.id, environmentId, provider, id);
24
25
  }
25
26
  create(session, environmentId, body) {
26
27
  return this.configurations.create(getActiveOrganizationId(session), session.user.id, environmentId, body);
27
28
  }
28
- update(session, environmentId, id, body) {
29
- return this.configurations.update(getActiveOrganizationId(session), session.user.id, environmentId, id, body);
29
+ update(session, environmentId, provider, id, body) {
30
+ return this.configurations.update(getActiveOrganizationId(session), session.user.id, environmentId, provider, id, body);
30
31
  }
31
- async remove(session, environmentId, id) {
32
- await this.configurations.remove(getActiveOrganizationId(session), session.user.id, environmentId, id);
32
+ async remove(session, environmentId, provider, id) {
33
+ await this.configurations.remove(getActiveOrganizationId(session), session.user.id, environmentId, provider, id);
33
34
  return { id, deleted: true };
34
35
  }
35
36
  };
@@ -44,14 +45,15 @@ __decorate([
44
45
  __metadata("design:returntype", void 0)
45
46
  ], ConfigurationsController.prototype, "list", null);
46
47
  __decorate([
47
- Get(':id'),
48
+ Get(':provider/:id'),
48
49
  ApiOperation({ summary: 'Get one configuration' }),
49
50
  ApiNotFoundResponse({ description: 'No such configuration here.' }),
50
51
  __param(0, Session()),
51
52
  __param(1, Param('environmentId')),
52
- __param(2, Param('id')),
53
+ __param(2, Param('provider')),
54
+ __param(3, Param('id')),
53
55
  __metadata("design:type", Function),
54
- __metadata("design:paramtypes", [Object, String, String]),
56
+ __metadata("design:paramtypes", [Object, String, String, String]),
55
57
  __metadata("design:returntype", void 0)
56
58
  ], ConfigurationsController.prototype, "get", null);
57
59
  __decorate([
@@ -59,7 +61,7 @@ __decorate([
59
61
  HttpCode(HttpStatus.CREATED),
60
62
  ApiOperation({
61
63
  summary: 'Set up a provider in this environment',
62
- description: 'The integration key names an installed package; the auth type comes from it rather than from the request.',
64
+ description: 'The provider names an installed package, and its tables are where the configuration is written.',
63
65
  }),
64
66
  ApiCreatedResponse({ description: 'The created configuration.' }),
65
67
  ApiConflictResponse({
@@ -73,22 +75,23 @@ __decorate([
73
75
  __metadata("design:returntype", void 0)
74
76
  ], ConfigurationsController.prototype, "create", null);
75
77
  __decorate([
76
- Patch(':id'),
78
+ Patch(':provider/:id'),
77
79
  ApiOperation({ summary: 'Update a configuration' }),
78
80
  ApiOkResponse({ description: 'The updated configuration.' }),
79
81
  __param(0, Session()),
80
82
  __param(1, Param('environmentId')),
81
- __param(2, Param('id')),
82
- __param(3, Body()),
83
+ __param(2, Param('provider')),
84
+ __param(3, Param('id')),
85
+ __param(4, Body()),
83
86
  __metadata("design:type", Function),
84
- __metadata("design:paramtypes", [Object, String, String, UpdateConfigurationDto]),
87
+ __metadata("design:paramtypes", [Object, String, String, String, UpdateConfigurationDto]),
85
88
  __metadata("design:returntype", void 0)
86
89
  ], ConfigurationsController.prototype, "update", null);
87
90
  __decorate([
88
- Delete(':id'),
91
+ Delete(':provider/:id'),
89
92
  ApiOperation({
90
93
  summary: 'Delete a configuration',
91
- description: 'Refused while connections still use it, since nothing in the database would stop those credentials being orphaned.',
94
+ description: 'Refused while connections still use it — the foreign key would refuse it anyway, and this reports which.',
92
95
  }),
93
96
  ApiOkResponse({ description: 'The deleted configuration id.' }),
94
97
  ApiConflictResponse({
@@ -96,9 +99,10 @@ __decorate([
96
99
  }),
97
100
  __param(0, Session()),
98
101
  __param(1, Param('environmentId')),
99
- __param(2, Param('id')),
102
+ __param(2, Param('provider')),
103
+ __param(3, Param('id')),
100
104
  __metadata("design:type", Function),
101
- __metadata("design:paramtypes", [Object, String, String]),
105
+ __metadata("design:paramtypes", [Object, String, String, String]),
102
106
  __metadata("design:returntype", Promise)
103
107
  ], ConfigurationsController.prototype, "remove", null);
104
108
  ConfigurationsController = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"configurations.module.d.ts","sourceRoot":"","sources":["../../src/configurations/configurations.module.ts"],"names":[],"mappings":"AAMA,qBAMa,oBAAoB;CAAG"}
1
+ {"version":3,"file":"configurations.module.d.ts","sourceRoot":"","sources":["../../src/configurations/configurations.module.ts"],"names":[],"mappings":"AAKA,qBAMa,oBAAoB;CAAG"}
@@ -2,7 +2,6 @@ import { __decorate } from "tslib";
2
2
  import { Module } from '@nestjs/common';
3
3
  import { EnvironmentsModule } from '../environments/environments.module.js';
4
4
  import { ConfigurationsController } from './configurations.controller.js';
5
- import { ConfigurationsRepository } from './configurations.repository.js';
6
5
  import { ConfigurationsService } from './configurations.service.js';
7
6
  let ConfigurationsModule = class ConfigurationsModule {
8
7
  };
@@ -10,7 +9,7 @@ ConfigurationsModule = __decorate([
10
9
  Module({
11
10
  imports: [EnvironmentsModule],
12
11
  controllers: [ConfigurationsController],
13
- providers: [ConfigurationsService, ConfigurationsRepository],
12
+ providers: [ConfigurationsService],
14
13
  exports: [ConfigurationsService],
15
14
  })
16
15
  ], ConfigurationsModule);
@@ -1,60 +1,54 @@
1
- import type { ResolvedKoshaConfig } from '../config/kosha-config.js';
2
1
  import { CryptoService } from '../crypto/crypto.service.js';
3
2
  import { EnvironmentsService } from '../environments/environments.service.js';
4
- import type { Configuration } from '../generated/prisma/client.js';
5
3
  import { IntegrationRegistry } from '../integrations/integration.registry.js';
6
- import { ConfigurationsRepository } from './configurations.repository.js';
4
+ import { ProviderStore, type ProviderConfiguration, type PublicProviderConfiguration } from '../integrations/provider-store.js';
7
5
  import type { CreateConfigurationDto } from './dto/create-configuration.dto.js';
8
6
  import type { UpdateConfigurationDto } from './dto/update-configuration.dto.js';
7
+ /** A configuration with the provider it belongs to named, as a client sees it. */
8
+ export type DescribedConfiguration = PublicProviderConfiguration & {
9
+ provider: string;
10
+ authType: string;
11
+ };
9
12
  /** A configuration with its secrets opened. Never leaves the server. */
10
13
  export interface ConfigurationWithCredentials {
11
- configuration: Configuration;
14
+ configuration: ProviderConfiguration;
12
15
  credentials: Record<string, unknown>;
13
16
  }
14
17
  export declare class ConfigurationsService {
15
- private readonly configurations;
18
+ private readonly store;
16
19
  private readonly environments;
17
20
  private readonly crypto;
18
21
  private readonly registry;
19
- private readonly config;
20
- constructor(configurations: ConfigurationsRepository, environments: EnvironmentsService, crypto: CryptoService, registry: IntegrationRegistry, config: ResolvedKoshaConfig);
22
+ constructor(store: ProviderStore, environments: EnvironmentsService, crypto: CryptoService, registry: IntegrationRegistry);
21
23
  /**
22
- * The redirect URI the provider must be told about. Derived from
23
- * `server.publicUrl` so it is stable and inspectable in the admin, rather
24
- * than being reconstructed per request.
24
+ * Every configuration in an environment, across every installed provider.
25
+ *
26
+ * Kosha owns no table that lists them, so this asks each provider in turn.
27
+ * An environment holds a handful, and each read is an index lookup.
25
28
  */
26
- callbackUrlFor(integrationKey: string): string;
27
- list(organizationId: string, userId: string, environmentId: string): Promise<import("./configurations.repository.js").PublicConfiguration[]>;
28
- get(organizationId: string, userId: string, environmentId: string, id: string): Promise<import("./configurations.repository.js").PublicConfiguration>;
29
- /** How a caller's slug resolves, once a key has named the environment. */
30
- getBySlug(environmentId: string, slug: string): Promise<import("./configurations.repository.js").PublicConfiguration>;
31
- create(organizationId: string, userId: string, environmentId: string, input: CreateConfigurationDto): Promise<import("./configurations.repository.js").PublicConfiguration>;
32
- update(organizationId: string, userId: string, environmentId: string, id: string, input: UpdateConfigurationDto): Promise<import("./configurations.repository.js").PublicConfiguration>;
33
- /**
34
- * Refused while credentials still point at this row. `account.providerId` is
35
- * a plain string, so nothing in the database would stop the delete from
36
- * orphaning them.
37
- */
38
- remove(organizationId: string, userId: string, environmentId: string, id: string): Promise<void>;
29
+ list(organizationId: string, userId: string, environmentId: string): Promise<DescribedConfiguration[]>;
30
+ get(organizationId: string, userId: string, environmentId: string, provider: string, id: string): Promise<DescribedConfiguration>;
31
+ create(organizationId: string, userId: string, environmentId: string, input: CreateConfigurationDto): Promise<DescribedConfiguration>;
32
+ update(organizationId: string, userId: string, environmentId: string, provider: string, id: string, input: UpdateConfigurationDto): Promise<DescribedConfiguration>;
33
+ /** Refused while connections still point at this row. */
34
+ remove(organizationId: string, userId: string, environmentId: string, provider: string, id: string): Promise<void>;
39
35
  /**
40
36
  * Opens the secret half, for the connect and proxy paths only. Never
41
37
  * reachable from a controller.
42
38
  */
43
- getWithCredentials(configurationId: string): Promise<ConfigurationWithCredentials>;
39
+ getWithCredentials(provider: string, configurationId: string): Promise<ConfigurationWithCredentials>;
44
40
  /**
45
- * What the auth type needs, encrypted as one blob rather than a column per
46
- * field — a GitHub App configuration holds an appId and a private key where
47
- * an OAuth2 one holds a client id and secret, and neither should force a
48
- * migration on the other.
41
+ * Refuses a URL the server would later be made to fetch from inside its own
42
+ * network. Checked when saved so an operator sees why, and again on every
43
+ * proxied call, since what a hostname resolves to can change.
49
44
  */
50
- private sealCredentials;
45
+ private checkedFields;
51
46
  /**
52
- * Checks per-organization settings against the integration's declared
53
- * `configFields`, and any scopes against what the provider actually offers.
54
- * Integrations describe their settings as data so the admin can render a
55
- * form; the same description is what validates here.
47
+ * Seals the whole credential set as one blob, so the shape is the auth
48
+ * type's business rather than the schema's: an OAuth2 provider stores a
49
+ * client id and secret, and a provider whose end users bring their own key
50
+ * stores nothing at all.
56
51
  */
57
- private validateSettings;
58
- private validateScopes;
52
+ private sealCredentials;
59
53
  }
60
54
  //# sourceMappingURL=configurations.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"configurations.service.d.ts","sourceRoot":"","sources":["../../src/configurations/configurations.service.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAU,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAEhF,wEAAwE;AACxE,MAAM,WAAW,4BAA4B;IAC3C,aAAa,EAAE,aAAa,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,qBACa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAJ5B,cAAc,EAAE,wBAAwB,EACxC,YAAY,EAAE,mBAAmB,EACjC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,mBAAmB,EACP,MAAM,EAAE,mBAAmB;IAGpE;;;;OAIG;IACH,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;IAKxC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;IAKlE,GAAG,CACP,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,EAAE,EAAE,MAAM;IASZ,0EAA0E;IACpE,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAS7C,MAAM,CACV,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,sBAAsB;IAyCzB,MAAM,CACV,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,sBAAsB;IAkB/B;;;;OAIG;IACG,MAAM,CACV,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,EAAE,EAAE,MAAM;IAcZ;;;OAGG;IACG,kBAAkB,CACtB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,4BAA4B,CAAC;IAgBxC;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAsBvB;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IA4CxB,OAAO,CAAC,cAAc;CAkBvB"}
1
+ {"version":3,"file":"configurations.service.d.ts","sourceRoot":"","sources":["../../src/configurations/configurations.service.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCA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