@dudousxd/nestjs-notifications-database 0.2.0 → 0.4.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 +1 -1
- package/dist/database.channel.d.ts.map +1 -1
- package/dist/database.channel.js +6 -6
- package/dist/database.channel.js.map +1 -1
- package/dist/database.module.d.ts +11 -2
- package/dist/database.module.d.ts.map +1 -1
- package/dist/database.module.js +15 -5
- package/dist/database.module.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +6 -0
- package/dist/interfaces.d.ts.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/dist/schema-initializer.d.ts +15 -0
- package/dist/schema-initializer.d.ts.map +1 -0
- package/dist/schema-initializer.js +51 -0
- package/dist/schema-initializer.js.map +1 -0
- package/dist/tokens.d.ts +2 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +3 -1
- package/dist/tokens.js.map +1 -1
- package/package.json +2 -2
|
@@ -10,7 +10,7 @@ export declare class DatabaseChannel implements ChannelDriver {
|
|
|
10
10
|
private readonly store;
|
|
11
11
|
readonly channel = "database";
|
|
12
12
|
constructor(store: NotificationStore);
|
|
13
|
-
send(notifiable: Notifiable, notification: Notification): Promise<
|
|
13
|
+
send(notifiable: Notifiable, notification: Notification): Promise<unknown>;
|
|
14
14
|
private referenceFor;
|
|
15
15
|
private payloadFor;
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAKlB,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,OAAO,CAAC;IAgBhF,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,UAAU;CAUnB"}
|
package/dist/database.channel.js
CHANGED
|
@@ -33,7 +33,8 @@ let DatabaseChannel = class DatabaseChannel {
|
|
|
33
33
|
const data = this.payloadFor(notifiable, notification);
|
|
34
34
|
const type = notification.constructor.notificationName ??
|
|
35
35
|
notification.constructor.name;
|
|
36
|
-
|
|
36
|
+
// Return the stored row so it flows into afterSending() and the SendResult.
|
|
37
|
+
return this.store.save({
|
|
37
38
|
type,
|
|
38
39
|
notifiableType: ref.type,
|
|
39
40
|
notifiableId: String(ref.id),
|
|
@@ -41,13 +42,12 @@ let DatabaseChannel = class DatabaseChannel {
|
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
referenceFor(notifiable, notification) {
|
|
44
|
-
|
|
45
|
+
// A { type, id } returned from the 'database' route wins; otherwise derive the ref from
|
|
46
|
+
// toNotifiableRef() or the @Notifiable/@NotifiableId decorators.
|
|
47
|
+
const routed = (0, nestjs_notifications_core_1.routeFor)(notifiable, 'database', notification);
|
|
45
48
|
if (isRef(routed))
|
|
46
49
|
return routed;
|
|
47
|
-
|
|
48
|
-
return notifiable.toNotifiableRef();
|
|
49
|
-
throw new Error('The database channel needs a notifiable reference. Implement toNotifiableRef() on the ' +
|
|
50
|
-
'notifiable, or return { type, id } from routeNotificationFor("database").');
|
|
50
|
+
return (0, nestjs_notifications_core_1.notifiableRef)(notifiable);
|
|
51
51
|
}
|
|
52
52
|
payloadFor(notifiable, notification) {
|
|
53
53
|
const handler = (0, nestjs_notifications_core_1.getHandler)(notification, 'database', 'toDatabase');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.channel.js","sourceRoot":"","sources":["../src/database.channel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"database.channel.js","sourceRoot":"","sources":["../src/database.channel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mFAS6C;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,4EAA4E;QAC5E,OAAO,IAAI,CAAC,KA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boolean;
|
|
8
8
|
/** Extra modules to import (e.g. the ORM module providing the store's dependencies). */
|
|
9
9
|
imports?: DynamicModule['imports'];
|
|
10
|
+
/**
|
|
11
|
+
* Create the backing schema on bootstrap if it's missing (non-destructive). Default true —
|
|
12
|
+
* set to false to manage the schema through your ORM's migrations instead.
|
|
13
|
+
*/
|
|
14
|
+
autoCreateSchema?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface DatabaseChannelFeatureOptions {
|
|
17
|
+
/** See {@link DatabaseChannelOptions.autoCreateSchema}. Default true. */
|
|
18
|
+
autoCreateSchema?: boolean;
|
|
10
19
|
}
|
|
11
20
|
/**
|
|
12
21
|
* Registers the database channel. Pair with an ORM adapter package
|
|
13
|
-
* (`@dudousxd/nestjs-notifications-database-typeorm
|
|
22
|
+
* (`@dudousxd/nestjs-notifications-database-typeorm`, `-mikro-orm`, `-prisma`) or pass a store.
|
|
14
23
|
*
|
|
15
24
|
* ```ts
|
|
16
25
|
* DatabaseChannelModule.forRoot({ store: TypeOrmNotificationStore, imports: [TypeOrmModule.forFeature([...])] })
|
|
@@ -19,6 +28,6 @@ export interface DatabaseChannelOptions {
|
|
|
19
28
|
export declare class DatabaseChannelModule {
|
|
20
29
|
static forRoot(options?: DatabaseChannelOptions): DynamicModule;
|
|
21
30
|
/** Register with an already-provided store token (e.g. provided by an ORM adapter module). */
|
|
22
|
-
static forFeature(): DynamicModule;
|
|
31
|
+
static forFeature(options?: DatabaseChannelFeatureOptions): DynamicModule;
|
|
23
32
|
}
|
|
24
33
|
//# sourceMappingURL=database.module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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;
|
|
1
|
+
{"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;AAKtD,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;IACnC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,6BAA6B;IAC5C,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,qBACa,qBAAqB;IAChC,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,sBAA2B,GAAG,aAAa;IAmBnE,8FAA8F;IAC9F,MAAM,CAAC,UAAU,CAAC,OAAO,GAAE,6BAAkC,GAAG,aAAa;CAY9E"}
|
package/dist/database.module.js
CHANGED
|
@@ -11,10 +11,12 @@ 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");
|
|
15
|
+
const schema_initializer_1 = require("./schema-initializer");
|
|
14
16
|
const tokens_1 = require("./tokens");
|
|
15
17
|
/**
|
|
16
18
|
* Registers the database channel. Pair with an ORM adapter package
|
|
17
|
-
* (`@dudousxd/nestjs-notifications-database-typeorm
|
|
19
|
+
* (`@dudousxd/nestjs-notifications-database-typeorm`, `-mikro-orm`, `-prisma`) or pass a store.
|
|
18
20
|
*
|
|
19
21
|
* ```ts
|
|
20
22
|
* DatabaseChannelModule.forRoot({ store: TypeOrmNotificationStore, imports: [TypeOrmModule.forFeature([...])] })
|
|
@@ -26,22 +28,30 @@ let DatabaseChannelModule = DatabaseChannelModule_1 = class DatabaseChannelModul
|
|
|
26
28
|
const providers = [
|
|
27
29
|
storeClass,
|
|
28
30
|
{ provide: tokens_1.NOTIFICATION_STORE, useExisting: storeClass },
|
|
31
|
+
{ provide: tokens_1.AUTO_CREATE_SCHEMA, useValue: options.autoCreateSchema ?? true },
|
|
29
32
|
database_channel_1.DatabaseChannel,
|
|
33
|
+
notifications_query_service_1.NotificationsQueryService,
|
|
34
|
+
schema_initializer_1.SchemaInitializer,
|
|
30
35
|
];
|
|
31
36
|
return {
|
|
32
37
|
module: DatabaseChannelModule_1,
|
|
33
38
|
global: options.global ?? true,
|
|
34
39
|
imports: options.imports ?? [],
|
|
35
40
|
providers,
|
|
36
|
-
exports: [database_channel_1.DatabaseChannel, tokens_1.NOTIFICATION_STORE],
|
|
41
|
+
exports: [database_channel_1.DatabaseChannel, tokens_1.NOTIFICATION_STORE, notifications_query_service_1.NotificationsQueryService],
|
|
37
42
|
};
|
|
38
43
|
}
|
|
39
44
|
/** Register with an already-provided store token (e.g. provided by an ORM adapter module). */
|
|
40
|
-
static forFeature() {
|
|
45
|
+
static forFeature(options = {}) {
|
|
41
46
|
return {
|
|
42
47
|
module: DatabaseChannelModule_1,
|
|
43
|
-
providers: [
|
|
44
|
-
|
|
48
|
+
providers: [
|
|
49
|
+
{ provide: tokens_1.AUTO_CREATE_SCHEMA, useValue: options.autoCreateSchema ?? true },
|
|
50
|
+
database_channel_1.DatabaseChannel,
|
|
51
|
+
notifications_query_service_1.NotificationsQueryService,
|
|
52
|
+
schema_initializer_1.SchemaInitializer,
|
|
53
|
+
],
|
|
54
|
+
exports: [database_channel_1.DatabaseChannel, notifications_query_service_1.NotificationsQueryService],
|
|
45
55
|
};
|
|
46
56
|
}
|
|
47
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.module.js","sourceRoot":"","sources":["../src/database.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAsF;AACtF,yDAAqD;AACrD,uDAAkD;AAElD,
|
|
1
|
+
{"version":3,"file":"database.module.js","sourceRoot":"","sources":["../src/database.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAsF;AACtF,yDAAqD;AACrD,uDAAkD;AAElD,+EAA0E;AAC1E,6DAAyD;AACzD,qCAAkE;AAqBlE;;;;;;;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,EAAE,OAAO,EAAE,2BAAkB,EAAE,QAAQ,EAAE,OAAO,CAAC,gBAAgB,IAAI,IAAI,EAAE;YAC3E,kCAAe;YACf,uDAAyB;YACzB,sCAAiB;SAClB,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,CAAC,UAAyC,EAAE;QAC3D,OAAO;YACL,MAAM,EAAE,uBAAqB;YAC7B,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,2BAAkB,EAAE,QAAQ,EAAE,OAAO,CAAC,gBAAgB,IAAI,IAAI,EAAE;gBAC3E,kCAAe;gBACf,uDAAyB;gBACzB,sCAAiB;aAClB;YACD,OAAO,EAAE,CAAC,kCAAe,EAAE,uDAAyB,CAAC;SACtD,CAAC;IACJ,CAAC;CACF,CAAA;AAjCY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,qBAAqB,CAiCjC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export * from './interfaces';
|
|
2
|
-
export { NOTIFICATION_STORE } from './tokens';
|
|
2
|
+
export { NOTIFICATION_STORE, AUTO_CREATE_SCHEMA } from './tokens';
|
|
3
3
|
export { Database, DatabaseChannel } from './database.channel';
|
|
4
4
|
export { InMemoryStore } from './in-memory.store';
|
|
5
|
-
export { DatabaseChannelModule, type DatabaseChannelOptions } from './database.module';
|
|
5
|
+
export { DatabaseChannelModule, type DatabaseChannelOptions, type DatabaseChannelFeatureOptions, } from './database.module';
|
|
6
|
+
export { SchemaInitializer } from './schema-initializer';
|
|
7
|
+
export { NotificationsQueryService, type NotifiableTarget, type PaginateOptions, type PaginatedNotifications, } from './notifications-query.service';
|
|
8
|
+
export { createNotificationsController, type NotificationsControllerOptions, } from './notifications.controller';
|
|
6
9
|
//# 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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EACL,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,GACnC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,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,10 +14,11 @@ 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.Database = exports.NOTIFICATION_STORE = void 0;
|
|
17
|
+
exports.createNotificationsController = exports.NotificationsQueryService = exports.SchemaInitializer = exports.DatabaseChannelModule = exports.InMemoryStore = exports.DatabaseChannel = exports.Database = exports.AUTO_CREATE_SCHEMA = 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
|
+
Object.defineProperty(exports, "AUTO_CREATE_SCHEMA", { enumerable: true, get: function () { return tokens_1.AUTO_CREATE_SCHEMA; } });
|
|
21
22
|
var database_channel_1 = require("./database.channel");
|
|
22
23
|
Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return database_channel_1.Database; } });
|
|
23
24
|
Object.defineProperty(exports, "DatabaseChannel", { enumerable: true, get: function () { return database_channel_1.DatabaseChannel; } });
|
|
@@ -25,4 +26,10 @@ var in_memory_store_1 = require("./in-memory.store");
|
|
|
25
26
|
Object.defineProperty(exports, "InMemoryStore", { enumerable: true, get: function () { return in_memory_store_1.InMemoryStore; } });
|
|
26
27
|
var database_module_1 = require("./database.module");
|
|
27
28
|
Object.defineProperty(exports, "DatabaseChannelModule", { enumerable: true, get: function () { return database_module_1.DatabaseChannelModule; } });
|
|
29
|
+
var schema_initializer_1 = require("./schema-initializer");
|
|
30
|
+
Object.defineProperty(exports, "SchemaInitializer", { enumerable: true, get: function () { return schema_initializer_1.SchemaInitializer; } });
|
|
31
|
+
var notifications_query_service_1 = require("./notifications-query.service");
|
|
32
|
+
Object.defineProperty(exports, "NotificationsQueryService", { enumerable: true, get: function () { return notifications_query_service_1.NotificationsQueryService; } });
|
|
33
|
+
var notifications_controller_1 = require("./notifications.controller");
|
|
34
|
+
Object.defineProperty(exports, "createNotificationsController", { enumerable: true, get: function () { return notifications_controller_1.createNotificationsController; } });
|
|
28
35
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,mCAAkE;AAAzD,4GAAA,kBAAkB,OAAA;AAAE,4GAAA,kBAAkB,OAAA;AAC/C,uDAA+D;AAAtD,4GAAA,QAAQ,OAAA;AAAE,mHAAA,eAAe,OAAA;AAClC,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AACtB,qDAI2B;AAHzB,wHAAA,qBAAqB,OAAA;AAIvB,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA;AAC1B,6EAKuC;AAJrC,wIAAA,yBAAyB,OAAA;AAK3B,uEAGoC;AAFlC,yIAAA,6BAA6B,OAAA"}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -29,6 +29,12 @@ export interface NotificationStore {
|
|
|
29
29
|
getForNotifiable(notifiableType: string, notifiableId: string): Promise<StoredNotification[]>;
|
|
30
30
|
getUnread(notifiableType: string, notifiableId: string): Promise<StoredNotification[]>;
|
|
31
31
|
delete(id: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Optionally create the backing schema if it's missing — non-destructively (never drops).
|
|
34
|
+
* Called on bootstrap when `autoCreateSchema` is enabled. Stores that don't manage schema
|
|
35
|
+
* (in-memory, or schema-first ORMs like Prisma) may omit it or make it a no-op.
|
|
36
|
+
*/
|
|
37
|
+
ensureSchema?(): Promise<void>;
|
|
32
38
|
}
|
|
33
39
|
/**
|
|
34
40
|
* Implement this on a notification to define its persisted payload. Falls back to
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEpF,+EAA+E;AAC/E,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,+BAA+B;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,gGAAgG;AAChG,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC,MAA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,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,4FAA4F;AAC5F,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,YAAY,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACvE,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC9F,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACvF,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC;;;;OAIG;IACH,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,UAAU,CAAC,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7D,OAAO,CAAC,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3D"}
|
|
@@ -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":";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,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.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAsCA,sEAkDC;AAvFD,2CAA6F;AAE7F,+EAA0E;AAU1E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,6BAA6B,CAC3C,OAAuC;IAEvC,IACM,uBAAuB,GAD7B,MACM,uBAAuB;QACE;QAA7B,YAA6B,aAAwC;YAAxC,kBAAa,GAAb,aAAa,CAA2B;QAAG,CAAC;QAGnE,AAAN,KAAK,CAAC,IAAI,CACD,GAAQ,EACA,IAAa,EACV,OA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CO;QADL,IAAA,YAAG,GAAE;QAEH,WAAA,IAAA,YAAG,GAAE,CAAA;QACL,WAAA,IAAA,cAAK,EAAC,MAAM,CAAC,CAAA;QACb,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;;;;uDAOlB;IAGK;QADL,IAAA,YAAG,EAAC,QAAQ,CAAC;QACA,WAAA,IAAA,YAAG,GAAE,CAAA;;;;yDAGlB;IAGK;QADL,IAAA,YAAG,EAAC,cAAc,CAAC;QACD,WAAA,IAAA,YAAG,GAAE,CAAA;;;;8DAGvB;IAGK;QADL,IAAA,aAAI,EAAC,UAAU,CAAC;QACC,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;6DAE5B;IAGK;QADL,IAAA,aAAI,EAAC,UAAU,CAAC;QACI,WAAA,IAAA,YAAG,GAAE,CAAA;;;;gEAGzB;IAGK;QADL,IAAA,eAAM,EAAC,KAAK,CAAC;QACA,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;yDAExB;IA1CG,uBAAuB;QAD5B,IAAA,mBAAU,EAAC,eAAe,CAAC;yCAEkB,uDAAyB;OADjE,uBAAuB,CA2C5B;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type OnApplicationBootstrap } from '@nestjs/common';
|
|
2
|
+
import type { NotificationStore } from './interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* On bootstrap, asks the store to create its schema if missing (non-destructively), so the
|
|
5
|
+
* library is self-contained out of the box. Disable with `autoCreateSchema: false` and manage
|
|
6
|
+
* the schema through your ORM's migrations instead.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SchemaInitializer implements OnApplicationBootstrap {
|
|
9
|
+
private readonly store;
|
|
10
|
+
private readonly autoCreateSchema;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
constructor(store: NotificationStore, autoCreateSchema: boolean);
|
|
13
|
+
onApplicationBootstrap(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=schema-initializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-initializer.d.ts","sourceRoot":"","sources":["../src/schema-initializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGtD;;;;GAIG;AACH,qBACa,iBAAkB,YAAW,sBAAsB;IAK5D,OAAO,CAAC,QAAQ,CAAC,KAAK;IAEtB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IANnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+B;gBAInC,KAAK,EAAE,iBAAiB,EAExB,gBAAgB,EAAE,OAAO;IAGtC,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;CAa9C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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.SchemaInitializer = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const tokens_1 = require("./tokens");
|
|
18
|
+
/**
|
|
19
|
+
* On bootstrap, asks the store to create its schema if missing (non-destructively), so the
|
|
20
|
+
* library is self-contained out of the box. Disable with `autoCreateSchema: false` and manage
|
|
21
|
+
* the schema through your ORM's migrations instead.
|
|
22
|
+
*/
|
|
23
|
+
let SchemaInitializer = class SchemaInitializer {
|
|
24
|
+
store;
|
|
25
|
+
autoCreateSchema;
|
|
26
|
+
logger = new common_1.Logger('Notifications');
|
|
27
|
+
constructor(store, autoCreateSchema) {
|
|
28
|
+
this.store = store;
|
|
29
|
+
this.autoCreateSchema = autoCreateSchema;
|
|
30
|
+
}
|
|
31
|
+
async onApplicationBootstrap() {
|
|
32
|
+
if (!this.autoCreateSchema)
|
|
33
|
+
return;
|
|
34
|
+
if (typeof this.store.ensureSchema !== 'function')
|
|
35
|
+
return;
|
|
36
|
+
try {
|
|
37
|
+
await this.store.ensureSchema();
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
this.logger.error(`Failed to ensure the notifications schema: ${error instanceof Error ? error.message : String(error)}. Set autoCreateSchema: false and manage the schema via migrations if this is expected.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.SchemaInitializer = SchemaInitializer;
|
|
45
|
+
exports.SchemaInitializer = SchemaInitializer = __decorate([
|
|
46
|
+
(0, common_1.Injectable)(),
|
|
47
|
+
__param(0, (0, common_1.Inject)(tokens_1.NOTIFICATION_STORE)),
|
|
48
|
+
__param(1, (0, common_1.Inject)(tokens_1.AUTO_CREATE_SCHEMA)),
|
|
49
|
+
__metadata("design:paramtypes", [Object, Boolean])
|
|
50
|
+
], SchemaInitializer);
|
|
51
|
+
//# sourceMappingURL=schema-initializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-initializer.js","sourceRoot":"","sources":["../src/schema-initializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAyF;AAEzF,qCAAkE;AAElE;;;;GAIG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAKT;IAEA;IANF,MAAM,GAAG,IAAI,eAAM,CAAC,eAAe,CAAC,CAAC;IAEtD,YAEmB,KAAwB,EAExB,gBAAyB;QAFzB,UAAK,GAAL,KAAK,CAAmB;QAExB,qBAAgB,GAAhB,gBAAgB,CAAS;IACzC,CAAC;IAEJ,KAAK,CAAC,sBAAsB;QAC1B,IAAI,CAAC,IAAI,CAAC,gBAAgB;YAAE,OAAO;QACnC,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,KAAK,UAAU;YAAE,OAAO;QAC1D,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,8CACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,yFAAyF,CAC1F,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AAvBY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,2BAAkB,CAAC,CAAA;IAE1B,WAAA,IAAA,eAAM,EAAC,2BAAkB,CAAC,CAAA;;GANlB,iBAAiB,CAuB7B"}
|
package/dist/tokens.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
/** DI token for the {@link NotificationStore} implementation backing the database channel. */
|
|
2
2
|
export declare const NOTIFICATION_STORE: unique symbol;
|
|
3
|
+
/** DI token for the `autoCreateSchema` flag consumed by the SchemaInitializer. */
|
|
4
|
+
export declare const AUTO_CREATE_SCHEMA: unique symbol;
|
|
3
5
|
//# sourceMappingURL=tokens.d.ts.map
|
package/dist/tokens.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,eAAO,MAAM,kBAAkB,eAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAE/D,kFAAkF;AAClF,eAAO,MAAM,kBAAkB,eAA+B,CAAC"}
|
package/dist/tokens.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NOTIFICATION_STORE = void 0;
|
|
3
|
+
exports.AUTO_CREATE_SCHEMA = exports.NOTIFICATION_STORE = void 0;
|
|
4
4
|
/** DI token for the {@link NotificationStore} implementation backing the database channel. */
|
|
5
5
|
exports.NOTIFICATION_STORE = Symbol('NOTIFICATION_STORE');
|
|
6
|
+
/** DI token for the `autoCreateSchema` flag consumed by the SchemaInitializer. */
|
|
7
|
+
exports.AUTO_CREATE_SCHEMA = Symbol('AUTO_CREATE_SCHEMA');
|
|
6
8
|
//# sourceMappingURL=tokens.js.map
|
package/dist/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":";;;AAAA,8FAA8F;AACjF,QAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":";;;AAAA,8FAA8F;AACjF,QAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAE/D,kFAAkF;AACrE,QAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/nestjs-notifications-database",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Database channel for nestjs-notifications — persist notifications for in-app display",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Davide Carvalho",
|
|
@@ -23,7 +23,7 @@
|
|
|
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.3.0"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "tsc -p tsconfig.json",
|