@shipfox/client-integrations 4.0.0 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +86 -0
- package/dist/application/complete-integration-callback.d.ts +13 -0
- package/dist/application/complete-integration-callback.d.ts.map +1 -0
- package/dist/application/complete-integration-callback.js +26 -0
- package/dist/application/complete-integration-callback.js.map +1 -0
- package/dist/components/connection-picker.d.ts +2 -2
- package/dist/components/connection-picker.d.ts.map +1 -1
- package/dist/components/connection-picker.js +4 -4
- package/dist/components/connection-picker.js.map +1 -1
- package/dist/components/installed-integrations-section.d.ts +8 -6
- package/dist/components/installed-integrations-section.d.ts.map +1 -1
- package/dist/components/installed-integrations-section.js +22 -15
- package/dist/components/installed-integrations-section.js.map +1 -1
- package/dist/components/integration-gallery-for-workspace.d.ts +2 -2
- package/dist/components/integration-gallery-for-workspace.d.ts.map +1 -1
- package/dist/components/integration-gallery-for-workspace.js +14 -7
- package/dist/components/integration-gallery-for-workspace.js.map +1 -1
- package/dist/components/integration-gallery.d.ts +2 -2
- package/dist/components/integration-gallery.d.ts.map +1 -1
- package/dist/components/integration-gallery.js.map +1 -1
- package/dist/components/integration-usage-events.d.ts +1 -3
- package/dist/components/integration-usage-events.d.ts.map +1 -1
- package/dist/components/integration-usage-events.js +1 -125
- package/dist/components/integration-usage-events.js.map +1 -1
- package/dist/components/integration-usage-modal.d.ts +2 -2
- package/dist/components/integration-usage-modal.d.ts.map +1 -1
- package/dist/components/integration-usage-modal.js +2 -2
- package/dist/components/integration-usage-modal.js.map +1 -1
- package/dist/components/provider-grid.d.ts +7 -4
- package/dist/components/provider-grid.d.ts.map +1 -1
- package/dist/components/provider-grid.js +15 -10
- package/dist/components/provider-grid.js.map +1 -1
- package/dist/components/redirect-install-page.d.ts +2 -3
- package/dist/components/redirect-install-page.d.ts.map +1 -1
- package/dist/components/redirect-install-page.js +1 -1
- package/dist/components/redirect-install-page.js.map +1 -1
- package/dist/components/repository-picker.d.ts +2 -2
- package/dist/components/repository-picker.d.ts.map +1 -1
- package/dist/components/repository-picker.js +4 -4
- package/dist/components/repository-picker.js.map +1 -1
- package/dist/components/webhook/webhook-create-modal.d.ts +2 -2
- package/dist/components/webhook/webhook-create-modal.d.ts.map +1 -1
- package/dist/components/webhook/webhook-create-modal.js +8 -8
- package/dist/components/webhook/webhook-create-modal.js.map +1 -1
- package/dist/components/webhook/webhook-modals.stories.d.ts.map +1 -1
- package/dist/components/webhook/webhook-modals.stories.js +7 -7
- package/dist/components/webhook/webhook-modals.stories.js.map +1 -1
- package/dist/components/webhook/webhook-usage-details.d.ts.map +1 -1
- package/dist/components/webhook/webhook-usage-details.js +2 -2
- package/dist/components/webhook/webhook-usage-details.js.map +1 -1
- package/dist/connection-status-badge.d.ts +2 -2
- package/dist/connection-status-badge.d.ts.map +1 -1
- package/dist/connection-status-badge.js +11 -15
- package/dist/connection-status-badge.js.map +1 -1
- package/dist/core/models.d.ts +66 -0
- package/dist/core/models.d.ts.map +1 -0
- package/dist/core/models.js +156 -0
- package/dist/core/models.js.map +1 -0
- package/dist/feature.d.ts +18 -0
- package/dist/feature.d.ts.map +1 -1
- package/dist/feature.js +16 -1
- package/dist/feature.js.map +1 -1
- package/dist/hooks/api/integration-mapper.d.ts +11 -0
- package/dist/hooks/api/integration-mapper.d.ts.map +1 -0
- package/dist/hooks/api/integration-mapper.js +54 -0
- package/dist/hooks/api/integration-mapper.js.map +1 -0
- package/dist/hooks/api/integrations.d.ts +47 -237
- package/dist/hooks/api/integrations.d.ts.map +1 -1
- package/dist/hooks/api/integrations.js +92 -42
- package/dist/hooks/api/integrations.js.map +1 -1
- package/dist/hooks/api/webhook-connections.d.ts +12 -64
- package/dist/hooks/api/webhook-connections.d.ts.map +1 -1
- package/dist/hooks/api/webhook-connections.js +17 -9
- package/dist/hooks/api/webhook-connections.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/linear-callback.d.ts +2 -1
- package/dist/linear-callback.d.ts.map +1 -1
- package/dist/linear-callback.js +14 -15
- package/dist/linear-callback.js.map +1 -1
- package/dist/pages/gitea-install-page.d.ts.map +1 -1
- package/dist/pages/gitea-install-page.js +1 -10
- package/dist/pages/gitea-install-page.js.map +1 -1
- package/dist/pages/linear-callback-page.d.ts.map +1 -1
- package/dist/pages/linear-callback-page.js +19 -32
- package/dist/pages/linear-callback-page.js.map +1 -1
- package/dist/pages/linear-install-page.d.ts.map +1 -1
- package/dist/pages/linear-install-page.js +2 -1
- package/dist/pages/linear-install-page.js.map +1 -1
- package/dist/pages/sentry-callback-page.d.ts.map +1 -1
- package/dist/pages/sentry-callback-page.js +22 -25
- package/dist/pages/sentry-callback-page.js.map +1 -1
- package/dist/pages/sentry-install-page.d.ts.map +1 -1
- package/dist/pages/sentry-install-page.js +2 -1
- package/dist/pages/sentry-install-page.js.map +1 -1
- package/dist/pages/slack-callback-page.d.ts.map +1 -1
- package/dist/pages/slack-callback-page.js +21 -28
- package/dist/pages/slack-callback-page.js.map +1 -1
- package/dist/pages/slack-install-page.d.ts.map +1 -1
- package/dist/pages/slack-install-page.js +2 -1
- package/dist/pages/slack-install-page.js.map +1 -1
- package/dist/pages/source-control-onboarding-page.d.ts.map +1 -1
- package/dist/pages/source-control-onboarding-page.js +5 -1
- package/dist/pages/source-control-onboarding-page.js.map +1 -1
- package/dist/provider-catalog.d.ts.map +1 -1
- package/dist/provider-catalog.js +7 -6
- package/dist/provider-catalog.js.map +1 -1
- package/dist/routes/github-callback.d.ts +16 -0
- package/dist/routes/github-callback.d.ts.map +1 -1
- package/dist/routes/github-callback.js +43 -21
- package/dist/routes/github-callback.js.map +1 -1
- package/dist/routes/integrations-settings.d.ts +6 -0
- package/dist/routes/integrations-settings.d.ts.map +1 -0
- package/dist/routes/integrations-settings.js +7 -0
- package/dist/routes/integrations-settings.js.map +1 -0
- package/dist/routes/linear-callback.d.ts +2 -0
- package/dist/routes/linear-callback.d.ts.map +1 -1
- package/dist/routes/linear-callback.js +2 -0
- package/dist/routes/linear-callback.js.map +1 -1
- package/dist/routes/sentry-callback.d.ts +2 -0
- package/dist/routes/sentry-callback.d.ts.map +1 -1
- package/dist/routes/sentry-callback.js +2 -0
- package/dist/routes/sentry-callback.js.map +1 -1
- package/dist/routes/slack-callback.d.ts +2 -0
- package/dist/routes/slack-callback.d.ts.map +1 -1
- package/dist/routes/slack-callback.js +2 -0
- package/dist/routes/slack-callback.js.map +1 -1
- package/dist/sentry-callback.d.ts +2 -1
- package/dist/sentry-callback.d.ts.map +1 -1
- package/dist/sentry-callback.js +16 -19
- package/dist/sentry-callback.js.map +1 -1
- package/dist/slack-callback.d.ts +2 -1
- package/dist/slack-callback.d.ts.map +1 -1
- package/dist/slack-callback.js +14 -15
- package/dist/slack-callback.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/src/application/complete-integration-callback.test.ts +41 -0
- package/src/application/complete-integration-callback.ts +39 -0
- package/src/components/connection-picker.tsx +7 -7
- package/src/components/installed-integrations-section.tsx +29 -24
- package/src/components/integration-gallery-for-workspace.tsx +23 -16
- package/src/components/integration-gallery.tsx +3 -3
- package/src/components/integration-usage-events.ts +1 -116
- package/src/components/integration-usage-modal.tsx +4 -4
- package/src/components/provider-grid.tsx +30 -18
- package/src/components/redirect-install-page.test.tsx +2 -6
- package/src/components/redirect-install-page.tsx +3 -2
- package/src/components/repository-picker.tsx +6 -6
- package/src/components/webhook/webhook-create-modal.tsx +12 -11
- package/src/components/webhook/webhook-modals.stories.tsx +10 -10
- package/src/components/webhook/webhook-usage-details.tsx +2 -4
- package/src/connection-status-badge.tsx +8 -14
- package/src/core/models.ts +200 -0
- package/src/feature.ts +17 -1
- package/src/hooks/api/integration-mapper.ts +64 -0
- package/src/hooks/api/integrations.test.ts +44 -22
- package/src/hooks/api/integrations.ts +258 -89
- package/src/hooks/api/webhook-connections.ts +58 -17
- package/src/index.ts +2 -1
- package/src/linear-callback.ts +21 -16
- package/src/pages/gitea-install-page.tsx +1 -10
- package/src/pages/linear-callback-page.test.tsx +1 -1
- package/src/pages/linear-callback-page.tsx +18 -29
- package/src/pages/linear-install-page.tsx +2 -1
- package/src/pages/sentry-callback-page.test.tsx +6 -2
- package/src/pages/sentry-callback-page.tsx +28 -25
- package/src/pages/sentry-install-page.tsx +2 -1
- package/src/pages/slack-callback-page.tsx +20 -25
- package/src/pages/slack-install-page.tsx +2 -1
- package/src/pages/source-control-onboarding-page.tsx +5 -1
- package/src/provider-catalog.ts +7 -6
- package/src/routes/github-callback.test.ts +35 -1
- package/src/routes/github-callback.tsx +47 -21
- package/src/routes/integrations-settings.tsx +4 -0
- package/src/routes/linear-callback.tsx +5 -1
- package/src/routes/sentry-callback.tsx +5 -1
- package/src/routes/slack-callback.tsx +6 -1
- package/src/sentry-callback.test.ts +2 -1
- package/src/sentry-callback.ts +28 -20
- package/src/slack-callback.ts +21 -16
- package/test/render.tsx +1 -5
- package/tsconfig.build.tsbuildinfo +1 -1
- package/vercel.json +5 -0
- package/dist/integration-icon.d.ts +0 -17
- package/dist/integration-icon.d.ts.map +0 -1
- package/dist/integration-icon.js +0 -22
- package/dist/integration-icon.js.map +0 -1
- package/src/integration-icon.react.test.tsx +0 -40
- package/src/integration-icon.test.ts +0 -19
- package/src/integration-icon.tsx +0 -26
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { integrationConnectionDtoSchema, listIntegrationConnectionsResponseSchema, listIntegrationProvidersResponseSchema, listRepositoriesResponseSchema } from '@shipfox/api-integration-core-dto';
|
|
2
|
+
import { createGiteaConnectionResponseSchema } from '@shipfox/api-integration-gitea-dto';
|
|
3
|
+
import { createGithubInstallResponseSchema, githubCallbackResponseSchema } from '@shipfox/api-integration-github-dto';
|
|
4
|
+
import { createLinearInstallResponseSchema, linearCallbackResponseSchema } from '@shipfox/api-integration-linear-dto';
|
|
5
|
+
import { createSentryInstallResponseSchema, sentryConnectResponseSchema } from '@shipfox/api-integration-sentry-dto';
|
|
6
|
+
import { createSlackInstallResponseSchema, slackCallbackResponseSchema } from '@shipfox/api-integration-slack-dto';
|
|
7
|
+
import { checkedApiRequest, emptyResponseSchema } from '@shipfox/client-api';
|
|
8
|
+
import { infiniteQueryOptions, queryOptions, useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
9
|
+
import { isUsableConnection } from '#core/models.js';
|
|
3
10
|
import { serializeLinearCallbackQuery } from '#linear-callback.js';
|
|
4
11
|
import { serializeSlackCallbackQuery } from '#slack-callback.js';
|
|
12
|
+
import { toInstallRedirect, toIntegrationConnection, toIntegrationProvider, toRepository } from './integration-mapper.js';
|
|
5
13
|
export const integrationsQueryKeys = {
|
|
6
14
|
all: [
|
|
7
15
|
'integrations'
|
|
@@ -38,21 +46,23 @@ export async function listIntegrationProviders({ capability, signal }) {
|
|
|
38
46
|
if (capability) search.set('capability', capability);
|
|
39
47
|
const query = search.toString();
|
|
40
48
|
const path = query ? `/integration-providers?${query}` : '/integration-providers';
|
|
41
|
-
|
|
49
|
+
const response = await checkedApiRequest(listIntegrationProvidersResponseSchema, path, {
|
|
42
50
|
signal
|
|
43
51
|
});
|
|
52
|
+
return response.providers.map(toIntegrationProvider);
|
|
44
53
|
}
|
|
45
54
|
export async function listIntegrationConnections({ workspaceId, capability, signal }) {
|
|
46
55
|
const search = new URLSearchParams({
|
|
47
56
|
workspace_id: workspaceId
|
|
48
57
|
});
|
|
49
58
|
if (capability) search.set('capability', capability);
|
|
50
|
-
|
|
59
|
+
const response = await checkedApiRequest(listIntegrationConnectionsResponseSchema, `/integration-connections?${search.toString()}`, {
|
|
51
60
|
signal
|
|
52
61
|
});
|
|
62
|
+
return response.connections.map(toIntegrationConnection);
|
|
53
63
|
}
|
|
54
64
|
export async function listSourceConnections({ workspaceId, signal }) {
|
|
55
|
-
const
|
|
65
|
+
const connections = await listIntegrationConnections({
|
|
56
66
|
workspaceId,
|
|
57
67
|
capability: 'source_control',
|
|
58
68
|
signal
|
|
@@ -60,65 +70,93 @@ export async function listSourceConnections({ workspaceId, signal }) {
|
|
|
60
70
|
// The endpoint returns every lifecycle status (the settings hub needs that),
|
|
61
71
|
// but source-control consumers (onboarding redirect, project creation) only
|
|
62
72
|
// act on usable connections — a disabled/error one must read as "not there".
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
return connections.filter(isUsableConnection);
|
|
74
|
+
}
|
|
75
|
+
export function sourceConnectionsQueryOptions(workspaceId) {
|
|
76
|
+
return queryOptions({
|
|
77
|
+
queryKey: workspaceId ? integrationsQueryKeys.sourceConnections(workspaceId) : [
|
|
78
|
+
...integrationsQueryKeys.all,
|
|
79
|
+
'source-connections'
|
|
80
|
+
],
|
|
81
|
+
enabled: Boolean(workspaceId),
|
|
82
|
+
queryFn: ({ signal })=>listSourceConnections({
|
|
83
|
+
workspaceId: workspaceId ?? '',
|
|
84
|
+
signal
|
|
85
|
+
})
|
|
86
|
+
});
|
|
67
87
|
}
|
|
68
88
|
export async function createGiteaConnection(body) {
|
|
69
|
-
|
|
89
|
+
const response = await checkedApiRequest(createGiteaConnectionResponseSchema, '/integrations/gitea/connections', {
|
|
70
90
|
method: 'POST',
|
|
71
91
|
body
|
|
72
92
|
});
|
|
93
|
+
return toIntegrationConnection(response);
|
|
73
94
|
}
|
|
74
95
|
export async function createGithubInstall(body) {
|
|
75
|
-
return await
|
|
96
|
+
return toInstallRedirect(await checkedApiRequest(createGithubInstallResponseSchema, '/integrations/github/install', {
|
|
76
97
|
method: 'POST',
|
|
77
98
|
body
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
export async function completeGithubCallback({ code, installationId, state, setupAction, token }) {
|
|
102
|
+
const query = new URLSearchParams({
|
|
103
|
+
code,
|
|
104
|
+
installation_id: String(installationId),
|
|
105
|
+
state
|
|
78
106
|
});
|
|
107
|
+
if (setupAction) query.set('setup_action', setupAction);
|
|
108
|
+
const response = await checkedApiRequest(githubCallbackResponseSchema, `/integrations/github/callback/api?${query.toString()}`, {
|
|
109
|
+
headers: {
|
|
110
|
+
authorization: `Bearer ${token}`
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return toIntegrationConnection(response);
|
|
79
114
|
}
|
|
80
115
|
export async function createSentryInstall(body) {
|
|
81
|
-
return await
|
|
116
|
+
return toInstallRedirect(await checkedApiRequest(createSentryInstallResponseSchema, '/integrations/sentry/install', {
|
|
82
117
|
method: 'POST',
|
|
83
118
|
body
|
|
84
|
-
});
|
|
119
|
+
}));
|
|
85
120
|
}
|
|
86
121
|
export async function createLinearInstall(body) {
|
|
87
|
-
return await
|
|
122
|
+
return toInstallRedirect(await checkedApiRequest(createLinearInstallResponseSchema, '/integrations/linear/install', {
|
|
88
123
|
method: 'POST',
|
|
89
124
|
body
|
|
90
|
-
});
|
|
125
|
+
}));
|
|
91
126
|
}
|
|
92
127
|
export async function createSlackInstall(body) {
|
|
93
|
-
return await
|
|
128
|
+
return toInstallRedirect(await checkedApiRequest(createSlackInstallResponseSchema, '/integrations/slack/install', {
|
|
94
129
|
method: 'POST',
|
|
95
130
|
body
|
|
96
|
-
});
|
|
131
|
+
}));
|
|
97
132
|
}
|
|
98
133
|
export async function completeLinearCallback({ query, token }) {
|
|
99
|
-
|
|
134
|
+
const response = await checkedApiRequest(linearCallbackResponseSchema, `/integrations/linear/callback/api?${serializeLinearCallbackQuery(query)}`, {
|
|
100
135
|
headers: {
|
|
101
136
|
authorization: `Bearer ${token}`
|
|
102
137
|
}
|
|
103
138
|
});
|
|
139
|
+
return toIntegrationConnection(response);
|
|
104
140
|
}
|
|
105
141
|
export async function completeSlackCallback({ query, token }) {
|
|
106
|
-
|
|
142
|
+
const response = await checkedApiRequest(slackCallbackResponseSchema, `/integrations/slack/callback/api?${serializeSlackCallbackQuery(query)}`, {
|
|
107
143
|
headers: {
|
|
108
144
|
authorization: `Bearer ${token}`
|
|
109
145
|
}
|
|
110
146
|
});
|
|
147
|
+
return toIntegrationConnection(response);
|
|
111
148
|
}
|
|
112
149
|
// Called from the callback route with an explicit bearer (same as the GitHub
|
|
113
150
|
// callback): the route refreshes auth itself before forwarding the grant code.
|
|
114
151
|
export async function connectSentry({ body, token }) {
|
|
115
|
-
|
|
152
|
+
const response = await checkedApiRequest(sentryConnectResponseSchema, '/integrations/sentry/connect', {
|
|
116
153
|
method: 'POST',
|
|
117
154
|
body,
|
|
118
155
|
headers: {
|
|
119
156
|
authorization: `Bearer ${token}`
|
|
120
157
|
}
|
|
121
158
|
});
|
|
159
|
+
return toIntegrationConnection(response);
|
|
122
160
|
}
|
|
123
161
|
export async function listRepositories({ connectionId, cursor, search, signal }) {
|
|
124
162
|
const params = new URLSearchParams();
|
|
@@ -126,24 +164,33 @@ export async function listRepositories({ connectionId, cursor, search, signal })
|
|
|
126
164
|
if (search) params.set('search', search);
|
|
127
165
|
const query = params.toString();
|
|
128
166
|
const path = query ? `/integration-connections/${connectionId}/repositories?${query}` : `/integration-connections/${connectionId}/repositories`;
|
|
129
|
-
|
|
167
|
+
const response = await checkedApiRequest(listRepositoriesResponseSchema, path, {
|
|
130
168
|
signal
|
|
131
169
|
});
|
|
170
|
+
return {
|
|
171
|
+
repositories: response.repositories.map(toRepository),
|
|
172
|
+
...response.next_cursor == null ? {} : {
|
|
173
|
+
nextCursor: response.next_cursor
|
|
174
|
+
}
|
|
175
|
+
};
|
|
132
176
|
}
|
|
133
177
|
export async function updateIntegrationConnection({ connectionId, body }) {
|
|
134
|
-
|
|
178
|
+
const response = await checkedApiRequest(integrationConnectionDtoSchema, `/integration-connections/${encodeURIComponent(connectionId)}`, {
|
|
135
179
|
method: 'PATCH',
|
|
136
180
|
body
|
|
137
181
|
});
|
|
182
|
+
return toIntegrationConnection(response);
|
|
138
183
|
}
|
|
139
184
|
export async function deleteIntegrationConnection({ connectionId }) {
|
|
140
|
-
await
|
|
185
|
+
await checkedApiRequest(emptyResponseSchema, `/integration-connections/${encodeURIComponent(connectionId)}`, {
|
|
141
186
|
method: 'DELETE'
|
|
142
187
|
});
|
|
143
188
|
}
|
|
144
189
|
export function useIntegrationProvidersQuery(params) {
|
|
145
|
-
|
|
146
|
-
|
|
190
|
+
return useQuery(integrationProvidersQueryOptions(params?.capability));
|
|
191
|
+
}
|
|
192
|
+
export function integrationProvidersQueryOptions(capability) {
|
|
193
|
+
return queryOptions({
|
|
147
194
|
queryKey: integrationsQueryKeys.providers(capability ?? 'all'),
|
|
148
195
|
queryFn: ({ signal })=>listIntegrationProviders(capability ? {
|
|
149
196
|
capability,
|
|
@@ -154,20 +201,13 @@ export function useIntegrationProvidersQuery(params) {
|
|
|
154
201
|
});
|
|
155
202
|
}
|
|
156
203
|
export function useSourceConnectionsQuery(workspaceId) {
|
|
157
|
-
return useQuery(
|
|
158
|
-
queryKey: workspaceId ? integrationsQueryKeys.sourceConnections(workspaceId) : [
|
|
159
|
-
...integrationsQueryKeys.all,
|
|
160
|
-
'source-connections'
|
|
161
|
-
],
|
|
162
|
-
enabled: Boolean(workspaceId),
|
|
163
|
-
queryFn: ({ signal })=>listSourceConnections({
|
|
164
|
-
workspaceId: workspaceId ?? '',
|
|
165
|
-
signal
|
|
166
|
-
})
|
|
167
|
-
});
|
|
204
|
+
return useQuery(sourceConnectionsQueryOptions(workspaceId));
|
|
168
205
|
}
|
|
169
206
|
export function useIntegrationConnectionsQuery(workspaceId) {
|
|
170
|
-
return useQuery(
|
|
207
|
+
return useQuery(integrationConnectionsQueryOptions(workspaceId));
|
|
208
|
+
}
|
|
209
|
+
export function integrationConnectionsQueryOptions(workspaceId) {
|
|
210
|
+
return queryOptions({
|
|
171
211
|
queryKey: workspaceId ? integrationsQueryKeys.connections(workspaceId, 'all') : [
|
|
172
212
|
...integrationsQueryKeys.all,
|
|
173
213
|
'connections'
|
|
@@ -179,9 +219,9 @@ export function useIntegrationConnectionsQuery(workspaceId) {
|
|
|
179
219
|
})
|
|
180
220
|
});
|
|
181
221
|
}
|
|
182
|
-
export function
|
|
222
|
+
export function repositoriesInfiniteQueryOptions(connectionId, options) {
|
|
183
223
|
const trimmedSearch = options?.search?.trim() ?? '';
|
|
184
|
-
return
|
|
224
|
+
return infiniteQueryOptions({
|
|
185
225
|
queryKey: connectionId ? integrationsQueryKeys.repositories(connectionId, trimmedSearch) : [
|
|
186
226
|
...integrationsQueryKeys.all,
|
|
187
227
|
'repositories'
|
|
@@ -197,12 +237,22 @@ export function useRepositoriesInfiniteQuery(connectionId, options) {
|
|
|
197
237
|
if (trimmedSearch) args.search = trimmedSearch;
|
|
198
238
|
return listRepositories(args);
|
|
199
239
|
},
|
|
200
|
-
getNextPageParam: (lastPage)=>lastPage.
|
|
240
|
+
getNextPageParam: (lastPage)=>lastPage.nextCursor
|
|
201
241
|
});
|
|
202
242
|
}
|
|
243
|
+
export function useRepositoriesInfiniteQuery(connectionId, options) {
|
|
244
|
+
return useInfiniteQuery(repositoriesInfiniteQueryOptions(connectionId, options));
|
|
245
|
+
}
|
|
203
246
|
export function useCreateGiteaConnectionMutation() {
|
|
247
|
+
const queryClient = useQueryClient();
|
|
204
248
|
return useMutation({
|
|
205
|
-
mutationFn: createGiteaConnection
|
|
249
|
+
mutationFn: createGiteaConnection,
|
|
250
|
+
onSuccess: async (connection)=>{
|
|
251
|
+
await queryClient.invalidateQueries({
|
|
252
|
+
queryKey: integrationsQueryKeys.connectionsByWorkspace(connection.workspaceId),
|
|
253
|
+
refetchType: 'all'
|
|
254
|
+
});
|
|
255
|
+
}
|
|
206
256
|
});
|
|
207
257
|
}
|
|
208
258
|
export function useCreateLinearInstallMutation() {
|
|
@@ -231,7 +281,7 @@ export function useUpdateIntegrationConnectionMutation() {
|
|
|
231
281
|
mutationFn: updateIntegrationConnection,
|
|
232
282
|
onSuccess: async (connection)=>{
|
|
233
283
|
await queryClient.invalidateQueries({
|
|
234
|
-
queryKey: integrationsQueryKeys.connectionsByWorkspace(connection.
|
|
284
|
+
queryKey: integrationsQueryKeys.connectionsByWorkspace(connection.workspaceId)
|
|
235
285
|
});
|
|
236
286
|
}
|
|
237
287
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/api/integrations.ts"],"sourcesContent":["import type {\n IntegrationCapabilityDto,\n IntegrationConnectionDto,\n ListIntegrationConnectionsResponseDto,\n ListIntegrationProvidersResponseDto,\n ListRepositoriesResponseDto,\n UpdateIntegrationConnectionBodyDto,\n} from '@shipfox/api-integration-core-dto';\nimport type {\n CreateGiteaConnectionBodyDto,\n CreateGiteaConnectionResponseDto,\n} from '@shipfox/api-integration-gitea-dto';\nimport type {\n CreateGithubInstallBodyDto,\n CreateGithubInstallResponseDto,\n} from '@shipfox/api-integration-github-dto';\nimport type {\n CreateLinearInstallBodyDto,\n CreateLinearInstallResponseDto,\n LinearCallbackQueryDto,\n LinearCallbackResponseDto,\n} from '@shipfox/api-integration-linear-dto';\nimport type {\n CreateSentryInstallBodyDto,\n CreateSentryInstallResponseDto,\n SentryConnectBodyDto,\n SentryConnectResponseDto,\n} from '@shipfox/api-integration-sentry-dto';\nimport type {\n CreateSlackInstallBodyDto,\n CreateSlackInstallResponseDto,\n SlackCallbackQueryDto,\n SlackCallbackResponseDto,\n} from '@shipfox/api-integration-slack-dto';\nimport {apiRequest} from '@shipfox/client-api';\nimport {useInfiniteQuery, useMutation, useQuery, useQueryClient} from '@tanstack/react-query';\nimport {serializeLinearCallbackQuery} from '#linear-callback.js';\nimport {serializeSlackCallbackQuery} from '#slack-callback.js';\n\nexport const integrationsQueryKeys = {\n all: ['integrations'] as const,\n providers: (capability: IntegrationCapabilityDto | 'all') =>\n [...integrationsQueryKeys.all, 'providers', capability] as const,\n connections: (workspaceId: string, capability: IntegrationCapabilityDto | 'all') =>\n [...integrationsQueryKeys.all, 'connections', workspaceId, capability] as const,\n // Prefix matching every per-capability connections query for a workspace, so\n // a mutation can refresh all connection views without touching providers or\n // repositories.\n connectionsByWorkspace: (workspaceId: string) =>\n [...integrationsQueryKeys.all, 'connections', workspaceId] as const,\n sourceConnections: (workspaceId: string) =>\n integrationsQueryKeys.connections(workspaceId, 'source_control'),\n repositories: (connectionId: string, search: string) =>\n [...integrationsQueryKeys.all, 'repositories', connectionId, search] as const,\n};\n\nexport async function listIntegrationProviders({\n capability,\n signal,\n}: {\n capability?: IntegrationCapabilityDto;\n signal?: AbortSignal;\n}) {\n const search = new URLSearchParams();\n if (capability) search.set('capability', capability);\n const query = search.toString();\n const path = query ? `/integration-providers?${query}` : '/integration-providers';\n return await apiRequest<ListIntegrationProvidersResponseDto>(path, {signal});\n}\n\nexport async function listIntegrationConnections({\n workspaceId,\n capability,\n signal,\n}: {\n workspaceId: string;\n capability?: IntegrationCapabilityDto | undefined;\n signal?: AbortSignal | undefined;\n}) {\n const search = new URLSearchParams({workspace_id: workspaceId});\n if (capability) search.set('capability', capability);\n return await apiRequest<ListIntegrationConnectionsResponseDto>(\n `/integration-connections?${search.toString()}`,\n {signal},\n );\n}\n\nexport async function listSourceConnections({\n workspaceId,\n signal,\n}: {\n workspaceId: string;\n signal?: AbortSignal;\n}) {\n const result = await listIntegrationConnections({\n workspaceId,\n capability: 'source_control',\n signal,\n });\n // The endpoint returns every lifecycle status (the settings hub needs that),\n // but source-control consumers (onboarding redirect, project creation) only\n // act on usable connections — a disabled/error one must read as \"not there\".\n return {\n ...result,\n connections: result.connections.filter(\n (connection) => connection.lifecycle_status === 'active',\n ),\n };\n}\n\nexport async function createGiteaConnection(body: CreateGiteaConnectionBodyDto) {\n return await apiRequest<CreateGiteaConnectionResponseDto>('/integrations/gitea/connections', {\n method: 'POST',\n body,\n });\n}\n\nexport async function createGithubInstall(body: CreateGithubInstallBodyDto) {\n return await apiRequest<CreateGithubInstallResponseDto>('/integrations/github/install', {\n method: 'POST',\n body,\n });\n}\n\nexport async function createSentryInstall(body: CreateSentryInstallBodyDto) {\n return await apiRequest<CreateSentryInstallResponseDto>('/integrations/sentry/install', {\n method: 'POST',\n body,\n });\n}\n\nexport async function createLinearInstall(body: CreateLinearInstallBodyDto) {\n return await apiRequest<CreateLinearInstallResponseDto>('/integrations/linear/install', {\n method: 'POST',\n body,\n });\n}\n\nexport async function createSlackInstall(body: CreateSlackInstallBodyDto) {\n return await apiRequest<CreateSlackInstallResponseDto>('/integrations/slack/install', {\n method: 'POST',\n body,\n });\n}\n\nexport async function completeLinearCallback({\n query,\n token,\n}: {\n query: LinearCallbackQueryDto;\n token: string;\n}) {\n return await apiRequest<LinearCallbackResponseDto>(\n `/integrations/linear/callback/api?${serializeLinearCallbackQuery(query)}`,\n {headers: {authorization: `Bearer ${token}`}},\n );\n}\n\nexport async function completeSlackCallback({\n query,\n token,\n}: {\n query: SlackCallbackQueryDto;\n token: string;\n}) {\n return await apiRequest<SlackCallbackResponseDto>(\n `/integrations/slack/callback/api?${serializeSlackCallbackQuery(query)}`,\n {headers: {authorization: `Bearer ${token}`}},\n );\n}\n\n// Called from the callback route with an explicit bearer (same as the GitHub\n// callback): the route refreshes auth itself before forwarding the grant code.\nexport async function connectSentry({body, token}: {body: SentryConnectBodyDto; token: string}) {\n return await apiRequest<SentryConnectResponseDto>('/integrations/sentry/connect', {\n method: 'POST',\n body,\n headers: {authorization: `Bearer ${token}`},\n });\n}\n\nexport async function listRepositories({\n connectionId,\n cursor,\n search,\n signal,\n}: {\n connectionId: string;\n cursor?: string;\n search?: string;\n signal?: AbortSignal;\n}) {\n const params = new URLSearchParams();\n if (cursor) params.set('cursor', cursor);\n if (search) params.set('search', search);\n const query = params.toString();\n const path = query\n ? `/integration-connections/${connectionId}/repositories?${query}`\n : `/integration-connections/${connectionId}/repositories`;\n return await apiRequest<ListRepositoriesResponseDto>(path, {signal});\n}\n\nexport async function updateIntegrationConnection({\n connectionId,\n body,\n}: {\n connectionId: string;\n body: UpdateIntegrationConnectionBodyDto;\n}) {\n return await apiRequest<IntegrationConnectionDto>(\n `/integration-connections/${encodeURIComponent(connectionId)}`,\n {method: 'PATCH', body},\n );\n}\n\nexport async function deleteIntegrationConnection({connectionId}: {connectionId: string}) {\n await apiRequest<void>(`/integration-connections/${encodeURIComponent(connectionId)}`, {\n method: 'DELETE',\n });\n}\n\nexport function useIntegrationProvidersQuery(params?: {capability?: IntegrationCapabilityDto}) {\n const capability = params?.capability;\n return useQuery({\n queryKey: integrationsQueryKeys.providers(capability ?? 'all'),\n queryFn: ({signal}) => listIntegrationProviders(capability ? {capability, signal} : {signal}),\n });\n}\n\nexport function useSourceConnectionsQuery(workspaceId: string | undefined) {\n return useQuery({\n queryKey: workspaceId\n ? integrationsQueryKeys.sourceConnections(workspaceId)\n : [...integrationsQueryKeys.all, 'source-connections'],\n enabled: Boolean(workspaceId),\n queryFn: ({signal}) => listSourceConnections({workspaceId: workspaceId ?? '', signal}),\n });\n}\n\nexport function useIntegrationConnectionsQuery(workspaceId: string | undefined) {\n return useQuery({\n queryKey: workspaceId\n ? integrationsQueryKeys.connections(workspaceId, 'all')\n : [...integrationsQueryKeys.all, 'connections'],\n enabled: Boolean(workspaceId),\n queryFn: ({signal}) => listIntegrationConnections({workspaceId: workspaceId ?? '', signal}),\n });\n}\n\nexport function useRepositoriesInfiniteQuery(\n connectionId: string | undefined,\n options?: {search?: string},\n) {\n const trimmedSearch = options?.search?.trim() ?? '';\n return useInfiniteQuery({\n queryKey: connectionId\n ? integrationsQueryKeys.repositories(connectionId, trimmedSearch)\n : [...integrationsQueryKeys.all, 'repositories'],\n enabled: Boolean(connectionId),\n initialPageParam: undefined as string | undefined,\n queryFn: ({pageParam, signal}) => {\n const args: {connectionId: string; cursor?: string; search?: string; signal: AbortSignal} = {\n connectionId: connectionId ?? '',\n signal,\n };\n if (pageParam) args.cursor = pageParam;\n if (trimmedSearch) args.search = trimmedSearch;\n return listRepositories(args);\n },\n getNextPageParam: (lastPage) => lastPage.next_cursor ?? undefined,\n });\n}\n\nexport function useCreateGiteaConnectionMutation() {\n return useMutation({mutationFn: createGiteaConnection});\n}\n\nexport function useCreateLinearInstallMutation() {\n return useMutation({mutationFn: createLinearInstall});\n}\n\nexport function useCreateSlackInstallMutation() {\n return useMutation({mutationFn: createSlackInstall});\n}\n\nexport function useCompleteLinearCallbackMutation() {\n return useMutation({mutationFn: completeLinearCallback});\n}\n\nexport function useCompleteSlackCallbackMutation() {\n return useMutation({mutationFn: completeSlackCallback});\n}\n\nexport function useUpdateIntegrationConnectionMutation() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: updateIntegrationConnection,\n onSuccess: async (connection) => {\n await queryClient.invalidateQueries({\n queryKey: integrationsQueryKeys.connectionsByWorkspace(connection.workspace_id),\n });\n },\n });\n}\n\nexport function useDeleteIntegrationConnectionMutation() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({\n workspaceId: _workspaceId,\n connectionId,\n }: {\n workspaceId: string;\n connectionId: string;\n }) => deleteIntegrationConnection({connectionId}),\n onSuccess: async (_result, variables) => {\n await queryClient.invalidateQueries({\n queryKey: integrationsQueryKeys.connectionsByWorkspace(variables.workspaceId),\n });\n },\n });\n}\n"],"names":["apiRequest","useInfiniteQuery","useMutation","useQuery","useQueryClient","serializeLinearCallbackQuery","serializeSlackCallbackQuery","integrationsQueryKeys","all","providers","capability","connections","workspaceId","connectionsByWorkspace","sourceConnections","repositories","connectionId","search","listIntegrationProviders","signal","URLSearchParams","set","query","toString","path","listIntegrationConnections","workspace_id","listSourceConnections","result","filter","connection","lifecycle_status","createGiteaConnection","body","method","createGithubInstall","createSentryInstall","createLinearInstall","createSlackInstall","completeLinearCallback","token","headers","authorization","completeSlackCallback","connectSentry","listRepositories","cursor","params","updateIntegrationConnection","encodeURIComponent","deleteIntegrationConnection","useIntegrationProvidersQuery","queryKey","queryFn","useSourceConnectionsQuery","enabled","Boolean","useIntegrationConnectionsQuery","useRepositoriesInfiniteQuery","options","trimmedSearch","trim","initialPageParam","undefined","pageParam","args","getNextPageParam","lastPage","next_cursor","useCreateGiteaConnectionMutation","mutationFn","useCreateLinearInstallMutation","useCreateSlackInstallMutation","useCompleteLinearCallbackMutation","useCompleteSlackCallbackMutation","useUpdateIntegrationConnectionMutation","queryClient","onSuccess","invalidateQueries","useDeleteIntegrationConnectionMutation","_workspaceId","_result","variables"],"mappings":"AAkCA,SAAQA,UAAU,QAAO,sBAAsB;AAC/C,SAAQC,gBAAgB,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,cAAc,QAAO,wBAAwB;AAC9F,SAAQC,4BAA4B,QAAO,sBAAsB;AACjE,SAAQC,2BAA2B,QAAO,qBAAqB;AAE/D,OAAO,MAAMC,wBAAwB;IACnCC,KAAK;QAAC;KAAe;IACrBC,WAAW,CAACC,aACV;eAAIH,sBAAsBC,GAAG;YAAE;YAAaE;SAAW;IACzDC,aAAa,CAACC,aAAqBF,aACjC;eAAIH,sBAAsBC,GAAG;YAAE;YAAeI;YAAaF;SAAW;IACxE,6EAA6E;IAC7E,4EAA4E;IAC5E,gBAAgB;IAChBG,wBAAwB,CAACD,cACvB;eAAIL,sBAAsBC,GAAG;YAAE;YAAeI;SAAY;IAC5DE,mBAAmB,CAACF,cAClBL,sBAAsBI,WAAW,CAACC,aAAa;IACjDG,cAAc,CAACC,cAAsBC,SACnC;eAAIV,sBAAsBC,GAAG;YAAE;YAAgBQ;YAAcC;SAAO;AACxE,EAAE;AAEF,OAAO,eAAeC,yBAAyB,EAC7CR,UAAU,EACVS,MAAM,EAIP;IACC,MAAMF,SAAS,IAAIG;IACnB,IAAIV,YAAYO,OAAOI,GAAG,CAAC,cAAcX;IACzC,MAAMY,QAAQL,OAAOM,QAAQ;IAC7B,MAAMC,OAAOF,QAAQ,CAAC,uBAAuB,EAAEA,OAAO,GAAG;IACzD,OAAO,MAAMtB,WAAgDwB,MAAM;QAACL;IAAM;AAC5E;AAEA,OAAO,eAAeM,2BAA2B,EAC/Cb,WAAW,EACXF,UAAU,EACVS,MAAM,EAKP;IACC,MAAMF,SAAS,IAAIG,gBAAgB;QAACM,cAA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AASM;IACd,OAAOnE,YAAY;QAACoE,YAAYtC;IAAqB;AACvD;AAEA,OAAO,SAASuC;IACd,OAAOrE,YAAY;QAACoE,YAAYjC;IAAmB;AACrD;AAEA,OAAO,SAASmC;IACd,OAAOtE,YAAY;QAACoE,YAAYhC;IAAkB;AACpD;AAEA,OAAO,SAASmC;IACd,OAAOvE,YAAY;QAACoE,YAAY/B;IAAsB;AACxD;AAEA,OAAO,SAASmC;IACd,OAAOxE,YAAY;QAACoE,YAAY3B;IAAqB;AACvD;AAEA,OAAO,SAASgC;IACd,MAAMC,cAAcxE;IACpB,OAAOF,YAAY;QACjBoE,YAAYtB;QACZ6B,WAAW,OAAO/C;YAChB,MAAM8C,YAAYE,iBAAiB,CAAC;gBAClC1B,UAAU7C,sBAAsBM,sBAAsB,CAACiB,WAAWJ,YAAY;YAChF;QACF;IACF;AACF;AAEA,OAAO,SAASqD;IACd,MAAMH,cAAcxE;IACpB,OAAOF,YAAY;QACjBoE,YAAY,CAAC,EACX1D,aAAaoE,YAAY,EACzBhE,YAAY,EAIb,GAAKkC,4BAA4B;gBAAClC;YAAY;QAC/C6D,WAAW,OAAOI,SAASC;YACzB,MAAMN,YAAYE,iBAAiB,CAAC;gBAClC1B,UAAU7C,sBAAsBM,sBAAsB,CAACqE,UAAUtE,WAAW;YAC9E;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/api/integrations.ts"],"sourcesContent":["import type {\n IntegrationCapabilityDto,\n UpdateIntegrationConnectionBodyDto,\n} from '@shipfox/api-integration-core-dto';\nimport {\n integrationConnectionDtoSchema,\n listIntegrationConnectionsResponseSchema,\n listIntegrationProvidersResponseSchema,\n listRepositoriesResponseSchema,\n} from '@shipfox/api-integration-core-dto';\nimport type {CreateGiteaConnectionBodyDto} from '@shipfox/api-integration-gitea-dto';\nimport {createGiteaConnectionResponseSchema} from '@shipfox/api-integration-gitea-dto';\nimport type {CreateGithubInstallBodyDto} from '@shipfox/api-integration-github-dto';\nimport {\n createGithubInstallResponseSchema,\n githubCallbackResponseSchema,\n} from '@shipfox/api-integration-github-dto';\nimport type {\n CreateLinearInstallBodyDto,\n LinearCallbackQueryDto,\n} from '@shipfox/api-integration-linear-dto';\nimport {\n createLinearInstallResponseSchema,\n linearCallbackResponseSchema,\n} from '@shipfox/api-integration-linear-dto';\nimport type {\n CreateSentryInstallBodyDto,\n SentryConnectBodyDto,\n} from '@shipfox/api-integration-sentry-dto';\nimport {\n createSentryInstallResponseSchema,\n sentryConnectResponseSchema,\n} from '@shipfox/api-integration-sentry-dto';\nimport type {\n CreateSlackInstallBodyDto,\n SlackCallbackQueryDto,\n} from '@shipfox/api-integration-slack-dto';\nimport {\n createSlackInstallResponseSchema,\n slackCallbackResponseSchema,\n} from '@shipfox/api-integration-slack-dto';\nimport {checkedApiRequest, emptyResponseSchema} from '@shipfox/client-api';\nimport {\n type FetchQueryOptions,\n type InfiniteData,\n infiniteQueryOptions,\n queryOptions,\n type UseInfiniteQueryOptions,\n useInfiniteQuery,\n useMutation,\n useQuery,\n useQueryClient,\n} from '@tanstack/react-query';\nimport {\n type InstallRedirect,\n type IntegrationConnection,\n type IntegrationProvider,\n isUsableConnection,\n type RepositoryPage,\n} from '#core/models.js';\nimport {serializeLinearCallbackQuery} from '#linear-callback.js';\nimport {serializeSlackCallbackQuery} from '#slack-callback.js';\nimport {\n toInstallRedirect,\n toIntegrationConnection,\n toIntegrationProvider,\n toRepository,\n} from './integration-mapper.js';\n\nexport const integrationsQueryKeys = {\n all: ['integrations'] as const,\n providers: (capability: IntegrationCapabilityDto | 'all') =>\n [...integrationsQueryKeys.all, 'providers', capability] as const,\n connections: (workspaceId: string, capability: IntegrationCapabilityDto | 'all') =>\n [...integrationsQueryKeys.all, 'connections', workspaceId, capability] as const,\n // Prefix matching every per-capability connections query for a workspace, so\n // a mutation can refresh all connection views without touching providers or\n // repositories.\n connectionsByWorkspace: (workspaceId: string) =>\n [...integrationsQueryKeys.all, 'connections', workspaceId] as const,\n sourceConnections: (workspaceId: string) =>\n integrationsQueryKeys.connections(workspaceId, 'source_control'),\n repositories: (connectionId: string, search: string) =>\n [...integrationsQueryKeys.all, 'repositories', connectionId, search] as const,\n};\n\ntype SourceConnectionsQueryKey =\n | ReturnType<typeof integrationsQueryKeys.sourceConnections>\n | readonly ['integrations', 'source-connections'];\n\ntype SourceConnectionsQueryOptions = FetchQueryOptions<\n IntegrationConnection[],\n Error,\n IntegrationConnection[],\n SourceConnectionsQueryKey\n>;\n\ntype ProvidersQueryKey = ReturnType<typeof integrationsQueryKeys.providers>;\n\ntype ProvidersQueryOptions = FetchQueryOptions<\n IntegrationProvider[],\n Error,\n IntegrationProvider[],\n ProvidersQueryKey\n>;\n\ntype ConnectionsQueryKey =\n | ReturnType<typeof integrationsQueryKeys.connections>\n | readonly ['integrations', 'connections'];\n\ntype ConnectionsQueryOptions = FetchQueryOptions<\n IntegrationConnection[],\n Error,\n IntegrationConnection[],\n ConnectionsQueryKey\n>;\n\ntype RepositoriesQueryKey =\n | ReturnType<typeof integrationsQueryKeys.repositories>\n | readonly ['integrations', 'repositories'];\n\ntype RepositoriesInfiniteQueryOptions = UseInfiniteQueryOptions<\n RepositoryPage,\n Error,\n InfiniteData<RepositoryPage, string | undefined>,\n RepositoriesQueryKey,\n string | undefined\n>;\n\nexport async function listIntegrationProviders({\n capability,\n signal,\n}: {\n capability?: IntegrationCapabilityDto;\n signal?: AbortSignal;\n}): Promise<IntegrationProvider[]> {\n const search = new URLSearchParams();\n if (capability) search.set('capability', capability);\n const query = search.toString();\n const path = query ? `/integration-providers?${query}` : '/integration-providers';\n const response = await checkedApiRequest(listIntegrationProvidersResponseSchema, path, {signal});\n return response.providers.map(toIntegrationProvider);\n}\n\nexport async function listIntegrationConnections({\n workspaceId,\n capability,\n signal,\n}: {\n workspaceId: string;\n capability?: IntegrationCapabilityDto | undefined;\n signal?: AbortSignal | undefined;\n}): Promise<IntegrationConnection[]> {\n const search = new URLSearchParams({workspace_id: workspaceId});\n if (capability) search.set('capability', capability);\n const response = await checkedApiRequest(\n listIntegrationConnectionsResponseSchema,\n `/integration-connections?${search.toString()}`,\n {signal},\n );\n return response.connections.map(toIntegrationConnection);\n}\n\nexport async function listSourceConnections({\n workspaceId,\n signal,\n}: {\n workspaceId: string;\n signal?: AbortSignal;\n}): Promise<IntegrationConnection[]> {\n const connections = await listIntegrationConnections({\n workspaceId,\n capability: 'source_control',\n signal,\n });\n // The endpoint returns every lifecycle status (the settings hub needs that),\n // but source-control consumers (onboarding redirect, project creation) only\n // act on usable connections — a disabled/error one must read as \"not there\".\n return connections.filter(isUsableConnection);\n}\n\nexport function sourceConnectionsQueryOptions(\n workspaceId: string | undefined,\n): SourceConnectionsQueryOptions {\n return queryOptions({\n queryKey: workspaceId\n ? integrationsQueryKeys.sourceConnections(workspaceId)\n : ([...integrationsQueryKeys.all, 'source-connections'] as const),\n enabled: Boolean(workspaceId),\n queryFn: ({signal}) => listSourceConnections({workspaceId: workspaceId ?? '', signal}),\n });\n}\n\nexport async function createGiteaConnection(\n body: CreateGiteaConnectionBodyDto,\n): Promise<IntegrationConnection> {\n const response = await checkedApiRequest(\n createGiteaConnectionResponseSchema,\n '/integrations/gitea/connections',\n {\n method: 'POST',\n body,\n },\n );\n return toIntegrationConnection(response);\n}\n\nexport async function createGithubInstall(\n body: CreateGithubInstallBodyDto,\n): Promise<InstallRedirect> {\n return toInstallRedirect(\n await checkedApiRequest(createGithubInstallResponseSchema, '/integrations/github/install', {\n method: 'POST',\n body,\n }),\n );\n}\n\nexport async function completeGithubCallback({\n code,\n installationId,\n state,\n setupAction,\n token,\n}: {\n code: string;\n installationId: number;\n state: string;\n setupAction?: string;\n token: string;\n}): Promise<IntegrationConnection> {\n const query = new URLSearchParams({code, installation_id: String(installationId), state});\n if (setupAction) query.set('setup_action', setupAction);\n const response = await checkedApiRequest(\n githubCallbackResponseSchema,\n `/integrations/github/callback/api?${query.toString()}`,\n {headers: {authorization: `Bearer ${token}`}},\n );\n return toIntegrationConnection(response);\n}\n\nexport async function createSentryInstall(\n body: CreateSentryInstallBodyDto,\n): Promise<InstallRedirect> {\n return toInstallRedirect(\n await checkedApiRequest(createSentryInstallResponseSchema, '/integrations/sentry/install', {\n method: 'POST',\n body,\n }),\n );\n}\n\nexport async function createLinearInstall(\n body: CreateLinearInstallBodyDto,\n): Promise<InstallRedirect> {\n return toInstallRedirect(\n await checkedApiRequest(createLinearInstallResponseSchema, '/integrations/linear/install', {\n method: 'POST',\n body,\n }),\n );\n}\n\nexport async function createSlackInstall(\n body: CreateSlackInstallBodyDto,\n): Promise<InstallRedirect> {\n return toInstallRedirect(\n await checkedApiRequest(createSlackInstallResponseSchema, '/integrations/slack/install', {\n method: 'POST',\n body,\n }),\n );\n}\n\nexport async function completeLinearCallback({\n query,\n token,\n}: {\n query: LinearCallbackQueryDto;\n token: string;\n}): Promise<IntegrationConnection> {\n const response = await checkedApiRequest(\n linearCallbackResponseSchema,\n `/integrations/linear/callback/api?${serializeLinearCallbackQuery(query)}`,\n {headers: {authorization: `Bearer ${token}`}},\n );\n return toIntegrationConnection(response);\n}\n\nexport async function completeSlackCallback({\n query,\n token,\n}: {\n query: SlackCallbackQueryDto;\n token: string;\n}): Promise<IntegrationConnection> {\n const response = await checkedApiRequest(\n slackCallbackResponseSchema,\n `/integrations/slack/callback/api?${serializeSlackCallbackQuery(query)}`,\n {headers: {authorization: `Bearer ${token}`}},\n );\n return toIntegrationConnection(response);\n}\n\n// Called from the callback route with an explicit bearer (same as the GitHub\n// callback): the route refreshes auth itself before forwarding the grant code.\nexport async function connectSentry({body, token}: {body: SentryConnectBodyDto; token: string}) {\n const response = await checkedApiRequest(\n sentryConnectResponseSchema,\n '/integrations/sentry/connect',\n {\n method: 'POST',\n body,\n headers: {authorization: `Bearer ${token}`},\n },\n );\n return toIntegrationConnection(response);\n}\n\nexport async function listRepositories({\n connectionId,\n cursor,\n search,\n signal,\n}: {\n connectionId: string;\n cursor?: string;\n search?: string;\n signal?: AbortSignal;\n}): Promise<RepositoryPage> {\n const params = new URLSearchParams();\n if (cursor) params.set('cursor', cursor);\n if (search) params.set('search', search);\n const query = params.toString();\n const path = query\n ? `/integration-connections/${connectionId}/repositories?${query}`\n : `/integration-connections/${connectionId}/repositories`;\n const response = await checkedApiRequest(listRepositoriesResponseSchema, path, {signal});\n return {\n repositories: response.repositories.map(toRepository),\n ...(response.next_cursor == null ? {} : {nextCursor: response.next_cursor}),\n };\n}\n\nexport async function updateIntegrationConnection({\n connectionId,\n body,\n}: {\n connectionId: string;\n body: UpdateIntegrationConnectionBodyDto;\n}): Promise<IntegrationConnection> {\n const response = await checkedApiRequest(\n integrationConnectionDtoSchema,\n `/integration-connections/${encodeURIComponent(connectionId)}`,\n {method: 'PATCH', body},\n );\n return toIntegrationConnection(response);\n}\n\nexport async function deleteIntegrationConnection({connectionId}: {connectionId: string}) {\n await checkedApiRequest(\n emptyResponseSchema,\n `/integration-connections/${encodeURIComponent(connectionId)}`,\n {\n method: 'DELETE',\n },\n );\n}\n\nexport function useIntegrationProvidersQuery(params?: {capability?: IntegrationCapabilityDto}) {\n return useQuery(integrationProvidersQueryOptions(params?.capability));\n}\n\nexport function integrationProvidersQueryOptions(\n capability?: IntegrationCapabilityDto,\n): ProvidersQueryOptions {\n return queryOptions({\n queryKey: integrationsQueryKeys.providers(capability ?? 'all'),\n queryFn: ({signal}) => listIntegrationProviders(capability ? {capability, signal} : {signal}),\n });\n}\n\nexport function useSourceConnectionsQuery(workspaceId: string | undefined) {\n return useQuery(sourceConnectionsQueryOptions(workspaceId));\n}\n\nexport function useIntegrationConnectionsQuery(workspaceId: string | undefined) {\n return useQuery(integrationConnectionsQueryOptions(workspaceId));\n}\n\nexport function integrationConnectionsQueryOptions(\n workspaceId: string | undefined,\n): ConnectionsQueryOptions {\n return queryOptions({\n queryKey: workspaceId\n ? integrationsQueryKeys.connections(workspaceId, 'all')\n : ([...integrationsQueryKeys.all, 'connections'] as const),\n enabled: Boolean(workspaceId),\n queryFn: ({signal}) => listIntegrationConnections({workspaceId: workspaceId ?? '', signal}),\n });\n}\n\nexport function repositoriesInfiniteQueryOptions(\n connectionId: string | undefined,\n options?: {search?: string},\n): RepositoriesInfiniteQueryOptions {\n const trimmedSearch = options?.search?.trim() ?? '';\n return infiniteQueryOptions({\n queryKey: connectionId\n ? integrationsQueryKeys.repositories(connectionId, trimmedSearch)\n : ([...integrationsQueryKeys.all, 'repositories'] as const),\n enabled: Boolean(connectionId),\n initialPageParam: undefined as string | undefined,\n queryFn: ({pageParam, signal}) => {\n const args: {connectionId: string; cursor?: string; search?: string; signal: AbortSignal} = {\n connectionId: connectionId ?? '',\n signal,\n };\n if (pageParam) args.cursor = pageParam;\n if (trimmedSearch) args.search = trimmedSearch;\n return listRepositories(args);\n },\n getNextPageParam: (lastPage) => lastPage.nextCursor,\n });\n}\n\nexport function useRepositoriesInfiniteQuery(\n connectionId: string | undefined,\n options?: {search?: string},\n) {\n return useInfiniteQuery(repositoriesInfiniteQueryOptions(connectionId, options));\n}\n\nexport function useCreateGiteaConnectionMutation() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: createGiteaConnection,\n onSuccess: async (connection) => {\n await queryClient.invalidateQueries({\n queryKey: integrationsQueryKeys.connectionsByWorkspace(connection.workspaceId),\n refetchType: 'all',\n });\n },\n });\n}\n\nexport function useCreateLinearInstallMutation() {\n return useMutation({mutationFn: createLinearInstall});\n}\n\nexport function useCreateSlackInstallMutation() {\n return useMutation({mutationFn: createSlackInstall});\n}\n\nexport function useCompleteLinearCallbackMutation() {\n return useMutation({mutationFn: completeLinearCallback});\n}\n\nexport function useCompleteSlackCallbackMutation() {\n return useMutation({mutationFn: completeSlackCallback});\n}\n\nexport function useUpdateIntegrationConnectionMutation() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: updateIntegrationConnection,\n onSuccess: async (connection) => {\n await queryClient.invalidateQueries({\n queryKey: integrationsQueryKeys.connectionsByWorkspace(connection.workspaceId),\n });\n },\n });\n}\n\nexport function useDeleteIntegrationConnectionMutation() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({\n workspaceId: _workspaceId,\n connectionId,\n }: {\n workspaceId: string;\n connectionId: string;\n }) => deleteIntegrationConnection({connectionId}),\n onSuccess: async (_result, variables) => {\n await queryClient.invalidateQueries({\n queryKey: integrationsQueryKeys.connectionsByWorkspace(variables.workspaceId),\n });\n },\n });\n}\n"],"names":["integrationConnectionDtoSchema","listIntegrationConnectionsResponseSchema","listIntegrationProvidersResponseSchema","listRepositoriesResponseSchema","createGiteaConnectionResponseSchema","createGithubInstallResponseSchema","githubCallbackResponseSchema","createLinearInstallResponseSchema","linearCallbackResponseSchema","createSentryInstallResponseSchema","sentryConnectResponseSchema","createSlackInstallResponseSchema","slackCallbackResponseSchema","checkedApiRequest","emptyResponseSchema","infiniteQueryOptions","queryOptions","useInfiniteQuery","useMutation","useQuery","useQueryClient","isUsableConnection","serializeLinearCallbackQuery","serializeSlackCallbackQuery","toInstallRedirect","toIntegrationConnection","toIntegrationProvider","toRepository","integrationsQueryKeys","all","providers","capability","connections","workspaceId","connectionsByWorkspace","sourceConnections","repositories","connectionId","search","listIntegrationProviders","signal","URLSearchParams","set","query","toString","path","response","map","listIntegrationConnections","workspace_id","listSourceConnections","filter","sourceConnectionsQueryOptions","queryKey","enabled","Boolean","queryFn","createGiteaConnection","body","method","createGithubInstall","completeGithubCallback","code","installationId","state","setupAction","token","installation_id","String","headers","authorization","createSentryInstall","createLinearInstall","createSlackInstall","completeLinearCallback","completeSlackCallback","connectSentry","listRepositories","cursor","params","next_cursor","nextCursor","updateIntegrationConnection","encodeURIComponent","deleteIntegrationConnection","useIntegrationProvidersQuery","integrationProvidersQueryOptions","useSourceConnectionsQuery","useIntegrationConnectionsQuery","integrationConnectionsQueryOptions","repositoriesInfiniteQueryOptions","options","trimmedSearch","trim","initialPageParam","undefined","pageParam","args","getNextPageParam","lastPage","useRepositoriesInfiniteQuery","useCreateGiteaConnectionMutation","queryClient","mutationFn","onSuccess","connection","invalidateQueries","refetchType","useCreateLinearInstallMutation","useCreateSlackInstallMutation","useCompleteLinearCallbackMutation","useCompleteSlackCallbackMutation","useUpdateIntegrationConnectionMutation","useDeleteIntegrationConnectionMutation","_workspaceId","_result","variables"],"mappings":"AAIA,SACEA,8BAA8B,EAC9BC,wCAAwC,EACxCC,sCAAsC,EACtCC,8BAA8B,QACzB,oCAAoC;AAE3C,SAAQC,mCAAmC,QAAO,qCAAqC;AAEvF,SACEC,iCAAiC,EACjCC,4BAA4B,QACvB,sCAAsC;AAK7C,SACEC,iCAAiC,EACjCC,4BAA4B,QACvB,sCAAsC;AAK7C,SACEC,iCAAiC,EACjCC,2BAA2B,QACtB,sCAAsC;AAK7C,SACEC,gCAAgC,EAChCC,2BAA2B,QACtB,qCAAqC;AAC5C,SAAQC,iBAAiB,EAAEC,mBAAmB,QAAO,sBAAsB;AAC3E,SAGEC,oBAAoB,EACpBC,YAAY,EAEZC,gBAAgB,EAChBC,WAAW,EACXC,QAAQ,EACRC,cAAc,QACT,wBAAwB;AAC/B,SAIEC,kBAAkB,QAEb,kBAAkB;AACzB,SAAQC,4BAA4B,QAAO,sBAAsB;AACjE,SAAQC,2BAA2B,QAAO,qBAAqB;AAC/D,SACEC,iBAAiB,EACjBC,uBAAuB,EACvBC,qBAAqB,EACrBC,YAAY,QACP,0BAA0B;AAEjC,OAAO,MAAMC,wBAAwB;IACnCC,KAAK;QAAC;KAAe;IACrBC,WAAW,CAACC,aACV;eAAIH,sBAAsBC,GAAG;YAAE;YAAaE;SAAW;IACzDC,aAAa,CAACC,aAAqBF,aACjC;eAAIH,sBAAsBC,GAAG;YAAE;YAAeI;YAAaF;SAAW;IACxE,6EAA6E;IAC7E,4EAA4E;IAC5E,gBAAgB;IAChBG,wBAAwB,CAACD,cACvB;eAAIL,sBAAsBC,GAAG;YAAE;YAAeI;SAAY;IAC5DE,mBAAmB,CAACF,cAClBL,sBAAsBI,WAAW,CAACC,aAAa;IACjDG,cAAc,CAACC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F,YAAY,CAAC,EACXtE,aAAaiF,YAAY,EACzB7E,YAAY,EAIb,GAAK+C,4BAA4B;gBAAC/C;YAAY;QAC/CmE,WAAW,OAAOW,SAASC;YACzB,MAAMd,YAAYI,iBAAiB,CAAC;gBAClCrD,UAAUzB,sBAAsBM,sBAAsB,CAACkF,UAAUnF,WAAW;YAC9E;QACF;IACF;AACF"}
|
|
@@ -1,85 +1,32 @@
|
|
|
1
1
|
import type { CreateWebhookConnectionBodyDto, UpdateWebhookConnectionBodyDto } from '@shipfox/api-integration-webhook-dto';
|
|
2
|
+
import { type FetchQueryOptions } from '@tanstack/react-query';
|
|
3
|
+
import type { WebhookConnection } from '#core/models.js';
|
|
2
4
|
export declare const webhookConnectionsQueryKeys: {
|
|
3
5
|
all: readonly ["webhook-connections"];
|
|
4
6
|
list: (workspaceId: string) => readonly ["webhook-connections", "list", string];
|
|
5
7
|
};
|
|
8
|
+
type WebhookConnectionsListQueryKey = ReturnType<typeof webhookConnectionsQueryKeys.list> | readonly ['webhook-connections', 'list'];
|
|
9
|
+
type WebhookConnectionsListQueryOptions = FetchQueryOptions<WebhookConnection[], Error, WebhookConnection[], WebhookConnectionsListQueryKey>;
|
|
6
10
|
export declare function listWebhookConnections({ workspaceId, signal, }: {
|
|
7
11
|
workspaceId: string;
|
|
8
12
|
signal?: AbortSignal;
|
|
9
|
-
}): Promise<
|
|
10
|
-
|
|
11
|
-
id: string;
|
|
12
|
-
workspace_id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
slug: string;
|
|
15
|
-
lifecycle_status: "error" | "active" | "disabled";
|
|
16
|
-
inbound_url: string;
|
|
17
|
-
created_at: string;
|
|
18
|
-
updated_at: string;
|
|
19
|
-
}[];
|
|
20
|
-
}>;
|
|
21
|
-
export declare function createWebhookConnection(body: CreateWebhookConnectionBodyDto): Promise<{
|
|
22
|
-
id: string;
|
|
23
|
-
workspace_id: string;
|
|
24
|
-
name: string;
|
|
25
|
-
slug: string;
|
|
26
|
-
lifecycle_status: "error" | "active" | "disabled";
|
|
27
|
-
inbound_url: string;
|
|
28
|
-
created_at: string;
|
|
29
|
-
updated_at: string;
|
|
30
|
-
}>;
|
|
13
|
+
}): Promise<WebhookConnection[]>;
|
|
14
|
+
export declare function createWebhookConnection(body: CreateWebhookConnectionBodyDto): Promise<WebhookConnection>;
|
|
31
15
|
export declare function updateWebhookConnection({ connectionId, body, }: {
|
|
32
16
|
connectionId: string;
|
|
33
17
|
body: UpdateWebhookConnectionBodyDto;
|
|
34
|
-
}): Promise<
|
|
35
|
-
id: string;
|
|
36
|
-
workspace_id: string;
|
|
37
|
-
name: string;
|
|
38
|
-
slug: string;
|
|
39
|
-
lifecycle_status: "error" | "active" | "disabled";
|
|
40
|
-
inbound_url: string;
|
|
41
|
-
created_at: string;
|
|
42
|
-
updated_at: string;
|
|
43
|
-
}>;
|
|
18
|
+
}): Promise<WebhookConnection>;
|
|
44
19
|
export declare function deleteWebhookConnection({ connectionId }: {
|
|
45
20
|
connectionId: string;
|
|
46
21
|
}): Promise<void>;
|
|
47
|
-
export declare function useWebhookConnectionsQuery(workspaceId: string | undefined): import("@tanstack/react-query").UseQueryResult<NoInfer<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
workspace_id: string;
|
|
51
|
-
name: string;
|
|
52
|
-
slug: string;
|
|
53
|
-
lifecycle_status: "error" | "active" | "disabled";
|
|
54
|
-
inbound_url: string;
|
|
55
|
-
created_at: string;
|
|
56
|
-
updated_at: string;
|
|
57
|
-
}[];
|
|
58
|
-
}>, Error>;
|
|
59
|
-
export declare function useCreateWebhookConnectionMutation(): import("@tanstack/react-query").UseMutationResult<{
|
|
60
|
-
id: string;
|
|
61
|
-
workspace_id: string;
|
|
62
|
-
name: string;
|
|
63
|
-
slug: string;
|
|
64
|
-
lifecycle_status: "error" | "active" | "disabled";
|
|
65
|
-
inbound_url: string;
|
|
66
|
-
created_at: string;
|
|
67
|
-
updated_at: string;
|
|
68
|
-
}, Error, {
|
|
22
|
+
export declare function useWebhookConnectionsQuery(workspaceId: string | undefined): import("@tanstack/react-query").UseQueryResult<NoInfer<WebhookConnection[]>, Error>;
|
|
23
|
+
export declare function webhookConnectionsQueryOptions(workspaceId: string | undefined): WebhookConnectionsListQueryOptions;
|
|
24
|
+
export declare function useCreateWebhookConnectionMutation(): import("@tanstack/react-query").UseMutationResult<WebhookConnection, Error, {
|
|
69
25
|
workspace_id: string;
|
|
70
26
|
name: string;
|
|
71
27
|
slug: string;
|
|
72
28
|
}, unknown>;
|
|
73
|
-
export declare function useUpdateWebhookConnectionMutation(): import("@tanstack/react-query").UseMutationResult<{
|
|
74
|
-
id: string;
|
|
75
|
-
workspace_id: string;
|
|
76
|
-
name: string;
|
|
77
|
-
slug: string;
|
|
78
|
-
lifecycle_status: "error" | "active" | "disabled";
|
|
79
|
-
inbound_url: string;
|
|
80
|
-
created_at: string;
|
|
81
|
-
updated_at: string;
|
|
82
|
-
}, Error, {
|
|
29
|
+
export declare function useUpdateWebhookConnectionMutation(): import("@tanstack/react-query").UseMutationResult<WebhookConnection, Error, {
|
|
83
30
|
workspaceId: string;
|
|
84
31
|
connectionId: string;
|
|
85
32
|
body: UpdateWebhookConnectionBodyDto;
|
|
@@ -88,4 +35,5 @@ export declare function useDeleteWebhookConnectionMutation(): import("@tanstack/
|
|
|
88
35
|
workspaceId: string;
|
|
89
36
|
connectionId: string;
|
|
90
37
|
}, unknown>;
|
|
38
|
+
export {};
|
|
91
39
|
//# sourceMappingURL=webhook-connections.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-connections.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/webhook-connections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8BAA8B,
|
|
1
|
+
{"version":3,"file":"webhook-connections.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/webhook-connections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8BAA8B,EAC9B,8BAA8B,EAC/B,MAAM,sCA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
+
import { listWebhookConnectionsResponseSchema, webhookConnectionDtoSchema } from '@shipfox/api-integration-webhook-dto';
|
|
2
|
+
import { checkedApiRequest, emptyResponseSchema } from '@shipfox/client-api';
|
|
3
|
+
import { queryOptions, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { toWebhookConnection } from './integration-mapper.js';
|
|
3
5
|
import { integrationsQueryKeys } from './integrations.js';
|
|
4
6
|
export const webhookConnectionsQueryKeys = {
|
|
5
7
|
all: [
|
|
@@ -15,29 +17,35 @@ export async function listWebhookConnections({ workspaceId, signal }) {
|
|
|
15
17
|
const search = new URLSearchParams({
|
|
16
18
|
workspace_id: workspaceId
|
|
17
19
|
});
|
|
18
|
-
|
|
20
|
+
const response = await checkedApiRequest(listWebhookConnectionsResponseSchema, `/integrations/webhook/connections?${search.toString()}`, {
|
|
19
21
|
signal
|
|
20
22
|
});
|
|
23
|
+
return response.connections.map(toWebhookConnection);
|
|
21
24
|
}
|
|
22
25
|
export async function createWebhookConnection(body) {
|
|
23
|
-
|
|
26
|
+
const response = await checkedApiRequest(webhookConnectionDtoSchema, '/integrations/webhook/connections', {
|
|
24
27
|
method: 'POST',
|
|
25
28
|
body
|
|
26
29
|
});
|
|
30
|
+
return toWebhookConnection(response);
|
|
27
31
|
}
|
|
28
32
|
export async function updateWebhookConnection({ connectionId, body }) {
|
|
29
|
-
|
|
33
|
+
const response = await checkedApiRequest(webhookConnectionDtoSchema, `/integrations/webhook/connections/${encodeURIComponent(connectionId)}`, {
|
|
30
34
|
method: 'PATCH',
|
|
31
35
|
body
|
|
32
36
|
});
|
|
37
|
+
return toWebhookConnection(response);
|
|
33
38
|
}
|
|
34
39
|
export async function deleteWebhookConnection({ connectionId }) {
|
|
35
|
-
await
|
|
40
|
+
await checkedApiRequest(emptyResponseSchema, `/integrations/webhook/connections/${encodeURIComponent(connectionId)}`, {
|
|
36
41
|
method: 'DELETE'
|
|
37
42
|
});
|
|
38
43
|
}
|
|
39
44
|
export function useWebhookConnectionsQuery(workspaceId) {
|
|
40
|
-
return useQuery(
|
|
45
|
+
return useQuery(webhookConnectionsQueryOptions(workspaceId));
|
|
46
|
+
}
|
|
47
|
+
export function webhookConnectionsQueryOptions(workspaceId) {
|
|
48
|
+
return queryOptions({
|
|
41
49
|
queryKey: workspaceId ? webhookConnectionsQueryKeys.list(workspaceId) : [
|
|
42
50
|
...webhookConnectionsQueryKeys.all,
|
|
43
51
|
'list'
|
|
@@ -54,7 +62,7 @@ export function useCreateWebhookConnectionMutation() {
|
|
|
54
62
|
return useMutation({
|
|
55
63
|
mutationFn: createWebhookConnection,
|
|
56
64
|
onSuccess: async (connection)=>{
|
|
57
|
-
await invalidateWebhookConnectionViews(queryClient, connection.
|
|
65
|
+
await invalidateWebhookConnectionViews(queryClient, connection.workspaceId);
|
|
58
66
|
}
|
|
59
67
|
});
|
|
60
68
|
}
|
|
@@ -66,7 +74,7 @@ export function useUpdateWebhookConnectionMutation() {
|
|
|
66
74
|
body
|
|
67
75
|
}),
|
|
68
76
|
onSuccess: async (connection)=>{
|
|
69
|
-
await invalidateWebhookConnectionViews(queryClient, connection.
|
|
77
|
+
await invalidateWebhookConnectionViews(queryClient, connection.workspaceId);
|
|
70
78
|
}
|
|
71
79
|
});
|
|
72
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/api/webhook-connections.ts"],"sourcesContent":["import type {\n CreateWebhookConnectionBodyDto,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/api/webhook-connections.ts"],"sourcesContent":["import type {\n CreateWebhookConnectionBodyDto,\n UpdateWebhookConnectionBodyDto,\n} from '@shipfox/api-integration-webhook-dto';\nimport {\n listWebhookConnectionsResponseSchema,\n webhookConnectionDtoSchema,\n} from '@shipfox/api-integration-webhook-dto';\nimport {checkedApiRequest, emptyResponseSchema} from '@shipfox/client-api';\nimport {\n type FetchQueryOptions,\n type QueryClient,\n queryOptions,\n useMutation,\n useQuery,\n useQueryClient,\n} from '@tanstack/react-query';\nimport type {WebhookConnection} from '#core/models.js';\nimport {toWebhookConnection} from './integration-mapper.js';\nimport {integrationsQueryKeys} from './integrations.js';\n\nexport const webhookConnectionsQueryKeys = {\n all: ['webhook-connections'] as const,\n list: (workspaceId: string) => [...webhookConnectionsQueryKeys.all, 'list', workspaceId] as const,\n};\n\ntype WebhookConnectionsListQueryKey =\n | ReturnType<typeof webhookConnectionsQueryKeys.list>\n | readonly ['webhook-connections', 'list'];\n\ntype WebhookConnectionsListQueryOptions = FetchQueryOptions<\n WebhookConnection[],\n Error,\n WebhookConnection[],\n WebhookConnectionsListQueryKey\n>;\n\nexport async function listWebhookConnections({\n workspaceId,\n signal,\n}: {\n workspaceId: string;\n signal?: AbortSignal;\n}) {\n const search = new URLSearchParams({workspace_id: workspaceId});\n const response = await checkedApiRequest(\n listWebhookConnectionsResponseSchema,\n `/integrations/webhook/connections?${search.toString()}`,\n {signal},\n );\n return response.connections.map(toWebhookConnection);\n}\n\nexport async function createWebhookConnection(body: CreateWebhookConnectionBodyDto) {\n const response = await checkedApiRequest(\n webhookConnectionDtoSchema,\n '/integrations/webhook/connections',\n {\n method: 'POST',\n body,\n },\n );\n return toWebhookConnection(response);\n}\n\nexport async function updateWebhookConnection({\n connectionId,\n body,\n}: {\n connectionId: string;\n body: UpdateWebhookConnectionBodyDto;\n}) {\n const response = await checkedApiRequest(\n webhookConnectionDtoSchema,\n `/integrations/webhook/connections/${encodeURIComponent(connectionId)}`,\n {method: 'PATCH', body},\n );\n return toWebhookConnection(response);\n}\n\nexport async function deleteWebhookConnection({connectionId}: {connectionId: string}) {\n await checkedApiRequest(\n emptyResponseSchema,\n `/integrations/webhook/connections/${encodeURIComponent(connectionId)}`,\n {\n method: 'DELETE',\n },\n );\n}\n\nexport function useWebhookConnectionsQuery(workspaceId: string | undefined) {\n return useQuery(webhookConnectionsQueryOptions(workspaceId));\n}\n\nexport function webhookConnectionsQueryOptions(\n workspaceId: string | undefined,\n): WebhookConnectionsListQueryOptions {\n return queryOptions({\n queryKey: workspaceId\n ? webhookConnectionsQueryKeys.list(workspaceId)\n : ([...webhookConnectionsQueryKeys.all, 'list'] as const),\n enabled: Boolean(workspaceId),\n queryFn: ({signal}) => listWebhookConnections({workspaceId: workspaceId ?? '', signal}),\n });\n}\n\nexport function useCreateWebhookConnectionMutation() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: createWebhookConnection,\n onSuccess: async (connection) => {\n await invalidateWebhookConnectionViews(queryClient, connection.workspaceId);\n },\n });\n}\n\nexport function useUpdateWebhookConnectionMutation() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({\n connectionId,\n body,\n }: {\n workspaceId: string;\n connectionId: string;\n body: UpdateWebhookConnectionBodyDto;\n }) => updateWebhookConnection({connectionId, body}),\n onSuccess: async (connection) => {\n await invalidateWebhookConnectionViews(queryClient, connection.workspaceId);\n },\n });\n}\n\nexport function useDeleteWebhookConnectionMutation() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({connectionId}: {workspaceId: string; connectionId: string}) =>\n deleteWebhookConnection({connectionId}),\n onSuccess: async (_result, variables) => {\n await invalidateWebhookConnectionViews(queryClient, variables.workspaceId);\n },\n });\n}\n\nasync function invalidateWebhookConnectionViews(queryClient: QueryClient, workspaceId: string) {\n await Promise.all([\n queryClient.invalidateQueries({\n queryKey: webhookConnectionsQueryKeys.list(workspaceId),\n refetchType: 'all',\n }),\n queryClient.invalidateQueries({\n queryKey: integrationsQueryKeys.connectionsByWorkspace(workspaceId),\n refetchType: 'all',\n }),\n ]);\n}\n"],"names":["listWebhookConnectionsResponseSchema","webhookConnectionDtoSchema","checkedApiRequest","emptyResponseSchema","queryOptions","useMutation","useQuery","useQueryClient","toWebhookConnection","integrationsQueryKeys","webhookConnectionsQueryKeys","all","list","workspaceId","listWebhookConnections","signal","search","URLSearchParams","workspace_id","response","toString","connections","map","createWebhookConnection","body","method","updateWebhookConnection","connectionId","encodeURIComponent","deleteWebhookConnection","useWebhookConnectionsQuery","webhookConnectionsQueryOptions","queryKey","enabled","Boolean","queryFn","useCreateWebhookConnectionMutation","queryClient","mutationFn","onSuccess","connection","invalidateWebhookConnectionViews","useUpdateWebhookConnectionMutation","useDeleteWebhookConnectionMutation","_result","variables","Promise","invalidateQueries","refetchType","connectionsByWorkspace"],"mappings":"AAIA,SACEA,oCAAoC,EACpCC,0BAA0B,QACrB,uCAAuC;AAC9C,SAAQC,iBAAiB,EAAEC,mBAAmB,QAAO,sBAAsB;AAC3E,SAGEC,YAAY,EACZC,WAAW,EACXC,QAAQ,EACRC,cAAc,QACT,wBAAwB;AAE/B,SAAQC,mBAAmB,QAAO,0BAA0B;AAC5D,SAAQC,qBAAqB,QAAO,oBAAoB;AAExD,OAAO,MAAMC,8BAA8B;IACzCC,KAAK;QAAC;KAAsB;IAC5BC,MAAM,CAACC,cAAwB;eAAIH,4BAA4BC,GAAG;YAAE;YAAQE;SAAY;AAC1F,EAAE;AAaF,OAAO,eAAeC,uBAAuB,EAC3CD,WAAW,EACXE,MAAM,EAIP;IACC,MAAMC,SAAS,IAAIC,gBAAgB;QAACC,cAAcL;IAAW;IAC7D,MAAMM,WAAW,MAAMjB,kBACrBF,sCACA,CAAC,kCAAkC,EAAEgB,OAAOI,QAAQ,IAAI,EACxD;QAACL;IAAM;IAET,OAAOI,SAASE,WAAW,CAACC,GAAG,CAACd;AAClC;AAEA,OAAO,eAAee,wBAAwBC,IAAoC;IAChF,MAAML,WAAW,MAAMjB,kBACrBD,4BACA,qCACA;QACEwB,QAAQ;QACRD;IACF;IAEF,OAAOhB,oBAAoBW;AAC7B;AAEA,OAAO,eAAeO,wBAAwB,EAC5CC,YAAY,EACZH,IAAI,EAIL;IACC,MAAML,WAAW,MAAMjB,kBACrBD,4BACA,CAAC,kCAAkC,EAAE2B,mBAAmBD,eAAe,EACvE;QAACF,QAAQ;QAASD;IAAI;IAExB,OAAOhB,oBAAoBW;AAC7B;AAEA,OAAO,eAAeU,wBAAwB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QACf;QACAX,YAAYU,iBAAiB,CAAC;YAC5Bf,UAAUvB,sBAAsBwC,sBAAsB,CAACpC;YACvDmC,aAAa;QACf;KACD;AACH"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
export * from '@shipfox/integration-icons';
|
|
2
|
+
export * from '#core/models.js';
|
|
1
3
|
export * from './components/connection-picker.js';
|
|
2
4
|
export * from './components/integration-gallery.js';
|
|
3
5
|
export * from './components/redirect-install-page.js';
|
|
4
6
|
export * from './components/repository-picker.js';
|
|
5
7
|
export * from './connection-status-badge.js';
|
|
6
8
|
export * from './hooks/api/integrations.js';
|
|
7
|
-
export * from './integration-icon.js';
|
|
8
9
|
export * from './pages/gitea-install-page.js';
|
|
9
10
|
export * from './pages/github-install-page.js';
|
|
10
11
|
export * from './pages/linear-callback-page.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
export * from '@shipfox/integration-icons';
|
|
2
|
+
export * from '#core/models.js';
|
|
1
3
|
export * from './components/connection-picker.js';
|
|
2
4
|
export * from './components/integration-gallery.js';
|
|
3
5
|
export * from './components/redirect-install-page.js';
|
|
4
6
|
export * from './components/repository-picker.js';
|
|
5
7
|
export * from './connection-status-badge.js';
|
|
6
8
|
export * from './hooks/api/integrations.js';
|
|
7
|
-
export * from './integration-icon.js';
|
|
8
9
|
export * from './pages/gitea-install-page.js';
|
|
9
10
|
export * from './pages/github-install-page.js';
|
|
10
11
|
export * from './pages/linear-callback-page.js';
|