@shipfox/api-integration-core 2.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/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-type$colon$emit.log +1 -0
- package/.turbo/turbo-type.log +1 -0
- package/CHANGELOG.md +264 -0
- package/LICENSE +21 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +29 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-tool-selection.d.ts +15 -0
- package/dist/core/agent-tool-selection.d.ts.map +1 -0
- package/dist/core/agent-tool-selection.js +48 -0
- package/dist/core/agent-tool-selection.js.map +1 -0
- package/dist/core/entities/connection.d.ts +2 -0
- package/dist/core/entities/connection.d.ts.map +1 -0
- package/dist/core/entities/connection.js +3 -0
- package/dist/core/entities/connection.js.map +1 -0
- package/dist/core/entities/provider.d.ts +6 -0
- package/dist/core/entities/provider.d.ts.map +1 -0
- package/dist/core/entities/provider.js +3 -0
- package/dist/core/entities/provider.js.map +1 -0
- package/dist/core/errors.d.ts +29 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +40 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/providers/agent-tools.d.ts +2 -0
- package/dist/core/providers/agent-tools.d.ts.map +1 -0
- package/dist/core/providers/agent-tools.js +3 -0
- package/dist/core/providers/agent-tools.js.map +1 -0
- package/dist/core/providers/redact-checkout-spec.d.ts +9 -0
- package/dist/core/providers/redact-checkout-spec.d.ts.map +1 -0
- package/dist/core/providers/redact-checkout-spec.js +25 -0
- package/dist/core/providers/redact-checkout-spec.js.map +1 -0
- package/dist/core/providers/registry.d.ts +9 -0
- package/dist/core/providers/registry.d.ts.map +1 -0
- package/dist/core/providers/registry.js +52 -0
- package/dist/core/providers/registry.js.map +1 -0
- package/dist/core/providers/source-control.d.ts +2 -0
- package/dist/core/providers/source-control.d.ts.map +1 -0
- package/dist/core/providers/source-control.js +3 -0
- package/dist/core/providers/source-control.js.map +1 -0
- package/dist/core/source-control-service.d.ts +46 -0
- package/dist/core/source-control-service.d.ts.map +1 -0
- package/dist/core/source-control-service.js +84 -0
- package/dist/core/source-control-service.js.map +1 -0
- package/dist/db/connections.d.ts +67 -0
- package/dist/db/connections.d.ts.map +1 -0
- package/dist/db/connections.js +130 -0
- package/dist/db/connections.js.map +1 -0
- package/dist/db/db.d.ts +865 -0
- package/dist/db/db.d.ts.map +1 -0
- package/dist/db/db.js +22 -0
- package/dist/db/db.js.map +1 -0
- package/dist/db/migrations.d.ts +2 -0
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +5 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/schema/common.d.ts +2 -0
- package/dist/db/schema/common.d.ts.map +1 -0
- package/dist/db/schema/common.js +4 -0
- package/dist/db/schema/common.js.map +1 -0
- package/dist/db/schema/connections.d.ts +165 -0
- package/dist/db/schema/connections.d.ts.map +1 -0
- package/dist/db/schema/connections.js +37 -0
- package/dist/db/schema/connections.js.map +1 -0
- package/dist/db/schema/outbox.d.ts +195 -0
- package/dist/db/schema/outbox.d.ts.map +1 -0
- package/dist/db/schema/outbox.js +5 -0
- package/dist/db/schema/outbox.js.map +1 -0
- package/dist/db/schema/webhook-deliveries.d.ts +76 -0
- package/dist/db/schema/webhook-deliveries.d.ts.map +1 -0
- package/dist/db/schema/webhook-deliveries.js +22 -0
- package/dist/db/schema/webhook-deliveries.js.map +1 -0
- package/dist/db/webhook-deliveries.d.ts +55 -0
- package/dist/db/webhook-deliveries.d.ts.map +1 -0
- package/dist/db/webhook-deliveries.js +132 -0
- package/dist/db/webhook-deliveries.js.map +1 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +105 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +3 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/instance.d.ts +8 -0
- package/dist/metrics/instance.d.ts.map +1 -0
- package/dist/metrics/instance.js +17 -0
- package/dist/metrics/instance.js.map +1 -0
- package/dist/presentation/dto/integrations.d.ts +36 -0
- package/dist/presentation/dto/integrations.d.ts.map +1 -0
- package/dist/presentation/dto/integrations.js +26 -0
- package/dist/presentation/dto/integrations.js.map +1 -0
- package/dist/presentation/routes/agent-tools-gateway/audit.d.ts +24 -0
- package/dist/presentation/routes/agent-tools-gateway/audit.d.ts.map +1 -0
- package/dist/presentation/routes/agent-tools-gateway/audit.js +52 -0
- package/dist/presentation/routes/agent-tools-gateway/audit.js.map +1 -0
- package/dist/presentation/routes/agent-tools-gateway/dispatch.d.ts +7 -0
- package/dist/presentation/routes/agent-tools-gateway/dispatch.d.ts.map +1 -0
- package/dist/presentation/routes/agent-tools-gateway/dispatch.js +108 -0
- package/dist/presentation/routes/agent-tools-gateway/dispatch.js.map +1 -0
- package/dist/presentation/routes/agent-tools-gateway/index.d.ts +12 -0
- package/dist/presentation/routes/agent-tools-gateway/index.d.ts.map +1 -0
- package/dist/presentation/routes/agent-tools-gateway/index.js +46 -0
- package/dist/presentation/routes/agent-tools-gateway/index.js.map +1 -0
- package/dist/presentation/routes/agent-tools-gateway/mcp-server.d.ts +17 -0
- package/dist/presentation/routes/agent-tools-gateway/mcp-server.d.ts.map +1 -0
- package/dist/presentation/routes/agent-tools-gateway/mcp-server.js +126 -0
- package/dist/presentation/routes/agent-tools-gateway/mcp-server.js.map +1 -0
- package/dist/presentation/routes/agent-tools-gateway/resolve-authorized-tools.d.ts +37 -0
- package/dist/presentation/routes/agent-tools-gateway/resolve-authorized-tools.d.ts.map +1 -0
- package/dist/presentation/routes/agent-tools-gateway/resolve-authorized-tools.js +145 -0
- package/dist/presentation/routes/agent-tools-gateway/resolve-authorized-tools.js.map +1 -0
- package/dist/presentation/routes/errors.d.ts +2 -0
- package/dist/presentation/routes/errors.d.ts.map +1 -0
- package/dist/presentation/routes/errors.js +53 -0
- package/dist/presentation/routes/errors.js.map +1 -0
- package/dist/presentation/routes/index.d.ts +14 -0
- package/dist/presentation/routes/index.d.ts.map +1 -0
- package/dist/presentation/routes/index.js +26 -0
- package/dist/presentation/routes/index.js.map +1 -0
- package/dist/presentation/routes/list-connections.d.ts +3 -0
- package/dist/presentation/routes/list-connections.d.ts.map +1 -0
- package/dist/presentation/routes/list-connections.js +58 -0
- package/dist/presentation/routes/list-connections.js.map +1 -0
- package/dist/presentation/routes/list-providers.d.ts +3 -0
- package/dist/presentation/routes/list-providers.d.ts.map +1 -0
- package/dist/presentation/routes/list-providers.js +27 -0
- package/dist/presentation/routes/list-providers.js.map +1 -0
- package/dist/presentation/routes/list-repositories.d.ts +3 -0
- package/dist/presentation/routes/list-repositories.d.ts.map +1 -0
- package/dist/presentation/routes/list-repositories.js +41 -0
- package/dist/presentation/routes/list-repositories.js.map +1 -0
- package/dist/presentation/routes/manage-connections.d.ts +4 -0
- package/dist/presentation/routes/manage-connections.d.ts.map +1 -0
- package/dist/presentation/routes/manage-connections.js +81 -0
- package/dist/presentation/routes/manage-connections.js.map +1 -0
- package/dist/providers/connection-slug.d.ts +2 -0
- package/dist/providers/connection-slug.d.ts.map +1 -0
- package/dist/providers/connection-slug.js +19 -0
- package/dist/providers/connection-slug.js.map +1 -0
- package/dist/providers/cron.d.ts +3 -0
- package/dist/providers/cron.d.ts.map +1 -0
- package/dist/providers/cron.js +13 -0
- package/dist/providers/cron.js.map +1 -0
- package/dist/providers/gitea.d.ts +3 -0
- package/dist/providers/gitea.d.ts.map +1 -0
- package/dist/providers/gitea.js +75 -0
- package/dist/providers/gitea.js.map +1 -0
- package/dist/providers/github.d.ts +3 -0
- package/dist/providers/github.d.ts.map +1 -0
- package/dist/providers/github.js +109 -0
- package/dist/providers/github.js.map +1 -0
- package/dist/providers/linear.d.ts +3 -0
- package/dist/providers/linear.d.ts.map +1 -0
- package/dist/providers/linear.js +134 -0
- package/dist/providers/linear.js.map +1 -0
- package/dist/providers/modules.d.ts +3 -0
- package/dist/providers/modules.d.ts.map +1 -0
- package/dist/providers/modules.js +26 -0
- package/dist/providers/modules.js.map +1 -0
- package/dist/providers/sentry.d.ts +3 -0
- package/dist/providers/sentry.d.ts.map +1 -0
- package/dist/providers/sentry.js +83 -0
- package/dist/providers/sentry.js.map +1 -0
- package/dist/providers/types.d.ts +58 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +3 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/providers/webhook.d.ts +3 -0
- package/dist/providers/webhook.d.ts.map +1 -0
- package/dist/providers/webhook.js +24 -0
- package/dist/providers/webhook.js.map +1 -0
- package/dist/temporal/activities/index.d.ts +5 -0
- package/dist/temporal/activities/index.d.ts.map +1 -0
- package/dist/temporal/activities/index.js +8 -0
- package/dist/temporal/activities/index.js.map +1 -0
- package/dist/temporal/activities/prune-webhook-deliveries.d.ts +4 -0
- package/dist/temporal/activities/prune-webhook-deliveries.d.ts.map +1 -0
- package/dist/temporal/activities/prune-webhook-deliveries.js +11 -0
- package/dist/temporal/activities/prune-webhook-deliveries.js.map +1 -0
- package/dist/temporal/constants.d.ts +3 -0
- package/dist/temporal/constants.d.ts.map +1 -0
- package/dist/temporal/constants.js +4 -0
- package/dist/temporal/constants.js.map +1 -0
- package/dist/temporal/workflows/index.d.ts +2 -0
- package/dist/temporal/workflows/index.d.ts.map +1 -0
- package/dist/temporal/workflows/index.js +3 -0
- package/dist/temporal/workflows/index.js.map +1 -0
- package/dist/temporal/workflows/prune-webhook-deliveries-cron.d.ts +2 -0
- package/dist/temporal/workflows/prune-webhook-deliveries-cron.d.ts.map +1 -0
- package/dist/temporal/workflows/prune-webhook-deliveries-cron.js +14 -0
- package/dist/temporal/workflows/prune-webhook-deliveries-cron.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -0
- package/drizzle/0000_initial.sql +41 -0
- package/drizzle/meta/0001_snapshot.json +341 -0
- package/drizzle/meta/_journal.json +13 -0
- package/drizzle.config.ts +7 -0
- package/package.json +85 -0
- package/src/config.test.ts +32 -0
- package/src/config.ts +28 -0
- package/src/core/agent-tool-selection.test.ts +137 -0
- package/src/core/agent-tool-selection.ts +80 -0
- package/src/core/entities/connection.ts +4 -0
- package/src/core/entities/provider.ts +21 -0
- package/src/core/errors.ts +55 -0
- package/src/core/providers/agent-tools.ts +10 -0
- package/src/core/providers/redact-checkout-spec.test.ts +78 -0
- package/src/core/providers/redact-checkout-spec.ts +20 -0
- package/src/core/providers/registry.test.ts +138 -0
- package/src/core/providers/registry.ts +90 -0
- package/src/core/providers/source-control.ts +17 -0
- package/src/core/source-control-service.test.ts +230 -0
- package/src/core/source-control-service.ts +161 -0
- package/src/db/connections.test.ts +296 -0
- package/src/db/connections.ts +262 -0
- package/src/db/db.ts +22 -0
- package/src/db/migrations.ts +4 -0
- package/src/db/schema/common.ts +3 -0
- package/src/db/schema/connections.ts +49 -0
- package/src/db/schema/outbox.ts +4 -0
- package/src/db/schema/webhook-deliveries.ts +19 -0
- package/src/db/webhook-deliveries.test.ts +267 -0
- package/src/db/webhook-deliveries.ts +207 -0
- package/src/index.ts +212 -0
- package/src/metrics/index.ts +1 -0
- package/src/metrics/instance.ts +35 -0
- package/src/presentation/dto/integrations.ts +39 -0
- package/src/presentation/routes/agent-tools-gateway/agent-tools-gateway.route.test.ts +371 -0
- package/src/presentation/routes/agent-tools-gateway/audit.test.ts +86 -0
- package/src/presentation/routes/agent-tools-gateway/audit.ts +90 -0
- package/src/presentation/routes/agent-tools-gateway/dispatch.ts +139 -0
- package/src/presentation/routes/agent-tools-gateway/index.ts +62 -0
- package/src/presentation/routes/agent-tools-gateway/mcp-server.test.ts +308 -0
- package/src/presentation/routes/agent-tools-gateway/mcp-server.ts +155 -0
- package/src/presentation/routes/agent-tools-gateway/resolve-authorized-tools.test.ts +181 -0
- package/src/presentation/routes/agent-tools-gateway/resolve-authorized-tools.ts +245 -0
- package/src/presentation/routes/errors.ts +63 -0
- package/src/presentation/routes/index.ts +53 -0
- package/src/presentation/routes/list-connections.test.ts +227 -0
- package/src/presentation/routes/list-connections.ts +56 -0
- package/src/presentation/routes/list-providers.test.ts +113 -0
- package/src/presentation/routes/list-providers.ts +28 -0
- package/src/presentation/routes/list-repositories.test.ts +150 -0
- package/src/presentation/routes/list-repositories.ts +47 -0
- package/src/presentation/routes/manage-connections.test.ts +125 -0
- package/src/presentation/routes/manage-connections.ts +77 -0
- package/src/providers/connection-slug.ts +19 -0
- package/src/providers/cron.ts +13 -0
- package/src/providers/gitea.ts +103 -0
- package/src/providers/github.ts +150 -0
- package/src/providers/linear.ts +179 -0
- package/src/providers/modules.test.ts +40 -0
- package/src/providers/modules.ts +32 -0
- package/src/providers/sentry.ts +113 -0
- package/src/providers/types.ts +52 -0
- package/src/providers/webhook.ts +30 -0
- package/src/temporal/activities/index.ts +7 -0
- package/src/temporal/activities/prune-webhook-deliveries.test.ts +39 -0
- package/src/temporal/activities/prune-webhook-deliveries.ts +9 -0
- package/src/temporal/constants.ts +3 -0
- package/src/temporal/workflows/index.ts +1 -0
- package/src/temporal/workflows/prune-webhook-deliveries-cron.ts +15 -0
- package/test/agent-tools-gateway-helpers.ts +210 -0
- package/test/env.ts +23 -0
- package/test/factories/connection.ts +21 -0
- package/test/globalSetup.ts +22 -0
- package/test/index.ts +1 -0
- package/test/route-utils.ts +104 -0
- package/test/setup.ts +19 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/tsconfig.test.json +8 -0
- package/vitest.config.ts +13 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ClientError } from '@shipfox/node-fastify';
|
|
2
|
+
import { IntegrationCapabilityUnavailableError, IntegrationCheckoutUnsupportedError, IntegrationConnectionInactiveError, IntegrationConnectionNotFoundError, IntegrationConnectionWorkspaceMismatchError, IntegrationProviderError, IntegrationProviderUnavailableError } from '#core/errors.js';
|
|
3
|
+
function providerStatus(reason) {
|
|
4
|
+
if (reason === 'rate-limited') return 429;
|
|
5
|
+
if (reason === 'timeout' || reason === 'provider-unavailable') return 503;
|
|
6
|
+
return 422;
|
|
7
|
+
}
|
|
8
|
+
function isProviderError(error) {
|
|
9
|
+
return error instanceof IntegrationProviderError || error instanceof Error && 'reason' in error && typeof error.reason === 'string' && (error.reason === 'repository-not-found' || error.reason === 'file-not-found' || error.reason === 'access-denied' || error.reason === 'rate-limited' || error.reason === 'timeout' || error.reason === 'provider-unavailable' || error.reason === 'malformed-provider-response' || error.reason === 'content-too-large' || error.reason === 'too-many-files');
|
|
10
|
+
}
|
|
11
|
+
export function integrationRouteErrorHandler(error) {
|
|
12
|
+
if (error instanceof IntegrationConnectionNotFoundError) {
|
|
13
|
+
throw new ClientError(error.message, 'integration-connection-not-found', {
|
|
14
|
+
status: 404
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (error instanceof IntegrationConnectionInactiveError) {
|
|
18
|
+
throw new ClientError(error.message, 'integration-connection-inactive', {
|
|
19
|
+
status: 422
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (error instanceof IntegrationConnectionWorkspaceMismatchError) {
|
|
23
|
+
throw new ClientError(error.message, 'forbidden', {
|
|
24
|
+
status: 403
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (error instanceof IntegrationProviderUnavailableError) {
|
|
28
|
+
throw new ClientError(error.message, 'integration-provider-unavailable', {
|
|
29
|
+
status: 422
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (error instanceof IntegrationCapabilityUnavailableError) {
|
|
33
|
+
throw new ClientError(error.message, 'integration-capability-unavailable', {
|
|
34
|
+
status: 422
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (error instanceof IntegrationCheckoutUnsupportedError) {
|
|
38
|
+
throw new ClientError(error.message, 'integration-checkout-unsupported', {
|
|
39
|
+
status: 422
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (isProviderError(error)) {
|
|
43
|
+
throw new ClientError(error.message, error.reason, {
|
|
44
|
+
details: {
|
|
45
|
+
retry_after_seconds: error.retryAfterSeconds
|
|
46
|
+
},
|
|
47
|
+
status: providerStatus(error.reason)
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/errors.ts"],"sourcesContent":["import {ClientError} from '@shipfox/node-fastify';\nimport {\n IntegrationCapabilityUnavailableError,\n IntegrationCheckoutUnsupportedError,\n IntegrationConnectionInactiveError,\n IntegrationConnectionNotFoundError,\n IntegrationConnectionWorkspaceMismatchError,\n IntegrationProviderError,\n type IntegrationProviderErrorReason,\n IntegrationProviderUnavailableError,\n} from '#core/errors.js';\n\nfunction providerStatus(reason: IntegrationProviderErrorReason): number {\n if (reason === 'rate-limited') return 429;\n if (reason === 'timeout' || reason === 'provider-unavailable') return 503;\n return 422;\n}\n\nfunction isProviderError(error: unknown): error is IntegrationProviderError {\n return (\n error instanceof IntegrationProviderError ||\n (error instanceof Error &&\n 'reason' in error &&\n typeof error.reason === 'string' &&\n (error.reason === 'repository-not-found' ||\n error.reason === 'file-not-found' ||\n error.reason === 'access-denied' ||\n error.reason === 'rate-limited' ||\n error.reason === 'timeout' ||\n error.reason === 'provider-unavailable' ||\n error.reason === 'malformed-provider-response' ||\n error.reason === 'content-too-large' ||\n error.reason === 'too-many-files'))\n );\n}\n\nexport function integrationRouteErrorHandler(error: unknown): never {\n if (error instanceof IntegrationConnectionNotFoundError) {\n throw new ClientError(error.message, 'integration-connection-not-found', {status: 404});\n }\n if (error instanceof IntegrationConnectionInactiveError) {\n throw new ClientError(error.message, 'integration-connection-inactive', {status: 422});\n }\n if (error instanceof IntegrationConnectionWorkspaceMismatchError) {\n throw new ClientError(error.message, 'forbidden', {status: 403});\n }\n if (error instanceof IntegrationProviderUnavailableError) {\n throw new ClientError(error.message, 'integration-provider-unavailable', {status: 422});\n }\n if (error instanceof IntegrationCapabilityUnavailableError) {\n throw new ClientError(error.message, 'integration-capability-unavailable', {status: 422});\n }\n if (error instanceof IntegrationCheckoutUnsupportedError) {\n throw new ClientError(error.message, 'integration-checkout-unsupported', {status: 422});\n }\n if (isProviderError(error)) {\n throw new ClientError(error.message, error.reason, {\n details: {retry_after_seconds: error.retryAfterSeconds},\n status: providerStatus(error.reason),\n });\n }\n throw error;\n}\n"],"names":["ClientError","IntegrationCapabilityUnavailableError","IntegrationCheckoutUnsupportedError","IntegrationConnectionInactiveError","IntegrationConnectionNotFoundError","IntegrationConnectionWorkspaceMismatchError","IntegrationProviderError","IntegrationProviderUnavailableError","providerStatus","reason","isProviderError","error","Error","integrationRouteErrorHandler","message","status","details","retry_after_seconds","retryAfterSeconds"],"mappings":"AAAA,SAAQA,WAAW,QAAO,wBAAwB;AAClD,SACEC,qCAAqC,EACrCC,mCAAmC,EACnCC,kCAAkC,EAClCC,kCAAkC,EAClCC,2CAA2C,EAC3CC,wBAAwB,EAExBC,mCAAmC,QAC9B,kBAAkB;AAEzB,SAASC,eAAeC,MAAsC;IAC5D,IAAIA,WAAW,gBAAgB,OAAO;IACtC,IAAIA,WAAW,aAAaA,WAAW,wBAAwB,OAAO;IACtE,OAAO;AACT;AAEA,SAASC,gBAAgBC,KAAc;IACrC,OACEA,iBAAiBL,4BAChBK,iBAAiBC,SAChB,YAAYD,SACZ,OAAOA,MAAMF,MAAM,KAAK,YACvBE,CAAAA,MAAMF,MAAM,KAAK,0BAChBE,MAAMF,MAAM,KAAK,oBACjBE,MAAMF,MAAM,KAAK,mBACjBE,MAAMF,MAAM,KAAK,kBACjBE,MAAMF,MAAM,KAAK,aACjBE,MAAMF,MAAM,KAAK,0BACjBE,MAAMF,MAAM,KAAK,iCACjBE,MAAMF,MAAM,KAAK,uBACjBE,MAAMF,MAAM,KAAK,gBAAe;AAExC;AAEA,OAAO,SAASI,6BAA6BF,KAAc;IACzD,IAAIA,iBAAiBP,oCAAoC;QACvD,MAAM,IAAIJ,YAAYW,MAAMG,OAAO,EAAE,oCAAoC;YAACC,QAAQ;QAAG;IACvF;IACA,IAAIJ,iBAAiBR,oCAAoC;QACvD,MAAM,IAAIH,YAAYW,MAAMG,OAAO,EAAE,mCAAmC;YAACC,QAAQ;QAAG;IACtF;IACA,IAAIJ,iBAAiBN,6CAA6C;QAChE,MAAM,IAAIL,YAAYW,MAAMG,OAAO,EAAE,aAAa;YAACC,QAAQ;QAAG;IAChE;IACA,IAAIJ,iBAAiBJ,qCAAqC;QACxD,MAAM,IAAIP,YAAYW,MAAMG,OAAO,EAAE,oCAAoC;YAACC,QAAQ;QAAG;IACvF;IACA,IAAIJ,iBAAiBV,uCAAuC;QAC1D,MAAM,IAAID,YAAYW,MAAMG,OAAO,EAAE,sCAAsC;YAACC,QAAQ;QAAG;IACzF;IACA,IAAIJ,iBAAiBT,qCAAqC;QACxD,MAAM,IAAIF,YAAYW,MAAMG,OAAO,EAAE,oCAAoC;YAACC,QAAQ;QAAG;IACvF;IACA,IAAIL,gBAAgBC,QAAQ;QAC1B,MAAM,IAAIX,YAAYW,MAAMG,OAAO,EAAEH,MAAMF,MAAM,EAAE;YACjDO,SAAS;gBAACC,qBAAqBN,MAAMO,iBAAiB;YAAA;YACtDH,QAAQP,eAAeG,MAAMF,MAAM;QACrC;IACF;IACA,MAAME;AACR"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RouteExport } from '@shipfox/node-fastify';
|
|
2
|
+
import type { IntegrationProviderRegistry } from '#core/providers/registry.js';
|
|
3
|
+
import type { IntegrationSourceControlService } from '#core/source-control-service.js';
|
|
4
|
+
import type { GetIntegrationConnectionByIdFn } from '#db/connections.js';
|
|
5
|
+
import { type LeasedAgentStepLoader } from './agent-tools-gateway/index.js';
|
|
6
|
+
export type { LeasedAgentStepLoader } from './agent-tools-gateway/index.js';
|
|
7
|
+
export interface CreateIntegrationRoutesOptions {
|
|
8
|
+
agentTools?: {
|
|
9
|
+
loadLeasedAgentStep: LeasedAgentStepLoader;
|
|
10
|
+
getIntegrationConnectionById: GetIntegrationConnectionByIdFn;
|
|
11
|
+
} | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare function createIntegrationRoutes(registry: IntegrationProviderRegistry, sourceControl: IntegrationSourceControlService, options?: CreateIntegrationRoutesOptions): RouteExport[];
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,6BAA6B,CAAC;AAC7E,OAAO,KAAK,EAAC,+BAA+B,EAAC,MAAM,iCAAiC,CAAC;AACrF,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,gCAAgC,CAAC;AASxC,YAAY,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAC;AAE1E,MAAM,WAAW,8BAA8B;IAC7C,UAAU,CAAC,EACP;QACE,mBAAmB,EAAE,qBAAqB,CAAC;QAC3C,4BAA4B,EAAE,8BAA8B,CAAC;KAC9D,GACD,SAAS,CAAC;CACf;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,2BAA2B,EACrC,aAAa,EAAE,+BAA+B,EAC9C,OAAO,GAAE,8BAAmC,GAC3C,WAAW,EAAE,CAqBf"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createAgentToolsGatewayRoutes } from './agent-tools-gateway/index.js';
|
|
2
|
+
import { createListIntegrationConnectionsRoute } from './list-connections.js';
|
|
3
|
+
import { createListIntegrationProvidersRoute } from './list-providers.js';
|
|
4
|
+
import { createListRepositoriesRoute } from './list-repositories.js';
|
|
5
|
+
import { createDeleteIntegrationConnectionRoute, createUpdateIntegrationConnectionRoute } from './manage-connections.js';
|
|
6
|
+
export function createIntegrationRoutes(registry, sourceControl, options = {}) {
|
|
7
|
+
const providerRoutes = registry.list().flatMap((provider)=>provider.routes ?? []);
|
|
8
|
+
const agentToolsRoutes = options.agentTools ? [
|
|
9
|
+
createAgentToolsGatewayRoutes({
|
|
10
|
+
registry,
|
|
11
|
+
loadLeasedAgentStep: options.agentTools.loadLeasedAgentStep,
|
|
12
|
+
getIntegrationConnectionById: options.agentTools.getIntegrationConnectionById
|
|
13
|
+
})
|
|
14
|
+
] : [];
|
|
15
|
+
return [
|
|
16
|
+
createListIntegrationProvidersRoute(registry),
|
|
17
|
+
createListIntegrationConnectionsRoute(registry),
|
|
18
|
+
createUpdateIntegrationConnectionRoute(registry),
|
|
19
|
+
createDeleteIntegrationConnectionRoute(),
|
|
20
|
+
createListRepositoriesRoute(sourceControl),
|
|
21
|
+
...agentToolsRoutes,
|
|
22
|
+
...providerRoutes
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/index.ts"],"sourcesContent":["import type {RouteExport} from '@shipfox/node-fastify';\nimport type {IntegrationProviderRegistry} from '#core/providers/registry.js';\nimport type {IntegrationSourceControlService} from '#core/source-control-service.js';\nimport type {GetIntegrationConnectionByIdFn} from '#db/connections.js';\nimport {\n createAgentToolsGatewayRoutes,\n type LeasedAgentStepLoader,\n} from './agent-tools-gateway/index.js';\nimport {createListIntegrationConnectionsRoute} from './list-connections.js';\nimport {createListIntegrationProvidersRoute} from './list-providers.js';\nimport {createListRepositoriesRoute} from './list-repositories.js';\nimport {\n createDeleteIntegrationConnectionRoute,\n createUpdateIntegrationConnectionRoute,\n} from './manage-connections.js';\n\nexport type {LeasedAgentStepLoader} from './agent-tools-gateway/index.js';\n\nexport interface CreateIntegrationRoutesOptions {\n agentTools?:\n | {\n loadLeasedAgentStep: LeasedAgentStepLoader;\n getIntegrationConnectionById: GetIntegrationConnectionByIdFn;\n }\n | undefined;\n}\n\nexport function createIntegrationRoutes(\n registry: IntegrationProviderRegistry,\n sourceControl: IntegrationSourceControlService,\n options: CreateIntegrationRoutesOptions = {},\n): RouteExport[] {\n const providerRoutes = registry.list().flatMap((provider) => provider.routes ?? []);\n const agentToolsRoutes = options.agentTools\n ? [\n createAgentToolsGatewayRoutes({\n registry,\n loadLeasedAgentStep: options.agentTools.loadLeasedAgentStep,\n getIntegrationConnectionById: options.agentTools.getIntegrationConnectionById,\n }),\n ]\n : [];\n\n return [\n createListIntegrationProvidersRoute(registry),\n createListIntegrationConnectionsRoute(registry),\n createUpdateIntegrationConnectionRoute(registry),\n createDeleteIntegrationConnectionRoute(),\n createListRepositoriesRoute(sourceControl),\n ...agentToolsRoutes,\n ...providerRoutes,\n ];\n}\n"],"names":["createAgentToolsGatewayRoutes","createListIntegrationConnectionsRoute","createListIntegrationProvidersRoute","createListRepositoriesRoute","createDeleteIntegrationConnectionRoute","createUpdateIntegrationConnectionRoute","createIntegrationRoutes","registry","sourceControl","options","providerRoutes","list","flatMap","provider","routes","agentToolsRoutes","agentTools","loadLeasedAgentStep","getIntegrationConnectionById"],"mappings":"AAIA,SACEA,6BAA6B,QAExB,iCAAiC;AACxC,SAAQC,qCAAqC,QAAO,wBAAwB;AAC5E,SAAQC,mCAAmC,QAAO,sBAAsB;AACxE,SAAQC,2BAA2B,QAAO,yBAAyB;AACnE,SACEC,sCAAsC,EACtCC,sCAAsC,QACjC,0BAA0B;AAajC,OAAO,SAASC,wBACdC,QAAqC,EACrCC,aAA8C,EAC9CC,UAA0C,CAAC,CAAC;IAE5C,MAAMC,iBAAiBH,SAASI,IAAI,GAAGC,OAAO,CAAC,CAACC,WAAaA,SAASC,MAAM,IAAI,EAAE;IAClF,MAAMC,mBAAmBN,QAAQO,UAAU,GACvC;QACEhB,8BAA8B;YAC5BO;YACAU,qBAAqBR,QAAQO,UAAU,CAACC,mBAAmB;YAC3DC,8BAA8BT,QAAQO,UAAU,CAACE,4BAA4B;QAC/E;KACD,GACD,EAAE;IAEN,OAAO;QACLhB,oCAAoCK;QACpCN,sCAAsCM;QACtCF,uCAAuCE;QACvCH;QACAD,4BAA4BK;WACzBO;WACAL;KACJ;AACH"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IntegrationProviderRegistry } from '#core/providers/registry.js';
|
|
2
|
+
export declare function createListIntegrationConnectionsRoute(registry: IntegrationProviderRegistry): import("@shipfox/node-fastify").RouteDefinition;
|
|
3
|
+
//# sourceMappingURL=list-connections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-connections.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-connections.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,6BAA6B,CAAC;AAI7E,wBAAgB,qCAAqC,CAAC,QAAQ,EAAE,2BAA2B,mDA6C1F"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { AUTH_USER, requireWorkspaceAccess } from '@shipfox/api-auth-context';
|
|
2
|
+
import { listIntegrationConnectionsQuerySchema, listIntegrationConnectionsResponseSchema } from '@shipfox/api-integration-core-dto';
|
|
3
|
+
import { defineRoute } from '@shipfox/node-fastify';
|
|
4
|
+
import { listIntegrationConnections } from '#db/connections.js';
|
|
5
|
+
import { toIntegrationConnectionDto } from '#presentation/dto/integrations.js';
|
|
6
|
+
export function createListIntegrationConnectionsRoute(registry) {
|
|
7
|
+
return defineRoute({
|
|
8
|
+
method: 'GET',
|
|
9
|
+
path: '/integration-connections',
|
|
10
|
+
auth: AUTH_USER,
|
|
11
|
+
description: 'List workspace integration connections across all lifecycle statuses.',
|
|
12
|
+
schema: {
|
|
13
|
+
querystring: listIntegrationConnectionsQuerySchema,
|
|
14
|
+
response: {
|
|
15
|
+
200: listIntegrationConnectionsResponseSchema
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
handler: async (request)=>{
|
|
19
|
+
const { workspace_id: workspaceId, capability } = request.query;
|
|
20
|
+
requireWorkspaceAccess({
|
|
21
|
+
request,
|
|
22
|
+
workspaceId
|
|
23
|
+
});
|
|
24
|
+
const connections = await listIntegrationConnections({
|
|
25
|
+
workspaceId
|
|
26
|
+
});
|
|
27
|
+
const providers = new Map(registry.list(capability).map((provider)=>[
|
|
28
|
+
provider.provider,
|
|
29
|
+
provider
|
|
30
|
+
]));
|
|
31
|
+
const connectionDtos = await Promise.all(connections.map(async (connection)=>{
|
|
32
|
+
const provider = providers.get(connection.provider);
|
|
33
|
+
if (!provider) return undefined;
|
|
34
|
+
// Best-effort: the external link is cosmetic, so a failing or missing
|
|
35
|
+
// provider-side lookup must never fail the whole connections list.
|
|
36
|
+
let externalUrl;
|
|
37
|
+
try {
|
|
38
|
+
externalUrl = await provider.connectionExternalUrl?.(connection);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
request.log.warn({
|
|
41
|
+
connectionId: connection.id,
|
|
42
|
+
provider: connection.provider,
|
|
43
|
+
err: error
|
|
44
|
+
}, 'Could not resolve integration connection external URL');
|
|
45
|
+
}
|
|
46
|
+
return toIntegrationConnectionDto(connection, {
|
|
47
|
+
capabilities: provider.capabilities,
|
|
48
|
+
externalUrl
|
|
49
|
+
});
|
|
50
|
+
}));
|
|
51
|
+
return {
|
|
52
|
+
connections: connectionDtos.filter((connection)=>connection !== undefined)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=list-connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/list-connections.ts"],"sourcesContent":["import {AUTH_USER, requireWorkspaceAccess} from '@shipfox/api-auth-context';\nimport {\n listIntegrationConnectionsQuerySchema,\n listIntegrationConnectionsResponseSchema,\n} from '@shipfox/api-integration-core-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport type {IntegrationProviderRegistry} from '#core/providers/registry.js';\nimport {listIntegrationConnections} from '#db/connections.js';\nimport {toIntegrationConnectionDto} from '#presentation/dto/integrations.js';\n\nexport function createListIntegrationConnectionsRoute(registry: IntegrationProviderRegistry) {\n return defineRoute({\n method: 'GET',\n path: '/integration-connections',\n auth: AUTH_USER,\n description: 'List workspace integration connections across all lifecycle statuses.',\n schema: {\n querystring: listIntegrationConnectionsQuerySchema,\n response: {\n 200: listIntegrationConnectionsResponseSchema,\n },\n },\n handler: async (request) => {\n const {workspace_id: workspaceId, capability} = request.query;\n\n requireWorkspaceAccess({request, workspaceId});\n const connections = await listIntegrationConnections({workspaceId});\n const providers = new Map(\n registry.list(capability).map((provider) => [provider.provider, provider]),\n );\n const connectionDtos = await Promise.all(\n connections.map(async (connection) => {\n const provider = providers.get(connection.provider);\n if (!provider) return undefined;\n // Best-effort: the external link is cosmetic, so a failing or missing\n // provider-side lookup must never fail the whole connections list.\n let externalUrl: string | undefined;\n try {\n externalUrl = await provider.connectionExternalUrl?.(connection);\n } catch (error) {\n request.log.warn(\n {connectionId: connection.id, provider: connection.provider, err: error},\n 'Could not resolve integration connection external URL',\n );\n }\n return toIntegrationConnectionDto(connection, {\n capabilities: provider.capabilities,\n externalUrl,\n });\n }),\n );\n\n return {connections: connectionDtos.filter((connection) => connection !== undefined)};\n },\n });\n}\n"],"names":["AUTH_USER","requireWorkspaceAccess","listIntegrationConnectionsQuerySchema","listIntegrationConnectionsResponseSchema","defineRoute","listIntegrationConnections","toIntegrationConnectionDto","createListIntegrationConnectionsRoute","registry","method","path","auth","description","schema","querystring","response","handler","request","workspace_id","workspaceId","capability","query","connections","providers","Map","list","map","provider","connectionDtos","Promise","all","connection","get","undefined","externalUrl","connectionExternalUrl","error","log","warn","connectionId","id","err","capabilities","filter"],"mappings":"AAAA,SAAQA,SAAS,EAAEC,sBAAsB,QAAO,4BAA4B;AAC5E,SACEC,qCAAqC,EACrCC,wCAAwC,QACnC,oCAAoC;AAC3C,SAAQC,WAAW,QAAO,wBAAwB;AAElD,SAAQC,0BAA0B,QAAO,qBAAqB;AAC9D,SAAQC,0BAA0B,QAAO,oCAAoC;AAE7E,OAAO,SAASC,sCAAsCC,QAAqC;IACzF,OAAOJ,YAAY;QACjBK,QAAQ;QACRC,MAAM;QACNC,MAAMX;QACNY,aAAa;QACbC,QAAQ;YACNC,aAAaZ;YACba,UAAU;gBACR,KAAKZ;YACP;QACF;QACAa,SAAS,OAAOC;YACd,MAAM,EAACC,cAAcC,WAAW,EAAEC,UAAU,EAAC,GAAGH,QAAQI,KAAK;YAE7DpB,uBAAuB;gBAACgB;gBAASE;YAAW;YAC5C,MAAMG,cAAc,MAAMjB,2BAA2B;gBAACc;YAAW;YACjE,MAAMI,YAAY,IAAIC,IACpBhB,SAASiB,IAAI,CAACL,YAAYM,GAAG,CAAC,CAACC,WAAa;oBAACA,SAASA,QAAQ;oBAAEA;iBAAS;YAE3E,MAAMC,iBAAiB,MAAMC,QAAQC,GAAG,CACtCR,YAAYI,GAAG,CAAC,OAAOK;gBACrB,MAAMJ,WAAWJ,UAAUS,GAAG,CAACD,WAAWJ,QAAQ;gBAClD,IAAI,CAACA,UAAU,OAAOM;gBACtB,sEAAsE;gBACtE,mEAAmE;gBACnE,IAAIC;gBACJ,IAAI;oBACFA,cAAc,MAAMP,SAASQ,qBAAqB,GAAGJ;gBACvD,EAAE,OAAOK,OAAO;oBACdnB,QAAQoB,GAAG,CAACC,IAAI,CACd;wBAACC,cAAcR,WAAWS,EAAE;wBAAEb,UAAUI,WAAWJ,QAAQ;wBAAEc,KAAKL;oBAAK,GACvE;gBAEJ;gBACA,OAAO9B,2BAA2ByB,YAAY;oBAC5CW,cAAcf,SAASe,YAAY;oBACnCR;gBACF;YACF;YAGF,OAAO;gBAACZ,aAAaM,eAAee,MAAM,CAAC,CAACZ,aAAeA,eAAeE;YAAU;QACtF;IACF;AACF"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IntegrationProviderRegistry } from '#core/providers/registry.js';
|
|
2
|
+
export declare function createListIntegrationProvidersRoute(registry: IntegrationProviderRegistry): import("@shipfox/node-fastify").RouteDefinition;
|
|
3
|
+
//# sourceMappingURL=list-providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-providers.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-providers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,6BAA6B,CAAC;AAG7E,wBAAgB,mCAAmC,CAAC,QAAQ,EAAE,2BAA2B,mDAkBxF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AUTH_USER } from '@shipfox/api-auth-context';
|
|
2
|
+
import { listIntegrationProvidersQuerySchema, listIntegrationProvidersResponseSchema } from '@shipfox/api-integration-core-dto';
|
|
3
|
+
import { defineRoute } from '@shipfox/node-fastify';
|
|
4
|
+
import { toIntegrationProviderDto } from '#presentation/dto/integrations.js';
|
|
5
|
+
export function createListIntegrationProvidersRoute(registry) {
|
|
6
|
+
return defineRoute({
|
|
7
|
+
method: 'GET',
|
|
8
|
+
path: '/integration-providers',
|
|
9
|
+
auth: AUTH_USER,
|
|
10
|
+
description: 'List integration providers available to the API.',
|
|
11
|
+
schema: {
|
|
12
|
+
querystring: listIntegrationProvidersQuerySchema,
|
|
13
|
+
response: {
|
|
14
|
+
200: listIntegrationProvidersResponseSchema
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
handler: async (request)=>{
|
|
18
|
+
await Promise.resolve();
|
|
19
|
+
const providers = registry.list(request.query.capability);
|
|
20
|
+
return {
|
|
21
|
+
providers: providers.map(toIntegrationProviderDto)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=list-providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/list-providers.ts"],"sourcesContent":["import {AUTH_USER} from '@shipfox/api-auth-context';\nimport {\n listIntegrationProvidersQuerySchema,\n listIntegrationProvidersResponseSchema,\n} from '@shipfox/api-integration-core-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport type {IntegrationProviderRegistry} from '#core/providers/registry.js';\nimport {toIntegrationProviderDto} from '#presentation/dto/integrations.js';\n\nexport function createListIntegrationProvidersRoute(registry: IntegrationProviderRegistry) {\n return defineRoute({\n method: 'GET',\n path: '/integration-providers',\n auth: AUTH_USER,\n description: 'List integration providers available to the API.',\n schema: {\n querystring: listIntegrationProvidersQuerySchema,\n response: {\n 200: listIntegrationProvidersResponseSchema,\n },\n },\n handler: async (request) => {\n await Promise.resolve();\n const providers = registry.list(request.query.capability);\n return {providers: providers.map(toIntegrationProviderDto)};\n },\n });\n}\n"],"names":["AUTH_USER","listIntegrationProvidersQuerySchema","listIntegrationProvidersResponseSchema","defineRoute","toIntegrationProviderDto","createListIntegrationProvidersRoute","registry","method","path","auth","description","schema","querystring","response","handler","request","Promise","resolve","providers","list","query","capability","map"],"mappings":"AAAA,SAAQA,SAAS,QAAO,4BAA4B;AACpD,SACEC,mCAAmC,EACnCC,sCAAsC,QACjC,oCAAoC;AAC3C,SAAQC,WAAW,QAAO,wBAAwB;AAElD,SAAQC,wBAAwB,QAAO,oCAAoC;AAE3E,OAAO,SAASC,oCAAoCC,QAAqC;IACvF,OAAOH,YAAY;QACjBI,QAAQ;QACRC,MAAM;QACNC,MAAMT;QACNU,aAAa;QACbC,QAAQ;YACNC,aAAaX;YACbY,UAAU;gBACR,KAAKX;YACP;QACF;QACAY,SAAS,OAAOC;YACd,MAAMC,QAAQC,OAAO;YACrB,MAAMC,YAAYZ,SAASa,IAAI,CAACJ,QAAQK,KAAK,CAACC,UAAU;YACxD,OAAO;gBAACH,WAAWA,UAAUI,GAAG,CAAClB;YAAyB;QAC5D;IACF;AACF"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IntegrationSourceControlService } from '#core/source-control-service.js';
|
|
2
|
+
export declare function createListRepositoriesRoute(sourceControl: IntegrationSourceControlService): import("@shipfox/node-fastify").RouteDefinition;
|
|
3
|
+
//# sourceMappingURL=list-repositories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-repositories.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-repositories.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,+BAA+B,EAAC,MAAM,iCAAiC,CAAC;AAIrF,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,+BAA+B,mDAmCzF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AUTH_USER, requireWorkspaceAccess } from '@shipfox/api-auth-context';
|
|
2
|
+
import { listRepositoriesParamsSchema, listRepositoriesQuerySchema, listRepositoriesResponseSchema } from '@shipfox/api-integration-core-dto';
|
|
3
|
+
import { defineRoute } from '@shipfox/node-fastify';
|
|
4
|
+
import { toRepositoryDto } from '#presentation/dto/integrations.js';
|
|
5
|
+
import { integrationRouteErrorHandler } from './errors.js';
|
|
6
|
+
export function createListRepositoriesRoute(sourceControl) {
|
|
7
|
+
return defineRoute({
|
|
8
|
+
method: 'GET',
|
|
9
|
+
path: '/integration-connections/:connectionId/repositories',
|
|
10
|
+
auth: AUTH_USER,
|
|
11
|
+
description: 'List repositories visible to a source-control integration connection.',
|
|
12
|
+
schema: {
|
|
13
|
+
params: listRepositoriesParamsSchema,
|
|
14
|
+
querystring: listRepositoriesQuerySchema,
|
|
15
|
+
response: {
|
|
16
|
+
200: listRepositoriesResponseSchema
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
errorHandler: integrationRouteErrorHandler,
|
|
20
|
+
handler: async (request)=>{
|
|
21
|
+
const { connectionId } = request.params;
|
|
22
|
+
const connection = await sourceControl.getConnection(connectionId);
|
|
23
|
+
requireWorkspaceAccess({
|
|
24
|
+
request,
|
|
25
|
+
workspaceId: connection.workspaceId
|
|
26
|
+
});
|
|
27
|
+
const page = await sourceControl.listRepositories({
|
|
28
|
+
connection,
|
|
29
|
+
limit: request.query.limit,
|
|
30
|
+
cursor: request.query.cursor,
|
|
31
|
+
search: request.query.search
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
repositories: page.repositories.map((repository)=>toRepositoryDto(connection.id, repository)),
|
|
35
|
+
next_cursor: page.nextCursor
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=list-repositories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/list-repositories.ts"],"sourcesContent":["import {AUTH_USER, requireWorkspaceAccess} from '@shipfox/api-auth-context';\nimport {\n listRepositoriesParamsSchema,\n listRepositoriesQuerySchema,\n listRepositoriesResponseSchema,\n} from '@shipfox/api-integration-core-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport type {IntegrationSourceControlService} from '#core/source-control-service.js';\nimport {toRepositoryDto} from '#presentation/dto/integrations.js';\nimport {integrationRouteErrorHandler} from './errors.js';\n\nexport function createListRepositoriesRoute(sourceControl: IntegrationSourceControlService) {\n return defineRoute({\n method: 'GET',\n path: '/integration-connections/:connectionId/repositories',\n auth: AUTH_USER,\n description: 'List repositories visible to a source-control integration connection.',\n schema: {\n params: listRepositoriesParamsSchema,\n querystring: listRepositoriesQuerySchema,\n response: {\n 200: listRepositoriesResponseSchema,\n },\n },\n errorHandler: integrationRouteErrorHandler,\n handler: async (request) => {\n const {connectionId} = request.params;\n const connection = await sourceControl.getConnection(connectionId);\n\n requireWorkspaceAccess({request, workspaceId: connection.workspaceId});\n\n const page = await sourceControl.listRepositories({\n connection,\n limit: request.query.limit,\n cursor: request.query.cursor,\n search: request.query.search,\n });\n\n return {\n repositories: page.repositories.map((repository) =>\n toRepositoryDto(connection.id, repository),\n ),\n next_cursor: page.nextCursor,\n };\n },\n });\n}\n"],"names":["AUTH_USER","requireWorkspaceAccess","listRepositoriesParamsSchema","listRepositoriesQuerySchema","listRepositoriesResponseSchema","defineRoute","toRepositoryDto","integrationRouteErrorHandler","createListRepositoriesRoute","sourceControl","method","path","auth","description","schema","params","querystring","response","errorHandler","handler","request","connectionId","connection","getConnection","workspaceId","page","listRepositories","limit","query","cursor","search","repositories","map","repository","id","next_cursor","nextCursor"],"mappings":"AAAA,SAAQA,SAAS,EAAEC,sBAAsB,QAAO,4BAA4B;AAC5E,SACEC,4BAA4B,EAC5BC,2BAA2B,EAC3BC,8BAA8B,QACzB,oCAAoC;AAC3C,SAAQC,WAAW,QAAO,wBAAwB;AAElD,SAAQC,eAAe,QAAO,oCAAoC;AAClE,SAAQC,4BAA4B,QAAO,cAAc;AAEzD,OAAO,SAASC,4BAA4BC,aAA8C;IACxF,OAAOJ,YAAY;QACjBK,QAAQ;QACRC,MAAM;QACNC,MAAMZ;QACNa,aAAa;QACbC,QAAQ;YACNC,QAAQb;YACRc,aAAab;YACbc,UAAU;gBACR,KAAKb;YACP;QACF;QACAc,cAAcX;QACdY,SAAS,OAAOC;YACd,MAAM,EAACC,YAAY,EAAC,GAAGD,QAAQL,MAAM;YACrC,MAAMO,aAAa,MAAMb,cAAcc,aAAa,CAACF;YAErDpB,uBAAuB;gBAACmB;gBAASI,aAAaF,WAAWE,WAAW;YAAA;YAEpE,MAAMC,OAAO,MAAMhB,cAAciB,gBAAgB,CAAC;gBAChDJ;gBACAK,OAAOP,QAAQQ,KAAK,CAACD,KAAK;gBAC1BE,QAAQT,QAAQQ,KAAK,CAACC,MAAM;gBAC5BC,QAAQV,QAAQQ,KAAK,CAACE,MAAM;YAC9B;YAEA,OAAO;gBACLC,cAAcN,KAAKM,YAAY,CAACC,GAAG,CAAC,CAACC,aACnC3B,gBAAgBgB,WAAWY,EAAE,EAAED;gBAEjCE,aAAaV,KAAKW,UAAU;YAC9B;QACF;IACF;AACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IntegrationProviderRegistry } from '#core/providers/registry.js';
|
|
2
|
+
export declare function createUpdateIntegrationConnectionRoute(registry: IntegrationProviderRegistry): import("@shipfox/node-fastify").RouteDefinition;
|
|
3
|
+
export declare function createDeleteIntegrationConnectionRoute(): import("@shipfox/node-fastify").RouteDefinition;
|
|
4
|
+
//# sourceMappingURL=manage-connections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manage-connections.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/manage-connections.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,6BAA6B,CAAC;AAY7E,wBAAgB,sCAAsC,CAAC,QAAQ,EAAE,2BAA2B,mDAgC3F;AAED,wBAAgB,sCAAsC,oDAuBrD"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AUTH_USER, requireWorkspaceAccess } from '@shipfox/api-auth-context';
|
|
2
|
+
import { integrationConnectionDtoSchema, updateIntegrationConnectionBodySchema } from '@shipfox/api-integration-core-dto';
|
|
3
|
+
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { deleteIntegrationConnection, getIntegrationConnectionById, updateIntegrationConnectionLifecycleStatus } from '#db/connections.js';
|
|
6
|
+
import { toIntegrationConnectionDto } from '#presentation/dto/integrations.js';
|
|
7
|
+
const connectionParamsSchema = z.object({
|
|
8
|
+
connectionId: z.string().uuid()
|
|
9
|
+
});
|
|
10
|
+
export function createUpdateIntegrationConnectionRoute(registry) {
|
|
11
|
+
return defineRoute({
|
|
12
|
+
method: 'PATCH',
|
|
13
|
+
path: '/integration-connections/:connectionId',
|
|
14
|
+
auth: AUTH_USER,
|
|
15
|
+
description: 'Update an integration connection.',
|
|
16
|
+
schema: {
|
|
17
|
+
params: connectionParamsSchema,
|
|
18
|
+
body: updateIntegrationConnectionBodySchema,
|
|
19
|
+
response: {
|
|
20
|
+
200: integrationConnectionDtoSchema
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
handler: async (request)=>{
|
|
24
|
+
const connection = await getIntegrationConnectionById(request.params.connectionId);
|
|
25
|
+
if (!connection) {
|
|
26
|
+
throw new ClientError('Integration connection not found', 'not-found', {
|
|
27
|
+
status: 404
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
requireWorkspaceAccess({
|
|
31
|
+
request,
|
|
32
|
+
workspaceId: connection.workspaceId
|
|
33
|
+
});
|
|
34
|
+
const updated = await updateIntegrationConnectionLifecycleStatus({
|
|
35
|
+
id: connection.id,
|
|
36
|
+
lifecycleStatus: request.body.lifecycle_status
|
|
37
|
+
});
|
|
38
|
+
if (!updated) {
|
|
39
|
+
throw new ClientError('Integration connection not found', 'not-found', {
|
|
40
|
+
status: 404
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const provider = registry.list().find((candidate)=>candidate.provider === updated.provider);
|
|
44
|
+
return toIntegrationConnectionDto(updated, {
|
|
45
|
+
capabilities: provider?.capabilities ?? []
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export function createDeleteIntegrationConnectionRoute() {
|
|
51
|
+
return defineRoute({
|
|
52
|
+
method: 'DELETE',
|
|
53
|
+
path: '/integration-connections/:connectionId',
|
|
54
|
+
auth: AUTH_USER,
|
|
55
|
+
description: 'Delete an integration connection.',
|
|
56
|
+
schema: {
|
|
57
|
+
params: connectionParamsSchema,
|
|
58
|
+
response: {
|
|
59
|
+
204: z.void()
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
handler: async (request, reply)=>{
|
|
63
|
+
const connection = await getIntegrationConnectionById(request.params.connectionId);
|
|
64
|
+
if (!connection) {
|
|
65
|
+
throw new ClientError('Integration connection not found', 'not-found', {
|
|
66
|
+
status: 404
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
requireWorkspaceAccess({
|
|
70
|
+
request,
|
|
71
|
+
workspaceId: connection.workspaceId
|
|
72
|
+
});
|
|
73
|
+
await deleteIntegrationConnection({
|
|
74
|
+
id: connection.id
|
|
75
|
+
});
|
|
76
|
+
reply.status(204);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=manage-connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/manage-connections.ts"],"sourcesContent":["import {AUTH_USER, requireWorkspaceAccess} from '@shipfox/api-auth-context';\nimport {\n integrationConnectionDtoSchema,\n updateIntegrationConnectionBodySchema,\n} from '@shipfox/api-integration-core-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport type {IntegrationProviderRegistry} from '#core/providers/registry.js';\nimport {\n deleteIntegrationConnection,\n getIntegrationConnectionById,\n updateIntegrationConnectionLifecycleStatus,\n} from '#db/connections.js';\nimport {toIntegrationConnectionDto} from '#presentation/dto/integrations.js';\n\nconst connectionParamsSchema = z.object({\n connectionId: z.string().uuid(),\n});\n\nexport function createUpdateIntegrationConnectionRoute(registry: IntegrationProviderRegistry) {\n return defineRoute({\n method: 'PATCH',\n path: '/integration-connections/:connectionId',\n auth: AUTH_USER,\n description: 'Update an integration connection.',\n schema: {\n params: connectionParamsSchema,\n body: updateIntegrationConnectionBodySchema,\n response: {\n 200: integrationConnectionDtoSchema,\n },\n },\n handler: async (request) => {\n const connection = await getIntegrationConnectionById(request.params.connectionId);\n if (!connection) {\n throw new ClientError('Integration connection not found', 'not-found', {status: 404});\n }\n\n requireWorkspaceAccess({request, workspaceId: connection.workspaceId});\n const updated = await updateIntegrationConnectionLifecycleStatus({\n id: connection.id,\n lifecycleStatus: request.body.lifecycle_status,\n });\n if (!updated) {\n throw new ClientError('Integration connection not found', 'not-found', {status: 404});\n }\n\n const provider = registry.list().find((candidate) => candidate.provider === updated.provider);\n return toIntegrationConnectionDto(updated, {capabilities: provider?.capabilities ?? []});\n },\n });\n}\n\nexport function createDeleteIntegrationConnectionRoute() {\n return defineRoute({\n method: 'DELETE',\n path: '/integration-connections/:connectionId',\n auth: AUTH_USER,\n description: 'Delete an integration connection.',\n schema: {\n params: connectionParamsSchema,\n response: {\n 204: z.void(),\n },\n },\n handler: async (request, reply) => {\n const connection = await getIntegrationConnectionById(request.params.connectionId);\n if (!connection) {\n throw new ClientError('Integration connection not found', 'not-found', {status: 404});\n }\n\n requireWorkspaceAccess({request, workspaceId: connection.workspaceId});\n await deleteIntegrationConnection({id: connection.id});\n reply.status(204);\n },\n });\n}\n"],"names":["AUTH_USER","requireWorkspaceAccess","integrationConnectionDtoSchema","updateIntegrationConnectionBodySchema","ClientError","defineRoute","z","deleteIntegrationConnection","getIntegrationConnectionById","updateIntegrationConnectionLifecycleStatus","toIntegrationConnectionDto","connectionParamsSchema","object","connectionId","string","uuid","createUpdateIntegrationConnectionRoute","registry","method","path","auth","description","schema","params","body","response","handler","request","connection","status","workspaceId","updated","id","lifecycleStatus","lifecycle_status","provider","list","find","candidate","capabilities","createDeleteIntegrationConnectionRoute","void","reply"],"mappings":"AAAA,SAAQA,SAAS,EAAEC,sBAAsB,QAAO,4BAA4B;AAC5E,SACEC,8BAA8B,EAC9BC,qCAAqC,QAChC,oCAAoC;AAC3C,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AAEtB,SACEC,2BAA2B,EAC3BC,4BAA4B,EAC5BC,0CAA0C,QACrC,qBAAqB;AAC5B,SAAQC,0BAA0B,QAAO,oCAAoC;AAE7E,MAAMC,yBAAyBL,EAAEM,MAAM,CAAC;IACtCC,cAAcP,EAAEQ,MAAM,GAAGC,IAAI;AAC/B;AAEA,OAAO,SAASC,uCAAuCC,QAAqC;IAC1F,OAAOZ,YAAY;QACjBa,QAAQ;QACRC,MAAM;QACNC,MAAMpB;QACNqB,aAAa;QACbC,QAAQ;YACNC,QAAQZ;YACRa,MAAMrB;YACNsB,UAAU;gBACR,KAAKvB;YACP;QACF;QACAwB,SAAS,OAAOC;YACd,MAAMC,aAAa,MAAMpB,6BAA6BmB,QAAQJ,MAAM,CAACV,YAAY;YACjF,IAAI,CAACe,YAAY;gBACf,MAAM,IAAIxB,YAAY,oCAAoC,aAAa;oBAACyB,QAAQ;gBAAG;YACrF;YAEA5B,uBAAuB;gBAAC0B;gBAASG,aAAaF,WAAWE,WAAW;YAAA;YACpE,MAAMC,UAAU,MAAMtB,2CAA2C;gBAC/DuB,IAAIJ,WAAWI,EAAE;gBACjBC,iBAAiBN,QAAQH,IAAI,CAACU,gBAAgB;YAChD;YACA,IAAI,CAACH,SAAS;gBACZ,MAAM,IAAI3B,YAAY,oCAAoC,aAAa;oBAACyB,QAAQ;gBAAG;YACrF;YAEA,MAAMM,WAAWlB,SAASmB,IAAI,GAAGC,IAAI,CAAC,CAACC,YAAcA,UAAUH,QAAQ,KAAKJ,QAAQI,QAAQ;YAC5F,OAAOzB,2BAA2BqB,SAAS;gBAACQ,cAAcJ,UAAUI,gBAAgB,EAAE;YAAA;QACxF;IACF;AACF;AAEA,OAAO,SAASC;IACd,OAAOnC,YAAY;QACjBa,QAAQ;QACRC,MAAM;QACNC,MAAMpB;QACNqB,aAAa;QACbC,QAAQ;YACNC,QAAQZ;YACRc,UAAU;gBACR,KAAKnB,EAAEmC,IAAI;YACb;QACF;QACAf,SAAS,OAAOC,SAASe;YACvB,MAAMd,aAAa,MAAMpB,6BAA6BmB,QAAQJ,MAAM,CAACV,YAAY;YACjF,IAAI,CAACe,YAAY;gBACf,MAAM,IAAIxB,YAAY,oCAAoC,aAAa;oBAACyB,QAAQ;gBAAG;YACrF;YAEA5B,uBAAuB;gBAAC0B;gBAASG,aAAaF,WAAWE,WAAW;YAAA;YACpE,MAAMvB,4BAA4B;gBAACyB,IAAIJ,WAAWI,EAAE;YAAA;YACpDU,MAAMb,MAAM,CAAC;QACf;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-slug.d.ts","sourceRoot":"","sources":["../../src/providers/connection-slug.ts"],"names":[],"mappings":"AAKA,wBAAsB,4BAA4B,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAa7F"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ConnectionSlugConflictError } from '@shipfox/api-integration-core-dto';
|
|
2
|
+
import { isIntegrationConnectionSlugUniqueViolation } from '#db/connections.js';
|
|
3
|
+
const MAX_CONNECTION_SLUG_ATTEMPTS = 3;
|
|
4
|
+
export async function retryConnectionSlugCollision(operation) {
|
|
5
|
+
for(let attempt = 1;; attempt += 1){
|
|
6
|
+
try {
|
|
7
|
+
return await operation();
|
|
8
|
+
} catch (error) {
|
|
9
|
+
if (!isIntegrationConnectionSlugUniqueViolation(error)) {
|
|
10
|
+
throw error;
|
|
11
|
+
}
|
|
12
|
+
if (attempt >= MAX_CONNECTION_SLUG_ATTEMPTS) {
|
|
13
|
+
throw new ConnectionSlugConflictError(error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=connection-slug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/providers/connection-slug.ts"],"sourcesContent":["import {ConnectionSlugConflictError} from '@shipfox/api-integration-core-dto';\nimport {isIntegrationConnectionSlugUniqueViolation} from '#db/connections.js';\n\nconst MAX_CONNECTION_SLUG_ATTEMPTS = 3;\n\nexport async function retryConnectionSlugCollision<T>(operation: () => Promise<T>): Promise<T> {\n for (let attempt = 1; ; attempt += 1) {\n try {\n return await operation();\n } catch (error) {\n if (!isIntegrationConnectionSlugUniqueViolation(error)) {\n throw error;\n }\n if (attempt >= MAX_CONNECTION_SLUG_ATTEMPTS) {\n throw new ConnectionSlugConflictError(error);\n }\n }\n }\n}\n"],"names":["ConnectionSlugConflictError","isIntegrationConnectionSlugUniqueViolation","MAX_CONNECTION_SLUG_ATTEMPTS","retryConnectionSlugCollision","operation","attempt","error"],"mappings":"AAAA,SAAQA,2BAA2B,QAAO,oCAAoC;AAC9E,SAAQC,0CAA0C,QAAO,qBAAqB;AAE9E,MAAMC,+BAA+B;AAErC,OAAO,eAAeC,6BAAgCC,SAA2B;IAC/E,IAAK,IAAIC,UAAU,IAAKA,WAAW,EAAG;QACpC,IAAI;YACF,OAAO,MAAMD;QACf,EAAE,OAAOE,OAAO;YACd,IAAI,CAACL,2CAA2CK,QAAQ;gBACtD,MAAMA;YACR;YACA,IAAID,WAAWH,8BAA8B;gBAC3C,MAAM,IAAIF,4BAA4BM;YACxC;QACF;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../src/providers/cron.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,qBAAqB,CAAC;AAEnE,eAAO,MAAM,kBAAkB,EAAE,yBAShC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { config } from '#config.js';
|
|
2
|
+
export const cronProviderModule = {
|
|
3
|
+
id: 'cron',
|
|
4
|
+
enabled: config.INTEGRATIONS_ENABLE_CRON_PROVIDER,
|
|
5
|
+
load: async ()=>({
|
|
6
|
+
provider: {
|
|
7
|
+
provider: 'cron',
|
|
8
|
+
displayName: 'Cron'
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=cron.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/providers/cron.ts"],"sourcesContent":["import {config} from '#config.js';\nimport type {IntegrationProviderModule} from '#providers/types.js';\n\nexport const cronProviderModule: IntegrationProviderModule = {\n id: 'cron',\n enabled: config.INTEGRATIONS_ENABLE_CRON_PROVIDER,\n load: async () => ({\n provider: {\n provider: 'cron',\n displayName: 'Cron',\n },\n }),\n};\n"],"names":["config","cronProviderModule","id","enabled","INTEGRATIONS_ENABLE_CRON_PROVIDER","load","provider","displayName"],"mappings":"AAAA,SAAQA,MAAM,QAAO,aAAa;AAGlC,OAAO,MAAMC,qBAAgD;IAC3DC,IAAI;IACJC,SAASH,OAAOI,iCAAiC;IACjDC,MAAM,UAAa,CAAA;YACjBC,UAAU;gBACRA,UAAU;gBACVC,aAAa;YACf;QACF,CAAA;AACF,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitea.d.ts","sourceRoot":"","sources":["../../src/providers/gitea.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAyB,yBAAyB,EAAC,MAAM,qBAAqB,CAAC;AAoF3F,eAAO,MAAM,mBAAmB,EAAE,yBAIjC,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { slugifyConnectionSlug } from '@shipfox/api-integration-core-dto';
|
|
2
|
+
import { config } from '#config.js';
|
|
3
|
+
import { getIntegrationConnectionById, resolveUniqueConnectionSlug, upsertIntegrationConnection } from '#db/connections.js';
|
|
4
|
+
import { db } from '#db/db.js';
|
|
5
|
+
import { publishSourcePush, recordDeliveryOnly } from '#db/webhook-deliveries.js';
|
|
6
|
+
import { retryConnectionSlugCollision } from '#providers/connection-slug.js';
|
|
7
|
+
// Stable migration-tracking table name for the Gitea provider database. This
|
|
8
|
+
// must NOT depend on the provider's position in the module `database` array. A
|
|
9
|
+
// positional name would shift if a provider is flag-disabled and silently
|
|
10
|
+
// re-run migrations against existing tables.
|
|
11
|
+
const GITEA_MIGRATIONS_TABLE = '__drizzle_migrations_integrations_gitea';
|
|
12
|
+
async function loadGiteaModuleParts() {
|
|
13
|
+
const { createGiteaIntegrationProvider, getGiteaConnectionByOrg, upsertGiteaConnection, db: giteaDb, migrationsPath: giteaMigrationsPath } = await import('@shipfox/api-integration-gitea');
|
|
14
|
+
async function getExistingGiteaConnection(input) {
|
|
15
|
+
const row = await getGiteaConnectionByOrg(input.org);
|
|
16
|
+
if (!row) return undefined;
|
|
17
|
+
const connection = await getIntegrationConnectionById(row.connectionId);
|
|
18
|
+
if (!connection) return undefined;
|
|
19
|
+
return connection;
|
|
20
|
+
}
|
|
21
|
+
async function connectGiteaConnection(input) {
|
|
22
|
+
return await retryConnectionSlugCollision(()=>db().transaction(async (tx)=>{
|
|
23
|
+
const baseSlug = slugifyConnectionSlug(`gitea_${input.org}`, {
|
|
24
|
+
fallback: 'gitea'
|
|
25
|
+
});
|
|
26
|
+
const slug = await resolveUniqueConnectionSlug({
|
|
27
|
+
workspaceId: input.workspaceId,
|
|
28
|
+
provider: 'gitea',
|
|
29
|
+
externalAccountId: input.org,
|
|
30
|
+
baseSlug
|
|
31
|
+
}, {
|
|
32
|
+
tx
|
|
33
|
+
});
|
|
34
|
+
const connection = await upsertIntegrationConnection({
|
|
35
|
+
workspaceId: input.workspaceId,
|
|
36
|
+
provider: 'gitea',
|
|
37
|
+
externalAccountId: input.org,
|
|
38
|
+
slug,
|
|
39
|
+
displayName: input.displayName,
|
|
40
|
+
lifecycleStatus: 'active'
|
|
41
|
+
}, {
|
|
42
|
+
tx
|
|
43
|
+
});
|
|
44
|
+
await upsertGiteaConnection({
|
|
45
|
+
connectionId: connection.id,
|
|
46
|
+
org: input.org
|
|
47
|
+
}, {
|
|
48
|
+
tx
|
|
49
|
+
});
|
|
50
|
+
return connection;
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
provider: createGiteaIntegrationProvider({
|
|
55
|
+
getExistingGiteaConnection,
|
|
56
|
+
connectGiteaConnection,
|
|
57
|
+
publishSourcePush,
|
|
58
|
+
recordDeliveryOnly,
|
|
59
|
+
getIntegrationConnectionById,
|
|
60
|
+
coreDb: db
|
|
61
|
+
}),
|
|
62
|
+
database: {
|
|
63
|
+
db: giteaDb,
|
|
64
|
+
migrationsPath: giteaMigrationsPath,
|
|
65
|
+
migrationsTableName: GITEA_MIGRATIONS_TABLE
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export const giteaProviderModule = {
|
|
70
|
+
id: 'gitea',
|
|
71
|
+
enabled: config.INTEGRATIONS_ENABLE_GITEA_PROVIDER,
|
|
72
|
+
load: loadGiteaModuleParts
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=gitea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/providers/gitea.ts"],"sourcesContent":["import {\n type IntegrationConnection as CoreIntegrationConnection,\n slugifyConnectionSlug,\n} from '@shipfox/api-integration-core-dto';\nimport type {ConnectGiteaConnectionInput} from '@shipfox/api-integration-gitea';\nimport {config} from '#config.js';\nimport {\n getIntegrationConnectionById,\n resolveUniqueConnectionSlug,\n upsertIntegrationConnection,\n} from '#db/connections.js';\nimport {db} from '#db/db.js';\nimport {publishSourcePush, recordDeliveryOnly} from '#db/webhook-deliveries.js';\nimport {retryConnectionSlugCollision} from '#providers/connection-slug.js';\nimport type {IntegrationModuleParts, IntegrationProviderModule} from '#providers/types.js';\n\n// Stable migration-tracking table name for the Gitea provider database. This\n// must NOT depend on the provider's position in the module `database` array. A\n// positional name would shift if a provider is flag-disabled and silently\n// re-run migrations against existing tables.\nconst GITEA_MIGRATIONS_TABLE = '__drizzle_migrations_integrations_gitea';\n\nasync function loadGiteaModuleParts(): Promise<IntegrationModuleParts> {\n const {\n createGiteaIntegrationProvider,\n getGiteaConnectionByOrg,\n upsertGiteaConnection,\n db: giteaDb,\n migrationsPath: giteaMigrationsPath,\n } = await import('@shipfox/api-integration-gitea');\n\n async function getExistingGiteaConnection(input: {\n org: string;\n }): Promise<CoreIntegrationConnection<'gitea'> | undefined> {\n const row = await getGiteaConnectionByOrg(input.org);\n if (!row) return undefined;\n const connection = await getIntegrationConnectionById(row.connectionId);\n if (!connection) return undefined;\n return connection as CoreIntegrationConnection<'gitea'>;\n }\n\n async function connectGiteaConnection(\n input: ConnectGiteaConnectionInput,\n ): Promise<CoreIntegrationConnection<'gitea'>> {\n return await retryConnectionSlugCollision(() =>\n db().transaction(async (tx) => {\n const baseSlug = slugifyConnectionSlug(`gitea_${input.org}`, {fallback: 'gitea'});\n const slug = await resolveUniqueConnectionSlug(\n {\n workspaceId: input.workspaceId,\n provider: 'gitea',\n externalAccountId: input.org,\n baseSlug,\n },\n {tx},\n );\n const connection = await upsertIntegrationConnection(\n {\n workspaceId: input.workspaceId,\n provider: 'gitea',\n externalAccountId: input.org,\n slug,\n displayName: input.displayName,\n lifecycleStatus: 'active',\n },\n {tx},\n );\n\n await upsertGiteaConnection(\n {\n connectionId: connection.id,\n org: input.org,\n },\n {tx},\n );\n\n return connection as CoreIntegrationConnection<'gitea'>;\n }),\n );\n }\n\n return {\n provider: createGiteaIntegrationProvider({\n getExistingGiteaConnection,\n connectGiteaConnection,\n publishSourcePush,\n recordDeliveryOnly,\n getIntegrationConnectionById,\n coreDb: db,\n }),\n database: {\n db: giteaDb,\n migrationsPath: giteaMigrationsPath,\n migrationsTableName: GITEA_MIGRATIONS_TABLE,\n },\n };\n}\n\nexport const giteaProviderModule: IntegrationProviderModule = {\n id: 'gitea',\n enabled: config.INTEGRATIONS_ENABLE_GITEA_PROVIDER,\n load: loadGiteaModuleParts,\n};\n"],"names":["slugifyConnectionSlug","config","getIntegrationConnectionById","resolveUniqueConnectionSlug","upsertIntegrationConnection","db","publishSourcePush","recordDeliveryOnly","retryConnectionSlugCollision","GITEA_MIGRATIONS_TABLE","loadGiteaModuleParts","createGiteaIntegrationProvider","getGiteaConnectionByOrg","upsertGiteaConnection","giteaDb","migrationsPath","giteaMigrationsPath","getExistingGiteaConnection","input","row","org","undefined","connection","connectionId","connectGiteaConnection","transaction","tx","baseSlug","fallback","slug","workspaceId","provider","externalAccountId","displayName","lifecycleStatus","id","coreDb","database","migrationsTableName","giteaProviderModule","enabled","INTEGRATIONS_ENABLE_GITEA_PROVIDER","load"],"mappings":"AAAA,SAEEA,qBAAqB,QAChB,oCAAoC;AAE3C,SAAQC,MAAM,QAAO,aAAa;AAClC,SACEC,4BAA4B,EAC5BC,2BAA2B,EAC3BC,2BAA2B,QACtB,qBAAqB;AAC5B,SAAQC,EAAE,QAAO,YAAY;AAC7B,SAAQC,iBAAiB,EAAEC,kBAAkB,QAAO,4BAA4B;AAChF,SAAQC,4BAA4B,QAAO,gCAAgC;AAG3E,6EAA6E;AAC7E,+EAA+E;AAC/E,0EAA0E;AAC1E,6CAA6C;AAC7C,MAAMC,yBAAyB;AAE/B,eAAeC;IACb,MAAM,EACJC,8BAA8B,EAC9BC,uBAAuB,EACvBC,qBAAqB,EACrBR,IAAIS,OAAO,EACXC,gBAAgBC,mBAAmB,EACpC,GAAG,MAAM,MAAM,CAAC;IAEjB,eAAeC,2BAA2BC,KAEzC;QACC,MAAMC,MAAM,MAAMP,wBAAwBM,MAAME,GAAG;QACnD,IAAI,CAACD,KAAK,OAAOE;QACjB,MAAMC,aAAa,MAAMpB,6BAA6BiB,IAAII,YAAY;QACtE,IAAI,CAACD,YAAY,OAAOD;QACxB,OAAOC;IACT;IAEA,eAAeE,uBACbN,KAAkC;QAElC,OAAO,MAAMV,6BAA6B,IACxCH,KAAKoB,WAAW,CAAC,OAAOC;gBACtB,MAAMC,WAAW3B,sBAAsB,CAAC,MAAM,EAAEkB,MAAME,GAAG,EAAE,EAAE;oBAACQ,UAAU;gBAAO;gBAC/E,MAAMC,OAAO,MAAM1B,4BACjB;oBACE2B,aAAaZ,MAAMY,WAAW;oBAC9BC,UAAU;oBACVC,mBAAmBd,MAAME,GAAG;oBAC5BO;gBACF,GACA;oBAACD;gBAAE;gBAEL,MAAMJ,aAAa,MAAMlB,4BACvB;oBACE0B,aAAaZ,MAAMY,WAAW;oBAC9BC,UAAU;oBACVC,mBAAmBd,MAAME,GAAG;oBAC5BS;oBACAI,aAAaf,MAAMe,WAAW;oBAC9BC,iBAAiB;gBACnB,GACA;oBAACR;gBAAE;gBAGL,MAAMb,sBACJ;oBACEU,cAAcD,WAAWa,EAAE;oBAC3Bf,KAAKF,MAAME,GAAG;gBAChB,GACA;oBAACM;gBAAE;gBAGL,OAAOJ;YACT;IAEJ;IAEA,OAAO;QACLS,UAAUpB,+BAA+B;YACvCM;YACAO;YACAlB;YACAC;YACAL;YACAkC,QAAQ/B;QACV;QACAgC,UAAU;YACRhC,IAAIS;YACJC,gBAAgBC;YAChBsB,qBAAqB7B;QACvB;IACF;AACF;AAEA,OAAO,MAAM8B,sBAAiD;IAC5DJ,IAAI;IACJK,SAASvC,OAAOwC,kCAAkC;IAClDC,MAAMhC;AACR,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/providers/github.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAEV,yBAAyB,EAE1B,MAAM,qBAAqB,CAAC;AA2H7B,eAAO,MAAM,oBAAoB,EAAE,yBAIlC,CAAC"}
|