@checkstack/test-utils-backend 0.1.24 → 0.1.26

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,176 @@
1
1
  # @checkstack/test-utils-backend
2
2
 
3
+ ## 0.1.26
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9016526]
8
+ - @checkstack/common@0.10.0
9
+ - @checkstack/backend-api@0.15.2
10
+ - @checkstack/signal-common@0.2.3
11
+ - @checkstack/queue-api@0.3.1
12
+
13
+ ## 0.1.25
14
+
15
+ ### Patch Changes
16
+
17
+ - aa89bc5: Replace the bespoke `registerInfrastructureTab()` registry with a standard
18
+ slot-extension contract (`InfrastructureTabsSlot` from
19
+ `@checkstack/infrastructure-common`). Plugins now contribute infrastructure
20
+ tabs via `createSlotExtension`, depending only on the slot owner.
21
+
22
+ The slot system in `@checkstack/frontend-api` gains a second type parameter
23
+ on `createSlot<TContext, TMetadata>` so extensions can declare typed static
24
+ metadata at registration time (label, icon, access rules, ordering for the
25
+ infrastructure tab bar). A new `useSlotExtensions(slot)` hook returns typed
26
+ extensions and subscribes to plugin lifecycle changes.
27
+
28
+ Each tab body now stacks a **Runtime** sub-section (live state, read-only)
29
+ on top of a **Configuration** sub-section (settings, gated by `canUpdate`).
30
+
31
+ **Queue runtime panel.** Surfaces aggregated counts (pending / processing /
32
+ completed / failed) plus three sub-tabs of recent jobs: **Active**, **Recent
33
+ failed** (with the failure message), and **Recent completed** (with
34
+ duration). Job payloads are deliberately not surfaced — they may carry
35
+ secrets and need a separate manage-access gate to be shown.
36
+
37
+ To support this, `Queue<T>` gains a required `listJobs(opts)` method
38
+ returning `JobSummary[]` (no payloads), and `QueueStats` gains a
39
+ `scope: "instance" | "cluster"` field. The in-memory queue keeps rolling
40
+ ring buffers (200 entries) for completed/failed history and tracks active
41
+ jobs by id; BullMQ uses native `getJobs`. `QueueManager.listJobs` aggregates
42
+ across queues and sorts (most-recent-first for terminal states, FIFO for
43
+ active/waiting/delayed).
44
+
45
+ **Cache runtime panel.** Lists the top N entries by size (or by recency) so
46
+ operators can debug a cache filling up. Values are deliberately omitted —
47
+ PII / secret risk. Backends opt in via an optional `listEntries?` method on
48
+ `CacheProvider`; non-supporting backends return `{ supported: false }` and
49
+ the UI renders a "not supported by this backend" hint. The in-memory cache
50
+ implements it using its existing per-entry byte tracking.
51
+
52
+ `CacheStats` also gains `scope: "instance" | "cluster"`.
53
+
54
+ **Multi-instance scope warning.** A new `<InstanceScopeBanner>` component in
55
+ `@checkstack/ui` renders a yellow banner above any runtime panel whose
56
+ backend reports `scope: "instance"` — i.e. in-memory queue or cache running
57
+ in a horizontally scaled deployment. The banner explains the metrics are
58
+ local to the responding replica and recommends switching to a clustered
59
+ backend (Redis-backed queue / cache) for cluster-wide visibility.
60
+
61
+ **Bug fix — stable cache provider proxy.** `CacheManagerImpl.getProvider()`
62
+ now returns a single stable proxy that delegates to whatever provider is
63
+ currently active. Previously, consumers of `createCachedScope` (and any
64
+ direct `cacheManager.getProvider()` caller) captured the active provider
65
+ reference at plugin-init time. After any `setActiveBackend` call — including
66
+ saving the same memory config in the new Cache tab, which reconstructs the
67
+ in-memory cache — those scopes wrote to an orphaned old provider while the
68
+ runtime panel read stats from the new (empty) one, making the runtime panel
69
+ appear to report 0 keys. With the proxy, all consumers share a single stable
70
+ identity and writes always land in the active provider.
71
+
72
+ **Bytes tracking on the in-memory cache.** `InMemoryCache.getStats().sizeBytes`
73
+ now returns a running approximation (UTF-8 bytes of the key plus
74
+ `v8.serialize(value).byteLength`, with a JSON fallback) that's kept in sync
75
+ across all eviction paths. Treat the number as a sanity gauge; it doesn't
76
+ include `Map` per-entry overhead.
77
+
78
+ **Pagination.** Both `Queue<T>.listJobs` and `CacheProvider.listEntries?`
79
+ are offset-paginated. Inputs gain an `offset: number`; outputs change to
80
+ `{ items, total: number | null, hasMore: boolean }`. `total` is nullable
81
+ so backends that can't compute it cheaply still paginate via `hasMore`.
82
+ The UI uses the existing `<Pagination>` component with a 25-row default
83
+ page size. `QueueManager.listJobs` aggregates by over-fetching
84
+ `[0, offset+limit)` per queue, merge-sorting, then slicing the window —
85
+ optimal for the single-queue case, acceptable for the multi-queue case
86
+ within the UI's reasonable page-depth bounds. BullMQ uses native offset
87
+ ranges via `getJobs(types, start, end)` plus `getJobCounts` for `total`.
88
+
89
+ **Pending tab.** The Queue runtime panel exposes a virtual `"pending"`
90
+ state (waiting ∪ delayed, FIFO). It's now the default sub-tab, since
91
+ "what's queued up?" is the most common question. Per-row state is shown
92
+ when viewing the combined list.
93
+
94
+ **Recurring schedules visible under Pending.** Cron- and interval-based
95
+ recurring jobs (e.g. healthchecks) are surfaced under Pending/Delayed
96
+ between fires, with a `nextRunAt` countdown column and a "(recurring)"
97
+ label. `JobSummary` gains optional `nextRunAt: Date` and `recurring:
98
+ boolean` fields. The in-memory queue synthesises these rows from its
99
+ `recurringJobs` registry; BullMQ already materialises the next fire of
100
+ each scheduler as a delayed job and we now surface its trigger time and
101
+ the `repeatJobKey`-derived `recurring` flag.
102
+
103
+ **Bug fix — drop hook emits with no listeners.** `EventBus.emit` no
104
+ longer enqueues a job when zero listeners (distributed or instance-local)
105
+ are registered for the hook. Previously, hooks like
106
+ `core.plugin.initialized` — emitted on every plugin init but subscribed
107
+ to by nothing in the core repo — accumulated one waiting job per emit
108
+ forever. The in-memory queue's `processNext` short-circuits when there
109
+ are zero consumer groups, so its post-loop cleanup never ran for these
110
+ orphaned jobs. The fix drops the emit at the source and logs a debug
111
+ line. Note: in distributed deployments using a Redis-backed queue, this
112
+ means a subscriber on another replica won't receive an event if no
113
+ replica that emits it has a local listener. Plugins needing cross-process
114
+ delivery must register their listener on every replica that should
115
+ receive the hook.
116
+
117
+ **Breaking notes (treated as minor under beta semantics)**:
118
+
119
+ - `@checkstack/infrastructure-common` removes `registerInfrastructureTab`
120
+ and `getInfrastructureTabs`; former callers must register an extension
121
+ into `InfrastructureTabsSlot`.
122
+ - `@checkstack/queue-api`'s `Queue<T>` interface requires the new
123
+ `listJobs(opts)` method returning `ListJobsResult` (paginated). Both
124
+ bundled queue backends (memory, BullMQ) are updated; out-of-tree
125
+ implementations will need to add it.
126
+ - `QueueStats` and `CacheStats` add a required `scope` field.
127
+ - `CacheProvider.listEntries?` (when implemented) now returns
128
+ `ListEntriesResult` instead of `CacheEntrySummary[]`.
129
+ - `JobState` adds a `"pending"` variant.
130
+
131
+ - 3547670: Add `@checkstack/tips-*` — first-run tip and onboarding infrastructure for
132
+ the frontends.
133
+
134
+ Three new packages:
135
+
136
+ - `@checkstack/tips-common` — RPC contract (`tipsContract`), `TipsApi`
137
+ client definition, and zod schemas. Fully-qualified tip IDs have shape
138
+ `<pluginId>.<localTipId>` and are produced exclusively by
139
+ `qualifyTipId(plugin, localId)` — plugins never write the namespace
140
+ themselves, and a local id with a leading or trailing `.` is rejected,
141
+ so one plugin cannot forge or dismiss a tip in another plugin's
142
+ namespace.
143
+ - `@checkstack/tips-backend` — Postgres-backed dismissal store
144
+ (`user_tip_dismissal` with composite PK on `(user_id, tip_id)`),
145
+ `listDismissed` / `dismiss` / `reset` endpoints scoped to the
146
+ requesting user via the auto-auth middleware, and a
147
+ `auth.userDeleted` hook that cleans up dismissals when a user is
148
+ deleted.
149
+ - `@checkstack/tips-frontend` — `<Tip>` (anchored popover) and
150
+ `<TipBanner>` (inline callout) components plus the `useTipState`
151
+ hook. All three accept `{ plugin, id }` (where `plugin` is the
152
+ caller's `pluginMetadata`) and route through `qualifyTipId` so the
153
+ namespace prefix is enforced at the boundary. Persists per-user on
154
+ the server when logged in, and per-browser in `localStorage`
155
+ (`checkstack.tips.dismissed`) when anonymous, with cross-tab sync via
156
+ the `storage` event.
157
+
158
+ `@checkstack/ui`'s `<EmptyState>` gains optional `steps` and `actions`
159
+ props for richer empty-state coaching (numbered onboarding lists +
160
+ primary CTA), and accepts `ReactNode` for `description`. Existing
161
+ callers continue to work unchanged.
162
+
163
+ `@checkstack/test-utils-backend`'s `createMockDb` now also mocks
164
+ `insert().values().onConflictDoNothing()` so routers using upsert-or-skip
165
+ semantics can be unit-tested.
166
+
167
+ - Updated dependencies [42abfff]
168
+ - Updated dependencies [aa89bc5]
169
+ - @checkstack/common@0.9.0
170
+ - @checkstack/queue-api@0.3.0
171
+ - @checkstack/backend-api@0.15.1
172
+ - @checkstack/signal-common@0.2.2
173
+
3
174
  ## 0.1.24
4
175
 
5
176
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/test-utils-backend",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "license": "Elastic-2.0",
5
5
  "checkstack": {
6
6
  "type": "tooling"
@@ -13,14 +13,14 @@
13
13
  "lint:code": "eslint . --max-warnings 0"
14
14
  },
15
15
  "dependencies": {
16
- "@checkstack/backend-api": "0.14.1",
17
- "@checkstack/common": "0.7.0",
18
- "@checkstack/queue-api": "0.2.17",
19
- "@checkstack/signal-common": "0.2.0"
16
+ "@checkstack/backend-api": "0.15.1",
17
+ "@checkstack/common": "0.9.0",
18
+ "@checkstack/queue-api": "0.3.0",
19
+ "@checkstack/signal-common": "0.2.2"
20
20
  },
21
21
  "devDependencies": {
22
- "@checkstack/tsconfig": "0.0.6",
23
- "@checkstack/scripts": "0.1.2",
22
+ "@checkstack/tsconfig": "0.0.7",
23
+ "@checkstack/scripts": "0.3.1",
24
24
  "@types/bun": "latest",
25
25
  "zod": "^4.0.0"
26
26
  }
package/src/mock-db.ts CHANGED
@@ -8,7 +8,9 @@ import { mock } from "bun:test";
8
8
  * - select().from().where().limit()
9
9
  * - insert().values()
10
10
  * - insert().values().onConflictDoUpdate()
11
+ * - insert().values().onConflictDoNothing()
11
12
  * - update().set().where()
13
+ * - delete().where()
12
14
  *
13
15
  * @returns A mock database object that can be used in place of a real Drizzle database
14
16
  *
@@ -56,6 +58,7 @@ export function createMockDb() {
56
58
  insert: mock(() => ({
57
59
  values: mock(() => ({
58
60
  onConflictDoUpdate: mock(() => Promise.resolve()),
61
+ onConflictDoNothing: mock(() => Promise.resolve()),
59
62
  returning: mock(() => Promise.resolve([])),
60
63
  })),
61
64
  })),
@@ -101,7 +101,9 @@ export function createMockQueueManager(): QueueManager {
101
101
  completed: 0,
102
102
  failed: 0,
103
103
  consumerGroups: consumers.size,
104
+ scope: "instance" as const,
104
105
  }),
106
+ listJobs: async () => ({ items: [], total: 0, hasMore: false }),
105
107
  };
106
108
 
107
109
  return mockQueue;
@@ -131,7 +133,9 @@ export function createMockQueueManager(): QueueManager {
131
133
  completed: 0,
132
134
  failed: 0,
133
135
  consumerGroups: 0,
136
+ scope: "instance" as const,
134
137
  }),
138
+ listJobs: async () => ({ items: [], total: 0, hasMore: false }),
135
139
  listAllRecurringJobs: async (): Promise<RecurringJobInfo[]> => [],
136
140
  startPolling: () => {},
137
141
  shutdown: async () => {