@dudousxd/nestjs-notifications-preferences 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.
- package/dist/in-memory.store.d.ts +13 -0
- package/dist/in-memory.store.d.ts.map +1 -0
- package/dist/in-memory.store.js +48 -0
- package/dist/in-memory.store.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces.d.ts +36 -0
- package/dist/interfaces.d.ts.map +1 -0
- package/dist/interfaces.js +3 -0
- package/dist/interfaces.js.map +1 -0
- package/dist/notification-preferences.d.ts +39 -0
- package/dist/notification-preferences.d.ts.map +1 -0
- package/dist/notification-preferences.js +77 -0
- package/dist/notification-preferences.js.map +1 -0
- package/dist/preference-gate.adapter.d.ts +13 -0
- package/dist/preference-gate.adapter.d.ts.map +1 -0
- package/dist/preference-gate.adapter.js +52 -0
- package/dist/preference-gate.adapter.js.map +1 -0
- package/dist/preferences.module.d.ts +22 -0
- package/dist/preferences.module.d.ts.map +1 -0
- package/dist/preferences.module.js +48 -0
- package/dist/preferences.module.js.map +1 -0
- package/dist/tokens.d.ts +3 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +6 -0
- package/dist/tokens.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PreferenceKey, PreferenceScope, PreferenceStore } from './interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* In-memory {@link PreferenceStore} for tests and prototyping. Holds the set of muted
|
|
4
|
+
* (tenant, notifiable, channel) tuples. Not for production — state is lost on restart.
|
|
5
|
+
*/
|
|
6
|
+
export declare class InMemoryPreferenceStore implements PreferenceStore {
|
|
7
|
+
private readonly muted;
|
|
8
|
+
isMuted(key: PreferenceKey): Promise<boolean>;
|
|
9
|
+
mute(key: PreferenceKey): Promise<void>;
|
|
10
|
+
unmute(key: PreferenceKey): Promise<void>;
|
|
11
|
+
mutedChannels(scope: PreferenceScope): Promise<string[]>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=in-memory.store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory.store.d.ts","sourceRoot":"","sources":["../src/in-memory.store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAOpF;;;GAGG;AACH,qBACa,uBAAwB,YAAW,eAAe;IAC7D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;IAErC,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAI7C,IAAI,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAa/D"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.InMemoryPreferenceStore = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
/** Serialize a key to a stable string for set membership. */
|
|
12
|
+
function serialize(key) {
|
|
13
|
+
return JSON.stringify([key.tenant ?? null, key.notifiableType, key.notifiableId, key.channel]);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* In-memory {@link PreferenceStore} for tests and prototyping. Holds the set of muted
|
|
17
|
+
* (tenant, notifiable, channel) tuples. Not for production — state is lost on restart.
|
|
18
|
+
*/
|
|
19
|
+
let InMemoryPreferenceStore = class InMemoryPreferenceStore {
|
|
20
|
+
muted = new Set();
|
|
21
|
+
async isMuted(key) {
|
|
22
|
+
return this.muted.has(serialize(key));
|
|
23
|
+
}
|
|
24
|
+
async mute(key) {
|
|
25
|
+
this.muted.add(serialize(key));
|
|
26
|
+
}
|
|
27
|
+
async unmute(key) {
|
|
28
|
+
this.muted.delete(serialize(key));
|
|
29
|
+
}
|
|
30
|
+
async mutedChannels(scope) {
|
|
31
|
+
const prefix = JSON.stringify([scope.tenant ?? null, scope.notifiableType, scope.notifiableId]);
|
|
32
|
+
// Each stored entry is [tenant, type, id, channel]; reuse the 3-element prefix.
|
|
33
|
+
const head = prefix.slice(0, -1); // drop the closing ']'
|
|
34
|
+
const channels = [];
|
|
35
|
+
for (const entry of this.muted) {
|
|
36
|
+
if (entry.startsWith(`${head},`)) {
|
|
37
|
+
const [, , , channel] = JSON.parse(entry);
|
|
38
|
+
channels.push(channel);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return channels;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.InMemoryPreferenceStore = InMemoryPreferenceStore;
|
|
45
|
+
exports.InMemoryPreferenceStore = InMemoryPreferenceStore = __decorate([
|
|
46
|
+
(0, common_1.Injectable)()
|
|
47
|
+
], InMemoryPreferenceStore);
|
|
48
|
+
//# sourceMappingURL=in-memory.store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory.store.js","sourceRoot":"","sources":["../src/in-memory.store.ts"],"names":[],"mappings":";;;;;;;;;A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,AAAD,EAAG,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAA4C,CAAC;gBACrF,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AA5BY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;GACA,uBAAuB,CA4BnC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { PreferenceKey, PreferenceScope, PreferenceStore } from './interfaces';
|
|
2
|
+
export { NOTIFICATION_PREFERENCE_STORE } from './tokens';
|
|
3
|
+
export { InMemoryPreferenceStore } from './in-memory.store';
|
|
4
|
+
export { NotificationPreferences, type PreferenceTarget, type ScopedPreferences, } from './notification-preferences';
|
|
5
|
+
export { PreferenceGateAdapter } from './preference-gate.adapter';
|
|
6
|
+
export { PreferencesModule, type PreferencesModuleOptions, } from './preferences.module';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PreferencesModule = exports.PreferenceGateAdapter = exports.NotificationPreferences = exports.InMemoryPreferenceStore = exports.NOTIFICATION_PREFERENCE_STORE = void 0;
|
|
4
|
+
var tokens_1 = require("./tokens");
|
|
5
|
+
Object.defineProperty(exports, "NOTIFICATION_PREFERENCE_STORE", { enumerable: true, get: function () { return tokens_1.NOTIFICATION_PREFERENCE_STORE; } });
|
|
6
|
+
var in_memory_store_1 = require("./in-memory.store");
|
|
7
|
+
Object.defineProperty(exports, "InMemoryPreferenceStore", { enumerable: true, get: function () { return in_memory_store_1.InMemoryPreferenceStore; } });
|
|
8
|
+
var notification_preferences_1 = require("./notification-preferences");
|
|
9
|
+
Object.defineProperty(exports, "NotificationPreferences", { enumerable: true, get: function () { return notification_preferences_1.NotificationPreferences; } });
|
|
10
|
+
var preference_gate_adapter_1 = require("./preference-gate.adapter");
|
|
11
|
+
Object.defineProperty(exports, "PreferenceGateAdapter", { enumerable: true, get: function () { return preference_gate_adapter_1.PreferenceGateAdapter; } });
|
|
12
|
+
var preferences_module_1 = require("./preferences.module");
|
|
13
|
+
Object.defineProperty(exports, "PreferencesModule", { enumerable: true, get: function () { return preferences_module_1.PreferencesModule; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,mCAAyD;AAAhD,uHAAA,6BAA6B,OAAA;AACtC,qDAA4D;AAAnD,0HAAA,uBAAuB,OAAA;AAChC,uEAIoC;AAHlC,mIAAA,uBAAuB,OAAA;AAIzB,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,2DAG8B;AAF5B,uHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A fully-qualified preference entry: which channel is muted for which notifiable, optionally
|
|
3
|
+
* scoped to a tenant. Used by the {@link PreferenceStore}.
|
|
4
|
+
*/
|
|
5
|
+
export interface PreferenceKey {
|
|
6
|
+
/** Tenant scope; undefined in single-tenant apps. */
|
|
7
|
+
tenant?: string;
|
|
8
|
+
/** The notifiable's morph type (e.g. the class name or `@Notifiable({ type })`). */
|
|
9
|
+
notifiableType: string;
|
|
10
|
+
/** The notifiable's id, stringified. */
|
|
11
|
+
notifiableId: string;
|
|
12
|
+
/** The channel name (e.g. `mail`, `sms`). */
|
|
13
|
+
channel: string;
|
|
14
|
+
}
|
|
15
|
+
/** A notifiable+tenant scope without a specific channel — used to list muted channels. */
|
|
16
|
+
export interface PreferenceScope {
|
|
17
|
+
tenant?: string;
|
|
18
|
+
notifiableType: string;
|
|
19
|
+
notifiableId: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Persistence for channel preferences. Models an **opt-out** policy: a channel is allowed
|
|
23
|
+
* unless it has been explicitly muted. Implement this against your datastore, or use the
|
|
24
|
+
* bundled {@link InMemoryPreferenceStore}.
|
|
25
|
+
*/
|
|
26
|
+
export interface PreferenceStore {
|
|
27
|
+
/** Whether `key.channel` is currently muted for the given notifiable (and tenant). */
|
|
28
|
+
isMuted(key: PreferenceKey): Promise<boolean>;
|
|
29
|
+
/** Mute a channel for a notifiable (and tenant). Idempotent. */
|
|
30
|
+
mute(key: PreferenceKey): Promise<void>;
|
|
31
|
+
/** Un-mute a previously muted channel. Idempotent. */
|
|
32
|
+
unmute(key: PreferenceKey): Promise<void>;
|
|
33
|
+
/** List all channels currently muted for the notifiable within the scope. */
|
|
34
|
+
mutedChannels(scope: PreferenceScope): Promise<string[]>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,cAAc,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,0FAA0F;AAC1F,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,sFAAsF;IACtF,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9C,gEAAgE;IAChE,IAAI,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,sDAAsD;IACtD,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,6EAA6E;IAC7E,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CAC1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Notifiable, type NotifiableRef } from '@dudousxd/nestjs-notifications-core';
|
|
2
|
+
import type { PreferenceStore } from './interfaces';
|
|
3
|
+
/** A notifiable instance or a pre-built reference to one. */
|
|
4
|
+
export type PreferenceTarget = Notifiable | NotifiableRef;
|
|
5
|
+
/**
|
|
6
|
+
* The set of preference operations, optionally pre-scoped to a tenant. Returned both directly by
|
|
7
|
+
* {@link NotificationPreferences} (tenant undefined) and by {@link NotificationPreferences.forTenant}.
|
|
8
|
+
*/
|
|
9
|
+
export interface ScopedPreferences {
|
|
10
|
+
/** Mute a channel for the target. */
|
|
11
|
+
mute(target: PreferenceTarget, channel: string): Promise<void>;
|
|
12
|
+
/** Un-mute a channel for the target. */
|
|
13
|
+
unmute(target: PreferenceTarget, channel: string): Promise<void>;
|
|
14
|
+
/** Whether the channel is muted for the target. */
|
|
15
|
+
isMuted(target: PreferenceTarget, channel: string): Promise<boolean>;
|
|
16
|
+
/** List the channels currently muted for the target. */
|
|
17
|
+
muted(target: PreferenceTarget): Promise<string[]>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Ergonomic façade over a {@link PreferenceStore}. Accepts a {@link Notifiable} (deriving its
|
|
21
|
+
* reference via the core `notifiableRef`) or a {@link NotifiableRef} directly.
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* await prefs.mute(user, 'mail');
|
|
25
|
+
* await prefs.forTenant('acme').mute(user, 'sms');
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare class NotificationPreferences implements ScopedPreferences {
|
|
29
|
+
private readonly store;
|
|
30
|
+
constructor(store: PreferenceStore);
|
|
31
|
+
mute(target: PreferenceTarget, channel: string): Promise<void>;
|
|
32
|
+
unmute(target: PreferenceTarget, channel: string): Promise<void>;
|
|
33
|
+
isMuted(target: PreferenceTarget, channel: string): Promise<boolean>;
|
|
34
|
+
muted(target: PreferenceTarget): Promise<string[]>;
|
|
35
|
+
/** Return the same operations scoped to a tenant (every key carries `tenant`). */
|
|
36
|
+
forTenant(tenant: string): ScopedPreferences;
|
|
37
|
+
private scoped;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=notification-preferences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-preferences.d.ts","sourceRoot":"","sources":["../src/notification-preferences.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,aAAa,EAEnB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,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= 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.NotificationPreferences = void 0;
|
|
16
|
+
const nestjs_notifications_core_1 = require("@dudousxd/nestjs-notifications-core");
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const tokens_1 = require("./tokens");
|
|
19
|
+
/** Discriminate a {@link NotifiableRef} from a full {@link Notifiable}. */
|
|
20
|
+
function isRef(target) {
|
|
21
|
+
return (typeof target.type === 'string' &&
|
|
22
|
+
target.id !== undefined &&
|
|
23
|
+
typeof target.routeNotificationFor !== 'function' &&
|
|
24
|
+
typeof target.toNotifiableRef !== 'function');
|
|
25
|
+
}
|
|
26
|
+
/** Normalize either input into a `{ notifiableType, notifiableId }` pair. */
|
|
27
|
+
function resolve(target) {
|
|
28
|
+
const ref = isRef(target) ? target : (0, nestjs_notifications_core_1.notifiableRef)(target);
|
|
29
|
+
return { notifiableType: ref.type, notifiableId: String(ref.id) };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Ergonomic façade over a {@link PreferenceStore}. Accepts a {@link Notifiable} (deriving its
|
|
33
|
+
* reference via the core `notifiableRef`) or a {@link NotifiableRef} directly.
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* await prefs.mute(user, 'mail');
|
|
37
|
+
* await prefs.forTenant('acme').mute(user, 'sms');
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
let NotificationPreferences = class NotificationPreferences {
|
|
41
|
+
store;
|
|
42
|
+
constructor(store) {
|
|
43
|
+
this.store = store;
|
|
44
|
+
}
|
|
45
|
+
mute(target, channel) {
|
|
46
|
+
return this.scoped(undefined).mute(target, channel);
|
|
47
|
+
}
|
|
48
|
+
unmute(target, channel) {
|
|
49
|
+
return this.scoped(undefined).unmute(target, channel);
|
|
50
|
+
}
|
|
51
|
+
isMuted(target, channel) {
|
|
52
|
+
return this.scoped(undefined).isMuted(target, channel);
|
|
53
|
+
}
|
|
54
|
+
muted(target) {
|
|
55
|
+
return this.scoped(undefined).muted(target);
|
|
56
|
+
}
|
|
57
|
+
/** Return the same operations scoped to a tenant (every key carries `tenant`). */
|
|
58
|
+
forTenant(tenant) {
|
|
59
|
+
return this.scoped(tenant);
|
|
60
|
+
}
|
|
61
|
+
scoped(tenant) {
|
|
62
|
+
const store = this.store;
|
|
63
|
+
return {
|
|
64
|
+
mute: (target, channel) => store.mute({ tenant, ...resolve(target), channel }),
|
|
65
|
+
unmute: (target, channel) => store.unmute({ tenant, ...resolve(target), channel }),
|
|
66
|
+
isMuted: (target, channel) => store.isMuted({ tenant, ...resolve(target), channel }),
|
|
67
|
+
muted: (target) => store.mutedChannels({ tenant, ...resolve(target) }),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.NotificationPreferences = NotificationPreferences;
|
|
72
|
+
exports.NotificationPreferences = NotificationPreferences = __decorate([
|
|
73
|
+
(0, common_1.Injectable)(),
|
|
74
|
+
__param(0, (0, common_1.Inject)(tokens_1.NOTIFICATION_PREFERENCE_STORE)),
|
|
75
|
+
__metadata("design:paramtypes", [Object])
|
|
76
|
+
], NotificationPreferences);
|
|
77
|
+
//# sourceMappingURL=notification-preferences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-preferences.js","sourceRoot":"","sources":["../src/notification-preferences.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mFAI6C;AAC7C,2CAAoD;AAEpD,qCAAyD;AAKzD,2EAA2E;AAC3E,SAAS,KAAK,CAAC,MAAwB;IACrC,OAAO,CACL,OAAQ,MAAwB,CAAC,IAAI,KAAK,QAAQ;QACjD,MAAwB,CAAC,EAAE,KAAK,SAAS;QAC1C,OAAQ,MAAqB,CAAC,oBAAoB,KAAK,UAAU;QACjE,OAAQ,MAAqB,CAAC,eAAe,KAAK,UAAU,CAC7D,CAAC;AACJ,CAAC;AAED,6EAA6E;AAC7E,SAAS,OAAO,CAAC,MAAwB;IACvC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAwB,CAAC,CAAC,CAAC,IAAA,yCAAa,EAAC,MAAoB,CAAC,CAAC;IAC5F,OAAO,EAAE,cAAc,EAAE,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;AACpE,CAAC;AAiBD;;;;;;;;GAQG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IACkC;IAApE,YAAoE,KAAsB;QAAtB,UAAK,GAAL,KAAK,CAAiB;IAAG,CAAC;IAE9F,IAAI,CAAC,MAAwB,EAAE,OAAe;QAC5C,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,CAAC,MAAwB,EAAE,OAAe;QAC9C,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,CAAC,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 @@
|
|
|
1
|
+
import { type ChannelGateContext, type PreferenceGate } from '@dudousxd/nestjs-notifications-core';
|
|
2
|
+
import type { PreferenceStore } from './interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Core {@link PreferenceGate} backed by a {@link PreferenceStore}. Bound to the core
|
|
5
|
+
* `NOTIFICATION_PREFERENCE_GATE` token by {@link PreferencesModule} so the ChannelRunner
|
|
6
|
+
* consults it before every delivery. Opt-out: a channel is allowed unless explicitly muted.
|
|
7
|
+
*/
|
|
8
|
+
export declare class PreferenceGateAdapter implements PreferenceGate {
|
|
9
|
+
private readonly store;
|
|
10
|
+
constructor(store: PreferenceStore);
|
|
11
|
+
isAllowed({ notifiable, channel, tenant }: ChannelGateContext): Promise<boolean>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=preference-gate.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preference-gate.adapter.d.ts","sourceRoot":"","sources":["../src/preference-gate.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EAEpB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD;;;;GAIG;AACH,qBACa,qBAAsB,YAAW,cAAc;IACP,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,eAAe;IAEpF,SAAS,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;CAevF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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.PreferenceGateAdapter = void 0;
|
|
16
|
+
const nestjs_notifications_core_1 = require("@dudousxd/nestjs-notifications-core");
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const tokens_1 = require("./tokens");
|
|
19
|
+
/**
|
|
20
|
+
* Core {@link PreferenceGate} backed by a {@link PreferenceStore}. Bound to the core
|
|
21
|
+
* `NOTIFICATION_PREFERENCE_GATE` token by {@link PreferencesModule} so the ChannelRunner
|
|
22
|
+
* consults it before every delivery. Opt-out: a channel is allowed unless explicitly muted.
|
|
23
|
+
*/
|
|
24
|
+
let PreferenceGateAdapter = class PreferenceGateAdapter {
|
|
25
|
+
store;
|
|
26
|
+
constructor(store) {
|
|
27
|
+
this.store = store;
|
|
28
|
+
}
|
|
29
|
+
async isAllowed({ notifiable, channel, tenant }) {
|
|
30
|
+
let ref;
|
|
31
|
+
try {
|
|
32
|
+
ref = (0, nestjs_notifications_core_1.notifiableRef)(notifiable);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// No stable reference (e.g. an anonymous notifiable) — nothing to mute against; allow.
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return !(await this.store.isMuted({
|
|
39
|
+
tenant,
|
|
40
|
+
notifiableType: ref.type,
|
|
41
|
+
notifiableId: String(ref.id),
|
|
42
|
+
channel,
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.PreferenceGateAdapter = PreferenceGateAdapter;
|
|
47
|
+
exports.PreferenceGateAdapter = PreferenceGateAdapter = __decorate([
|
|
48
|
+
(0, common_1.Injectable)(),
|
|
49
|
+
__param(0, (0, common_1.Inject)(tokens_1.NOTIFICATION_PREFERENCE_STORE)),
|
|
50
|
+
__metadata("design:paramtypes", [Object])
|
|
51
|
+
], PreferenceGateAdapter);
|
|
52
|
+
//# sourceMappingURL=preference-gate.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preference-gate.adapter.js","sourceRoot":"","sources":["../src/preference-gate.adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mFAI6C;AAC7C,2CAAoD;AAEpD,qCAAyD;AAEzD;;;;GAIG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACoC;IAApE,YAAoE,KAAsB;QAAtB,UAAK,GAAL,KAAK,CAAiB;IAAG,CAAC;IAE9F,KAAK,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAsB;QACjE,IAAI,GAA0C,CAAC;QAC/C,IAAI,CAAC;YACH,GAAG,GAAG,IAAA,yCAAa,EAAC,UAAU,CAAC,CAAC;QAClC,CAAC;QAAC,MAAM,CAAC;YACP,uFAAuF;YACvF,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;YAChC,MAAM;YACN,cAAc,EAAE,GAAG,CAAC,IAAI;YACxB,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO;SACR,CAAC,CAAC,CAAC;IACN,CAAC;CACF,CAAA;AAlBY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,sCAA6B,CAAC,CAAA;;GADvC,qBAAqB,CAkBjC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type DynamicModule, type Type } from '@nestjs/common';
|
|
2
|
+
import type { PreferenceStore } from './interfaces';
|
|
3
|
+
/** Options for {@link PreferencesModule.forRoot}. */
|
|
4
|
+
export interface PreferencesModuleOptions {
|
|
5
|
+
/** A {@link PreferenceStore} class to instantiate; defaults to {@link InMemoryPreferenceStore}. */
|
|
6
|
+
store?: Type<PreferenceStore>;
|
|
7
|
+
/** Register globally so the preferences service and gate are available app-wide. Default true. */
|
|
8
|
+
global?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Registers channel preferences. Binds the core `NOTIFICATION_PREFERENCE_GATE` token to a
|
|
12
|
+
* store-backed gate so the ChannelRunner automatically skips muted channels.
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* PreferencesModule.forRoot() // in-memory store
|
|
16
|
+
* PreferencesModule.forRoot({ store: PrismaPrefStore }) // your store
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class PreferencesModule {
|
|
20
|
+
static forRoot(options?: PreferencesModuleOptions): DynamicModule;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=preferences.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferences.module.d.ts","sourceRoot":"","sources":["../src/preferences.module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAyB,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAKpD,qDAAqD;AACrD,MAAM,WAAW,wBAAwB;IACvC,mGAAmG;IACnG,KAAK,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;IAC9B,kGAAkG;IAClG,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,qBACa,iBAAiB;IAC5B,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,wBAA6B,GAAG,aAAa;CAgBtE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 PreferencesModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.PreferencesModule = void 0;
|
|
11
|
+
const nestjs_notifications_core_1 = require("@dudousxd/nestjs-notifications-core");
|
|
12
|
+
const common_1 = require("@nestjs/common");
|
|
13
|
+
const in_memory_store_1 = require("./in-memory.store");
|
|
14
|
+
const notification_preferences_1 = require("./notification-preferences");
|
|
15
|
+
const preference_gate_adapter_1 = require("./preference-gate.adapter");
|
|
16
|
+
const tokens_1 = require("./tokens");
|
|
17
|
+
/**
|
|
18
|
+
* Registers channel preferences. Binds the core `NOTIFICATION_PREFERENCE_GATE` token to a
|
|
19
|
+
* store-backed gate so the ChannelRunner automatically skips muted channels.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* PreferencesModule.forRoot() // in-memory store
|
|
23
|
+
* PreferencesModule.forRoot({ store: PrismaPrefStore }) // your store
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
let PreferencesModule = PreferencesModule_1 = class PreferencesModule {
|
|
27
|
+
static forRoot(options = {}) {
|
|
28
|
+
const storeClass = options.store ?? in_memory_store_1.InMemoryPreferenceStore;
|
|
29
|
+
const providers = [
|
|
30
|
+
storeClass,
|
|
31
|
+
{ provide: tokens_1.NOTIFICATION_PREFERENCE_STORE, useExisting: storeClass },
|
|
32
|
+
notification_preferences_1.NotificationPreferences,
|
|
33
|
+
preference_gate_adapter_1.PreferenceGateAdapter,
|
|
34
|
+
{ provide: nestjs_notifications_core_1.NOTIFICATION_PREFERENCE_GATE, useExisting: preference_gate_adapter_1.PreferenceGateAdapter },
|
|
35
|
+
];
|
|
36
|
+
return {
|
|
37
|
+
module: PreferencesModule_1,
|
|
38
|
+
global: options.global ?? true,
|
|
39
|
+
providers,
|
|
40
|
+
exports: [notification_preferences_1.NotificationPreferences, tokens_1.NOTIFICATION_PREFERENCE_STORE],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.PreferencesModule = PreferencesModule;
|
|
45
|
+
exports.PreferencesModule = PreferencesModule = PreferencesModule_1 = __decorate([
|
|
46
|
+
(0, common_1.Module)({})
|
|
47
|
+
], PreferencesModule);
|
|
48
|
+
//# sourceMappingURL=preferences.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferences.module.js","sourceRoot":"","sources":["../src/preferences.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,mFAAmF;AACnF,2CAAsF;AACtF,uDAA4D;AAE5D,yEAAqE;AACrE,uEAAkE;AAClE,qCAAyD;AAUzD;;;;;;;;GAQG;AAEI,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAC5B,MAAM,CAAC,OAAO,CAAC,UAAoC,EAAE;QACnD,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,IAAI,yCAAuB,CAAC;QAC5D,MAAM,SAAS,GAAe;YAC5B,UAAU;YACV,EAAE,OAAO,EAAE,sCAA6B,EAAE,WAAW,EAAE,UAAU,EAAE;YACnE,kDAAuB;YACvB,+CAAqB;YACrB,EAAE,OAAO,EAAE,wDAA4B,EAAE,WAAW,EAAE,+CAAqB,EAAE;SAC9E,CAAC;QACF,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI;YAC9B,SAAS;YACT,OAAO,EAAE,CAAC,kDAAuB,EAAE,sCAA6B,CAAC;SAClE,CAAC;IACJ,CAAC;CACF,CAAA;AAjBY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,iBAAiB,CAiB7B"}
|
package/dist/tokens.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,eAAO,MAAM,6BAA6B,eAA0C,CAAC"}
|
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NOTIFICATION_PREFERENCE_STORE = void 0;
|
|
4
|
+
/** DI token for the {@link PreferenceStore} implementation backing the preferences package. */
|
|
5
|
+
exports.NOTIFICATION_PREFERENCE_STORE = Symbol('NOTIFICATION_PREFERENCE_STORE');
|
|
6
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":";;;AAAA,+FAA+F;AAClF,QAAA,6BAA6B,GAAG,MAAM,CAAC,+BAA+B,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dudousxd/nestjs-notifications-preferences",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Per-user, per-tenant channel preferences for nestjs-notifications — opt-out muting enforced via the core PreferenceGate",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Davide Carvalho",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/DavideCarvalho/nestjs-notifications.git",
|
|
10
|
+
"directory": "packages/preferences"
|
|
11
|
+
},
|
|
12
|
+
"type": "commonjs",
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@dudousxd/nestjs-notifications-core": ">=0.1.0 <1.0.0",
|
|
20
|
+
"@nestjs/common": "^10.0.0 || ^11.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@nestjs/common": "^11.0.0",
|
|
24
|
+
"reflect-metadata": "^0.2.2",
|
|
25
|
+
"typescript": "^5.7.2",
|
|
26
|
+
"@dudousxd/nestjs-notifications-core": "^0.4.0"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -p tsconfig.json",
|
|
30
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
31
|
+
}
|
|
32
|
+
}
|