@checkstack/integration-backend 0.1.28 → 0.1.29

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 CHANGED
@@ -1,5 +1,88 @@
1
1
  # @checkstack/integration-backend
2
2
 
3
+ ## 0.1.29
4
+
5
+ ### Patch Changes
6
+
7
+ - f23f3c9: Add `correlationMiddleware` to `@checkstack/backend-api` and apply it
8
+ to every plugin/core router so each request carries a stable
9
+ `x-correlation-id` (read from the inbound header, or freshly minted
10
+ via `crypto.randomUUID()` when absent) and an auto-injected child
11
+ logger bound with `{ correlationId, pluginId, userId? }`. The ID is
12
+ echoed back on the response header so the caller can correlate their
13
+ client-side trace to the server logs.
14
+
15
+ The `Logger` interface in `@checkstack/backend-api` now formally
16
+ documents the structured-metadata convention (`logger.info("msg",
17
+ { ...meta })`) alongside the long-standing varargs shape. Winston's
18
+ splat handling already routes both shapes through the same vararg
19
+ slot, so existing call sites are unaffected. A new optional
20
+ `Logger.child(meta)` method captures the metadata-binding contract the
21
+ new middleware relies on; production loggers always implement it,
22
+ minimal test mocks may omit it (the middleware falls back gracefully).
23
+
24
+ `RpcContext` grew two optional `Headers` bags, `requestHeaders` and
25
+ `responseHeaders`, populated by the outer Hono `/api/*` and `/rest/*`
26
+ handlers in `@checkstack/backend`. They are write-through observation
27
+ points for middleware; an `RpcContext` constructed without them (S2S
28
+ clients, tests) keeps working — the echo is a silent no-op and the ID
29
+ is still bound onto the child logger for server-side correlation.
30
+
31
+ The scaffolding template in `@checkstack/scripts` was updated so any
32
+ new plugin generated via `bun run create` wires the middleware in the
33
+ expected `.use(correlationMiddleware).use(autoAuthMiddleware)` order
34
+ out of the box.
35
+
36
+ - f23f3c9: Sweep every paginated `*-common` contract onto the canonical
37
+ `PaginationInput` / `PaginatedResult` from `@checkstack/common` and
38
+ remove the now-unused legacy exports.
39
+
40
+ **BREAKING CHANGE** - `@checkstack/common` drops the deprecated
41
+ `PaginationInputSchema`, `paginatedOutput`, and `PaginatedResponse`
42
+ symbols. Callers must consume `PaginationInput` (input) and
43
+ `PaginatedResult(itemSchema)` (output) instead. The canonical input is
44
+ `{ limit (1-100, default 20), offset (>= 0, default 0) }`; the
45
+ canonical output envelope is
46
+ `{ items, total, limit, offset }`.
47
+
48
+ **BREAKING CHANGE** - `@checkstack/notification-common` migrates
49
+ `getNotifications` off the legacy `PaginationInputSchema`
50
+ (`{ limit, offset, unreadOnly }` with output `{ notifications, total }`)
51
+ onto `ListNotificationsInputSchema =
52
+ PaginationInput.extend({ unreadOnly })` and
53
+ `PaginatedResult(NotificationSchema)`. The output key changes from
54
+ `notifications` to `items`, and `limit` / `offset` are now echoed on
55
+ the response. The `PaginationInput` type alias previously exported
56
+ from `notification-common` is removed - use `ListNotificationsInput`
57
+ or the canonical `PaginationInput` from `@checkstack/common`.
58
+
59
+ **BREAKING CHANGE** - `@checkstack/integration-common` migrates
60
+ `listSubscriptions` (inline `{ page, pageSize, ... }` -> output
61
+ `{ subscriptions, total }`) and `getDeliveryLogs` (via
62
+ `DeliveryLogQueryInputSchema` `{ subscriptionId?, eventType?, status?,
63
+ page, pageSize }` -> output `{ logs, total }`) onto the canonical
64
+ `PaginationInput.extend({...})` input and
65
+ `PaginatedResult(itemSchema)` output. External callers must switch
66
+ from `{ page, pageSize }` to `{ limit, offset }` and read response
67
+ items from `data.items` (no more `data.subscriptions` / `data.logs`).
68
+
69
+ The matching `*-backend` handlers were updated to consume the new
70
+ input shape (`offset` arithmetic in lieu of `(page - 1) * pageSize`)
71
+ and to echo `limit` / `offset` on the response. The `*-frontend` call
72
+ sites in `NotificationsPage`, `NotificationBell`, `IntegrationsPage`,
73
+ and `DeliveryLogsPage` were updated to send the new input shape and
74
+ read `data.items`.
75
+
76
+ - Updated dependencies [f23f3c9]
77
+ - Updated dependencies [f23f3c9]
78
+ - Updated dependencies [f23f3c9]
79
+ - @checkstack/common@0.11.0
80
+ - @checkstack/backend-api@0.17.0
81
+ - @checkstack/command-backend@0.1.29
82
+ - @checkstack/integration-common@0.5.0
83
+ - @checkstack/signal-common@0.2.4
84
+ - @checkstack/queue-api@0.3.4
85
+
3
86
  ## 0.1.28
4
87
 
5
88
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/integration-backend",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "license": "Elastic-2.0",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -16,11 +16,11 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@checkstack/integration-common": "0.4.0",
19
- "@checkstack/backend-api": "0.15.3",
19
+ "@checkstack/backend-api": "0.16.0",
20
20
  "@checkstack/signal-common": "0.2.3",
21
- "@checkstack/queue-api": "0.3.2",
21
+ "@checkstack/queue-api": "0.3.3",
22
22
  "@checkstack/common": "0.10.0",
23
- "@checkstack/command-backend": "0.1.27",
23
+ "@checkstack/command-backend": "0.1.28",
24
24
  "drizzle-orm": "^0.45.0",
25
25
  "zod": "^4.2.1",
26
26
  "@orpc/server": "^1.13.2"
@@ -29,7 +29,7 @@
29
29
  "@checkstack/drizzle-helper": "0.0.5",
30
30
  "@checkstack/scripts": "0.3.2",
31
31
  "@checkstack/tsconfig": "0.0.7",
32
- "@checkstack/test-utils-backend": "0.1.27",
32
+ "@checkstack/test-utils-backend": "0.1.28",
33
33
  "@types/node": "^20.0.0",
34
34
  "drizzle-kit": "^0.31.10",
35
35
  "typescript": "^5.0.0"
package/src/router.ts CHANGED
@@ -2,6 +2,7 @@ import { implement, ORPCError } from "@orpc/server";
2
2
  import type { SafeDatabase } from "@checkstack/backend-api";
3
3
  import {
4
4
  autoAuthMiddleware,
5
+ correlationMiddleware,
5
6
  type RpcContext,
6
7
  type Logger,
7
8
  } from "@checkstack/backend-api";
@@ -126,6 +127,7 @@ export function createIntegrationRouter(deps: RouterDeps) {
126
127
  // Create contract implementer with context type AND auto auth middleware
127
128
  const os = implement(integrationContract)
128
129
  .$context<RpcContext>()
130
+ .use(correlationMiddleware)
129
131
  .use(autoAuthMiddleware);
130
132
 
131
133
  return os.router({
@@ -134,8 +136,7 @@ export function createIntegrationRouter(deps: RouterDeps) {
134
136
  // =========================================================================
135
137
 
136
138
  listSubscriptions: os.listSubscriptions.handler(async ({ input }) => {
137
- const { page, pageSize, providerId, eventType, enabled } = input;
138
- const offset = (page - 1) * pageSize;
139
+ const { limit, offset, providerId, eventType, enabled } = input;
139
140
 
140
141
  // Build where conditions
141
142
  const conditions = [];
@@ -160,7 +161,7 @@ export function createIntegrationRouter(deps: RouterDeps) {
160
161
  .select()
161
162
  .from(schema.webhookSubscriptions)
162
163
  .orderBy(desc(schema.webhookSubscriptions.createdAt))
163
- .limit(pageSize)
164
+ .limit(limit)
164
165
  .offset(offset);
165
166
 
166
167
  if (whereClause) {
@@ -175,7 +176,7 @@ export function createIntegrationRouter(deps: RouterDeps) {
175
176
  : subscriptions;
176
177
 
177
178
  return {
178
- subscriptions: filtered.map((s) => ({
179
+ items: filtered.map((s) => ({
179
180
  ...s,
180
181
  description: s.description ?? undefined,
181
182
  systemFilter: s.systemFilter ?? undefined,
@@ -183,6 +184,8 @@ export function createIntegrationRouter(deps: RouterDeps) {
183
184
  updatedAt: s.updatedAt,
184
185
  })),
185
186
  total: Number(total),
187
+ limit,
188
+ offset,
186
189
  };
187
190
  }),
188
191
 
@@ -701,8 +704,7 @@ export function createIntegrationRouter(deps: RouterDeps) {
701
704
  // =========================================================================
702
705
 
703
706
  getDeliveryLogs: os.getDeliveryLogs.handler(async ({ input }) => {
704
- const { subscriptionId, eventType, status, page, pageSize } = input;
705
- const offset = (page - 1) * pageSize;
707
+ const { subscriptionId, eventType, status, limit, offset } = input;
706
708
 
707
709
  // Build where conditions
708
710
  const conditions = [];
@@ -738,11 +740,11 @@ export function createIntegrationRouter(deps: RouterDeps) {
738
740
  )
739
741
  .where(whereClause)
740
742
  .orderBy(desc(schema.deliveryLogs.createdAt))
741
- .limit(pageSize)
743
+ .limit(limit)
742
744
  .offset(offset);
743
745
 
744
746
  return {
745
- logs: logs.map(({ log, subscriptionName }) => ({
747
+ items: logs.map(({ log, subscriptionName }) => ({
746
748
  ...log,
747
749
  subscriptionName: subscriptionName ?? undefined,
748
750
  createdAt: log.createdAt,
@@ -752,6 +754,8 @@ export function createIntegrationRouter(deps: RouterDeps) {
752
754
  errorMessage: log.errorMessage ?? undefined,
753
755
  })),
754
756
  total: Number(total),
757
+ limit,
758
+ offset,
755
759
  };
756
760
  }),
757
761