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.
- package/LICENSE +21 -0
- package/README.md +171 -0
- package/dist/index.cjs +301 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +242 -0
- package/dist/index.d.ts +242 -0
- package/dist/index.js +273 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
// src/errors.ts
|
|
2
|
+
var NotideusError = class extends Error {
|
|
3
|
+
code;
|
|
4
|
+
status;
|
|
5
|
+
retryAfter;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super(options.message);
|
|
8
|
+
this.name = "NotideusError";
|
|
9
|
+
this.code = options.code;
|
|
10
|
+
this.status = options.status;
|
|
11
|
+
this.retryAfter = options.retryAfter;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/client.ts
|
|
16
|
+
var DEFAULT_BASE_URL = "https://api.notideus.io";
|
|
17
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
18
|
+
var VERSION = "0.1.0";
|
|
19
|
+
var ApiClient = class {
|
|
20
|
+
apiKey;
|
|
21
|
+
baseURL;
|
|
22
|
+
timeout;
|
|
23
|
+
maxRetries;
|
|
24
|
+
sleep;
|
|
25
|
+
constructor(options = {}) {
|
|
26
|
+
this.apiKey = options.apiKey;
|
|
27
|
+
this.baseURL = options.baseURL ?? DEFAULT_BASE_URL;
|
|
28
|
+
this.timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;
|
|
29
|
+
this.maxRetries = options.maxRetries ?? 2;
|
|
30
|
+
this.sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
31
|
+
}
|
|
32
|
+
async request(method, path, options = {}) {
|
|
33
|
+
const idempotent = method !== "POST" || hasIdempotencyKey(options.body);
|
|
34
|
+
let attempt = 0;
|
|
35
|
+
for (; ; ) {
|
|
36
|
+
try {
|
|
37
|
+
return await this.attempt(method, path, options);
|
|
38
|
+
} catch (err) {
|
|
39
|
+
if (!idempotent || !isRetriable(err) || attempt >= this.maxRetries) {
|
|
40
|
+
throw err;
|
|
41
|
+
}
|
|
42
|
+
await this.sleep(this.delayMs(err, attempt));
|
|
43
|
+
attempt += 1;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
delayMs(err, attempt) {
|
|
48
|
+
if (err instanceof NotideusError && err.retryAfter != null) {
|
|
49
|
+
return err.retryAfter * 1e3;
|
|
50
|
+
}
|
|
51
|
+
return Math.min(1e3 * 2 ** attempt, 8e3) + Math.floor(Math.random() * 250);
|
|
52
|
+
}
|
|
53
|
+
async attempt(method, path, options) {
|
|
54
|
+
const url = this.buildUrl(path, options.query);
|
|
55
|
+
const headers = {
|
|
56
|
+
"User-Agent": `notideus-node/${VERSION}`
|
|
57
|
+
};
|
|
58
|
+
if (options.authenticated !== false && this.apiKey) {
|
|
59
|
+
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
60
|
+
}
|
|
61
|
+
let body;
|
|
62
|
+
if (options.body !== void 0) {
|
|
63
|
+
headers["Content-Type"] = "application/json";
|
|
64
|
+
body = JSON.stringify(options.body);
|
|
65
|
+
}
|
|
66
|
+
const controller = new AbortController();
|
|
67
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
68
|
+
const onCallerAbort = () => controller.abort();
|
|
69
|
+
if (options.signal) {
|
|
70
|
+
if (options.signal.aborted) controller.abort();
|
|
71
|
+
else options.signal.addEventListener("abort", onCallerAbort, { once: true });
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const response = await fetch(url, { method, headers, body, signal: controller.signal });
|
|
75
|
+
if (response.status === 204) return void 0;
|
|
76
|
+
if (!response.ok) throw await this.toError(response);
|
|
77
|
+
return await response.json();
|
|
78
|
+
} catch (err) {
|
|
79
|
+
if (err instanceof NotideusError) throw err;
|
|
80
|
+
if (options.signal?.aborted) throw err;
|
|
81
|
+
throw new NotideusError({
|
|
82
|
+
code: controller.signal.aborted ? "request_timeout" : "network_error",
|
|
83
|
+
message: err instanceof Error ? err.message : String(err),
|
|
84
|
+
status: 0
|
|
85
|
+
});
|
|
86
|
+
} finally {
|
|
87
|
+
clearTimeout(timer);
|
|
88
|
+
options.signal?.removeEventListener("abort", onCallerAbort);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
buildUrl(path, query) {
|
|
92
|
+
const url = new URL(path, this.baseURL);
|
|
93
|
+
if (query) {
|
|
94
|
+
for (const [key, value] of Object.entries(query)) {
|
|
95
|
+
if (value !== void 0) url.searchParams.set(key, String(value));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return url.toString();
|
|
99
|
+
}
|
|
100
|
+
async toError(response) {
|
|
101
|
+
let code = "unknown_error";
|
|
102
|
+
let message = response.statusText || `HTTP ${response.status}`;
|
|
103
|
+
try {
|
|
104
|
+
const parsed = await response.json();
|
|
105
|
+
if (parsed.error?.code) code = parsed.error.code;
|
|
106
|
+
if (parsed.error?.message) message = parsed.error.message;
|
|
107
|
+
} catch {
|
|
108
|
+
}
|
|
109
|
+
const retryAfterHeader = response.headers.get("retry-after");
|
|
110
|
+
return new NotideusError({
|
|
111
|
+
code,
|
|
112
|
+
message,
|
|
113
|
+
status: response.status,
|
|
114
|
+
retryAfter: retryAfterHeader ? Number(retryAfterHeader) : void 0
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
function hasIdempotencyKey(body) {
|
|
119
|
+
return typeof body === "object" && body !== null && body.idempotency_key != null;
|
|
120
|
+
}
|
|
121
|
+
function isRetriable(err) {
|
|
122
|
+
if (!(err instanceof NotideusError)) return false;
|
|
123
|
+
if (err.code === "network_error" || err.code === "request_timeout") return true;
|
|
124
|
+
return err.status === 429 || err.status >= 500;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/resources/contacts.ts
|
|
128
|
+
function contactPath(email) {
|
|
129
|
+
return `/v1/contacts/${encodeURIComponent(email)}`;
|
|
130
|
+
}
|
|
131
|
+
var ContactsResource = class {
|
|
132
|
+
constructor(client) {
|
|
133
|
+
this.client = client;
|
|
134
|
+
}
|
|
135
|
+
client;
|
|
136
|
+
async list(params = {}) {
|
|
137
|
+
const { limit, status, email, cursor } = params;
|
|
138
|
+
return this.client.request("GET", "/v1/contacts", {
|
|
139
|
+
query: { limit, status, email, cursor }
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async create(params) {
|
|
143
|
+
return this.client.request("POST", "/v1/contacts", { body: params });
|
|
144
|
+
}
|
|
145
|
+
async get(email) {
|
|
146
|
+
return this.client.request("GET", contactPath(email));
|
|
147
|
+
}
|
|
148
|
+
async update(email, params) {
|
|
149
|
+
return this.client.request("PATCH", contactPath(email), { body: params });
|
|
150
|
+
}
|
|
151
|
+
async delete(email) {
|
|
152
|
+
await this.client.request("DELETE", contactPath(email));
|
|
153
|
+
}
|
|
154
|
+
async bulk(contacts) {
|
|
155
|
+
const res = await this.client.request("POST", "/v1/contacts/bulk", {
|
|
156
|
+
body: { contacts }
|
|
157
|
+
});
|
|
158
|
+
return res.data;
|
|
159
|
+
}
|
|
160
|
+
async unsubscribe(email) {
|
|
161
|
+
return this.client.request("POST", `${contactPath(email)}/unsubscribe`);
|
|
162
|
+
}
|
|
163
|
+
async resubscribe(email) {
|
|
164
|
+
return this.client.request("POST", `${contactPath(email)}/resubscribe`);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// src/resources/emails.ts
|
|
169
|
+
var EmailsResource = class {
|
|
170
|
+
constructor(client) {
|
|
171
|
+
this.client = client;
|
|
172
|
+
}
|
|
173
|
+
client;
|
|
174
|
+
async send(params) {
|
|
175
|
+
return this.client.request("POST", "/v1/emails", { body: params });
|
|
176
|
+
}
|
|
177
|
+
async sendBatch(emails) {
|
|
178
|
+
const res = await this.client.request("POST", "/v1/emails/batch", {
|
|
179
|
+
body: { emails }
|
|
180
|
+
});
|
|
181
|
+
return res.data;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// src/resources/plans.ts
|
|
186
|
+
var PlansResource = class {
|
|
187
|
+
constructor(client) {
|
|
188
|
+
this.client = client;
|
|
189
|
+
}
|
|
190
|
+
client;
|
|
191
|
+
async list(params = {}) {
|
|
192
|
+
return this.client.request("GET", "/v1/plans", {
|
|
193
|
+
query: { locale: params.locale },
|
|
194
|
+
authenticated: false
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// src/resources/unsubscribe.ts
|
|
200
|
+
var UnsubscribeResource = class {
|
|
201
|
+
constructor(client) {
|
|
202
|
+
this.client = client;
|
|
203
|
+
}
|
|
204
|
+
client;
|
|
205
|
+
async info(token) {
|
|
206
|
+
return this.client.request("GET", "/v1/unsubscribe/info", {
|
|
207
|
+
query: { t: token },
|
|
208
|
+
authenticated: false
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
async unsubscribe(token, topicIds) {
|
|
212
|
+
const body = { token };
|
|
213
|
+
if (topicIds !== void 0) {
|
|
214
|
+
body.topic_ids = topicIds;
|
|
215
|
+
}
|
|
216
|
+
await this.client.request("POST", "/v1/unsubscribe", { body, authenticated: false });
|
|
217
|
+
}
|
|
218
|
+
async preferences(token, topicIds) {
|
|
219
|
+
await this.client.request("POST", "/v1/unsubscribe/preferences", {
|
|
220
|
+
body: { token, topic_ids: topicIds },
|
|
221
|
+
authenticated: false
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// src/resources/whatsapp.ts
|
|
227
|
+
var WhatsAppResource = class {
|
|
228
|
+
messages;
|
|
229
|
+
constructor(client) {
|
|
230
|
+
this.messages = new WhatsAppMessagesResource(client);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
var WhatsAppMessagesResource = class {
|
|
234
|
+
constructor(client) {
|
|
235
|
+
this.client = client;
|
|
236
|
+
}
|
|
237
|
+
client;
|
|
238
|
+
async send(params) {
|
|
239
|
+
const res = await this.client.request("POST", "/v1/whatsapp/messages", {
|
|
240
|
+
body: params
|
|
241
|
+
});
|
|
242
|
+
return res.data;
|
|
243
|
+
}
|
|
244
|
+
async sendBatch(messages) {
|
|
245
|
+
const res = await this.client.request("POST", "/v1/whatsapp/messages/batch", {
|
|
246
|
+
body: { messages }
|
|
247
|
+
});
|
|
248
|
+
return res.data;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
// src/index.ts
|
|
253
|
+
var Notideus = class {
|
|
254
|
+
client;
|
|
255
|
+
emails;
|
|
256
|
+
contacts;
|
|
257
|
+
whatsapp;
|
|
258
|
+
unsubscribe;
|
|
259
|
+
plans;
|
|
260
|
+
constructor(apiKey, options = {}) {
|
|
261
|
+
this.client = new ApiClient({ ...options, apiKey });
|
|
262
|
+
this.emails = new EmailsResource(this.client);
|
|
263
|
+
this.contacts = new ContactsResource(this.client);
|
|
264
|
+
this.whatsapp = new WhatsAppResource(this.client);
|
|
265
|
+
this.unsubscribe = new UnsubscribeResource(this.client);
|
|
266
|
+
this.plans = new PlansResource(this.client);
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
export {
|
|
270
|
+
Notideus,
|
|
271
|
+
NotideusError
|
|
272
|
+
};
|
|
273
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/resources/contacts.ts","../src/resources/emails.ts","../src/resources/plans.ts","../src/resources/unsubscribe.ts","../src/resources/whatsapp.ts","../src/index.ts"],"sourcesContent":["export interface NotideusErrorOptions {\n code: string;\n message: string;\n status: number;\n retryAfter?: number;\n}\n\nexport class NotideusError extends Error {\n readonly code: string;\n readonly status: number;\n readonly retryAfter?: number;\n\n constructor(options: NotideusErrorOptions) {\n super(options.message);\n this.name = 'NotideusError';\n this.code = options.code;\n this.status = options.status;\n this.retryAfter = options.retryAfter;\n }\n}\n","import { NotideusError } from './errors.js';\n\nconst DEFAULT_BASE_URL = 'https://api.notideus.io';\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst VERSION = '0.1.0';\n\nexport interface ClientOptions {\n apiKey?: string;\n baseURL?: string;\n timeout?: number;\n maxRetries?: number;\n sleep?: (ms: number) => Promise<void>;\n}\n\nexport interface RequestOptions {\n query?: Record<string, string | number | undefined>;\n body?: unknown;\n authenticated?: boolean;\n signal?: AbortSignal;\n}\n\nexport class ApiClient {\n private readonly apiKey?: string;\n private readonly baseURL: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n private readonly sleep: (ms: number) => Promise<void>;\n\n constructor(options: ClientOptions = {}) {\n this.apiKey = options.apiKey;\n this.baseURL = options.baseURL ?? DEFAULT_BASE_URL;\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;\n this.maxRetries = options.maxRetries ?? 2;\n this.sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));\n }\n\n async request<T>(method: string, path: string, options: RequestOptions = {}): Promise<T> {\n const idempotent = method !== 'POST' || hasIdempotencyKey(options.body);\n let attempt = 0;\n for (;;) {\n try {\n return await this.attempt<T>(method, path, options);\n } catch (err) {\n if (!idempotent || !isRetriable(err) || attempt >= this.maxRetries) {\n throw err;\n }\n await this.sleep(this.delayMs(err, attempt));\n attempt += 1;\n }\n }\n }\n\n private delayMs(err: unknown, attempt: number): number {\n if (err instanceof NotideusError && err.retryAfter != null) {\n return err.retryAfter * 1000;\n }\n return Math.min(1000 * 2 ** attempt, 8000) + Math.floor(Math.random() * 250);\n }\n\n private async attempt<T>(method: string, path: string, options: RequestOptions): Promise<T> {\n const url = this.buildUrl(path, options.query);\n const headers: Record<string, string> = {\n 'User-Agent': `notideus-node/${VERSION}`\n };\n if (options.authenticated !== false && this.apiKey) {\n headers.Authorization = `Bearer ${this.apiKey}`;\n }\n let body: string | undefined;\n if (options.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n body = JSON.stringify(options.body);\n }\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n const onCallerAbort = () => controller.abort();\n if (options.signal) {\n if (options.signal.aborted) controller.abort();\n else options.signal.addEventListener('abort', onCallerAbort, { once: true });\n }\n\n try {\n const response = await fetch(url, { method, headers, body, signal: controller.signal });\n if (response.status === 204) return undefined as T;\n if (!response.ok) throw await this.toError(response);\n return (await response.json()) as T;\n } catch (err) {\n if (err instanceof NotideusError) throw err;\n if (options.signal?.aborted) throw err;\n throw new NotideusError({\n code: controller.signal.aborted ? 'request_timeout' : 'network_error',\n message: err instanceof Error ? err.message : String(err),\n status: 0\n });\n } finally {\n clearTimeout(timer);\n options.signal?.removeEventListener('abort', onCallerAbort);\n }\n }\n\n private buildUrl(path: string, query?: RequestOptions['query']): string {\n const url = new URL(path, this.baseURL);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) url.searchParams.set(key, String(value));\n }\n }\n return url.toString();\n }\n\n private async toError(response: Response): Promise<NotideusError> {\n let code = 'unknown_error';\n let message = response.statusText || `HTTP ${response.status}`;\n try {\n const parsed = (await response.json()) as { error?: { code?: string; message?: string } };\n if (parsed.error?.code) code = parsed.error.code;\n if (parsed.error?.message) message = parsed.error.message;\n } catch {\n // non-JSON error body — keep the defaults\n }\n const retryAfterHeader = response.headers.get('retry-after');\n return new NotideusError({\n code,\n message,\n status: response.status,\n retryAfter: retryAfterHeader ? Number(retryAfterHeader) : undefined\n });\n }\n}\n\nfunction hasIdempotencyKey(body: unknown): boolean {\n return (\n typeof body === 'object' &&\n body !== null &&\n (body as Record<string, unknown>).idempotency_key != null\n );\n}\n\nfunction isRetriable(err: unknown): boolean {\n if (!(err instanceof NotideusError)) return false;\n if (err.code === 'network_error' || err.code === 'request_timeout') return true;\n return err.status === 429 || err.status >= 500;\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type {\n BulkContactInput,\n Contact,\n CreateContactParams,\n ListContactsParams,\n ListContactsResponse,\n UpdateContactParams\n} from '../types/contact.js';\n\nfunction contactPath(email: string): string {\n return `/v1/contacts/${encodeURIComponent(email)}`;\n}\n\nexport class ContactsResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: ListContactsParams = {}): Promise<ListContactsResponse> {\n const { limit, status, email, cursor } = params;\n return this.client.request<ListContactsResponse>('GET', '/v1/contacts', {\n query: { limit, status, email, cursor }\n });\n }\n\n async create(params: CreateContactParams): Promise<Contact> {\n return this.client.request<Contact>('POST', '/v1/contacts', { body: params });\n }\n\n async get(email: string): Promise<Contact> {\n return this.client.request<Contact>('GET', contactPath(email));\n }\n\n async update(email: string, params: UpdateContactParams): Promise<Contact> {\n return this.client.request<Contact>('PATCH', contactPath(email), { body: params });\n }\n\n async delete(email: string): Promise<void> {\n await this.client.request<void>('DELETE', contactPath(email));\n }\n\n async bulk(contacts: BulkContactInput[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/contacts/bulk', {\n body: { contacts }\n });\n return res.data;\n }\n\n async unsubscribe(email: string): Promise<Contact> {\n return this.client.request<Contact>('POST', `${contactPath(email)}/unsubscribe`);\n }\n\n async resubscribe(email: string): Promise<Contact> {\n return this.client.request<Contact>('POST', `${contactPath(email)}/resubscribe`);\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type { Email, SendEmailParams } from '../types/email.js';\n\nexport class EmailsResource {\n constructor(private readonly client: ApiClient) {}\n\n async send(params: SendEmailParams): Promise<Email> {\n return this.client.request<Email>('POST', '/v1/emails', { body: params });\n }\n\n async sendBatch(emails: SendEmailParams[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/emails/batch', {\n body: { emails }\n });\n return res.data;\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { PlanCatalog, PlanLocale } from '../types/plans.js';\n\nexport class PlansResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: { locale?: PlanLocale } = {}): Promise<PlanCatalog> {\n return this.client.request<PlanCatalog>('GET', '/v1/plans', {\n query: { locale: params.locale },\n authenticated: false\n });\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { UnsubscribeInfo } from '../types/unsubscribe.js';\n\nexport class UnsubscribeResource {\n constructor(private readonly client: ApiClient) {}\n\n async info(token: string): Promise<UnsubscribeInfo> {\n return this.client.request<UnsubscribeInfo>('GET', '/v1/unsubscribe/info', {\n query: { t: token },\n authenticated: false\n });\n }\n\n async unsubscribe(token: string, topicIds?: string[]): Promise<void> {\n const body: Record<string, unknown> = { token };\n if (topicIds !== undefined) {\n body.topic_ids = topicIds;\n }\n await this.client.request<void>('POST', '/v1/unsubscribe', { body, authenticated: false });\n }\n\n async preferences(token: string, topicIds: string[]): Promise<void> {\n await this.client.request<void>('POST', '/v1/unsubscribe/preferences', {\n body: { token, topic_ids: topicIds },\n authenticated: false\n });\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type { SendWhatsAppMessageParams, WhatsAppMessage } from '../types/whatsapp.js';\n\nexport class WhatsAppResource {\n readonly messages: WhatsAppMessagesResource;\n\n constructor(client: ApiClient) {\n this.messages = new WhatsAppMessagesResource(client);\n }\n}\n\nexport class WhatsAppMessagesResource {\n constructor(private readonly client: ApiClient) {}\n\n async send(params: SendWhatsAppMessageParams): Promise<WhatsAppMessage[]> {\n const res = await this.client.request<{ data: WhatsAppMessage[] }>('POST', '/v1/whatsapp/messages', {\n body: params\n });\n return res.data;\n }\n\n async sendBatch(messages: SendWhatsAppMessageParams[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/whatsapp/messages/batch', {\n body: { messages }\n });\n return res.data;\n }\n}\n","import { ApiClient, type ClientOptions } from './client.js';\nimport { ContactsResource } from './resources/contacts.js';\nimport { EmailsResource } from './resources/emails.js';\nimport { PlansResource } from './resources/plans.js';\nimport { UnsubscribeResource } from './resources/unsubscribe.js';\nimport { WhatsAppResource } from './resources/whatsapp.js';\n\nexport { NotideusError } from './errors.js';\nexport type { ClientOptions } from './client.js';\nexport type { BatchItemError, BatchItemResult } from './types/common.js';\nexport type {\n BulkContactInput,\n Contact,\n ContactStatus,\n CreateContactParams,\n ListContactsParams,\n ListContactsResponse,\n UpdateContactParams\n} from './types/contact.js';\nexport type { Email, SendEmailParams } from './types/email.js';\nexport type {\n ContactsTier,\n FreeAllowances,\n Plan,\n PlanCatalog,\n PlanLocale,\n PlanTier\n} from './types/plans.js';\nexport type { SendWhatsAppMessageParams, WhatsAppMessage } from './types/whatsapp.js';\nexport type { UnsubscribeInfo, UnsubscribeTopic } from './types/unsubscribe.js';\n\nexport class Notideus {\n private readonly client: ApiClient;\n readonly emails: EmailsResource;\n readonly contacts: ContactsResource;\n readonly whatsapp: WhatsAppResource;\n readonly unsubscribe: UnsubscribeResource;\n readonly plans: PlansResource;\n\n constructor(apiKey?: string, options: Omit<ClientOptions, 'apiKey'> = {}) {\n this.client = new ApiClient({ ...options, apiKey });\n this.emails = new EmailsResource(this.client);\n this.contacts = new ContactsResource(this.client);\n this.whatsapp = new WhatsAppResource(this.client);\n this.unsubscribe = new UnsubscribeResource(this.client);\n this.plans = new PlansResource(this.client);\n }\n}\n"],"mappings":";AAOO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,SAA+B;AACzC,UAAM,QAAQ,OAAO;AACrB,SAAK,OAAO;AACZ,SAAK,OAAO,QAAQ;AACpB,SAAK,SAAS,QAAQ;AACtB,SAAK,aAAa,QAAQ;AAAA,EAC5B;AACF;;;ACjBA,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;AAC3B,IAAM,UAAU;AAiBT,IAAM,YAAN,MAAgB;AAAA,EACJ;AAAA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A+B;AAAA,MACxG,MAAM,EAAE,SAAS;AAAA,IACnB,CAAC;AACD,WAAO,IAAI;AAAA,EACb;AACF;;;ACGO,IAAM,WAAN,MAAe;AAAA,EACH;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,QAAiB,UAAyC,CAAC,GAAG;AACxE,SAAK,SAAS,IAAI,UAAU,EAAE,GAAG,SAAS,OAAO,CAAC;AAClD,SAAK,SAAS,IAAI,eAAe,KAAK,MAAM;AAC5C,SAAK,WAAW,IAAI,iBAAiB,KAAK,MAAM;AAChD,SAAK,WAAW,IAAI,iBAAiB,KAAK,MAAM;AAChD,SAAK,cAAc,IAAI,oBAAoB,KAAK,MAAM;AACtD,SAAK,QAAQ,IAAI,cAAc,KAAK,MAAM;AAAA,EAC5C;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "notideus",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official Node.js SDK for the Notideus email API",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"notideus",
|
|
7
|
+
"email",
|
|
8
|
+
"email api",
|
|
9
|
+
"transactional email",
|
|
10
|
+
"marketing email",
|
|
11
|
+
"sdk",
|
|
12
|
+
"api client",
|
|
13
|
+
"nodejs",
|
|
14
|
+
"typescript",
|
|
15
|
+
"whatsapp"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": "github:notideus/sdk-node",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"main": "./dist/index.cjs",
|
|
22
|
+
"module": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"default": "./dist/index.cjs"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsup",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"lint": "eslint .",
|
|
47
|
+
"prepublishOnly": "npm run build"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@eslint/js": "^9.13.0",
|
|
51
|
+
"@types/node": "^22.7.0",
|
|
52
|
+
"eslint": "^9.13.0",
|
|
53
|
+
"tsup": "^8.3.0",
|
|
54
|
+
"typescript": "^5.6.0",
|
|
55
|
+
"typescript-eslint": "^8.10.0",
|
|
56
|
+
"vitest": "^3.0.0"
|
|
57
|
+
}
|
|
58
|
+
}
|