@checkstack/incident-backend 0.2.6 → 0.2.7

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,21 @@
1
1
  # @checkstack/incident-backend
2
2
 
3
+ ## 0.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 66a3963: Update database types to use SafeDatabase
8
+
9
+ - Updated all database type declarations from `NodePgDatabase` to `SafeDatabase` for compile-time safety
10
+
11
+ - Updated dependencies [66a3963]
12
+ - Updated dependencies [66a3963]
13
+ - Updated dependencies [66a3963]
14
+ - @checkstack/catalog-backend@0.2.7
15
+ - @checkstack/integration-backend@0.1.6
16
+ - @checkstack/backend-api@0.5.0
17
+ - @checkstack/command-backend@0.1.6
18
+
3
19
  ## 0.2.6
4
20
 
5
21
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/incident-backend",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as schema from "./schema";
2
- import type { NodePgDatabase } from "drizzle-orm/node-postgres";
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 NodePgDatabase<typeof schema>
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 NodePgDatabase<typeof schema>;
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 { NodePgDatabase } from "drizzle-orm/node-postgres";
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 = NodePgDatabase<typeof schema>;
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
- ? undefined
48
- : ne(incidents.status, "resolved");
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
- ? undefined
59
- : ne(incidents.status, "resolved");
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()