@checkstack/integration-common 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/package.json +1 -1
- package/src/rpc-contract.ts +118 -128
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,65 @@
|
|
|
1
1
|
# @checkstack/integration-common
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7a23261: ## TanStack Query Integration
|
|
8
|
+
|
|
9
|
+
Migrated all frontend components to use `usePluginClient` hook with TanStack Query integration, replacing the legacy `forPlugin()` pattern.
|
|
10
|
+
|
|
11
|
+
### New Features
|
|
12
|
+
|
|
13
|
+
- **`usePluginClient` hook**: Provides type-safe access to plugin APIs with `.useQuery()` and `.useMutation()` methods
|
|
14
|
+
- **Automatic request deduplication**: Multiple components requesting the same data share a single network request
|
|
15
|
+
- **Built-in caching**: Configurable stale time and cache duration per query
|
|
16
|
+
- **Loading/error states**: TanStack Query provides `isLoading`, `error`, `isRefetching` states automatically
|
|
17
|
+
- **Background refetching**: Stale data is automatically refreshed when components mount
|
|
18
|
+
|
|
19
|
+
### Contract Changes
|
|
20
|
+
|
|
21
|
+
All RPC contracts now require `operationType: "query"` or `operationType: "mutation"` metadata:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
const getItems = proc()
|
|
25
|
+
.meta({ operationType: "query", access: [access.read] })
|
|
26
|
+
.output(z.array(itemSchema))
|
|
27
|
+
.query();
|
|
28
|
+
|
|
29
|
+
const createItem = proc()
|
|
30
|
+
.meta({ operationType: "mutation", access: [access.manage] })
|
|
31
|
+
.input(createItemSchema)
|
|
32
|
+
.output(itemSchema)
|
|
33
|
+
.mutation();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Migration
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// Before (forPlugin pattern)
|
|
40
|
+
const api = useApi(myPluginApiRef);
|
|
41
|
+
const [items, setItems] = useState<Item[]>([]);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
api.getItems().then(setItems);
|
|
44
|
+
}, [api]);
|
|
45
|
+
|
|
46
|
+
// After (usePluginClient pattern)
|
|
47
|
+
const client = usePluginClient(MyPluginApi);
|
|
48
|
+
const { data: items, isLoading } = client.getItems.useQuery({});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Bug Fixes
|
|
52
|
+
|
|
53
|
+
- Fixed `rpc.test.ts` test setup for middleware type inference
|
|
54
|
+
- Fixed `SearchDialog` to use `setQuery` instead of deprecated `search` method
|
|
55
|
+
- Fixed null→undefined warnings in notification and queue frontends
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [7a23261]
|
|
60
|
+
- @checkstack/common@0.3.0
|
|
61
|
+
- @checkstack/signal-common@0.1.1
|
|
62
|
+
|
|
3
63
|
## 0.1.0
|
|
4
64
|
|
|
5
65
|
### Minor Changes
|
package/package.json
CHANGED
package/src/rpc-contract.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { oc } from "@orpc/contract";
|
|
2
1
|
import { z } from "zod";
|
|
3
2
|
import { integrationAccess } from "./access";
|
|
4
3
|
import { pluginMetadata } from "./plugin-metadata";
|
|
5
|
-
import {
|
|
6
|
-
createClientDefinition,
|
|
7
|
-
type ProcedureMetadata,
|
|
8
|
-
} from "@checkstack/common";
|
|
4
|
+
import { createClientDefinition, proc } from "@checkstack/common";
|
|
9
5
|
import {
|
|
10
6
|
WebhookSubscriptionSchema,
|
|
11
7
|
CreateSubscriptionInputSchema,
|
|
@@ -23,9 +19,6 @@ import {
|
|
|
23
19
|
EventPayloadSchemaOutputSchema,
|
|
24
20
|
} from "./schemas";
|
|
25
21
|
|
|
26
|
-
// Base builder with full metadata support (userType + access)
|
|
27
|
-
const _base = oc.$meta<ProcedureMetadata>({});
|
|
28
|
-
|
|
29
22
|
// Integration RPC Contract
|
|
30
23
|
export const integrationContract = {
|
|
31
24
|
// ==========================================================================
|
|
@@ -33,11 +26,11 @@ export const integrationContract = {
|
|
|
33
26
|
// ==========================================================================
|
|
34
27
|
|
|
35
28
|
/** List all webhook subscriptions */
|
|
36
|
-
listSubscriptions:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
listSubscriptions: proc({
|
|
30
|
+
operationType: "query",
|
|
31
|
+
userType: "authenticated",
|
|
32
|
+
access: [integrationAccess.manage],
|
|
33
|
+
})
|
|
41
34
|
.input(
|
|
42
35
|
z.object({
|
|
43
36
|
page: z.number().min(1).default(1),
|
|
@@ -55,47 +48,47 @@ export const integrationContract = {
|
|
|
55
48
|
),
|
|
56
49
|
|
|
57
50
|
/** Get a single subscription by ID */
|
|
58
|
-
getSubscription:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
51
|
+
getSubscription: proc({
|
|
52
|
+
operationType: "query",
|
|
53
|
+
userType: "authenticated",
|
|
54
|
+
access: [integrationAccess.manage],
|
|
55
|
+
})
|
|
63
56
|
.input(z.object({ id: z.string() }))
|
|
64
57
|
.output(WebhookSubscriptionSchema),
|
|
65
58
|
|
|
66
59
|
/** Create a new webhook subscription */
|
|
67
|
-
createSubscription:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
createSubscription: proc({
|
|
61
|
+
operationType: "mutation",
|
|
62
|
+
userType: "authenticated",
|
|
63
|
+
access: [integrationAccess.manage],
|
|
64
|
+
})
|
|
72
65
|
.input(CreateSubscriptionInputSchema)
|
|
73
66
|
.output(WebhookSubscriptionSchema),
|
|
74
67
|
|
|
75
68
|
/** Update an existing subscription */
|
|
76
|
-
updateSubscription:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
updateSubscription: proc({
|
|
70
|
+
operationType: "mutation",
|
|
71
|
+
userType: "authenticated",
|
|
72
|
+
access: [integrationAccess.manage],
|
|
73
|
+
})
|
|
81
74
|
.input(UpdateSubscriptionInputSchema)
|
|
82
75
|
.output(WebhookSubscriptionSchema),
|
|
83
76
|
|
|
84
77
|
/** Delete a subscription */
|
|
85
|
-
deleteSubscription:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
78
|
+
deleteSubscription: proc({
|
|
79
|
+
operationType: "mutation",
|
|
80
|
+
userType: "authenticated",
|
|
81
|
+
access: [integrationAccess.manage],
|
|
82
|
+
})
|
|
90
83
|
.input(z.object({ id: z.string() }))
|
|
91
84
|
.output(z.object({ success: z.boolean() })),
|
|
92
85
|
|
|
93
86
|
/** Toggle subscription enabled state */
|
|
94
|
-
toggleSubscription:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
toggleSubscription: proc({
|
|
88
|
+
operationType: "mutation",
|
|
89
|
+
userType: "authenticated",
|
|
90
|
+
access: [integrationAccess.manage],
|
|
91
|
+
})
|
|
99
92
|
.input(z.object({ id: z.string(), enabled: z.boolean() }))
|
|
100
93
|
.output(z.object({ success: z.boolean() })),
|
|
101
94
|
|
|
@@ -104,19 +97,18 @@ export const integrationContract = {
|
|
|
104
97
|
// ==========================================================================
|
|
105
98
|
|
|
106
99
|
/** List all registered integration providers */
|
|
107
|
-
listProviders:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
.output(z.array(IntegrationProviderInfoSchema)),
|
|
100
|
+
listProviders: proc({
|
|
101
|
+
operationType: "query",
|
|
102
|
+
userType: "authenticated",
|
|
103
|
+
access: [integrationAccess.manage],
|
|
104
|
+
}).output(z.array(IntegrationProviderInfoSchema)),
|
|
113
105
|
|
|
114
106
|
/** Test a provider connection with given config */
|
|
115
|
-
testProviderConnection:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
107
|
+
testProviderConnection: proc({
|
|
108
|
+
operationType: "mutation",
|
|
109
|
+
userType: "authenticated",
|
|
110
|
+
access: [integrationAccess.manage],
|
|
111
|
+
})
|
|
120
112
|
.input(
|
|
121
113
|
z.object({
|
|
122
114
|
providerId: z.string(),
|
|
@@ -131,65 +123,65 @@ export const integrationContract = {
|
|
|
131
123
|
// ==========================================================================
|
|
132
124
|
|
|
133
125
|
/** List all connections for a provider */
|
|
134
|
-
listConnections:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
126
|
+
listConnections: proc({
|
|
127
|
+
operationType: "query",
|
|
128
|
+
userType: "authenticated",
|
|
129
|
+
access: [integrationAccess.manage],
|
|
130
|
+
})
|
|
139
131
|
.input(z.object({ providerId: z.string() }))
|
|
140
132
|
.output(z.array(ProviderConnectionRedactedSchema)),
|
|
141
133
|
|
|
142
134
|
/** Get a single connection (redacted) */
|
|
143
|
-
getConnection:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
135
|
+
getConnection: proc({
|
|
136
|
+
operationType: "query",
|
|
137
|
+
userType: "authenticated",
|
|
138
|
+
access: [integrationAccess.manage],
|
|
139
|
+
})
|
|
148
140
|
.input(z.object({ connectionId: z.string() }))
|
|
149
141
|
.output(ProviderConnectionRedactedSchema),
|
|
150
142
|
|
|
151
143
|
/** Create a new provider connection */
|
|
152
|
-
createConnection:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
144
|
+
createConnection: proc({
|
|
145
|
+
operationType: "mutation",
|
|
146
|
+
userType: "authenticated",
|
|
147
|
+
access: [integrationAccess.manage],
|
|
148
|
+
})
|
|
157
149
|
.input(CreateConnectionInputSchema)
|
|
158
150
|
.output(ProviderConnectionRedactedSchema),
|
|
159
151
|
|
|
160
152
|
/** Update a provider connection */
|
|
161
|
-
updateConnection:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
153
|
+
updateConnection: proc({
|
|
154
|
+
operationType: "mutation",
|
|
155
|
+
userType: "authenticated",
|
|
156
|
+
access: [integrationAccess.manage],
|
|
157
|
+
})
|
|
166
158
|
.input(UpdateConnectionInputSchema)
|
|
167
159
|
.output(ProviderConnectionRedactedSchema),
|
|
168
160
|
|
|
169
161
|
/** Delete a provider connection */
|
|
170
|
-
deleteConnection:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
162
|
+
deleteConnection: proc({
|
|
163
|
+
operationType: "mutation",
|
|
164
|
+
userType: "authenticated",
|
|
165
|
+
access: [integrationAccess.manage],
|
|
166
|
+
})
|
|
175
167
|
.input(z.object({ connectionId: z.string() }))
|
|
176
168
|
.output(z.object({ success: z.boolean() })),
|
|
177
169
|
|
|
178
170
|
/** Test a saved connection */
|
|
179
|
-
testConnection:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
171
|
+
testConnection: proc({
|
|
172
|
+
operationType: "mutation",
|
|
173
|
+
userType: "authenticated",
|
|
174
|
+
access: [integrationAccess.manage],
|
|
175
|
+
})
|
|
184
176
|
.input(z.object({ connectionId: z.string() }))
|
|
185
177
|
.output(TestConnectionResultSchema),
|
|
186
178
|
|
|
187
179
|
/** Get dynamic options for cascading dropdowns */
|
|
188
|
-
getConnectionOptions:
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
180
|
+
getConnectionOptions: proc({
|
|
181
|
+
operationType: "mutation",
|
|
182
|
+
userType: "authenticated",
|
|
183
|
+
access: [integrationAccess.manage],
|
|
184
|
+
})
|
|
193
185
|
.input(GetConnectionOptionsInputSchema)
|
|
194
186
|
.output(z.array(ConnectionOptionSchema)),
|
|
195
187
|
|
|
@@ -198,34 +190,32 @@ export const integrationContract = {
|
|
|
198
190
|
// ==========================================================================
|
|
199
191
|
|
|
200
192
|
/** List all registered integration events */
|
|
201
|
-
listEventTypes:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
.output(z.array(IntegrationEventInfoSchema)),
|
|
193
|
+
listEventTypes: proc({
|
|
194
|
+
operationType: "query",
|
|
195
|
+
userType: "authenticated",
|
|
196
|
+
access: [integrationAccess.manage],
|
|
197
|
+
}).output(z.array(IntegrationEventInfoSchema)),
|
|
207
198
|
|
|
208
199
|
/** Get events grouped by category */
|
|
209
|
-
getEventsByCategory:
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
.
|
|
215
|
-
z.
|
|
216
|
-
z.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
),
|
|
200
|
+
getEventsByCategory: proc({
|
|
201
|
+
operationType: "query",
|
|
202
|
+
userType: "authenticated",
|
|
203
|
+
access: [integrationAccess.manage],
|
|
204
|
+
}).output(
|
|
205
|
+
z.array(
|
|
206
|
+
z.object({
|
|
207
|
+
category: z.string(),
|
|
208
|
+
events: z.array(IntegrationEventInfoSchema),
|
|
209
|
+
})
|
|
210
|
+
)
|
|
211
|
+
),
|
|
222
212
|
|
|
223
213
|
/** Get payload schema for a specific event with flattened property list for template hints */
|
|
224
|
-
getEventPayloadSchema:
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
214
|
+
getEventPayloadSchema: proc({
|
|
215
|
+
operationType: "query",
|
|
216
|
+
userType: "authenticated",
|
|
217
|
+
access: [integrationAccess.manage],
|
|
218
|
+
})
|
|
229
219
|
.input(z.object({ eventId: z.string() }))
|
|
230
220
|
.output(EventPayloadSchemaOutputSchema),
|
|
231
221
|
|
|
@@ -234,11 +224,11 @@ export const integrationContract = {
|
|
|
234
224
|
// ==========================================================================
|
|
235
225
|
|
|
236
226
|
/** Get delivery logs with filtering */
|
|
237
|
-
getDeliveryLogs:
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
227
|
+
getDeliveryLogs: proc({
|
|
228
|
+
operationType: "query",
|
|
229
|
+
userType: "authenticated",
|
|
230
|
+
access: [integrationAccess.manage],
|
|
231
|
+
})
|
|
242
232
|
.input(DeliveryLogQueryInputSchema)
|
|
243
233
|
.output(
|
|
244
234
|
z.object({
|
|
@@ -248,29 +238,29 @@ export const integrationContract = {
|
|
|
248
238
|
),
|
|
249
239
|
|
|
250
240
|
/** Get a single delivery log entry */
|
|
251
|
-
getDeliveryLog:
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
241
|
+
getDeliveryLog: proc({
|
|
242
|
+
operationType: "query",
|
|
243
|
+
userType: "authenticated",
|
|
244
|
+
access: [integrationAccess.manage],
|
|
245
|
+
})
|
|
256
246
|
.input(z.object({ id: z.string() }))
|
|
257
247
|
.output(DeliveryLogSchema),
|
|
258
248
|
|
|
259
249
|
/** Retry a failed delivery */
|
|
260
|
-
retryDelivery:
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
250
|
+
retryDelivery: proc({
|
|
251
|
+
operationType: "mutation",
|
|
252
|
+
userType: "authenticated",
|
|
253
|
+
access: [integrationAccess.manage],
|
|
254
|
+
})
|
|
265
255
|
.input(z.object({ logId: z.string() }))
|
|
266
256
|
.output(z.object({ success: z.boolean(), message: z.string().optional() })),
|
|
267
257
|
|
|
268
258
|
/** Get delivery statistics for dashboard */
|
|
269
|
-
getDeliveryStats:
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
259
|
+
getDeliveryStats: proc({
|
|
260
|
+
operationType: "query",
|
|
261
|
+
userType: "authenticated",
|
|
262
|
+
access: [integrationAccess.manage],
|
|
263
|
+
})
|
|
274
264
|
.input(
|
|
275
265
|
z.object({
|
|
276
266
|
/** Time range in hours (default: 24) */
|