@checkstack/catalog-backend 0.2.5 → 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 +25 -0
- package/package.json +1 -1
- package/src/index.ts +12 -10
- package/src/router.ts +2 -2
- package/src/services/entity-service.test.ts +2 -2
- package/src/services/entity-service.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @checkstack/catalog-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
|
+
- @checkstack/backend-api@0.5.0
|
|
13
|
+
- @checkstack/command-backend@0.1.6
|
|
14
|
+
|
|
15
|
+
## 0.2.6
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [8a87cd4]
|
|
20
|
+
- Updated dependencies [8a87cd4]
|
|
21
|
+
- Updated dependencies [8a87cd4]
|
|
22
|
+
- @checkstack/backend-api@0.4.1
|
|
23
|
+
- @checkstack/catalog-common@1.2.3
|
|
24
|
+
- @checkstack/common@0.5.0
|
|
25
|
+
- @checkstack/command-backend@0.1.5
|
|
26
|
+
- @checkstack/notification-common@0.2.2
|
|
27
|
+
|
|
3
28
|
## 0.2.5
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
createBackendPlugin,
|
|
3
|
+
type SafeDatabase,
|
|
4
|
+
} from "@checkstack/backend-api";
|
|
3
5
|
import { coreServices } from "@checkstack/backend-api";
|
|
4
6
|
import {
|
|
5
7
|
catalogAccessRules,
|
|
@@ -16,7 +18,7 @@ import { registerSearchProvider } from "@checkstack/command-backend";
|
|
|
16
18
|
// Database schema is still needed for types in creating the router
|
|
17
19
|
import * as schema from "./schema";
|
|
18
20
|
|
|
19
|
-
export let db:
|
|
21
|
+
export let db: SafeDatabase<typeof schema> | undefined;
|
|
20
22
|
|
|
21
23
|
// Export hooks for other plugins to subscribe to
|
|
22
24
|
export { catalogHooks } from "./hooks";
|
|
@@ -37,7 +39,7 @@ export default createBackendPlugin({
|
|
|
37
39
|
init: async ({ database, rpc, rpcClient, logger }) => {
|
|
38
40
|
logger.debug("Initializing Catalog Backend...");
|
|
39
41
|
|
|
40
|
-
const typedDb = database as
|
|
42
|
+
const typedDb = database as SafeDatabase<typeof schema>;
|
|
41
43
|
|
|
42
44
|
// Get notification client for group management and sending notifications
|
|
43
45
|
const notificationClient = rpcClient.forPlugin(NotificationApi);
|
|
@@ -66,7 +68,7 @@ export default createBackendPlugin({
|
|
|
66
68
|
(s) =>
|
|
67
69
|
!q ||
|
|
68
70
|
s.name.toLowerCase().includes(q) ||
|
|
69
|
-
s.description?.toLowerCase().includes(q)
|
|
71
|
+
s.description?.toLowerCase().includes(q),
|
|
70
72
|
)
|
|
71
73
|
.map((s) => ({
|
|
72
74
|
id: s.id,
|
|
@@ -107,7 +109,7 @@ export default createBackendPlugin({
|
|
|
107
109
|
},
|
|
108
110
|
// Phase 3: Safe to make RPC calls after all plugins are ready
|
|
109
111
|
afterPluginsReady: async ({ database, rpcClient, logger }) => {
|
|
110
|
-
const typedDb = database as
|
|
112
|
+
const typedDb = database as SafeDatabase<typeof schema>;
|
|
111
113
|
const notificationClient = rpcClient.forPlugin(NotificationApi);
|
|
112
114
|
|
|
113
115
|
// Bootstrap: Create notification groups for existing systems and groups
|
|
@@ -121,9 +123,9 @@ export default createBackendPlugin({
|
|
|
121
123
|
* Bootstrap notification groups for existing catalog entities
|
|
122
124
|
*/
|
|
123
125
|
async function bootstrapNotificationGroups(
|
|
124
|
-
database:
|
|
126
|
+
database: SafeDatabase<typeof schema>,
|
|
125
127
|
notificationClient: InferClient<typeof NotificationApi>,
|
|
126
|
-
logger: { debug: (msg: string) => void }
|
|
128
|
+
logger: { debug: (msg: string) => void },
|
|
127
129
|
) {
|
|
128
130
|
try {
|
|
129
131
|
// Get all existing systems and groups
|
|
@@ -151,14 +153,14 @@ async function bootstrapNotificationGroups(
|
|
|
151
153
|
}
|
|
152
154
|
|
|
153
155
|
logger.debug(
|
|
154
|
-
`Bootstrapped notification groups for ${systems.length} systems and ${groups.length} groups
|
|
156
|
+
`Bootstrapped notification groups for ${systems.length} systems and ${groups.length} groups`,
|
|
155
157
|
);
|
|
156
158
|
} catch (error) {
|
|
157
159
|
// Don't fail startup if notification service is unavailable
|
|
158
160
|
logger.debug(
|
|
159
161
|
`Failed to bootstrap notification groups: ${
|
|
160
162
|
error instanceof Error ? error.message : "Unknown error"
|
|
161
|
-
}
|
|
163
|
+
}`,
|
|
162
164
|
);
|
|
163
165
|
}
|
|
164
166
|
}
|
package/src/router.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { implement, ORPCError } from "@orpc/server";
|
|
|
2
2
|
import { autoAuthMiddleware, type RpcContext } from "@checkstack/backend-api";
|
|
3
3
|
import { catalogContract } from "@checkstack/catalog-common";
|
|
4
4
|
import { EntityService } from "./services/entity-service";
|
|
5
|
-
import type {
|
|
5
|
+
import type { SafeDatabase } from "@checkstack/backend-api";
|
|
6
6
|
import * as schema from "./schema";
|
|
7
7
|
import { NotificationApi } from "@checkstack/notification-common";
|
|
8
8
|
import type { InferClient } from "@checkstack/common";
|
|
@@ -20,7 +20,7 @@ const os = implement(catalogContract)
|
|
|
20
20
|
.use(autoAuthMiddleware);
|
|
21
21
|
|
|
22
22
|
export interface CatalogRouterDeps {
|
|
23
|
-
database:
|
|
23
|
+
database: SafeDatabase<typeof schema>;
|
|
24
24
|
notificationClient: InferClient<typeof NotificationApi>;
|
|
25
25
|
pluginId: string;
|
|
26
26
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, mock } from "bun:test";
|
|
2
2
|
import { EntityService } from "./entity-service";
|
|
3
3
|
import * as schema from "../schema";
|
|
4
|
-
import {
|
|
4
|
+
import { SafeDatabase } from "@checkstack/backend-api";
|
|
5
5
|
|
|
6
6
|
describe("EntityService", () => {
|
|
7
7
|
const mockDb = {
|
|
@@ -23,7 +23,7 @@ describe("EntityService", () => {
|
|
|
23
23
|
delete: mock(() => ({
|
|
24
24
|
where: mock(() => Promise.resolve()),
|
|
25
25
|
})),
|
|
26
|
-
} as unknown as
|
|
26
|
+
} as unknown as SafeDatabase<typeof schema>;
|
|
27
27
|
|
|
28
28
|
const service = new EntityService(mockDb);
|
|
29
29
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { eq, and } from "drizzle-orm";
|
|
2
2
|
import * as schema from "../schema";
|
|
3
|
-
import {
|
|
3
|
+
import { SafeDatabase } from "@checkstack/backend-api";
|
|
4
4
|
import { v4 as uuidv4 } from "uuid";
|
|
5
5
|
|
|
6
6
|
// Type aliases for entity creation
|
|
@@ -23,9 +23,9 @@ type NewView = {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export class EntityService {
|
|
26
|
-
private database:
|
|
26
|
+
private database: SafeDatabase<typeof schema>;
|
|
27
27
|
|
|
28
|
-
constructor(database:
|
|
28
|
+
constructor(database: SafeDatabase<typeof schema>) {
|
|
29
29
|
this.database = database;
|
|
30
30
|
}
|
|
31
31
|
|