@dudousxd/nestjs-notifications-database 0.1.0 → 0.2.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.
@@ -1,5 +1,7 @@
1
- import type { ChannelDriver, Notifiable, Notification } from '@dudousxd/nestjs-notifications-core';
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,EACV,aAAa,EACb,UAAU,EAEV,YAAY,EACb,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAwB,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAG5E;;;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;CASnB"}
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"}
@@ -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
- if (typeof notification.toDatabase === 'function')
51
- return notification.toDatabase(notifiable);
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":";;;;;;;;;;;;;;;AAMA,2CAA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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
6
  //# sourceMappingURL=index.d.ts.map
@@ -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;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,KAAK,sBAAsB,EAAE,MAAM,mBAAmB,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"}
package/dist/index.js CHANGED
@@ -14,11 +14,12 @@ 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.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; } });
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,uDAAqD;AAA5C,mHAAA,eAAe,OAAA;AACxB,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AACtB,qDAAuF;AAA9E,wHAAA,qBAAqB,OAAA"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-notifications-database",
3
- "version": "0.1.0",
3
+ "version": "0.2.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/common": "^10.0.0 || ^11.0.0",
20
- "@dudousxd/nestjs-notifications-core": "^0.1.0"
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.1.0"
26
+ "@dudousxd/nestjs-notifications-core": "^0.2.0"
27
27
  },
28
28
  "scripts": {
29
29
  "build": "tsc -p tsconfig.json",