vintasend-prisma 0.2.0 → 0.2.1
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.
|
@@ -64,6 +64,9 @@ export interface NotificationPrismaClientInterface<NotificationIdType, UserIdTyp
|
|
|
64
64
|
user?: boolean;
|
|
65
65
|
};
|
|
66
66
|
}): Promise<PrismaNotificationModel<NotificationIdType, UserIdType>>;
|
|
67
|
+
createMany(args: {
|
|
68
|
+
data: BaseNotificationCreateInput<UserIdType>[];
|
|
69
|
+
}): Promise<NotificationIdType[]>;
|
|
67
70
|
update(args: {
|
|
68
71
|
where: {
|
|
69
72
|
id: NotificationIdType;
|
|
@@ -142,7 +145,9 @@ export declare class PrismaNotificationBackend<Client extends NotificationPrisma
|
|
|
142
145
|
getAllFutureNotifications(): Promise<DatabaseNotification<Config>[]>;
|
|
143
146
|
getFutureNotifications(): Promise<DatabaseNotification<Config>[]>;
|
|
144
147
|
getAllFutureNotificationsFromUser(userId: NonNullable<Awaited<ReturnType<typeof this.prismaClient.notification.findUnique>>>['userId']): Promise<DatabaseNotification<Config>[]>;
|
|
145
|
-
getFutureNotificationsFromUser(userId: NonNullable<Awaited<ReturnType<typeof this.prismaClient.notification.findUnique>>>['userId']): Promise<DatabaseNotification<Config>[]>;
|
|
148
|
+
getFutureNotificationsFromUser(userId: NonNullable<Awaited<ReturnType<typeof this.prismaClient.notification.findUnique>>>['userId'], page: number, pageSize: number): Promise<DatabaseNotification<Config>[]>;
|
|
149
|
+
getAllNotifications(): Promise<DatabaseNotification<Config>[]>;
|
|
150
|
+
getNotifications(page: number, pageSize: number): Promise<DatabaseNotification<Config>[]>;
|
|
146
151
|
persistNotification(notification: NotificationInput<Config>): Promise<DatabaseNotification<Config>>;
|
|
147
152
|
persistNotificationUpdate(notificationId: NonNullable<Awaited<ReturnType<typeof this.prismaClient.notification.findUnique>>>['id'], notification: Partial<Omit<DatabaseNotification<Config>, 'id'>>): Promise<DatabaseNotification<Config>>;
|
|
148
153
|
markAsSent(notificationId: NonNullable<Awaited<ReturnType<typeof this.prismaClient.notification.findUnique>>>['id'], checkIsPending?: boolean): Promise<DatabaseNotification<Config>>;
|
|
@@ -154,6 +159,7 @@ export declare class PrismaNotificationBackend<Client extends NotificationPrisma
|
|
|
154
159
|
filterInAppUnreadNotifications(userId: NonNullable<Awaited<ReturnType<typeof this.prismaClient.notification.findUnique>>>['userId'], page: number, pageSize: number): Promise<DatabaseNotification<Config>[]>;
|
|
155
160
|
getUserEmailFromNotification(notificationId: NonNullable<Awaited<ReturnType<typeof this.prismaClient.notification.findUnique>>>['id']): Promise<string | undefined>;
|
|
156
161
|
storeContextUsed(notificationId: NonNullable<Awaited<ReturnType<typeof this.prismaClient.notification.findUnique>>>['id'], context: InputJsonValue): Promise<void>;
|
|
162
|
+
bulkPersistNotifications(notifications: Omit<Notification<Config>, 'id'>[]): Promise<Config['NotificationIdType'][]>;
|
|
157
163
|
}
|
|
158
164
|
export declare class PrismaNotificationBackendFactory<Config extends BaseNotificationTypeConfig> {
|
|
159
165
|
create<Client extends NotificationPrismaClientInterface<Config['NotificationIdType'], Config['UserIdType']>>(prismaClient: Client): PrismaNotificationBackend<Client, Config>;
|
|
@@ -143,7 +143,7 @@ class PrismaNotificationBackend {
|
|
|
143
143
|
});
|
|
144
144
|
return notifications.map(this.serializeNotification);
|
|
145
145
|
}
|
|
146
|
-
async getFutureNotificationsFromUser(userId) {
|
|
146
|
+
async getFutureNotificationsFromUser(userId, page, pageSize) {
|
|
147
147
|
const notifications = await this.prismaClient.notification.findMany({
|
|
148
148
|
where: {
|
|
149
149
|
userId,
|
|
@@ -154,6 +154,19 @@ class PrismaNotificationBackend {
|
|
|
154
154
|
lte: new Date(),
|
|
155
155
|
},
|
|
156
156
|
},
|
|
157
|
+
skip: page * pageSize,
|
|
158
|
+
take: pageSize,
|
|
159
|
+
});
|
|
160
|
+
return notifications.map(this.serializeNotification);
|
|
161
|
+
}
|
|
162
|
+
async getAllNotifications() {
|
|
163
|
+
const notifications = await this.prismaClient.notification.findMany({});
|
|
164
|
+
return notifications.map(this.serializeNotification);
|
|
165
|
+
}
|
|
166
|
+
async getNotifications(page, pageSize) {
|
|
167
|
+
const notifications = await this.prismaClient.notification.findMany({
|
|
168
|
+
skip: page * pageSize,
|
|
169
|
+
take: pageSize,
|
|
157
170
|
});
|
|
158
171
|
return notifications.map(this.serializeNotification);
|
|
159
172
|
}
|
|
@@ -271,6 +284,11 @@ class PrismaNotificationBackend {
|
|
|
271
284
|
},
|
|
272
285
|
});
|
|
273
286
|
}
|
|
287
|
+
async bulkPersistNotifications(notifications) {
|
|
288
|
+
return this.prismaClient.notification.createMany({
|
|
289
|
+
data: notifications.map((notification) => this.deserializeNotification(notification)),
|
|
290
|
+
});
|
|
291
|
+
}
|
|
274
292
|
}
|
|
275
293
|
exports.PrismaNotificationBackend = PrismaNotificationBackend;
|
|
276
294
|
class PrismaNotificationBackendFactory {
|