@checkstack/notification-backend 0.1.6 → 0.1.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 +28 -0
- package/package.json +1 -1
- package/src/oauth-callback-handler.ts +2 -2
- package/src/router.ts +2 -2
- package/src/service.ts +10 -10
- package/src/strategy-service.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @checkstack/notification-backend
|
|
2
2
|
|
|
3
|
+
## 0.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [db1f56f]
|
|
8
|
+
- @checkstack/common@0.6.0
|
|
9
|
+
- @checkstack/auth-backend@0.4.4
|
|
10
|
+
- @checkstack/auth-common@0.5.3
|
|
11
|
+
- @checkstack/backend-api@0.5.1
|
|
12
|
+
- @checkstack/notification-common@0.2.3
|
|
13
|
+
- @checkstack/signal-common@0.1.4
|
|
14
|
+
- @checkstack/queue-api@0.2.1
|
|
15
|
+
|
|
16
|
+
## 0.1.7
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 66a3963: Update database types to use SafeDatabase
|
|
21
|
+
|
|
22
|
+
- Updated all database type declarations from `NodePgDatabase` to `SafeDatabase` for compile-time safety
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [2c0822d]
|
|
25
|
+
- Updated dependencies [66a3963]
|
|
26
|
+
- Updated dependencies [66a3963]
|
|
27
|
+
- @checkstack/queue-api@0.2.0
|
|
28
|
+
- @checkstack/auth-backend@0.4.3
|
|
29
|
+
- @checkstack/backend-api@0.5.0
|
|
30
|
+
|
|
3
31
|
## 0.1.6
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -9,12 +9,12 @@ import type {
|
|
|
9
9
|
NotificationStrategyRegistry,
|
|
10
10
|
ConfigService,
|
|
11
11
|
} from "@checkstack/backend-api";
|
|
12
|
-
import type {
|
|
12
|
+
import type { SafeDatabase } from "@checkstack/backend-api";
|
|
13
13
|
import { createStrategyService } from "./strategy-service";
|
|
14
14
|
import type * as schema from "./schema";
|
|
15
15
|
|
|
16
16
|
export interface OAuthCallbackDeps {
|
|
17
|
-
db:
|
|
17
|
+
db: SafeDatabase<typeof schema>;
|
|
18
18
|
configService: ConfigService;
|
|
19
19
|
strategyRegistry: NotificationStrategyRegistry;
|
|
20
20
|
baseUrl: string;
|
package/src/router.ts
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "@checkstack/notification-common";
|
|
19
19
|
import { AuthApi } from "@checkstack/auth-common";
|
|
20
20
|
import type { SignalService } from "@checkstack/signal-common";
|
|
21
|
-
import {
|
|
21
|
+
import { SafeDatabase } from "@checkstack/backend-api";
|
|
22
22
|
import * as schema from "./schema";
|
|
23
23
|
import {
|
|
24
24
|
getUserNotifications,
|
|
@@ -89,7 +89,7 @@ function resolveContact({
|
|
|
89
89
|
* based on the contract's meta.userType and meta.access.
|
|
90
90
|
*/
|
|
91
91
|
export const createNotificationRouter = (
|
|
92
|
-
database:
|
|
92
|
+
database: SafeDatabase<typeof schema>,
|
|
93
93
|
configService: ConfigService,
|
|
94
94
|
signalService: SignalService,
|
|
95
95
|
strategyRegistry: NotificationStrategyRegistry,
|
package/src/service.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SafeDatabase } from "@checkstack/backend-api";
|
|
2
2
|
import { eq, and, count, desc, lt } from "drizzle-orm";
|
|
3
3
|
import * as schema from "./schema";
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ import * as schema from "./schema";
|
|
|
8
8
|
* Get notifications for a user (for router use)
|
|
9
9
|
*/
|
|
10
10
|
export async function getUserNotifications(
|
|
11
|
-
db:
|
|
11
|
+
db: SafeDatabase<typeof schema>,
|
|
12
12
|
userId: string,
|
|
13
13
|
options: { limit: number; offset: number; unreadOnly: boolean }
|
|
14
14
|
): Promise<{
|
|
@@ -44,7 +44,7 @@ export async function getUserNotifications(
|
|
|
44
44
|
* Get unread count for a user
|
|
45
45
|
*/
|
|
46
46
|
export async function getUnreadCount(
|
|
47
|
-
db:
|
|
47
|
+
db: SafeDatabase<typeof schema>,
|
|
48
48
|
userId: string
|
|
49
49
|
): Promise<number> {
|
|
50
50
|
const result = await db
|
|
@@ -64,7 +64,7 @@ export async function getUnreadCount(
|
|
|
64
64
|
* Mark notification(s) as read
|
|
65
65
|
*/
|
|
66
66
|
export async function markAsRead(
|
|
67
|
-
db:
|
|
67
|
+
db: SafeDatabase<typeof schema>,
|
|
68
68
|
userId: string,
|
|
69
69
|
notificationId?: string
|
|
70
70
|
): Promise<void> {
|
|
@@ -85,7 +85,7 @@ export async function markAsRead(
|
|
|
85
85
|
* Delete a notification
|
|
86
86
|
*/
|
|
87
87
|
export async function deleteNotification(
|
|
88
|
-
db:
|
|
88
|
+
db: SafeDatabase<typeof schema>,
|
|
89
89
|
userId: string,
|
|
90
90
|
notificationId: string
|
|
91
91
|
): Promise<void> {
|
|
@@ -103,7 +103,7 @@ export async function deleteNotification(
|
|
|
103
103
|
* Get all notification groups
|
|
104
104
|
*/
|
|
105
105
|
export async function getAllGroups(
|
|
106
|
-
db:
|
|
106
|
+
db: SafeDatabase<typeof schema>
|
|
107
107
|
): Promise<(typeof schema.notificationGroups.$inferSelect)[]> {
|
|
108
108
|
return db.select().from(schema.notificationGroups);
|
|
109
109
|
}
|
|
@@ -112,7 +112,7 @@ export async function getAllGroups(
|
|
|
112
112
|
* Get user's subscriptions with enriched group details
|
|
113
113
|
*/
|
|
114
114
|
export async function getEnrichedUserSubscriptions(
|
|
115
|
-
db:
|
|
115
|
+
db: SafeDatabase<typeof schema>,
|
|
116
116
|
userId: string
|
|
117
117
|
): Promise<
|
|
118
118
|
{
|
|
@@ -145,7 +145,7 @@ export async function getEnrichedUserSubscriptions(
|
|
|
145
145
|
* Subscribe user to a group
|
|
146
146
|
*/
|
|
147
147
|
export async function subscribeToGroup(
|
|
148
|
-
db:
|
|
148
|
+
db: SafeDatabase<typeof schema>,
|
|
149
149
|
userId: string,
|
|
150
150
|
groupId: string
|
|
151
151
|
): Promise<void> {
|
|
@@ -173,7 +173,7 @@ export async function subscribeToGroup(
|
|
|
173
173
|
* Unsubscribe user from a group
|
|
174
174
|
*/
|
|
175
175
|
export async function unsubscribeFromGroup(
|
|
176
|
-
db:
|
|
176
|
+
db: SafeDatabase<typeof schema>,
|
|
177
177
|
userId: string,
|
|
178
178
|
groupId: string
|
|
179
179
|
): Promise<void> {
|
|
@@ -196,7 +196,7 @@ export async function purgeOldNotifications({
|
|
|
196
196
|
enabled,
|
|
197
197
|
retentionDays,
|
|
198
198
|
}: {
|
|
199
|
-
db:
|
|
199
|
+
db: SafeDatabase<typeof schema>;
|
|
200
200
|
enabled: boolean;
|
|
201
201
|
retentionDays: number;
|
|
202
202
|
}): Promise<number> {
|
package/src/strategy-service.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
configString,
|
|
12
12
|
type ConfigService,
|
|
13
13
|
} from "@checkstack/backend-api";
|
|
14
|
-
import type {
|
|
14
|
+
import type { SafeDatabase } from "@checkstack/backend-api";
|
|
15
15
|
import type { NotificationStrategyRegistry } from "@checkstack/backend-api";
|
|
16
16
|
import type * as schema from "./schema";
|
|
17
17
|
|
|
@@ -78,7 +78,7 @@ const STRATEGY_META_VERSION = 1;
|
|
|
78
78
|
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
79
79
|
|
|
80
80
|
export interface StrategyServiceDeps {
|
|
81
|
-
db:
|
|
81
|
+
db: SafeDatabase<typeof schema>;
|
|
82
82
|
configService: ConfigService;
|
|
83
83
|
strategyRegistry: NotificationStrategyRegistry;
|
|
84
84
|
}
|