@checkstack/queue-common 0.3.0 → 0.4.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 +228 -0
- package/package.json +7 -6
- package/src/rpc-contract.ts +11 -0
- package/src/schemas.ts +52 -1
- package/tsconfig.json +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,233 @@
|
|
|
1
1
|
# @checkstack/queue-common
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor 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
|
+
### Patch Changes
|
|
122
|
+
|
|
123
|
+
- Updated dependencies [42abfff]
|
|
124
|
+
- @checkstack/common@0.9.0
|
|
125
|
+
- @checkstack/signal-common@0.2.2
|
|
126
|
+
|
|
127
|
+
## 0.3.1
|
|
128
|
+
|
|
129
|
+
### Patch Changes
|
|
130
|
+
|
|
131
|
+
- 50e5f5f: Runtime plugin system: install + uninstall plugins from npm, GitHub releases
|
|
132
|
+
(including private GitHub Enterprise instances), or tarball uploads at
|
|
133
|
+
runtime, with multi-package bundles, dependency-derived compatibility checks,
|
|
134
|
+
multi-instance coordination via a Postgres artifact store, and
|
|
135
|
+
single-coordinator destructive cleanup.
|
|
136
|
+
|
|
137
|
+
Highlights:
|
|
138
|
+
|
|
139
|
+
- New `PluginSource` discriminated union and `PluginInstaller` /
|
|
140
|
+
`PluginInstallerRegistry` interfaces in `@checkstack/backend-api`. The
|
|
141
|
+
GitHub variant accepts an optional `apiBaseUrl` so deployments backed by
|
|
142
|
+
GitHub Enterprise can install from `https://ghe.example.com/api/v3`
|
|
143
|
+
instead of `api.github.com`.
|
|
144
|
+
- New `installPackageMetadataSchema` (Zod) in `@checkstack/common` validates
|
|
145
|
+
every plugin's `package.json` at install time. Required fields: `name`,
|
|
146
|
+
`version`, `description`, `author`, `license`, `checkstack.type`,
|
|
147
|
+
`checkstack.pluginId`. Optional: `checkstack.bundle`,
|
|
148
|
+
`checkstack.usageInstructions`, `checkstack.allowInstallScripts`.
|
|
149
|
+
- New `pluginManagerContract` in `@checkstack/pluginmanager-common` with
|
|
150
|
+
`list`, `previewInstall`, `install`, `previewUninstall`, `uninstall`, and
|
|
151
|
+
`events` procedures.
|
|
152
|
+
- New `@checkstack/pluginmanager-frontend` admin UI: installed-plugins list
|
|
153
|
+
with per-row uninstall (typed-confirmation modal, schema/configs/cascade
|
|
154
|
+
toggles), install page with NPM / Tarball Upload / GitHub Release tabs
|
|
155
|
+
(Catalog tab disabled — coming soon), and an events page surfacing the
|
|
156
|
+
install/uninstall audit log.
|
|
157
|
+
- New `bunx @checkstack/scripts plugin-pack` CLI for plugin authors —
|
|
158
|
+
per-package mode produces an npm-shaped tarball; `--bundle` mode produces
|
|
159
|
+
an outer tarball containing every sibling declared in
|
|
160
|
+
`package.json#checkstack.bundle`. Published to npm so external authors
|
|
161
|
+
can `bunx` it directly without a workspace checkout.
|
|
162
|
+
- Compatibility derived from `package.json#dependencies` ranges
|
|
163
|
+
(`semver.satisfies` against the platform's loaded `@checkstack/*`
|
|
164
|
+
versions) — no separate `compatibility` field.
|
|
165
|
+
- Multi-instance: originator persists artifacts + `plugins` rows + broadcasts
|
|
166
|
+
install/uninstall; receiving instances do in-process register/unregister
|
|
167
|
+
only. Destructive ops (drop schema, delete plugin_configs, delete
|
|
168
|
+
artifacts, delete `plugins` rows) run exactly once on the originator.
|
|
169
|
+
- Fresh-instance bootstrap: `loadPlugins()` hydrates any
|
|
170
|
+
`is_uninstallable=true` plugin missing from `node_modules` from the
|
|
171
|
+
artifact store before normal Phase 1 register.
|
|
172
|
+
- New schema: `plugin_artifacts` (tarball storage), `plugin_install_events`
|
|
173
|
+
(audit/error log). `plugins` extended with `version`, `metadata`,
|
|
174
|
+
`source`, `bundle_id`, `is_primary`. Local plugin sync now writes
|
|
175
|
+
`version` from each plugin's `package.json` so the admin UI shows real
|
|
176
|
+
versions instead of `—`.
|
|
177
|
+
- Tarball-upload endpoint (`POST /api/pluginmanager/upload-tarball`) for
|
|
178
|
+
the install UI; access-gated by `pluginmanager.plugin.manage`.
|
|
179
|
+
- Plugin Manager menu link added to the user menu (main grid, alongside
|
|
180
|
+
Profile / Notification Settings / etc.).
|
|
181
|
+
|
|
182
|
+
Cross-cutting changes:
|
|
183
|
+
|
|
184
|
+
- Backend request/response logging now flows through `rootLogger` (winston)
|
|
185
|
+
instead of `hono/logger`. 5xx responses include the response body inline
|
|
186
|
+
so swallowed early-return errors are visible in the log.
|
|
187
|
+
- The `/api/:pluginId/*` dispatcher now logs which core service is missing
|
|
188
|
+
or which `pluginId` had no metadata when it 500s.
|
|
189
|
+
- New `registerCorePluginMetadata` on `PluginManager` for core routers
|
|
190
|
+
(like the plugin manager itself) that need their metadata visible to the
|
|
191
|
+
RPC dispatcher without going through the full plugin lifecycle.
|
|
192
|
+
- ESLint: `unicorn/no-null` is now disabled globally. Drizzle distinguishes
|
|
193
|
+
between `null` (writes a real SQL NULL) and `undefined` (skip the column
|
|
194
|
+
on insert), so treating them as interchangeable produced latent bugs at
|
|
195
|
+
the persistence boundary. The bulk of the patch-bumped packages above
|
|
196
|
+
reflect lint-fix touches that landed when this rule was relaxed.
|
|
197
|
+
- Workspace-wide license normalization to `Elastic-2.0` (matches
|
|
198
|
+
`LICENSE.md`). Every `package.json` in the workspace now declares the
|
|
199
|
+
same SPDX identifier; the patch bumps capture this.
|
|
200
|
+
|
|
201
|
+
Plugin packages (every `plugins/*`): added a `pack` npm script
|
|
202
|
+
(`bunx @checkstack/scripts plugin-pack`), mirrored each plugin's
|
|
203
|
+
`pluginId` from `plugin-metadata.ts` into `package.json#checkstack.pluginId`
|
|
204
|
+
so install-time validation passes, stubbed any missing required metadata
|
|
205
|
+
fields (`description`, `author`, `license`), and added
|
|
206
|
+
`checkstack.bundle` to multi-package plugin primaries (telegram, rcon, ssh,
|
|
207
|
+
jira, queue-bullmq, queue-memory, cache-memory).
|
|
208
|
+
|
|
209
|
+
Breaking changes:
|
|
210
|
+
|
|
211
|
+
- The legacy single-method `PluginInstaller` interface (`install(packageName)`)
|
|
212
|
+
is removed. Callers must use `coreServices.pluginInstallerRegistry`.
|
|
213
|
+
- The old `pluginAdminContract` and `createPluginAdminRouter` are removed.
|
|
214
|
+
Replaced by `pluginManagerContract` in `@checkstack/pluginmanager-common`
|
|
215
|
+
and `createPluginManagerRouter` in `core/backend`.
|
|
216
|
+
- `@checkstack/test-utils-backend` no longer exports
|
|
217
|
+
`createMockPluginInstaller` / `MockPluginInstaller` (the legacy interface
|
|
218
|
+
it shimmed is gone).
|
|
219
|
+
|
|
220
|
+
Note: bumps are limited to `minor` (for packages with new public API
|
|
221
|
+
surface) and `patch` (for downstream consumers, license normalization,
|
|
222
|
+
and lint fixes). No `major` bumps despite the `PluginInstaller` removal —
|
|
223
|
+
the legacy interface had no third-party consumers in the wild before this
|
|
224
|
+
runtime plugin system landed, and the contract surface is the same shape
|
|
225
|
+
modulo the rename.
|
|
226
|
+
|
|
227
|
+
- Updated dependencies [50e5f5f]
|
|
228
|
+
- @checkstack/common@0.8.0
|
|
229
|
+
- @checkstack/signal-common@0.2.1
|
|
230
|
+
|
|
3
231
|
## 0.3.0
|
|
4
232
|
|
|
5
233
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/queue-common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"license": "Elastic-2.0",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"exports": {
|
|
6
7
|
".": {
|
|
@@ -8,20 +9,20 @@
|
|
|
8
9
|
}
|
|
9
10
|
},
|
|
10
11
|
"scripts": {
|
|
11
|
-
"typecheck": "
|
|
12
|
+
"typecheck": "tsgo -b",
|
|
12
13
|
"lint": "bun run lint:code",
|
|
13
14
|
"lint:code": "eslint . --max-warnings 0"
|
|
14
15
|
},
|
|
15
16
|
"dependencies": {
|
|
16
|
-
"@checkstack/common": "0.
|
|
17
|
-
"@checkstack/signal-common": "0.1
|
|
17
|
+
"@checkstack/common": "0.8.0",
|
|
18
|
+
"@checkstack/signal-common": "0.2.1",
|
|
18
19
|
"@orpc/contract": "^1.13.14",
|
|
19
20
|
"zod": "^4.0.0"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"typescript": "^5.7.2",
|
|
23
|
-
"@checkstack/tsconfig": "0.0.
|
|
24
|
-
"@checkstack/scripts": "0.
|
|
24
|
+
"@checkstack/tsconfig": "0.0.7",
|
|
25
|
+
"@checkstack/scripts": "0.3.0"
|
|
25
26
|
},
|
|
26
27
|
"checkstack": {
|
|
27
28
|
"type": "common"
|
package/src/rpc-contract.ts
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
QueueStatsDtoSchema,
|
|
10
10
|
QueueLagStatusSchema,
|
|
11
11
|
QueueLagThresholdsSchema,
|
|
12
|
+
ListJobsInputSchema,
|
|
13
|
+
ListJobsResultSchema,
|
|
12
14
|
} from "./schemas";
|
|
13
15
|
|
|
14
16
|
// Queue RPC Contract with access metadata
|
|
@@ -57,6 +59,15 @@ export const queueContract = {
|
|
|
57
59
|
})
|
|
58
60
|
.input(QueueLagThresholdsSchema)
|
|
59
61
|
.output(QueueLagThresholdsSchema),
|
|
62
|
+
|
|
63
|
+
// List jobs in a state — read access. Payloads omitted by design.
|
|
64
|
+
listJobs: proc({
|
|
65
|
+
operationType: "query",
|
|
66
|
+
userType: "authenticated",
|
|
67
|
+
access: [queueAccess.settings.read],
|
|
68
|
+
})
|
|
69
|
+
.input(ListJobsInputSchema)
|
|
70
|
+
.output(ListJobsResultSchema),
|
|
60
71
|
};
|
|
61
72
|
|
|
62
73
|
// Export contract type
|
package/src/schemas.ts
CHANGED
|
@@ -38,17 +38,68 @@ export type UpdateQueueConfiguration = z.infer<
|
|
|
38
38
|
>;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* Scope of a stats response: `"instance"` if the figures reflect just the
|
|
42
|
+
* local process (in-memory backends), `"cluster"` if they're shared across
|
|
43
|
+
* the deployment (Redis-backed backends).
|
|
44
|
+
*/
|
|
45
|
+
export const StatsScopeSchema = z.enum(["instance", "cluster"]);
|
|
46
|
+
export type StatsScope = z.infer<typeof StatsScopeSchema>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Queue statistics DTO. The `scope` field exists so the UI can warn users
|
|
50
|
+
* when in-memory backends are running with horizontal scaling.
|
|
42
51
|
*/
|
|
43
52
|
export const QueueStatsDtoSchema = z.object({
|
|
44
53
|
pending: z.number(),
|
|
45
54
|
processing: z.number(),
|
|
46
55
|
completed: z.number(),
|
|
47
56
|
failed: z.number(),
|
|
57
|
+
scope: StatsScopeSchema,
|
|
48
58
|
});
|
|
49
59
|
|
|
50
60
|
export type QueueStatsDto = z.infer<typeof QueueStatsDtoSchema>;
|
|
51
61
|
|
|
62
|
+
export const JobStateSchema = z.enum([
|
|
63
|
+
"pending",
|
|
64
|
+
"waiting",
|
|
65
|
+
"active",
|
|
66
|
+
"delayed",
|
|
67
|
+
"completed",
|
|
68
|
+
"failed",
|
|
69
|
+
]);
|
|
70
|
+
export type JobStateDto = z.infer<typeof JobStateSchema>;
|
|
71
|
+
|
|
72
|
+
export const JobSummaryDtoSchema = z.object({
|
|
73
|
+
id: z.string(),
|
|
74
|
+
name: z.string().optional(),
|
|
75
|
+
state: JobStateSchema,
|
|
76
|
+
enqueuedAt: z.coerce.date(),
|
|
77
|
+
startedAt: z.coerce.date().optional(),
|
|
78
|
+
finishedAt: z.coerce.date().optional(),
|
|
79
|
+
attempts: z.number().int().nonnegative(),
|
|
80
|
+
failedReason: z.string().optional(),
|
|
81
|
+
nextRunAt: z.coerce.date().optional(),
|
|
82
|
+
recurring: z.boolean().optional(),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export type JobSummaryDto = z.infer<typeof JobSummaryDtoSchema>;
|
|
86
|
+
|
|
87
|
+
export const ListJobsInputSchema = z.object({
|
|
88
|
+
state: JobStateSchema,
|
|
89
|
+
offset: z.number().int().nonnegative().default(0),
|
|
90
|
+
limit: z.number().int().min(1).max(200),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export type ListJobsInput = z.infer<typeof ListJobsInputSchema>;
|
|
94
|
+
|
|
95
|
+
export const ListJobsResultSchema = z.object({
|
|
96
|
+
items: z.array(JobSummaryDtoSchema),
|
|
97
|
+
total: z.number().int().nonnegative().nullable(),
|
|
98
|
+
hasMore: z.boolean(),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export type ListJobsResultDto = z.infer<typeof ListJobsResultSchema>;
|
|
102
|
+
|
|
52
103
|
/**
|
|
53
104
|
* Lag severity levels
|
|
54
105
|
*/
|