notideus 0.1.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.
@@ -0,0 +1,242 @@
1
+ interface ClientOptions {
2
+ apiKey?: string;
3
+ baseURL?: string;
4
+ timeout?: number;
5
+ maxRetries?: number;
6
+ sleep?: (ms: number) => Promise<void>;
7
+ }
8
+ interface RequestOptions {
9
+ query?: Record<string, string | number | undefined>;
10
+ body?: unknown;
11
+ authenticated?: boolean;
12
+ signal?: AbortSignal;
13
+ }
14
+ declare class ApiClient {
15
+ private readonly apiKey?;
16
+ private readonly baseURL;
17
+ private readonly timeout;
18
+ private readonly maxRetries;
19
+ private readonly sleep;
20
+ constructor(options?: ClientOptions);
21
+ request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
22
+ private delayMs;
23
+ private attempt;
24
+ private buildUrl;
25
+ private toError;
26
+ }
27
+
28
+ interface BatchItemError {
29
+ code: string;
30
+ message: string;
31
+ }
32
+ type BatchItemResult = {
33
+ index: number;
34
+ id: string;
35
+ } | {
36
+ index: number;
37
+ error: BatchItemError;
38
+ };
39
+
40
+ type ContactStatus = 'subscribed' | 'unsubscribed' | 'bounced' | 'complained';
41
+ interface Contact {
42
+ id: string;
43
+ email: string;
44
+ status: ContactStatus;
45
+ properties: Record<string, string>;
46
+ subscribed_topic_ids: string[];
47
+ created_at: string;
48
+ updated_at: string;
49
+ }
50
+ interface ListContactsParams {
51
+ cursor?: string;
52
+ limit?: number;
53
+ email?: string;
54
+ status?: ContactStatus;
55
+ }
56
+ interface ListContactsResponse {
57
+ data: Contact[];
58
+ next_cursor?: string;
59
+ }
60
+ interface CreateContactParams {
61
+ email: string;
62
+ properties?: Record<string, string>;
63
+ topic_ids?: string[];
64
+ }
65
+ interface UpdateContactParams {
66
+ properties?: Record<string, string>;
67
+ topic_ids?: string[];
68
+ }
69
+ interface BulkContactInput {
70
+ email: string;
71
+ properties?: Record<string, string>;
72
+ }
73
+
74
+ declare class ContactsResource {
75
+ private readonly client;
76
+ constructor(client: ApiClient);
77
+ list(params?: ListContactsParams): Promise<ListContactsResponse>;
78
+ create(params: CreateContactParams): Promise<Contact>;
79
+ get(email: string): Promise<Contact>;
80
+ update(email: string, params: UpdateContactParams): Promise<Contact>;
81
+ delete(email: string): Promise<void>;
82
+ bulk(contacts: BulkContactInput[]): Promise<BatchItemResult[]>;
83
+ unsubscribe(email: string): Promise<Contact>;
84
+ resubscribe(email: string): Promise<Contact>;
85
+ }
86
+
87
+ interface SendEmailParams {
88
+ from: string;
89
+ to: string[];
90
+ subject: string;
91
+ html?: string;
92
+ text?: string;
93
+ headers?: Record<string, string>;
94
+ reply_to?: string;
95
+ template_id?: string | null;
96
+ variables?: Record<string, string>;
97
+ tags?: string[];
98
+ idempotency_key?: string;
99
+ }
100
+ interface Email {
101
+ id: string;
102
+ team_id: string;
103
+ domain_id: string;
104
+ template_id: string | null;
105
+ from_address: string;
106
+ to_emails: string[];
107
+ subject: string;
108
+ html: string;
109
+ size_kb: number;
110
+ tags: string[] | null;
111
+ status: string;
112
+ idempotency_key: string | null;
113
+ created_at: string;
114
+ requeued_at: string | null;
115
+ ses_message_id: string | null;
116
+ broadcast_id: string | null;
117
+ contact_id: string | null;
118
+ unsubscribe_token: string | null;
119
+ body_text: string;
120
+ headers: Record<string, string> | null;
121
+ reply_to: string;
122
+ }
123
+
124
+ declare class EmailsResource {
125
+ private readonly client;
126
+ constructor(client: ApiClient);
127
+ send(params: SendEmailParams): Promise<Email>;
128
+ sendBatch(emails: SendEmailParams[]): Promise<BatchItemResult[]>;
129
+ }
130
+
131
+ type PlanLocale = 'en' | 'fr';
132
+ interface PlanTier {
133
+ emails: number;
134
+ monthly_cents: number;
135
+ annual_cents?: number | null;
136
+ }
137
+ interface ContactsTier {
138
+ contacts: number;
139
+ monthly_cents: number;
140
+ }
141
+ interface Plan {
142
+ key: string;
143
+ kind: 'free' | 'paid' | 'custom';
144
+ name: string;
145
+ blurb: string;
146
+ cta: string | null;
147
+ featured: boolean;
148
+ benefits: string[];
149
+ email_limit?: number;
150
+ contact_limit?: number;
151
+ domains_limit?: number;
152
+ storage_gb?: number;
153
+ send_rate_per_second?: number | null;
154
+ tiers?: PlanTier[] | null;
155
+ }
156
+ interface FreeAllowances {
157
+ emails: number;
158
+ contacts: number;
159
+ }
160
+ interface PlanCatalog {
161
+ free_allowances: FreeAllowances;
162
+ overage_per_1000_cents: number | null;
163
+ plans: Plan[];
164
+ contacts_tiers: ContactsTier[];
165
+ }
166
+
167
+ declare class PlansResource {
168
+ private readonly client;
169
+ constructor(client: ApiClient);
170
+ list(params?: {
171
+ locale?: PlanLocale;
172
+ }): Promise<PlanCatalog>;
173
+ }
174
+
175
+ interface UnsubscribeTopic {
176
+ id: string;
177
+ name: string;
178
+ display_name: string;
179
+ subscribed: boolean;
180
+ }
181
+ interface UnsubscribeInfo {
182
+ email: string;
183
+ status: string;
184
+ team_name: string;
185
+ topics: UnsubscribeTopic[];
186
+ }
187
+
188
+ declare class UnsubscribeResource {
189
+ private readonly client;
190
+ constructor(client: ApiClient);
191
+ info(token: string): Promise<UnsubscribeInfo>;
192
+ unsubscribe(token: string, topicIds?: string[]): Promise<void>;
193
+ preferences(token: string, topicIds: string[]): Promise<void>;
194
+ }
195
+
196
+ interface SendWhatsAppMessageParams {
197
+ template_id: string;
198
+ to: string[];
199
+ parameters?: Record<string, string>;
200
+ idempotency_key?: string;
201
+ }
202
+ interface WhatsAppMessage {
203
+ id: string;
204
+ to: string;
205
+ status: string;
206
+ }
207
+
208
+ declare class WhatsAppResource {
209
+ readonly messages: WhatsAppMessagesResource;
210
+ constructor(client: ApiClient);
211
+ }
212
+ declare class WhatsAppMessagesResource {
213
+ private readonly client;
214
+ constructor(client: ApiClient);
215
+ send(params: SendWhatsAppMessageParams): Promise<WhatsAppMessage[]>;
216
+ sendBatch(messages: SendWhatsAppMessageParams[]): Promise<BatchItemResult[]>;
217
+ }
218
+
219
+ interface NotideusErrorOptions {
220
+ code: string;
221
+ message: string;
222
+ status: number;
223
+ retryAfter?: number;
224
+ }
225
+ declare class NotideusError extends Error {
226
+ readonly code: string;
227
+ readonly status: number;
228
+ readonly retryAfter?: number;
229
+ constructor(options: NotideusErrorOptions);
230
+ }
231
+
232
+ declare class Notideus {
233
+ private readonly client;
234
+ readonly emails: EmailsResource;
235
+ readonly contacts: ContactsResource;
236
+ readonly whatsapp: WhatsAppResource;
237
+ readonly unsubscribe: UnsubscribeResource;
238
+ readonly plans: PlansResource;
239
+ constructor(apiKey?: string, options?: Omit<ClientOptions, 'apiKey'>);
240
+ }
241
+
242
+ export { type BatchItemError, type BatchItemResult, type BulkContactInput, type ClientOptions, type Contact, type ContactStatus, type ContactsTier, type CreateContactParams, type Email, type FreeAllowances, type ListContactsParams, type ListContactsResponse, Notideus, NotideusError, type Plan, type PlanCatalog, type PlanLocale, type PlanTier, type SendEmailParams, type SendWhatsAppMessageParams, type UnsubscribeInfo, type UnsubscribeTopic, type UpdateContactParams, type WhatsAppMessage };
@@ -0,0 +1,242 @@
1
+ interface ClientOptions {
2
+ apiKey?: string;
3
+ baseURL?: string;
4
+ timeout?: number;
5
+ maxRetries?: number;
6
+ sleep?: (ms: number) => Promise<void>;
7
+ }
8
+ interface RequestOptions {
9
+ query?: Record<string, string | number | undefined>;
10
+ body?: unknown;
11
+ authenticated?: boolean;
12
+ signal?: AbortSignal;
13
+ }
14
+ declare class ApiClient {
15
+ private readonly apiKey?;
16
+ private readonly baseURL;
17
+ private readonly timeout;
18
+ private readonly maxRetries;
19
+ private readonly sleep;
20
+ constructor(options?: ClientOptions);
21
+ request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
22
+ private delayMs;
23
+ private attempt;
24
+ private buildUrl;
25
+ private toError;
26
+ }
27
+
28
+ interface BatchItemError {
29
+ code: string;
30
+ message: string;
31
+ }
32
+ type BatchItemResult = {
33
+ index: number;
34
+ id: string;
35
+ } | {
36
+ index: number;
37
+ error: BatchItemError;
38
+ };
39
+
40
+ type ContactStatus = 'subscribed' | 'unsubscribed' | 'bounced' | 'complained';
41
+ interface Contact {
42
+ id: string;
43
+ email: string;
44
+ status: ContactStatus;
45
+ properties: Record<string, string>;
46
+ subscribed_topic_ids: string[];
47
+ created_at: string;
48
+ updated_at: string;
49
+ }
50
+ interface ListContactsParams {
51
+ cursor?: string;
52
+ limit?: number;
53
+ email?: string;
54
+ status?: ContactStatus;
55
+ }
56
+ interface ListContactsResponse {
57
+ data: Contact[];
58
+ next_cursor?: string;
59
+ }
60
+ interface CreateContactParams {
61
+ email: string;
62
+ properties?: Record<string, string>;
63
+ topic_ids?: string[];
64
+ }
65
+ interface UpdateContactParams {
66
+ properties?: Record<string, string>;
67
+ topic_ids?: string[];
68
+ }
69
+ interface BulkContactInput {
70
+ email: string;
71
+ properties?: Record<string, string>;
72
+ }
73
+
74
+ declare class ContactsResource {
75
+ private readonly client;
76
+ constructor(client: ApiClient);
77
+ list(params?: ListContactsParams): Promise<ListContactsResponse>;
78
+ create(params: CreateContactParams): Promise<Contact>;
79
+ get(email: string): Promise<Contact>;
80
+ update(email: string, params: UpdateContactParams): Promise<Contact>;
81
+ delete(email: string): Promise<void>;
82
+ bulk(contacts: BulkContactInput[]): Promise<BatchItemResult[]>;
83
+ unsubscribe(email: string): Promise<Contact>;
84
+ resubscribe(email: string): Promise<Contact>;
85
+ }
86
+
87
+ interface SendEmailParams {
88
+ from: string;
89
+ to: string[];
90
+ subject: string;
91
+ html?: string;
92
+ text?: string;
93
+ headers?: Record<string, string>;
94
+ reply_to?: string;
95
+ template_id?: string | null;
96
+ variables?: Record<string, string>;
97
+ tags?: string[];
98
+ idempotency_key?: string;
99
+ }
100
+ interface Email {
101
+ id: string;
102
+ team_id: string;
103
+ domain_id: string;
104
+ template_id: string | null;
105
+ from_address: string;
106
+ to_emails: string[];
107
+ subject: string;
108
+ html: string;
109
+ size_kb: number;
110
+ tags: string[] | null;
111
+ status: string;
112
+ idempotency_key: string | null;
113
+ created_at: string;
114
+ requeued_at: string | null;
115
+ ses_message_id: string | null;
116
+ broadcast_id: string | null;
117
+ contact_id: string | null;
118
+ unsubscribe_token: string | null;
119
+ body_text: string;
120
+ headers: Record<string, string> | null;
121
+ reply_to: string;
122
+ }
123
+
124
+ declare class EmailsResource {
125
+ private readonly client;
126
+ constructor(client: ApiClient);
127
+ send(params: SendEmailParams): Promise<Email>;
128
+ sendBatch(emails: SendEmailParams[]): Promise<BatchItemResult[]>;
129
+ }
130
+
131
+ type PlanLocale = 'en' | 'fr';
132
+ interface PlanTier {
133
+ emails: number;
134
+ monthly_cents: number;
135
+ annual_cents?: number | null;
136
+ }
137
+ interface ContactsTier {
138
+ contacts: number;
139
+ monthly_cents: number;
140
+ }
141
+ interface Plan {
142
+ key: string;
143
+ kind: 'free' | 'paid' | 'custom';
144
+ name: string;
145
+ blurb: string;
146
+ cta: string | null;
147
+ featured: boolean;
148
+ benefits: string[];
149
+ email_limit?: number;
150
+ contact_limit?: number;
151
+ domains_limit?: number;
152
+ storage_gb?: number;
153
+ send_rate_per_second?: number | null;
154
+ tiers?: PlanTier[] | null;
155
+ }
156
+ interface FreeAllowances {
157
+ emails: number;
158
+ contacts: number;
159
+ }
160
+ interface PlanCatalog {
161
+ free_allowances: FreeAllowances;
162
+ overage_per_1000_cents: number | null;
163
+ plans: Plan[];
164
+ contacts_tiers: ContactsTier[];
165
+ }
166
+
167
+ declare class PlansResource {
168
+ private readonly client;
169
+ constructor(client: ApiClient);
170
+ list(params?: {
171
+ locale?: PlanLocale;
172
+ }): Promise<PlanCatalog>;
173
+ }
174
+
175
+ interface UnsubscribeTopic {
176
+ id: string;
177
+ name: string;
178
+ display_name: string;
179
+ subscribed: boolean;
180
+ }
181
+ interface UnsubscribeInfo {
182
+ email: string;
183
+ status: string;
184
+ team_name: string;
185
+ topics: UnsubscribeTopic[];
186
+ }
187
+
188
+ declare class UnsubscribeResource {
189
+ private readonly client;
190
+ constructor(client: ApiClient);
191
+ info(token: string): Promise<UnsubscribeInfo>;
192
+ unsubscribe(token: string, topicIds?: string[]): Promise<void>;
193
+ preferences(token: string, topicIds: string[]): Promise<void>;
194
+ }
195
+
196
+ interface SendWhatsAppMessageParams {
197
+ template_id: string;
198
+ to: string[];
199
+ parameters?: Record<string, string>;
200
+ idempotency_key?: string;
201
+ }
202
+ interface WhatsAppMessage {
203
+ id: string;
204
+ to: string;
205
+ status: string;
206
+ }
207
+
208
+ declare class WhatsAppResource {
209
+ readonly messages: WhatsAppMessagesResource;
210
+ constructor(client: ApiClient);
211
+ }
212
+ declare class WhatsAppMessagesResource {
213
+ private readonly client;
214
+ constructor(client: ApiClient);
215
+ send(params: SendWhatsAppMessageParams): Promise<WhatsAppMessage[]>;
216
+ sendBatch(messages: SendWhatsAppMessageParams[]): Promise<BatchItemResult[]>;
217
+ }
218
+
219
+ interface NotideusErrorOptions {
220
+ code: string;
221
+ message: string;
222
+ status: number;
223
+ retryAfter?: number;
224
+ }
225
+ declare class NotideusError extends Error {
226
+ readonly code: string;
227
+ readonly status: number;
228
+ readonly retryAfter?: number;
229
+ constructor(options: NotideusErrorOptions);
230
+ }
231
+
232
+ declare class Notideus {
233
+ private readonly client;
234
+ readonly emails: EmailsResource;
235
+ readonly contacts: ContactsResource;
236
+ readonly whatsapp: WhatsAppResource;
237
+ readonly unsubscribe: UnsubscribeResource;
238
+ readonly plans: PlansResource;
239
+ constructor(apiKey?: string, options?: Omit<ClientOptions, 'apiKey'>);
240
+ }
241
+
242
+ export { type BatchItemError, type BatchItemResult, type BulkContactInput, type ClientOptions, type Contact, type ContactStatus, type ContactsTier, type CreateContactParams, type Email, type FreeAllowances, type ListContactsParams, type ListContactsResponse, Notideus, NotideusError, type Plan, type PlanCatalog, type PlanLocale, type PlanTier, type SendEmailParams, type SendWhatsAppMessageParams, type UnsubscribeInfo, type UnsubscribeTopic, type UpdateContactParams, type WhatsAppMessage };