@dudousxd/nestjs-notifications-database 0.1.0 → 0.3.0
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/dist/database.channel.d.ts +3 -1
- package/dist/database.channel.d.ts.map +1 -1
- package/dist/database.channel.js +7 -3
- package/dist/database.channel.js.map +1 -1
- package/dist/database.module.d.ts.map +1 -1
- package/dist/database.module.js +5 -3
- package/dist/database.module.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/notifications-query.service.d.ts +53 -0
- package/dist/notifications-query.service.d.ts.map +1 -0
- package/dist/notifications-query.service.js +102 -0
- package/dist/notifications-query.service.js.map +1 -0
- package/dist/notifications.controller.d.ts +36 -0
- package/dist/notifications.controller.d.ts.map +1 -0
- package/dist/notifications.controller.js +125 -0
- package/dist/notifications.controller.js.map +1 -0
- package/package.json +4 -4
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ChannelDriver, type Notifiable, type Notification } from '@dudousxd/nestjs-notifications-core';
|
|
2
2
|
import type { NotificationStore } from './interfaces';
|
|
3
|
+
/** Channel handle: use as `@Database()` on a payload method, or as a token in `via()`. */
|
|
4
|
+
export declare const Database: import("@dudousxd/nestjs-notifications-core").ChannelHandle;
|
|
3
5
|
/**
|
|
4
6
|
* Persists notifications via a {@link NotificationStore} so they can be shown in-app.
|
|
5
7
|
* Reads the payload from `toDatabase()`, then `toArray()`, then a structural copy.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.channel.d.ts","sourceRoot":"","sources":["../src/database.channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"database.channel.d.ts","sourceRoot":"","sources":["../src/database.channel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,UAAU,EAEf,KAAK,YAAY,EAGlB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAwB,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAG5E,0FAA0F;AAC1F,eAAO,MAAM,QAAQ,6DAA4B,CAAC;AAElD;;;GAGG;AACH,qBACa,eAAgB,YAAW,aAAa;IAKjD,OAAO,CAAC,QAAQ,CAAC,KAAK;IAJxB,QAAQ,CAAC,OAAO,cAAc;gBAIX,KAAK,EAAE,iBAAiB;IAGrC,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAe7E,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,UAAU;CAUnB"}
|
package/dist/database.channel.js
CHANGED
|
@@ -12,9 +12,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.DatabaseChannel = void 0;
|
|
15
|
+
exports.DatabaseChannel = exports.Database = void 0;
|
|
16
|
+
const nestjs_notifications_core_1 = require("@dudousxd/nestjs-notifications-core");
|
|
16
17
|
const common_1 = require("@nestjs/common");
|
|
17
18
|
const tokens_1 = require("./tokens");
|
|
19
|
+
/** Channel handle: use as `@Database()` on a payload method, or as a token in `via()`. */
|
|
20
|
+
exports.Database = (0, nestjs_notifications_core_1.createChannel)('database');
|
|
18
21
|
/**
|
|
19
22
|
* Persists notifications via a {@link NotificationStore} so they can be shown in-app.
|
|
20
23
|
* Reads the payload from `toDatabase()`, then `toArray()`, then a structural copy.
|
|
@@ -47,8 +50,9 @@ let DatabaseChannel = class DatabaseChannel {
|
|
|
47
50
|
'notifiable, or return { type, id } from routeNotificationFor("database").');
|
|
48
51
|
}
|
|
49
52
|
payloadFor(notifiable, notification) {
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
const handler = (0, nestjs_notifications_core_1.getHandler)(notification, 'database', 'toDatabase');
|
|
54
|
+
if (handler)
|
|
55
|
+
return handler(notifiable);
|
|
52
56
|
if (typeof notification.toArray === 'function')
|
|
53
57
|
return notification.toArray(notifiable);
|
|
54
58
|
const { ...rest } = notification;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.channel.js","sourceRoot":"","sources":["../src/database.channel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"database.channel.js","sourceRoot":"","sources":["../src/database.channel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mFAO6C;AAC7C,2CAAoD;AAEpD,qCAA8C;AAE9C,0FAA0F;AAC7E,QAAA,QAAQ,GAAG,IAAA,yCAAa,EAAC,UAAU,CAAC,CAAC;AAElD;;;GAGG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAKP;IAJV,OAAO,GAAG,UAAU,CAAC;IAE9B,YAEmB,KAAwB;QAAxB,UAAK,GAAL,KAAK,CAAmB;IACxC,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,UAAsB,EAAE,YAA0B;QAC3D,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACxD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACvD,MAAM,IAAI,GACP,YAAY,CAAC,WAA6C,CAAC,gBAAgB;YAC5E,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC;QAEhC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YACpB,IAAI;YACJ,cAAc,EAAE,GAAG,CAAC,IAAI;YACxB,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAEO,YAAY,CAAC,UAAsB,EAAE,YAA0B;QACrE,MAAM,MAAM,GAAG,UAAU,CAAC,oBAAoB,CAAC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+
{"version":3,"file":"database.module.d.ts","sourceRoot":"","sources":["../src/database.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAyB,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAItD,MAAM,WAAW,sBAAsB;IACrC,wEAAwE;IACxE,KAAK,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAChC,+EAA+E;IAC/E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wFAAwF;IACxF,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACpC;AAED;;;;;;;GAOG;AACH,qBACa,qBAAqB;IAChC,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,sBAA2B,GAAG,aAAa;IAiBnE,8FAA8F;IAC9F,MAAM,CAAC,UAAU,IAAI,aAAa;CAOnC"}
|
package/dist/database.module.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.DatabaseChannelModule = void 0;
|
|
|
11
11
|
const common_1 = require("@nestjs/common");
|
|
12
12
|
const database_channel_1 = require("./database.channel");
|
|
13
13
|
const in_memory_store_1 = require("./in-memory.store");
|
|
14
|
+
const notifications_query_service_1 = require("./notifications-query.service");
|
|
14
15
|
const tokens_1 = require("./tokens");
|
|
15
16
|
/**
|
|
16
17
|
* Registers the database channel. Pair with an ORM adapter package
|
|
@@ -27,21 +28,22 @@ let DatabaseChannelModule = DatabaseChannelModule_1 = class DatabaseChannelModul
|
|
|
27
28
|
storeClass,
|
|
28
29
|
{ provide: tokens_1.NOTIFICATION_STORE, useExisting: storeClass },
|
|
29
30
|
database_channel_1.DatabaseChannel,
|
|
31
|
+
notifications_query_service_1.NotificationsQueryService,
|
|
30
32
|
];
|
|
31
33
|
return {
|
|
32
34
|
module: DatabaseChannelModule_1,
|
|
33
35
|
global: options.global ?? true,
|
|
34
36
|
imports: options.imports ?? [],
|
|
35
37
|
providers,
|
|
36
|
-
exports: [database_channel_1.DatabaseChannel, tokens_1.NOTIFICATION_STORE],
|
|
38
|
+
exports: [database_channel_1.DatabaseChannel, tokens_1.NOTIFICATION_STORE, notifications_query_service_1.NotificationsQueryService],
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
41
|
/** Register with an already-provided store token (e.g. provided by an ORM adapter module). */
|
|
40
42
|
static forFeature() {
|
|
41
43
|
return {
|
|
42
44
|
module: DatabaseChannelModule_1,
|
|
43
|
-
providers: [database_channel_1.DatabaseChannel],
|
|
44
|
-
exports: [database_channel_1.DatabaseChannel],
|
|
45
|
+
providers: [database_channel_1.DatabaseChannel, notifications_query_service_1.NotificationsQueryService],
|
|
46
|
+
exports: [database_channel_1.DatabaseChannel, notifications_query_service_1.NotificationsQueryService],
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.module.js","sourceRoot":"","sources":["../src/database.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAsF;AACtF,yDAAqD;AACrD,uDAAkD;AAElD,qCAA8C;AAW9C;;;;;;;GAOG;AAEI,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAChC,MAAM,CAAC,OAAO,CAAC,UAAkC,EAAE;QACjD,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,IAAI,+BAAa,CAAC;QAClD,MAAM,SAAS,GAAe;YAC5B,UAAU;YACV,EAAE,OAAO,EAAE,2BAAkB,EAAE,WAAW,EAAE,UAAU,EAAE;YACxD,kCAAe;
|
|
1
|
+
{"version":3,"file":"database.module.js","sourceRoot":"","sources":["../src/database.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAsF;AACtF,yDAAqD;AACrD,uDAAkD;AAElD,+EAA0E;AAC1E,qCAA8C;AAW9C;;;;;;;GAOG;AAEI,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAChC,MAAM,CAAC,OAAO,CAAC,UAAkC,EAAE;QACjD,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,IAAI,+BAAa,CAAC;QAClD,MAAM,SAAS,GAAe;YAC5B,UAAU;YACV,EAAE,OAAO,EAAE,2BAAkB,EAAE,WAAW,EAAE,UAAU,EAAE;YACxD,kCAAe;YACf,uDAAyB;SAC1B,CAAC;QACF,OAAO;YACL,MAAM,EAAE,uBAAqB;YAC7B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI;YAC9B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;YAC9B,SAAS;YACT,OAAO,EAAE,CAAC,kCAAe,EAAE,2BAAkB,EAAE,uDAAyB,CAAC;SAC1E,CAAC;IACJ,CAAC;IAED,8FAA8F;IAC9F,MAAM,CAAC,UAAU;QACf,OAAO;YACL,MAAM,EAAE,uBAAqB;YAC7B,SAAS,EAAE,CAAC,kCAAe,EAAE,uDAAyB,CAAC;YACvD,OAAO,EAAE,CAAC,kCAAe,EAAE,uDAAyB,CAAC;SACtD,CAAC;IACJ,CAAC;CACF,CAAA;AA1BY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,qBAAqB,CA0BjC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './interfaces';
|
|
2
2
|
export { NOTIFICATION_STORE } from './tokens';
|
|
3
|
-
export { DatabaseChannel } from './database.channel';
|
|
3
|
+
export { Database, DatabaseChannel } from './database.channel';
|
|
4
4
|
export { InMemoryStore } from './in-memory.store';
|
|
5
5
|
export { DatabaseChannelModule, type DatabaseChannelOptions } from './database.module';
|
|
6
|
+
export { NotificationsQueryService, type NotifiableTarget, type PaginateOptions, type PaginatedNotifications, } from './notifications-query.service';
|
|
7
|
+
export { createNotificationsController, type NotificationsControllerOptions, } from './notifications.controller';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,KAAK,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EACL,yBAAyB,EACzB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,sBAAsB,GAC5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,6BAA6B,EAC7B,KAAK,8BAA8B,GACpC,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,14 +14,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.DatabaseChannelModule = exports.InMemoryStore = exports.DatabaseChannel = exports.NOTIFICATION_STORE = void 0;
|
|
17
|
+
exports.createNotificationsController = exports.NotificationsQueryService = exports.DatabaseChannelModule = exports.InMemoryStore = exports.DatabaseChannel = exports.Database = exports.NOTIFICATION_STORE = void 0;
|
|
18
18
|
__exportStar(require("./interfaces"), exports);
|
|
19
19
|
var tokens_1 = require("./tokens");
|
|
20
20
|
Object.defineProperty(exports, "NOTIFICATION_STORE", { enumerable: true, get: function () { return tokens_1.NOTIFICATION_STORE; } });
|
|
21
21
|
var database_channel_1 = require("./database.channel");
|
|
22
|
+
Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return database_channel_1.Database; } });
|
|
22
23
|
Object.defineProperty(exports, "DatabaseChannel", { enumerable: true, get: function () { return database_channel_1.DatabaseChannel; } });
|
|
23
24
|
var in_memory_store_1 = require("./in-memory.store");
|
|
24
25
|
Object.defineProperty(exports, "InMemoryStore", { enumerable: true, get: function () { return in_memory_store_1.InMemoryStore; } });
|
|
25
26
|
var database_module_1 = require("./database.module");
|
|
26
27
|
Object.defineProperty(exports, "DatabaseChannelModule", { enumerable: true, get: function () { return database_module_1.DatabaseChannelModule; } });
|
|
28
|
+
var notifications_query_service_1 = require("./notifications-query.service");
|
|
29
|
+
Object.defineProperty(exports, "NotificationsQueryService", { enumerable: true, get: function () { return notifications_query_service_1.NotificationsQueryService; } });
|
|
30
|
+
var notifications_controller_1 = require("./notifications.controller");
|
|
31
|
+
Object.defineProperty(exports, "createNotificationsController", { enumerable: true, get: function () { return notifications_controller_1.createNotificationsController; } });
|
|
27
32
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,mCAA8C;AAArC,4GAAA,kBAAkB,OAAA;AAC3B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,mCAA8C;AAArC,4GAAA,kBAAkB,OAAA;AAC3B,uDAA+D;AAAtD,4GAAA,QAAQ,OAAA;AAAE,mHAAA,eAAe,OAAA;AAClC,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AACtB,qDAAuF;AAA9E,wHAAA,qBAAqB,OAAA;AAC9B,6EAKuC;AAJrC,wIAAA,yBAAyB,OAAA;AAK3B,uEAGoC;AAFlC,yIAAA,6BAA6B,OAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Notifiable, NotifiableRef } from '@dudousxd/nestjs-notifications-core';
|
|
2
|
+
import type { NotificationStore, StoredNotification } from './interfaces';
|
|
3
|
+
/** A notifiable, or just a stable reference to one. Accepted by every query method. */
|
|
4
|
+
export type NotifiableTarget = Notifiable | NotifiableRef;
|
|
5
|
+
/** Pagination options for {@link NotificationsQueryService.paginate}. */
|
|
6
|
+
export interface PaginateOptions {
|
|
7
|
+
/** 1-based page number. Default 1. */
|
|
8
|
+
page?: number;
|
|
9
|
+
/** Page size. Default 20. */
|
|
10
|
+
perPage?: number;
|
|
11
|
+
}
|
|
12
|
+
/** A page of stored notifications. */
|
|
13
|
+
export interface PaginatedNotifications {
|
|
14
|
+
items: StoredNotification[];
|
|
15
|
+
page: number;
|
|
16
|
+
perPage: number;
|
|
17
|
+
total: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Read side of the database channel: lists and mutates the notifications the channel
|
|
21
|
+
* persisted, mirroring Laravel's `$user->notifications`, `unreadNotifications`,
|
|
22
|
+
* `markAsRead()` and friends. Wraps the {@link NotificationStore} — it does not extend
|
|
23
|
+
* the store interface.
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* constructor(private readonly notifications: NotificationsQueryService) {}
|
|
27
|
+
* const inbox = await this.notifications.all(user);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class NotificationsQueryService {
|
|
31
|
+
private readonly store;
|
|
32
|
+
constructor(store: NotificationStore);
|
|
33
|
+
/** All notifications for the target, newest first (store ordering). */
|
|
34
|
+
all(target: NotifiableTarget): Promise<StoredNotification[]>;
|
|
35
|
+
/** Unread notifications for the target. */
|
|
36
|
+
unread(target: NotifiableTarget): Promise<StoredNotification[]>;
|
|
37
|
+
/** A single page over {@link all}. */
|
|
38
|
+
paginate(target: NotifiableTarget, { page, perPage }?: PaginateOptions): Promise<PaginatedNotifications>;
|
|
39
|
+
/** Number of unread notifications for the target. */
|
|
40
|
+
unreadCount(target: NotifiableTarget): Promise<number>;
|
|
41
|
+
/** Mark one notification read by id. */
|
|
42
|
+
markAsRead(id: string): Promise<void>;
|
|
43
|
+
/** Mark every notification for the target read. */
|
|
44
|
+
markAllAsRead(target: NotifiableTarget): Promise<void>;
|
|
45
|
+
/** Delete one notification by id. */
|
|
46
|
+
delete(id: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Derive a {@link NotifiableRef} from the target. Accepts a raw ref directly, otherwise
|
|
49
|
+
* prefers `toNotifiableRef()`. Throws if neither is available.
|
|
50
|
+
*/
|
|
51
|
+
private refOf;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=notifications-query.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications-query.service.d.ts","sourceRoot":"","sources":["../src/notifications-query.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAErF,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAG1E,uFAAuF;AACvF,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,aAAa,CAAC;AAE1D,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,sCAAsC;AACtC,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,qBACa,yBAAyB;IAGlC,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,iBAAiB;IAG3C,uEAAuE;IACjE,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAKlE,2CAA2C;IACrC,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAKrE,sCAAsC;IAChC,QAAQ,CACZ,MAAM,EAAE,gBAAgB,EACxB,EAAE,IAAQ,EAAE,OAAY,EAAE,GAAE,eAAoB,GAC/C,OAAO,CAAC,sBAAsB,CAAC;IAalC,qDAAqD;IAC/C,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAI5D,wCAAwC;IAClC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C,mDAAmD;IAC7C,aAAa,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5D,qCAAqC;IAC/B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC;;;OAGG;IACH,OAAO,CAAC,KAAK;CAWd"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.NotificationsQueryService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const tokens_1 = require("./tokens");
|
|
18
|
+
/**
|
|
19
|
+
* Read side of the database channel: lists and mutates the notifications the channel
|
|
20
|
+
* persisted, mirroring Laravel's `$user->notifications`, `unreadNotifications`,
|
|
21
|
+
* `markAsRead()` and friends. Wraps the {@link NotificationStore} — it does not extend
|
|
22
|
+
* the store interface.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* constructor(private readonly notifications: NotificationsQueryService) {}
|
|
26
|
+
* const inbox = await this.notifications.all(user);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
let NotificationsQueryService = class NotificationsQueryService {
|
|
30
|
+
store;
|
|
31
|
+
constructor(store) {
|
|
32
|
+
this.store = store;
|
|
33
|
+
}
|
|
34
|
+
/** All notifications for the target, newest first (store ordering). */
|
|
35
|
+
async all(target) {
|
|
36
|
+
const ref = this.refOf(target);
|
|
37
|
+
return this.store.getForNotifiable(ref.type, String(ref.id));
|
|
38
|
+
}
|
|
39
|
+
/** Unread notifications for the target. */
|
|
40
|
+
async unread(target) {
|
|
41
|
+
const ref = this.refOf(target);
|
|
42
|
+
return this.store.getUnread(ref.type, String(ref.id));
|
|
43
|
+
}
|
|
44
|
+
/** A single page over {@link all}. */
|
|
45
|
+
async paginate(target, { page = 1, perPage = 20 } = {}) {
|
|
46
|
+
const safePage = Math.max(1, Math.floor(page));
|
|
47
|
+
const safePerPage = Math.max(1, Math.floor(perPage));
|
|
48
|
+
const items = await this.all(target);
|
|
49
|
+
const start = (safePage - 1) * safePerPage;
|
|
50
|
+
return {
|
|
51
|
+
items: items.slice(start, start + safePerPage),
|
|
52
|
+
page: safePage,
|
|
53
|
+
perPage: safePerPage,
|
|
54
|
+
total: items.length,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Number of unread notifications for the target. */
|
|
58
|
+
async unreadCount(target) {
|
|
59
|
+
return (await this.unread(target)).length;
|
|
60
|
+
}
|
|
61
|
+
/** Mark one notification read by id. */
|
|
62
|
+
async markAsRead(id) {
|
|
63
|
+
await this.store.markAsRead(id);
|
|
64
|
+
}
|
|
65
|
+
/** Mark every notification for the target read. */
|
|
66
|
+
async markAllAsRead(target) {
|
|
67
|
+
const ref = this.refOf(target);
|
|
68
|
+
await this.store.markAllAsRead(ref.type, String(ref.id));
|
|
69
|
+
}
|
|
70
|
+
/** Delete one notification by id. */
|
|
71
|
+
async delete(id) {
|
|
72
|
+
await this.store.delete(id);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Derive a {@link NotifiableRef} from the target. Accepts a raw ref directly, otherwise
|
|
76
|
+
* prefers `toNotifiableRef()`. Throws if neither is available.
|
|
77
|
+
*/
|
|
78
|
+
refOf(target) {
|
|
79
|
+
if (isRef(target))
|
|
80
|
+
return target;
|
|
81
|
+
const toRef = target.toNotifiableRef;
|
|
82
|
+
if (typeof toRef === 'function') {
|
|
83
|
+
return toRef.call(target);
|
|
84
|
+
}
|
|
85
|
+
throw new Error('NotificationsQueryService needs a notifiable reference. Pass a { type, id } ref, or ' +
|
|
86
|
+
'implement toNotifiableRef() on the notifiable.');
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
exports.NotificationsQueryService = NotificationsQueryService;
|
|
90
|
+
exports.NotificationsQueryService = NotificationsQueryService = __decorate([
|
|
91
|
+
(0, common_1.Injectable)(),
|
|
92
|
+
__param(0, (0, common_1.Inject)(tokens_1.NOTIFICATION_STORE)),
|
|
93
|
+
__metadata("design:paramtypes", [Object])
|
|
94
|
+
], NotificationsQueryService);
|
|
95
|
+
function isRef(value) {
|
|
96
|
+
return (typeof value === 'object' &&
|
|
97
|
+
value !== null &&
|
|
98
|
+
'type' in value &&
|
|
99
|
+
'id' in value &&
|
|
100
|
+
typeof value.type === 'string');
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=notifications-query.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications-query.service.js","sourceRoot":"","sources":["../src/notifications-query.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,2CAAoD;AAEpD,qCAA8C;AAqB9C;;;;;;;;;;GAUG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAGjB;IAFnB,YAEmB,KAAwB;QAAxB,UAAK,GAAL,KAAK,CAAmB;IACxC,CAAC;IAEJ,uEAAuE;IACvE,KAAK,CAAC,GAAG,CAAC,MAAwB;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,2CAA2C;IAC3C,KAAK,CAAC,MAAM,CAAC,MAAwB;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,sCAAsC;IACtC,KAAK,CAAC,QAAQ,CACZ,MAAwB,EACxB,EAAE,IAAI,GAAG,CAAC,EAAE,OAAO,GAAG,EAAE,KAAsB,EAAE;QAEhD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,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;QACjC,MAAM,KAAK,GAAI,MAAqB,CAAC,eAAe,CAAC;QACrD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAChC,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,MAAM,IAAI,KAAK,CACb,sFAAsF;YACpF,gDAAgD,CACnD,CAAC;IACJ,CAAC;CACF,CAAA;AAvEY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,2BAAkB,CAAC,CAAA;;GAFlB,yBAAyB,CAuErC;AAED,SAAS,KAAK,CAAC,KAAuB;IACpC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACf,IAAI,IAAI,KAAK;QACb,OAAQ,KAAuB,CAAC,IAAI,KAAK,QAAQ,CAClD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { NotifiableRef } from '@dudousxd/nestjs-notifications-core';
|
|
2
|
+
import { type Type } from '@nestjs/common';
|
|
3
|
+
/** Options for {@link createNotificationsController}. */
|
|
4
|
+
export interface NotificationsControllerOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the current notifiable from the request (e.g. from `req.user`). May be async.
|
|
7
|
+
*/
|
|
8
|
+
resolveRef: (req: any) => NotifiableRef | Promise<NotifiableRef>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Builds a `@Controller('notifications')` exposing the in-app inbox endpoints:
|
|
12
|
+
*
|
|
13
|
+
* - `GET /notifications` — list (`?page&perPage` paginates)
|
|
14
|
+
* - `GET /notifications/unread`
|
|
15
|
+
* - `GET /notifications/unread/count`
|
|
16
|
+
* - `POST /notifications/:id/read`
|
|
17
|
+
* - `POST /notifications/read-all`
|
|
18
|
+
* - `DELETE /notifications/:id`
|
|
19
|
+
*
|
|
20
|
+
* Mount it by adding the returned class to a module's `controllers`, alongside
|
|
21
|
+
* `DatabaseChannelModule` (which provides {@link NotificationsQueryService}):
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* const NotificationsController = createNotificationsController({
|
|
25
|
+
* resolveRef: (req) => ({ type: 'User', id: req.user.id }),
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* @Module({
|
|
29
|
+
* imports: [DatabaseChannelModule.forFeature()],
|
|
30
|
+
* controllers: [NotificationsController],
|
|
31
|
+
* })
|
|
32
|
+
* export class InboxModule {}
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function createNotificationsController(options: NotificationsControllerOptions): Type<unknown>;
|
|
36
|
+
//# sourceMappingURL=notifications.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.controller.d.ts","sourceRoot":"","sources":["../src/notifications.controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAoD,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAI7F,yDAAyD;AACzD,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,UAAU,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAClE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,8BAA8B,GACtC,IAAI,CAAC,OAAO,CAAC,CAgDf"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.createNotificationsController = createNotificationsController;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const notifications_query_service_1 = require("./notifications-query.service");
|
|
18
|
+
/**
|
|
19
|
+
* Builds a `@Controller('notifications')` exposing the in-app inbox endpoints:
|
|
20
|
+
*
|
|
21
|
+
* - `GET /notifications` — list (`?page&perPage` paginates)
|
|
22
|
+
* - `GET /notifications/unread`
|
|
23
|
+
* - `GET /notifications/unread/count`
|
|
24
|
+
* - `POST /notifications/:id/read`
|
|
25
|
+
* - `POST /notifications/read-all`
|
|
26
|
+
* - `DELETE /notifications/:id`
|
|
27
|
+
*
|
|
28
|
+
* Mount it by adding the returned class to a module's `controllers`, alongside
|
|
29
|
+
* `DatabaseChannelModule` (which provides {@link NotificationsQueryService}):
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* const NotificationsController = createNotificationsController({
|
|
33
|
+
* resolveRef: (req) => ({ type: 'User', id: req.user.id }),
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* @Module({
|
|
37
|
+
* imports: [DatabaseChannelModule.forFeature()],
|
|
38
|
+
* controllers: [NotificationsController],
|
|
39
|
+
* })
|
|
40
|
+
* export class InboxModule {}
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
function createNotificationsController(options) {
|
|
44
|
+
let NotificationsController = class NotificationsController {
|
|
45
|
+
notifications;
|
|
46
|
+
constructor(notifications) {
|
|
47
|
+
this.notifications = notifications;
|
|
48
|
+
}
|
|
49
|
+
async list(req, page, perPage) {
|
|
50
|
+
const ref = await options.resolveRef(req);
|
|
51
|
+
return this.notifications.paginate(ref, {
|
|
52
|
+
page: page ? Number(page) : undefined,
|
|
53
|
+
perPage: perPage ? Number(perPage) : undefined,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async unread(req) {
|
|
57
|
+
const ref = await options.resolveRef(req);
|
|
58
|
+
return this.notifications.unread(ref);
|
|
59
|
+
}
|
|
60
|
+
async unreadCount(req) {
|
|
61
|
+
const ref = await options.resolveRef(req);
|
|
62
|
+
return { count: await this.notifications.unreadCount(ref) };
|
|
63
|
+
}
|
|
64
|
+
async markAsRead(id) {
|
|
65
|
+
await this.notifications.markAsRead(id);
|
|
66
|
+
}
|
|
67
|
+
async markAllAsRead(req) {
|
|
68
|
+
const ref = await options.resolveRef(req);
|
|
69
|
+
await this.notifications.markAllAsRead(ref);
|
|
70
|
+
}
|
|
71
|
+
async remove(id) {
|
|
72
|
+
await this.notifications.delete(id);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, common_1.Get)(),
|
|
77
|
+
__param(0, (0, common_1.Req)()),
|
|
78
|
+
__param(1, (0, common_1.Query)('page')),
|
|
79
|
+
__param(2, (0, common_1.Query)('perPage')),
|
|
80
|
+
__metadata("design:type", Function),
|
|
81
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
82
|
+
__metadata("design:returntype", Promise)
|
|
83
|
+
], NotificationsController.prototype, "list", null);
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, common_1.Get)('unread'),
|
|
86
|
+
__param(0, (0, common_1.Req)()),
|
|
87
|
+
__metadata("design:type", Function),
|
|
88
|
+
__metadata("design:paramtypes", [Object]),
|
|
89
|
+
__metadata("design:returntype", Promise)
|
|
90
|
+
], NotificationsController.prototype, "unread", null);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, common_1.Get)('unread/count'),
|
|
93
|
+
__param(0, (0, common_1.Req)()),
|
|
94
|
+
__metadata("design:type", Function),
|
|
95
|
+
__metadata("design:paramtypes", [Object]),
|
|
96
|
+
__metadata("design:returntype", Promise)
|
|
97
|
+
], NotificationsController.prototype, "unreadCount", null);
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, common_1.Post)(':id/read'),
|
|
100
|
+
__param(0, (0, common_1.Param)('id')),
|
|
101
|
+
__metadata("design:type", Function),
|
|
102
|
+
__metadata("design:paramtypes", [String]),
|
|
103
|
+
__metadata("design:returntype", Promise)
|
|
104
|
+
], NotificationsController.prototype, "markAsRead", null);
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, common_1.Post)('read-all'),
|
|
107
|
+
__param(0, (0, common_1.Req)()),
|
|
108
|
+
__metadata("design:type", Function),
|
|
109
|
+
__metadata("design:paramtypes", [Object]),
|
|
110
|
+
__metadata("design:returntype", Promise)
|
|
111
|
+
], NotificationsController.prototype, "markAllAsRead", null);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, common_1.Delete)(':id'),
|
|
114
|
+
__param(0, (0, common_1.Param)('id')),
|
|
115
|
+
__metadata("design:type", Function),
|
|
116
|
+
__metadata("design:paramtypes", [String]),
|
|
117
|
+
__metadata("design:returntype", Promise)
|
|
118
|
+
], NotificationsController.prototype, "remove", null);
|
|
119
|
+
NotificationsController = __decorate([
|
|
120
|
+
(0, common_1.Controller)('notifications'),
|
|
121
|
+
__metadata("design:paramtypes", [notifications_query_service_1.NotificationsQueryService])
|
|
122
|
+
], NotificationsController);
|
|
123
|
+
return NotificationsController;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=notifications.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.controller.js","sourceRoot":"","sources":["../src/notifications.controller.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3.0",
|
|
4
4
|
"description": "Database channel for nestjs-notifications — persist notifications for in-app display",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Davide Carvalho",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@nestjs
|
|
20
|
-
"@
|
|
19
|
+
"@dudousxd/nestjs-notifications-core": ">=0.1.0 <1.0.0",
|
|
20
|
+
"@nestjs/common": "^10.0.0 || ^11.0.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@nestjs/common": "^11.0.0",
|
|
24
24
|
"reflect-metadata": "^0.2.2",
|
|
25
25
|
"typescript": "^5.7.2",
|
|
26
|
-
"@dudousxd/nestjs-notifications-core": "^0.
|
|
26
|
+
"@dudousxd/nestjs-notifications-core": "^0.2.0"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "tsc -p tsconfig.json",
|