@shipfox/api-integration-core 12.4.0 → 12.5.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 +4 -4
- package/CHANGELOG.md +20 -0
- package/dist/presentation/routes/agent-tools-gateway/dispatch.d.ts +7 -1
- package/dist/presentation/routes/agent-tools-gateway/dispatch.d.ts.map +1 -1
- package/dist/presentation/routes/agent-tools-gateway/dispatch.js +24 -10
- package/dist/presentation/routes/agent-tools-gateway/dispatch.js.map +1 -1
- package/dist/presentation/routes/errors.d.ts.map +1 -1
- package/dist/presentation/routes/errors.js +1 -1
- package/dist/presentation/routes/errors.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/presentation/routes/agent-tools-gateway/agent-tools-gateway.route.test.ts +11 -4
- package/src/presentation/routes/agent-tools-gateway/dispatch.test.ts +107 -0
- package/src/presentation/routes/agent-tools-gateway/dispatch.ts +54 -15
- package/src/presentation/routes/errors.ts +1 -0
- package/tsconfig.build.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
$ shipfox-swc && shipfox-temporal-bundle dist/temporal/workflows/index.js
|
|
2
|
-
Successfully compiled: 54 files with swc (
|
|
3
|
-
2026-08-
|
|
2
|
+
Successfully compiled: 54 files with swc (819.4ms)
|
|
3
|
+
2026-08-09T17:51:34.556Z [INFO] asset workflow-bundle-e0d869d865fd59433325.js 3.17 MiB [emitted] [immutable] (name: main)
|
|
4
4
|
orphan modules 33.5 KiB [orphan] 21 modules
|
|
5
5
|
runtime modules 1.13 KiB 5 modules
|
|
6
6
|
modules by path ../../../../node_modules/.pnpm/ 970 KiB 196 modules
|
|
@@ -15,6 +15,6 @@ optional modules 30 bytes [optional]
|
|
|
15
15
|
__temporal_custom_payload_converter (ignored) 15 bytes [optional] [built] [code generated]
|
|
16
16
|
__temporal_custom_failure_converter (ignored) 15 bytes [optional] [built] [code generated]
|
|
17
17
|
../../../shared/node/temporal/dist/workflow-error-interceptor.js 1.21 KiB [built] [code generated]
|
|
18
|
-
webpack 5.107.2 compiled successfully in
|
|
19
|
-
2026-08-
|
|
18
|
+
webpack 5.107.2 compiled successfully in 14751 ms
|
|
19
|
+
2026-08-09T17:51:34.577Z [INFO] Workflow bundle created { size: '3.17MB' }
|
|
20
20
|
/home/runner/work/shipfox/shipfox/libs/api/integration/core/dist/temporal/workflows/index.js: 3328998 bytes
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @shipfox/api-integration-core
|
|
2
2
|
|
|
3
|
+
## 12.5.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f2b20af: Preserve GitHub provider rejection details and classify terminal agent-tool failures without reporting them as provider outages.
|
|
8
|
+
- Updated dependencies [420ef97]
|
|
9
|
+
- Updated dependencies [f2b20af]
|
|
10
|
+
- Updated dependencies [da02bd8]
|
|
11
|
+
- Updated dependencies [4fa3667]
|
|
12
|
+
- Updated dependencies [5b1838c]
|
|
13
|
+
- @shipfox/api-integration-github@12.5.0
|
|
14
|
+
- @shipfox/api-integration-spi@1.1.1
|
|
15
|
+
- @shipfox/api-workflows-dto@12.5.0
|
|
16
|
+
- @shipfox/api-integration-gitea@12.5.0
|
|
17
|
+
- @shipfox/api-integration-jira@12.5.0
|
|
18
|
+
- @shipfox/api-integration-linear@12.5.0
|
|
19
|
+
- @shipfox/api-integration-sentry@12.5.0
|
|
20
|
+
- @shipfox/api-integration-slack@12.5.0
|
|
21
|
+
- @shipfox/api-integration-webhook@12.5.0
|
|
22
|
+
|
|
3
23
|
## 12.4.0
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { reportError } from '@shipfox/node-error-monitoring';
|
|
2
|
+
import { logger } from '@shipfox/node-opentelemetry';
|
|
1
3
|
import type { IntegrationProviderRegistry } from '#core/providers/registry.js';
|
|
2
4
|
import type { IntegrationToolDispatcher } from './mcp-server.js';
|
|
3
5
|
export interface CreateIntegrationToolDispatcherParams {
|
|
4
6
|
registry: IntegrationProviderRegistry;
|
|
5
7
|
}
|
|
6
|
-
export
|
|
8
|
+
export interface IntegrationToolDispatcherDependencies {
|
|
9
|
+
logger?: typeof logger;
|
|
10
|
+
reportError?: typeof reportError;
|
|
11
|
+
}
|
|
12
|
+
export declare function createIntegrationToolDispatcher(params: CreateIntegrationToolDispatcherParams, dependencies?: IntegrationToolDispatcherDependencies): IntegrationToolDispatcher;
|
|
7
13
|
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../../src/presentation/routes/agent-tools-gateway/dispatch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../../src/presentation/routes/agent-tools-gateway/dispatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAC,MAAM,EAAC,MAAM,6BAA6B,CAAC;AAQnD,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,6BAA6B,CAAC;AAC7E,OAAO,KAAK,EAAC,yBAAyB,EAA+B,MAAM,iBAAiB,CAAC;AAE7F,MAAM,WAAW,qCAAqC;IACpD,QAAQ,EAAE,2BAA2B,CAAC;CACvC;AAED,MAAM,WAAW,qCAAqC;IACpD,MAAM,CAAC,EAAE,OAAO,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,WAAW,CAAC;CAClC;AAKD,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,qCAAqC,EAC7C,YAAY,GAAE,qCAA0C,GACvD,yBAAyB,CAQ3B"}
|
|
@@ -3,10 +3,12 @@ import { logger } from '@shipfox/node-opentelemetry';
|
|
|
3
3
|
import { IntegrationProviderError } from '#core/errors.js';
|
|
4
4
|
const timeoutErrorPattern = /timed?\s*out|timeout/i;
|
|
5
5
|
const credentialErrorNamePattern = /Token|Credential|Secret|AccessToken/;
|
|
6
|
-
export function createIntegrationToolDispatcher(params) {
|
|
6
|
+
export function createIntegrationToolDispatcher(params, dependencies = {}) {
|
|
7
7
|
return (input)=>dispatchIntegrationToolCall({
|
|
8
8
|
...input,
|
|
9
|
-
registry: params.registry
|
|
9
|
+
registry: params.registry,
|
|
10
|
+
logger: dependencies.logger ?? logger,
|
|
11
|
+
reportError: dependencies.reportError ?? reportError
|
|
10
12
|
});
|
|
11
13
|
}
|
|
12
14
|
async function dispatchIntegrationToolCall(input) {
|
|
@@ -27,17 +29,17 @@ async function dispatchIntegrationToolCall(input) {
|
|
|
27
29
|
} catch (error) {
|
|
28
30
|
const result = errorResult(error);
|
|
29
31
|
if (result.code === 'provider-unavailable') {
|
|
30
|
-
logger().error({
|
|
32
|
+
input.logger().error({
|
|
31
33
|
err: error,
|
|
32
34
|
provider: input.authorizedTool.integration.provider
|
|
33
35
|
}, 'Integration agent tool provider was unavailable');
|
|
34
|
-
reportError(error, {
|
|
36
|
+
input.reportError(error, {
|
|
35
37
|
boundary: 'integration.agent-tool'
|
|
36
38
|
});
|
|
37
39
|
}
|
|
38
40
|
return toolError(result);
|
|
39
41
|
} finally{
|
|
40
|
-
await closeSession(session);
|
|
42
|
+
await closeSession(session, input.logger, input.reportError);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
function agentToolCatalogEntry(input) {
|
|
@@ -63,15 +65,15 @@ function agentToolCatalogEntry(input) {
|
|
|
63
65
|
}
|
|
64
66
|
};
|
|
65
67
|
}
|
|
66
|
-
async function closeSession(session) {
|
|
68
|
+
async function closeSession(session, loggerFactory, reportErrorFn) {
|
|
67
69
|
try {
|
|
68
70
|
await session?.close?.();
|
|
69
71
|
} catch (error) {
|
|
70
72
|
// Cleanup must not mask the tool result returned to the runner.
|
|
71
|
-
|
|
73
|
+
loggerFactory().error({
|
|
72
74
|
err: error
|
|
73
75
|
}, 'Failed to close integration agent tool session');
|
|
74
|
-
|
|
76
|
+
reportErrorFn(error, {
|
|
75
77
|
boundary: 'integration.agent-tool',
|
|
76
78
|
operation: 'close-session'
|
|
77
79
|
});
|
|
@@ -81,7 +83,13 @@ function errorResult(error) {
|
|
|
81
83
|
if (error instanceof IntegrationProviderError) {
|
|
82
84
|
return {
|
|
83
85
|
code: error.reason,
|
|
84
|
-
message:
|
|
86
|
+
message: error.message,
|
|
87
|
+
...error.retryAfterSeconds === undefined ? {} : {
|
|
88
|
+
retryAfterSeconds: error.retryAfterSeconds
|
|
89
|
+
},
|
|
90
|
+
...error.status === undefined ? {} : {
|
|
91
|
+
status: error.status
|
|
92
|
+
}
|
|
85
93
|
};
|
|
86
94
|
}
|
|
87
95
|
if (isTimeoutError(error)) {
|
|
@@ -119,7 +127,13 @@ function toolError(params) {
|
|
|
119
127
|
}
|
|
120
128
|
],
|
|
121
129
|
structuredContent: {
|
|
122
|
-
code: params.code
|
|
130
|
+
code: params.code,
|
|
131
|
+
...params.retryAfterSeconds === undefined ? {} : {
|
|
132
|
+
retryAfterSeconds: params.retryAfterSeconds
|
|
133
|
+
},
|
|
134
|
+
...params.status === undefined ? {} : {
|
|
135
|
+
status: params.status
|
|
136
|
+
}
|
|
123
137
|
}
|
|
124
138
|
};
|
|
125
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/presentation/routes/agent-tools-gateway/dispatch.ts"],"sourcesContent":["import type {CallToolResult} from '@modelcontextprotocol/sdk/types.js';\nimport {reportError} from '@shipfox/node-error-monitoring';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {IntegrationProviderError} from '#core/errors.js';\nimport type {\n AgentToolCatalogEntry,\n AgentToolCatalogMethod,\n AgentToolSession,\n AgentToolsProvider,\n} from '#core/providers/agent-tools.js';\nimport type {IntegrationProviderRegistry} from '#core/providers/registry.js';\nimport type {IntegrationToolDispatcher, IntegrationToolDispatchInput} from './mcp-server.js';\n\nexport interface CreateIntegrationToolDispatcherParams {\n registry: IntegrationProviderRegistry;\n}\n\nconst timeoutErrorPattern = /timed?\\s*out|timeout/i;\nconst credentialErrorNamePattern = /Token|Credential|Secret|AccessToken/;\n\nexport function createIntegrationToolDispatcher(\n params: CreateIntegrationToolDispatcherParams,\n): IntegrationToolDispatcher {\n return (input)
|
|
1
|
+
{"version":3,"sources":["../../../../src/presentation/routes/agent-tools-gateway/dispatch.ts"],"sourcesContent":["import type {CallToolResult} from '@modelcontextprotocol/sdk/types.js';\nimport {reportError} from '@shipfox/node-error-monitoring';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {IntegrationProviderError} from '#core/errors.js';\nimport type {\n AgentToolCatalogEntry,\n AgentToolCatalogMethod,\n AgentToolSession,\n AgentToolsProvider,\n} from '#core/providers/agent-tools.js';\nimport type {IntegrationProviderRegistry} from '#core/providers/registry.js';\nimport type {IntegrationToolDispatcher, IntegrationToolDispatchInput} from './mcp-server.js';\n\nexport interface CreateIntegrationToolDispatcherParams {\n registry: IntegrationProviderRegistry;\n}\n\nexport interface IntegrationToolDispatcherDependencies {\n logger?: typeof logger;\n reportError?: typeof reportError;\n}\n\nconst timeoutErrorPattern = /timed?\\s*out|timeout/i;\nconst credentialErrorNamePattern = /Token|Credential|Secret|AccessToken/;\n\nexport function createIntegrationToolDispatcher(\n params: CreateIntegrationToolDispatcherParams,\n dependencies: IntegrationToolDispatcherDependencies = {},\n): IntegrationToolDispatcher {\n return (input) =>\n dispatchIntegrationToolCall({\n ...input,\n registry: params.registry,\n logger: dependencies.logger ?? logger,\n reportError: dependencies.reportError ?? reportError,\n });\n}\n\nasync function dispatchIntegrationToolCall(\n input: IntegrationToolDispatchInput & {\n registry: IntegrationProviderRegistry;\n logger: typeof logger;\n reportError: typeof reportError;\n },\n): Promise<CallToolResult> {\n let session: AgentToolSession<CallToolResult> | undefined;\n\n try {\n const adapter = input.registry.getAdapter(\n input.authorizedTool.integration.provider,\n 'agent_tools',\n ) as AgentToolsProvider<\n typeof input.authorizedTool.connection,\n unknown,\n typeof input.authorizedTool.integration,\n CallToolResult\n >;\n session = await adapter.openSession({\n connection: input.authorizedTool.connection,\n tools: [agentToolCatalogEntry(input)],\n scope: input.authorizedTool.integration,\n });\n\n return await session.call({\n toolId: input.authorizedTool.tool.id,\n arguments: input.arguments,\n });\n } catch (error) {\n const result = errorResult(error);\n if (result.code === 'provider-unavailable') {\n input\n .logger()\n .error(\n {err: error, provider: input.authorizedTool.integration.provider},\n 'Integration agent tool provider was unavailable',\n );\n input.reportError(error, {boundary: 'integration.agent-tool'});\n }\n return toolError(result);\n } finally {\n await closeSession(session, input.logger, input.reportError);\n }\n}\n\nfunction agentToolCatalogEntry(input: IntegrationToolDispatchInput): AgentToolCatalogEntry {\n const {tool, description, inputSchema, outputSchema} = input.authorizedTool;\n return {\n id: tool.id,\n description,\n sensitivity: tool.sensitivity,\n sensitive: tool.sensitive,\n requiredScope: tool.requiredScope,\n inputSchema,\n ...(outputSchema === undefined ? {} : {outputSchema}),\n ...(tool.methods === undefined\n ? {}\n : {\n methods: tool.methods.map(\n (method): AgentToolCatalogMethod => ({\n id: method.id,\n description: method.description ?? method.token,\n sensitivity: method.sensitivity,\n sensitive: method.sensitive,\n requiredScope: method.requiredScope,\n }),\n ),\n }),\n };\n}\n\nasync function closeSession(\n session: {close?(): Promise<void>} | undefined,\n loggerFactory: typeof logger,\n reportErrorFn: typeof reportError,\n): Promise<void> {\n try {\n await session?.close?.();\n } catch (error) {\n // Cleanup must not mask the tool result returned to the runner.\n loggerFactory().error({err: error}, 'Failed to close integration agent tool session');\n reportErrorFn(error, {boundary: 'integration.agent-tool', operation: 'close-session'});\n }\n}\n\ninterface IntegrationToolError {\n code: string;\n message: string;\n retryAfterSeconds?: number | undefined;\n status?: number | undefined;\n}\n\nfunction errorResult(error: unknown): IntegrationToolError {\n if (error instanceof IntegrationProviderError) {\n return {\n code: error.reason,\n message: error.message,\n ...(error.retryAfterSeconds === undefined\n ? {}\n : {retryAfterSeconds: error.retryAfterSeconds}),\n ...(error.status === undefined ? {} : {status: error.status}),\n };\n }\n\n if (isTimeoutError(error)) {\n return {\n code: 'provider-timeout',\n message: 'Integration provider timed out',\n };\n }\n\n if (isCredentialError(error)) {\n return {\n code: 'credentials-unavailable',\n message: 'Integration provider credentials are unavailable',\n };\n }\n\n return {\n code: 'provider-unavailable',\n message: 'Integration provider call failed',\n };\n}\n\nfunction isTimeoutError(error: unknown): boolean {\n if (!(error instanceof Error)) return false;\n return (\n error.name === 'AbortError' ||\n timeoutErrorPattern.test(error.name) ||\n timeoutErrorPattern.test(error.message)\n );\n}\n\nfunction isCredentialError(error: unknown): boolean {\n if (!(error instanceof Error)) return false;\n return credentialErrorNamePattern.test(error.name);\n}\n\nfunction toolError(params: IntegrationToolError): CallToolResult {\n return {\n isError: true,\n content: [{type: 'text', text: params.message}],\n structuredContent: {\n code: params.code,\n ...(params.retryAfterSeconds === undefined\n ? {}\n : {retryAfterSeconds: params.retryAfterSeconds}),\n ...(params.status === undefined ? {} : {status: params.status}),\n },\n };\n}\n"],"names":["reportError","logger","IntegrationProviderError","timeoutErrorPattern","credentialErrorNamePattern","createIntegrationToolDispatcher","params","dependencies","input","dispatchIntegrationToolCall","registry","session","adapter","getAdapter","authorizedTool","integration","provider","openSession","connection","tools","agentToolCatalogEntry","scope","call","toolId","tool","id","arguments","error","result","errorResult","code","err","boundary","toolError","closeSession","description","inputSchema","outputSchema","sensitivity","sensitive","requiredScope","undefined","methods","map","method","token","loggerFactory","reportErrorFn","close","operation","reason","message","retryAfterSeconds","status","isTimeoutError","isCredentialError","Error","name","test","isError","content","type","text","structuredContent"],"mappings":"AACA,SAAQA,WAAW,QAAO,iCAAiC;AAC3D,SAAQC,MAAM,QAAO,8BAA8B;AACnD,SAAQC,wBAAwB,QAAO,kBAAkB;AAmBzD,MAAMC,sBAAsB;AAC5B,MAAMC,6BAA6B;AAEnC,OA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qB,SAAS;IACX;AACF;AAEA,SAASG,eAAe3B,KAAc;IACpC,IAAI,CAAEA,CAAAA,iBAAiB6B,KAAI,GAAI,OAAO;IACtC,OACE7B,MAAM8B,IAAI,KAAK,gBACftD,oBAAoBuD,IAAI,CAAC/B,MAAM8B,IAAI,KACnCtD,oBAAoBuD,IAAI,CAAC/B,MAAMwB,OAAO;AAE1C;AAEA,SAASI,kBAAkB5B,KAAc;IACvC,IAAI,CAAEA,CAAAA,iBAAiB6B,KAAI,GAAI,OAAO;IACtC,OAAOpD,2BAA2BsD,IAAI,CAAC/B,MAAM8B,IAAI;AACnD;AAEA,SAASxB,UAAU3B,MAA4B;IAC7C,OAAO;QACLqD,SAAS;QACTC,SAAS;YAAC;gBAACC,MAAM;gBAAQC,MAAMxD,OAAO6C,OAAO;YAAA;SAAE;QAC/CY,mBAAmB;YACjBjC,MAAMxB,OAAOwB,IAAI;YACjB,GAAIxB,OAAO8C,iBAAiB,KAAKX,YAC7B,CAAC,IACD;gBAACW,mBAAmB9C,OAAO8C,iBAAiB;YAAA,CAAC;YACjD,GAAI9C,OAAO+C,MAAM,KAAKZ,YAAY,CAAC,IAAI;gBAACY,QAAQ/C,OAAO+C,MAAM;YAAA,CAAC;QAChE;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/errors.ts"],"names":[],"mappings":"AAqCA,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CA0BlE"}
|
|
@@ -6,7 +6,7 @@ function providerStatus(reason) {
|
|
|
6
6
|
return 422;
|
|
7
7
|
}
|
|
8
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');
|
|
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 === 'provider-rejected' || error.reason === 'malformed-provider-response' || error.reason === 'content-too-large' || error.reason === 'too-many-files');
|
|
10
10
|
}
|
|
11
11
|
export function integrationRouteErrorHandler(error) {
|
|
12
12
|
if (error instanceof IntegrationConnectionNotFoundError) {
|
|
@@ -1 +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"}
|
|
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 === 'provider-rejected' ||\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,uBACjBE,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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