@checkstack/incident-backend 0.2.6 → 0.2.8
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 +31 -0
- package/package.json +1 -1
- package/src/index.ts +3 -3
- package/src/service.ts +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @checkstack/incident-backend
|
|
2
2
|
|
|
3
|
+
## 0.2.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [db1f56f]
|
|
8
|
+
- @checkstack/common@0.6.0
|
|
9
|
+
- @checkstack/backend-api@0.5.1
|
|
10
|
+
- @checkstack/catalog-backend@0.2.8
|
|
11
|
+
- @checkstack/catalog-common@1.2.4
|
|
12
|
+
- @checkstack/command-backend@0.1.7
|
|
13
|
+
- @checkstack/incident-common@0.3.4
|
|
14
|
+
- @checkstack/integration-backend@0.1.7
|
|
15
|
+
- @checkstack/integration-common@0.2.3
|
|
16
|
+
- @checkstack/signal-common@0.1.4
|
|
17
|
+
|
|
18
|
+
## 0.2.7
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 66a3963: Update database types to use SafeDatabase
|
|
23
|
+
|
|
24
|
+
- Updated all database type declarations from `NodePgDatabase` to `SafeDatabase` for compile-time safety
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [66a3963]
|
|
27
|
+
- Updated dependencies [66a3963]
|
|
28
|
+
- Updated dependencies [66a3963]
|
|
29
|
+
- @checkstack/catalog-backend@0.2.7
|
|
30
|
+
- @checkstack/integration-backend@0.1.6
|
|
31
|
+
- @checkstack/backend-api@0.5.0
|
|
32
|
+
- @checkstack/command-backend@0.1.6
|
|
33
|
+
|
|
3
34
|
## 0.2.6
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as schema from "./schema";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SafeDatabase } from "@checkstack/backend-api";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import {
|
|
5
5
|
incidentAccessRules,
|
|
@@ -112,7 +112,7 @@ export default createBackendPlugin({
|
|
|
112
112
|
const catalogClient = rpcClient.forPlugin(CatalogApi);
|
|
113
113
|
|
|
114
114
|
const service = new IncidentService(
|
|
115
|
-
database as
|
|
115
|
+
database as SafeDatabase<typeof schema>
|
|
116
116
|
);
|
|
117
117
|
const router = createRouter(
|
|
118
118
|
service,
|
|
@@ -151,7 +151,7 @@ export default createBackendPlugin({
|
|
|
151
151
|
},
|
|
152
152
|
// Phase 3: Subscribe to catalog events for cleanup
|
|
153
153
|
afterPluginsReady: async ({ database, logger, onHook }) => {
|
|
154
|
-
const typedDb = database as
|
|
154
|
+
const typedDb = database as SafeDatabase<typeof schema>;
|
|
155
155
|
const service = new IncidentService(typedDb);
|
|
156
156
|
|
|
157
157
|
// Subscribe to catalog system deletion to clean up associations
|
package/src/service.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { eq, and, inArray, ne } from "drizzle-orm";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SafeDatabase } from "@checkstack/backend-api";
|
|
3
3
|
import * as schema from "./schema";
|
|
4
4
|
import { incidents, incidentSystems, incidentUpdates } from "./schema";
|
|
5
5
|
import type {
|
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
IncidentStatus,
|
|
13
13
|
} from "@checkstack/incident-common";
|
|
14
14
|
|
|
15
|
-
type Db =
|
|
15
|
+
type Db = SafeDatabase<typeof schema>;
|
|
16
16
|
|
|
17
17
|
function generateId(): string {
|
|
18
18
|
return crypto.randomUUID();
|
|
@@ -44,8 +44,8 @@ export class IncidentService {
|
|
|
44
44
|
const statusFilter = filters.status
|
|
45
45
|
? eq(incidents.status, filters.status)
|
|
46
46
|
: filters.includeResolved
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
? undefined
|
|
48
|
+
: ne(incidents.status, "resolved");
|
|
49
49
|
|
|
50
50
|
incidentRows = await this.db
|
|
51
51
|
.select()
|
|
@@ -55,8 +55,8 @@ export class IncidentService {
|
|
|
55
55
|
const statusFilter = filters?.status
|
|
56
56
|
? eq(incidents.status, filters.status)
|
|
57
57
|
: filters?.includeResolved
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
? undefined
|
|
59
|
+
: ne(incidents.status, "resolved");
|
|
60
60
|
|
|
61
61
|
incidentRows = await this.db.select().from(incidents).where(statusFilter);
|
|
62
62
|
}
|
|
@@ -116,7 +116,7 @@ export class IncidentService {
|
|
|
116
116
|
* Get active incidents for a system
|
|
117
117
|
*/
|
|
118
118
|
async getIncidentsForSystem(
|
|
119
|
-
systemId: string
|
|
119
|
+
systemId: string,
|
|
120
120
|
): Promise<IncidentWithSystems[]> {
|
|
121
121
|
// Get incident IDs for this system
|
|
122
122
|
const systemIncidents = await this.db
|
|
@@ -156,7 +156,7 @@ export class IncidentService {
|
|
|
156
156
|
*/
|
|
157
157
|
async createIncident(
|
|
158
158
|
input: CreateIncidentInput,
|
|
159
|
-
userId?: string
|
|
159
|
+
userId?: string,
|
|
160
160
|
): Promise<IncidentWithSystems> {
|
|
161
161
|
const id = generateId();
|
|
162
162
|
|
|
@@ -194,7 +194,7 @@ export class IncidentService {
|
|
|
194
194
|
* Update an existing incident
|
|
195
195
|
*/
|
|
196
196
|
async updateIncident(
|
|
197
|
-
input: UpdateIncidentInput
|
|
197
|
+
input: UpdateIncidentInput,
|
|
198
198
|
): Promise<IncidentWithSystems | undefined> {
|
|
199
199
|
const [existing] = await this.db
|
|
200
200
|
.select()
|
|
@@ -239,7 +239,7 @@ export class IncidentService {
|
|
|
239
239
|
*/
|
|
240
240
|
async addUpdate(
|
|
241
241
|
input: AddIncidentUpdateInput,
|
|
242
|
-
userId?: string
|
|
242
|
+
userId?: string,
|
|
243
243
|
): Promise<IncidentUpdate> {
|
|
244
244
|
const id = generateId();
|
|
245
245
|
|
|
@@ -277,7 +277,7 @@ export class IncidentService {
|
|
|
277
277
|
async resolveIncident(
|
|
278
278
|
id: string,
|
|
279
279
|
message?: string,
|
|
280
|
-
userId?: string
|
|
280
|
+
userId?: string,
|
|
281
281
|
): Promise<IncidentWithSystems | undefined> {
|
|
282
282
|
const [existing] = await this.db
|
|
283
283
|
.select()
|