@solytude/listmonk 1.0.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/LICENSE +21 -0
- package/README.md +542 -0
- package/dist/chunk-saezhne8.js +14 -0
- package/dist/chunk-saezhne8.js.map +9 -0
- package/dist/client.d.ts +430 -0
- package/dist/errors/api.d.ts +178 -0
- package/dist/errors/base.d.ts +47 -0
- package/dist/errors/configuration.d.ts +49 -0
- package/dist/errors/index.d.ts +13 -0
- package/dist/errors/network.d.ts +69 -0
- package/dist/errors/validation.d.ts +57 -0
- package/dist/http/auth.d.ts +39 -0
- package/dist/http/client.d.ts +149 -0
- package/dist/http/hooks.d.ts +90 -0
- package/dist/http/index.d.ts +10 -0
- package/dist/http/resource.d.ts +100 -0
- package/dist/http/sse.d.ts +36 -0
- package/dist/http/url.d.ts +51 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +16039 -0
- package/dist/index.js.map +120 -0
- package/dist/resources/admin/admin.d.ts +92 -0
- package/dist/resources/admin/index.d.ts +10 -0
- package/dist/resources/admin/schemas.d.ts +23 -0
- package/dist/resources/admin/types.d.ts +29 -0
- package/dist/resources/bounces/bounces.d.ts +262 -0
- package/dist/resources/bounces/index.d.ts +10 -0
- package/dist/resources/bounces/schemas.d.ts +86 -0
- package/dist/resources/bounces/types.d.ts +37 -0
- package/dist/resources/campaigns/campaigns.d.ts +339 -0
- package/dist/resources/campaigns/index.d.ts +10 -0
- package/dist/resources/campaigns/schemas.d.ts +374 -0
- package/dist/resources/campaigns/types.d.ts +111 -0
- package/dist/resources/dashboard/dashboard.d.ts +73 -0
- package/dist/resources/dashboard/index.d.ts +10 -0
- package/dist/resources/dashboard/schemas.d.ts +55 -0
- package/dist/resources/dashboard/types.d.ts +22 -0
- package/dist/resources/import/import.d.ts +215 -0
- package/dist/resources/import/index.d.ts +10 -0
- package/dist/resources/import/schemas.d.ts +109 -0
- package/dist/resources/import/types.d.ts +72 -0
- package/dist/resources/lists/index.d.ts +10 -0
- package/dist/resources/lists/lists.d.ts +180 -0
- package/dist/resources/lists/schemas.d.ts +176 -0
- package/dist/resources/lists/types.d.ts +56 -0
- package/dist/resources/maintenance/index.d.ts +10 -0
- package/dist/resources/maintenance/maintenance.d.ts +92 -0
- package/dist/resources/maintenance/schemas.d.ts +36 -0
- package/dist/resources/maintenance/types.d.ts +31 -0
- package/dist/resources/media/index.d.ts +10 -0
- package/dist/resources/media/media.d.ts +198 -0
- package/dist/resources/media/schemas.d.ts +48 -0
- package/dist/resources/media/types.d.ts +48 -0
- package/dist/resources/public/index.d.ts +10 -0
- package/dist/resources/public/public.d.ts +111 -0
- package/dist/resources/public/schemas.d.ts +52 -0
- package/dist/resources/public/types.d.ts +30 -0
- package/dist/resources/settings/index.d.ts +10 -0
- package/dist/resources/settings/schemas.d.ts +374 -0
- package/dist/resources/settings/settings.d.ts +106 -0
- package/dist/resources/settings/types.d.ts +78 -0
- package/dist/resources/subscribers/index.d.ts +10 -0
- package/dist/resources/subscribers/schemas.d.ts +360 -0
- package/dist/resources/subscribers/subscribers.d.ts +308 -0
- package/dist/resources/subscribers/types.d.ts +113 -0
- package/dist/resources/templates/index.d.ts +10 -0
- package/dist/resources/templates/schemas.d.ts +110 -0
- package/dist/resources/templates/templates.d.ts +225 -0
- package/dist/resources/templates/types.d.ts +45 -0
- package/dist/resources/tx/index.d.ts +10 -0
- package/dist/resources/tx/schemas.d.ts +67 -0
- package/dist/resources/tx/tx.d.ts +167 -0
- package/dist/resources/tx/types.d.ts +88 -0
- package/dist/schemas/common.d.ts +48 -0
- package/dist/schemas/index.d.ts +6 -0
- package/dist/testing/errors.d.ts +25 -0
- package/dist/testing/factories/bounce.d.ts +43 -0
- package/dist/testing/factories/campaign.d.ts +43 -0
- package/dist/testing/factories/common.d.ts +54 -0
- package/dist/testing/factories/index.d.ts +12 -0
- package/dist/testing/factories/list.d.ts +43 -0
- package/dist/testing/factories/media.d.ts +40 -0
- package/dist/testing/factories/subscriber.d.ts +43 -0
- package/dist/testing/factories/template.d.ts +40 -0
- package/dist/testing/index.d.ts +39 -0
- package/dist/testing/index.js +573 -0
- package/dist/testing/index.js.map +32 -0
- package/dist/testing/mock-client.d.ts +119 -0
- package/dist/testing/mock-function.d.ts +28 -0
- package/dist/testing/resources/admin.d.ts +20 -0
- package/dist/testing/resources/bounces.d.ts +22 -0
- package/dist/testing/resources/campaigns.d.ts +31 -0
- package/dist/testing/resources/dashboard.d.ts +17 -0
- package/dist/testing/resources/import.d.ts +19 -0
- package/dist/testing/resources/index.d.ts +18 -0
- package/dist/testing/resources/lists.d.ts +24 -0
- package/dist/testing/resources/maintenance.d.ts +18 -0
- package/dist/testing/resources/media.d.ts +21 -0
- package/dist/testing/resources/public.d.ts +18 -0
- package/dist/testing/resources/settings.d.ts +19 -0
- package/dist/testing/resources/subscribers.d.ts +33 -0
- package/dist/testing/resources/templates.d.ts +24 -0
- package/dist/testing/resources/tx.d.ts +16 -0
- package/dist/testing/types.d.ts +138 -0
- package/dist/types/config.d.ts +59 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/pagination.d.ts +37 -0
- package/package.json +97 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin resource for server administration.
|
|
3
|
+
*
|
|
4
|
+
* @module resources/admin
|
|
5
|
+
*/
|
|
6
|
+
import { APIResource } from "../../http/resource";
|
|
7
|
+
import type { ReloadResponse, LogsResponse, SSEEvent, SSEStreamOptions } from "./types";
|
|
8
|
+
/**
|
|
9
|
+
* Resource for administrative operations on the listmonk server.
|
|
10
|
+
*
|
|
11
|
+
* Provides methods for application reload, log retrieval, and
|
|
12
|
+
* real-time event streaming via SSE.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // Reload application
|
|
17
|
+
* await client.admin.reload();
|
|
18
|
+
*
|
|
19
|
+
* // Get logs
|
|
20
|
+
* const logs = await client.admin.getLogs();
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class AdminResource extends APIResource {
|
|
24
|
+
/**
|
|
25
|
+
* Triggers an application reload.
|
|
26
|
+
*
|
|
27
|
+
* Sends a SIGHUP signal to the server after a 500ms delay
|
|
28
|
+
* for a graceful restart. The server may be briefly unavailable.
|
|
29
|
+
*
|
|
30
|
+
* @returns `true` on success
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* await client.admin.reload();
|
|
35
|
+
* console.log('Application reload triggered');
|
|
36
|
+
* // Note: Server may be briefly unavailable
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
reload(): Promise<ReloadResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves application logs.
|
|
42
|
+
*
|
|
43
|
+
* Returns up to 5000 most recent log lines.
|
|
44
|
+
*
|
|
45
|
+
* @returns Array of log lines
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const logs = await client.admin.getLogs();
|
|
50
|
+
*
|
|
51
|
+
* // Print last 10 lines
|
|
52
|
+
* for (const line of logs.slice(-10)) {
|
|
53
|
+
* console.log(line);
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
getLogs(): Promise<LogsResponse>;
|
|
58
|
+
/**
|
|
59
|
+
* Opens a Server-Sent Events stream for real-time server events.
|
|
60
|
+
*
|
|
61
|
+
* Returns an async generator that yields events as they arrive.
|
|
62
|
+
* The stream stays open indefinitely until cancelled.
|
|
63
|
+
*
|
|
64
|
+
* Note: Listmonk's SSE does not support Last-Event-ID for reconnection.
|
|
65
|
+
* Events lost during disconnection cannot be recovered.
|
|
66
|
+
*
|
|
67
|
+
* @param options - Stream options
|
|
68
|
+
* @param options.signal - AbortSignal for cancellation
|
|
69
|
+
* @yields SSE events from the server
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* // Stop after 60 seconds using AbortSignal.timeout() (Node 17.3+)
|
|
74
|
+
* try {
|
|
75
|
+
* for await (const event of client.admin.getEventStream({
|
|
76
|
+
* signal: AbortSignal.timeout(60_000),
|
|
77
|
+
* })) {
|
|
78
|
+
* console.log(`Event: ${event.type}`);
|
|
79
|
+
* console.log(`Message: ${event.message}`);
|
|
80
|
+
* console.log(`Data:`, event.data);
|
|
81
|
+
* }
|
|
82
|
+
* } catch (error) {
|
|
83
|
+
* if (error.name === 'TimeoutError') {
|
|
84
|
+
* console.log('Stream closed after timeout');
|
|
85
|
+
* } else {
|
|
86
|
+
* throw error;
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
getEventStream(options?: SSEStreamOptions): AsyncGenerator<SSEEvent, void, undefined>;
|
|
92
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin resource module.
|
|
3
|
+
*
|
|
4
|
+
* Provides administrative operations for the listmonk API.
|
|
5
|
+
*
|
|
6
|
+
* @module resources/admin
|
|
7
|
+
*/
|
|
8
|
+
export { AdminResource } from "./admin";
|
|
9
|
+
export type { ReloadResponse, LogsResponse, SSEEvent, SSEStreamOptions, } from "./types";
|
|
10
|
+
export { ReloadResponseSchema, LogsResponseSchema, SSEEventSchema, } from "./schemas";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for admin-related requests and responses.
|
|
3
|
+
*
|
|
4
|
+
* @module resources/admin/schemas
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
/**
|
|
8
|
+
* Application reload response.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ReloadResponseSchema: z.ZodLiteral<true>;
|
|
11
|
+
/**
|
|
12
|
+
* Application logs response (array of log lines).
|
|
13
|
+
*/
|
|
14
|
+
export declare const LogsResponseSchema: z.ZodArray<z.ZodString>;
|
|
15
|
+
/**
|
|
16
|
+
* Server-sent event structure.
|
|
17
|
+
*/
|
|
18
|
+
export declare const SSEEventSchema: z.ZodObject<{
|
|
19
|
+
id: z.ZodOptional<z.ZodString>;
|
|
20
|
+
type: z.ZodString;
|
|
21
|
+
message: z.ZodString;
|
|
22
|
+
data: z.ZodUnknown;
|
|
23
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript types for admin module.
|
|
3
|
+
*
|
|
4
|
+
* All types are inferred from Zod schemas to ensure runtime
|
|
5
|
+
* validation matches compile-time types.
|
|
6
|
+
*
|
|
7
|
+
* @module resources/admin/types
|
|
8
|
+
*/
|
|
9
|
+
import type { z } from "zod";
|
|
10
|
+
import type { ReloadResponseSchema, LogsResponseSchema, SSEEventSchema } from "./schemas";
|
|
11
|
+
/**
|
|
12
|
+
* Application reload response.
|
|
13
|
+
*/
|
|
14
|
+
export type ReloadResponse = z.infer<typeof ReloadResponseSchema>;
|
|
15
|
+
/**
|
|
16
|
+
* Application logs response.
|
|
17
|
+
*/
|
|
18
|
+
export type LogsResponse = z.infer<typeof LogsResponseSchema>;
|
|
19
|
+
/**
|
|
20
|
+
* Server-sent event structure.
|
|
21
|
+
*/
|
|
22
|
+
export type SSEEvent = z.infer<typeof SSEEventSchema>;
|
|
23
|
+
/**
|
|
24
|
+
* Options for SSE event stream.
|
|
25
|
+
*/
|
|
26
|
+
export interface SSEStreamOptions {
|
|
27
|
+
/** AbortSignal for cancellation */
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounces resource for managing email bounce records.
|
|
3
|
+
*
|
|
4
|
+
* @module resources/bounces
|
|
5
|
+
*/
|
|
6
|
+
import { APIResource } from "../../http/resource";
|
|
7
|
+
import type { Bounce, ListBouncesOptions, ListBouncesResponse } from "./types";
|
|
8
|
+
import type { PagedAsyncIterableIterator } from "../../types/pagination";
|
|
9
|
+
/**
|
|
10
|
+
* Resource for managing email bounce records in listmonk.
|
|
11
|
+
*
|
|
12
|
+
* Provides methods for listing, retrieving, and deleting bounce records,
|
|
13
|
+
* as well as blocklisting bounced subscribers.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // List bounces with filtering
|
|
18
|
+
* const bounces = await client.bounces.list({
|
|
19
|
+
* campaign_id: 5,
|
|
20
|
+
* order_by: 'created_at',
|
|
21
|
+
* order: 'desc',
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Iterate all bounces
|
|
25
|
+
* for await (const bounce of client.bounces.listAll()) {
|
|
26
|
+
* if (bounce.type === 'hard') {
|
|
27
|
+
* console.log(`Hard bounce: ${bounce.email}`);
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* // Delete a specific bounce
|
|
32
|
+
* await client.bounces.remove(123);
|
|
33
|
+
*
|
|
34
|
+
* // Blocklist all bounced subscribers
|
|
35
|
+
* await client.bounces.blocklistBounced();
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare class BouncesResource extends APIResource {
|
|
39
|
+
/**
|
|
40
|
+
* Lists bounce records with optional filtering and pagination.
|
|
41
|
+
*
|
|
42
|
+
* Returns a paginated response containing bounce records. Use filtering
|
|
43
|
+
* options to narrow results by campaign or source.
|
|
44
|
+
*
|
|
45
|
+
* @param options - Query options for filtering and pagination
|
|
46
|
+
* @returns Paginated response with bounce records
|
|
47
|
+
*
|
|
48
|
+
* @example Basic listing
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const response = await client.bounces.list();
|
|
51
|
+
* console.log(`Total bounces: ${response.total}`);
|
|
52
|
+
* for (const bounce of response.results) {
|
|
53
|
+
* console.log(`${bounce.email}: ${bounce.type}`);
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @example Filter by campaign
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const campaignBounces = await client.bounces.list({
|
|
60
|
+
* campaign_id: 5,
|
|
61
|
+
* per_page: 100,
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @example Filter by source with sorting
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const sesBounces = await client.bounces.list({
|
|
68
|
+
* source: 'ses',
|
|
69
|
+
* order_by: 'created_at',
|
|
70
|
+
* order: 'desc',
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @example Pagination
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const page2 = await client.bounces.list({
|
|
77
|
+
* page: 2,
|
|
78
|
+
* per_page: 25,
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
list(options?: ListBouncesOptions): Promise<ListBouncesResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* Returns an async iterator over all bounce records matching the options.
|
|
85
|
+
*
|
|
86
|
+
* Pages are fetched on-demand as you iterate. The iterator also
|
|
87
|
+
* provides a `byPage()` method for page-level iteration.
|
|
88
|
+
*
|
|
89
|
+
* @param options - Query options (page is ignored, starts from 1)
|
|
90
|
+
* @returns Async iterator over bounce records
|
|
91
|
+
*
|
|
92
|
+
* @example Iterate over all bounces
|
|
93
|
+
* ```typescript
|
|
94
|
+
* for await (const bounce of client.bounces.listAll()) {
|
|
95
|
+
* console.log(`Processing: ${bounce.email}`);
|
|
96
|
+
* if (bounce.type === 'hard') {
|
|
97
|
+
* // Handle hard bounces
|
|
98
|
+
* }
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @example Iterate by page
|
|
103
|
+
* ```typescript
|
|
104
|
+
* for await (const page of client.bounces.listAll().byPage()) {
|
|
105
|
+
* console.log(`Page ${page.page}: ${page.results.length} bounces`);
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @example With filtering
|
|
110
|
+
* ```typescript
|
|
111
|
+
* // All SES bounces, ordered by date
|
|
112
|
+
* for await (const bounce of client.bounces.listAll({
|
|
113
|
+
* source: 'ses',
|
|
114
|
+
* order_by: 'created_at',
|
|
115
|
+
* order: 'desc',
|
|
116
|
+
* })) {
|
|
117
|
+
* console.log(bounce.email, bounce.created_at);
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @example Collect into array
|
|
122
|
+
* ```typescript
|
|
123
|
+
* const allBounces: Bounce[] = [];
|
|
124
|
+
* for await (const bounce of client.bounces.listAll()) {
|
|
125
|
+
* allBounces.push(bounce);
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
listAll(options?: Omit<ListBouncesOptions, "page">): PagedAsyncIterableIterator<Bounce, ListBouncesResponse>;
|
|
130
|
+
/**
|
|
131
|
+
* Deletes a single bounce record by ID.
|
|
132
|
+
*
|
|
133
|
+
* @param id - Bounce record ID
|
|
134
|
+
* @returns `true` on successful deletion
|
|
135
|
+
* @throws {ListmonkNotFoundError} If bounce record not found
|
|
136
|
+
* @throws {ListmonkValidationError} If ID is not a positive integer
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* const deleted = await client.bounces.remove(123);
|
|
141
|
+
* console.log(`Deleted: ${deleted}`); // true
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
remove(id: number): Promise<boolean>;
|
|
145
|
+
/**
|
|
146
|
+
* Deletes multiple bounce records by ID.
|
|
147
|
+
*
|
|
148
|
+
* All specified bounce records are deleted in a single API call.
|
|
149
|
+
*
|
|
150
|
+
* @param ids - Array of bounce record IDs to delete
|
|
151
|
+
* @returns `true` on successful deletion
|
|
152
|
+
* @throws {ListmonkValidationError} If ids is empty or contains invalid values
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* const deleted = await client.bounces.deleteMany([1, 2, 3, 4, 5]);
|
|
157
|
+
* console.log(`Deleted: ${deleted}`); // true
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @example With IDs from listing
|
|
161
|
+
* ```typescript
|
|
162
|
+
* // Get old bounces
|
|
163
|
+
* const oldBounceIds: number[] = [];
|
|
164
|
+
* for await (const bounce of client.bounces.listAll()) {
|
|
165
|
+
* const bounceDate = new Date(bounce.created_at);
|
|
166
|
+
* if (bounceDate < cutoffDate) {
|
|
167
|
+
* oldBounceIds.push(bounce.id);
|
|
168
|
+
* }
|
|
169
|
+
* }
|
|
170
|
+
*
|
|
171
|
+
* // Delete in batches
|
|
172
|
+
* const batchSize = 100;
|
|
173
|
+
* for (let i = 0; i < oldBounceIds.length; i += batchSize) {
|
|
174
|
+
* const batch = oldBounceIds.slice(i, i + batchSize);
|
|
175
|
+
* await client.bounces.deleteMany(batch);
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
deleteMany(ids: number[]): Promise<boolean>;
|
|
180
|
+
/**
|
|
181
|
+
* Deletes all bounce records.
|
|
182
|
+
*
|
|
183
|
+
* **Warning**: This operation cannot be undone. Use with caution.
|
|
184
|
+
*
|
|
185
|
+
* @returns `true` on successful deletion
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* // Delete all bounce records
|
|
190
|
+
* const deleted = await client.bounces.deleteAll();
|
|
191
|
+
* console.log(`All bounces deleted: ${deleted}`); // true
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
deleteAll(): Promise<boolean>;
|
|
195
|
+
/**
|
|
196
|
+
* Retrieves a single bounce record by ID.
|
|
197
|
+
*
|
|
198
|
+
* @param id - Bounce record ID
|
|
199
|
+
* @returns The bounce record
|
|
200
|
+
* @throws {ListmonkNotFoundError} If bounce record not found
|
|
201
|
+
* @throws {ListmonkValidationError} If ID is not a positive integer
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* const bounce = await client.bounces.retrieve(123);
|
|
206
|
+
*
|
|
207
|
+
* console.log(`Bounce ID: ${bounce.id}`);
|
|
208
|
+
* console.log(`Type: ${bounce.type}`);
|
|
209
|
+
* console.log(`Email: ${bounce.email}`);
|
|
210
|
+
* console.log(`Source: ${bounce.source}`);
|
|
211
|
+
* console.log(`Subscriber ID: ${bounce.subscriber_id}`);
|
|
212
|
+
*
|
|
213
|
+
* // Access provider-specific metadata
|
|
214
|
+
* if (bounce.meta) {
|
|
215
|
+
* console.log('Metadata:', bounce.meta);
|
|
216
|
+
* // AWS SES: bounce.meta.bounceType, bounce.meta.bounceSubType
|
|
217
|
+
* }
|
|
218
|
+
*
|
|
219
|
+
* // Check campaign association
|
|
220
|
+
* if (bounce.campaign) {
|
|
221
|
+
* console.log(`Campaign: ${bounce.campaign.name}`);
|
|
222
|
+
* }
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
retrieve(id: number): Promise<Bounce>;
|
|
226
|
+
/**
|
|
227
|
+
* Blocklists all subscribers who have bounced.
|
|
228
|
+
*
|
|
229
|
+
* This operation adds all subscribers with any bounce record to the
|
|
230
|
+
* blocklist. It is an all-or-nothing operation with no filtering options.
|
|
231
|
+
*
|
|
232
|
+
* The operation is idempotent - running it multiple times has no
|
|
233
|
+
* additional effect if no new bounces have occurred.
|
|
234
|
+
*
|
|
235
|
+
* @returns `true` on successful operation
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* // Blocklist all bounced subscribers
|
|
240
|
+
* const success = await client.bounces.blocklistBounced();
|
|
241
|
+
* console.log(`Blocklisted: ${success}`); // true
|
|
242
|
+
* ```
|
|
243
|
+
*
|
|
244
|
+
* @example Maintenance workflow
|
|
245
|
+
* ```typescript
|
|
246
|
+
* // 1. Review bounces first
|
|
247
|
+
* const response = await client.bounces.list({
|
|
248
|
+
* order_by: 'created_at',
|
|
249
|
+
* order: 'desc',
|
|
250
|
+
* per_page: 100,
|
|
251
|
+
* });
|
|
252
|
+
* console.log(`Found ${response.total} bounce records`);
|
|
253
|
+
*
|
|
254
|
+
* // 2. Blocklist all bounced subscribers
|
|
255
|
+
* await client.bounces.blocklistBounced();
|
|
256
|
+
*
|
|
257
|
+
* // 3. Optionally clean up bounce records
|
|
258
|
+
* await client.bounces.deleteAll();
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
blocklistBounced(): Promise<boolean>;
|
|
262
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounces resource module.
|
|
3
|
+
*
|
|
4
|
+
* Provides bounce record management for the listmonk API.
|
|
5
|
+
*
|
|
6
|
+
* @module resources/bounces
|
|
7
|
+
*/
|
|
8
|
+
export { BouncesResource } from "./bounces";
|
|
9
|
+
export type { Bounce, BounceType, BounceCampaign, ListBouncesOptions, ListBouncesResponse, } from "./types";
|
|
10
|
+
export { BounceSchema, BounceTypeSchema, BounceCampaignSchema, ListBouncesOptionsSchema, ListBouncesResponseSchema, BulkDeleteIdsSchema, PositiveIdSchema, DeleteResponseSchema, } from "./schemas";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for bounce-related requests and responses.
|
|
3
|
+
*
|
|
4
|
+
* @module resources/bounces/schemas
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
export { BounceTypeSchema, BounceCampaignSchema } from "../../schemas";
|
|
8
|
+
/**
|
|
9
|
+
* Complete bounce entity returned from API.
|
|
10
|
+
*
|
|
11
|
+
* Represents an email delivery failure record with metadata.
|
|
12
|
+
*/
|
|
13
|
+
export declare const BounceSchema: z.ZodObject<{
|
|
14
|
+
id: z.ZodNumber;
|
|
15
|
+
type: z.ZodEnum<{
|
|
16
|
+
hard: "hard";
|
|
17
|
+
soft: "soft";
|
|
18
|
+
}>;
|
|
19
|
+
source: z.ZodString;
|
|
20
|
+
meta: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
21
|
+
created_at: z.ZodString;
|
|
22
|
+
email: z.ZodString;
|
|
23
|
+
subscriber_uuid: z.ZodString;
|
|
24
|
+
subscriber_id: z.ZodNumber;
|
|
25
|
+
campaign: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
26
|
+
id: z.ZodNumber;
|
|
27
|
+
name: z.ZodString;
|
|
28
|
+
}, z.core.$strip>>>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
/**
|
|
31
|
+
* Valid fields for sorting bounce records.
|
|
32
|
+
*/
|
|
33
|
+
export declare const BounceOrderBySchema: z.ZodEnum<{
|
|
34
|
+
type: "type";
|
|
35
|
+
created_at: "created_at";
|
|
36
|
+
email: "email";
|
|
37
|
+
source: "source";
|
|
38
|
+
campaign_name: "campaign_name";
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Query parameters for listing bounce records.
|
|
42
|
+
*/
|
|
43
|
+
export declare const ListBouncesOptionsSchema: z.ZodObject<{
|
|
44
|
+
page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
45
|
+
per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
46
|
+
campaign_id: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
source: z.ZodOptional<z.ZodString>;
|
|
48
|
+
order_by: z.ZodOptional<z.ZodEnum<{
|
|
49
|
+
type: "type";
|
|
50
|
+
created_at: "created_at";
|
|
51
|
+
email: "email";
|
|
52
|
+
source: "source";
|
|
53
|
+
campaign_name: "campaign_name";
|
|
54
|
+
}>>;
|
|
55
|
+
order: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
asc: "asc";
|
|
57
|
+
desc: "desc";
|
|
58
|
+
}>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
/**
|
|
61
|
+
* Paginated response for bounce listing.
|
|
62
|
+
*/
|
|
63
|
+
export declare const ListBouncesResponseSchema: z.ZodObject<{
|
|
64
|
+
results: z.ZodArray<z.ZodObject<{
|
|
65
|
+
id: z.ZodNumber;
|
|
66
|
+
type: z.ZodEnum<{
|
|
67
|
+
hard: "hard";
|
|
68
|
+
soft: "soft";
|
|
69
|
+
}>;
|
|
70
|
+
source: z.ZodString;
|
|
71
|
+
meta: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
72
|
+
created_at: z.ZodString;
|
|
73
|
+
email: z.ZodString;
|
|
74
|
+
subscriber_uuid: z.ZodString;
|
|
75
|
+
subscriber_id: z.ZodNumber;
|
|
76
|
+
campaign: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
77
|
+
id: z.ZodNumber;
|
|
78
|
+
name: z.ZodString;
|
|
79
|
+
}, z.core.$strip>>>;
|
|
80
|
+
}, z.core.$strip>>;
|
|
81
|
+
query: z.ZodString;
|
|
82
|
+
total: z.ZodNumber;
|
|
83
|
+
per_page: z.ZodNumber;
|
|
84
|
+
page: z.ZodNumber;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
export { DeleteResponseSchema, BulkDeleteIdsSchema, PositiveIdSchema, } from "../../schemas";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript types for bounces module.
|
|
3
|
+
*
|
|
4
|
+
* All types are inferred from Zod schemas to ensure runtime
|
|
5
|
+
* validation matches compile-time types.
|
|
6
|
+
*
|
|
7
|
+
* @module resources/bounces/types
|
|
8
|
+
*/
|
|
9
|
+
import type { z } from "zod";
|
|
10
|
+
import type { BounceSchema, BounceTypeSchema, BounceCampaignSchema, ListBouncesOptionsSchema, ListBouncesResponseSchema } from "./schemas";
|
|
11
|
+
/**
|
|
12
|
+
* Bounce type classification.
|
|
13
|
+
*
|
|
14
|
+
* - `hard`: Permanent delivery failure (invalid address, domain doesn't exist)
|
|
15
|
+
* - `soft`: Temporary delivery failure (mailbox full, server unavailable)
|
|
16
|
+
*/
|
|
17
|
+
export type BounceType = z.infer<typeof BounceTypeSchema>;
|
|
18
|
+
/**
|
|
19
|
+
* Embedded campaign reference in a bounce record.
|
|
20
|
+
*/
|
|
21
|
+
export type BounceCampaign = z.infer<typeof BounceCampaignSchema>;
|
|
22
|
+
/**
|
|
23
|
+
* Complete bounce entity.
|
|
24
|
+
*
|
|
25
|
+
* Represents an email delivery failure record with metadata.
|
|
26
|
+
*/
|
|
27
|
+
export type Bounce = z.infer<typeof BounceSchema>;
|
|
28
|
+
/**
|
|
29
|
+
* Options for listing bounces (input).
|
|
30
|
+
*
|
|
31
|
+
* Uses z.input to allow optional fields to be omitted.
|
|
32
|
+
*/
|
|
33
|
+
export type ListBouncesOptions = z.input<typeof ListBouncesOptionsSchema>;
|
|
34
|
+
/**
|
|
35
|
+
* Paginated bounce list response (output).
|
|
36
|
+
*/
|
|
37
|
+
export type ListBouncesResponse = z.infer<typeof ListBouncesResponseSchema>;
|