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