@checkstack/queue-common 0.3.1 → 0.5.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 +182 -0
- package/package.json +5 -5
- package/src/rpc-contract.ts +13 -0
- package/src/schemas.ts +52 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,187 @@
|
|
|
1
1
|
# @checkstack/queue-common
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9016526: Add a `/rest/:pluginId/*` HTTP mount that serves every plugin's oRPC contract
|
|
8
|
+
through the REST/OpenAPI shape described by `/api/openapi.json`. Queries are
|
|
9
|
+
`GET` with query parameters, mutations are `POST` with the input as the raw
|
|
10
|
+
JSON body. The existing `/api/:pluginId/*` mount continues to serve oRPC's
|
|
11
|
+
native wire protocol unchanged, so existing clients are not affected.
|
|
12
|
+
|
|
13
|
+
The OpenAPI spec at `/api/openapi.json` now reflects the real mount: every
|
|
14
|
+
`paths` entry is prefixed with `/rest` instead of `/api`.
|
|
15
|
+
|
|
16
|
+
Also fixes a SPA-fallback bug: the backend's `/api-docs` route previously
|
|
17
|
+
returned 404 on production deployments because the static-file middleware
|
|
18
|
+
skipped any path starting with `/api`, capturing `/api-docs` along with real
|
|
19
|
+
API routes. The skip now requires a trailing slash (`/api/`, `/rest/`).
|
|
20
|
+
|
|
21
|
+
Required access rules are now visible in the API Docs UI. The OpenAPI spec
|
|
22
|
+
generator was reading a non-existent `accessRules` field on procedure
|
|
23
|
+
metadata; the real field is `access: AccessRule[]`. Each procedure's access
|
|
24
|
+
rules are now flattened to fully-qualified IDs (e.g. `catalog.system.read`)
|
|
25
|
+
and emitted under `x-orpc-meta.accessRules`, which the existing
|
|
26
|
+
`Required Access Rules` section in the docs UI already knew how to render.
|
|
27
|
+
|
|
28
|
+
The API Docs schema renderer now handles record types (zod `z.record`),
|
|
29
|
+
`$ref`s into `components.schemas`, `oneOf`/`anyOf`/`allOf`, nullable union
|
|
30
|
+
types (`type: ["string", "null"]`), and `format` qualifiers. Previously
|
|
31
|
+
record outputs like `{ statuses: object }` masked the actual value type;
|
|
32
|
+
they now render as `{ [key]: <ResolvedType> { ... } }` with the inner
|
|
33
|
+
schema expanded, capped at 12 levels with cycle detection.
|
|
34
|
+
|
|
35
|
+
**REST method conventions.** `proc()` now defaults to `GET` for queries and
|
|
36
|
+
`POST` for mutations on the `/rest` mount, using bracket-notation query
|
|
37
|
+
params (`?filter[status]=active&ids[0]=a`) for GET inputs. Existing
|
|
38
|
+
procedures were updated to follow REST semantics:
|
|
39
|
+
|
|
40
|
+
- `update*` mutations → `PATCH`
|
|
41
|
+
- `delete*` / `remove*` mutations → `DELETE`
|
|
42
|
+
- `getBulk*` queries and any query taking a large array input → `POST`
|
|
43
|
+
(because `@orpc/openapi@1.13.x` has no GET→POST URL-length fallback)
|
|
44
|
+
|
|
45
|
+
GET endpoints require an `object` input — bare scalars like
|
|
46
|
+
`.input(z.string())` are not valid on GET. `getSystemConfigurations` was
|
|
47
|
+
refactored from `.input(z.string())` to `.input(z.object({ systemId: ... }))`
|
|
48
|
+
to fit the GET shape; the only call-site update was the in-process router
|
|
49
|
+
unpacking `input.systemId` instead of passing `input` directly.
|
|
50
|
+
|
|
51
|
+
The API Docs UI now renders query parameters (path/query/header/cookie) in a
|
|
52
|
+
dedicated table for GET endpoints, and the fetch example shows them in the
|
|
53
|
+
URL with `<required>` / `<optional>` placeholders.
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- Updated dependencies [9016526]
|
|
58
|
+
- @checkstack/common@0.10.0
|
|
59
|
+
- @checkstack/signal-common@0.2.3
|
|
60
|
+
|
|
61
|
+
## 0.4.0
|
|
62
|
+
|
|
63
|
+
### Minor Changes
|
|
64
|
+
|
|
65
|
+
- aa89bc5: Replace the bespoke `registerInfrastructureTab()` registry with a standard
|
|
66
|
+
slot-extension contract (`InfrastructureTabsSlot` from
|
|
67
|
+
`@checkstack/infrastructure-common`). Plugins now contribute infrastructure
|
|
68
|
+
tabs via `createSlotExtension`, depending only on the slot owner.
|
|
69
|
+
|
|
70
|
+
The slot system in `@checkstack/frontend-api` gains a second type parameter
|
|
71
|
+
on `createSlot<TContext, TMetadata>` so extensions can declare typed static
|
|
72
|
+
metadata at registration time (label, icon, access rules, ordering for the
|
|
73
|
+
infrastructure tab bar). A new `useSlotExtensions(slot)` hook returns typed
|
|
74
|
+
extensions and subscribes to plugin lifecycle changes.
|
|
75
|
+
|
|
76
|
+
Each tab body now stacks a **Runtime** sub-section (live state, read-only)
|
|
77
|
+
on top of a **Configuration** sub-section (settings, gated by `canUpdate`).
|
|
78
|
+
|
|
79
|
+
**Queue runtime panel.** Surfaces aggregated counts (pending / processing /
|
|
80
|
+
completed / failed) plus three sub-tabs of recent jobs: **Active**, **Recent
|
|
81
|
+
failed** (with the failure message), and **Recent completed** (with
|
|
82
|
+
duration). Job payloads are deliberately not surfaced — they may carry
|
|
83
|
+
secrets and need a separate manage-access gate to be shown.
|
|
84
|
+
|
|
85
|
+
To support this, `Queue<T>` gains a required `listJobs(opts)` method
|
|
86
|
+
returning `JobSummary[]` (no payloads), and `QueueStats` gains a
|
|
87
|
+
`scope: "instance" | "cluster"` field. The in-memory queue keeps rolling
|
|
88
|
+
ring buffers (200 entries) for completed/failed history and tracks active
|
|
89
|
+
jobs by id; BullMQ uses native `getJobs`. `QueueManager.listJobs` aggregates
|
|
90
|
+
across queues and sorts (most-recent-first for terminal states, FIFO for
|
|
91
|
+
active/waiting/delayed).
|
|
92
|
+
|
|
93
|
+
**Cache runtime panel.** Lists the top N entries by size (or by recency) so
|
|
94
|
+
operators can debug a cache filling up. Values are deliberately omitted —
|
|
95
|
+
PII / secret risk. Backends opt in via an optional `listEntries?` method on
|
|
96
|
+
`CacheProvider`; non-supporting backends return `{ supported: false }` and
|
|
97
|
+
the UI renders a "not supported by this backend" hint. The in-memory cache
|
|
98
|
+
implements it using its existing per-entry byte tracking.
|
|
99
|
+
|
|
100
|
+
`CacheStats` also gains `scope: "instance" | "cluster"`.
|
|
101
|
+
|
|
102
|
+
**Multi-instance scope warning.** A new `<InstanceScopeBanner>` component in
|
|
103
|
+
`@checkstack/ui` renders a yellow banner above any runtime panel whose
|
|
104
|
+
backend reports `scope: "instance"` — i.e. in-memory queue or cache running
|
|
105
|
+
in a horizontally scaled deployment. The banner explains the metrics are
|
|
106
|
+
local to the responding replica and recommends switching to a clustered
|
|
107
|
+
backend (Redis-backed queue / cache) for cluster-wide visibility.
|
|
108
|
+
|
|
109
|
+
**Bug fix — stable cache provider proxy.** `CacheManagerImpl.getProvider()`
|
|
110
|
+
now returns a single stable proxy that delegates to whatever provider is
|
|
111
|
+
currently active. Previously, consumers of `createCachedScope` (and any
|
|
112
|
+
direct `cacheManager.getProvider()` caller) captured the active provider
|
|
113
|
+
reference at plugin-init time. After any `setActiveBackend` call — including
|
|
114
|
+
saving the same memory config in the new Cache tab, which reconstructs the
|
|
115
|
+
in-memory cache — those scopes wrote to an orphaned old provider while the
|
|
116
|
+
runtime panel read stats from the new (empty) one, making the runtime panel
|
|
117
|
+
appear to report 0 keys. With the proxy, all consumers share a single stable
|
|
118
|
+
identity and writes always land in the active provider.
|
|
119
|
+
|
|
120
|
+
**Bytes tracking on the in-memory cache.** `InMemoryCache.getStats().sizeBytes`
|
|
121
|
+
now returns a running approximation (UTF-8 bytes of the key plus
|
|
122
|
+
`v8.serialize(value).byteLength`, with a JSON fallback) that's kept in sync
|
|
123
|
+
across all eviction paths. Treat the number as a sanity gauge; it doesn't
|
|
124
|
+
include `Map` per-entry overhead.
|
|
125
|
+
|
|
126
|
+
**Pagination.** Both `Queue<T>.listJobs` and `CacheProvider.listEntries?`
|
|
127
|
+
are offset-paginated. Inputs gain an `offset: number`; outputs change to
|
|
128
|
+
`{ items, total: number | null, hasMore: boolean }`. `total` is nullable
|
|
129
|
+
so backends that can't compute it cheaply still paginate via `hasMore`.
|
|
130
|
+
The UI uses the existing `<Pagination>` component with a 25-row default
|
|
131
|
+
page size. `QueueManager.listJobs` aggregates by over-fetching
|
|
132
|
+
`[0, offset+limit)` per queue, merge-sorting, then slicing the window —
|
|
133
|
+
optimal for the single-queue case, acceptable for the multi-queue case
|
|
134
|
+
within the UI's reasonable page-depth bounds. BullMQ uses native offset
|
|
135
|
+
ranges via `getJobs(types, start, end)` plus `getJobCounts` for `total`.
|
|
136
|
+
|
|
137
|
+
**Pending tab.** The Queue runtime panel exposes a virtual `"pending"`
|
|
138
|
+
state (waiting ∪ delayed, FIFO). It's now the default sub-tab, since
|
|
139
|
+
"what's queued up?" is the most common question. Per-row state is shown
|
|
140
|
+
when viewing the combined list.
|
|
141
|
+
|
|
142
|
+
**Recurring schedules visible under Pending.** Cron- and interval-based
|
|
143
|
+
recurring jobs (e.g. healthchecks) are surfaced under Pending/Delayed
|
|
144
|
+
between fires, with a `nextRunAt` countdown column and a "(recurring)"
|
|
145
|
+
label. `JobSummary` gains optional `nextRunAt: Date` and `recurring:
|
|
146
|
+
boolean` fields. The in-memory queue synthesises these rows from its
|
|
147
|
+
`recurringJobs` registry; BullMQ already materialises the next fire of
|
|
148
|
+
each scheduler as a delayed job and we now surface its trigger time and
|
|
149
|
+
the `repeatJobKey`-derived `recurring` flag.
|
|
150
|
+
|
|
151
|
+
**Bug fix — drop hook emits with no listeners.** `EventBus.emit` no
|
|
152
|
+
longer enqueues a job when zero listeners (distributed or instance-local)
|
|
153
|
+
are registered for the hook. Previously, hooks like
|
|
154
|
+
`core.plugin.initialized` — emitted on every plugin init but subscribed
|
|
155
|
+
to by nothing in the core repo — accumulated one waiting job per emit
|
|
156
|
+
forever. The in-memory queue's `processNext` short-circuits when there
|
|
157
|
+
are zero consumer groups, so its post-loop cleanup never ran for these
|
|
158
|
+
orphaned jobs. The fix drops the emit at the source and logs a debug
|
|
159
|
+
line. Note: in distributed deployments using a Redis-backed queue, this
|
|
160
|
+
means a subscriber on another replica won't receive an event if no
|
|
161
|
+
replica that emits it has a local listener. Plugins needing cross-process
|
|
162
|
+
delivery must register their listener on every replica that should
|
|
163
|
+
receive the hook.
|
|
164
|
+
|
|
165
|
+
**Breaking notes (treated as minor under beta semantics)**:
|
|
166
|
+
|
|
167
|
+
- `@checkstack/infrastructure-common` removes `registerInfrastructureTab`
|
|
168
|
+
and `getInfrastructureTabs`; former callers must register an extension
|
|
169
|
+
into `InfrastructureTabsSlot`.
|
|
170
|
+
- `@checkstack/queue-api`'s `Queue<T>` interface requires the new
|
|
171
|
+
`listJobs(opts)` method returning `ListJobsResult` (paginated). Both
|
|
172
|
+
bundled queue backends (memory, BullMQ) are updated; out-of-tree
|
|
173
|
+
implementations will need to add it.
|
|
174
|
+
- `QueueStats` and `CacheStats` add a required `scope` field.
|
|
175
|
+
- `CacheProvider.listEntries?` (when implemented) now returns
|
|
176
|
+
`ListEntriesResult` instead of `CacheEntrySummary[]`.
|
|
177
|
+
- `JobState` adds a `"pending"` variant.
|
|
178
|
+
|
|
179
|
+
### Patch Changes
|
|
180
|
+
|
|
181
|
+
- Updated dependencies [42abfff]
|
|
182
|
+
- @checkstack/common@0.9.0
|
|
183
|
+
- @checkstack/signal-common@0.2.2
|
|
184
|
+
|
|
3
185
|
## 0.3.1
|
|
4
186
|
|
|
5
187
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/queue-common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"license": "Elastic-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
"lint:code": "eslint . --max-warnings 0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@checkstack/common": "0.
|
|
18
|
-
"@checkstack/signal-common": "0.2.
|
|
17
|
+
"@checkstack/common": "0.9.0",
|
|
18
|
+
"@checkstack/signal-common": "0.2.2",
|
|
19
19
|
"@orpc/contract": "^1.13.14",
|
|
20
20
|
"zod": "^4.0.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"typescript": "^5.7.2",
|
|
24
|
-
"@checkstack/tsconfig": "0.0.
|
|
25
|
-
"@checkstack/scripts": "0.1
|
|
24
|
+
"@checkstack/tsconfig": "0.0.7",
|
|
25
|
+
"@checkstack/scripts": "0.3.1"
|
|
26
26
|
},
|
|
27
27
|
"checkstack": {
|
|
28
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
|
|
@@ -32,6 +34,7 @@ export const queueContract = {
|
|
|
32
34
|
userType: "authenticated",
|
|
33
35
|
access: [queueAccess.settings.manage],
|
|
34
36
|
})
|
|
37
|
+
.route({ method: "PATCH" })
|
|
35
38
|
.input(UpdateQueueConfigurationSchema)
|
|
36
39
|
.output(QueueConfigurationDtoSchema),
|
|
37
40
|
|
|
@@ -55,8 +58,18 @@ export const queueContract = {
|
|
|
55
58
|
userType: "authenticated",
|
|
56
59
|
access: [queueAccess.settings.manage],
|
|
57
60
|
})
|
|
61
|
+
.route({ method: "PATCH" })
|
|
58
62
|
.input(QueueLagThresholdsSchema)
|
|
59
63
|
.output(QueueLagThresholdsSchema),
|
|
64
|
+
|
|
65
|
+
// List jobs in a state — read access. Payloads omitted by design.
|
|
66
|
+
listJobs: proc({
|
|
67
|
+
operationType: "query",
|
|
68
|
+
userType: "authenticated",
|
|
69
|
+
access: [queueAccess.settings.read],
|
|
70
|
+
})
|
|
71
|
+
.input(ListJobsInputSchema)
|
|
72
|
+
.output(ListJobsResultSchema),
|
|
60
73
|
};
|
|
61
74
|
|
|
62
75
|
// 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
|
*/
|