@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.
Files changed (105) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +101 -0
  3. package/dist/core/agent-tool-selection.d.ts +1 -1
  4. package/dist/core/agent-tool-selection.d.ts.map +1 -1
  5. package/dist/core/agent-tool-selection.js.map +1 -1
  6. package/dist/core/entities/connection.d.ts +1 -1
  7. package/dist/core/entities/connection.d.ts.map +1 -1
  8. package/dist/core/entities/connection.js.map +1 -1
  9. package/dist/core/entities/provider.d.ts +2 -2
  10. package/dist/core/entities/provider.d.ts.map +1 -1
  11. package/dist/core/entities/provider.js.map +1 -1
  12. package/dist/core/errors.d.ts +1 -1
  13. package/dist/core/errors.d.ts.map +1 -1
  14. package/dist/core/errors.js +1 -1
  15. package/dist/core/errors.js.map +1 -1
  16. package/dist/core/providers/agent-tools.d.ts +1 -1
  17. package/dist/core/providers/agent-tools.d.ts.map +1 -1
  18. package/dist/core/providers/agent-tools.js.map +1 -1
  19. package/dist/core/providers/redact-checkout-spec.d.ts +1 -1
  20. package/dist/core/providers/redact-checkout-spec.d.ts.map +1 -1
  21. package/dist/core/providers/redact-checkout-spec.js.map +1 -1
  22. package/dist/core/providers/source-control.d.ts +1 -1
  23. package/dist/core/providers/source-control.d.ts.map +1 -1
  24. package/dist/core/providers/source-control.js.map +1 -1
  25. package/dist/db/connections.d.ts.map +1 -1
  26. package/dist/db/connections.js +2 -1
  27. package/dist/db/connections.js.map +1 -1
  28. package/dist/db/webhook-deliveries.d.ts +1 -1
  29. package/dist/db/webhook-deliveries.d.ts.map +1 -1
  30. package/dist/db/webhook-deliveries.js +1 -1
  31. package/dist/db/webhook-deliveries.js.map +1 -1
  32. package/dist/index.d.ts +3 -3
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +4 -3
  35. package/dist/index.js.map +1 -1
  36. package/dist/presentation/dto/integrations.d.ts +2 -2
  37. package/dist/presentation/dto/integrations.d.ts.map +1 -1
  38. package/dist/presentation/dto/integrations.js +18 -2
  39. package/dist/presentation/dto/integrations.js.map +1 -1
  40. package/dist/presentation/routes/list-connections.js +1 -1
  41. package/dist/presentation/routes/list-connections.js.map +1 -1
  42. package/dist/presentation/routes/list-providers.js +1 -1
  43. package/dist/presentation/routes/list-providers.js.map +1 -1
  44. package/dist/presentation/routes/list-repositories.js +1 -1
  45. package/dist/presentation/routes/list-repositories.js.map +1 -1
  46. package/dist/presentation/routes/manage-connections.js +1 -1
  47. package/dist/presentation/routes/manage-connections.js.map +1 -1
  48. package/dist/providers/connection-slug.d.ts +3 -0
  49. package/dist/providers/connection-slug.d.ts.map +1 -1
  50. package/dist/providers/connection-slug.js +10 -1
  51. package/dist/providers/connection-slug.js.map +1 -1
  52. package/dist/providers/gitea.d.ts.map +1 -1
  53. package/dist/providers/gitea.js +2 -8
  54. package/dist/providers/gitea.js.map +1 -1
  55. package/dist/providers/github.d.ts.map +1 -1
  56. package/dist/providers/github.js +2 -8
  57. package/dist/providers/github.js.map +1 -1
  58. package/dist/providers/jira.d.ts.map +1 -1
  59. package/dist/providers/jira.js +2 -4
  60. package/dist/providers/jira.js.map +1 -1
  61. package/dist/providers/linear.d.ts.map +1 -1
  62. package/dist/providers/linear.js +2 -4
  63. package/dist/providers/linear.js.map +1 -1
  64. package/dist/providers/sentry.d.ts.map +1 -1
  65. package/dist/providers/sentry.js +2 -8
  66. package/dist/providers/sentry.js.map +1 -1
  67. package/dist/providers/slack.d.ts.map +1 -1
  68. package/dist/providers/slack.js +2 -4
  69. package/dist/providers/slack.js.map +1 -1
  70. package/dist/providers/types.d.ts +1 -1
  71. package/dist/providers/types.d.ts.map +1 -1
  72. package/dist/providers/types.js.map +1 -1
  73. package/dist/tsconfig.test.tsbuildinfo +1 -1
  74. package/package.json +37 -29
  75. package/src/core/agent-tool-selection.ts +1 -1
  76. package/src/core/entities/connection.ts +1 -1
  77. package/src/core/entities/provider.ts +2 -2
  78. package/src/core/errors.ts +1 -1
  79. package/src/core/providers/agent-tools.ts +1 -1
  80. package/src/core/providers/redact-checkout-spec.test.ts +1 -1
  81. package/src/core/providers/redact-checkout-spec.ts +1 -1
  82. package/src/core/providers/source-control.ts +1 -1
  83. package/src/db/connections.test.ts +1 -1
  84. package/src/db/connections.ts +2 -4
  85. package/src/db/webhook-deliveries.test.ts +1 -1
  86. package/src/db/webhook-deliveries.ts +1 -1
  87. package/src/index.test.ts +1 -4
  88. package/src/index.ts +4 -4
  89. package/src/presentation/dto/integrations.ts +21 -2
  90. package/src/presentation/routes/list-connections.ts +1 -1
  91. package/src/presentation/routes/list-providers.ts +1 -1
  92. package/src/presentation/routes/list-repositories.ts +1 -1
  93. package/src/presentation/routes/manage-connections.ts +1 -1
  94. package/src/providers/connection-slug.ts +18 -1
  95. package/src/providers/gitea.ts +3 -12
  96. package/src/providers/github.ts +3 -12
  97. package/src/providers/jira.test.ts +1 -1
  98. package/src/providers/jira.ts +3 -7
  99. package/src/providers/linear.test.ts +2 -2
  100. package/src/providers/linear.ts +3 -7
  101. package/src/providers/sentry.ts +3 -12
  102. package/src/providers/slack.test.ts +3 -3
  103. package/src/providers/slack.ts +3 -7
  104. package/src/providers/types.ts +1 -1
  105. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1,6 +1,6 @@
1
1
  $ shipfox-swc && shipfox-temporal-bundle dist/temporal/workflows/index.js
2
- Successfully compiled: 50 files with swc (386.43ms)
3
- 2026-07-22T14:52:27.401Z [INFO] asset workflow-bundle-646aca428e9943f8cf17.js 3.17 MiB [emitted] [immutable] (name: main)
2
+ Successfully compiled: 50 files with swc (291.62ms)
3
+ 2026-07-24T15:39:49.304Z [INFO] asset workflow-bundle-646aca428e9943f8cf17.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
@@ -12,6 +12,6 @@ optional modules 30 bytes [optional]
12
12
  __temporal_custom_payload_converter (ignored) 15 bytes [optional] [built] [code generated]
13
13
  __temporal_custom_failure_converter (ignored) 15 bytes [optional] [built] [code generated]
14
14
  ../../../shared/node/temporal/dist/workflow-error-interceptor.js 1.21 KiB [built] [code generated]
15
- webpack 5.107.2 compiled successfully in 6215 ms
16
- 2026-07-22T14:52:27.413Z [INFO] Workflow bundle created { size: '3.17MB' }
15
+ webpack 5.107.2 compiled successfully in 7560 ms
16
+ 2026-07-24T15:39:49.321Z [INFO] Workflow bundle created { size: '3.17MB' }
17
17
  /home/runner/work/shipfox/shipfox/libs/api/integration/core/dist/temporal/workflows/index.js: 3323154 bytes
package/CHANGELOG.md CHANGED
@@ -1,5 +1,106 @@
1
1
  # @shipfox/api-integration-core
2
2
 
3
+ ## 9.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 4b85404: Adds versioned architecture identity to participating package artifacts during publication.
8
+ - Updated dependencies [4b85404]
9
+ - @shipfox/api-agent-dto@9.0.2
10
+ - @shipfox/api-auth-context@9.0.2
11
+ - @shipfox/api-integration-core-dto@9.0.2
12
+ - @shipfox/api-integration-gitea@9.0.2
13
+ - @shipfox/api-integration-github@9.0.2
14
+ - @shipfox/api-integration-jira@9.0.2
15
+ - @shipfox/api-integration-linear@9.0.2
16
+ - @shipfox/api-integration-sentry@9.0.2
17
+ - @shipfox/api-integration-slack@9.0.2
18
+ - @shipfox/api-integration-spi@0.2.2
19
+ - @shipfox/api-integration-webhook@9.0.2
20
+ - @shipfox/api-workflows-dto@9.0.2
21
+ - @shipfox/api-workspaces-dto@9.0.2
22
+ - @shipfox/config@1.2.4
23
+ - @shipfox/inter-module@0.2.2
24
+ - @shipfox/node-drizzle@0.3.4
25
+ - @shipfox/node-error-monitoring@0.2.2
26
+ - @shipfox/node-fastify@0.3.2
27
+ - @shipfox/node-module@1.0.1
28
+ - @shipfox/node-opentelemetry@0.6.2
29
+ - @shipfox/node-outbox@0.2.6
30
+ - @shipfox/node-postgres@0.4.4
31
+ - @shipfox/node-temporal@0.4.2
32
+ - @shipfox/redact@0.2.5
33
+ - @shipfox/regex@0.2.4
34
+
35
+ ## 9.0.1
36
+
37
+ ### Patch Changes
38
+
39
+ - 475ce59: Republishes all public packages after restoring release authorization.
40
+ - Updated dependencies [8436596]
41
+ - Updated dependencies [475ce59]
42
+ - Updated dependencies [154e03f]
43
+ - @shipfox/redact@0.2.4
44
+ - @shipfox/regex@0.2.3
45
+ - @shipfox/api-agent-dto@9.0.1
46
+ - @shipfox/api-auth-context@9.0.1
47
+ - @shipfox/api-integration-core-dto@9.0.1
48
+ - @shipfox/api-integration-gitea@9.0.1
49
+ - @shipfox/api-integration-github@9.0.1
50
+ - @shipfox/api-integration-jira@9.0.1
51
+ - @shipfox/api-integration-linear@9.0.1
52
+ - @shipfox/api-integration-sentry@9.0.1
53
+ - @shipfox/api-integration-slack@9.0.1
54
+ - @shipfox/api-integration-spi@0.2.1
55
+ - @shipfox/api-integration-webhook@9.0.1
56
+ - @shipfox/api-workflows-dto@9.0.1
57
+ - @shipfox/api-workspaces-dto@9.0.1
58
+ - @shipfox/config@1.2.3
59
+ - @shipfox/inter-module@0.2.1
60
+ - @shipfox/node-drizzle@0.3.3
61
+ - @shipfox/node-error-monitoring@0.2.1
62
+ - @shipfox/node-fastify@0.3.1
63
+ - @shipfox/node-module@1.0.0
64
+ - @shipfox/node-opentelemetry@0.6.1
65
+ - @shipfox/node-outbox@0.2.5
66
+ - @shipfox/node-postgres@0.4.3
67
+ - @shipfox/node-temporal@0.4.1
68
+
69
+ ## 9.0.0
70
+
71
+ ### Patch Changes
72
+
73
+ - 4a6d124: Separates Integrations provider SPI contracts from the public DTO surface.
74
+ - Updated dependencies [9c9d266]
75
+ - Updated dependencies [46aa52f]
76
+ - Updated dependencies [02974d6]
77
+ - Updated dependencies [4a6d124]
78
+ - @shipfox/api-workspaces-dto@9.0.0
79
+ - @shipfox/api-agent-dto@9.0.0
80
+ - @shipfox/api-integration-core-dto@9.0.0
81
+ - @shipfox/api-integration-github@9.0.0
82
+ - @shipfox/api-integration-spi@0.2.0
83
+ - @shipfox/api-integration-gitea@9.0.0
84
+ - @shipfox/api-integration-jira@9.0.0
85
+ - @shipfox/api-integration-linear@9.0.0
86
+ - @shipfox/api-integration-sentry@9.0.0
87
+ - @shipfox/api-integration-slack@9.0.0
88
+ - @shipfox/api-integration-webhook@9.0.0
89
+ - @shipfox/api-auth-context@9.0.0
90
+ - @shipfox/api-workflows-dto@9.0.0
91
+ - @shipfox/config@1.2.2
92
+ - @shipfox/inter-module@0.2.0
93
+ - @shipfox/redact@0.2.3
94
+ - @shipfox/regex@0.2.2
95
+ - @shipfox/node-drizzle@0.3.2
96
+ - @shipfox/node-error-monitoring@0.2.0
97
+ - @shipfox/node-fastify@0.3.0
98
+ - @shipfox/node-module@0.5.0
99
+ - @shipfox/node-opentelemetry@0.6.0
100
+ - @shipfox/node-outbox@0.2.4
101
+ - @shipfox/node-postgres@0.4.2
102
+ - @shipfox/node-temporal@0.4.0
103
+
3
104
  ## 8.0.0
4
105
 
5
106
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import type { AgentToolCatalogEntry, AgentToolSelectionCatalog, IntegrationCapability, IntegrationProviderKind } from '@shipfox/api-integration-core-dto';
1
+ import type { AgentToolCatalogEntry, AgentToolSelectionCatalog, IntegrationCapability, IntegrationProviderKind } from '@shipfox/api-integration-spi';
2
2
  import type { IntegrationProviderRegistry } from '#core/providers/registry.js';
3
3
  export type AgentToolSelectionCatalogs = ReadonlyMap<IntegrationProviderKind, AgentToolSelectionCatalog>;
4
4
  export type AgentToolCatalogs = ReadonlyMap<IntegrationProviderKind, readonly AgentToolCatalogEntry[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-tool-selection.d.ts","sourceRoot":"","sources":["../../src/core/agent-tool-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,y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;AACF,MAAM,MAAM,iBAAiB,GAAG,WAAW,CACzC,uBAAuB,EACvB,SAAS,qBAAqB,EAAE,CACjC,CAAC;AAEF,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAC;IAC3C,QAAQ,CAAC,YAAY,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACzD;AAED,MAAM,MAAM,2BAA2B,GAAG,WAAW,CAAC,MAAM,EAAE,gCAAgC,CAAC,CAAC;AAChG,MAAM,MAAM,+BAA+B,GAAG,CAC5C,WAAW,EAAE,MAAM,KAChB,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAE1C,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,2BAA2B,GACpC,OAAO,CAAC,0BAA0B,CAAC,CAWrC;AAED,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,2BAA2B,GACpC,OAAO,CAAC,iBAAiB,CAAC,CAW5B;AAED,wBAAgB,uCAAuC,CACrD,QAAQ,EAAE,2BAA2B,GACpC,+BAA+B,CAkBjC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/agent-tool-selection.ts"],"sourcesContent":["import type {\n AgentToolCatalogEntry,\n AgentToolSelectionCatalog,\n IntegrationCapability,\n IntegrationProviderKind,\n} from '@shipfox/api-integration-core-dto';\nimport type {IntegrationProviderRegistry} from '#core/providers/registry.js';\nimport {listIntegrationConnections} from '#db/connections.js';\n\nexport type AgentToolSelectionCatalogs = ReadonlyMap<\n IntegrationProviderKind,\n AgentToolSelectionCatalog\n>;\nexport type AgentToolCatalogs = ReadonlyMap<\n IntegrationProviderKind,\n readonly AgentToolCatalogEntry[]\n>;\n\nexport interface WorkspaceConnectionSnapshotEntry {\n readonly id: string;\n readonly provider: IntegrationProviderKind;\n readonly capabilities: readonly IntegrationCapability[];\n}\n\nexport type WorkspaceConnectionSnapshot = ReadonlyMap<string, WorkspaceConnectionSnapshotEntry>;\nexport type LoadWorkspaceConnectionSnapshot = (\n workspaceId: string,\n) => Promise<WorkspaceConnectionSnapshot>;\n\nexport async function buildAgentToolSelectionCatalogs(\n registry: IntegrationProviderRegistry,\n): Promise<AgentToolSelectionCatalogs> {\n const entries = await Promise.all(\n registry.list('agent_tools').map(async (provider) => {\n const adapter = provider.adapters.agent_tools;\n if (adapter === undefined) {\n throw new Error(`Integration provider \"${provider.provider}\" has no agent tools adapter`);\n }\n return [provider.provider, await adapter.selectionCatalog()] as const;\n }),\n );\n return new Map(entries);\n}\n\nexport async function buildAgentToolCatalogs(\n registry: IntegrationProviderRegistry,\n): Promise<AgentToolCatalogs> {\n const entries = await Promise.all(\n registry.list('agent_tools').map(async (provider) => {\n const adapter = provider.adapters.agent_tools;\n if (adapter === undefined) {\n throw new Error(`Integration provider \"${provider.provider}\" has no agent tools adapter`);\n }\n return [provider.provider, await adapter.catalog()] as const;\n }),\n );\n return new Map(entries);\n}\n\nexport function createWorkspaceConnectionSnapshotLoader(\n registry: IntegrationProviderRegistry,\n): LoadWorkspaceConnectionSnapshot {\n const capabilitiesByProvider = new Map(\n registry.list().map((provider) => [provider.provider, provider.capabilities]),\n );\n\n return async (workspaceId) => {\n const connections = await listIntegrationConnections({workspaceId});\n return new Map(\n connections.map((connection) => [\n connection.slug,\n {\n id: connection.id,\n provider: connection.provider,\n capabilities: capabilitiesByProvider.get(connection.provider) ?? [],\n },\n ]),\n );\n };\n}\n"],"names":["listIntegrationConnections","buildAgentToolSelectionCatalogs","registry","entries","Promise","all","list","map","provider","adapter","adapters","agent_tools","undefined","Error","selectionCatalog","Map","buildAgentToolCatalogs","catalog","createWorkspaceConnectionSnapshotLoader","capabilitiesByProvider","capabilities","workspaceId","connections","connection","slug","id","get"],"mappings":"AAOA,SAAQA,0BAA0B,QAAO,qBAAqB;AAsB9D,OAAO,eAAeC,gCACpBC,QAAqC;IAErC,MAAMC,UAAU,MAAMC,QAAQC,GAAG,CAC/BH,SAASI,IAA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\n AgentToolSelectionCatalog,\n IntegrationCapability,\n IntegrationProviderKind,\n} from '@shipfox/api-integration-spi';\nimport type {IntegrationProviderRegistry} from '#core/providers/registry.js';\nimport {listIntegrationConnections} from '#db/connections.js';\n\nexport type AgentToolSelectionCatalogs = ReadonlyMap<\n IntegrationProviderKind,\n AgentToolSelectionCatalog\n>;\nexport type AgentToolCatalogs = ReadonlyMap<\n IntegrationProviderKind,\n readonly AgentToolCatalogEntry[]\n>;\n\nexport interface WorkspaceConnectionSnapshotEntry {\n readonly id: string;\n readonly provider: IntegrationProviderKind;\n readonly capabilities: readonly IntegrationCapability[];\n}\n\nexport type WorkspaceConnectionSnapshot = ReadonlyMap<string, WorkspaceConnectionSnapshotEntry>;\nexport type LoadWorkspaceConnectionSnapshot = (\n workspaceId: string,\n) => Promise<WorkspaceConnectionSnapshot>;\n\nexport async function buildAgentToolSelectionCatalogs(\n registry: IntegrationProviderRegistry,\n): Promise<AgentToolSelectionCatalogs> {\n const entries = await Promise.all(\n registry.list('agent_tools').map(async (provider) => {\n const adapter = provider.adapters.agent_tools;\n if (adapter === undefined) {\n throw new Error(`Integration provider \"${provider.provider}\" has no agent tools adapter`);\n }\n return [provider.provider, await adapter.selectionCatalog()] as const;\n }),\n );\n return new Map(entries);\n}\n\nexport async function buildAgentToolCatalogs(\n registry: IntegrationProviderRegistry,\n): Promise<AgentToolCatalogs> {\n const entries = await Promise.all(\n registry.list('agent_tools').map(async (provider) => {\n const adapter = provider.adapters.agent_tools;\n if (adapter === undefined) {\n throw new Error(`Integration provider \"${provider.provider}\" has no agent tools adapter`);\n }\n return [provider.provider, await adapter.catalog()] as const;\n }),\n );\n return new Map(entries);\n}\n\nexport function createWorkspaceConnectionSnapshotLoader(\n registry: IntegrationProviderRegistry,\n): LoadWorkspaceConnectionSnapshot {\n const capabilitiesByProvider = new Map(\n registry.list().map((provider) => [provider.provider, provider.capabilities]),\n );\n\n return async (workspaceId) => {\n const connections = await listIntegrationConnections({workspaceId});\n return new Map(\n connections.map((connection) => [\n connection.slug,\n {\n id: connection.id,\n provider: connection.provider,\n capabilities: capabilitiesByProvider.get(connection.provider) ?? [],\n },\n ]),\n );\n };\n}\n"],"names":["listIntegrationConnections","buildAgentToolSelectionCatalogs","registry","entries","Promise","all","list","map","provider","adapter","adapters","agent_tools","undefined","Error","selectionCatalog","Map","buildAgentToolCatalogs","catalog","createWorkspaceConnectionSnapshotLoader","capabilitiesByProvider","capabilities","workspaceId","connections","connection","slug","id","get"],"mappings":"AAOA,SAAQA,0BAA0B,QAAO,qBAAqB;AAsB9D,OAAO,eAAeC,gCACpBC,QAAqC;IAErC,MAAMC,UAAU,MAAMC,QAAQC,GAAG,CAC/BH,SAASI,IAAI,CAAC,eAAeC,GAAG,CAAC,OAAOC;QACtC,MAAMC,UAAUD,SAASE,QAAQ,CAACC,WAAW;QAC7C,IAAIF,YAAYG,WAAW;YACzB,MAAM,IAAIC,MAAM,CAAC,sBAAsB,EAAEL,SAASA,QAAQ,CAAC,4BAA4B,CAAC;QAC1F;QACA,OAAO;YAACA,SAASA,QAAQ;YAAE,MAAMC,QAAQK,gBAAgB;SAAG;IAC9D;IAEF,OAAO,IAAIC,IAAIZ;AACjB;AAEA,OAAO,eAAea,uBACpBd,QAAqC;IAErC,MAAMC,UAAU,MAAMC,QAAQC,GAAG,CAC/BH,SAASI,IAAI,CAAC,eAAeC,GAAG,CAAC,OAAOC;QACtC,MAAMC,UAAUD,SAASE,QAAQ,CAACC,WAAW;QAC7C,IAAIF,YAAYG,WAAW;YACzB,MAAM,IAAIC,MAAM,CAAC,sBAAsB,EAAEL,SAASA,QAAQ,CAAC,4BAA4B,CAAC;QAC1F;QACA,OAAO;YAACA,SAASA,QAAQ;YAAE,MAAMC,QAAQQ,OAAO;SAAG;IACrD;IAEF,OAAO,IAAIF,IAAIZ;AACjB;AAEA,OAAO,SAASe,wCACdhB,QAAqC;IAErC,MAAMiB,yBAAyB,IAAIJ,IACjCb,SAASI,IAAI,GAAGC,GAAG,CAAC,CAACC,WAAa;YAACA,SAASA,QAAQ;YAAEA,SAASY,YAAY;SAAC;IAG9E,OAAO,OAAOC;QACZ,MAAMC,cAAc,MAAMtB,2BAA2B;YAACqB;QAAW;QACjE,OAAO,IAAIN,IACTO,YAAYf,GAAG,CAAC,CAACgB,aAAe;gBAC9BA,WAAWC,IAAI;gBACf;oBACEC,IAAIF,WAAWE,EAAE;oBACjBjB,UAAUe,WAAWf,QAAQ;oBAC7BY,cAAcD,uBAAuBO,GAAG,CAACH,WAAWf,QAAQ,KAAK,EAAE;gBACrE;aACD;IAEL;AACF"}
@@ -1,2 +1,2 @@
1
- export type { IntegrationConnection, IntegrationConnectionLifecycleStatus, } from '@shipfox/api-integration-core-dto';
1
+ export type { IntegrationConnection, IntegrationConnectionLifecycleStatus, } from '@shipfox/api-integration-spi';
2
2
  //# sourceMappingURL=connection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/core/entities/connection.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,oCAAoC,GACrC,MAAM,mCAAmC,CAAC"}
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/core/entities/connection.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,oCAAoC,GACrC,MAAM,8BAA8B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/entities/connection.ts"],"sourcesContent":["export type {\n IntegrationConnection,\n IntegrationConnectionLifecycleStatus,\n} from '@shipfox/api-integration-core-dto';\n"],"names":[],"mappings":"AAAA,WAG2C"}
1
+ {"version":3,"sources":["../../../src/core/entities/connection.ts"],"sourcesContent":["export type {\n IntegrationConnection,\n IntegrationConnectionLifecycleStatus,\n} from '@shipfox/api-integration-spi';\n"],"names":[],"mappings":"AAAA,WAGsC"}
@@ -1,6 +1,6 @@
1
- import type { IntegrationProvider as CoreIntegrationProvider, RegisteredIntegrationProvider as CoreRegisteredIntegrationProvider, WebhookRequestProcessor, WebhookRouteId } from '@shipfox/api-integration-core-dto';
1
+ import type { IntegrationProvider as CoreIntegrationProvider, RegisteredIntegrationProvider as CoreRegisteredIntegrationProvider, WebhookRequestProcessor, WebhookRouteId } from '@shipfox/api-integration-spi';
2
2
  import type { RouteExport } from '@shipfox/node-fastify';
3
- export type { AgentToolCallInput, AgentToolCatalogEntry, AgentToolJsonSchema, AgentToolSensitivity, AgentToolSession, AgentToolsProvider, IntegrationCapability, IntegrationProviderAdapters, IntegrationProviderKind, OpenAgentToolsSessionInput, } from '@shipfox/api-integration-core-dto';
3
+ export type { AgentToolCallInput, AgentToolCatalogEntry, AgentToolJsonSchema, AgentToolSensitivity, AgentToolSession, AgentToolsProvider, IntegrationCapability, IntegrationProviderAdapters, IntegrationProviderKind, OpenAgentToolsSessionInput, } from '@shipfox/api-integration-spi';
4
4
  export type IntegrationProvider = CoreIntegrationProvider<string, RouteExport> & {
5
5
  webhookProcessors?: Array<{
6
6
  routeIds: readonly WebhookRouteId[];
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/core/entities/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,IAAI,uBAAuB,EAC9C,6BAA6B,IAAI,iCAAiC,EAClE,uBAAuB,EACvB,cAAc,EACf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAC;AAEvD,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAE3C,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG;IAC/E,iBAAiB,CAAC,EACd,KAAK,CAAC;QAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;QAAC,SAAS,EAAE,uBAAuB,CAAA;KAAC,CAAC,GAChF,SAAS,CAAC;CACf,CAAC;AACF,MAAM,MAAM,6BAA6B,GAAG,iCAAiC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/core/entities/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,IAAI,uBAAuB,EAC9C,6BAA6B,IAAI,iCAAiC,EAClE,uBAAuB,EACvB,cAAc,EACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAC;AAEvD,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,8BAA8B,CAAC;AAEtC,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG;IAC/E,iBAAiB,CAAC,EACd,KAAK,CAAC;QAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;QAAC,SAAS,EAAE,uBAAuB,CAAA;KAAC,CAAC,GAChF,SAAS,CAAC;CACf,CAAC;AACF,MAAM,MAAM,6BAA6B,GAAG,iCAAiC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/entities/provider.ts"],"sourcesContent":["import type {\n IntegrationProvider as CoreIntegrationProvider,\n RegisteredIntegrationProvider as CoreRegisteredIntegrationProvider,\n WebhookRequestProcessor,\n WebhookRouteId,\n} from '@shipfox/api-integration-core-dto';\nimport type {RouteExport} from '@shipfox/node-fastify';\n\nexport type {\n AgentToolCallInput,\n AgentToolCatalogEntry,\n AgentToolJsonSchema,\n AgentToolSensitivity,\n AgentToolSession,\n AgentToolsProvider,\n IntegrationCapability,\n IntegrationProviderAdapters,\n IntegrationProviderKind,\n OpenAgentToolsSessionInput,\n} from '@shipfox/api-integration-core-dto';\n\nexport type IntegrationProvider = CoreIntegrationProvider<string, RouteExport> & {\n webhookProcessors?:\n | Array<{routeIds: readonly WebhookRouteId[]; processor: WebhookRequestProcessor}>\n | undefined;\n};\nexport type RegisteredIntegrationProvider = CoreRegisteredIntegrationProvider<string, RouteExport>;\n"],"names":[],"mappings":"AA0BA,WAAmG"}
1
+ {"version":3,"sources":["../../../src/core/entities/provider.ts"],"sourcesContent":["import type {\n IntegrationProvider as CoreIntegrationProvider,\n RegisteredIntegrationProvider as CoreRegisteredIntegrationProvider,\n WebhookRequestProcessor,\n WebhookRouteId,\n} from '@shipfox/api-integration-spi';\nimport type {RouteExport} from '@shipfox/node-fastify';\n\nexport type {\n AgentToolCallInput,\n AgentToolCatalogEntry,\n AgentToolJsonSchema,\n AgentToolSensitivity,\n AgentToolSession,\n AgentToolsProvider,\n IntegrationCapability,\n IntegrationProviderAdapters,\n IntegrationProviderKind,\n OpenAgentToolsSessionInput,\n} from '@shipfox/api-integration-spi';\n\nexport type IntegrationProvider = CoreIntegrationProvider<string, RouteExport> & {\n webhookProcessors?:\n | Array<{routeIds: readonly WebhookRouteId[]; processor: WebhookRequestProcessor}>\n | undefined;\n};\nexport type RegisteredIntegrationProvider = CoreRegisteredIntegrationProvider<string, RouteExport>;\n"],"names":[],"mappings":"AA0BA,WAAmG"}
@@ -1,4 +1,4 @@
1
- import { ConnectionSlugConflictError, IntegrationProviderError, type IntegrationProviderErrorReason } from '@shipfox/api-integration-core-dto';
1
+ import { ConnectionSlugConflictError, IntegrationProviderError, type IntegrationProviderErrorReason } from '@shipfox/api-integration-spi';
2
2
  import type { IntegrationCapability, IntegrationProviderKind } from '#core/entities/provider.js';
3
3
  export declare class IntegrationConnectionNotFoundError extends Error {
4
4
  constructor(connectionId: string);
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,KAAK,8BAA8B,EACpC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAC,qBAAqB,EAAE,uBAAuB,EAAC,MAAM,4BAA4B,CAAC;AAE/F,qBAAa,kCAAmC,SAAQ,KAAK;gBAC/C,YAAY,EAAE,MAAM;CAGjC;AAED,qBAAa,kCAAmC,SAAQ,KAAK;gBAC/C,YAAY,EAAE,MAAM;CAGjC;AAED,qBAAa,2CAA4C,SAAQ,KAAK;gBACxD,YAAY,EAAE,MAAM;CAGjC;AAED,qBAAa,uCAAwC,SAAQ,KAAK;aAE9C,WAAW,EAAE,MAAM;aACnB,QAAQ,EAAE,uBAAuB;aACjC,iBAAiB,EAAE,MAAM;gBAFzB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,uBAAuB,EACjC,iBAAiB,EAAE,MAAM;CAK5C;AAED,qBAAa,qCAAsC,SAAQ,KAAK;aAE5C,UAAU,EAAE,qBAAqB;aACjC,QAAQ,EAAE,uBAAuB;gBADjC,UAAU,EAAE,qBAAqB,EACjC,QAAQ,EAAE,uBAAuB;CAIpD;AAED,qBAAa,mCAAoC,SAAQ,KAAK;aAChC,QAAQ,EAAE,uBAAuB;gBAAjC,QAAQ,EAAE,uBAAuB;CAG9D;AAED,qBAAa,mCAAoC,SAAQ,KAAK;aAChC,QAAQ,EAAE,uBAAuB;gBAAjC,QAAQ,EAAE,uBAAuB;CAG9D;AAED,qBAAa,kCAAmC,SAAQ,KAAK;aAC/B,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;CAI5C;AAED,OAAO,EAAC,2BAA2B,EAAE,wBAAwB,EAAE,KAAK,8BAA8B,EAAC,CAAC"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,KAAK,8BAA8B,EACpC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAC,qBAAqB,EAAE,uBAAuB,EAAC,MAAM,4BAA4B,CAAC;AAE/F,qBAAa,kCAAmC,SAAQ,KAAK;gBAC/C,YAAY,EAAE,MAAM;CAGjC;AAED,qBAAa,kCAAmC,SAAQ,KAAK;gBAC/C,YAAY,EAAE,MAAM;CAGjC;AAED,qBAAa,2CAA4C,SAAQ,KAAK;gBACxD,YAAY,EAAE,MAAM;CAGjC;AAED,qBAAa,uCAAwC,SAAQ,KAAK;aAE9C,WAAW,EAAE,MAAM;aACnB,QAAQ,EAAE,uBAAuB;aACjC,iBAAiB,EAAE,MAAM;gBAFzB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,uBAAuB,EACjC,iBAAiB,EAAE,MAAM;CAK5C;AAED,qBAAa,qCAAsC,SAAQ,KAAK;aAE5C,UAAU,EAAE,qBAAqB;aACjC,QAAQ,EAAE,uBAAuB;gBADjC,UAAU,EAAE,qBAAqB,EACjC,QAAQ,EAAE,uBAAuB;CAIpD;AAED,qBAAa,mCAAoC,SAAQ,KAAK;aAChC,QAAQ,EAAE,uBAAuB;gBAAjC,QAAQ,EAAE,uBAAuB;CAG9D;AAED,qBAAa,mCAAoC,SAAQ,KAAK;aAChC,QAAQ,EAAE,uBAAuB;gBAAjC,QAAQ,EAAE,uBAAuB;CAG9D;AAED,qBAAa,kCAAmC,SAAQ,KAAK;aAC/B,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;CAI5C;AAED,OAAO,EAAC,2BAA2B,EAAE,wBAAwB,EAAE,KAAK,8BAA8B,EAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ConnectionSlugConflictError, IntegrationProviderError } from '@shipfox/api-integration-core-dto';
1
+ import { ConnectionSlugConflictError, IntegrationProviderError } from '@shipfox/api-integration-spi';
2
2
  export class IntegrationConnectionNotFoundError extends Error {
3
3
  constructor(connectionId){
4
4
  super(`Integration connection not found: ${connectionId}`);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/errors.ts"],"sourcesContent":["import {\n ConnectionSlugConflictError,\n IntegrationProviderError,\n type IntegrationProviderErrorReason,\n} from '@shipfox/api-integration-core-dto';\nimport type {IntegrationCapability, IntegrationProviderKind} from '#core/entities/provider.js';\n\nexport class IntegrationConnectionNotFoundError extends Error {\n constructor(connectionId: string) {\n super(`Integration connection not found: ${connectionId}`);\n }\n}\n\nexport class IntegrationConnectionInactiveError extends Error {\n constructor(connectionId: string) {\n super(`Integration connection is not active: ${connectionId}`);\n }\n}\n\nexport class IntegrationConnectionWorkspaceMismatchError extends Error {\n constructor(connectionId: string) {\n super(`Integration connection does not belong to the requested workspace: ${connectionId}`);\n }\n}\n\nexport class IntegrationConnectionAlreadyExistsError extends Error {\n constructor(\n public readonly workspaceId: string,\n public readonly provider: IntegrationProviderKind,\n public readonly externalAccountId: string,\n ) {\n super(`Integration connection already exists: ${workspaceId}/${provider}/${externalAccountId}`);\n this.name = 'IntegrationConnectionAlreadyExistsError';\n }\n}\n\nexport class IntegrationCapabilityUnavailableError extends Error {\n constructor(\n public readonly capability: IntegrationCapability,\n public readonly provider: IntegrationProviderKind,\n ) {\n super(`Integration provider ${provider} does not expose ${capability}`);\n }\n}\n\nexport class IntegrationCheckoutUnsupportedError extends Error {\n constructor(public readonly provider: IntegrationProviderKind) {\n super(`Integration provider ${provider} cannot create a checkout spec`);\n }\n}\n\nexport class IntegrationProviderUnavailableError extends Error {\n constructor(public readonly provider: IntegrationProviderKind) {\n super(`No integration provider registered for ${provider}`);\n }\n}\n\nexport class WebhookProcessorNotConfiguredError extends Error {\n constructor(public readonly routeId: string) {\n super(`No webhook processor is configured for ${routeId}`);\n this.name = 'WebhookProcessorNotConfiguredError';\n }\n}\n\nexport {ConnectionSlugConflictError, IntegrationProviderError, type IntegrationProviderErrorReason};\n"],"names":["ConnectionSlugConflictError","IntegrationProviderError","IntegrationConnectionNotFoundError","Error","connectionId","IntegrationConnectionInactiveError","IntegrationConnectionWorkspaceMismatchError","IntegrationConnectionAlreadyExistsError","workspaceId","provider","externalAccountId","name","IntegrationCapabilityUnavailableError","capability","IntegrationCheckoutUnsupportedError","IntegrationProviderUnavailableError","WebhookProcessorNotConfiguredError","routeId"],"mappings":"AAAA,SACEA,2BAA2B,EAC3BC,wBAAwB,QAEnB,oCAAoC;AAG3C,OAAO,MAAMC,2CAA2CC;IACtD,YAAYC,YAAoB,CAAE;QAChC,KAAK,CAAC,CAAC,kCAAkC,EAAEA,cAAc;IAC3D;AACF;AAEA,OAAO,MAAMC,2CAA2CF;IACtD,YAAYC,YAAoB,CAAE;QAChC,KAAK,CAAC,CAAC,sCAAsC,EAAEA,cAAc;IAC/D;AACF;AAEA,OAAO,MAAME,oDAAoDH;IAC/D,YAAYC,YAAoB,CAAE;QAChC,KAAK,CAAC,CAAC,mEAAmE,EAAEA,cAAc;IAC5F;AACF;AAEA,OAAO,MAAMG,gDAAgDJ;IAC3D,YACE,AAAgBK,WAAmB,EACnC,AAAgBC,QAAiC,EACjD,AAAgBC,iBAAyB,CACzC;QACA,KAAK,CAAC,CAAC,uCAAuC,EAAEF,YAAY,CAAC,EAAEC,SAAS,CAAC,EAAEC,mBAAmB,QAJ9EF,cAAAA,kBACAC,WAAAA,eACAC,oBAAAA;QAGhB,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMC,8CAA8CT;IACzD,YACE,AAAgBU,UAAiC,EACjD,AAAgBJ,QAAiC,CACjD;QACA,KAAK,CAAC,CAAC,qBAAqB,EAAEA,SAAS,iBAAiB,EAAEI,YAAY,QAHtDA,aAAAA,iBACAJ,WAAAA;IAGlB;AACF;AAEA,OAAO,MAAMK,4CAA4CX;IACvD,YAAY,AAAgBM,QAAiC,CAAE;QAC7D,KAAK,CAAC,CAAC,qBAAqB,EAAEA,SAAS,8BAA8B,CAAC,QAD5CA,WAAAA;IAE5B;AACF;AAEA,OAAO,MAAMM,4CAA4CZ;IACvD,YAAY,AAAgBM,QAAiC,CAAE;QAC7D,KAAK,CAAC,CAAC,uCAAuC,EAAEA,UAAU,QADhCA,WAAAA;IAE5B;AACF;AAEA,OAAO,MAAMO,2CAA2Cb;IACtD,YAAY,AAAgBc,OAAe,CAAE;QAC3C,KAAK,CAAC,CAAC,uCAAuC,EAAEA,SAAS,QAD/BA,UAAAA;QAE1B,IAAI,CAACN,IAAI,GAAG;IACd;AACF;AAEA,SAAQX,2BAA2B,EAAEC,wBAAwB,GAAuC"}
1
+ {"version":3,"sources":["../../src/core/errors.ts"],"sourcesContent":["import {\n ConnectionSlugConflictError,\n IntegrationProviderError,\n type IntegrationProviderErrorReason,\n} from '@shipfox/api-integration-spi';\nimport type {IntegrationCapability, IntegrationProviderKind} from '#core/entities/provider.js';\n\nexport class IntegrationConnectionNotFoundError extends Error {\n constructor(connectionId: string) {\n super(`Integration connection not found: ${connectionId}`);\n }\n}\n\nexport class IntegrationConnectionInactiveError extends Error {\n constructor(connectionId: string) {\n super(`Integration connection is not active: ${connectionId}`);\n }\n}\n\nexport class IntegrationConnectionWorkspaceMismatchError extends Error {\n constructor(connectionId: string) {\n super(`Integration connection does not belong to the requested workspace: ${connectionId}`);\n }\n}\n\nexport class IntegrationConnectionAlreadyExistsError extends Error {\n constructor(\n public readonly workspaceId: string,\n public readonly provider: IntegrationProviderKind,\n public readonly externalAccountId: string,\n ) {\n super(`Integration connection already exists: ${workspaceId}/${provider}/${externalAccountId}`);\n this.name = 'IntegrationConnectionAlreadyExistsError';\n }\n}\n\nexport class IntegrationCapabilityUnavailableError extends Error {\n constructor(\n public readonly capability: IntegrationCapability,\n public readonly provider: IntegrationProviderKind,\n ) {\n super(`Integration provider ${provider} does not expose ${capability}`);\n }\n}\n\nexport class IntegrationCheckoutUnsupportedError extends Error {\n constructor(public readonly provider: IntegrationProviderKind) {\n super(`Integration provider ${provider} cannot create a checkout spec`);\n }\n}\n\nexport class IntegrationProviderUnavailableError extends Error {\n constructor(public readonly provider: IntegrationProviderKind) {\n super(`No integration provider registered for ${provider}`);\n }\n}\n\nexport class WebhookProcessorNotConfiguredError extends Error {\n constructor(public readonly routeId: string) {\n super(`No webhook processor is configured for ${routeId}`);\n this.name = 'WebhookProcessorNotConfiguredError';\n }\n}\n\nexport {ConnectionSlugConflictError, IntegrationProviderError, type IntegrationProviderErrorReason};\n"],"names":["ConnectionSlugConflictError","IntegrationProviderError","IntegrationConnectionNotFoundError","Error","connectionId","IntegrationConnectionInactiveError","IntegrationConnectionWorkspaceMismatchError","IntegrationConnectionAlreadyExistsError","workspaceId","provider","externalAccountId","name","IntegrationCapabilityUnavailableError","capability","IntegrationCheckoutUnsupportedError","IntegrationProviderUnavailableError","WebhookProcessorNotConfiguredError","routeId"],"mappings":"AAAA,SACEA,2BAA2B,EAC3BC,wBAAwB,QAEnB,+BAA+B;AAGtC,OAAO,MAAMC,2CAA2CC;IACtD,YAAYC,YAAoB,CAAE;QAChC,KAAK,CAAC,CAAC,kCAAkC,EAAEA,cAAc;IAC3D;AACF;AAEA,OAAO,MAAMC,2CAA2CF;IACtD,YAAYC,YAAoB,CAAE;QAChC,KAAK,CAAC,CAAC,sCAAsC,EAAEA,cAAc;IAC/D;AACF;AAEA,OAAO,MAAME,oDAAoDH;IAC/D,YAAYC,YAAoB,CAAE;QAChC,KAAK,CAAC,CAAC,mEAAmE,EAAEA,cAAc;IAC5F;AACF;AAEA,OAAO,MAAMG,gDAAgDJ;IAC3D,YACE,AAAgBK,WAAmB,EACnC,AAAgBC,QAAiC,EACjD,AAAgBC,iBAAyB,CACzC;QACA,KAAK,CAAC,CAAC,uCAAuC,EAAEF,YAAY,CAAC,EAAEC,SAAS,CAAC,EAAEC,mBAAmB,QAJ9EF,cAAAA,kBACAC,WAAAA,eACAC,oBAAAA;QAGhB,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMC,8CAA8CT;IACzD,YACE,AAAgBU,UAAiC,EACjD,AAAgBJ,QAAiC,CACjD;QACA,KAAK,CAAC,CAAC,qBAAqB,EAAEA,SAAS,iBAAiB,EAAEI,YAAY,QAHtDA,aAAAA,iBACAJ,WAAAA;IAGlB;AACF;AAEA,OAAO,MAAMK,4CAA4CX;IACvD,YAAY,AAAgBM,QAAiC,CAAE;QAC7D,KAAK,CAAC,CAAC,qBAAqB,EAAEA,SAAS,8BAA8B,CAAC,QAD5CA,WAAAA;IAE5B;AACF;AAEA,OAAO,MAAMM,4CAA4CZ;IACvD,YAAY,AAAgBM,QAAiC,CAAE;QAC7D,KAAK,CAAC,CAAC,uCAAuC,EAAEA,UAAU,QADhCA,WAAAA;IAE5B;AACF;AAEA,OAAO,MAAMO,2CAA2Cb;IACtD,YAAY,AAAgBc,OAAe,CAAE;QAC3C,KAAK,CAAC,CAAC,uCAAuC,EAAEA,SAAS,QAD/BA,UAAAA;QAE1B,IAAI,CAACN,IAAI,GAAG;IACd;AACF;AAEA,SAAQX,2BAA2B,EAAEC,wBAAwB,GAAuC"}
@@ -1,2 +1,2 @@
1
- export type { AgentToolCallInput, AgentToolCatalogEntry, AgentToolCatalogMethod, AgentToolJsonSchema, AgentToolSensitivity, AgentToolSession, AgentToolsProvider, OpenAgentToolsSessionInput, } from '@shipfox/api-integration-core-dto';
1
+ export type { AgentToolCallInput, AgentToolCatalogEntry, AgentToolCatalogMethod, AgentToolJsonSchema, AgentToolSensitivity, AgentToolSession, AgentToolsProvider, OpenAgentToolsSessionInput, } from '@shipfox/api-integration-spi';
2
2
  //# sourceMappingURL=agent-tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-tools.d.ts","sourceRoot":"","sources":["../../../src/core/providers/agent-tools.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC"}
1
+ {"version":3,"file":"agent-tools.d.ts","sourceRoot":"","sources":["../../../src/core/providers/agent-tools.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,8BAA8B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/providers/agent-tools.ts"],"sourcesContent":["export type {\n AgentToolCallInput,\n AgentToolCatalogEntry,\n AgentToolCatalogMethod,\n AgentToolJsonSchema,\n AgentToolSensitivity,\n AgentToolSession,\n AgentToolsProvider,\n OpenAgentToolsSessionInput,\n} from '@shipfox/api-integration-core-dto';\n"],"names":[],"mappings":"AAAA,WAS2C"}
1
+ {"version":3,"sources":["../../../src/core/providers/agent-tools.ts"],"sourcesContent":["export type {\n AgentToolCallInput,\n AgentToolCatalogEntry,\n AgentToolCatalogMethod,\n AgentToolJsonSchema,\n AgentToolSensitivity,\n AgentToolSession,\n AgentToolsProvider,\n OpenAgentToolsSessionInput,\n} from '@shipfox/api-integration-spi';\n"],"names":[],"mappings":"AAAA,WASsC"}
@@ -1,4 +1,4 @@
1
- import type { CheckoutSpec } from '@shipfox/api-integration-core-dto';
1
+ import type { CheckoutSpec } from '@shipfox/api-integration-spi';
2
2
  /**
3
3
  * Returns a copy of `spec` that is safe to log: the credential token is masked
4
4
  * and any userinfo a provider mistakenly left in `repositoryUrl` is stripped.
@@ -1 +1 @@
1
- {"version":3,"file":"redact-checkout-spec.d.ts","sourceRoot":"","sources":["../../../src/core/providers/redact-checkout-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAGpE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,CAUnE"}
1
+ {"version":3,"file":"redact-checkout-spec.d.ts","sourceRoot":"","sources":["../../../src/core/providers/redact-checkout-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAG/D;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,CAUnE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/providers/redact-checkout-spec.ts"],"sourcesContent":["import type {CheckoutSpec} from '@shipfox/api-integration-core-dto';\nimport {REDACTION_PLACEHOLDER, stripUrlCredentials} from '@shipfox/redact';\n\n/**\n * Returns a copy of `spec` that is safe to log: the credential token is masked\n * and any userinfo a provider mistakenly left in `repositoryUrl` is stripped.\n * Returns the original spec unchanged when it has no credentials and the URL is\n * already clean.\n */\nexport function redactCheckoutSpec(spec: CheckoutSpec): CheckoutSpec {\n const repositoryUrl = stripUrlCredentials(spec.repositoryUrl);\n if (!spec.credentials) {\n return repositoryUrl === spec.repositoryUrl ? spec : {...spec, repositoryUrl};\n }\n return {\n ...spec,\n repositoryUrl,\n credentials: {...spec.credentials, token: REDACTION_PLACEHOLDER},\n };\n}\n"],"names":["REDACTION_PLACEHOLDER","stripUrlCredentials","redactCheckoutSpec","spec","repositoryUrl","credentials","token"],"mappings":"AACA,SAAQA,qBAAqB,EAAEC,mBAAmB,QAAO,kBAAkB;AAE3E;;;;;CAKC,GACD,OAAO,SAASC,mBAAmBC,IAAkB;IACnD,MAAMC,gBAAgBH,oBAAoBE,KAAKC,aAAa;IAC5D,IAAI,CAACD,KAAKE,WAAW,EAAE;QACrB,OAAOD,kBAAkBD,KAAKC,aAAa,GAAGD,OAAO;YAAC,GAAGA,IAAI;YAAEC;QAAa;IAC9E;IACA,OAAO;QACL,GAAGD,IAAI;QACPC;QACAC,aAAa;YAAC,GAAGF,KAAKE,WAAW;YAAEC,OAAON;QAAqB;IACjE;AACF"}
1
+ {"version":3,"sources":["../../../src/core/providers/redact-checkout-spec.ts"],"sourcesContent":["import type {CheckoutSpec} from '@shipfox/api-integration-spi';\nimport {REDACTION_PLACEHOLDER, stripUrlCredentials} from '@shipfox/redact';\n\n/**\n * Returns a copy of `spec` that is safe to log: the credential token is masked\n * and any userinfo a provider mistakenly left in `repositoryUrl` is stripped.\n * Returns the original spec unchanged when it has no credentials and the URL is\n * already clean.\n */\nexport function redactCheckoutSpec(spec: CheckoutSpec): CheckoutSpec {\n const repositoryUrl = stripUrlCredentials(spec.repositoryUrl);\n if (!spec.credentials) {\n return repositoryUrl === spec.repositoryUrl ? spec : {...spec, repositoryUrl};\n }\n return {\n ...spec,\n repositoryUrl,\n credentials: {...spec.credentials, token: REDACTION_PLACEHOLDER},\n };\n}\n"],"names":["REDACTION_PLACEHOLDER","stripUrlCredentials","redactCheckoutSpec","spec","repositoryUrl","credentials","token"],"mappings":"AACA,SAAQA,qBAAqB,EAAEC,mBAAmB,QAAO,kBAAkB;AAE3E;;;;;CAKC,GACD,OAAO,SAASC,mBAAmBC,IAAkB;IACnD,MAAMC,gBAAgBH,oBAAoBE,KAAKC,aAAa;IAC5D,IAAI,CAACD,KAAKE,WAAW,EAAE;QACrB,OAAOD,kBAAkBD,KAAKC,aAAa,GAAGD,OAAO;YAAC,GAAGA,IAAI;YAAEC;QAAa;IAC9E;IACA,OAAO;QACL,GAAGD,IAAI;QACPC;QACAC,aAAa;YAAC,GAAGF,KAAKE,WAAW;YAAEC,OAAON;QAAqB;IACjE;AACF"}
@@ -1,2 +1,2 @@
1
- export type { CheckoutCredentials, CheckoutPermissions, CheckoutSpec, CreateCheckoutSpecInput, FetchFileInput, FileEntry, FilePage, FileSnapshot, ListFilesInput, ListRepositoriesInput, RepositoryPage, RepositorySnapshot, RepositoryVisibility, ResolveRepositoryInput, SourceControlProvider, } from '@shipfox/api-integration-core-dto';
1
+ export type { CheckoutCredentials, CheckoutPermissions, CheckoutSpec, CreateCheckoutSpecInput, FetchFileInput, FileEntry, FilePage, FileSnapshot, ListFilesInput, ListRepositoriesInput, RepositoryPage, RepositorySnapshot, RepositoryVisibility, ResolveRepositoryInput, SourceControlProvider, } from '@shipfox/api-integration-spi';
2
2
  //# sourceMappingURL=source-control.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"source-control.d.ts","sourceRoot":"","sources":["../../../src/core/providers/source-control.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,uBAAuB,EACvB,cAAc,EACd,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,mCAAmC,CAAC"}
1
+ {"version":3,"file":"source-control.d.ts","sourceRoot":"","sources":["../../../src/core/providers/source-control.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,uBAAuB,EACvB,cAAc,EACd,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,8BAA8B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/providers/source-control.ts"],"sourcesContent":["export type {\n CheckoutCredentials,\n CheckoutPermissions,\n CheckoutSpec,\n CreateCheckoutSpecInput,\n FetchFileInput,\n FileEntry,\n FilePage,\n FileSnapshot,\n ListFilesInput,\n ListRepositoriesInput,\n RepositoryPage,\n RepositorySnapshot,\n RepositoryVisibility,\n ResolveRepositoryInput,\n SourceControlProvider,\n} from '@shipfox/api-integration-core-dto';\n"],"names":[],"mappings":"AAAA,WAgB2C"}
1
+ {"version":3,"sources":["../../../src/core/providers/source-control.ts"],"sourcesContent":["export type {\n CheckoutCredentials,\n CheckoutPermissions,\n CheckoutSpec,\n CreateCheckoutSpecInput,\n FetchFileInput,\n FileEntry,\n FilePage,\n FileSnapshot,\n ListFilesInput,\n ListRepositoriesInput,\n RepositoryPage,\n RepositorySnapshot,\n RepositoryVisibility,\n ResolveRepositoryInput,\n SourceControlProvider,\n} from '@shipfox/api-integration-spi';\n"],"names":[],"mappings":"AAAA,WAgBsC"}
@@ -1 +1 @@
1
- {"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../src/db/connections.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,qBAAqB,EACrB,oCAAoC,EACrC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,4BAA4B,CAAC;AAExE,OAAO,EAAC,EAAE,EAAC,MAAM,SAAS,CAAC;AAG3B,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;AAC3C,KAAK,aAAa,GAAG,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhF,MAAM,WAAW,iCAAiC;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,oCAAoC,GAAG,SAAS,CAAC;CACpE;AAED,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,iCAAiC,EACzC,OAAO,GAAE;IAAC,EAAE,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS,CAAA;CAAM,GAC7D,OAAO,CAAC,qBAAqB,CAAC,CA6BhC;AAED,MAAM,WAAW,iCAAiC;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,oCAAoC,GAAG,SAAS,CAAC;C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AAE,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS,CAAA;CAAM,GAC7D,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAU5C;AAED,MAAM,MAAM,8BAA8B,GAAG,OAAO,4BAA4B,CAAC;AAEjF,MAAM,WAAW,gDAAgD;IAC/D,EAAE,EAAE,MAAM,CAAC;IACX,eAAe,EAAE,oCAAoC,CAAC;CACvD;AAED,wBAAsB,0CAA0C,CAC9D,MAAM,EAAE,gDAAgD,EACxD,OAAO,GAAE;IAAC,EAAE,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS,CAAA;CAAM,GAC7D,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAS5C;AAED,MAAM,MAAM,4CAA4C,GACtD,OAAO,0CAA0C,CAAC;AAEpD,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE;IAAC,EAAE,EAAE,MAAM,CAAA;CAAC,EACpB,OAAO,GAAE;IAAC,EAAE,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS,CAAA;CAAM,GAC7D,OAAO,CAAC,OAAO,CAAC,CAMlB;AAED,MAAM,MAAM,6BAA6B,GAAG,OAAO,2BAA2B,CAAC;AAE/E,MAAM,WAAW,gCAAgC;IAC/C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,gCAAgC,GACvC,OAAO,CAAC,qBAAqB,EAAE,CAAC,CASlC;AAED,MAAM,WAAW,0CAA0C;IACzD,QAAQ,EAAE,uBAAuB,CAAC;CACnC;AAED,wBAAsB,oCAAoC,CACxD,MAAM,EAAE,0CAA0C,GACjD,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAQlC"}
@@ -1,4 +1,5 @@
1
- import { CONNECTION_SLUG_MAX_LENGTH, ConnectionSlugConflictError } 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';
2
3
  import { and, eq } from 'drizzle-orm';
3
4
  import { IntegrationConnectionAlreadyExistsError } from '#core/errors.js';
4
5
  import { db } from './db.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/db/connections.ts"],"sourcesContent":["import {\n CONNECTION_SLUG_MAX_LENGTH,\n ConnectionSlugConflictError,\n} from '@shipfox/api-integration-core-dto';\nimport {and, eq} from 'drizzle-orm';\nimport type {\n IntegrationConnection,\n IntegrationConnectionLifecycleStatus,\n} from '#core/entities/connection.js';\nimport type {IntegrationProviderKind} from '#core/entities/provider.js';\nimport {IntegrationConnectionAlreadyExistsError} from '#core/errors.js';\nimport {db} from './db.js';\nimport {integrationConnections, toIntegrationConnection} from './schema/connections.js';\n\ntype IntegrationDb = ReturnType<typeof db>;\ntype IntegrationTx = Parameters<Parameters<IntegrationDb['transaction']>[0]>[0];\n\nexport interface UpsertIntegrationConnectionParams {\n workspaceId: string;\n provider: IntegrationProviderKind;\n externalAccountId: string;\n slug: string;\n displayName: string;\n lifecycleStatus?: IntegrationConnectionLifecycleStatus | undefined;\n}\n\nexport async function upsertIntegrationConnection(\n params: UpsertIntegrationConnectionParams,\n options: {tx?: IntegrationDb | IntegrationTx | undefined} = {},\n): Promise<IntegrationConnection> {\n const executor = options.tx ?? db();\n const now = new Date();\n const [row] = await executor\n .insert(integrationConnections)\n .values({\n workspaceId: params.workspaceId,\n provider: params.provider,\n externalAccountId: params.externalAccountId,\n slug: params.slug,\n displayName: params.displayName,\n lifecycleStatus: params.lifecycleStatus ?? 'active',\n })\n .onConflictDoUpdate({\n target: [\n integrationConnections.workspaceId,\n integrationConnections.provider,\n integrationConnections.externalAccountId,\n ],\n set: {\n displayName: params.displayName,\n lifecycleStatus: params.lifecycleStatus ?? 'active',\n updatedAt: now,\n },\n })\n .returning();\n\n if (!row) throw new Error('Integration connection upsert returned no rows');\n return toIntegrationConnection(row);\n}\n\nexport interface CreateIntegrationConnectionParams {\n workspaceId: string;\n provider: IntegrationProviderKind;\n externalAccountId: string;\n slug: string;\n displayName: string;\n lifecycleStatus?: IntegrationConnectionLifecycleStatus | undefined;\n}\n\nconst INTEGRATION_CONNECTION_EXTERNAL_UNIQUE_CONSTRAINT =\n 'integrations_connections_workspace_external_unique';\nconst INTEGRATION_CONNECTION_SLUG_UNIQUE_CONSTRAINT =\n 'integrations_connections_workspace_slug_unique';\n\nexport function isIntegrationConnectionUniqueViolation(error: unknown): boolean {\n let current: unknown = error;\n for (let depth = 0; depth < 5 && current != null; depth += 1) {\n if (typeof current !== 'object') return false;\n const {code, constraint} = current as {code?: unknown; constraint?: unknown};\n if (code === '23505' && constraint === INTEGRATION_CONNECTION_EXTERNAL_UNIQUE_CONSTRAINT) {\n return true;\n }\n current = (current as {cause?: unknown}).cause;\n }\n return false;\n}\n\nexport function isIntegrationConnectionSlugUniqueViolation(error: unknown): boolean {\n let current: unknown = error;\n for (let depth = 0; depth < 5 && current != null; depth += 1) {\n if (typeof current !== 'object') return false;\n const {code, constraint} = current as {code?: unknown; constraint?: unknown};\n if (code === '23505' && constraint === INTEGRATION_CONNECTION_SLUG_UNIQUE_CONSTRAINT) {\n return true;\n }\n current = (current as {cause?: unknown}).cause;\n }\n return false;\n}\n\nexport async function createIntegrationConnection(\n params: CreateIntegrationConnectionParams,\n options: {tx?: IntegrationDb | IntegrationTx | undefined} = {},\n): Promise<IntegrationConnection> {\n const executor = options.tx ?? db();\n let rows: (typeof integrationConnections.$inferSelect)[];\n try {\n rows = await executor\n .insert(integrationConnections)\n .values({\n workspaceId: params.workspaceId,\n provider: params.provider,\n externalAccountId: params.externalAccountId,\n slug: params.slug,\n displayName: params.displayName,\n lifecycleStatus: params.lifecycleStatus ?? 'active',\n })\n .returning();\n } catch (error) {\n if (isIntegrationConnectionUniqueViolation(error)) {\n throw new IntegrationConnectionAlreadyExistsError(\n params.workspaceId,\n params.provider,\n params.externalAccountId,\n );\n }\n if (isIntegrationConnectionSlugUniqueViolation(error)) {\n throw new ConnectionSlugConflictError(error);\n }\n throw error;\n }\n\n const row = rows[0];\n if (!row) throw new Error('Integration connection insert returned no rows');\n return toIntegrationConnection(row);\n}\n\nexport interface ResolveUniqueConnectionSlugParams {\n workspaceId: string;\n provider: IntegrationProviderKind;\n externalAccountId: string;\n baseSlug: string;\n}\n\nexport async function resolveUniqueConnectionSlug(\n params: ResolveUniqueConnectionSlugParams,\n options: {tx?: IntegrationDb | IntegrationTx | undefined} = {},\n): Promise<string> {\n const executor = options.tx ?? db();\n const [existing] = await executor\n .select({slug: integrationConnections.slug})\n .from(integrationConnections)\n .where(\n and(\n eq(integrationConnections.workspaceId, params.workspaceId),\n eq(integrationConnections.provider, params.provider),\n eq(integrationConnections.externalAccountId, params.externalAccountId),\n ),\n )\n .limit(1);\n if (existing) return existing.slug;\n\n const workspaceSlugs = await executor\n .select({slug: integrationConnections.slug})\n .from(integrationConnections)\n .where(eq(integrationConnections.workspaceId, params.workspaceId));\n const used = new Set(workspaceSlugs.map((row) => row.slug));\n\n for (let suffixNumber = 1; ; suffixNumber += 1) {\n const suffix = suffixNumber === 1 ? '' : `_${suffixNumber}`;\n const baseBudget = CONNECTION_SLUG_MAX_LENGTH - suffix.length;\n const candidate = `${params.baseSlug.slice(0, baseBudget).replaceAll(/[_-]+$/g, '')}${suffix}`;\n if (!used.has(candidate)) return candidate;\n }\n}\n\nexport type CreateIntegrationConnectionFn = typeof createIntegrationConnection;\n\nexport async function getIntegrationConnectionById(\n id: string,\n options: {tx?: IntegrationDb | IntegrationTx | undefined} = {},\n): Promise<IntegrationConnection | undefined> {\n const executor = options.tx ?? db();\n const rows = await executor\n .select()\n .from(integrationConnections)\n .where(eq(integrationConnections.id, id))\n .limit(1);\n const row = rows[0];\n if (!row) return undefined;\n return toIntegrationConnection(row);\n}\n\nexport type GetIntegrationConnectionByIdFn = typeof getIntegrationConnectionById;\n\nexport interface UpdateIntegrationConnectionLifecycleStatusParams {\n id: string;\n lifecycleStatus: IntegrationConnectionLifecycleStatus;\n}\n\nexport async function updateIntegrationConnectionLifecycleStatus(\n params: UpdateIntegrationConnectionLifecycleStatusParams,\n options: {tx?: IntegrationDb | IntegrationTx | undefined} = {},\n): Promise<IntegrationConnection | undefined> {\n const executor = options.tx ?? db();\n const [row] = await executor\n .update(integrationConnections)\n .set({lifecycleStatus: params.lifecycleStatus, updatedAt: new Date()})\n .where(eq(integrationConnections.id, params.id))\n .returning();\n if (!row) return undefined;\n return toIntegrationConnection(row);\n}\n\nexport type UpdateIntegrationConnectionLifecycleStatusFn =\n typeof updateIntegrationConnectionLifecycleStatus;\n\nexport async function deleteIntegrationConnection(\n params: {id: string},\n options: {tx?: IntegrationDb | IntegrationTx | undefined} = {},\n): Promise<boolean> {\n const executor = options.tx ?? db();\n const result = await executor\n .delete(integrationConnections)\n .where(eq(integrationConnections.id, params.id));\n return (result.rowCount ?? 0) > 0;\n}\n\nexport type DeleteIntegrationConnectionFn = typeof deleteIntegrationConnection;\n\nexport interface ListIntegrationConnectionsParams {\n workspaceId: string;\n}\n\nexport async function listIntegrationConnections(\n params: ListIntegrationConnectionsParams,\n): Promise<IntegrationConnection[]> {\n const rows = await db()\n .select()\n .from(integrationConnections)\n .where(eq(integrationConnections.workspaceId, params.workspaceId))\n .orderBy(integrationConnections.createdAt, integrationConnections.id);\n\n const connections = rows.map(toIntegrationConnection);\n return connections;\n}\n\nexport interface ListIntegrationConnectionsByProviderParams {\n provider: IntegrationProviderKind;\n}\n\nexport async function listIntegrationConnectionsByProvider(\n params: ListIntegrationConnectionsByProviderParams,\n): Promise<IntegrationConnection[]> {\n const rows = await db()\n .select()\n .from(integrationConnections)\n .where(eq(integrationConnections.provider, params.provider))\n .orderBy(integrationConnections.createdAt, integrationConnections.id);\n\n return rows.map(toIntegrationConnection);\n}\n"],"names":["CONNECTION_SLUG_MAX_LENGTH","ConnectionSlugConflictError","and","eq","IntegrationConnectionAlreadyExistsError","db","integrationConnections","toIntegrationConnection","upsertIntegrationConnection","params","options","executor","tx","now","Date","row","insert","values","workspaceId","provider","externalAccountId","slug","displayName","lifecycleStatus","onConflictDoUpdate","target","set","updatedAt","returning","Error","INTEGRATION_CONNECTION_EXTERNAL_UNIQUE_CONSTRAINT","INTEGRATION_CONNECTION_SLUG_UNIQUE_CONSTRAINT","isIntegrationConnectionUniqueViolation","error","current","depth","code","constraint","cause","isIntegrationConnectionSlugUniqueViolation","createIntegrationConnection","rows","resolveUniqueConnectionSlug","existing","select","from","where","limit","workspaceSlugs","used","Set","map","suffixNumber","suffix","baseBudget","length","candidate","baseSlug","slice","replaceAll","has","getIntegrationConnectionById","id","undefined","updateIntegrationConnectionLifecycleStatus","update","deleteIntegrationConnection","result","delete","rowCount","listIntegrationConnections","orderBy","createdAt","connections","listIntegrationConnectionsByProvider"],"mappings":"AAAA,SACEA,0BAA0B,EAC1BC,2BAA2B,QACtB,oCAAoC;AAC3C,SAAQC,GAAG,EAAEC,EAAE,QAAO,cAAc;AAMpC,SAAQC,uCAAuC,QAAO,kBAAkB;AACxE,SAAQC,EAAE,QAAO,UAAU;AAC3B,SAAQC,sBAAsB,EAAEC,uBAAuB,QAAO,0BAA0B;AAcxF,OAAO,eAAeC,4BACpBC,MAAyC,EACzCC,UAA4D,CAAC,CAAC;IAE9D,MAAMC,WAAWD,QAAQE,EAAE,IAAIP;IAC/B,MAAMQ,MAAM,IAAIC;IAChB,MAAM,CAACC,IAAI,GAAG,MAAMJ,SACjBK,MAAM,CAACV,wBACPW,MAAM,CAAC;QACNC,aAAaT,OAAOS,WAAW;QAC/BC,UAAUV,OAAOU,QAAQ;QACzBC,mBAAmBX,OAAOW,iBAAiB;QAC3CC,MAAMZ,OAAOY,IAAI;QACjBC,aAAab,OAAOa,WAAW;QAC/BC,iBAAiBd,OAAOc,eAAe,IAAI;IAC7C,GACCC,kBAAkB,CAAC;QAClBC,QAAQ;YACNnB,uBAAuBY,WAAW;YAClCZ,uBAAuBa,QAAQ;YAC/Bb,uBAAuBc,iBAAiB;SACzC;QACDM,KAA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AK;AAClC;AAQA,OAAO,eAAeC,2BACpB7D,MAAwC;IAExC,MAAMgC,OAAO,MAAMpC,KAChBuC,MAAM,GACNC,IAAI,CAACvC,wBACLwC,KAAK,CAAC3C,GAAGG,uBAAuBY,WAAW,EAAET,OAAOS,WAAW,GAC/DqD,OAAO,CAACjE,uBAAuBkE,SAAS,EAAElE,uBAAuBwD,EAAE;IAEtE,MAAMW,cAAchC,KAAKU,GAAG,CAAC5C;IAC7B,OAAOkE;AACT;AAMA,OAAO,eAAeC,qCACpBjE,MAAkD;IAElD,MAAMgC,OAAO,MAAMpC,KAChBuC,MAAM,GACNC,IAAI,CAACvC,wBACLwC,KAAK,CAAC3C,GAAGG,uBAAuBa,QAAQ,EAAEV,OAAOU,QAAQ,GACzDoD,OAAO,CAACjE,uBAAuBkE,SAAS,EAAElE,uBAAuBwD,EAAE;IAEtE,OAAOrB,KAAKU,GAAG,CAAC5C;AAClB"}
1
+ {"version":3,"sources":["../../src/db/connections.ts"],"sourcesContent":["import {CONNECTION_SLUG_MAX_LENGTH} from '@shipfox/api-integration-core-dto';\nimport {ConnectionSlugConflictError} from '@shipfox/api-integration-spi';\nimport {and, eq} from 'drizzle-orm';\nimport type {\n IntegrationConnection,\n IntegrationConnectionLifecycleStatus,\n} from '#core/entities/connection.js';\nimport type {IntegrationProviderKind} from '#core/entities/provider.js';\nimport {IntegrationConnectionAlreadyExistsError} from '#core/errors.js';\nimport {db} from './db.js';\nimport {integrationConnections, toIntegrationConnection} from './schema/connections.js';\n\ntype IntegrationDb = ReturnType<typeof db>;\ntype IntegrationTx = Parameters<Parameters<IntegrationDb['transaction']>[0]>[0];\n\nexport interface UpsertIntegrationConnectionParams {\n workspaceId: string;\n provider: IntegrationProviderKind;\n externalAccountId: string;\n slug: string;\n displayName: string;\n lifecycleStatus?: IntegrationConnectionLifecycleStatus | undefined;\n}\n\nexport async function upsertIntegrationConnection(\n params: UpsertIntegrationConnectionParams,\n options: {tx?: IntegrationDb | IntegrationTx | undefined} = {},\n): Promise<IntegrationConnection> {\n const executor = options.tx ?? db();\n const now = new Date();\n const [row] = await executor\n .insert(integrationConnections)\n .values({\n workspaceId: params.workspaceId,\n provider: params.provider,\n externalAccountId: params.externalAccountId,\n slug: params.slug,\n displayName: params.displayName,\n lifecycleStatus: params.lifecycleStatus ?? 'active',\n })\n .onConflictDoUpdate({\n target: [\n integrationConnections.workspaceId,\n integrationConnections.provider,\n integrationConnections.externalAccountId,\n ],\n set: {\n displayName: params.displayName,\n lifecycleStatus: params.lifecycleStatus ?? 'active',\n updatedAt: now,\n },\n })\n .returning();\n\n if (!row) throw new Error('Integration connection upsert returned no rows');\n return toIntegrationConnection(row);\n}\n\nexport interface CreateIntegrationConnectionParams {\n workspaceId: string;\n provider: IntegrationProviderKind;\n externalAccountId: string;\n slug: string;\n displayName: string;\n lifecycleStatus?: IntegrationConnectionLifecycleStatus | undefined;\n}\n\nconst INTEGRATION_CONNECTION_EXTERNAL_UNIQUE_CONSTRAINT =\n 'integrations_connections_workspace_external_unique';\nconst INTEGRATION_CONNECTION_SLUG_UNIQUE_CONSTRAINT =\n 'integrations_connections_workspace_slug_unique';\n\nexport function isIntegrationConnectionUniqueViolation(error: unknown): boolean {\n let current: unknown = error;\n for (let depth = 0; depth < 5 && current != null; depth += 1) {\n if (typeof current !== 'object') return false;\n const {code, constraint} = current as {code?: unknown; constraint?: unknown};\n if (code === '23505' && constraint === INTEGRATION_CONNECTION_EXTERNAL_UNIQUE_CONSTRAINT) {\n return true;\n }\n current = (current as {cause?: unknown}).cause;\n }\n return false;\n}\n\nexport function isIntegrationConnectionSlugUniqueViolation(error: unknown): boolean {\n let current: unknown = error;\n for (let depth = 0; depth < 5 && current != null; depth += 1) {\n if (typeof current !== 'object') return false;\n const {code, constraint} = current as {code?: unknown; constraint?: unknown};\n if (code === '23505' && constraint === INTEGRATION_CONNECTION_SLUG_UNIQUE_CONSTRAINT) {\n return true;\n }\n current = (current as {cause?: unknown}).cause;\n }\n return false;\n}\n\nexport async function createIntegrationConnection(\n params: CreateIntegrationConnectionParams,\n options: {tx?: IntegrationDb | IntegrationTx | undefined} = {},\n): Promise<IntegrationConnection> {\n const executor = options.tx ?? db();\n let rows: (typeof integrationConnections.$inferSelect)[];\n try {\n rows = await executor\n .insert(integrationConnections)\n .values({\n workspaceId: params.workspaceId,\n provider: params.provider,\n externalAccountId: params.externalAccountId,\n slug: params.slug,\n displayName: params.displayName,\n lifecycleStatus: params.lifecycleStatus ?? 'active',\n })\n .returning();\n } catch (error) {\n if (isIntegrationConnectionUniqueViolation(error)) {\n throw new IntegrationConnectionAlreadyExistsError(\n params.workspaceId,\n params.provider,\n params.externalAccountId,\n );\n }\n if (isIntegrationConnectionSlugUniqueViolation(error)) {\n throw new ConnectionSlugConflictError(error);\n }\n throw error;\n }\n\n const row = rows[0];\n if (!row) throw new Error('Integration connection insert returned no rows');\n return toIntegrationConnection(row);\n}\n\nexport interface ResolveUniqueConnectionSlugParams {\n workspaceId: string;\n provider: IntegrationProviderKind;\n externalAccountId: string;\n baseSlug: string;\n}\n\nexport async function resolveUniqueConnectionSlug(\n params: ResolveUniqueConnectionSlugParams,\n options: {tx?: IntegrationDb | IntegrationTx | undefined} = {},\n): Promise<string> {\n const executor = options.tx ?? db();\n const [existing] = await executor\n .select({slug: integrationConnections.slug})\n .from(integrationConnections)\n .where(\n and(\n eq(integrationConnections.workspaceId, params.workspaceId),\n eq(integrationConnections.provider, params.provider),\n eq(integrationConnections.externalAccountId, params.externalAccountId),\n ),\n )\n .limit(1);\n if (existing) return existing.slug;\n\n const workspaceSlugs = await executor\n .select({slug: integrationConnections.slug})\n .from(integrationConnections)\n .where(eq(integrationConnections.workspaceId, params.workspaceId));\n const used = new Set(workspaceSlugs.map((row) => row.slug));\n\n for (let suffixNumber = 1; ; suffixNumber += 1) {\n const suffix = suffixNumber === 1 ? '' : `_${suffixNumber}`;\n const baseBudget = CONNECTION_SLUG_MAX_LENGTH - suffix.length;\n const candidate = `${params.baseSlug.slice(0, baseBudget).replaceAll(/[_-]+$/g, '')}${suffix}`;\n if (!used.has(candidate)) return candidate;\n }\n}\n\nexport type CreateIntegrationConnectionFn = typeof createIntegrationConnection;\n\nexport async function getIntegrationConnectionById(\n id: string,\n options: {tx?: IntegrationDb | IntegrationTx | undefined} = {},\n): Promise<IntegrationConnection | undefined> {\n const executor = options.tx ?? db();\n const rows = await executor\n .select()\n .from(integrationConnections)\n .where(eq(integrationConnections.id, id))\n .limit(1);\n const row = rows[0];\n if (!row) return undefined;\n return toIntegrationConnection(row);\n}\n\nexport type GetIntegrationConnectionByIdFn = typeof getIntegrationConnectionById;\n\nexport interface UpdateIntegrationConnectionLifecycleStatusParams {\n id: string;\n lifecycleStatus: IntegrationConnectionLifecycleStatus;\n}\n\nexport async function updateIntegrationConnectionLifecycleStatus(\n params: UpdateIntegrationConnectionLifecycleStatusParams,\n options: {tx?: IntegrationDb | IntegrationTx | undefined} = {},\n): Promise<IntegrationConnection | undefined> {\n const executor = options.tx ?? db();\n const [row] = await executor\n .update(integrationConnections)\n .set({lifecycleStatus: params.lifecycleStatus, updatedAt: new Date()})\n .where(eq(integrationConnections.id, params.id))\n .returning();\n if (!row) return undefined;\n return toIntegrationConnection(row);\n}\n\nexport type UpdateIntegrationConnectionLifecycleStatusFn =\n typeof updateIntegrationConnectionLifecycleStatus;\n\nexport async function deleteIntegrationConnection(\n params: {id: string},\n options: {tx?: IntegrationDb | IntegrationTx | undefined} = {},\n): Promise<boolean> {\n const executor = options.tx ?? db();\n const result = await executor\n .delete(integrationConnections)\n .where(eq(integrationConnections.id, params.id));\n return (result.rowCount ?? 0) > 0;\n}\n\nexport type DeleteIntegrationConnectionFn = typeof deleteIntegrationConnection;\n\nexport interface ListIntegrationConnectionsParams {\n workspaceId: string;\n}\n\nexport async function listIntegrationConnections(\n params: ListIntegrationConnectionsParams,\n): Promise<IntegrationConnection[]> {\n const rows = await db()\n .select()\n .from(integrationConnections)\n .where(eq(integrationConnections.workspaceId, params.workspaceId))\n .orderBy(integrationConnections.createdAt, integrationConnections.id);\n\n const connections = rows.map(toIntegrationConnection);\n return connections;\n}\n\nexport interface ListIntegrationConnectionsByProviderParams {\n provider: IntegrationProviderKind;\n}\n\nexport async function listIntegrationConnectionsByProvider(\n params: ListIntegrationConnectionsByProviderParams,\n): Promise<IntegrationConnection[]> {\n const rows = await db()\n .select()\n .from(integrationConnections)\n .where(eq(integrationConnections.provider, params.provider))\n .orderBy(integrationConnections.createdAt, integrationConnections.id);\n\n return rows.map(toIntegrationConnection);\n}\n"],"names":["CONNECTION_SLUG_MAX_LENGTH","ConnectionSlugConflictError","and","eq","IntegrationConnectionAlreadyExistsError","db","integrationConnections","toIntegrationConnection","upsertIntegrationConnection","params","options","executor","tx","now","Date","row","insert","values","workspaceId","provider","externalAccountId","slug","displayName","lifecycleStatus","onConflictDoUpdate","target","set","updatedAt","returning","Error","INTEGRATION_CONNECTION_EXTERNAL_UNIQUE_CONSTRAINT","INTEGRATION_CONNECTION_SLUG_UNIQUE_CONSTRAINT","isIntegrationConnectionUniqueViolation","error","current","depth","code","constraint","cause","isIntegrationConnectionSlugUniqueViolation","createIntegrationConnection","rows","resolveUniqueConnectionSlug","existing","select","from","where","limit","workspaceSlugs","used","Set","map","suffixNumber","suffix","baseBudget","length","candidate","baseSlug","slice","replaceAll","has","getIntegrationConnectionById","id","undefined","updateIntegrationConnectionLifecycleStatus","update","deleteIntegrationConnection","result","delete","rowCount","listIntegrationConnections","orderBy","createdAt","connections","listIntegrationConnectionsByProvider"],"mappings":"AAAA,SAAQA,0BAA0B,QAAO,oCAAoC;AAC7E,SAAQC,2BAA2B,QAAO,+BAA+B;AACzE,SAAQC,GAAG,EAAEC,EAAE,QAAO,cAAc;AAMpC,SAAQC,uCAAuC,QAAO,kBAAkB;AACxE,SAAQC,EAAE,QAAO,UAAU;AAC3B,SAAQC,sBAAsB,EAAEC,uBAAuB,QAAO,0BAA0B;AAcxF,OAAO,eAAeC,4BACpBC,MAAyC,EACzCC,UAA4D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,iBAAiBd,OAAOc,eAAe;QAAEI,WAAW,IAAIb;IAAM,GACnEgC,KAAK,CAAC3C,GAAGG,uBAAuBwD,EAAE,EAAErD,OAAOqD,EAAE,GAC7ClC,SAAS;IACZ,IAAI,CAACb,KAAK,OAAOgD;IACjB,OAAOxD,wBAAwBQ;AACjC;AAKA,OAAO,eAAemD,4BACpBzD,MAAoB,EACpBC,UAA4D,CAAC,CAAC;IAE9D,MAAMC,WAAWD,QAAQE,EAAE,IAAIP;IAC/B,MAAM8D,SAAS,MAAMxD,SAClByD,MAAM,CAAC9D,wBACPwC,KAAK,CAAC3C,GAAGG,uBAAuBwD,EAAE,EAAErD,OAAOqD,EAAE;IAChD,OAAO,AAACK,CAAAA,OAAOE,QAAQ,IAAI,CAAA,IAAK;AAClC;AAQA,OAAO,eAAeC,2BACpB7D,MAAwC;IAExC,MAAMgC,OAAO,MAAMpC,KAChBuC,MAAM,GACNC,IAAI,CAACvC,wBACLwC,KAAK,CAAC3C,GAAGG,uBAAuBY,WAAW,EAAET,OAAOS,WAAW,GAC/DqD,OAAO,CAACjE,uBAAuBkE,SAAS,EAAElE,uBAAuBwD,EAAE;IAEtE,MAAMW,cAAchC,KAAKU,GAAG,CAAC5C;IAC7B,OAAOkE;AACT;AAMA,OAAO,eAAeC,qCACpBjE,MAAkD;IAElD,MAAMgC,OAAO,MAAMpC,KAChBuC,MAAM,GACNC,IAAI,CAACvC,wBACLwC,KAAK,CAAC3C,GAAGG,uBAAuBa,QAAQ,EAAEV,OAAOU,QAAQ,GACzDoD,OAAO,CAACjE,uBAAuBkE,SAAS,EAAElE,uBAAuBwD,EAAE;IAEtE,OAAOrB,KAAKU,GAAG,CAAC5C;AAClB"}
@@ -1,4 +1,4 @@
1
- import { type IntegrationEventReceivedEvent, type SourcePushPayload } from '@shipfox/api-integration-core-dto';
1
+ import { type IntegrationEventReceivedEvent, type SourcePushPayload } from '@shipfox/api-integration-spi';
2
2
  import { db } from './db.js';
3
3
  type IntegrationDb = ReturnType<typeof db>;
4
4
  type IntegrationTx = Parameters<Parameters<IntegrationDb['transaction']>[0]>[0];
@@ -1 +1 @@
1
- {"version":3,"file":"webhook-deliveries.d.ts","sourceRoot":"","sources":["../../src/db/webhook-deliveries.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,6BAA6B,EAElC,KAAK,iBAAiB,EACvB,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAAC,EAAE,EAAC,MAAM,SAAS,CAAC;AAI3B,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;AAC3C,KAAK,aAAa,GAAG,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChF,KAAK,QAAQ,GAAG,aAAa,GAAG,aAAa,CAAC;AAe9C,MAAM,WAAW,qCAAqC;IACpD,EAAE,EAAE,QAAQ,CAAC;IACb,KAAK,EAAE,6BAA6B,CAAC;CACtC;AAED,MAAM,WAAW,qCAAqC;IACpD,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,qCAAqC,GAC5C,OAAO,CAAC,qCAAqC,CAAC,CAyBhD;AAED,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,aAAa,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAOD,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAC,CAAC,CAgD/B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AAyB,CAC7C,MAAM,EAAE,+BAA+B,GACtC,OAAO,CAAC,IAAI,CAAC,CAYf;AAED,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,QAAQ,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAC,CAAC,CAiB7B;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAExF;AAED,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC,CAK5B;AAED,MAAM,MAAM,iCAAiC,GAAG,OAAO,+BAA+B,CAAC;AACvF,MAAM,MAAM,mBAAmB,GAAG,OAAO,iBAAiB,CAAC;AAC3D,MAAM,MAAM,2BAA2B,GAAG,OAAO,yBAAyB,CAAC;AAC3E,MAAM,MAAM,sBAAsB,GAAG,OAAO,oBAAoB,CAAC;AACjE,MAAM,MAAM,oBAAoB,GAAG,OAAO,kBAAkB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { INTEGRATION_EVENT_RECEIVED, INTEGRATION_SOURCE_COMMIT_PUSHED } from '@shipfox/api-integration-core-dto';
1
+ import { INTEGRATION_EVENT_RECEIVED, INTEGRATION_SOURCE_COMMIT_PUSHED } from '@shipfox/api-integration-spi';
2
2
  import { writeOutboxEvent, writeOutboxEvents } from '@shipfox/node-outbox';
3
3
  import { lt } from 'drizzle-orm';
4
4
  import { db } from './db.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/db/webhook-deliveries.ts"],"sourcesContent":["import {\n INTEGRATION_EVENT_RECEIVED,\n INTEGRATION_SOURCE_COMMIT_PUSHED,\n type IntegrationEventReceivedEvent,\n type IntegrationsEventMap,\n type SourcePushPayload,\n} from '@shipfox/api-integration-core-dto';\nimport {writeOutboxEvent, writeOutboxEvents} from '@shipfox/node-outbox';\nimport {lt} from 'drizzle-orm';\nimport {db} from './db.js';\nimport {integrationsOutbox} from './schema/outbox.js';\nimport {integrationsWebhookDeliveries} from './schema/webhook-deliveries.js';\n\ntype IntegrationDb = ReturnType<typeof db>;\ntype IntegrationTx = Parameters<Parameters<IntegrationDb['transaction']>[0]>[0];\ntype Executor = IntegrationDb | IntegrationTx;\n\nfunction connectionDedupScope(connectionId: string): string {\n return `connection:${connectionId}`;\n}\n\nfunction providerDedupScope(provider: string): string {\n return `provider:${provider}`;\n}\n\nfunction receivedEventDedupScope(event: IntegrationEventReceivedEvent): string {\n if (event.provider === 'webhook') return connectionDedupScope(event.connectionId);\n return providerDedupScope(event.provider);\n}\n\nexport interface PublishIntegrationEventReceivedParams {\n tx: Executor;\n event: IntegrationEventReceivedEvent;\n}\n\nexport interface PublishIntegrationEventReceivedResult {\n published: boolean;\n}\n\nexport async function publishIntegrationEventReceived(\n params: PublishIntegrationEventReceivedParams,\n): Promise<PublishIntegrationEventReceivedResult> {\n const inserted = await params.tx\n .insert(integrationsWebhookDeliveries)\n .values({\n provider: params.event.provider,\n dedupScope: receivedEventDedupScope(params.event),\n deliveryId: params.event.deliveryId,\n })\n .onConflictDoNothing({\n target: [\n integrationsWebhookDeliveries.provider,\n integrationsWebhookDeliveries.dedupScope,\n integrationsWebhookDeliveries.deliveryId,\n ],\n })\n .returning({deliveryId: integrationsWebhookDeliveries.deliveryId});\n\n if (inserted.length === 0) return {published: false};\n\n await writeOutboxEvent(params.tx, integrationsOutbox, {\n type: INTEGRATION_EVENT_RECEIVED,\n payload: params.event,\n });\n\n return {published: true};\n}\n\nexport interface PublishSourcePushParams {\n tx: IntegrationTx;\n provider: string;\n source: string;\n workspaceId: string;\n connectionId: string;\n connectionName: string;\n deliveryId: string;\n receivedAt: string;\n rawPayload: unknown;\n push: SourcePushPayload;\n}\n\n// Emits a single source-control push as two outbox rows: the generic\n// `INTEGRATION_EVENT_RECEIVED` envelope with the raw provider payload for triggers, and the\n// typed `INTEGRATION_SOURCE_COMMIT_PUSHED` event for domain modules. One delivery-dedup gates\n// both, so a redelivered webhook writes nothing. Requires a transaction: the dedup insert and\n// both outbox rows must commit or roll back together.\nexport async function publishSourcePush(\n params: PublishSourcePushParams,\n): Promise<{published: boolean}> {\n const inserted = await params.tx\n .insert(integrationsWebhookDeliveries)\n .values({\n provider: params.provider,\n dedupScope: providerDedupScope(params.provider),\n deliveryId: params.deliveryId,\n })\n .onConflictDoNothing({\n target: [\n integrationsWebhookDeliveries.provider,\n integrationsWebhookDeliveries.dedupScope,\n integrationsWebhookDeliveries.deliveryId,\n ],\n })\n .returning({deliveryId: integrationsWebhookDeliveries.deliveryId});\n\n if (inserted.length === 0) return {published: false};\n\n await writeOutboxEvents<IntegrationsEventMap>(params.tx, integrationsOutbox, [\n {\n type: INTEGRATION_EVENT_RECEIVED,\n payload: {\n provider: params.provider,\n source: params.source,\n event: 'push',\n workspaceId: params.workspaceId,\n connectionId: params.connectionId,\n connectionName: params.connectionName,\n deliveryId: params.deliveryId,\n receivedAt: params.receivedAt,\n payload: params.rawPayload,\n },\n },\n {\n type: INTEGRATION_SOURCE_COMMIT_PUSHED,\n payload: {\n provider: params.provider,\n workspaceId: params.workspaceId,\n connectionId: params.connectionId,\n deliveryId: params.deliveryId,\n receivedAt: params.receivedAt,\n push: params.push,\n },\n },\n ]);\n\n return {published: true};\n}\n\nexport interface PublishSourceCommitPushedParams {\n provider: string;\n workspaceId: string;\n connectionId: string;\n deliveryId: string;\n receivedAt: string;\n push: SourcePushPayload;\n}\n\n// Emits ONLY the typed `INTEGRATION_SOURCE_COMMIT_PUSHED` event, intentionally skipping the\n// `INTEGRATION_EVENT_RECEIVED` envelope so triggers do not run workflows, and skipping the\n// delivery-dedup row so it is never suppressed. Used to force a definitions re-sync without\n// simulating an inbound webhook.\nexport async function publishSourceCommitPushed(\n params: PublishSourceCommitPushedParams,\n): Promise<void> {\n await writeOutboxEvent<IntegrationsEventMap>(db(), integrationsOutbox, {\n type: INTEGRATION_SOURCE_COMMIT_PUSHED,\n payload: {\n provider: params.provider,\n workspaceId: params.workspaceId,\n connectionId: params.connectionId,\n deliveryId: params.deliveryId,\n receivedAt: params.receivedAt,\n push: params.push,\n },\n });\n}\n\nexport interface RecordDeliveryOnlyParams {\n tx: Executor;\n provider: string;\n deliveryId: string;\n}\n\nexport async function claimWebhookDelivery(\n params: RecordDeliveryOnlyParams,\n): Promise<{claimed: boolean}> {\n const inserted = await params.tx\n .insert(integrationsWebhookDeliveries)\n .values({\n provider: params.provider,\n dedupScope: providerDedupScope(params.provider),\n deliveryId: params.deliveryId,\n })\n .onConflictDoNothing({\n target: [\n integrationsWebhookDeliveries.provider,\n integrationsWebhookDeliveries.dedupScope,\n integrationsWebhookDeliveries.deliveryId,\n ],\n })\n .returning({deliveryId: integrationsWebhookDeliveries.deliveryId});\n return {claimed: inserted.length > 0};\n}\n\nexport async function recordDeliveryOnly(params: RecordDeliveryOnlyParams): Promise<void> {\n await claimWebhookDelivery(params);\n}\n\nexport interface PruneWebhookDeliveriesParams {\n olderThan: Date;\n}\n\nexport async function pruneWebhookDeliveries(\n params: PruneWebhookDeliveriesParams,\n): Promise<{deleted: number}> {\n const result = await db()\n .delete(integrationsWebhookDeliveries)\n .where(lt(integrationsWebhookDeliveries.receivedAt, params.olderThan));\n return {deleted: result.rowCount ?? 0};\n}\n\nexport type PublishIntegrationEventReceivedFn = typeof publishIntegrationEventReceived;\nexport type PublishSourcePushFn = typeof publishSourcePush;\nexport type PublishSourceCommitPushedFn = typeof publishSourceCommitPushed;\nexport type ClaimWebhookDeliveryFn = typeof claimWebhookDelivery;\nexport type RecordDeliveryOnlyFn = typeof recordDeliveryOnly;\n"],"names":["INTEGRATION_EVENT_RECEIVED","INTEGRATION_SOURCE_COMMIT_PUSHED","writeOutboxEvent","writeOutboxEvents","lt","db","integrationsOutbox","integrationsWebhookDeliveries","connectionDedupScope","connectionId","providerDedupScope","provider","receivedEventDedupScope","event","publishIntegrationEventReceived","params","inserted","tx","insert","values","dedupScope","deliveryId","onConflictDoNothing","target","returning","length","published","type","payload","publishSourcePush","source","workspaceId","connectionName","receivedAt","rawPayload","push","publishSourceCommitPushed","claimWebhookDelivery","claimed","recordDeliveryOnly","pruneWebhookDeliveries","result","delete","where","olderThan","deleted","rowCount"],"mappings":"AAAA,SACEA,0BAA0B,EAC1BC,gCAAgC,QAI3B,oCAAoC;AAC3C,SAAQC,gBAAgB,EAAEC,iBAAiB,QAAO,uBAAuB;AACzE,SAAQC,EAAE,QAAO,cAAc;AAC/B,SAAQC,EAAE,QAAO,UAAU;AAC3B,SAAQC,kBAAkB,QAAO,qBAAqB;AACtD,SAAQC,6BAA6B,QAAO,iCAAiC;AAM7E,SAASC,qBAAqBC,YAAoB;IAChD,OAAO,CAAC,WAAW,EAAEA,cAAc;AACrC;AAEA,SAASC,mBAAmBC,QAAgB;IAC1C,OAAO,CAAC,SAAS,EAAEA,UAAU;AAC/B;AAEA,SAASC,wBAAwBC,KAAoC;IACnE,IAAIA,MAAMF,QAAQ,KAAK,WAAW,OAAOH,qBAAqBK,MAAMJ,YAAY;IAChF,OAAOC,mBAAmBG,MAAMF,QAAQ;AAC1C;AAWA,OAAO,eAAeG,gCACpBC,MAA6C;IAE7C,MAAMC,WAAW,MAAMD,OAAOE,EAAE,CAC7BC,MAAM,CAACX,+BACPY,MAAM,CAAC;QACNR,UAAUI,OAAOF,KAAK,CAACF,QAAQ;QAC/BS,YAAYR,wBAAwBG,OAAOF,KAAK;QAChDQ,YAAYN,OAAOF,KAAK,CAACQ,UAAU;IACrC,GACCC,mBAAmB,CAAC;QACnBC,QAAQ;YACNhB,8BAA8BI,QAAQ;YACtCJ,8BAA8Ba,UAAU;YACxCb,8BAA8Bc,UAAU;SACzC;IACH,G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OAAO;QAACC,SAASJ,OAAOK,QAAQ,IAAI;IAAC;AACvC"}
1
+ {"version":3,"sources":["../../src/db/webhook-deliveries.ts"],"sourcesContent":["import {\n INTEGRATION_EVENT_RECEIVED,\n INTEGRATION_SOURCE_COMMIT_PUSHED,\n type IntegrationEventReceivedEvent,\n type IntegrationsEventMap,\n type SourcePushPayload,\n} from '@shipfox/api-integration-spi';\nimport {writeOutboxEvent, writeOutboxEvents} from '@shipfox/node-outbox';\nimport {lt} from 'drizzle-orm';\nimport {db} from './db.js';\nimport {integrationsOutbox} from './schema/outbox.js';\nimport {integrationsWebhookDeliveries} from './schema/webhook-deliveries.js';\n\ntype IntegrationDb = ReturnType<typeof db>;\ntype IntegrationTx = Parameters<Parameters<IntegrationDb['transaction']>[0]>[0];\ntype Executor = IntegrationDb | IntegrationTx;\n\nfunction connectionDedupScope(connectionId: string): string {\n return `connection:${connectionId}`;\n}\n\nfunction providerDedupScope(provider: string): string {\n return `provider:${provider}`;\n}\n\nfunction receivedEventDedupScope(event: IntegrationEventReceivedEvent): string {\n if (event.provider === 'webhook') return connectionDedupScope(event.connectionId);\n return providerDedupScope(event.provider);\n}\n\nexport interface PublishIntegrationEventReceivedParams {\n tx: Executor;\n event: IntegrationEventReceivedEvent;\n}\n\nexport interface PublishIntegrationEventReceivedResult {\n published: boolean;\n}\n\nexport async function publishIntegrationEventReceived(\n params: PublishIntegrationEventReceivedParams,\n): Promise<PublishIntegrationEventReceivedResult> {\n const inserted = await params.tx\n .insert(integrationsWebhookDeliveries)\n .values({\n provider: params.event.provider,\n dedupScope: receivedEventDedupScope(params.event),\n deliveryId: params.event.deliveryId,\n })\n .onConflictDoNothing({\n target: [\n integrationsWebhookDeliveries.provider,\n integrationsWebhookDeliveries.dedupScope,\n integrationsWebhookDeliveries.deliveryId,\n ],\n })\n .returning({deliveryId: integrationsWebhookDeliveries.deliveryId});\n\n if (inserted.length === 0) return {published: false};\n\n await writeOutboxEvent(params.tx, integrationsOutbox, {\n type: INTEGRATION_EVENT_RECEIVED,\n payload: params.event,\n });\n\n return {published: true};\n}\n\nexport interface PublishSourcePushParams {\n tx: IntegrationTx;\n provider: string;\n source: string;\n workspaceId: string;\n connectionId: string;\n connectionName: string;\n deliveryId: string;\n receivedAt: string;\n rawPayload: unknown;\n push: SourcePushPayload;\n}\n\n// Emits a single source-control push as two outbox rows: the generic\n// `INTEGRATION_EVENT_RECEIVED` envelope with the raw provider payload for triggers, and the\n// typed `INTEGRATION_SOURCE_COMMIT_PUSHED` event for domain modules. One delivery-dedup gates\n// both, so a redelivered webhook writes nothing. Requires a transaction: the dedup insert and\n// both outbox rows must commit or roll back together.\nexport async function publishSourcePush(\n params: PublishSourcePushParams,\n): Promise<{published: boolean}> {\n const inserted = await params.tx\n .insert(integrationsWebhookDeliveries)\n .values({\n provider: params.provider,\n dedupScope: providerDedupScope(params.provider),\n deliveryId: params.deliveryId,\n })\n .onConflictDoNothing({\n target: [\n integrationsWebhookDeliveries.provider,\n integrationsWebhookDeliveries.dedupScope,\n integrationsWebhookDeliveries.deliveryId,\n ],\n })\n .returning({deliveryId: integrationsWebhookDeliveries.deliveryId});\n\n if (inserted.length === 0) return {published: false};\n\n await writeOutboxEvents<IntegrationsEventMap>(params.tx, integrationsOutbox, [\n {\n type: INTEGRATION_EVENT_RECEIVED,\n payload: {\n provider: params.provider,\n source: params.source,\n event: 'push',\n workspaceId: params.workspaceId,\n connectionId: params.connectionId,\n connectionName: params.connectionName,\n deliveryId: params.deliveryId,\n receivedAt: params.receivedAt,\n payload: params.rawPayload,\n },\n },\n {\n type: INTEGRATION_SOURCE_COMMIT_PUSHED,\n payload: {\n provider: params.provider,\n workspaceId: params.workspaceId,\n connectionId: params.connectionId,\n deliveryId: params.deliveryId,\n receivedAt: params.receivedAt,\n push: params.push,\n },\n },\n ]);\n\n return {published: true};\n}\n\nexport interface PublishSourceCommitPushedParams {\n provider: string;\n workspaceId: string;\n connectionId: string;\n deliveryId: string;\n receivedAt: string;\n push: SourcePushPayload;\n}\n\n// Emits ONLY the typed `INTEGRATION_SOURCE_COMMIT_PUSHED` event, intentionally skipping the\n// `INTEGRATION_EVENT_RECEIVED` envelope so triggers do not run workflows, and skipping the\n// delivery-dedup row so it is never suppressed. Used to force a definitions re-sync without\n// simulating an inbound webhook.\nexport async function publishSourceCommitPushed(\n params: PublishSourceCommitPushedParams,\n): Promise<void> {\n await writeOutboxEvent<IntegrationsEventMap>(db(), integrationsOutbox, {\n type: INTEGRATION_SOURCE_COMMIT_PUSHED,\n payload: {\n provider: params.provider,\n workspaceId: params.workspaceId,\n connectionId: params.connectionId,\n deliveryId: params.deliveryId,\n receivedAt: params.receivedAt,\n push: params.push,\n },\n });\n}\n\nexport interface RecordDeliveryOnlyParams {\n tx: Executor;\n provider: string;\n deliveryId: string;\n}\n\nexport async function claimWebhookDelivery(\n params: RecordDeliveryOnlyParams,\n): Promise<{claimed: boolean}> {\n const inserted = await params.tx\n .insert(integrationsWebhookDeliveries)\n .values({\n provider: params.provider,\n dedupScope: providerDedupScope(params.provider),\n deliveryId: params.deliveryId,\n })\n .onConflictDoNothing({\n target: [\n integrationsWebhookDeliveries.provider,\n integrationsWebhookDeliveries.dedupScope,\n integrationsWebhookDeliveries.deliveryId,\n ],\n })\n .returning({deliveryId: integrationsWebhookDeliveries.deliveryId});\n return {claimed: inserted.length > 0};\n}\n\nexport async function recordDeliveryOnly(params: RecordDeliveryOnlyParams): Promise<void> {\n await claimWebhookDelivery(params);\n}\n\nexport interface PruneWebhookDeliveriesParams {\n olderThan: Date;\n}\n\nexport async function pruneWebhookDeliveries(\n params: PruneWebhookDeliveriesParams,\n): Promise<{deleted: number}> {\n const result = await db()\n .delete(integrationsWebhookDeliveries)\n .where(lt(integrationsWebhookDeliveries.receivedAt, params.olderThan));\n return {deleted: result.rowCount ?? 0};\n}\n\nexport type PublishIntegrationEventReceivedFn = typeof publishIntegrationEventReceived;\nexport type PublishSourcePushFn = typeof publishSourcePush;\nexport type PublishSourceCommitPushedFn = typeof publishSourceCommitPushed;\nexport type ClaimWebhookDeliveryFn = typeof claimWebhookDelivery;\nexport type RecordDeliveryOnlyFn = typeof recordDeliveryOnly;\n"],"names":["INTEGRATION_EVENT_RECEIVED","INTEGRATION_SOURCE_COMMIT_PUSHED","writeOutboxEvent","writeOutboxEvents","lt","db","integrationsOutbox","integrationsWebhookDeliveries","connectionDedupScope","connectionId","providerDedupScope","provider","receivedEventDedupScope","event","publishIntegrationEventReceived","params","inserted","tx","insert","values","dedupScope","deliveryId","onConflictDoNothing","target","returning","length","published","type","payload","publishSourcePush","source","workspaceId","connectionName","receivedAt","rawPayload","push","publishSourceCommitPushed","claimWebhookDelivery","claimed","recordDeliveryOnly","pruneWebhookDeliveries","result","delete","where","olderThan","deleted","rowCount"],"mappings":"AAAA,SACEA,0BAA0B,EAC1BC,gCAAgC,QAI3B,+BAA+B;AACtC,SAAQC,gBAAgB,EAAEC,iBAAiB,QAAO,uBAAuB;AACzE,SAAQC,EAAE,QAAO,cAAc;AAC/B,SAAQC,EAAE,QAAO,UAAU;AAC3B,SAAQC,kBAAkB,QAAO,qBAAqB;AACtD,SAAQC,6BAA6B,QAAO,iCAAiC;AAM7E,SAASC,qBAAqBC,YAAoB;IAChD,OAAO,CAAC,WAAW,EAAEA,cAAc;AACrC;AAEA,SAASC,mBAAmBC,QAAgB;IAC1C,OAAO,CAAC,SAAS,EAAEA,UAAU;AAC/B;AAEA,SAASC,wBAAwBC,KAAoC;IACnE,IAAIA,MAAMF,QAAQ,KAAK,WAAW,OAAOH,qBAAqBK,MAAMJ,YAAY;IAChF,OAAOC,mBAAmBG,MAAMF,QAAQ;AAC1C;AAWA,OAAO,eAAeG,gCACpBC,MAA6C;IAE7C,MAAMC,WAAW,MAAMD,OAAOE,EAAE,CAC7BC,MAAM,CAACX,+BACPY,MAAM,CAAC;QACNR,UAAUI,OAAOF,KAAK,CAACF,QAAQ;QAC/BS,YAAYR,wBAAwBG,OAAOF,KAAK;QAChDQ,YAAYN,OAAOF,K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B,uBACpBzB,MAAoC;IAEpC,MAAM0B,SAAS,MAAMpC,KAClBqC,MAAM,CAACnC,+BACPoC,KAAK,CAACvC,GAAGG,8BAA8B0B,UAAU,EAAElB,OAAO6B,SAAS;IACtE,OAAO;QAACC,SAASJ,OAAOK,QAAQ,IAAI;IAAC;AACvC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type WebhookRequestProcessor } from '@shipfox/api-integration-core-dto';
1
+ import { type WebhookRequestProcessor } from '@shipfox/api-integration-spi';
2
2
  import type { WorkflowsModuleClient } from '@shipfox/api-workflows-dto/inter-module';
3
3
  import type { WorkspacesInterModuleClient } from '@shipfox/api-workspaces-dto/inter-module';
4
4
  import type { ModuleService, ShipfoxModule } from '@shipfox/node-module';
@@ -6,8 +6,8 @@ import type { IntegrationProvider } from '#core/entities/provider.js';
6
6
  import { type IntegrationProviderRegistry } from '#core/providers/registry.js';
7
7
  import { type IntegrationSourceControlService } from '#core/source-control-service.js';
8
8
  import type { IntegrationModuleParts, IntegrationProviderSecrets } from '#providers/types.js';
9
- export type { StoredWebhookRequest, WebhookProcessingResult, WebhookRequestProcessor, WebhookRouteId, } from '@shipfox/api-integration-core-dto';
10
- export { buildProviderRepositoryId, MAX_REPOSITORY_FILE_BYTES, parseProviderRepositoryId, } from '@shipfox/api-integration-core-dto';
9
+ export type { StoredWebhookRequest, WebhookProcessingResult, WebhookRequestProcessor, WebhookRouteId, } from '@shipfox/api-integration-spi';
10
+ export { buildProviderRepositoryId, MAX_REPOSITORY_FILE_BYTES, parseProviderRepositoryId, } from '@shipfox/api-integration-spi';
11
11
  export type { AgentToolCatalogs, AgentToolSelectionCatalogs, LoadWorkspaceConnectionSnapshot, WorkspaceConnectionSnapshot, WorkspaceConnectionSnapshotEntry, } from '#core/agent-tool-selection.js';
12
12
  export { buildAgentToolCatalogs, buildAgentToolSelectionCatalogs, createWorkspaceConnectionSnapshotLoader, } from '#core/agent-tool-selection.js';
13
13
  export type { IntegrationConnection, IntegrationConnectionLifecycleStatus, } from '#core/entities/connection.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,uBAAuB,EAE7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,yCAAyC,CAAC;AACnF,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,0CAA0C,CAAC;AAE1F,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAEvE,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,iCAAiC,CAAC;AAQzC,OAAO,KAAK,EACV,sBAAsB,EACtB,0BAA0B,EAE3B,MAAM,qBAAqB,CAAC;AAO7B,YAAY,EACV,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,cAAc,GACf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EACV,iBAAiB,EACjB,0BAA0B,EAC1B,+BAA+B,EAC/B,2BAA2B,EAC3B,gCAAgC,GACjC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,uCAAuC,GACxC,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACV,qBAAqB,EACrB,oCAAoC,GACrC,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAC,8BAA8B,EAAC,MAAM,iBAAiB,CAAC;AACpE,OA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AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,2BAA2B,CAAC;IACtC,YAAY,EAAE;QACZ,aAAa,EAAE,+BAA+B,CAAC;KAChD,CAAC;IACF,aAAa,EAAE,+BAA+B,CAAC;IAC/C,gBAAgB,EAAE,uBAAuB,CAAC;IAC1C;;;;OAIG;IACH,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,GAAE,+BAAoC,GAC5C,OAAO,CAAC,aAAa,CAAC,CAExB;AAED,wBAAsB,yBAAyB,CAC7C,OAAO,GAAE,+BAAoC,GAC5C,OAAO,CAAC,mBAAmB,CAAC,CAmG9B"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { dirname, resolve } from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
- import { integrationsEventSchemas } from '@shipfox/api-integration-core-dto';
3
+ import { integrationsEventSchemas } from '@shipfox/api-integration-spi';
4
4
  import { reportError } from '@shipfox/node-error-monitoring';
5
5
  import { logger } from '@shipfox/node-opentelemetry';
6
6
  import { WebhookProcessorNotConfiguredError } from '#core/errors.js';
@@ -17,7 +17,7 @@ import { createIntegrationsMaintenanceActivities } from '#temporal/activities/in
17
17
  import { INTEGRATIONS_MAINTENANCE_TASK_QUEUE } from '#temporal/constants.js';
18
18
  const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
19
19
  const maintenanceWorkflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');
20
- export { buildProviderRepositoryId, MAX_REPOSITORY_FILE_BYTES, parseProviderRepositoryId } from '@shipfox/api-integration-core-dto';
20
+ export { buildProviderRepositoryId, MAX_REPOSITORY_FILE_BYTES, parseProviderRepositoryId } from '@shipfox/api-integration-spi';
21
21
  export { buildAgentToolCatalogs, buildAgentToolSelectionCatalogs, createWorkspaceConnectionSnapshotLoader } from '#core/agent-tool-selection.js';
22
22
  export { ConnectionSlugConflictError, IntegrationCapabilityUnavailableError, IntegrationCheckoutUnsupportedError, IntegrationConnectionInactiveError, IntegrationConnectionNotFoundError, IntegrationConnectionWorkspaceMismatchError, IntegrationProviderError, IntegrationProviderUnavailableError, WebhookProcessorNotConfiguredError } from '#core/errors.js';
23
23
  export { redactCheckoutSpec } from '#core/providers/redact-checkout-spec.js';
@@ -77,7 +77,8 @@ export async function createIntegrationsContext(options = {}) {
77
77
  database: [
78
78
  {
79
79
  db,
80
- migrationsPath
80
+ migrationsPath,
81
+ databaseNamespace: 'integrations'
81
82
  },
82
83
  ...parts.flatMap((part)=>part.database ? [
83
84
  part.database