@checkstack/maintenance-common 1.0.1 → 1.2.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 CHANGED
@@ -1,5 +1,110 @@
1
1
  # @checkstack/maintenance-common
2
2
 
3
+ ## 1.2.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/catalog-common@2.2.0
60
+ - @checkstack/notification-common@1.1.0
61
+ - @checkstack/frontend-api@0.5.1
62
+ - @checkstack/signal-common@0.2.3
63
+
64
+ ## 1.1.0
65
+
66
+ ### Minor Changes
67
+
68
+ - 1ef2e79: feat: hotlinks on incidents/maintenances and additional links on systems
69
+
70
+ Users with `manage` access on an incident, maintenance, or system can now
71
+ attach free-form URL "hotlinks" — Jira tickets, runbooks, dashboards, ticket
72
+ tools, etc. — alongside the existing fields.
73
+
74
+ - **Incidents** & **maintenances**: links live on the entity itself and are
75
+ surfaced both in the editor dialog and on the public detail page. Two new
76
+ RPC procedures per plugin (`addLink`, `removeLink`) gated behind the
77
+ existing `manage` access rule. Links are returned as part of
78
+ `getIncident` / `getMaintenance` and cache-invalidated on every link
79
+ mutation.
80
+ - **Systems**: a parallel `system_links` table with `getSystemLinks`,
81
+ `addSystemLink`, `removeSystemLink` procedures. Surfaced inside the
82
+ system editor (next to contacts) and on the read-only system detail
83
+ sidebar. Cache-scoped per-system so list endpoints remain hot.
84
+ - **Shared UI**: a `LinksEditor` component in `@checkstack/ui` does the
85
+ presentation; the three plugins each own their own RPC wiring.
86
+
87
+ Database changes ship as additive migrations (new `incident_links`,
88
+ `maintenance_links`, `system_links` tables, all FK-cascaded on parent
89
+ delete). No existing columns or rows are touched.
90
+
91
+ The system incident and maintenance history pages now sort by relevance:
92
+ active entries (non-`resolved` incidents, `scheduled` or `in_progress`
93
+ maintenances) appear at the top, with creation date descending as the
94
+ tiebreaker.
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies [42abfff]
99
+ - Updated dependencies [1ef2e79]
100
+ - Updated dependencies [aa89bc5]
101
+ - Updated dependencies [950d6ec]
102
+ - @checkstack/common@0.9.0
103
+ - @checkstack/catalog-common@2.1.0
104
+ - @checkstack/frontend-api@0.5.0
105
+ - @checkstack/notification-common@1.0.2
106
+ - @checkstack/signal-common@0.2.2
107
+
3
108
  ## 1.0.1
4
109
 
5
110
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/maintenance-common",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "license": "Elastic-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -9,18 +9,18 @@
9
9
  }
10
10
  },
11
11
  "dependencies": {
12
- "@checkstack/common": "0.7.0",
13
- "@checkstack/catalog-common": "2.0.0",
14
- "@checkstack/frontend-api": "0.4.1",
15
- "@checkstack/notification-common": "1.0.0",
16
- "@checkstack/signal-common": "0.2.0",
12
+ "@checkstack/common": "0.9.0",
13
+ "@checkstack/catalog-common": "2.1.0",
14
+ "@checkstack/frontend-api": "0.5.0",
15
+ "@checkstack/notification-common": "1.0.2",
16
+ "@checkstack/signal-common": "0.2.2",
17
17
  "@orpc/contract": "^1.13.14",
18
18
  "zod": "^4.2.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "typescript": "^5.7.2",
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
  },
25
25
  "scripts": {
26
26
  "typecheck": "tsgo -b",
package/src/index.ts CHANGED
@@ -10,6 +10,8 @@ export {
10
10
  MaintenanceWithSystemsSchema,
11
11
  MaintenanceUpdateSchema,
12
12
  MaintenanceDetailSchema,
13
+ MaintenanceLinkSchema,
14
+ AddMaintenanceLinkInputSchema,
13
15
  CreateMaintenanceInputSchema,
14
16
  UpdateMaintenanceInputSchema,
15
17
  AddMaintenanceUpdateInputSchema,
@@ -18,6 +20,8 @@ export {
18
20
  type MaintenanceWithSystems,
19
21
  type MaintenanceUpdate,
20
22
  type MaintenanceDetail,
23
+ type MaintenanceLink,
24
+ type AddMaintenanceLinkInput,
21
25
  type CreateMaintenanceInput,
22
26
  type UpdateMaintenanceInput,
23
27
  type AddMaintenanceUpdateInput,
@@ -6,6 +6,8 @@ import {
6
6
  MaintenanceWithSystemsSchema,
7
7
  MaintenanceDetailSchema,
8
8
  MaintenanceUpdateSchema,
9
+ MaintenanceLinkSchema,
10
+ AddMaintenanceLinkInputSchema,
9
11
  CreateMaintenanceInputSchema,
10
12
  UpdateMaintenanceInputSchema,
11
13
  AddMaintenanceUpdateInputSchema,
@@ -56,6 +58,7 @@ export const maintenanceContract = {
56
58
  access: [maintenanceAccess.maintenance.read],
57
59
  instanceAccess: { recordKey: "maintenances" },
58
60
  })
61
+ .route({ method: "POST" })
59
62
  .input(z.object({ systemIds: z.array(z.string()) }))
60
63
  .output(
61
64
  z.object({
@@ -81,6 +84,7 @@ export const maintenanceContract = {
81
84
  userType: "authenticated",
82
85
  access: [maintenanceAccess.maintenance.manage],
83
86
  })
87
+ .route({ method: "PATCH" })
84
88
  .input(UpdateMaintenanceInputSchema)
85
89
  .output(MaintenanceWithSystemsSchema),
86
90
 
@@ -102,12 +106,32 @@ export const maintenanceContract = {
102
106
  .input(z.object({ id: z.string(), message: z.string().optional() }))
103
107
  .output(MaintenanceWithSystemsSchema),
104
108
 
109
+ /** Add a hotlink (e.g. change ticket, runbook) to a maintenance */
110
+ addLink: proc({
111
+ operationType: "mutation",
112
+ userType: "authenticated",
113
+ access: [maintenanceAccess.maintenance.manage],
114
+ })
115
+ .input(AddMaintenanceLinkInputSchema)
116
+ .output(MaintenanceLinkSchema),
117
+
118
+ /** Remove a hotlink from a maintenance */
119
+ removeLink: proc({
120
+ operationType: "mutation",
121
+ userType: "authenticated",
122
+ access: [maintenanceAccess.maintenance.manage],
123
+ })
124
+ .route({ method: "DELETE" })
125
+ .input(z.object({ id: z.string() }))
126
+ .output(z.object({ success: z.boolean() })),
127
+
105
128
  /** Delete a maintenance */
106
129
  deleteMaintenance: proc({
107
130
  operationType: "mutation",
108
131
  userType: "authenticated",
109
132
  access: [maintenanceAccess.maintenance.manage],
110
133
  })
134
+ .route({ method: "DELETE" })
111
135
  .input(z.object({ id: z.string() }))
112
136
  .output(z.object({ success: z.boolean() })),
113
137
 
package/src/schemas.ts CHANGED
@@ -52,10 +52,32 @@ export const MaintenanceUpdateSchema = z.object({
52
52
  export type MaintenanceUpdate = z.infer<typeof MaintenanceUpdateSchema>;
53
53
 
54
54
  /**
55
- * Full maintenance detail with systems and updates
55
+ * Free-form hotlink attached to a maintenance (e.g. change ticket, runbook).
56
+ */
57
+ export const MaintenanceLinkSchema = z.object({
58
+ id: z.string(),
59
+ maintenanceId: z.string(),
60
+ label: z.string().nullable(),
61
+ url: z.string(),
62
+ createdAt: z.date(),
63
+ });
64
+ export type MaintenanceLink = z.infer<typeof MaintenanceLinkSchema>;
65
+
66
+ export const AddMaintenanceLinkInputSchema = z.object({
67
+ maintenanceId: z.string(),
68
+ label: z.string().max(120).optional(),
69
+ url: z.string().url("Must be a valid URL"),
70
+ });
71
+ export type AddMaintenanceLinkInput = z.infer<
72
+ typeof AddMaintenanceLinkInputSchema
73
+ >;
74
+
75
+ /**
76
+ * Full maintenance detail with systems, updates, and hotlinks
56
77
  */
57
78
  export const MaintenanceDetailSchema = MaintenanceWithSystemsSchema.extend({
58
79
  updates: z.array(MaintenanceUpdateSchema),
80
+ links: z.array(MaintenanceLinkSchema),
59
81
  });
60
82
  export type MaintenanceDetail = z.infer<typeof MaintenanceDetailSchema>;
61
83