@checkstack/integration-backend 0.1.28 → 0.1.30

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,96 @@
1
1
  # @checkstack/integration-backend
2
2
 
3
+ ## 0.1.30
4
+
5
+ ### Patch Changes
6
+
7
+ - @checkstack/backend-api@0.17.1
8
+ - @checkstack/command-backend@0.1.30
9
+ - @checkstack/queue-api@0.3.5
10
+
11
+ ## 0.1.29
12
+
13
+ ### Patch Changes
14
+
15
+ - f23f3c9: Add `correlationMiddleware` to `@checkstack/backend-api` and apply it
16
+ to every plugin/core router so each request carries a stable
17
+ `x-correlation-id` (read from the inbound header, or freshly minted
18
+ via `crypto.randomUUID()` when absent) and an auto-injected child
19
+ logger bound with `{ correlationId, pluginId, userId? }`. The ID is
20
+ echoed back on the response header so the caller can correlate their
21
+ client-side trace to the server logs.
22
+
23
+ The `Logger` interface in `@checkstack/backend-api` now formally
24
+ documents the structured-metadata convention (`logger.info("msg",
25
+ { ...meta })`) alongside the long-standing varargs shape. Winston's
26
+ splat handling already routes both shapes through the same vararg
27
+ slot, so existing call sites are unaffected. A new optional
28
+ `Logger.child(meta)` method captures the metadata-binding contract the
29
+ new middleware relies on; production loggers always implement it,
30
+ minimal test mocks may omit it (the middleware falls back gracefully).
31
+
32
+ `RpcContext` grew two optional `Headers` bags, `requestHeaders` and
33
+ `responseHeaders`, populated by the outer Hono `/api/*` and `/rest/*`
34
+ handlers in `@checkstack/backend`. They are write-through observation
35
+ points for middleware; an `RpcContext` constructed without them (S2S
36
+ clients, tests) keeps working — the echo is a silent no-op and the ID
37
+ is still bound onto the child logger for server-side correlation.
38
+
39
+ The scaffolding template in `@checkstack/scripts` was updated so any
40
+ new plugin generated via `bun run create` wires the middleware in the
41
+ expected `.use(correlationMiddleware).use(autoAuthMiddleware)` order
42
+ out of the box.
43
+
44
+ - f23f3c9: Sweep every paginated `*-common` contract onto the canonical
45
+ `PaginationInput` / `PaginatedResult` from `@checkstack/common` and
46
+ remove the now-unused legacy exports.
47
+
48
+ **BREAKING CHANGE** - `@checkstack/common` drops the deprecated
49
+ `PaginationInputSchema`, `paginatedOutput`, and `PaginatedResponse`
50
+ symbols. Callers must consume `PaginationInput` (input) and
51
+ `PaginatedResult(itemSchema)` (output) instead. The canonical input is
52
+ `{ limit (1-100, default 20), offset (>= 0, default 0) }`; the
53
+ canonical output envelope is
54
+ `{ items, total, limit, offset }`.
55
+
56
+ **BREAKING CHANGE** - `@checkstack/notification-common` migrates
57
+ `getNotifications` off the legacy `PaginationInputSchema`
58
+ (`{ limit, offset, unreadOnly }` with output `{ notifications, total }`)
59
+ onto `ListNotificationsInputSchema =
60
+ PaginationInput.extend({ unreadOnly })` and
61
+ `PaginatedResult(NotificationSchema)`. The output key changes from
62
+ `notifications` to `items`, and `limit` / `offset` are now echoed on
63
+ the response. The `PaginationInput` type alias previously exported
64
+ from `notification-common` is removed - use `ListNotificationsInput`
65
+ or the canonical `PaginationInput` from `@checkstack/common`.
66
+
67
+ **BREAKING CHANGE** - `@checkstack/integration-common` migrates
68
+ `listSubscriptions` (inline `{ page, pageSize, ... }` -> output
69
+ `{ subscriptions, total }`) and `getDeliveryLogs` (via
70
+ `DeliveryLogQueryInputSchema` `{ subscriptionId?, eventType?, status?,
71
+ page, pageSize }` -> output `{ logs, total }`) onto the canonical
72
+ `PaginationInput.extend({...})` input and
73
+ `PaginatedResult(itemSchema)` output. External callers must switch
74
+ from `{ page, pageSize }` to `{ limit, offset }` and read response
75
+ items from `data.items` (no more `data.subscriptions` / `data.logs`).
76
+
77
+ The matching `*-backend` handlers were updated to consume the new
78
+ input shape (`offset` arithmetic in lieu of `(page - 1) * pageSize`)
79
+ and to echo `limit` / `offset` on the response. The `*-frontend` call
80
+ sites in `NotificationsPage`, `NotificationBell`, `IntegrationsPage`,
81
+ and `DeliveryLogsPage` were updated to send the new input shape and
82
+ read `data.items`.
83
+
84
+ - Updated dependencies [f23f3c9]
85
+ - Updated dependencies [f23f3c9]
86
+ - Updated dependencies [f23f3c9]
87
+ - @checkstack/common@0.11.0
88
+ - @checkstack/backend-api@0.17.0
89
+ - @checkstack/command-backend@0.1.29
90
+ - @checkstack/integration-common@0.5.0
91
+ - @checkstack/signal-common@0.2.4
92
+ - @checkstack/queue-api@0.3.4
93
+
3
94
  ## 0.1.28
4
95
 
5
96
  ### 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.30",
4
4
  "license": "Elastic-2.0",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -15,21 +15,21 @@
15
15
  "test": "bun test"
16
16
  },
17
17
  "dependencies": {
18
- "@checkstack/integration-common": "0.4.0",
19
- "@checkstack/backend-api": "0.15.3",
20
- "@checkstack/signal-common": "0.2.3",
21
- "@checkstack/queue-api": "0.3.2",
22
- "@checkstack/common": "0.10.0",
23
- "@checkstack/command-backend": "0.1.27",
18
+ "@checkstack/integration-common": "0.5.0",
19
+ "@checkstack/backend-api": "0.17.0",
20
+ "@checkstack/signal-common": "0.2.4",
21
+ "@checkstack/queue-api": "0.3.4",
22
+ "@checkstack/common": "0.11.0",
23
+ "@checkstack/command-backend": "0.1.29",
24
24
  "drizzle-orm": "^0.45.0",
25
25
  "zod": "^4.2.1",
26
26
  "@orpc/server": "^1.13.2"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@checkstack/drizzle-helper": "0.0.5",
30
- "@checkstack/scripts": "0.3.2",
30
+ "@checkstack/scripts": "0.3.3",
31
31
  "@checkstack/tsconfig": "0.0.7",
32
- "@checkstack/test-utils-backend": "0.1.27",
32
+ "@checkstack/test-utils-backend": "0.1.29",
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