@shipfox/api-integration-core 11.0.0 → 12.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +73 -0
  3. package/dist/core/providers/source-control.d.ts +1 -1
  4. package/dist/core/providers/source-control.d.ts.map +1 -1
  5. package/dist/core/providers/source-control.js.map +1 -1
  6. package/dist/core/source-control-service.d.ts +7 -1
  7. package/dist/core/source-control-service.d.ts.map +1 -1
  8. package/dist/core/source-control-service.js +11 -0
  9. package/dist/core/source-control-service.js.map +1 -1
  10. package/dist/db/connections.d.ts +6 -0
  11. package/dist/db/connections.d.ts.map +1 -1
  12. package/dist/db/connections.js +6 -0
  13. package/dist/db/connections.js.map +1 -1
  14. package/dist/db/webhook-deliveries.d.ts +18 -1
  15. package/dist/db/webhook-deliveries.d.ts.map +1 -1
  16. package/dist/db/webhook-deliveries.js +65 -19
  17. package/dist/db/webhook-deliveries.js.map +1 -1
  18. package/dist/index.d.ts +5 -5
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +2 -2
  21. package/dist/index.js.map +1 -1
  22. package/dist/presentation/inter-module.d.ts.map +1 -1
  23. package/dist/presentation/inter-module.js +10 -1
  24. package/dist/presentation/inter-module.js.map +1 -1
  25. package/dist/providers/github.d.ts.map +1 -1
  26. package/dist/providers/github.js +2 -1
  27. package/dist/providers/github.js.map +1 -1
  28. package/dist/providers/jira.d.ts.map +1 -1
  29. package/dist/providers/jira.js +44 -12
  30. package/dist/providers/jira.js.map +1 -1
  31. package/dist/providers/types.d.ts +1 -1
  32. package/dist/providers/types.js.map +1 -1
  33. package/dist/tsconfig.test.tsbuildinfo +1 -1
  34. package/package.json +20 -20
  35. package/src/core/agent-tool-selection.test.ts +1 -0
  36. package/src/core/providers/registry.test.ts +1 -0
  37. package/src/core/providers/source-control.ts +1 -0
  38. package/src/core/source-control-service.test.ts +25 -0
  39. package/src/core/source-control-service.ts +21 -0
  40. package/src/db/connections.test.ts +18 -0
  41. package/src/db/connections.ts +25 -0
  42. package/src/db/webhook-deliveries.test.ts +77 -0
  43. package/src/db/webhook-deliveries.ts +110 -21
  44. package/src/index.ts +13 -3
  45. package/src/presentation/inter-module.ts +11 -1
  46. package/src/presentation/routes/list-repositories.test.ts +1 -0
  47. package/src/providers/github.ts +2 -0
  48. package/src/providers/jira.test.ts +5 -0
  49. package/src/providers/jira.ts +45 -11
  50. package/src/providers/types.ts +1 -1
  51. package/test/env.ts +0 -1
  52. package/test/route-utils.ts +1 -0
  53. package/tsconfig.build.tsbuildinfo +1 -1
@@ -13,6 +13,7 @@ import {
13
13
  upsertIntegrationConnection,
14
14
  } from '#db/connections.js';
15
15
  import {db} from '#db/db.js';
16
+ import {publishIntegrationEventReceived, recordDeliveryOnly} from '#db/webhook-deliveries.js';
16
17
  import {retryConnectionSlugCollision, slugifyConnectionSlug} from '#providers/connection-slug.js';
17
18
  import type {IntegrationModuleParts, IntegrationProviderModule} from '#providers/types.js';
18
19
 
@@ -25,6 +26,7 @@ async function loadJiraModuleParts(
25
26
  ): Promise<IntegrationModuleParts> {
26
27
  const {
27
28
  createJiraIntegrationProvider,
29
+ createJiraMaintenanceWorker,
28
30
  createJiraPendingSelectionStore,
29
31
  createJiraTokenStore,
30
32
  db: jiraDb,
@@ -140,19 +142,51 @@ async function loadJiraModuleParts(
140
142
  });
141
143
  const pendingStore = createJiraPendingSelectionStore({secrets});
142
144
 
145
+ const integrationProvider = createJiraIntegrationProvider({
146
+ agentTools: {tokenStore},
147
+ routes: {
148
+ tokenStore,
149
+ pendingStore,
150
+ getExistingJiraConnection,
151
+ connectJiraInstallation,
152
+ disconnectJiraInstallation,
153
+ coreDb: db,
154
+ publishIntegrationEventReceived,
155
+ recordDeliveryOnly,
156
+ getIntegrationConnectionById,
157
+ markConnectionActive: async ({connectionId, tx}) => {
158
+ await updateIntegrationConnectionLifecycleStatus(
159
+ {
160
+ id: connectionId,
161
+ lifecycleStatus: 'active',
162
+ },
163
+ tx === undefined ? {} : {tx: tx as IntegrationTx},
164
+ );
165
+ },
166
+ markConnectionError: async ({connectionId, tx}) => {
167
+ await updateIntegrationConnectionLifecycleStatus(
168
+ {
169
+ id: connectionId,
170
+ lifecycleStatus: 'error',
171
+ },
172
+ tx === undefined ? {} : {tx: tx as IntegrationTx},
173
+ );
174
+ },
175
+ ...(options.requireActiveWorkspaceMembership
176
+ ? {requireActiveWorkspaceMembership: options.requireActiveWorkspaceMembership}
177
+ : {}),
178
+ },
179
+ });
180
+
143
181
  return {
144
- provider: createJiraIntegrationProvider({
145
- routes: {
182
+ provider: integrationProvider,
183
+ workers: [
184
+ createJiraMaintenanceWorker({
146
185
  tokenStore,
147
- pendingStore,
148
- getExistingJiraConnection,
149
- connectJiraInstallation,
150
- disconnectJiraInstallation,
151
- ...(options.requireActiveWorkspaceMembership
152
- ? {requireActiveWorkspaceMembership: options.requireActiveWorkspaceMembership}
153
- : {}),
154
- },
155
- }),
186
+ resolveConnection: getIntegrationConnectionById,
187
+ }),
188
+ ],
189
+ webhookProcessors: integrationProvider.webhookProcessors,
156
190
  database: {db: jiraDb, migrationsPath, databaseNamespace: 'integrations_jira'},
157
191
  };
158
192
  }
@@ -10,7 +10,7 @@ import type {IntegrationProvider} from '#core/entities/provider.js';
10
10
  * and one-shot boot-time tasks. Providers that own none of these simply omit them.
11
11
  *
12
12
  * A startup task is run once after modules are initialized (migrations done). The
13
- * provider owns its own wiring core runs each task generically and isolates
13
+ * provider owns its own wiring: core runs each task generically and isolates
14
14
  * failures so a task can never gate API boot.
15
15
  */
16
16
  export interface IntegrationModuleParts {
package/test/env.ts CHANGED
@@ -15,7 +15,6 @@ process.env.GITHUB_INSTALL_STATE_SECRET = 'test-install-state-secret';
15
15
  process.env.JIRA_OAUTH_CLIENT_ID = 'test-client-id';
16
16
  process.env.JIRA_OAUTH_CLIENT_SECRET = 'test-client-secret';
17
17
  process.env.JIRA_OAUTH_REDIRECT_URL = 'https://shipfox.example.com/integrations/jira/callback';
18
- process.env.JIRA_WEBHOOK_SIGNING_SECRET = 'test-webhook-secret';
19
18
  process.env.JIRA_WEBHOOK_BASE_URL = 'https://shipfox.example.com';
20
19
  process.env.JIRA_API_BASE_URL = 'https://jira.example.com/api';
21
20
  process.env.JIRA_AUTH_BASE_URL = 'https://jira.example.com/auth';
@@ -66,6 +66,7 @@ export function sourceProvider(overrides: Partial<IntegrationProvider> = {}): In
66
66
  await Promise.resolve();
67
67
  throw new Error('not used');
68
68
  },
69
+ resolveTriggerReference: () => null,
69
70
  },
70
71
  },
71
72
  ...overrides,