@shipfox/api-integration-core 8.0.0 → 9.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +101 -0
- package/dist/core/agent-tool-selection.d.ts +1 -1
- package/dist/core/agent-tool-selection.d.ts.map +1 -1
- package/dist/core/agent-tool-selection.js.map +1 -1
- package/dist/core/entities/connection.d.ts +1 -1
- package/dist/core/entities/connection.d.ts.map +1 -1
- package/dist/core/entities/connection.js.map +1 -1
- package/dist/core/entities/provider.d.ts +2 -2
- package/dist/core/entities/provider.d.ts.map +1 -1
- package/dist/core/entities/provider.js.map +1 -1
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +1 -1
- package/dist/core/errors.js.map +1 -1
- package/dist/core/providers/agent-tools.d.ts +1 -1
- package/dist/core/providers/agent-tools.d.ts.map +1 -1
- package/dist/core/providers/agent-tools.js.map +1 -1
- package/dist/core/providers/redact-checkout-spec.d.ts +1 -1
- package/dist/core/providers/redact-checkout-spec.d.ts.map +1 -1
- package/dist/core/providers/redact-checkout-spec.js.map +1 -1
- package/dist/core/providers/source-control.d.ts +1 -1
- package/dist/core/providers/source-control.d.ts.map +1 -1
- package/dist/core/providers/source-control.js.map +1 -1
- package/dist/db/connections.d.ts.map +1 -1
- package/dist/db/connections.js +2 -1
- package/dist/db/connections.js.map +1 -1
- package/dist/db/webhook-deliveries.d.ts +1 -1
- package/dist/db/webhook-deliveries.d.ts.map +1 -1
- package/dist/db/webhook-deliveries.js +1 -1
- package/dist/db/webhook-deliveries.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/presentation/dto/integrations.d.ts +2 -2
- package/dist/presentation/dto/integrations.d.ts.map +1 -1
- package/dist/presentation/dto/integrations.js +18 -2
- package/dist/presentation/dto/integrations.js.map +1 -1
- package/dist/presentation/routes/list-connections.js +1 -1
- package/dist/presentation/routes/list-connections.js.map +1 -1
- package/dist/presentation/routes/list-providers.js +1 -1
- package/dist/presentation/routes/list-providers.js.map +1 -1
- package/dist/presentation/routes/list-repositories.js +1 -1
- package/dist/presentation/routes/list-repositories.js.map +1 -1
- package/dist/presentation/routes/manage-connections.js +1 -1
- package/dist/presentation/routes/manage-connections.js.map +1 -1
- package/dist/providers/connection-slug.d.ts +3 -0
- package/dist/providers/connection-slug.d.ts.map +1 -1
- package/dist/providers/connection-slug.js +10 -1
- package/dist/providers/connection-slug.js.map +1 -1
- package/dist/providers/gitea.d.ts.map +1 -1
- package/dist/providers/gitea.js +2 -8
- package/dist/providers/gitea.js.map +1 -1
- package/dist/providers/github.d.ts.map +1 -1
- package/dist/providers/github.js +2 -8
- package/dist/providers/github.js.map +1 -1
- package/dist/providers/jira.d.ts.map +1 -1
- package/dist/providers/jira.js +2 -4
- package/dist/providers/jira.js.map +1 -1
- package/dist/providers/linear.d.ts.map +1 -1
- package/dist/providers/linear.js +2 -4
- package/dist/providers/linear.js.map +1 -1
- package/dist/providers/sentry.d.ts.map +1 -1
- package/dist/providers/sentry.js +2 -8
- package/dist/providers/sentry.js.map +1 -1
- package/dist/providers/slack.d.ts.map +1 -1
- package/dist/providers/slack.js +2 -4
- package/dist/providers/slack.js.map +1 -1
- package/dist/providers/types.d.ts +1 -1
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/providers/types.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +37 -29
- package/src/core/agent-tool-selection.ts +1 -1
- package/src/core/entities/connection.ts +1 -1
- package/src/core/entities/provider.ts +2 -2
- package/src/core/errors.ts +1 -1
- package/src/core/providers/agent-tools.ts +1 -1
- package/src/core/providers/redact-checkout-spec.test.ts +1 -1
- package/src/core/providers/redact-checkout-spec.ts +1 -1
- package/src/core/providers/source-control.ts +1 -1
- package/src/db/connections.test.ts +1 -1
- package/src/db/connections.ts +2 -4
- package/src/db/webhook-deliveries.test.ts +1 -1
- package/src/db/webhook-deliveries.ts +1 -1
- package/src/index.test.ts +1 -4
- package/src/index.ts +4 -4
- package/src/presentation/dto/integrations.ts +21 -2
- package/src/presentation/routes/list-connections.ts +1 -1
- package/src/presentation/routes/list-providers.ts +1 -1
- package/src/presentation/routes/list-repositories.ts +1 -1
- package/src/presentation/routes/manage-connections.ts +1 -1
- package/src/providers/connection-slug.ts +18 -1
- package/src/providers/gitea.ts +3 -12
- package/src/providers/github.ts +3 -12
- package/src/providers/jira.test.ts +1 -1
- package/src/providers/jira.ts +3 -7
- package/src/providers/linear.test.ts +2 -2
- package/src/providers/linear.ts +3 -7
- package/src/providers/sentry.ts +3 -12
- package/src/providers/slack.test.ts +3 -3
- package/src/providers/slack.ts +3 -7
- package/src/providers/types.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipfox/api-integration-core",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "9.0.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/ShipfoxHQ/shipfox.git",
|
|
@@ -11,10 +11,6 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "dist/index.js",
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
|
-
"imports": {
|
|
15
|
-
"#test/*": "./test/*",
|
|
16
|
-
"#*": "./dist/*"
|
|
17
|
-
},
|
|
18
14
|
"exports": {
|
|
19
15
|
".": {
|
|
20
16
|
"types": "./dist/index.d.ts",
|
|
@@ -27,30 +23,42 @@
|
|
|
27
23
|
"ajv": "^8.20.0",
|
|
28
24
|
"drizzle-orm": "^0.45.2",
|
|
29
25
|
"zod": "^4.4.3",
|
|
30
|
-
"@shipfox/api-agent-dto": "
|
|
31
|
-
"@shipfox/api-auth-context": "
|
|
32
|
-
"@shipfox/api-workflows-dto": "
|
|
33
|
-
"@shipfox/api-integration-core-dto": "
|
|
34
|
-
"@shipfox/api-
|
|
35
|
-
"@shipfox/api-
|
|
36
|
-
"@shipfox/api-integration-
|
|
37
|
-
"@shipfox/api-integration-
|
|
38
|
-
"@shipfox/api-integration-
|
|
39
|
-
"@shipfox/api-integration-
|
|
40
|
-
"@shipfox/api-integration-slack": "
|
|
41
|
-
"@shipfox/api-integration-
|
|
42
|
-
"@shipfox/config": "1.2.
|
|
43
|
-
"@shipfox/
|
|
44
|
-
"@shipfox/
|
|
45
|
-
"@shipfox/node-
|
|
46
|
-
"@shipfox/node-
|
|
47
|
-
"@shipfox/node-
|
|
48
|
-
"@shipfox/node-error-monitoring": "0.2.
|
|
49
|
-
"@shipfox/node-
|
|
50
|
-
"@shipfox/node-
|
|
51
|
-
"@shipfox/node-
|
|
52
|
-
"@shipfox/
|
|
53
|
-
"@shipfox/redact": "0.2.
|
|
26
|
+
"@shipfox/api-agent-dto": "9.0.2",
|
|
27
|
+
"@shipfox/api-auth-context": "9.0.2",
|
|
28
|
+
"@shipfox/api-workflows-dto": "9.0.2",
|
|
29
|
+
"@shipfox/api-integration-core-dto": "9.0.2",
|
|
30
|
+
"@shipfox/api-integration-spi": "0.2.2",
|
|
31
|
+
"@shipfox/api-workspaces-dto": "9.0.2",
|
|
32
|
+
"@shipfox/api-integration-gitea": "9.0.2",
|
|
33
|
+
"@shipfox/api-integration-github": "9.0.2",
|
|
34
|
+
"@shipfox/api-integration-jira": "9.0.2",
|
|
35
|
+
"@shipfox/api-integration-linear": "9.0.2",
|
|
36
|
+
"@shipfox/api-integration-slack": "9.0.2",
|
|
37
|
+
"@shipfox/api-integration-sentry": "9.0.2",
|
|
38
|
+
"@shipfox/config": "1.2.4",
|
|
39
|
+
"@shipfox/api-integration-webhook": "9.0.2",
|
|
40
|
+
"@shipfox/inter-module": "0.2.2",
|
|
41
|
+
"@shipfox/node-drizzle": "0.3.4",
|
|
42
|
+
"@shipfox/node-fastify": "0.3.2",
|
|
43
|
+
"@shipfox/node-module": "1.0.1",
|
|
44
|
+
"@shipfox/node-error-monitoring": "0.2.2",
|
|
45
|
+
"@shipfox/node-opentelemetry": "0.6.2",
|
|
46
|
+
"@shipfox/node-outbox": "0.2.6",
|
|
47
|
+
"@shipfox/node-postgres": "0.4.4",
|
|
48
|
+
"@shipfox/node-temporal": "0.4.2",
|
|
49
|
+
"@shipfox/redact": "0.2.5",
|
|
50
|
+
"@shipfox/regex": "0.2.4"
|
|
51
|
+
},
|
|
52
|
+
"imports": {
|
|
53
|
+
"#*": "./dist/*"
|
|
54
|
+
},
|
|
55
|
+
"shipfox": {
|
|
56
|
+
"architecture": {
|
|
57
|
+
"schema": 1,
|
|
58
|
+
"realm": "source-available",
|
|
59
|
+
"kind": "implementation",
|
|
60
|
+
"context": "integrations"
|
|
61
|
+
}
|
|
54
62
|
},
|
|
55
63
|
"scripts": {
|
|
56
64
|
"build": "shipfox-swc && shipfox-temporal-bundle dist/temporal/workflows/index.js",
|
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
AgentToolSelectionCatalog,
|
|
4
4
|
IntegrationCapability,
|
|
5
5
|
IntegrationProviderKind,
|
|
6
|
-
} from '@shipfox/api-integration-
|
|
6
|
+
} from '@shipfox/api-integration-spi';
|
|
7
7
|
import type {IntegrationProviderRegistry} from '#core/providers/registry.js';
|
|
8
8
|
import {listIntegrationConnections} from '#db/connections.js';
|
|
9
9
|
|
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
RegisteredIntegrationProvider as CoreRegisteredIntegrationProvider,
|
|
4
4
|
WebhookRequestProcessor,
|
|
5
5
|
WebhookRouteId,
|
|
6
|
-
} from '@shipfox/api-integration-
|
|
6
|
+
} from '@shipfox/api-integration-spi';
|
|
7
7
|
import type {RouteExport} from '@shipfox/node-fastify';
|
|
8
8
|
|
|
9
9
|
export type {
|
|
@@ -17,7 +17,7 @@ export type {
|
|
|
17
17
|
IntegrationProviderAdapters,
|
|
18
18
|
IntegrationProviderKind,
|
|
19
19
|
OpenAgentToolsSessionInput,
|
|
20
|
-
} from '@shipfox/api-integration-
|
|
20
|
+
} from '@shipfox/api-integration-spi';
|
|
21
21
|
|
|
22
22
|
export type IntegrationProvider = CoreIntegrationProvider<string, RouteExport> & {
|
|
23
23
|
webhookProcessors?:
|
package/src/core/errors.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
ConnectionSlugConflictError,
|
|
3
3
|
IntegrationProviderError,
|
|
4
4
|
type IntegrationProviderErrorReason,
|
|
5
|
-
} from '@shipfox/api-integration-
|
|
5
|
+
} from '@shipfox/api-integration-spi';
|
|
6
6
|
import type {IntegrationCapability, IntegrationProviderKind} from '#core/entities/provider.js';
|
|
7
7
|
|
|
8
8
|
export class IntegrationConnectionNotFoundError extends Error {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ConnectionSlugConflictError} from '@shipfox/api-integration-core-dto';
|
|
2
1
|
import {upsertGithubInstallation} from '@shipfox/api-integration-github';
|
|
2
|
+
import {ConnectionSlugConflictError} from '@shipfox/api-integration-spi';
|
|
3
3
|
import {IntegrationConnectionAlreadyExistsError} from '#core/errors.js';
|
|
4
4
|
import {
|
|
5
5
|
createIntegrationConnection,
|
package/src/db/connections.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ConnectionSlugConflictError,
|
|
4
|
-
} from '@shipfox/api-integration-core-dto';
|
|
1
|
+
import {CONNECTION_SLUG_MAX_LENGTH} from '@shipfox/api-integration-core-dto';
|
|
2
|
+
import {ConnectionSlugConflictError} from '@shipfox/api-integration-spi';
|
|
5
3
|
import {and, eq} from 'drizzle-orm';
|
|
6
4
|
import type {
|
|
7
5
|
IntegrationConnection,
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
INTEGRATION_SOURCE_COMMIT_PUSHED,
|
|
4
4
|
type IntegrationEventReceivedEvent,
|
|
5
5
|
type SourcePushPayload,
|
|
6
|
-
} from '@shipfox/api-integration-
|
|
6
|
+
} from '@shipfox/api-integration-spi';
|
|
7
7
|
import {and, eq, sql} from 'drizzle-orm';
|
|
8
8
|
import {db} from './db.js';
|
|
9
9
|
import {integrationsOutbox} from './schema/outbox.js';
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
type IntegrationEventReceivedEvent,
|
|
5
5
|
type IntegrationsEventMap,
|
|
6
6
|
type SourcePushPayload,
|
|
7
|
-
} from '@shipfox/api-integration-
|
|
7
|
+
} from '@shipfox/api-integration-spi';
|
|
8
8
|
import {writeOutboxEvent, writeOutboxEvents} from '@shipfox/node-outbox';
|
|
9
9
|
import {lt} from 'drizzle-orm';
|
|
10
10
|
import {db} from './db.js';
|
package/src/index.test.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
StoredWebhookRequest,
|
|
3
|
-
WebhookRequestProcessor,
|
|
4
|
-
} from '@shipfox/api-integration-core-dto';
|
|
1
|
+
import type {StoredWebhookRequest, WebhookRequestProcessor} from '@shipfox/api-integration-spi';
|
|
5
2
|
import {createOutboxRegistry, type ModuleService, startModuleServices} from '@shipfox/node-module';
|
|
6
3
|
import {createIntegrationsContext, WebhookProcessorNotConfiguredError} from './index.js';
|
|
7
4
|
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
type WebhookProcessingResult,
|
|
7
7
|
type WebhookRequestProcessor,
|
|
8
8
|
type WebhookRouteId,
|
|
9
|
-
} from '@shipfox/api-integration-
|
|
9
|
+
} from '@shipfox/api-integration-spi';
|
|
10
10
|
import type {WorkflowsModuleClient} from '@shipfox/api-workflows-dto/inter-module';
|
|
11
11
|
import type {WorkspacesInterModuleClient} from '@shipfox/api-workspaces-dto/inter-module';
|
|
12
12
|
import {reportError} from '@shipfox/node-error-monitoring';
|
|
@@ -45,12 +45,12 @@ export type {
|
|
|
45
45
|
WebhookProcessingResult,
|
|
46
46
|
WebhookRequestProcessor,
|
|
47
47
|
WebhookRouteId,
|
|
48
|
-
} from '@shipfox/api-integration-
|
|
48
|
+
} from '@shipfox/api-integration-spi';
|
|
49
49
|
export {
|
|
50
50
|
buildProviderRepositoryId,
|
|
51
51
|
MAX_REPOSITORY_FILE_BYTES,
|
|
52
52
|
parseProviderRepositoryId,
|
|
53
|
-
} from '@shipfox/api-integration-
|
|
53
|
+
} from '@shipfox/api-integration-spi';
|
|
54
54
|
export type {
|
|
55
55
|
AgentToolCatalogs,
|
|
56
56
|
AgentToolSelectionCatalogs,
|
|
@@ -238,7 +238,7 @@ export async function createIntegrationsContext(
|
|
|
238
238
|
],
|
|
239
239
|
startupTasks: runStartupTasks,
|
|
240
240
|
database: [
|
|
241
|
-
{db, migrationsPath},
|
|
241
|
+
{db, migrationsPath, databaseNamespace: 'integrations'},
|
|
242
242
|
...parts.flatMap((part) => (part.database ? [part.database] : [])),
|
|
243
243
|
],
|
|
244
244
|
routes: createIntegrationRoutes(registry, sourceControl, {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {toIntegrationConnectionDto as toCoreIntegrationConnectionDto} from '@shipfox/api-integration-core-dto';
|
|
2
1
|
import type {IntegrationConnection} from '#core/entities/connection.js';
|
|
3
2
|
import type {
|
|
4
3
|
IntegrationCapability,
|
|
@@ -21,7 +20,27 @@ export function toIntegrationConnectionDto(
|
|
|
21
20
|
externalUrl?: string | undefined;
|
|
22
21
|
},
|
|
23
22
|
) {
|
|
24
|
-
return
|
|
23
|
+
return mapIntegrationConnection(connection, options.capabilities, options.externalUrl);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function mapIntegrationConnection(
|
|
27
|
+
connection: IntegrationConnection,
|
|
28
|
+
capabilities: IntegrationCapability[],
|
|
29
|
+
externalUrl?: string,
|
|
30
|
+
) {
|
|
31
|
+
return {
|
|
32
|
+
id: connection.id,
|
|
33
|
+
workspace_id: connection.workspaceId,
|
|
34
|
+
provider: connection.provider,
|
|
35
|
+
external_account_id: connection.externalAccountId,
|
|
36
|
+
slug: connection.slug,
|
|
37
|
+
display_name: connection.displayName,
|
|
38
|
+
lifecycle_status: connection.lifecycleStatus,
|
|
39
|
+
capabilities,
|
|
40
|
+
...(externalUrl ? {external_url: externalUrl} : {}),
|
|
41
|
+
created_at: connection.createdAt.toISOString(),
|
|
42
|
+
updated_at: connection.updatedAt.toISOString(),
|
|
43
|
+
};
|
|
25
44
|
}
|
|
26
45
|
|
|
27
46
|
export function toRepositoryDto(connectionId: string, repository: RepositorySnapshot) {
|
|
@@ -2,7 +2,7 @@ import {AUTH_USER, requireWorkspaceAccess} from '@shipfox/api-auth-context';
|
|
|
2
2
|
import {
|
|
3
3
|
listIntegrationConnectionsQuerySchema,
|
|
4
4
|
listIntegrationConnectionsResponseSchema,
|
|
5
|
-
} from '@shipfox/api-integration-
|
|
5
|
+
} from '@shipfox/api-integration-spi';
|
|
6
6
|
import {defineRoute} from '@shipfox/node-fastify';
|
|
7
7
|
import type {IntegrationProviderRegistry} from '#core/providers/registry.js';
|
|
8
8
|
import {listIntegrationConnections} from '#db/connections.js';
|
|
@@ -2,7 +2,7 @@ import {AUTH_USER} from '@shipfox/api-auth-context';
|
|
|
2
2
|
import {
|
|
3
3
|
listIntegrationProvidersQuerySchema,
|
|
4
4
|
listIntegrationProvidersResponseSchema,
|
|
5
|
-
} from '@shipfox/api-integration-
|
|
5
|
+
} from '@shipfox/api-integration-spi';
|
|
6
6
|
import {defineRoute} from '@shipfox/node-fastify';
|
|
7
7
|
import type {IntegrationProviderRegistry} from '#core/providers/registry.js';
|
|
8
8
|
import {toIntegrationProviderDto} from '#presentation/dto/integrations.js';
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
listRepositoriesParamsSchema,
|
|
4
4
|
listRepositoriesQuerySchema,
|
|
5
5
|
listRepositoriesResponseSchema,
|
|
6
|
-
} from '@shipfox/api-integration-
|
|
6
|
+
} from '@shipfox/api-integration-spi';
|
|
7
7
|
import {defineRoute} from '@shipfox/node-fastify';
|
|
8
8
|
import type {IntegrationSourceControlService} from '#core/source-control-service.js';
|
|
9
9
|
import {toRepositoryDto} from '#presentation/dto/integrations.js';
|
|
@@ -2,7 +2,7 @@ import {AUTH_USER, requireWorkspaceAccess} from '@shipfox/api-auth-context';
|
|
|
2
2
|
import {
|
|
3
3
|
integrationConnectionDtoSchema,
|
|
4
4
|
updateIntegrationConnectionBodySchema,
|
|
5
|
-
} from '@shipfox/api-integration-
|
|
5
|
+
} from '@shipfox/api-integration-spi';
|
|
6
6
|
import {ClientError, defineRoute} from '@shipfox/node-fastify';
|
|
7
7
|
import {z} from 'zod';
|
|
8
8
|
import type {IntegrationProviderRegistry} from '#core/providers/registry.js';
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {CONNECTION_SLUG_MAX_LENGTH} from '@shipfox/api-integration-core-dto';
|
|
2
|
+
import {ConnectionSlugConflictError} from '@shipfox/api-integration-spi';
|
|
2
3
|
import {isIntegrationConnectionSlugUniqueViolation} from '#db/connections.js';
|
|
3
4
|
|
|
4
5
|
const MAX_CONNECTION_SLUG_ATTEMPTS = 3;
|
|
5
6
|
|
|
7
|
+
export function slugifyConnectionSlug(input: string, options: {fallback: string}): string {
|
|
8
|
+
const slug = normalizeSlug(input);
|
|
9
|
+
if (slug) return slug;
|
|
10
|
+
|
|
11
|
+
return normalizeSlug(options.fallback) || 'connection';
|
|
12
|
+
}
|
|
13
|
+
|
|
6
14
|
export async function retryConnectionSlugCollision<T>(operation: () => Promise<T>): Promise<T> {
|
|
7
15
|
for (let attempt = 1; ; attempt += 1) {
|
|
8
16
|
try {
|
|
@@ -17,3 +25,12 @@ export async function retryConnectionSlugCollision<T>(operation: () => Promise<T
|
|
|
17
25
|
}
|
|
18
26
|
}
|
|
19
27
|
}
|
|
28
|
+
|
|
29
|
+
function normalizeSlug(input: string): string {
|
|
30
|
+
return input
|
|
31
|
+
.toLowerCase()
|
|
32
|
+
.replaceAll(/[^a-z0-9]+/g, '_')
|
|
33
|
+
.replaceAll(/^_+|_+$/g, '')
|
|
34
|
+
.slice(0, CONNECTION_SLUG_MAX_LENGTH)
|
|
35
|
+
.replaceAll(/_+$/g, '');
|
|
36
|
+
}
|
package/src/providers/gitea.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type IntegrationConnection as CoreIntegrationConnection,
|
|
3
|
-
slugifyConnectionSlug,
|
|
4
|
-
} from '@shipfox/api-integration-core-dto';
|
|
5
1
|
import type {ConnectGiteaConnectionInput} from '@shipfox/api-integration-gitea';
|
|
2
|
+
import type {IntegrationConnection as CoreIntegrationConnection} from '@shipfox/api-integration-spi';
|
|
6
3
|
import {config} from '#config.js';
|
|
7
4
|
import {
|
|
8
5
|
getIntegrationConnectionById,
|
|
@@ -11,15 +8,9 @@ import {
|
|
|
11
8
|
} from '#db/connections.js';
|
|
12
9
|
import {db} from '#db/db.js';
|
|
13
10
|
import {publishSourcePush, recordDeliveryOnly} from '#db/webhook-deliveries.js';
|
|
14
|
-
import {retryConnectionSlugCollision} from '#providers/connection-slug.js';
|
|
11
|
+
import {retryConnectionSlugCollision, slugifyConnectionSlug} from '#providers/connection-slug.js';
|
|
15
12
|
import type {IntegrationModuleParts, IntegrationProviderModule} from '#providers/types.js';
|
|
16
13
|
|
|
17
|
-
// Stable migration-tracking table name for the Gitea provider database. This
|
|
18
|
-
// must NOT depend on the provider's position in the module `database` array. A
|
|
19
|
-
// positional name would shift if a provider is flag-disabled and silently
|
|
20
|
-
// re-run migrations against existing tables.
|
|
21
|
-
const GITEA_MIGRATIONS_TABLE = '__drizzle_migrations_integrations_gitea';
|
|
22
|
-
|
|
23
14
|
async function loadGiteaModuleParts(): Promise<IntegrationModuleParts> {
|
|
24
15
|
const {
|
|
25
16
|
createGiteaIntegrationProvider,
|
|
@@ -94,7 +85,7 @@ async function loadGiteaModuleParts(): Promise<IntegrationModuleParts> {
|
|
|
94
85
|
database: {
|
|
95
86
|
db: giteaDb,
|
|
96
87
|
migrationsPath: giteaMigrationsPath,
|
|
97
|
-
|
|
88
|
+
databaseNamespace: 'integrations_gitea',
|
|
98
89
|
},
|
|
99
90
|
};
|
|
100
91
|
}
|
package/src/providers/github.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type IntegrationConnection as CoreIntegrationConnection,
|
|
3
|
-
slugifyConnectionSlug,
|
|
4
|
-
} from '@shipfox/api-integration-core-dto';
|
|
5
1
|
import type {ConnectGithubInstallationInput} from '@shipfox/api-integration-github';
|
|
2
|
+
import type {IntegrationConnection as CoreIntegrationConnection} from '@shipfox/api-integration-spi';
|
|
6
3
|
import {config} from '#config.js';
|
|
7
4
|
import {
|
|
8
5
|
getIntegrationConnectionById,
|
|
@@ -15,19 +12,13 @@ import {
|
|
|
15
12
|
publishSourcePush,
|
|
16
13
|
recordDeliveryOnly,
|
|
17
14
|
} from '#db/webhook-deliveries.js';
|
|
18
|
-
import {retryConnectionSlugCollision} from '#providers/connection-slug.js';
|
|
15
|
+
import {retryConnectionSlugCollision, slugifyConnectionSlug} from '#providers/connection-slug.js';
|
|
19
16
|
import type {
|
|
20
17
|
IntegrationModuleParts,
|
|
21
18
|
IntegrationProviderModule,
|
|
22
19
|
IntegrationProviderModuleLoadOptions,
|
|
23
20
|
} from '#providers/types.js';
|
|
24
21
|
|
|
25
|
-
// Stable migration-tracking table name for the GitHub provider database. This
|
|
26
|
-
// must NOT depend on the provider's position in the module `database` array. A
|
|
27
|
-
// positional name would shift if a provider is flag-disabled and silently
|
|
28
|
-
// re-run migrations against existing tables.
|
|
29
|
-
const GITHUB_MIGRATIONS_TABLE = '__drizzle_migrations_integrations_github';
|
|
30
|
-
|
|
31
22
|
async function loadGithubModuleParts(
|
|
32
23
|
options: IntegrationProviderModuleLoadOptions = {},
|
|
33
24
|
): Promise<IntegrationModuleParts> {
|
|
@@ -144,7 +135,7 @@ async function loadGithubModuleParts(
|
|
|
144
135
|
database: {
|
|
145
136
|
db: githubDb,
|
|
146
137
|
migrationsPath: githubMigrationsPath,
|
|
147
|
-
|
|
138
|
+
databaseNamespace: 'integrations_github',
|
|
148
139
|
},
|
|
149
140
|
};
|
|
150
141
|
}
|
|
@@ -26,7 +26,7 @@ describe('jiraProviderModule', () => {
|
|
|
26
26
|
await runMigrations(
|
|
27
27
|
jiraPart.database.db(),
|
|
28
28
|
jiraPart.database.migrationsPath,
|
|
29
|
-
jiraPart.database.
|
|
29
|
+
`__drizzle_migrations_${jiraPart.database.databaseNamespace}`,
|
|
30
30
|
);
|
|
31
31
|
const connection = await upsertIntegrationConnection({
|
|
32
32
|
workspaceId,
|
package/src/providers/jira.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type IntegrationConnection as CoreIntegrationConnection,
|
|
3
|
-
slugifyConnectionSlug,
|
|
4
|
-
} from '@shipfox/api-integration-core-dto';
|
|
5
1
|
import type {
|
|
6
2
|
ConnectJiraInstallationInput,
|
|
7
3
|
JiraPendingSelectionSecretsStore,
|
|
8
4
|
JiraSecretsStore,
|
|
9
5
|
} from '@shipfox/api-integration-jira';
|
|
6
|
+
import type {IntegrationConnection as CoreIntegrationConnection} from '@shipfox/api-integration-spi';
|
|
10
7
|
import {config} from '#config.js';
|
|
11
8
|
import {
|
|
12
9
|
deleteIntegrationConnection,
|
|
@@ -16,10 +13,9 @@ import {
|
|
|
16
13
|
upsertIntegrationConnection,
|
|
17
14
|
} from '#db/connections.js';
|
|
18
15
|
import {db} from '#db/db.js';
|
|
19
|
-
import {retryConnectionSlugCollision} from '#providers/connection-slug.js';
|
|
16
|
+
import {retryConnectionSlugCollision, slugifyConnectionSlug} from '#providers/connection-slug.js';
|
|
20
17
|
import type {IntegrationModuleParts, IntegrationProviderModule} from '#providers/types.js';
|
|
21
18
|
|
|
22
|
-
const JIRA_MIGRATIONS_TABLE = '__drizzle_migrations_integrations_jira';
|
|
23
19
|
const JIRA_SECRETS_NAMESPACE_PREFIX = 'system/integrations/jira/';
|
|
24
20
|
type IntegrationDb = ReturnType<typeof db>;
|
|
25
21
|
type IntegrationTx = Parameters<Parameters<IntegrationDb['transaction']>[0]>[0];
|
|
@@ -157,7 +153,7 @@ async function loadJiraModuleParts(
|
|
|
157
153
|
: {}),
|
|
158
154
|
},
|
|
159
155
|
}),
|
|
160
|
-
database: {db: jiraDb, migrationsPath,
|
|
156
|
+
database: {db: jiraDb, migrationsPath, databaseNamespace: 'integrations_jira'},
|
|
161
157
|
};
|
|
162
158
|
}
|
|
163
159
|
|
|
@@ -27,7 +27,7 @@ describe('linearProviderModule', () => {
|
|
|
27
27
|
await runMigrations(
|
|
28
28
|
linearPart.database.db(),
|
|
29
29
|
linearPart.database.migrationsPath,
|
|
30
|
-
linearPart.database.
|
|
30
|
+
`__drizzle_migrations_${linearPart.database.databaseNamespace}`,
|
|
31
31
|
);
|
|
32
32
|
const app = await createTestApp([linearPart.provider]);
|
|
33
33
|
const connection = await upsertIntegrationConnection({
|
|
@@ -99,7 +99,7 @@ describe('linearProviderModule', () => {
|
|
|
99
99
|
await runMigrations(
|
|
100
100
|
linearPart.database.db(),
|
|
101
101
|
linearPart.database.migrationsPath,
|
|
102
|
-
linearPart.database.
|
|
102
|
+
`__drizzle_migrations_${linearPart.database.databaseNamespace}`,
|
|
103
103
|
);
|
|
104
104
|
const connection = await upsertIntegrationConnection({
|
|
105
105
|
workspaceId: context.workspaceId,
|
package/src/providers/linear.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type IntegrationConnection as CoreIntegrationConnection,
|
|
3
|
-
slugifyConnectionSlug,
|
|
4
|
-
} from '@shipfox/api-integration-core-dto';
|
|
5
1
|
import type {
|
|
6
2
|
ConnectLinearInstallationInput,
|
|
7
3
|
LinearSecretsStore,
|
|
8
4
|
} from '@shipfox/api-integration-linear';
|
|
5
|
+
import type {IntegrationConnection as CoreIntegrationConnection} from '@shipfox/api-integration-spi';
|
|
9
6
|
import {config} from '#config.js';
|
|
10
7
|
import {
|
|
11
8
|
deleteIntegrationConnection,
|
|
@@ -15,10 +12,9 @@ import {
|
|
|
15
12
|
} from '#db/connections.js';
|
|
16
13
|
import {db} from '#db/db.js';
|
|
17
14
|
import {publishIntegrationEventReceived, recordDeliveryOnly} from '#db/webhook-deliveries.js';
|
|
18
|
-
import {retryConnectionSlugCollision} from '#providers/connection-slug.js';
|
|
15
|
+
import {retryConnectionSlugCollision, slugifyConnectionSlug} from '#providers/connection-slug.js';
|
|
19
16
|
import type {IntegrationModuleParts, IntegrationProviderModule} from '#providers/types.js';
|
|
20
17
|
|
|
21
|
-
const LINEAR_MIGRATIONS_TABLE = '__drizzle_migrations_integrations_linear';
|
|
22
18
|
const LINEAR_SECRETS_NAMESPACE_PREFIX = 'system/integrations/linear/';
|
|
23
19
|
|
|
24
20
|
type IntegrationDb = ReturnType<typeof db>;
|
|
@@ -180,7 +176,7 @@ async function loadLinearModuleParts(
|
|
|
180
176
|
database: {
|
|
181
177
|
db: linearDb,
|
|
182
178
|
migrationsPath: linearMigrationsPath,
|
|
183
|
-
|
|
179
|
+
databaseNamespace: 'integrations_linear',
|
|
184
180
|
},
|
|
185
181
|
};
|
|
186
182
|
}
|
package/src/providers/sentry.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type IntegrationConnection as CoreIntegrationConnection,
|
|
3
|
-
slugifyConnectionSlug,
|
|
4
|
-
} from '@shipfox/api-integration-core-dto';
|
|
5
1
|
import type {ConnectSentryInstallationInput} from '@shipfox/api-integration-sentry';
|
|
2
|
+
import type {IntegrationConnection as CoreIntegrationConnection} from '@shipfox/api-integration-spi';
|
|
6
3
|
import {config} from '#config.js';
|
|
7
4
|
import {
|
|
8
5
|
getIntegrationConnectionById,
|
|
@@ -12,15 +9,9 @@ import {
|
|
|
12
9
|
} from '#db/connections.js';
|
|
13
10
|
import {db} from '#db/db.js';
|
|
14
11
|
import {publishIntegrationEventReceived, recordDeliveryOnly} from '#db/webhook-deliveries.js';
|
|
15
|
-
import {retryConnectionSlugCollision} from '#providers/connection-slug.js';
|
|
12
|
+
import {retryConnectionSlugCollision, slugifyConnectionSlug} from '#providers/connection-slug.js';
|
|
16
13
|
import type {IntegrationModuleParts, IntegrationProviderModule} from '#providers/types.js';
|
|
17
14
|
|
|
18
|
-
// Stable migration-tracking table name for the Sentry provider database. This
|
|
19
|
-
// must NOT depend on the provider's position in the module `database` array. A
|
|
20
|
-
// positional name would shift if a provider is flag-disabled and silently
|
|
21
|
-
// re-run migrations against existing tables.
|
|
22
|
-
const SENTRY_MIGRATIONS_TABLE = '__drizzle_migrations_integrations_sentry';
|
|
23
|
-
|
|
24
15
|
async function loadSentryModuleParts(): Promise<IntegrationModuleParts> {
|
|
25
16
|
const {
|
|
26
17
|
createSentryIntegrationProvider,
|
|
@@ -103,7 +94,7 @@ async function loadSentryModuleParts(): Promise<IntegrationModuleParts> {
|
|
|
103
94
|
database: {
|
|
104
95
|
db: sentryDb,
|
|
105
96
|
migrationsPath: sentryMigrationsPath,
|
|
106
|
-
|
|
97
|
+
databaseNamespace: 'integrations_sentry',
|
|
107
98
|
},
|
|
108
99
|
workers: [createSentryMaintenanceWorker()],
|
|
109
100
|
};
|
|
@@ -30,7 +30,7 @@ describe('slackProviderModule', () => {
|
|
|
30
30
|
await runMigrations(
|
|
31
31
|
slackPart.database.db(),
|
|
32
32
|
slackPart.database.migrationsPath,
|
|
33
|
-
slackPart.database.
|
|
33
|
+
`__drizzle_migrations_${slackPart.database.databaseNamespace}`,
|
|
34
34
|
);
|
|
35
35
|
const connection = await upsertIntegrationConnection({
|
|
36
36
|
workspaceId,
|
|
@@ -81,7 +81,7 @@ describe('slackProviderModule', () => {
|
|
|
81
81
|
await runMigrations(
|
|
82
82
|
slackPart.database.db(),
|
|
83
83
|
slackPart.database.migrationsPath,
|
|
84
|
-
slackPart.database.
|
|
84
|
+
`__drizzle_migrations_${slackPart.database.databaseNamespace}`,
|
|
85
85
|
);
|
|
86
86
|
const app = await createTestApp([slackPart.provider]);
|
|
87
87
|
const connection = await upsertIntegrationConnection({
|
|
@@ -159,7 +159,7 @@ describe('slackProviderModule', () => {
|
|
|
159
159
|
await runMigrations(
|
|
160
160
|
slackPart.database.db(),
|
|
161
161
|
slackPart.database.migrationsPath,
|
|
162
|
-
slackPart.database.
|
|
162
|
+
`__drizzle_migrations_${slackPart.database.databaseNamespace}`,
|
|
163
163
|
);
|
|
164
164
|
const connection = await upsertIntegrationConnection({
|
|
165
165
|
workspaceId: context.workspaceId,
|
package/src/providers/slack.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type IntegrationConnection as CoreIntegrationConnection,
|
|
3
|
-
slugifyConnectionSlug,
|
|
4
|
-
} from '@shipfox/api-integration-core-dto';
|
|
5
1
|
import type {
|
|
6
2
|
ConnectSlackInstallationInput,
|
|
7
3
|
SlackSecretsStore,
|
|
8
4
|
} from '@shipfox/api-integration-slack';
|
|
5
|
+
import type {IntegrationConnection as CoreIntegrationConnection} from '@shipfox/api-integration-spi';
|
|
9
6
|
import {config} from '#config.js';
|
|
10
7
|
import {
|
|
11
8
|
deleteIntegrationConnection,
|
|
@@ -19,10 +16,9 @@ import {
|
|
|
19
16
|
publishIntegrationEventReceived,
|
|
20
17
|
recordDeliveryOnly,
|
|
21
18
|
} from '#db/webhook-deliveries.js';
|
|
22
|
-
import {retryConnectionSlugCollision} from '#providers/connection-slug.js';
|
|
19
|
+
import {retryConnectionSlugCollision, slugifyConnectionSlug} from '#providers/connection-slug.js';
|
|
23
20
|
import type {IntegrationModuleParts, IntegrationProviderModule} from '#providers/types.js';
|
|
24
21
|
|
|
25
|
-
const SLACK_MIGRATIONS_TABLE = '__drizzle_migrations_integrations_slack';
|
|
26
22
|
const SLACK_SECRETS_NAMESPACE_PREFIX = 'system/integrations/slack/';
|
|
27
23
|
|
|
28
24
|
type IntegrationDb = ReturnType<typeof db>;
|
|
@@ -183,7 +179,7 @@ async function loadSlackModuleParts(
|
|
|
183
179
|
database: {
|
|
184
180
|
db: slackDb,
|
|
185
181
|
migrationsPath: slackMigrationsPath,
|
|
186
|
-
|
|
182
|
+
databaseNamespace: 'integrations_slack',
|
|
187
183
|
},
|
|
188
184
|
};
|
|
189
185
|
}
|
package/src/providers/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {UserContextMembership} from '@shipfox/api-auth-context';
|
|
2
|
-
import type {WebhookRequestProcessor, WebhookRouteId} from '@shipfox/api-integration-
|
|
2
|
+
import type {WebhookRequestProcessor, WebhookRouteId} from '@shipfox/api-integration-spi';
|
|
3
3
|
import type {RouteExport} from '@shipfox/node-fastify';
|
|
4
4
|
import type {ModuleDatabase, ModuleWorker} from '@shipfox/node-module';
|
|
5
5
|
import type {IntegrationProvider} from '#core/entities/provider.js';
|