@tstdl/base 0.88.0-alpha1 → 0.88.0-alpha3

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.
Files changed (78) hide show
  1. package/authentication/index.d.ts +1 -0
  2. package/authentication/index.js +1 -0
  3. package/browser/index.d.ts +1 -0
  4. package/browser/index.js +1 -0
  5. package/data-structures/index.d.ts +1 -0
  6. package/data-structures/index.js +1 -0
  7. package/http/client/adapters/index.d.ts +1 -0
  8. package/http/client/adapters/index.js +1 -0
  9. package/http/client/index.d.ts +2 -0
  10. package/http/client/index.js +2 -0
  11. package/mail/clients/index.d.ts +1 -0
  12. package/mail/clients/index.js +1 -0
  13. package/mail/index.d.ts +2 -0
  14. package/mail/index.js +2 -0
  15. package/mail/mail.service.d.ts +1 -1
  16. package/mail/mail.service.js +1 -1
  17. package/mail/module.d.ts +1 -1
  18. package/mail/module.js +1 -1
  19. package/mail/repositories/index.d.ts +1 -0
  20. package/mail/repositories/index.js +1 -0
  21. package/mail/repositories/mail-log.repository.d.ts +4 -0
  22. package/mail/{mail-log.repository.js → repositories/mail-log.repository.js} +1 -1
  23. package/mail/repositories/mongo/index.d.ts +1 -0
  24. package/mail/repositories/mongo/index.js +1 -0
  25. package/mail/repositories/{mongo-mail-log.repository.d.ts → mongo/mongo-mail-log.repository.d.ts} +6 -6
  26. package/mail/repositories/{mongo-mail-log.repository.js → mongo/mongo-mail-log.repository.js} +3 -3
  27. package/package.json +103 -6
  28. package/random/number-generator/index.d.ts +2 -0
  29. package/random/number-generator/index.js +2 -0
  30. package/random/number-generator/utils.d.ts +1 -0
  31. package/random/number-generator/utils.js +5 -0
  32. package/rpc/endpoints/index.d.ts +1 -0
  33. package/rpc/endpoints/index.js +1 -0
  34. package/rpc/endpoints/message-port.rpc-endpoint.js +1 -1
  35. package/signals/implementation/api.d.ts +1 -18
  36. package/signals/implementation/api.js +1 -10
  37. package/signals/implementation/computed.js +42 -94
  38. package/signals/implementation/effect.d.ts +1 -1
  39. package/signals/implementation/effect.js +16 -15
  40. package/signals/implementation/graph.d.ts +118 -73
  41. package/signals/implementation/graph.js +235 -156
  42. package/signals/implementation/signal.js +58 -81
  43. package/signals/implementation/watch.d.ts +2 -18
  44. package/signals/implementation/watch.js +37 -54
  45. package/sse/index.d.ts +1 -0
  46. package/sse/index.js +1 -0
  47. package/templates/providers/index.d.ts +2 -0
  48. package/templates/providers/index.js +2 -0
  49. package/templates/renderers/index.d.ts +4 -0
  50. package/templates/renderers/index.js +4 -0
  51. package/templates/resolvers/index.d.ts +3 -0
  52. package/templates/resolvers/index.js +3 -0
  53. package/templates/types/index.d.ts +1 -0
  54. package/templates/types/index.js +1 -0
  55. package/text/dynamic-text.model.js +3 -5
  56. package/theme/adapters/index.d.ts +2 -0
  57. package/theme/adapters/index.js +2 -0
  58. package/utils/index.d.ts +8 -0
  59. package/utils/index.js +8 -0
  60. package/async-iterator-symbol.d.ts +0 -1
  61. package/async-iterator-symbol.js +0 -6
  62. package/mail/mail-log.repository.d.ts +0 -4
  63. package/notification/api.d.ts +0 -15
  64. package/notification/api.js +0 -28
  65. package/notification/models/index.d.ts +0 -2
  66. package/notification/models/index.js +0 -2
  67. package/notification/models/notification-channel-job.model.d.ts +0 -3
  68. package/notification/models/notification-channel-job.model.js +0 -1
  69. package/notification/models/notification.model.d.ts +0 -45
  70. package/notification/models/notification.model.js +0 -103
  71. package/notification/module.d.ts +0 -9
  72. package/notification/module.js +0 -10
  73. package/notification/notification-channel.service.d.ts +0 -5
  74. package/notification/notification-channel.service.js +0 -2
  75. package/notification/notification.repository.d.ts +0 -5
  76. package/notification/notification.repository.js +0 -2
  77. package/notification/notification.service.d.ts +0 -8
  78. package/notification/notification.service.js +0 -36
@@ -5,65 +5,48 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { ReactiveNode, setActiveConsumer } from './graph.js';
9
- const NOOP_CLEANUP_FN = () => { };
10
- /**
11
- * Watches a reactive expression and allows it to be scheduled to re-run
12
- * when any dependencies notify of a change.
13
- *
14
- * `Watch` doesn't run reactive expressions itself, but relies on a consumer-
15
- * provided scheduling operation to coordinate calling `Watch.run()`.
16
- */
17
- export class Watch extends ReactiveNode {
18
- watch;
19
- schedule;
20
- consumerAllowSignalWrites;
21
- dirty = false;
22
- cleanupFn = NOOP_CLEANUP_FN;
23
- registerOnCleanup = (cleanupFn) => {
24
- this.cleanupFn = cleanupFn;
25
- };
26
- constructor(watch, schedule, allowSignalWrites) {
27
- super();
28
- this.watch = watch;
29
- this.schedule = schedule;
30
- this.consumerAllowSignalWrites = allowSignalWrites;
31
- }
32
- notify() {
33
- if (!this.dirty) {
34
- this.schedule(this);
35
- }
36
- this.dirty = true;
37
- }
38
- onConsumerDependencyMayHaveChanged() {
39
- this.notify();
8
+ import { consumerAfterComputation, consumerBeforeComputation, consumerMarkDirty, consumerPollProducersForChange, REACTIVE_NODE } from './graph.js';
9
+ export function watch(fn, schedule, allowSignalWrites) {
10
+ const node = Object.create(WATCH_NODE);
11
+ if (allowSignalWrites) {
12
+ node.consumerAllowSignalWrites = true;
40
13
  }
41
- onProducerUpdateValueVersion() {
42
- // Watches are not producers.
43
- }
44
- /**
45
- * Execute the reactive expression in the context of this `Watch` consumer.
46
- *
47
- * Should be called by the user scheduling algorithm when the provided
48
- * `schedule` hook is called by `Watch`.
49
- */
50
- run() {
51
- this.dirty = false;
52
- if (this.trackingVersion !== 0 && !this.consumerPollProducersForChange()) {
14
+ node.fn = fn;
15
+ node.schedule = schedule;
16
+ const registerOnCleanup = (cleanupFn) => {
17
+ node.cleanupFn = cleanupFn;
18
+ };
19
+ const run = () => {
20
+ node.dirty = false;
21
+ if (node.hasRun && !consumerPollProducersForChange(node)) {
53
22
  return;
54
23
  }
55
- const prevConsumer = setActiveConsumer(this);
56
- this.trackingVersion++;
24
+ node.hasRun = true;
25
+ const prevConsumer = consumerBeforeComputation(node);
57
26
  try {
58
- this.cleanupFn();
59
- this.cleanupFn = NOOP_CLEANUP_FN;
60
- this.watch(this.registerOnCleanup);
27
+ node.cleanupFn();
28
+ node.cleanupFn = NOOP_CLEANUP_FN;
29
+ node.fn(registerOnCleanup);
61
30
  }
62
31
  finally {
63
- setActiveConsumer(prevConsumer);
32
+ consumerAfterComputation(node, prevConsumer);
64
33
  }
65
- }
66
- cleanup() {
67
- this.cleanupFn();
68
- }
34
+ };
35
+ node.ref = {
36
+ notify: () => consumerMarkDirty(node),
37
+ run,
38
+ cleanup: () => node.cleanupFn(),
39
+ };
40
+ return node.ref;
69
41
  }
42
+ const NOOP_CLEANUP_FN = () => { };
43
+ const WATCH_NODE = {
44
+ ...REACTIVE_NODE,
45
+ consumerIsAlwaysLive: true,
46
+ consumerAllowSignalWrites: false,
47
+ consumerMarkedDirty: (node) => {
48
+ node.schedule(node.ref);
49
+ },
50
+ hasRun: false,
51
+ cleanupFn: NOOP_CLEANUP_FN,
52
+ };
package/sse/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ export * from './model.js';
1
2
  export * from './server-sent-events-source.js';
2
3
  export * from './server-sent-events.js';
package/sse/index.js CHANGED
@@ -1,2 +1,3 @@
1
+ export * from './model.js';
1
2
  export * from './server-sent-events-source.js';
2
3
  export * from './server-sent-events.js';
@@ -0,0 +1,2 @@
1
+ export * from './file.template-provider.js';
2
+ export * from './memory.template-provider.js';
@@ -0,0 +1,2 @@
1
+ export * from './file.template-provider.js';
2
+ export * from './memory.template-provider.js';
@@ -0,0 +1,4 @@
1
+ export * from './handlebars.template-renderer.js';
2
+ export * from './jsx.template-renderer.js';
3
+ export * from './mjml.template-renderer.js';
4
+ export * from './string.template-renderer.js';
@@ -0,0 +1,4 @@
1
+ export * from './handlebars.template-renderer.js';
2
+ export * from './jsx.template-renderer.js';
3
+ export * from './mjml.template-renderer.js';
4
+ export * from './string.template-renderer.js';
@@ -0,0 +1,3 @@
1
+ export * from './file.template-resolver.js';
2
+ export * from './jsx.template-resolver.js';
3
+ export * from './string.template-resolver.js';
@@ -0,0 +1,3 @@
1
+ export * from './file.template-resolver.js';
2
+ export * from './jsx.template-resolver.js';
3
+ export * from './string.template-resolver.js';
@@ -0,0 +1 @@
1
+ export * from './jsx.intrinsic-elements.js';
@@ -0,0 +1 @@
1
+ export * from './jsx.intrinsic-elements.js';
@@ -1,20 +1,18 @@
1
1
  import { isObservable } from 'rxjs';
2
- import { getGlobalInjector } from '../core.js';
3
- import { inject, isInInjectionContext } from '../injector/inject.js';
2
+ import { inject } from '../injector/inject.js';
4
3
  import { computed, isSignal, toObservable, toSignal } from '../signals/api.js';
5
4
  import { switchMap } from '../signals/switch-map.js';
6
5
  import { runInUntracked } from '../signals/untracked-operator.js';
7
6
  import { isString } from '../utils/type-guards.js';
8
7
  import { LocalizationService } from './localization.service.js';
9
8
  export const missingLocalizationKeyText = '[MISSING LOCALIZATION KEY]';
10
- export function resolveDynamicText(text, localizationService) {
11
- const resolvedLocalizationService = localizationService ?? (isInInjectionContext() ? inject(LocalizationService) : getGlobalInjector().resolve(LocalizationService));
9
+ export function resolveDynamicText(text, localizationService = inject(LocalizationService)) {
12
10
  const localizableTextSignal = isSignal(text) ? text
13
11
  : isObservable(text) ? toSignal(text.pipe(runInUntracked()), { initialValue: missingLocalizationKeyText })
14
12
  : computed(() => text);
15
13
  return switchMap(() => {
16
14
  const localizableText = localizableTextSignal();
17
- return isString(localizableText) ? computed(() => localizableText) : resolvedLocalizationService.localize(localizableText);
15
+ return isString(localizableText) ? computed(() => localizableText) : localizationService.localize(localizableText);
18
16
  });
19
17
  }
20
18
  export function resolveDynamicText$(text, localizationService) {
@@ -0,0 +1,2 @@
1
+ export * from './css-adapter.js';
2
+ export * from './tailwind-adapter.js';
@@ -0,0 +1,2 @@
1
+ export * from './css-adapter.js';
2
+ export * from './tailwind-adapter.js';
package/utils/index.d.ts CHANGED
@@ -8,6 +8,10 @@ export * from './binary-search.js';
8
8
  export * from './binary.js';
9
9
  export * from './clone.js';
10
10
  export * from './comparison.js';
11
+ export * from './compression.js';
12
+ export * from './config-parser.js';
13
+ export * from './crc32.js';
14
+ export * from './cryptography.js';
11
15
  export * from './date-time.js';
12
16
  export * from './encoding.js';
13
17
  export * from './enum.js';
@@ -17,8 +21,10 @@ export * from './factory-map.js';
17
21
  export * from './feedable-async-iterable.js';
18
22
  export * from './file-reader.js';
19
23
  export * from './format-error.js';
24
+ export * from './format.js';
20
25
  export * from './helpers.js';
21
26
  export * from './image.js';
27
+ export * from './jwt.js';
22
28
  export * from './map.js';
23
29
  export * from './math.js';
24
30
  export * from './merge.js';
@@ -26,6 +32,7 @@ export * from './middleware.js';
26
32
  export * from './moving-metric.js';
27
33
  export * from './noop.js';
28
34
  export * from './ordered-feedable-async-iterable.js';
35
+ export * from './patch-worker.js';
29
36
  export * from './patterns.js';
30
37
  export * from './periodic-reporter.js';
31
38
  export * from './periodic-sampler.js';
@@ -33,6 +40,7 @@ export * from './provider-function-iterable.js';
33
40
  export * from './proxy.js';
34
41
  export * from './random.js';
35
42
  export * from './reflection.js';
43
+ export * from './repl.js';
36
44
  export * from './set.js';
37
45
  export * from './singleton.js';
38
46
  export * from './sort.js';
package/utils/index.js CHANGED
@@ -8,6 +8,10 @@ export * from './binary-search.js';
8
8
  export * from './binary.js';
9
9
  export * from './clone.js';
10
10
  export * from './comparison.js';
11
+ export * from './compression.js';
12
+ export * from './config-parser.js';
13
+ export * from './crc32.js';
14
+ export * from './cryptography.js';
11
15
  export * from './date-time.js';
12
16
  export * from './encoding.js';
13
17
  export * from './enum.js';
@@ -17,8 +21,10 @@ export * from './factory-map.js';
17
21
  export * from './feedable-async-iterable.js';
18
22
  export * from './file-reader.js';
19
23
  export * from './format-error.js';
24
+ export * from './format.js';
20
25
  export * from './helpers.js';
21
26
  export * from './image.js';
27
+ export * from './jwt.js';
22
28
  export * from './map.js';
23
29
  export * from './math.js';
24
30
  export * from './merge.js';
@@ -26,6 +32,7 @@ export * from './middleware.js';
26
32
  export * from './moving-metric.js';
27
33
  export * from './noop.js';
28
34
  export * from './ordered-feedable-async-iterable.js';
35
+ export * from './patch-worker.js';
29
36
  export * from './patterns.js';
30
37
  export * from './periodic-reporter.js';
31
38
  export * from './periodic-sampler.js';
@@ -33,6 +40,7 @@ export * from './provider-function-iterable.js';
33
40
  export * from './proxy.js';
34
41
  export * from './random.js';
35
42
  export * from './reflection.js';
43
+ export * from './repl.js';
36
44
  export * from './set.js';
37
45
  export * from './singleton.js';
38
46
  export * from './sort.js';
@@ -1 +0,0 @@
1
- export declare function polyfillAsyncIteratorSymbol(): void;
@@ -1,6 +0,0 @@
1
- export function polyfillAsyncIteratorSymbol() {
2
- const hasAsyncIteratorSymbol = 'asyncIterator' in Symbol;
3
- if (!hasAsyncIteratorSymbol) {
4
- Symbol.asyncIterator = Symbol.for('Symbol.asyncIterator');
5
- }
6
- }
@@ -1,4 +0,0 @@
1
- import { EntityRepository } from '../database/index.js';
2
- import type { MailLog } from './models/mail-log.model.js';
3
- export declare abstract class MailLogRepository extends EntityRepository<MailLog> {
4
- }
@@ -1,15 +0,0 @@
1
- import type { ApiServerResult } from '../api/types.js';
2
- import { Notification } from './models/index.js';
3
- declare const notificationApiDefinition: {
4
- readonly resource: string;
5
- endpoints: {
6
- get: {
7
- result: import("../schema/index.js").ValueSchema<Notification<unknown>[]>;
8
- };
9
- };
10
- };
11
- type NotificationApiDefinition = typeof notificationApiDefinition;
12
- export declare class NotificationApi {
13
- get(): Promise<ApiServerResult<NotificationApiDefinition, 'get'>>;
14
- }
15
- export {};
@@ -1,28 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { apiController } from '../api/server/api-controller.js';
8
- import { defineApi } from '../api/types.js';
9
- import { array } from '../schema/index.js';
10
- import { Notification } from './models/index.js';
11
- import { notificationModuleConfig } from './module.js';
12
- const notificationApiDefinition = defineApi({
13
- get resource() { return notificationModuleConfig.apiResource; },
14
- endpoints: {
15
- get: {
16
- result: array(Notification)
17
- }
18
- }
19
- });
20
- let NotificationApi = class NotificationApi {
21
- async get() {
22
- return [];
23
- }
24
- };
25
- NotificationApi = __decorate([
26
- apiController(notificationApiDefinition)
27
- ], NotificationApi);
28
- export { NotificationApi };
@@ -1,2 +0,0 @@
1
- export * from './notification-channel-job.model.js';
2
- export * from './notification.model.js';
@@ -1,2 +0,0 @@
1
- export * from './notification-channel-job.model.js';
2
- export * from './notification.model.js';
@@ -1,3 +0,0 @@
1
- export type NotificationChannelJob<Type extends string = string> = {
2
- type: Type;
3
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,45 +0,0 @@
1
- export declare class Notification<T = unknown> {
2
- id: string;
3
- /**
4
- * Receiver for the notification
5
- */
6
- receiver: string;
7
- /**
8
- * Channels over which the notification is sent
9
- */
10
- channels: string[];
11
- /**
12
- * Timestamp at which the notification was created
13
- */
14
- timestamp: number;
15
- /**
16
- * Timestamp at which the notification was marked as read
17
- */
18
- readTimestamp: number | null;
19
- /**
20
- * Custom data
21
- */
22
- data: T;
23
- }
24
- export declare class NewNotification<T> {
25
- /**
26
- * Receiver for the notification
27
- */
28
- receiver: string;
29
- /**
30
- * Channels over which the notification is sent
31
- */
32
- channels: string[];
33
- /**
34
- * Timestamp at which the notification was created
35
- */
36
- timestamp: number;
37
- /**
38
- * Timestamp at which the notification was marked as read
39
- */
40
- readTimestamp: number | null;
41
- /**
42
- * Custom data
43
- */
44
- data: T;
45
- }
@@ -1,103 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { Any, Array, Class, Property } from '../../schema/index.js';
11
- export class Notification {
12
- id;
13
- /**
14
- * Receiver for the notification
15
- */
16
- receiver;
17
- /**
18
- * Channels over which the notification is sent
19
- */
20
- channels;
21
- /**
22
- * Timestamp at which the notification was created
23
- */
24
- timestamp;
25
- /**
26
- * Timestamp at which the notification was marked as read
27
- */
28
- readTimestamp;
29
- /**
30
- * Custom data
31
- */
32
- data;
33
- }
34
- __decorate([
35
- Property(),
36
- __metadata("design:type", String)
37
- ], Notification.prototype, "id", void 0);
38
- __decorate([
39
- Property(),
40
- __metadata("design:type", String)
41
- ], Notification.prototype, "receiver", void 0);
42
- __decorate([
43
- Array(String),
44
- __metadata("design:type", Array)
45
- ], Notification.prototype, "channels", void 0);
46
- __decorate([
47
- Property(),
48
- __metadata("design:type", Number)
49
- ], Notification.prototype, "timestamp", void 0);
50
- __decorate([
51
- Property(),
52
- __metadata("design:type", Object)
53
- ], Notification.prototype, "readTimestamp", void 0);
54
- __decorate([
55
- Any(),
56
- __metadata("design:type", Object)
57
- ], Notification.prototype, "data", void 0);
58
- let NewNotification = class NewNotification {
59
- /**
60
- * Receiver for the notification
61
- */
62
- receiver;
63
- /**
64
- * Channels over which the notification is sent
65
- */
66
- channels;
67
- /**
68
- * Timestamp at which the notification was created
69
- */
70
- timestamp;
71
- /**
72
- * Timestamp at which the notification was marked as read
73
- */
74
- readTimestamp;
75
- /**
76
- * Custom data
77
- */
78
- data;
79
- };
80
- __decorate([
81
- Property(),
82
- __metadata("design:type", String)
83
- ], NewNotification.prototype, "receiver", void 0);
84
- __decorate([
85
- Array(String),
86
- __metadata("design:type", Array)
87
- ], NewNotification.prototype, "channels", void 0);
88
- __decorate([
89
- Property(),
90
- __metadata("design:type", Number)
91
- ], NewNotification.prototype, "timestamp", void 0);
92
- __decorate([
93
- Property(),
94
- __metadata("design:type", Object)
95
- ], NewNotification.prototype, "readTimestamp", void 0);
96
- __decorate([
97
- Any(),
98
- __metadata("design:type", Object)
99
- ], NewNotification.prototype, "data", void 0);
100
- NewNotification = __decorate([
101
- Class()
102
- ], NewNotification);
103
- export { NewNotification };
@@ -1,9 +0,0 @@
1
- export type NotificationModuleConfig = {
2
- apiResource: string;
3
- };
4
- export declare const notificationModuleConfig: NotificationModuleConfig;
5
- /**
6
- * Configure notifiation module.
7
- * @param config configuration
8
- */
9
- export declare function configureNotification(config: Partial<NotificationModuleConfig>): void;
@@ -1,10 +0,0 @@
1
- export const notificationModuleConfig = {
2
- apiResource: 'notifications'
3
- };
4
- /**
5
- * Configure notifiation module.
6
- * @param config configuration
7
- */
8
- export function configureNotification(config) {
9
- notificationModuleConfig.apiResource = config.apiResource ?? notificationModuleConfig.apiResource;
10
- }
@@ -1,5 +0,0 @@
1
- import type { NotificationChannelJob } from './models/notification-channel-job.model.js';
2
- export declare abstract class NotificationChannel {
3
- abstract type: string;
4
- abstract handle(job: NotificationChannelJob): Promise<void>;
5
- }
@@ -1,2 +0,0 @@
1
- export class NotificationChannel {
2
- }
@@ -1,5 +0,0 @@
1
- import type { NewNotification, Notification } from './models/notification.model.js';
2
- export declare abstract class NotificationRepository<T> {
3
- abstract insertAndLoad(notification: NewNotification<T>): Promise<Notification<T>>;
4
- abstract markAsRead(id: string): Promise<void>;
5
- }
@@ -1,2 +0,0 @@
1
- export class NotificationRepository {
2
- }
@@ -1,8 +0,0 @@
1
- import type { Notification } from './models/notification.model.js';
2
- import { NotificationRepository } from './notification.repository.js';
3
- export declare class NotificationService<T> {
4
- private readonly notificationRepository;
5
- constructor(notificationRepository: NotificationRepository<T>);
6
- send(receiver: string, channels: string[], data: T): Promise<Notification<T>>;
7
- markAsRead(id: string): Promise<void>;
8
- }
@@ -1,36 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { Singleton } from '../injector/decorators.js';
11
- import { currentTimestamp } from '../utils/date-time.js';
12
- import { NotificationRepository } from './notification.repository.js';
13
- let NotificationService = class NotificationService {
14
- notificationRepository;
15
- constructor(notificationRepository) {
16
- this.notificationRepository = notificationRepository;
17
- }
18
- async send(receiver, channels, data) {
19
- const newNotification = {
20
- receiver,
21
- channels,
22
- timestamp: currentTimestamp(),
23
- readTimestamp: null,
24
- data
25
- };
26
- return this.notificationRepository.insertAndLoad(newNotification);
27
- }
28
- async markAsRead(id) {
29
- return this.notificationRepository.markAsRead(id);
30
- }
31
- };
32
- NotificationService = __decorate([
33
- Singleton(),
34
- __metadata("design:paramtypes", [NotificationRepository])
35
- ], NotificationService);
36
- export { NotificationService };