@checkstack/queue-common 0.1.0 → 0.2.1

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,91 @@
1
1
  # @checkstack/queue-common
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [83557c7]
8
+ - @checkstack/common@0.4.0
9
+ - @checkstack/signal-common@0.1.2
10
+
11
+ ## 0.2.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 180be38: # Queue Lag Warning
16
+
17
+ Added a queue lag warning system that displays alerts when pending jobs exceed configurable thresholds.
18
+
19
+ ## Features
20
+
21
+ - **Backend Stats API**: New `getStats`, `getLagStatus`, and `updateLagThresholds` RPC endpoints
22
+ - **Signal-based Updates**: `QUEUE_LAG_CHANGED` signal for real-time frontend updates
23
+ - **Aggregated Stats**: `QueueManager.getAggregatedStats()` sums stats across all queues
24
+ - **Configurable Thresholds**: Warning (default 100) and Critical (default 500) thresholds stored in config
25
+ - **Dashboard Integration**: Queue lag alert displayed on main Dashboard (access-gated)
26
+ - **Queue Settings Page**: Lag alert and Performance Tuning guidance card with concurrency tips
27
+
28
+ ## UI Changes
29
+
30
+ - Queue lag alert banner appears on Dashboard and Queue Settings when pending jobs exceed thresholds
31
+ - New "Performance Tuning" card with concurrency settings guidance and bottleneck indicators
32
+
33
+ - 7a23261: ## TanStack Query Integration
34
+
35
+ Migrated all frontend components to use `usePluginClient` hook with TanStack Query integration, replacing the legacy `forPlugin()` pattern.
36
+
37
+ ### New Features
38
+
39
+ - **`usePluginClient` hook**: Provides type-safe access to plugin APIs with `.useQuery()` and `.useMutation()` methods
40
+ - **Automatic request deduplication**: Multiple components requesting the same data share a single network request
41
+ - **Built-in caching**: Configurable stale time and cache duration per query
42
+ - **Loading/error states**: TanStack Query provides `isLoading`, `error`, `isRefetching` states automatically
43
+ - **Background refetching**: Stale data is automatically refreshed when components mount
44
+
45
+ ### Contract Changes
46
+
47
+ All RPC contracts now require `operationType: "query"` or `operationType: "mutation"` metadata:
48
+
49
+ ```typescript
50
+ const getItems = proc()
51
+ .meta({ operationType: "query", access: [access.read] })
52
+ .output(z.array(itemSchema))
53
+ .query();
54
+
55
+ const createItem = proc()
56
+ .meta({ operationType: "mutation", access: [access.manage] })
57
+ .input(createItemSchema)
58
+ .output(itemSchema)
59
+ .mutation();
60
+ ```
61
+
62
+ ### Migration
63
+
64
+ ```typescript
65
+ // Before (forPlugin pattern)
66
+ const api = useApi(myPluginApiRef);
67
+ const [items, setItems] = useState<Item[]>([]);
68
+ useEffect(() => {
69
+ api.getItems().then(setItems);
70
+ }, [api]);
71
+
72
+ // After (usePluginClient pattern)
73
+ const client = usePluginClient(MyPluginApi);
74
+ const { data: items, isLoading } = client.getItems.useQuery({});
75
+ ```
76
+
77
+ ### Bug Fixes
78
+
79
+ - Fixed `rpc.test.ts` test setup for middleware type inference
80
+ - Fixed `SearchDialog` to use `setQuery` instead of deprecated `search` method
81
+ - Fixed null→undefined warnings in notification and queue frontends
82
+
83
+ ### Patch Changes
84
+
85
+ - Updated dependencies [7a23261]
86
+ - @checkstack/common@0.3.0
87
+ - @checkstack/signal-common@0.1.1
88
+
3
89
  ## 0.1.0
4
90
 
5
91
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/queue-common",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -14,6 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@checkstack/common": "workspace:*",
17
+ "@checkstack/signal-common": "workspace:*",
17
18
  "@orpc/contract": "^1.13.2",
18
19
  "zod": "^4.0.0"
19
20
  },
package/src/index.ts CHANGED
@@ -3,3 +3,4 @@ export * from "./access";
3
3
  export { queueContract, QueueApi, type QueueContract } from "./rpc-contract";
4
4
  export * from "./plugin-metadata";
5
5
  export { queueRoutes } from "./routes";
6
+ export * from "./signals";
@@ -1,8 +1,4 @@
1
- import { oc } from "@orpc/contract";
2
- import {
3
- createClientDefinition,
4
- type ProcedureMetadata,
5
- } from "@checkstack/common";
1
+ import { createClientDefinition, proc } from "@checkstack/common";
6
2
  import { z } from "zod";
7
3
  import { queueAccess } from "./access";
8
4
  import { pluginMetadata } from "./plugin-metadata";
@@ -10,36 +6,57 @@ import {
10
6
  QueuePluginDtoSchema,
11
7
  QueueConfigurationDtoSchema,
12
8
  UpdateQueueConfigurationSchema,
9
+ QueueStatsDtoSchema,
10
+ QueueLagStatusSchema,
11
+ QueueLagThresholdsSchema,
13
12
  } from "./schemas";
14
13
 
15
- // Base builder with metadata support
16
- const _base = oc.$meta<ProcedureMetadata>({});
17
-
18
14
  // Queue RPC Contract with access metadata
19
15
  export const queueContract = {
20
16
  // Queue plugin queries - Read access
21
- getPlugins: _base
22
- .meta({
23
- userType: "authenticated",
24
- access: [queueAccess.settings.read],
25
- })
26
- .output(z.array(QueuePluginDtoSchema)),
27
-
28
- getConfiguration: _base
29
- .meta({
30
- userType: "authenticated",
31
- access: [queueAccess.settings.read],
32
- })
33
- .output(QueueConfigurationDtoSchema),
17
+ getPlugins: proc({
18
+ operationType: "query",
19
+ userType: "authenticated",
20
+ access: [queueAccess.settings.read],
21
+ }).output(z.array(QueuePluginDtoSchema)),
22
+
23
+ getConfiguration: proc({
24
+ operationType: "query",
25
+ userType: "authenticated",
26
+ access: [queueAccess.settings.read],
27
+ }).output(QueueConfigurationDtoSchema),
34
28
 
35
29
  // Queue configuration updates - Manage access
36
- updateConfiguration: _base
37
- .meta({
38
- userType: "authenticated",
39
- access: [queueAccess.settings.manage],
40
- })
30
+ updateConfiguration: proc({
31
+ operationType: "mutation",
32
+ userType: "authenticated",
33
+ access: [queueAccess.settings.manage],
34
+ })
41
35
  .input(UpdateQueueConfigurationSchema)
42
36
  .output(QueueConfigurationDtoSchema),
37
+
38
+ // Queue statistics - Read access
39
+ getStats: proc({
40
+ operationType: "query",
41
+ userType: "authenticated",
42
+ access: [queueAccess.settings.read],
43
+ }).output(QueueStatsDtoSchema),
44
+
45
+ // Queue lag status (includes thresholds) - Read access
46
+ getLagStatus: proc({
47
+ operationType: "query",
48
+ userType: "authenticated",
49
+ access: [queueAccess.settings.read],
50
+ }).output(QueueLagStatusSchema),
51
+
52
+ // Update lag thresholds - Manage access
53
+ updateLagThresholds: proc({
54
+ operationType: "mutation",
55
+ userType: "authenticated",
56
+ access: [queueAccess.settings.manage],
57
+ })
58
+ .input(QueueLagThresholdsSchema)
59
+ .output(QueueLagThresholdsSchema),
43
60
  };
44
61
 
45
62
  // Export contract type
package/src/schemas.ts CHANGED
@@ -36,3 +36,50 @@ export const UpdateQueueConfigurationSchema = z.object({
36
36
  export type UpdateQueueConfiguration = z.infer<
37
37
  typeof UpdateQueueConfigurationSchema
38
38
  >;
39
+
40
+ /**
41
+ * Queue statistics DTO
42
+ */
43
+ export const QueueStatsDtoSchema = z.object({
44
+ pending: z.number(),
45
+ processing: z.number(),
46
+ completed: z.number(),
47
+ failed: z.number(),
48
+ });
49
+
50
+ export type QueueStatsDto = z.infer<typeof QueueStatsDtoSchema>;
51
+
52
+ /**
53
+ * Lag severity levels
54
+ */
55
+ export const LagSeveritySchema = z.enum(["none", "warning", "critical"]);
56
+ export type LagSeverity = z.infer<typeof LagSeveritySchema>;
57
+
58
+ /**
59
+ * Queue lag thresholds configuration
60
+ */
61
+ export const QueueLagThresholdsSchema = z.object({
62
+ warningThreshold: z
63
+ .number()
64
+ .min(1)
65
+ .default(100)
66
+ .describe("Pending job count to trigger warning"),
67
+ criticalThreshold: z
68
+ .number()
69
+ .min(1)
70
+ .default(500)
71
+ .describe("Pending job count to trigger critical alert"),
72
+ });
73
+
74
+ export type QueueLagThresholds = z.infer<typeof QueueLagThresholdsSchema>;
75
+
76
+ /**
77
+ * Queue lag status response
78
+ */
79
+ export const QueueLagStatusSchema = z.object({
80
+ pending: z.number(),
81
+ severity: LagSeveritySchema,
82
+ thresholds: QueueLagThresholdsSchema,
83
+ });
84
+
85
+ export type QueueLagStatus = z.infer<typeof QueueLagStatusSchema>;
package/src/signals.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ import { createSignal } from "@checkstack/signal-common";
3
+ import { LagSeveritySchema } from "./schemas";
4
+
5
+ /**
6
+ * Signal broadcast when queue lag status changes.
7
+ * Frontend listens to update lag warning UI in real-time.
8
+ */
9
+ export const QUEUE_LAG_CHANGED = createSignal(
10
+ "queue.lag.changed",
11
+ z.object({
12
+ pending: z.number(),
13
+ severity: LagSeveritySchema,
14
+ })
15
+ );