@plyaz/types 1.45.2 → 1.45.3
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/api/endpoints/index.d.ts +1 -0
- package/dist/api/endpoints/notification/endpoints.d.ts +47 -0
- package/dist/api/endpoints/notification/index.d.ts +13 -0
- package/dist/api/endpoints/notification/schemas.d.ts +195 -0
- package/dist/api/endpoints/types.d.ts +2 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/core/domain/index.d.ts +1 -0
- package/dist/core/domain/notifications/index.d.ts +11 -0
- package/dist/core/domain/notifications/schemas.d.ts +195 -0
- package/dist/core/domain/notifications/streaming.d.ts +97 -0
- package/dist/core/domain/notifications/types.d.ts +120 -0
- package/dist/core/index.cjs +164 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +154 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/services/keys.d.ts +4 -0
- package/dist/index.cjs +265 -139
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +255 -140
- package/dist/index.js.map +1 -1
- package/dist/store/index.d.ts +1 -0
- package/dist/store/notifications/index.d.ts +5 -0
- package/dist/store/notifications/types.d.ts +85 -0
- package/dist/store/types.d.ts +3 -0
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ export type * from './featureFlags';
|
|
|
3
3
|
export type * from './files';
|
|
4
4
|
export type * from './health';
|
|
5
5
|
export type * from './infobip';
|
|
6
|
+
export type * from './notification';
|
|
6
7
|
export type * from './virustotal';
|
|
7
8
|
export type * from './cdn';
|
|
8
9
|
export type * from './types';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification Endpoint Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Uses fetchff's Endpoint and Req types for type-safe API definitions.
|
|
5
|
+
*
|
|
6
|
+
* Req<TResponse, TBody?, TQuery?, TParams?> generic parameters:
|
|
7
|
+
* - TResponse: The response type returned by the endpoint
|
|
8
|
+
* - TBody: The request body type (use 'never' for GET/DELETE)
|
|
9
|
+
* - TQuery: URL query parameters type
|
|
10
|
+
* - TParams: URL path parameters type (use 'never' if no path params)
|
|
11
|
+
*
|
|
12
|
+
* Available endpoints:
|
|
13
|
+
* - GET /notifications (list)
|
|
14
|
+
* - DELETE /notifications/:id
|
|
15
|
+
*/
|
|
16
|
+
import type { Endpoint, Req } from 'fetchff';
|
|
17
|
+
import type { ListNotificationFilters, ListNotificationResponse, DeleteNotificationParams, DeleteNotificationResponse } from './schemas';
|
|
18
|
+
/**
|
|
19
|
+
* Notification API endpoint types.
|
|
20
|
+
* Complete type definitions for notification operation endpoints.
|
|
21
|
+
*/
|
|
22
|
+
export interface NotificationEndpointTypes {
|
|
23
|
+
/**
|
|
24
|
+
* GET /notifications - List notifications
|
|
25
|
+
* Returns paginated list with optional filters.
|
|
26
|
+
*
|
|
27
|
+
* Req<Response, Body, Query>
|
|
28
|
+
* - Response: ListNotificationResponse
|
|
29
|
+
* - Body: never (GET has no body)
|
|
30
|
+
* - Query: ListNotificationFilters
|
|
31
|
+
*/
|
|
32
|
+
listNotifications: Endpoint<Req<ListNotificationResponse, never, ListNotificationFilters>>;
|
|
33
|
+
/**
|
|
34
|
+
* DELETE /notifications/:id - Delete a notification
|
|
35
|
+
*
|
|
36
|
+
* Req<Response, Body, Query, Params>
|
|
37
|
+
* - Response: DeleteNotificationResponse
|
|
38
|
+
* - Body: never (DELETE typically has no body)
|
|
39
|
+
* - Query: never (no query params)
|
|
40
|
+
* - Params: DeleteNotificationParams (path params)
|
|
41
|
+
*/
|
|
42
|
+
deleteNotification: Endpoint<Req<DeleteNotificationResponse, never, never, DeleteNotificationParams>>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Type guard for notification endpoint keys.
|
|
46
|
+
*/
|
|
47
|
+
export type NotificationEndpointKey = keyof NotificationEndpointTypes;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification API Endpoint Types
|
|
3
|
+
* Export all notification operation types and schemas
|
|
4
|
+
*
|
|
5
|
+
* Single source of truth: types are inferred from Zod schemas
|
|
6
|
+
*
|
|
7
|
+
* Available endpoints:
|
|
8
|
+
* - GET /notifications (list)
|
|
9
|
+
* - DELETE /notifications/:id
|
|
10
|
+
*/
|
|
11
|
+
export { NotificationSchema, ListNotificationFiltersSchema, DeleteNotificationParamsSchema, ListNotificationResponseSchema, DeleteNotificationResponseSchema, } from './schemas';
|
|
12
|
+
export type { NotificationTypeValue, NotificationChannelValue, NotificationStatusValue, NotificationCategoryValue, Notification, ListNotificationFilters, DeleteNotificationParams, ListNotificationResponse, DeleteNotificationResponse, } from './schemas';
|
|
13
|
+
export type { NotificationEndpointTypes, NotificationEndpointKey } from './endpoints';
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification API Endpoint Schemas
|
|
3
|
+
*
|
|
4
|
+
* Zod schemas for notification API operations.
|
|
5
|
+
* Types are inferred from schemas (single source of truth).
|
|
6
|
+
*
|
|
7
|
+
* Enum schemas are imported from core/domain (match DB ENUMs)
|
|
8
|
+
*
|
|
9
|
+
* Available endpoints:
|
|
10
|
+
* - GET /notifications (list)
|
|
11
|
+
* - DELETE /notifications/:id
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { NotificationCategorySchema } from '../../../notifications/schemas';
|
|
15
|
+
import { NotificationTypeSchema, NotificationChannelSchema, NotificationStatusSchema } from '../../../core/domain/notifications/schemas';
|
|
16
|
+
/**
|
|
17
|
+
* Notification entity schema
|
|
18
|
+
* Matches migration 006_notifications_media.sql
|
|
19
|
+
*/
|
|
20
|
+
export declare const NotificationSchema: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
user_id: z.ZodString;
|
|
23
|
+
type: z.ZodEnum<{
|
|
24
|
+
SYSTEM: "SYSTEM";
|
|
25
|
+
CAMPAIGN_BACKED: "CAMPAIGN_BACKED";
|
|
26
|
+
}>;
|
|
27
|
+
title: z.ZodString;
|
|
28
|
+
message: z.ZodString;
|
|
29
|
+
link_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
reference_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
|
+
reference_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
correlation_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
|
+
recipient_id: z.ZodString;
|
|
34
|
+
template_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
35
|
+
channel: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
36
|
+
IN_APP: "IN_APP";
|
|
37
|
+
EMAIL: "EMAIL";
|
|
38
|
+
SMS: "SMS";
|
|
39
|
+
PUSH: "PUSH";
|
|
40
|
+
}>>>;
|
|
41
|
+
category: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodEnum<{
|
|
42
|
+
system: "system";
|
|
43
|
+
transactional: "transactional";
|
|
44
|
+
marketing: "marketing";
|
|
45
|
+
social: "social";
|
|
46
|
+
promotional: "promotional";
|
|
47
|
+
}>>>>;
|
|
48
|
+
provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
provider_message_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
51
|
+
processing: "processing";
|
|
52
|
+
failed: "failed";
|
|
53
|
+
sent: "sent";
|
|
54
|
+
delivered: "delivered";
|
|
55
|
+
bounced: "bounced";
|
|
56
|
+
queued: "queued";
|
|
57
|
+
}>>;
|
|
58
|
+
sent_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
delivered_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
60
|
+
is_read: z.ZodDefault<z.ZodBoolean>;
|
|
61
|
+
read_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
62
|
+
error_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
63
|
+
retry_count: z.ZodDefault<z.ZodNumber>;
|
|
64
|
+
created_at: z.ZodString;
|
|
65
|
+
deleted_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
/**
|
|
68
|
+
* GET /notifications - Query filters
|
|
69
|
+
*/
|
|
70
|
+
export declare const ListNotificationFiltersSchema: z.ZodObject<{
|
|
71
|
+
page: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
72
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
73
|
+
offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
74
|
+
sort_by: z.ZodOptional<z.ZodEnum<{
|
|
75
|
+
created_at: "created_at";
|
|
76
|
+
sent_at: "sent_at";
|
|
77
|
+
delivered_at: "delivered_at";
|
|
78
|
+
}>>;
|
|
79
|
+
sort_order: z.ZodOptional<z.ZodEnum<{
|
|
80
|
+
asc: "asc";
|
|
81
|
+
desc: "desc";
|
|
82
|
+
}>>;
|
|
83
|
+
user_id: z.ZodOptional<z.ZodString>;
|
|
84
|
+
channel: z.ZodOptional<z.ZodEnum<{
|
|
85
|
+
IN_APP: "IN_APP";
|
|
86
|
+
EMAIL: "EMAIL";
|
|
87
|
+
SMS: "SMS";
|
|
88
|
+
PUSH: "PUSH";
|
|
89
|
+
}>>;
|
|
90
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
91
|
+
processing: "processing";
|
|
92
|
+
failed: "failed";
|
|
93
|
+
sent: "sent";
|
|
94
|
+
delivered: "delivered";
|
|
95
|
+
bounced: "bounced";
|
|
96
|
+
queued: "queued";
|
|
97
|
+
}>>;
|
|
98
|
+
category: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
99
|
+
system: "system";
|
|
100
|
+
transactional: "transactional";
|
|
101
|
+
marketing: "marketing";
|
|
102
|
+
social: "social";
|
|
103
|
+
promotional: "promotional";
|
|
104
|
+
}>>>;
|
|
105
|
+
template_id: z.ZodOptional<z.ZodString>;
|
|
106
|
+
recipient_id: z.ZodOptional<z.ZodString>;
|
|
107
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
108
|
+
SYSTEM: "SYSTEM";
|
|
109
|
+
CAMPAIGN_BACKED: "CAMPAIGN_BACKED";
|
|
110
|
+
}>>;
|
|
111
|
+
is_read: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
112
|
+
created_after: z.ZodOptional<z.ZodString>;
|
|
113
|
+
created_before: z.ZodOptional<z.ZodString>;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
/**
|
|
116
|
+
* DELETE /notifications/:id - Delete params
|
|
117
|
+
*/
|
|
118
|
+
export declare const DeleteNotificationParamsSchema: z.ZodObject<{
|
|
119
|
+
id: z.ZodString;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
/**
|
|
122
|
+
* GET /notifications - List response
|
|
123
|
+
* Pagination fields inlined (no separate schema needed)
|
|
124
|
+
*/
|
|
125
|
+
export declare const ListNotificationResponseSchema: z.ZodObject<{
|
|
126
|
+
data: z.ZodArray<z.ZodObject<{
|
|
127
|
+
id: z.ZodString;
|
|
128
|
+
user_id: z.ZodString;
|
|
129
|
+
type: z.ZodEnum<{
|
|
130
|
+
SYSTEM: "SYSTEM";
|
|
131
|
+
CAMPAIGN_BACKED: "CAMPAIGN_BACKED";
|
|
132
|
+
}>;
|
|
133
|
+
title: z.ZodString;
|
|
134
|
+
message: z.ZodString;
|
|
135
|
+
link_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
136
|
+
reference_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
137
|
+
reference_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
138
|
+
correlation_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
139
|
+
recipient_id: z.ZodString;
|
|
140
|
+
template_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
141
|
+
channel: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
142
|
+
IN_APP: "IN_APP";
|
|
143
|
+
EMAIL: "EMAIL";
|
|
144
|
+
SMS: "SMS";
|
|
145
|
+
PUSH: "PUSH";
|
|
146
|
+
}>>>;
|
|
147
|
+
category: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodEnum<{
|
|
148
|
+
system: "system";
|
|
149
|
+
transactional: "transactional";
|
|
150
|
+
marketing: "marketing";
|
|
151
|
+
social: "social";
|
|
152
|
+
promotional: "promotional";
|
|
153
|
+
}>>>>;
|
|
154
|
+
provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
155
|
+
provider_message_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
156
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
157
|
+
processing: "processing";
|
|
158
|
+
failed: "failed";
|
|
159
|
+
sent: "sent";
|
|
160
|
+
delivered: "delivered";
|
|
161
|
+
bounced: "bounced";
|
|
162
|
+
queued: "queued";
|
|
163
|
+
}>>;
|
|
164
|
+
sent_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
165
|
+
delivered_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
166
|
+
is_read: z.ZodDefault<z.ZodBoolean>;
|
|
167
|
+
read_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
168
|
+
error_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
169
|
+
retry_count: z.ZodDefault<z.ZodNumber>;
|
|
170
|
+
created_at: z.ZodString;
|
|
171
|
+
deleted_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
172
|
+
}, z.core.$strip>>;
|
|
173
|
+
pagination: z.ZodOptional<z.ZodObject<{
|
|
174
|
+
page: z.ZodNumber;
|
|
175
|
+
limit: z.ZodNumber;
|
|
176
|
+
total: z.ZodNumber;
|
|
177
|
+
totalPages: z.ZodNumber;
|
|
178
|
+
}, z.core.$strip>>;
|
|
179
|
+
}, z.core.$strip>;
|
|
180
|
+
/**
|
|
181
|
+
* DELETE /notifications/:id - Delete response
|
|
182
|
+
*/
|
|
183
|
+
export declare const DeleteNotificationResponseSchema: z.ZodObject<{
|
|
184
|
+
success: z.ZodBoolean;
|
|
185
|
+
id: z.ZodString;
|
|
186
|
+
}, z.core.$strip>;
|
|
187
|
+
export type NotificationTypeValue = z.infer<typeof NotificationTypeSchema>;
|
|
188
|
+
export type NotificationChannelValue = z.infer<typeof NotificationChannelSchema>;
|
|
189
|
+
export type NotificationStatusValue = z.infer<typeof NotificationStatusSchema>;
|
|
190
|
+
export type NotificationCategoryValue = z.infer<typeof NotificationCategorySchema>;
|
|
191
|
+
export type Notification = z.infer<typeof NotificationSchema>;
|
|
192
|
+
export type ListNotificationFilters = z.input<typeof ListNotificationFiltersSchema>;
|
|
193
|
+
export type DeleteNotificationParams = z.input<typeof DeleteNotificationParamsSchema>;
|
|
194
|
+
export type ListNotificationResponse = z.infer<typeof ListNotificationResponseSchema>;
|
|
195
|
+
export type DeleteNotificationResponse = z.infer<typeof DeleteNotificationResponseSchema>;
|
|
@@ -6,6 +6,7 @@ import type { CloudflareEndpointTypes, CloudFrontEndpointTypes, FastlyEndpointTy
|
|
|
6
6
|
import type { FeatureFlagEndpointTypes } from './featureFlags';
|
|
7
7
|
import type { PaymentEndpointTypes } from './payments';
|
|
8
8
|
import type { FilesEndpointTypes } from './files';
|
|
9
|
+
import type { NotificationEndpointTypes } from './notification';
|
|
9
10
|
/**
|
|
10
11
|
* Query parameters type - matches fetchff's flexible param handling
|
|
11
12
|
* Supports objects, URLSearchParams, and arrays of name-value pairs
|
|
@@ -14,5 +15,5 @@ export type QueryParams = Record<string, string | number | boolean | string[] |
|
|
|
14
15
|
/**
|
|
15
16
|
* All endpoint types combined
|
|
16
17
|
*/
|
|
17
|
-
export interface EndpointTypes extends CampaignEndpointTypes, PaymentEndpointTypes, PollingEndpointTypes, InfobipEndpointTypes, VirusTotalEndpointTypes, CloudflareEndpointTypes, CloudFrontEndpointTypes, FastlyEndpointTypes, FeatureFlagEndpointTypes, FilesEndpointTypes {
|
|
18
|
+
export interface EndpointTypes extends CampaignEndpointTypes, PaymentEndpointTypes, PollingEndpointTypes, InfobipEndpointTypes, VirusTotalEndpointTypes, CloudflareEndpointTypes, CloudFrontEndpointTypes, FastlyEndpointTypes, FeatureFlagEndpointTypes, FilesEndpointTypes, NotificationEndpointTypes {
|
|
18
19
|
}
|
package/dist/api/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export type * from './endpoints/health/types';
|
|
|
45
45
|
export type * from './endpoints/campaigns/types';
|
|
46
46
|
export type * from './endpoints/featureFlags';
|
|
47
47
|
export type * from './endpoints/files';
|
|
48
|
+
export type * from './endpoints/notification';
|
|
48
49
|
export type * from './endpoints/infobip/types';
|
|
49
50
|
export type * from './endpoints/virustotal/types';
|
|
50
51
|
export type * from './endpoints/cdn/types';
|
|
@@ -5,3 +5,4 @@
|
|
|
5
5
|
export type { EmptyDTO, CoreDeleteOptions, CoreBaseDomainServiceInterface, CoreEventSubscribable, CoreProviderSubscribable, CoreValidationResult, CoreValidatorConfig, CoreBaseValidatorInstance, CoreBaseMapperInstance, CoreBaseDomainServiceConfig, CoreBaseBackendServiceConfig, CoreMapperClass, CoreValidatorClass, CoreBaseServiceConfig, CoreInjectedServices, } from './types';
|
|
6
6
|
export type { CrudCacheOptions, CrudTransactionOptions, CrudOperationOptions, } from './crud';
|
|
7
7
|
export * from './files';
|
|
8
|
+
export * from './notifications';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notifications Domain Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for notifications domain.
|
|
5
|
+
*
|
|
6
|
+
* @module core/domain/notifications
|
|
7
|
+
*/
|
|
8
|
+
export type * from './types';
|
|
9
|
+
export * from './schemas';
|
|
10
|
+
export * from './streaming';
|
|
11
|
+
export type { NotificationStoreItem } from '../../../store/notifications';
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notifications Domain Schemas
|
|
3
|
+
*
|
|
4
|
+
* Zod validation schemas for notifications operations.
|
|
5
|
+
* Single source of truth - types are inferred from schemas.
|
|
6
|
+
*
|
|
7
|
+
* Used by:
|
|
8
|
+
* - NotificationsValidator in @plyaz/core for validation
|
|
9
|
+
* - NotificationsRepository for type safety
|
|
10
|
+
* - NotificationsMapper for transformations
|
|
11
|
+
*
|
|
12
|
+
* Note: Enum schemas are imported from @plyaz/types/notifications/schemas
|
|
13
|
+
* to avoid duplication. This file defines domain-specific schemas only.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
/**
|
|
17
|
+
* Notification type enum - matches notification_type DB ENUM
|
|
18
|
+
* Simplified for now - expand as needed
|
|
19
|
+
*/
|
|
20
|
+
export declare const NotificationTypeSchema: z.ZodEnum<{
|
|
21
|
+
SYSTEM: "SYSTEM";
|
|
22
|
+
CAMPAIGN_BACKED: "CAMPAIGN_BACKED";
|
|
23
|
+
}>;
|
|
24
|
+
export type NotificationTypeValue = z.infer<typeof NotificationTypeSchema>;
|
|
25
|
+
/**
|
|
26
|
+
* Notification channel enum - matches notification_channel DB ENUM
|
|
27
|
+
*/
|
|
28
|
+
export declare const NotificationChannelSchema: z.ZodEnum<{
|
|
29
|
+
IN_APP: "IN_APP";
|
|
30
|
+
EMAIL: "EMAIL";
|
|
31
|
+
SMS: "SMS";
|
|
32
|
+
PUSH: "PUSH";
|
|
33
|
+
}>;
|
|
34
|
+
export type NotificationChannelValue = z.infer<typeof NotificationChannelSchema>;
|
|
35
|
+
/**
|
|
36
|
+
* Notification status enum
|
|
37
|
+
*/
|
|
38
|
+
export declare const NotificationStatusSchema: z.ZodEnum<{
|
|
39
|
+
processing: "processing";
|
|
40
|
+
failed: "failed";
|
|
41
|
+
sent: "sent";
|
|
42
|
+
delivered: "delivered";
|
|
43
|
+
bounced: "bounced";
|
|
44
|
+
queued: "queued";
|
|
45
|
+
}>;
|
|
46
|
+
export type NotificationStatusValue = z.infer<typeof NotificationStatusSchema>;
|
|
47
|
+
/**
|
|
48
|
+
* Full notifications database row schema
|
|
49
|
+
* Matches migration 006_notifications_media.sql schema
|
|
50
|
+
*/
|
|
51
|
+
export declare const NotificationsDatabaseRowSchema: z.ZodObject<{
|
|
52
|
+
id: z.ZodString;
|
|
53
|
+
created_at: z.ZodString;
|
|
54
|
+
user_id: z.ZodString;
|
|
55
|
+
type: z.ZodEnum<{
|
|
56
|
+
SYSTEM: "SYSTEM";
|
|
57
|
+
CAMPAIGN_BACKED: "CAMPAIGN_BACKED";
|
|
58
|
+
}>;
|
|
59
|
+
title: z.ZodString;
|
|
60
|
+
message: z.ZodString;
|
|
61
|
+
recipient_id: z.ZodString;
|
|
62
|
+
link_url: z.ZodNullable<z.ZodString>;
|
|
63
|
+
reference_id: z.ZodNullable<z.ZodString>;
|
|
64
|
+
reference_type: z.ZodNullable<z.ZodString>;
|
|
65
|
+
correlation_id: z.ZodNullable<z.ZodString>;
|
|
66
|
+
template_id: z.ZodNullable<z.ZodString>;
|
|
67
|
+
channel: z.ZodNullable<z.ZodEnum<{
|
|
68
|
+
IN_APP: "IN_APP";
|
|
69
|
+
EMAIL: "EMAIL";
|
|
70
|
+
SMS: "SMS";
|
|
71
|
+
PUSH: "PUSH";
|
|
72
|
+
}>>;
|
|
73
|
+
category: z.ZodNullable<z.ZodDefault<z.ZodEnum<{
|
|
74
|
+
system: "system";
|
|
75
|
+
transactional: "transactional";
|
|
76
|
+
marketing: "marketing";
|
|
77
|
+
social: "social";
|
|
78
|
+
promotional: "promotional";
|
|
79
|
+
}>>>;
|
|
80
|
+
provider: z.ZodNullable<z.ZodString>;
|
|
81
|
+
provider_message_id: z.ZodNullable<z.ZodString>;
|
|
82
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
83
|
+
processing: "processing";
|
|
84
|
+
failed: "failed";
|
|
85
|
+
sent: "sent";
|
|
86
|
+
delivered: "delivered";
|
|
87
|
+
bounced: "bounced";
|
|
88
|
+
queued: "queued";
|
|
89
|
+
}>>;
|
|
90
|
+
sent_at: z.ZodNullable<z.ZodString>;
|
|
91
|
+
delivered_at: z.ZodNullable<z.ZodString>;
|
|
92
|
+
is_read: z.ZodDefault<z.ZodBoolean>;
|
|
93
|
+
read_at: z.ZodNullable<z.ZodString>;
|
|
94
|
+
error_message: z.ZodNullable<z.ZodString>;
|
|
95
|
+
retry_count: z.ZodDefault<z.ZodNumber>;
|
|
96
|
+
deleted_at: z.ZodNullable<z.ZodString>;
|
|
97
|
+
}, z.core.$strip>;
|
|
98
|
+
/**
|
|
99
|
+
* Database row type - inferred from schema
|
|
100
|
+
*/
|
|
101
|
+
export type NotificationsDatabaseRow = z.infer<typeof NotificationsDatabaseRowSchema>;
|
|
102
|
+
/**
|
|
103
|
+
* Delete Notifications Schema
|
|
104
|
+
* Validates delete params (id)
|
|
105
|
+
*/
|
|
106
|
+
export declare const DeleteNotificationsSchema: z.ZodObject<{
|
|
107
|
+
id: z.ZodOptional<z.ZodString>;
|
|
108
|
+
soft: z.ZodOptional<z.ZodBoolean>;
|
|
109
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
export type DeleteNotificationsDTO = z.infer<typeof DeleteNotificationsSchema>;
|
|
112
|
+
/**
|
|
113
|
+
* Query Notifications Schema
|
|
114
|
+
* GET /notifications filters
|
|
115
|
+
*/
|
|
116
|
+
export declare const QueryNotificationsSchema: z.ZodObject<{
|
|
117
|
+
page: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
118
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
119
|
+
offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
120
|
+
sort_by: z.ZodOptional<z.ZodEnum<{
|
|
121
|
+
created_at: "created_at";
|
|
122
|
+
sent_at: "sent_at";
|
|
123
|
+
delivered_at: "delivered_at";
|
|
124
|
+
}>>;
|
|
125
|
+
sort_order: z.ZodOptional<z.ZodEnum<{
|
|
126
|
+
asc: "asc";
|
|
127
|
+
desc: "desc";
|
|
128
|
+
}>>;
|
|
129
|
+
user_id: z.ZodOptional<z.ZodString>;
|
|
130
|
+
channel: z.ZodOptional<z.ZodEnum<{
|
|
131
|
+
IN_APP: "IN_APP";
|
|
132
|
+
EMAIL: "EMAIL";
|
|
133
|
+
SMS: "SMS";
|
|
134
|
+
PUSH: "PUSH";
|
|
135
|
+
}>>;
|
|
136
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
137
|
+
processing: "processing";
|
|
138
|
+
failed: "failed";
|
|
139
|
+
sent: "sent";
|
|
140
|
+
delivered: "delivered";
|
|
141
|
+
bounced: "bounced";
|
|
142
|
+
queued: "queued";
|
|
143
|
+
}>>;
|
|
144
|
+
category: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
145
|
+
system: "system";
|
|
146
|
+
transactional: "transactional";
|
|
147
|
+
marketing: "marketing";
|
|
148
|
+
social: "social";
|
|
149
|
+
promotional: "promotional";
|
|
150
|
+
}>>>;
|
|
151
|
+
template_id: z.ZodOptional<z.ZodString>;
|
|
152
|
+
recipient_id: z.ZodOptional<z.ZodString>;
|
|
153
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
154
|
+
SYSTEM: "SYSTEM";
|
|
155
|
+
CAMPAIGN_BACKED: "CAMPAIGN_BACKED";
|
|
156
|
+
}>>;
|
|
157
|
+
is_read: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
158
|
+
created_after: z.ZodOptional<z.ZodString>;
|
|
159
|
+
created_before: z.ZodOptional<z.ZodString>;
|
|
160
|
+
}, z.core.$strip>;
|
|
161
|
+
export type QueryNotificationsDTO = z.input<typeof QueryNotificationsSchema>;
|
|
162
|
+
/**
|
|
163
|
+
* Create Notifications Schema (for backend)
|
|
164
|
+
*/
|
|
165
|
+
export declare const CreateNotificationsSchema: z.ZodObject<{
|
|
166
|
+
user_id: z.ZodString;
|
|
167
|
+
type: z.ZodEnum<{
|
|
168
|
+
SYSTEM: "SYSTEM";
|
|
169
|
+
CAMPAIGN_BACKED: "CAMPAIGN_BACKED";
|
|
170
|
+
}>;
|
|
171
|
+
title: z.ZodString;
|
|
172
|
+
message: z.ZodString;
|
|
173
|
+
link_url: z.ZodOptional<z.ZodString>;
|
|
174
|
+
reference_id: z.ZodOptional<z.ZodString>;
|
|
175
|
+
reference_type: z.ZodOptional<z.ZodString>;
|
|
176
|
+
correlation_id: z.ZodOptional<z.ZodString>;
|
|
177
|
+
recipient_id: z.ZodString;
|
|
178
|
+
template_id: z.ZodOptional<z.ZodString>;
|
|
179
|
+
channel: z.ZodOptional<z.ZodEnum<{
|
|
180
|
+
IN_APP: "IN_APP";
|
|
181
|
+
EMAIL: "EMAIL";
|
|
182
|
+
SMS: "SMS";
|
|
183
|
+
PUSH: "PUSH";
|
|
184
|
+
}>>;
|
|
185
|
+
category: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
186
|
+
system: "system";
|
|
187
|
+
transactional: "transactional";
|
|
188
|
+
marketing: "marketing";
|
|
189
|
+
social: "social";
|
|
190
|
+
promotional: "promotional";
|
|
191
|
+
}>>>;
|
|
192
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
193
|
+
provider_message_id: z.ZodOptional<z.ZodString>;
|
|
194
|
+
}, z.core.$strip>;
|
|
195
|
+
export type CreateNotificationsDTO = z.infer<typeof CreateNotificationsSchema>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notifications Domain Streaming Types
|
|
3
|
+
*
|
|
4
|
+
* Stream message types for IN_APP notification delivery.
|
|
5
|
+
* Only supports notification:created - user receives new notifications in real-time.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: Only IN_APP notifications are supported for streaming.
|
|
8
|
+
* Email, SMS, and Push notifications are backend-only operations via @plyaz/notifications.
|
|
9
|
+
*
|
|
10
|
+
* Flow:
|
|
11
|
+
* 1. Backend creates notification with user_id
|
|
12
|
+
* 2. Backend emits notification:created event
|
|
13
|
+
* 3. Channel controller broadcasts to user:notifications:{userId}
|
|
14
|
+
* 4. User's connected clients receive the notification
|
|
15
|
+
*/
|
|
16
|
+
import type { NotificationStatus, NotificationCategory } from '../../../notifications';
|
|
17
|
+
/**
|
|
18
|
+
* SSE/WebSocket event names for notifications domain.
|
|
19
|
+
* Only notification:created is needed - user receives new notifications.
|
|
20
|
+
*/
|
|
21
|
+
export declare const NOTIFICATIONS_STREAM_EVENT: {
|
|
22
|
+
/** New notification created for user */
|
|
23
|
+
readonly NOTIFICATION_CREATED: "notification:created";
|
|
24
|
+
};
|
|
25
|
+
export type NotificationsStreamEventName = (typeof NOTIFICATIONS_STREAM_EVENT)[keyof typeof NOTIFICATIONS_STREAM_EVENT];
|
|
26
|
+
/**
|
|
27
|
+
* Channel prefixes for notifications domain subscriptions.
|
|
28
|
+
*/
|
|
29
|
+
export declare const NOTIFICATIONS_STREAM_CHANNEL_PREFIX: {
|
|
30
|
+
/** Per-user channel - user subscribes to receive their notifications */
|
|
31
|
+
readonly USER: "user:notifications:";
|
|
32
|
+
};
|
|
33
|
+
export type NotificationsStreamChannelPrefix = (typeof NOTIFICATIONS_STREAM_CHANNEL_PREFIX)[keyof typeof NOTIFICATIONS_STREAM_CHANNEL_PREFIX];
|
|
34
|
+
/**
|
|
35
|
+
* Broadcast channels for notifications domain.
|
|
36
|
+
*/
|
|
37
|
+
export declare const NOTIFICATIONS_STREAM_BROADCAST_CHANNEL: {
|
|
38
|
+
/** All notifications broadcast (admin/debug) */
|
|
39
|
+
readonly ALL_NOTIFICATIONS: "notifications";
|
|
40
|
+
};
|
|
41
|
+
export type NotificationsStreamBroadcastChannel = (typeof NOTIFICATIONS_STREAM_BROADCAST_CHANNEL)[keyof typeof NOTIFICATIONS_STREAM_BROADCAST_CHANNEL];
|
|
42
|
+
/**
|
|
43
|
+
* All notifications stream channels.
|
|
44
|
+
*/
|
|
45
|
+
export declare const NOTIFICATIONS_STREAM_CHANNEL: {
|
|
46
|
+
readonly PREFIX: {
|
|
47
|
+
/** Per-user channel - user subscribes to receive their notifications */
|
|
48
|
+
readonly USER: "user:notifications:";
|
|
49
|
+
};
|
|
50
|
+
readonly BROADCAST: {
|
|
51
|
+
/** All notifications broadcast (admin/debug) */
|
|
52
|
+
readonly ALL_NOTIFICATIONS: "notifications";
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Channel patterns for notifications domain subscriptions.
|
|
57
|
+
*
|
|
58
|
+
* - `user:notifications:{userId}` - User subscribes to receive their notifications
|
|
59
|
+
* - `notifications` - Broadcast channel (admin/debug)
|
|
60
|
+
*/
|
|
61
|
+
export type NotificationsStreamChannel = `user:notifications:${string}` | NotificationsStreamBroadcastChannel;
|
|
62
|
+
/**
|
|
63
|
+
* Notification created event data.
|
|
64
|
+
* Contains all info needed to display the notification to the user.
|
|
65
|
+
*
|
|
66
|
+
* IMPORTANT: userId is required for routing to the correct user's channel.
|
|
67
|
+
*/
|
|
68
|
+
export interface NotificationCreatedStreamData {
|
|
69
|
+
/** Notification ID */
|
|
70
|
+
notificationId: string;
|
|
71
|
+
/** User ID - REQUIRED for routing to correct user */
|
|
72
|
+
userId: string;
|
|
73
|
+
/** Notification type (system, alert, info, etc.) */
|
|
74
|
+
type: string;
|
|
75
|
+
/** Notification title */
|
|
76
|
+
title: string;
|
|
77
|
+
/** Notification message/body */
|
|
78
|
+
message: string;
|
|
79
|
+
/** Link URL for action */
|
|
80
|
+
linkUrl?: string;
|
|
81
|
+
/** Reference ID (e.g., order ID, campaign ID) */
|
|
82
|
+
referenceId?: string;
|
|
83
|
+
/** Reference type (e.g., 'order', 'campaign') */
|
|
84
|
+
referenceType?: string;
|
|
85
|
+
/** Notification category */
|
|
86
|
+
category: NotificationCategory;
|
|
87
|
+
/** Current status */
|
|
88
|
+
status: NotificationStatus;
|
|
89
|
+
/** When the notification was created */
|
|
90
|
+
createdAt: string;
|
|
91
|
+
/** Timestamp of the stream event */
|
|
92
|
+
timestamp?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Union of all notifications stream data types.
|
|
96
|
+
*/
|
|
97
|
+
export type NotificationsStreamData = NotificationCreatedStreamData;
|