@medalsocial/sdk 1.1.2 → 1.1.4
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/src/index.d.mts +65 -1
- package/dist/src/index.d.ts +65 -1
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +5 -0
- package/dist/src/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/src/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Configuration for the low-level HTTP client. */
|
|
1
2
|
interface ClientConfig {
|
|
2
3
|
baseUrl: string;
|
|
3
4
|
token: string;
|
|
@@ -10,11 +11,16 @@ interface ClientConfig {
|
|
|
10
11
|
* Handles authentication, retries, timeout, and error parsing.
|
|
11
12
|
*/
|
|
12
13
|
declare class BaseClient {
|
|
14
|
+
/** Resolved client configuration. */
|
|
13
15
|
readonly config: ClientConfig;
|
|
14
16
|
constructor(config: ClientConfig);
|
|
17
|
+
/** Execute an authenticated GET request and return the parsed JSON body. */
|
|
15
18
|
get<T>(path: string, params?: Record<string, string | undefined>): Promise<T>;
|
|
19
|
+
/** Execute an authenticated POST request with a JSON body. */
|
|
16
20
|
post<T>(path: string, body?: unknown): Promise<T>;
|
|
21
|
+
/** Execute an authenticated PATCH request with a JSON body. */
|
|
17
22
|
patch<T>(path: string, body: unknown): Promise<T>;
|
|
23
|
+
/** Execute an authenticated DELETE request. */
|
|
18
24
|
delete<T>(path: string): Promise<T>;
|
|
19
25
|
private buildUrl;
|
|
20
26
|
private request;
|
|
@@ -45,6 +51,7 @@ interface PaginationOptions {
|
|
|
45
51
|
cursor?: string;
|
|
46
52
|
}
|
|
47
53
|
|
|
54
|
+
/** A contact in the workspace CRM. */
|
|
48
55
|
interface Contact {
|
|
49
56
|
id: string;
|
|
50
57
|
email: string;
|
|
@@ -62,20 +69,27 @@ interface Contact {
|
|
|
62
69
|
created_at: string | null;
|
|
63
70
|
updated_at: string | null;
|
|
64
71
|
}
|
|
72
|
+
/** Result returned after creating a contact. */
|
|
65
73
|
interface ContactCreateResult {
|
|
66
74
|
id: string;
|
|
67
75
|
}
|
|
76
|
+
/** Result returned after updating a contact. */
|
|
68
77
|
interface ContactUpdateResult {
|
|
69
78
|
success: true;
|
|
70
79
|
}
|
|
80
|
+
/** Result returned after deleting a contact. */
|
|
71
81
|
interface ContactRemoveResult {
|
|
72
82
|
success: true;
|
|
73
83
|
}
|
|
84
|
+
/** Result returned after adding a note to a contact. */
|
|
74
85
|
interface ContactNoteResult {
|
|
75
86
|
id: string;
|
|
76
87
|
}
|
|
88
|
+
/** Lifecycle stage of a contact in the CRM. */
|
|
77
89
|
type ContactStatus = "lead" | "prospect" | "customer" | "churned" | "archived";
|
|
90
|
+
/** Email deliverability status for a contact. */
|
|
78
91
|
type EmailStatus = "subscribed" | "unsubscribed" | "bounced" | "complained";
|
|
92
|
+
/** Input for creating a new contact. */
|
|
79
93
|
interface CreateContactInput {
|
|
80
94
|
email: string;
|
|
81
95
|
first_name?: string;
|
|
@@ -100,6 +114,7 @@ interface CreateContactInput {
|
|
|
100
114
|
}[];
|
|
101
115
|
};
|
|
102
116
|
}
|
|
117
|
+
/** Input for updating one or more fields on a contact. */
|
|
103
118
|
interface UpdateContactInput {
|
|
104
119
|
email?: string;
|
|
105
120
|
first_name?: string;
|
|
@@ -114,12 +129,14 @@ interface UpdateContactInput {
|
|
|
114
129
|
labels?: string[];
|
|
115
130
|
custom_fields?: Record<string, unknown>;
|
|
116
131
|
}
|
|
132
|
+
/** Options for listing contacts with pagination and filters. */
|
|
117
133
|
interface ListContactsOptions extends PaginationOptions {
|
|
118
134
|
status?: ContactStatus;
|
|
119
135
|
email_status?: EmailStatus;
|
|
120
136
|
label_ids?: string[];
|
|
121
137
|
search?: string;
|
|
122
138
|
}
|
|
139
|
+
/** A single contact record for bulk import. */
|
|
123
140
|
interface ImportContactInput {
|
|
124
141
|
email: string;
|
|
125
142
|
first_name?: string;
|
|
@@ -130,11 +147,13 @@ interface ImportContactInput {
|
|
|
130
147
|
label_ids?: string[];
|
|
131
148
|
status?: string;
|
|
132
149
|
}
|
|
150
|
+
/** Summary returned after a bulk contact import. */
|
|
133
151
|
interface ImportContactsResult {
|
|
134
152
|
added: number;
|
|
135
153
|
skipped: number;
|
|
136
154
|
total: number;
|
|
137
155
|
}
|
|
156
|
+
/** A contact activity event on the timeline. */
|
|
138
157
|
interface Activity {
|
|
139
158
|
id: string;
|
|
140
159
|
type: string;
|
|
@@ -145,10 +164,12 @@ interface Activity {
|
|
|
145
164
|
metadata: unknown;
|
|
146
165
|
created_at: string | null;
|
|
147
166
|
}
|
|
167
|
+
/** Input for adding a text note to a contact's timeline. */
|
|
148
168
|
interface AddNoteInput {
|
|
149
169
|
content: string;
|
|
150
170
|
}
|
|
151
171
|
|
|
172
|
+
/** Manage contacts in the workspace CRM. */
|
|
152
173
|
declare class Contacts {
|
|
153
174
|
private client;
|
|
154
175
|
constructor(client: BaseClient);
|
|
@@ -170,6 +191,7 @@ declare class Contacts {
|
|
|
170
191
|
import(contacts: ImportContactInput[]): Promise<ApiResponse<ImportContactsResult>>;
|
|
171
192
|
}
|
|
172
193
|
|
|
194
|
+
/** A sponsorship or brand deal in the workspace. */
|
|
173
195
|
interface Deal {
|
|
174
196
|
id: string;
|
|
175
197
|
title: string;
|
|
@@ -188,16 +210,21 @@ interface Deal {
|
|
|
188
210
|
created_at: string | null;
|
|
189
211
|
updated_at: string | null;
|
|
190
212
|
}
|
|
213
|
+
/** Result returned after creating a deal. */
|
|
191
214
|
interface DealCreateResult {
|
|
192
215
|
id: string;
|
|
193
216
|
}
|
|
217
|
+
/** Result returned after updating a deal. */
|
|
194
218
|
interface DealUpdateResult {
|
|
195
219
|
success: true;
|
|
196
220
|
}
|
|
221
|
+
/** Result returned after deleting a deal. */
|
|
197
222
|
interface DealRemoveResult {
|
|
198
223
|
success: true;
|
|
199
224
|
}
|
|
225
|
+
/** Lifecycle stage of a sponsorship deal. */
|
|
200
226
|
type DealStatus = "draft" | "open" | "won" | "lost" | "negotiating" | "proposal_sent" | "on_hold" | "churned";
|
|
227
|
+
/** Input for creating a new deal. */
|
|
201
228
|
interface CreateDealInput {
|
|
202
229
|
title: string;
|
|
203
230
|
description?: string;
|
|
@@ -212,6 +239,7 @@ interface CreateDealInput {
|
|
|
212
239
|
end_date?: string;
|
|
213
240
|
notes?: string;
|
|
214
241
|
}
|
|
242
|
+
/** Input for updating one or more fields on a deal. */
|
|
215
243
|
interface UpdateDealInput {
|
|
216
244
|
title?: string;
|
|
217
245
|
description?: string;
|
|
@@ -227,11 +255,13 @@ interface UpdateDealInput {
|
|
|
227
255
|
end_date?: string;
|
|
228
256
|
notes?: string;
|
|
229
257
|
}
|
|
258
|
+
/** Options for listing deals with pagination and filters. */
|
|
230
259
|
interface ListDealsOptions extends PaginationOptions {
|
|
231
260
|
status?: DealStatus;
|
|
232
261
|
search?: string;
|
|
233
262
|
}
|
|
234
263
|
|
|
264
|
+
/** Manage sponsorship deals in the workspace. */
|
|
235
265
|
declare class Deals {
|
|
236
266
|
private client;
|
|
237
267
|
constructor(client: BaseClient);
|
|
@@ -247,6 +277,7 @@ declare class Deals {
|
|
|
247
277
|
remove(id: string): Promise<ApiResponse<DealRemoveResult>>;
|
|
248
278
|
}
|
|
249
279
|
|
|
280
|
+
/** Input for sending a transactional email via a template. */
|
|
250
281
|
interface SendEmailInput {
|
|
251
282
|
template_slug: string;
|
|
252
283
|
to: string;
|
|
@@ -256,10 +287,12 @@ interface SendEmailInput {
|
|
|
256
287
|
variables?: Record<string, string>;
|
|
257
288
|
contact_id?: string;
|
|
258
289
|
}
|
|
290
|
+
/** Result returned after queuing a transactional email send (HTTP 202). */
|
|
259
291
|
interface EmailSendResult {
|
|
260
292
|
id: string;
|
|
261
293
|
status: string;
|
|
262
294
|
}
|
|
295
|
+
/** Full record for a sent email, including delivery timestamps. */
|
|
263
296
|
interface EmailSend {
|
|
264
297
|
id: string;
|
|
265
298
|
status: string;
|
|
@@ -275,6 +308,7 @@ interface EmailSend {
|
|
|
275
308
|
clicked_at: string | null;
|
|
276
309
|
error_message: string | null;
|
|
277
310
|
}
|
|
311
|
+
/** Input for sending the same template to multiple recipients (max 100). */
|
|
278
312
|
interface BatchSendInput {
|
|
279
313
|
template_slug: string;
|
|
280
314
|
default_locale?: string;
|
|
@@ -285,6 +319,7 @@ interface BatchSendInput {
|
|
|
285
319
|
variables?: Record<string, string>;
|
|
286
320
|
}[];
|
|
287
321
|
}
|
|
322
|
+
/** Summary returned after queuing a batch email send. */
|
|
288
323
|
interface BatchSendSummary {
|
|
289
324
|
batch_id: string;
|
|
290
325
|
total: number;
|
|
@@ -293,6 +328,7 @@ interface BatchSendSummary {
|
|
|
293
328
|
}
|
|
294
329
|
/** @deprecated Use `BatchSendSummary` for `emails.batch()` responses. */
|
|
295
330
|
type BatchSendResult = BatchSendSummary;
|
|
331
|
+
/** An email template stored in the workspace. */
|
|
296
332
|
interface EmailTemplate {
|
|
297
333
|
id: string;
|
|
298
334
|
name: string;
|
|
@@ -310,6 +346,7 @@ interface EmailTemplate {
|
|
|
310
346
|
created_at: string | null;
|
|
311
347
|
updated_at: string | null;
|
|
312
348
|
}
|
|
349
|
+
/** Full template detail including per-locale content. */
|
|
313
350
|
interface EmailTemplateDetail extends EmailTemplate {
|
|
314
351
|
html_content: string | null;
|
|
315
352
|
text_content: string | null;
|
|
@@ -328,11 +365,13 @@ interface EmailTemplateDetail extends EmailTemplate {
|
|
|
328
365
|
preview_text: string | null;
|
|
329
366
|
}[];
|
|
330
367
|
}
|
|
368
|
+
/** Options for fetching a template with locale resolution. */
|
|
331
369
|
interface GetTemplateOptions {
|
|
332
370
|
locale?: string;
|
|
333
371
|
fallback_locale?: string;
|
|
334
372
|
}
|
|
335
373
|
|
|
374
|
+
/** Manage email templates stored in the workspace. */
|
|
336
375
|
declare class EmailTemplates {
|
|
337
376
|
private client;
|
|
338
377
|
constructor(client: BaseClient);
|
|
@@ -341,6 +380,7 @@ declare class EmailTemplates {
|
|
|
341
380
|
/** Get a specific email template by slug, optionally with locale resolution. */
|
|
342
381
|
get(slug: string, options?: GetTemplateOptions): Promise<ApiResponse<EmailTemplateDetail>>;
|
|
343
382
|
}
|
|
383
|
+
/** Send transactional emails and manage templates. */
|
|
344
384
|
declare class Emails {
|
|
345
385
|
private client;
|
|
346
386
|
readonly templates: EmailTemplates;
|
|
@@ -353,6 +393,7 @@ declare class Emails {
|
|
|
353
393
|
batch(input: BatchSendInput): Promise<ApiResponse<BatchSendSummary>>;
|
|
354
394
|
}
|
|
355
395
|
|
|
396
|
+
/** A workspace data export request and its current status. */
|
|
356
397
|
interface GdprExport {
|
|
357
398
|
id: string;
|
|
358
399
|
request_type: string;
|
|
@@ -363,7 +404,9 @@ interface GdprExport {
|
|
|
363
404
|
download_url?: string | null;
|
|
364
405
|
expires_at?: string | null;
|
|
365
406
|
}
|
|
407
|
+
/** GDPR consent category. */
|
|
366
408
|
type ConsentType = "marketing_email" | "analytics_tracking" | "third_party_sharing";
|
|
409
|
+
/** Input for recording a GDPR consent decision for a contact. */
|
|
367
410
|
interface RecordConsentInput {
|
|
368
411
|
email: string;
|
|
369
412
|
consent_type: ConsentType;
|
|
@@ -373,6 +416,7 @@ interface RecordConsentInput {
|
|
|
373
416
|
consent_text?: string;
|
|
374
417
|
version?: string;
|
|
375
418
|
}
|
|
419
|
+
/** A stored consent record for a contact. */
|
|
376
420
|
interface ConsentRecord {
|
|
377
421
|
id: string;
|
|
378
422
|
email: string;
|
|
@@ -383,11 +427,13 @@ interface ConsentRecord {
|
|
|
383
427
|
source?: string;
|
|
384
428
|
version?: string;
|
|
385
429
|
}
|
|
430
|
+
/** Result returned after recording a consent decision. */
|
|
386
431
|
interface ConsentResult {
|
|
387
432
|
id: string;
|
|
388
433
|
}
|
|
389
434
|
/** @deprecated Use `ConsentRecord[]` for `gdpr.getConsent()` responses. */
|
|
390
435
|
type ContactConsents = ConsentRecord[];
|
|
436
|
+
/** Input for recording cookie consent from an external site. */
|
|
391
437
|
interface CookieConsentInput {
|
|
392
438
|
domain: string;
|
|
393
439
|
consentStatus: "granted" | "denied" | "partial" | string;
|
|
@@ -402,6 +448,7 @@ interface CookieConsentInput {
|
|
|
402
448
|
[key: string]: CookieCategoryConsent | undefined;
|
|
403
449
|
};
|
|
404
450
|
}
|
|
451
|
+
/** Consent decision and optional cookie records for a single cookie category. */
|
|
405
452
|
interface CookieCategoryConsent {
|
|
406
453
|
allowed: boolean;
|
|
407
454
|
cookieRecords?: {
|
|
@@ -411,6 +458,7 @@ interface CookieCategoryConsent {
|
|
|
411
458
|
}[];
|
|
412
459
|
}
|
|
413
460
|
|
|
461
|
+
/** Manage GDPR compliance — data exports, consent records, and cookie consent. */
|
|
414
462
|
declare class Gdpr {
|
|
415
463
|
private client;
|
|
416
464
|
constructor(client: BaseClient);
|
|
@@ -434,6 +482,7 @@ declare class Gdpr {
|
|
|
434
482
|
}>;
|
|
435
483
|
}
|
|
436
484
|
|
|
485
|
+
/** A post in the workspace (list view). */
|
|
437
486
|
interface Post {
|
|
438
487
|
id: string;
|
|
439
488
|
type: PostType;
|
|
@@ -449,7 +498,9 @@ interface Post {
|
|
|
449
498
|
created_at: string | null;
|
|
450
499
|
updated_at: string | null;
|
|
451
500
|
}
|
|
501
|
+
/** Content format / distribution channel type for a post. */
|
|
452
502
|
type PostType = "social" | "newsletter" | "blog";
|
|
503
|
+
/** Per-channel variant of a post with publishing state. */
|
|
453
504
|
interface PostVariant {
|
|
454
505
|
id: string;
|
|
455
506
|
channel_id: string;
|
|
@@ -463,9 +514,11 @@ interface PostVariant {
|
|
|
463
514
|
permalink: string | null;
|
|
464
515
|
error: string | null;
|
|
465
516
|
}
|
|
517
|
+
/** Full post detail including per-channel variants. */
|
|
466
518
|
interface PostDetail extends Post {
|
|
467
519
|
variants: PostVariant[];
|
|
468
520
|
}
|
|
521
|
+
/** A connected publishing channel in the workspace. */
|
|
469
522
|
interface Channel {
|
|
470
523
|
id: string;
|
|
471
524
|
platform: string | null;
|
|
@@ -474,33 +527,40 @@ interface Channel {
|
|
|
474
527
|
state: string;
|
|
475
528
|
connected_at: string | null;
|
|
476
529
|
}
|
|
530
|
+
/** Input for creating a new post. */
|
|
477
531
|
interface CreatePostInput {
|
|
478
532
|
type?: PostType;
|
|
479
533
|
title?: string;
|
|
480
534
|
content: string;
|
|
481
535
|
channel_ids: string[];
|
|
482
536
|
}
|
|
537
|
+
/** Input for updating a draft post's title or content. */
|
|
483
538
|
interface UpdatePostInput {
|
|
484
539
|
title?: string;
|
|
485
540
|
content?: string;
|
|
486
541
|
}
|
|
542
|
+
/** Input for scheduling a post for future publication. */
|
|
487
543
|
interface SchedulePostInput {
|
|
488
544
|
/** Unix timestamp (ms) or ISO datetime string. */
|
|
489
545
|
scheduled_at: number | string;
|
|
490
546
|
}
|
|
547
|
+
/** Options for listing posts with pagination and filters. */
|
|
491
548
|
interface ListPostsOptions extends PaginationOptions {
|
|
492
549
|
status?: string;
|
|
493
550
|
type?: PostType;
|
|
494
551
|
}
|
|
552
|
+
/** Result returned after scheduling a post. */
|
|
495
553
|
interface ScheduleResult {
|
|
496
554
|
success: boolean;
|
|
497
555
|
workflow_id: string;
|
|
498
556
|
}
|
|
557
|
+
/** Result returned after publishing a post immediately. */
|
|
499
558
|
interface PublishResult {
|
|
500
559
|
success: boolean;
|
|
501
560
|
workflow_id: string;
|
|
502
561
|
}
|
|
503
562
|
|
|
563
|
+
/** Create and publish posts across connected channels. */
|
|
504
564
|
declare class Posts {
|
|
505
565
|
private client;
|
|
506
566
|
constructor(client: BaseClient);
|
|
@@ -528,6 +588,7 @@ declare class Posts {
|
|
|
528
588
|
channels(): Promise<ApiResponse<Channel[]>>;
|
|
529
589
|
}
|
|
530
590
|
|
|
591
|
+
/** A Medal Social workspace accessible to the authenticated credential. */
|
|
531
592
|
interface Workspace {
|
|
532
593
|
id: string;
|
|
533
594
|
name: string;
|
|
@@ -535,6 +596,7 @@ interface Workspace {
|
|
|
535
596
|
[key: string]: unknown;
|
|
536
597
|
}
|
|
537
598
|
|
|
599
|
+
/** Access workspaces for the authenticated credential. */
|
|
538
600
|
declare class Workspaces {
|
|
539
601
|
private client;
|
|
540
602
|
constructor(client: BaseClient);
|
|
@@ -542,8 +604,9 @@ declare class Workspaces {
|
|
|
542
604
|
list(): Promise<ApiResponse<Workspace[]>>;
|
|
543
605
|
}
|
|
544
606
|
|
|
607
|
+
/** Options for configuring the {@link Medal} client. */
|
|
545
608
|
interface MedalOptions {
|
|
546
|
-
/** Override the base URL (defaults to https://
|
|
609
|
+
/** Override the base URL (defaults to https://io.medalsocial.com). */
|
|
547
610
|
baseUrl?: string;
|
|
548
611
|
/** Request timeout in ms (default 30000). */
|
|
549
612
|
timeout?: number;
|
|
@@ -610,6 +673,7 @@ declare class Medal {
|
|
|
610
673
|
constructor(token: string, options?: MedalOptions);
|
|
611
674
|
}
|
|
612
675
|
|
|
676
|
+
/** Convenience factory — equivalent to `new Medal(apiKey, options)`. */
|
|
613
677
|
declare function createMedalClient(apiKey: string, options?: MedalOptions): Medal;
|
|
614
678
|
|
|
615
679
|
export { type Activity, type AddNoteInput, type ApiResponse, BaseClient, type BatchSendInput, type BatchSendResult, type BatchSendSummary, type Channel, type ConsentRecord, type ConsentResult, type ConsentType, type Contact, type ContactConsents, type ContactCreateResult, type ContactNoteResult, type ContactRemoveResult, type ContactStatus, type ContactUpdateResult, Contacts, type CookieCategoryConsent, type CookieConsentInput, type CreateContactInput, type CreateDealInput, type CreatePostInput, type Deal, type DealCreateResult, type DealRemoveResult, type DealStatus, type DealUpdateResult, Deals, type EmailSend, type EmailSendResult, type EmailStatus, type EmailTemplate, type EmailTemplateDetail, Emails, Gdpr, type GdprExport, type GetTemplateOptions, type ImportContactInput, type ImportContactsResult, type ListContactsOptions, type ListDealsOptions, type ListPostsOptions, Medal, MedalApiError, type MedalOptions, type PaginatedResponse, type PaginationOptions, type Post, type PostDetail, type PostType, type PostVariant, Posts, type PublishResult, type RecordConsentInput, type SchedulePostInput, type ScheduleResult, type SendEmailInput, type UpdateContactInput, type UpdateDealInput, type UpdatePostInput, type Workspace, Workspaces, createMedalClient, Medal as default };
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Configuration for the low-level HTTP client. */
|
|
1
2
|
interface ClientConfig {
|
|
2
3
|
baseUrl: string;
|
|
3
4
|
token: string;
|
|
@@ -10,11 +11,16 @@ interface ClientConfig {
|
|
|
10
11
|
* Handles authentication, retries, timeout, and error parsing.
|
|
11
12
|
*/
|
|
12
13
|
declare class BaseClient {
|
|
14
|
+
/** Resolved client configuration. */
|
|
13
15
|
readonly config: ClientConfig;
|
|
14
16
|
constructor(config: ClientConfig);
|
|
17
|
+
/** Execute an authenticated GET request and return the parsed JSON body. */
|
|
15
18
|
get<T>(path: string, params?: Record<string, string | undefined>): Promise<T>;
|
|
19
|
+
/** Execute an authenticated POST request with a JSON body. */
|
|
16
20
|
post<T>(path: string, body?: unknown): Promise<T>;
|
|
21
|
+
/** Execute an authenticated PATCH request with a JSON body. */
|
|
17
22
|
patch<T>(path: string, body: unknown): Promise<T>;
|
|
23
|
+
/** Execute an authenticated DELETE request. */
|
|
18
24
|
delete<T>(path: string): Promise<T>;
|
|
19
25
|
private buildUrl;
|
|
20
26
|
private request;
|
|
@@ -45,6 +51,7 @@ interface PaginationOptions {
|
|
|
45
51
|
cursor?: string;
|
|
46
52
|
}
|
|
47
53
|
|
|
54
|
+
/** A contact in the workspace CRM. */
|
|
48
55
|
interface Contact {
|
|
49
56
|
id: string;
|
|
50
57
|
email: string;
|
|
@@ -62,20 +69,27 @@ interface Contact {
|
|
|
62
69
|
created_at: string | null;
|
|
63
70
|
updated_at: string | null;
|
|
64
71
|
}
|
|
72
|
+
/** Result returned after creating a contact. */
|
|
65
73
|
interface ContactCreateResult {
|
|
66
74
|
id: string;
|
|
67
75
|
}
|
|
76
|
+
/** Result returned after updating a contact. */
|
|
68
77
|
interface ContactUpdateResult {
|
|
69
78
|
success: true;
|
|
70
79
|
}
|
|
80
|
+
/** Result returned after deleting a contact. */
|
|
71
81
|
interface ContactRemoveResult {
|
|
72
82
|
success: true;
|
|
73
83
|
}
|
|
84
|
+
/** Result returned after adding a note to a contact. */
|
|
74
85
|
interface ContactNoteResult {
|
|
75
86
|
id: string;
|
|
76
87
|
}
|
|
88
|
+
/** Lifecycle stage of a contact in the CRM. */
|
|
77
89
|
type ContactStatus = "lead" | "prospect" | "customer" | "churned" | "archived";
|
|
90
|
+
/** Email deliverability status for a contact. */
|
|
78
91
|
type EmailStatus = "subscribed" | "unsubscribed" | "bounced" | "complained";
|
|
92
|
+
/** Input for creating a new contact. */
|
|
79
93
|
interface CreateContactInput {
|
|
80
94
|
email: string;
|
|
81
95
|
first_name?: string;
|
|
@@ -100,6 +114,7 @@ interface CreateContactInput {
|
|
|
100
114
|
}[];
|
|
101
115
|
};
|
|
102
116
|
}
|
|
117
|
+
/** Input for updating one or more fields on a contact. */
|
|
103
118
|
interface UpdateContactInput {
|
|
104
119
|
email?: string;
|
|
105
120
|
first_name?: string;
|
|
@@ -114,12 +129,14 @@ interface UpdateContactInput {
|
|
|
114
129
|
labels?: string[];
|
|
115
130
|
custom_fields?: Record<string, unknown>;
|
|
116
131
|
}
|
|
132
|
+
/** Options for listing contacts with pagination and filters. */
|
|
117
133
|
interface ListContactsOptions extends PaginationOptions {
|
|
118
134
|
status?: ContactStatus;
|
|
119
135
|
email_status?: EmailStatus;
|
|
120
136
|
label_ids?: string[];
|
|
121
137
|
search?: string;
|
|
122
138
|
}
|
|
139
|
+
/** A single contact record for bulk import. */
|
|
123
140
|
interface ImportContactInput {
|
|
124
141
|
email: string;
|
|
125
142
|
first_name?: string;
|
|
@@ -130,11 +147,13 @@ interface ImportContactInput {
|
|
|
130
147
|
label_ids?: string[];
|
|
131
148
|
status?: string;
|
|
132
149
|
}
|
|
150
|
+
/** Summary returned after a bulk contact import. */
|
|
133
151
|
interface ImportContactsResult {
|
|
134
152
|
added: number;
|
|
135
153
|
skipped: number;
|
|
136
154
|
total: number;
|
|
137
155
|
}
|
|
156
|
+
/** A contact activity event on the timeline. */
|
|
138
157
|
interface Activity {
|
|
139
158
|
id: string;
|
|
140
159
|
type: string;
|
|
@@ -145,10 +164,12 @@ interface Activity {
|
|
|
145
164
|
metadata: unknown;
|
|
146
165
|
created_at: string | null;
|
|
147
166
|
}
|
|
167
|
+
/** Input for adding a text note to a contact's timeline. */
|
|
148
168
|
interface AddNoteInput {
|
|
149
169
|
content: string;
|
|
150
170
|
}
|
|
151
171
|
|
|
172
|
+
/** Manage contacts in the workspace CRM. */
|
|
152
173
|
declare class Contacts {
|
|
153
174
|
private client;
|
|
154
175
|
constructor(client: BaseClient);
|
|
@@ -170,6 +191,7 @@ declare class Contacts {
|
|
|
170
191
|
import(contacts: ImportContactInput[]): Promise<ApiResponse<ImportContactsResult>>;
|
|
171
192
|
}
|
|
172
193
|
|
|
194
|
+
/** A sponsorship or brand deal in the workspace. */
|
|
173
195
|
interface Deal {
|
|
174
196
|
id: string;
|
|
175
197
|
title: string;
|
|
@@ -188,16 +210,21 @@ interface Deal {
|
|
|
188
210
|
created_at: string | null;
|
|
189
211
|
updated_at: string | null;
|
|
190
212
|
}
|
|
213
|
+
/** Result returned after creating a deal. */
|
|
191
214
|
interface DealCreateResult {
|
|
192
215
|
id: string;
|
|
193
216
|
}
|
|
217
|
+
/** Result returned after updating a deal. */
|
|
194
218
|
interface DealUpdateResult {
|
|
195
219
|
success: true;
|
|
196
220
|
}
|
|
221
|
+
/** Result returned after deleting a deal. */
|
|
197
222
|
interface DealRemoveResult {
|
|
198
223
|
success: true;
|
|
199
224
|
}
|
|
225
|
+
/** Lifecycle stage of a sponsorship deal. */
|
|
200
226
|
type DealStatus = "draft" | "open" | "won" | "lost" | "negotiating" | "proposal_sent" | "on_hold" | "churned";
|
|
227
|
+
/** Input for creating a new deal. */
|
|
201
228
|
interface CreateDealInput {
|
|
202
229
|
title: string;
|
|
203
230
|
description?: string;
|
|
@@ -212,6 +239,7 @@ interface CreateDealInput {
|
|
|
212
239
|
end_date?: string;
|
|
213
240
|
notes?: string;
|
|
214
241
|
}
|
|
242
|
+
/** Input for updating one or more fields on a deal. */
|
|
215
243
|
interface UpdateDealInput {
|
|
216
244
|
title?: string;
|
|
217
245
|
description?: string;
|
|
@@ -227,11 +255,13 @@ interface UpdateDealInput {
|
|
|
227
255
|
end_date?: string;
|
|
228
256
|
notes?: string;
|
|
229
257
|
}
|
|
258
|
+
/** Options for listing deals with pagination and filters. */
|
|
230
259
|
interface ListDealsOptions extends PaginationOptions {
|
|
231
260
|
status?: DealStatus;
|
|
232
261
|
search?: string;
|
|
233
262
|
}
|
|
234
263
|
|
|
264
|
+
/** Manage sponsorship deals in the workspace. */
|
|
235
265
|
declare class Deals {
|
|
236
266
|
private client;
|
|
237
267
|
constructor(client: BaseClient);
|
|
@@ -247,6 +277,7 @@ declare class Deals {
|
|
|
247
277
|
remove(id: string): Promise<ApiResponse<DealRemoveResult>>;
|
|
248
278
|
}
|
|
249
279
|
|
|
280
|
+
/** Input for sending a transactional email via a template. */
|
|
250
281
|
interface SendEmailInput {
|
|
251
282
|
template_slug: string;
|
|
252
283
|
to: string;
|
|
@@ -256,10 +287,12 @@ interface SendEmailInput {
|
|
|
256
287
|
variables?: Record<string, string>;
|
|
257
288
|
contact_id?: string;
|
|
258
289
|
}
|
|
290
|
+
/** Result returned after queuing a transactional email send (HTTP 202). */
|
|
259
291
|
interface EmailSendResult {
|
|
260
292
|
id: string;
|
|
261
293
|
status: string;
|
|
262
294
|
}
|
|
295
|
+
/** Full record for a sent email, including delivery timestamps. */
|
|
263
296
|
interface EmailSend {
|
|
264
297
|
id: string;
|
|
265
298
|
status: string;
|
|
@@ -275,6 +308,7 @@ interface EmailSend {
|
|
|
275
308
|
clicked_at: string | null;
|
|
276
309
|
error_message: string | null;
|
|
277
310
|
}
|
|
311
|
+
/** Input for sending the same template to multiple recipients (max 100). */
|
|
278
312
|
interface BatchSendInput {
|
|
279
313
|
template_slug: string;
|
|
280
314
|
default_locale?: string;
|
|
@@ -285,6 +319,7 @@ interface BatchSendInput {
|
|
|
285
319
|
variables?: Record<string, string>;
|
|
286
320
|
}[];
|
|
287
321
|
}
|
|
322
|
+
/** Summary returned after queuing a batch email send. */
|
|
288
323
|
interface BatchSendSummary {
|
|
289
324
|
batch_id: string;
|
|
290
325
|
total: number;
|
|
@@ -293,6 +328,7 @@ interface BatchSendSummary {
|
|
|
293
328
|
}
|
|
294
329
|
/** @deprecated Use `BatchSendSummary` for `emails.batch()` responses. */
|
|
295
330
|
type BatchSendResult = BatchSendSummary;
|
|
331
|
+
/** An email template stored in the workspace. */
|
|
296
332
|
interface EmailTemplate {
|
|
297
333
|
id: string;
|
|
298
334
|
name: string;
|
|
@@ -310,6 +346,7 @@ interface EmailTemplate {
|
|
|
310
346
|
created_at: string | null;
|
|
311
347
|
updated_at: string | null;
|
|
312
348
|
}
|
|
349
|
+
/** Full template detail including per-locale content. */
|
|
313
350
|
interface EmailTemplateDetail extends EmailTemplate {
|
|
314
351
|
html_content: string | null;
|
|
315
352
|
text_content: string | null;
|
|
@@ -328,11 +365,13 @@ interface EmailTemplateDetail extends EmailTemplate {
|
|
|
328
365
|
preview_text: string | null;
|
|
329
366
|
}[];
|
|
330
367
|
}
|
|
368
|
+
/** Options for fetching a template with locale resolution. */
|
|
331
369
|
interface GetTemplateOptions {
|
|
332
370
|
locale?: string;
|
|
333
371
|
fallback_locale?: string;
|
|
334
372
|
}
|
|
335
373
|
|
|
374
|
+
/** Manage email templates stored in the workspace. */
|
|
336
375
|
declare class EmailTemplates {
|
|
337
376
|
private client;
|
|
338
377
|
constructor(client: BaseClient);
|
|
@@ -341,6 +380,7 @@ declare class EmailTemplates {
|
|
|
341
380
|
/** Get a specific email template by slug, optionally with locale resolution. */
|
|
342
381
|
get(slug: string, options?: GetTemplateOptions): Promise<ApiResponse<EmailTemplateDetail>>;
|
|
343
382
|
}
|
|
383
|
+
/** Send transactional emails and manage templates. */
|
|
344
384
|
declare class Emails {
|
|
345
385
|
private client;
|
|
346
386
|
readonly templates: EmailTemplates;
|
|
@@ -353,6 +393,7 @@ declare class Emails {
|
|
|
353
393
|
batch(input: BatchSendInput): Promise<ApiResponse<BatchSendSummary>>;
|
|
354
394
|
}
|
|
355
395
|
|
|
396
|
+
/** A workspace data export request and its current status. */
|
|
356
397
|
interface GdprExport {
|
|
357
398
|
id: string;
|
|
358
399
|
request_type: string;
|
|
@@ -363,7 +404,9 @@ interface GdprExport {
|
|
|
363
404
|
download_url?: string | null;
|
|
364
405
|
expires_at?: string | null;
|
|
365
406
|
}
|
|
407
|
+
/** GDPR consent category. */
|
|
366
408
|
type ConsentType = "marketing_email" | "analytics_tracking" | "third_party_sharing";
|
|
409
|
+
/** Input for recording a GDPR consent decision for a contact. */
|
|
367
410
|
interface RecordConsentInput {
|
|
368
411
|
email: string;
|
|
369
412
|
consent_type: ConsentType;
|
|
@@ -373,6 +416,7 @@ interface RecordConsentInput {
|
|
|
373
416
|
consent_text?: string;
|
|
374
417
|
version?: string;
|
|
375
418
|
}
|
|
419
|
+
/** A stored consent record for a contact. */
|
|
376
420
|
interface ConsentRecord {
|
|
377
421
|
id: string;
|
|
378
422
|
email: string;
|
|
@@ -383,11 +427,13 @@ interface ConsentRecord {
|
|
|
383
427
|
source?: string;
|
|
384
428
|
version?: string;
|
|
385
429
|
}
|
|
430
|
+
/** Result returned after recording a consent decision. */
|
|
386
431
|
interface ConsentResult {
|
|
387
432
|
id: string;
|
|
388
433
|
}
|
|
389
434
|
/** @deprecated Use `ConsentRecord[]` for `gdpr.getConsent()` responses. */
|
|
390
435
|
type ContactConsents = ConsentRecord[];
|
|
436
|
+
/** Input for recording cookie consent from an external site. */
|
|
391
437
|
interface CookieConsentInput {
|
|
392
438
|
domain: string;
|
|
393
439
|
consentStatus: "granted" | "denied" | "partial" | string;
|
|
@@ -402,6 +448,7 @@ interface CookieConsentInput {
|
|
|
402
448
|
[key: string]: CookieCategoryConsent | undefined;
|
|
403
449
|
};
|
|
404
450
|
}
|
|
451
|
+
/** Consent decision and optional cookie records for a single cookie category. */
|
|
405
452
|
interface CookieCategoryConsent {
|
|
406
453
|
allowed: boolean;
|
|
407
454
|
cookieRecords?: {
|
|
@@ -411,6 +458,7 @@ interface CookieCategoryConsent {
|
|
|
411
458
|
}[];
|
|
412
459
|
}
|
|
413
460
|
|
|
461
|
+
/** Manage GDPR compliance — data exports, consent records, and cookie consent. */
|
|
414
462
|
declare class Gdpr {
|
|
415
463
|
private client;
|
|
416
464
|
constructor(client: BaseClient);
|
|
@@ -434,6 +482,7 @@ declare class Gdpr {
|
|
|
434
482
|
}>;
|
|
435
483
|
}
|
|
436
484
|
|
|
485
|
+
/** A post in the workspace (list view). */
|
|
437
486
|
interface Post {
|
|
438
487
|
id: string;
|
|
439
488
|
type: PostType;
|
|
@@ -449,7 +498,9 @@ interface Post {
|
|
|
449
498
|
created_at: string | null;
|
|
450
499
|
updated_at: string | null;
|
|
451
500
|
}
|
|
501
|
+
/** Content format / distribution channel type for a post. */
|
|
452
502
|
type PostType = "social" | "newsletter" | "blog";
|
|
503
|
+
/** Per-channel variant of a post with publishing state. */
|
|
453
504
|
interface PostVariant {
|
|
454
505
|
id: string;
|
|
455
506
|
channel_id: string;
|
|
@@ -463,9 +514,11 @@ interface PostVariant {
|
|
|
463
514
|
permalink: string | null;
|
|
464
515
|
error: string | null;
|
|
465
516
|
}
|
|
517
|
+
/** Full post detail including per-channel variants. */
|
|
466
518
|
interface PostDetail extends Post {
|
|
467
519
|
variants: PostVariant[];
|
|
468
520
|
}
|
|
521
|
+
/** A connected publishing channel in the workspace. */
|
|
469
522
|
interface Channel {
|
|
470
523
|
id: string;
|
|
471
524
|
platform: string | null;
|
|
@@ -474,33 +527,40 @@ interface Channel {
|
|
|
474
527
|
state: string;
|
|
475
528
|
connected_at: string | null;
|
|
476
529
|
}
|
|
530
|
+
/** Input for creating a new post. */
|
|
477
531
|
interface CreatePostInput {
|
|
478
532
|
type?: PostType;
|
|
479
533
|
title?: string;
|
|
480
534
|
content: string;
|
|
481
535
|
channel_ids: string[];
|
|
482
536
|
}
|
|
537
|
+
/** Input for updating a draft post's title or content. */
|
|
483
538
|
interface UpdatePostInput {
|
|
484
539
|
title?: string;
|
|
485
540
|
content?: string;
|
|
486
541
|
}
|
|
542
|
+
/** Input for scheduling a post for future publication. */
|
|
487
543
|
interface SchedulePostInput {
|
|
488
544
|
/** Unix timestamp (ms) or ISO datetime string. */
|
|
489
545
|
scheduled_at: number | string;
|
|
490
546
|
}
|
|
547
|
+
/** Options for listing posts with pagination and filters. */
|
|
491
548
|
interface ListPostsOptions extends PaginationOptions {
|
|
492
549
|
status?: string;
|
|
493
550
|
type?: PostType;
|
|
494
551
|
}
|
|
552
|
+
/** Result returned after scheduling a post. */
|
|
495
553
|
interface ScheduleResult {
|
|
496
554
|
success: boolean;
|
|
497
555
|
workflow_id: string;
|
|
498
556
|
}
|
|
557
|
+
/** Result returned after publishing a post immediately. */
|
|
499
558
|
interface PublishResult {
|
|
500
559
|
success: boolean;
|
|
501
560
|
workflow_id: string;
|
|
502
561
|
}
|
|
503
562
|
|
|
563
|
+
/** Create and publish posts across connected channels. */
|
|
504
564
|
declare class Posts {
|
|
505
565
|
private client;
|
|
506
566
|
constructor(client: BaseClient);
|
|
@@ -528,6 +588,7 @@ declare class Posts {
|
|
|
528
588
|
channels(): Promise<ApiResponse<Channel[]>>;
|
|
529
589
|
}
|
|
530
590
|
|
|
591
|
+
/** A Medal Social workspace accessible to the authenticated credential. */
|
|
531
592
|
interface Workspace {
|
|
532
593
|
id: string;
|
|
533
594
|
name: string;
|
|
@@ -535,6 +596,7 @@ interface Workspace {
|
|
|
535
596
|
[key: string]: unknown;
|
|
536
597
|
}
|
|
537
598
|
|
|
599
|
+
/** Access workspaces for the authenticated credential. */
|
|
538
600
|
declare class Workspaces {
|
|
539
601
|
private client;
|
|
540
602
|
constructor(client: BaseClient);
|
|
@@ -542,8 +604,9 @@ declare class Workspaces {
|
|
|
542
604
|
list(): Promise<ApiResponse<Workspace[]>>;
|
|
543
605
|
}
|
|
544
606
|
|
|
607
|
+
/** Options for configuring the {@link Medal} client. */
|
|
545
608
|
interface MedalOptions {
|
|
546
|
-
/** Override the base URL (defaults to https://
|
|
609
|
+
/** Override the base URL (defaults to https://io.medalsocial.com). */
|
|
547
610
|
baseUrl?: string;
|
|
548
611
|
/** Request timeout in ms (default 30000). */
|
|
549
612
|
timeout?: number;
|
|
@@ -610,6 +673,7 @@ declare class Medal {
|
|
|
610
673
|
constructor(token: string, options?: MedalOptions);
|
|
611
674
|
}
|
|
612
675
|
|
|
676
|
+
/** Convenience factory — equivalent to `new Medal(apiKey, options)`. */
|
|
613
677
|
declare function createMedalClient(apiKey: string, options?: MedalOptions): Medal;
|
|
614
678
|
|
|
615
679
|
export { type Activity, type AddNoteInput, type ApiResponse, BaseClient, type BatchSendInput, type BatchSendResult, type BatchSendSummary, type Channel, type ConsentRecord, type ConsentResult, type ConsentType, type Contact, type ContactConsents, type ContactCreateResult, type ContactNoteResult, type ContactRemoveResult, type ContactStatus, type ContactUpdateResult, Contacts, type CookieCategoryConsent, type CookieConsentInput, type CreateContactInput, type CreateDealInput, type CreatePostInput, type Deal, type DealCreateResult, type DealRemoveResult, type DealStatus, type DealUpdateResult, Deals, type EmailSend, type EmailSendResult, type EmailStatus, type EmailTemplate, type EmailTemplateDetail, Emails, Gdpr, type GdprExport, type GetTemplateOptions, type ImportContactInput, type ImportContactsResult, type ListContactsOptions, type ListDealsOptions, type ListPostsOptions, Medal, MedalApiError, type MedalOptions, type PaginatedResponse, type PaginationOptions, type Post, type PostDetail, type PostType, type PostVariant, Posts, type PublishResult, type RecordConsentInput, type SchedulePostInput, type ScheduleResult, type SendEmailInput, type UpdateContactInput, type UpdateDealInput, type UpdatePostInput, type Workspace, Workspaces, createMedalClient, Medal as default };
|
package/dist/src/index.js
CHANGED
|
@@ -50,14 +50,17 @@ var MedalApiError = class extends Error {
|
|
|
50
50
|
|
|
51
51
|
// src/client.ts
|
|
52
52
|
var BaseClient = class {
|
|
53
|
+
/** Resolved client configuration. */
|
|
53
54
|
config;
|
|
54
55
|
constructor(config) {
|
|
55
56
|
this.config = config;
|
|
56
57
|
}
|
|
58
|
+
/** Execute an authenticated GET request and return the parsed JSON body. */
|
|
57
59
|
async get(path, params) {
|
|
58
60
|
const url = this.buildUrl(path, params);
|
|
59
61
|
return this.request(url, { method: "GET" });
|
|
60
62
|
}
|
|
63
|
+
/** Execute an authenticated POST request with a JSON body. */
|
|
61
64
|
async post(path, body) {
|
|
62
65
|
return this.request(this.buildUrl(path), {
|
|
63
66
|
method: "POST",
|
|
@@ -65,6 +68,7 @@ var BaseClient = class {
|
|
|
65
68
|
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
66
69
|
});
|
|
67
70
|
}
|
|
71
|
+
/** Execute an authenticated PATCH request with a JSON body. */
|
|
68
72
|
async patch(path, body) {
|
|
69
73
|
return this.request(this.buildUrl(path), {
|
|
70
74
|
method: "PATCH",
|
|
@@ -72,6 +76,7 @@ var BaseClient = class {
|
|
|
72
76
|
body: JSON.stringify(body)
|
|
73
77
|
});
|
|
74
78
|
}
|
|
79
|
+
/** Execute an authenticated DELETE request. */
|
|
75
80
|
async delete(path) {
|
|
76
81
|
return this.request(this.buildUrl(path), { method: "DELETE" });
|
|
77
82
|
}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/types/common.ts","../../src/client.ts","../../src/resources/contacts.ts","../../src/resources/deals.ts","../../src/resources/emails.ts","../../src/resources/gdpr.ts","../../src/resources/posts.ts","../../src/resources/workspaces.ts"],"sourcesContent":["import { BaseClient } from \"./client\";\nimport { Contacts } from \"./resources/contacts\";\nimport { Deals } from \"./resources/deals\";\nimport { Emails } from \"./resources/emails\";\nimport { Gdpr } from \"./resources/gdpr\";\nimport { Posts } from \"./resources/posts\";\nimport { Workspaces } from \"./resources/workspaces\";\n\nexport interface MedalOptions {\n /** Override the base URL (defaults to https://api.medalsocial.com). */\n baseUrl?: string;\n /** Request timeout in ms (default 30000). */\n timeout?: number;\n /**\n * Workspace ID — required for OAuth access tokens, ignored for API keys.\n * API keys are scoped to a single workspace, so the workspace is inferred.\n * OAuth tokens can access multiple workspaces, so you must specify which one.\n */\n workspaceId?: string;\n}\n\n/**\n * Medal Social SDK client.\n *\n * Supports both API key and OAuth access token authentication:\n *\n * @example API Key (recommended for server-side)\n * ```ts\n * import { Medal } from '@medalsocial/sdk';\n *\n * // API keys start with medal_ and are scoped to one workspace\n * const medal = new Medal('medal_xxx');\n * ```\n *\n * @example OAuth Access Token\n * ```ts\n * // OAuth tokens require a workspaceId\n * const medal = new Medal('oauth_access_token', {\n * workspaceId: 'workspace_id_here',\n * });\n * ```\n *\n * @example Full usage\n * ```ts\n * const medal = new Medal('medal_xxx');\n *\n * // Posts — create, schedule, publish\n * const { data: post } = await medal.posts.create({\n * content: 'Hello world!',\n * channel_ids: ['ch_1'],\n * });\n * await medal.posts.schedule(post.id, { scheduled_at: '2026-03-15T10:00:00Z' });\n *\n * // Emails — send transactional emails\n * await medal.emails.send({\n * template_slug: 'welcome',\n * to: 'user@example.com',\n * variables: { name: 'John' },\n * });\n *\n * // Contacts, Deals, GDPR, Workspaces\n * const contacts = await medal.contacts.list({ status: 'lead' });\n * const { data: deal } = await medal.deals.create({ title: 'Acme', value: 50000 });\n * await medal.gdpr.recordConsent({ email: 'u@x.com', consent_type: 'marketing_email', granted: true });\n * const { data: workspaces } = await medal.workspaces.list();\n * ```\n */\nexport class Medal {\n readonly emails: Emails;\n readonly contacts: Contacts;\n readonly deals: Deals;\n readonly gdpr: Gdpr;\n readonly posts: Posts;\n readonly workspaces: Workspaces;\n\n constructor(token: string, options?: MedalOptions) {\n if (!token) {\n throw new Error(\n \"Authentication token is required. Pass your medal_xxx API key or OAuth access token as the first argument.\",\n );\n }\n\n const client = new BaseClient({\n baseUrl: (options?.baseUrl ?? \"https://io.medalsocial.com\").replace(/\\/$/, \"\"),\n token,\n workspaceId: options?.workspaceId,\n timeout: options?.timeout ?? 30000,\n userAgent: \"medalsocial-sdk/1.0.0 (+https://github.com/Medal-Social/MedalSocial)\",\n });\n\n this.emails = new Emails(client);\n this.contacts = new Contacts(client);\n this.deals = new Deals(client);\n this.gdpr = new Gdpr(client);\n this.posts = new Posts(client);\n this.workspaces = new Workspaces(client);\n }\n}\n\n// Re-export all types\nexport { MedalApiError } from \"./types/common\";\nexport type { ApiResponse, PaginatedResponse, PaginationOptions } from \"./types/common\";\nexport type {\n SendEmailInput,\n EmailSendResult,\n EmailSend,\n BatchSendInput,\n BatchSendSummary,\n BatchSendResult,\n EmailTemplate,\n EmailTemplateDetail,\n GetTemplateOptions,\n} from \"./types/emails\";\nexport type {\n Contact,\n ContactCreateResult,\n ContactUpdateResult,\n ContactRemoveResult,\n ContactNoteResult,\n ContactStatus,\n EmailStatus,\n CreateContactInput,\n UpdateContactInput,\n ListContactsOptions,\n ImportContactInput,\n ImportContactsResult,\n Activity,\n AddNoteInput,\n} from \"./types/contacts\";\nexport type {\n Deal,\n DealCreateResult,\n DealUpdateResult,\n DealRemoveResult,\n DealStatus,\n CreateDealInput,\n UpdateDealInput,\n ListDealsOptions,\n} from \"./types/deals\";\nexport type {\n GdprExport,\n ConsentType,\n RecordConsentInput,\n ConsentRecord,\n ConsentResult,\n ContactConsents,\n CookieConsentInput,\n CookieCategoryConsent,\n} from \"./types/gdpr\";\nexport type {\n Post,\n PostType,\n PostVariant,\n PostDetail,\n Channel,\n CreatePostInput,\n UpdatePostInput,\n SchedulePostInput,\n ListPostsOptions,\n ScheduleResult,\n PublishResult,\n} from \"./types/posts\";\nexport type { Workspace } from \"./types/workspaces\";\n\n// Resource class re-exports (for advanced usage)\nexport { Emails } from \"./resources/emails\";\nexport { Contacts } from \"./resources/contacts\";\nexport { Deals } from \"./resources/deals\";\nexport { Gdpr } from \"./resources/gdpr\";\nexport { Posts } from \"./resources/posts\";\nexport { Workspaces } from \"./resources/workspaces\";\nexport { BaseClient } from \"./client\";\n\nexport function createMedalClient(apiKey: string, options?: MedalOptions): Medal {\n return new Medal(apiKey, options);\n}\n\nexport default Medal;\n","/** Successful API response wrapper */\nexport interface ApiResponse<T> {\n data: T;\n}\n\n/** Paginated API response */\nexport interface PaginatedResponse<T> {\n data: T[];\n pagination: {\n has_more: boolean;\n next_cursor: string | null;\n };\n}\n\n/** API error thrown by the client */\nexport class MedalApiError extends Error {\n readonly status: number;\n readonly code: string;\n readonly details?: unknown;\n\n constructor(status: number, code: string, message: string, details?: unknown) {\n super(message);\n this.name = \"MedalApiError\";\n this.status = status;\n this.code = code;\n this.details = details;\n }\n}\n\n/** Pagination options for list endpoints */\nexport interface PaginationOptions {\n limit?: number;\n cursor?: string;\n}\n","import { MedalApiError } from \"./types/common\";\n\nexport interface ClientConfig {\n baseUrl: string;\n token: string;\n workspaceId?: string;\n timeout: number;\n userAgent: string;\n}\n\n/**\n * Low-level HTTP client used by all resource classes.\n * Handles authentication, retries, timeout, and error parsing.\n */\nexport class BaseClient {\n readonly config: ClientConfig;\n\n constructor(config: ClientConfig) {\n this.config = config;\n }\n\n async get<T>(path: string, params?: Record<string, string | undefined>): Promise<T> {\n const url = this.buildUrl(path, params);\n return this.request<T>(url, { method: \"GET\" });\n }\n\n async post<T>(path: string, body?: unknown): Promise<T> {\n return this.request<T>(this.buildUrl(path), {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n }\n\n async patch<T>(path: string, body: unknown): Promise<T> {\n return this.request<T>(this.buildUrl(path), {\n method: \"PATCH\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(body),\n });\n }\n\n async delete<T>(path: string): Promise<T> {\n return this.request<T>(this.buildUrl(path), { method: \"DELETE\" });\n }\n\n private buildUrl(path: string, params?: Record<string, string | undefined>): string {\n const url = new URL(`${this.config.baseUrl}${path}`);\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n url.searchParams.set(key, value);\n }\n }\n }\n return url.toString();\n }\n\n private async request<T>(url: string, init: RequestInit): Promise<T> {\n const maxAttempts = 3;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n const headers = new Headers(init.headers);\n headers.set(\"authorization\", `Bearer ${this.config.token}`);\n if (this.config.workspaceId) {\n headers.set(\"x-workspace-id\", this.config.workspaceId);\n }\n try {\n headers.set(\"user-agent\", this.config.userAgent);\n } catch {\n // Browsers disallow setting user-agent\n }\n\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.config.timeout);\n\n let res: Response;\n try {\n res = await fetch(url, { ...init, headers, signal: controller.signal });\n } finally {\n clearTimeout(timeout);\n }\n\n // Retry on 429 / 5xx (but not on the final attempt)\n if (\n (res.status === 429 || (res.status >= 500 && res.status <= 599)) &&\n attempt < maxAttempts\n ) {\n const retryAfter = res.headers.get(\"retry-after\");\n let delayMs = 0;\n if (retryAfter) {\n const seconds = Number(retryAfter);\n delayMs = Number.isFinite(seconds) ? seconds * 1000 : 0;\n }\n if (delayMs <= 0) {\n delayMs = 250 * attempt;\n }\n await new Promise((r) => setTimeout(r, delayMs));\n continue;\n }\n\n // Parse response\n const text = await res.text();\n let parsed: unknown;\n try {\n parsed = text ? JSON.parse(text) : undefined;\n } catch {\n parsed = text;\n }\n\n if (!res.ok) {\n const body = parsed as\n | { error?: { code?: string; message?: string; details?: unknown } }\n | undefined;\n throw new MedalApiError(\n res.status,\n body?.error?.code ?? \"UNKNOWN_ERROR\",\n body?.error?.message ?? `HTTP ${res.status}: ${res.statusText}`,\n body?.error?.details,\n );\n }\n\n return parsed as T;\n }\n\n /* v8 ignore next -- unreachable: loop always returns or throws */\n throw new Error(\"Request failed after retries\");\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse, PaginatedResponse, PaginationOptions } from \"../types/common\";\nimport type {\n Activity,\n AddNoteInput,\n Contact,\n ContactCreateResult,\n ContactNoteResult,\n ContactRemoveResult,\n ContactUpdateResult,\n CreateContactInput,\n ImportContactInput,\n ImportContactsResult,\n ListContactsOptions,\n UpdateContactInput,\n} from \"../types/contacts\";\n\nexport class Contacts {\n constructor(private client: BaseClient) {}\n\n /** List contacts with cursor-based pagination and optional filters. */\n async list(options?: ListContactsOptions): Promise<PaginatedResponse<Contact>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n if (options?.status) params.status = options.status;\n if (options?.email_status) params.email_status = options.email_status;\n if (options?.label_ids) params.label_ids = options.label_ids.join(\",\");\n if (options?.search) params.search = options.search;\n return this.client.get(\"/api/v1/contacts\", params);\n }\n\n /** Create a new contact. Email must be unique in the workspace. */\n async create(input: CreateContactInput): Promise<ApiResponse<ContactCreateResult>> {\n return this.client.post(\"/api/v1/contacts\", input);\n }\n\n /** Get a contact by ID. */\n async get(id: string): Promise<ApiResponse<Contact>> {\n return this.client.get(`/api/v1/contacts/${encodeURIComponent(id)}`);\n }\n\n /** Update one or more fields on a contact. */\n async update(id: string, input: UpdateContactInput): Promise<ApiResponse<ContactUpdateResult>> {\n return this.client.patch(`/api/v1/contacts/${encodeURIComponent(id)}`, input);\n }\n\n /** Permanently delete a contact. */\n async remove(id: string): Promise<ApiResponse<ContactRemoveResult>> {\n return this.client.delete(`/api/v1/contacts/${encodeURIComponent(id)}`);\n }\n\n /** Get the activity timeline for a contact. */\n async activities(id: string, options?: PaginationOptions): Promise<PaginatedResponse<Activity>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n return this.client.get(`/api/v1/contacts/${encodeURIComponent(id)}/activities`, params);\n }\n\n /** Add a note to a contact's timeline. */\n async addNote(id: string, input: AddNoteInput): Promise<ApiResponse<ContactNoteResult>> {\n return this.client.post(`/api/v1/contacts/${encodeURIComponent(id)}/notes`, input);\n }\n\n /** Bulk import contacts (max 500). Duplicates are skipped. */\n async import(contacts: ImportContactInput[]): Promise<ApiResponse<ImportContactsResult>> {\n return this.client.post(\"/api/v1/contacts/import\", { contacts });\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse, PaginatedResponse } from \"../types/common\";\nimport type {\n CreateDealInput,\n Deal,\n DealCreateResult,\n DealRemoveResult,\n DealUpdateResult,\n ListDealsOptions,\n UpdateDealInput,\n} from \"../types/deals\";\n\nexport class Deals {\n constructor(private client: BaseClient) {}\n\n /** List deals with cursor-based pagination and optional filters. */\n async list(options?: ListDealsOptions): Promise<PaginatedResponse<Deal>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n if (options?.status) params.status = options.status;\n if (options?.search) params.search = options.search;\n return this.client.get(\"/api/v1/deals\", params);\n }\n\n /** Create a new deal. */\n async create(input: CreateDealInput): Promise<ApiResponse<DealCreateResult>> {\n return this.client.post(\"/api/v1/deals\", input);\n }\n\n /** Get a deal by ID. */\n async get(id: string): Promise<ApiResponse<Deal>> {\n return this.client.get(`/api/v1/deals/${encodeURIComponent(id)}`);\n }\n\n /** Update one or more fields on a deal. Set contact_id to null to unlink. */\n async update(id: string, input: UpdateDealInput): Promise<ApiResponse<DealUpdateResult>> {\n return this.client.patch(`/api/v1/deals/${encodeURIComponent(id)}`, input);\n }\n\n /** Permanently delete a deal. */\n async remove(id: string): Promise<ApiResponse<DealRemoveResult>> {\n return this.client.delete(`/api/v1/deals/${encodeURIComponent(id)}`);\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse } from \"../types/common\";\nimport type {\n BatchSendInput,\n BatchSendSummary,\n EmailSend,\n EmailSendResult,\n EmailTemplate,\n EmailTemplateDetail,\n GetTemplateOptions,\n SendEmailInput,\n} from \"../types/emails\";\n\nclass EmailTemplates {\n constructor(private client: BaseClient) {}\n\n /** List all active email templates in the workspace. */\n async list(): Promise<ApiResponse<EmailTemplate[]>> {\n return this.client.get(\"/api/v1/emails/templates\");\n }\n\n /** Get a specific email template by slug, optionally with locale resolution. */\n async get(slug: string, options?: GetTemplateOptions): Promise<ApiResponse<EmailTemplateDetail>> {\n const params: Record<string, string | undefined> = {};\n if (options?.locale) params.locale = options.locale;\n if (options?.fallback_locale) params.fallback_locale = options.fallback_locale;\n return this.client.get(`/api/v1/emails/templates/${encodeURIComponent(slug)}`, params);\n }\n}\n\nexport class Emails {\n readonly templates: EmailTemplates;\n\n constructor(private client: BaseClient) {\n this.templates = new EmailTemplates(client);\n }\n\n /** Send a transactional email using a template. Returns a queued job ID (HTTP 202). */\n async send(input: SendEmailInput): Promise<ApiResponse<EmailSendResult>> {\n return this.client.post(\"/api/v1/emails\", input);\n }\n\n /** Get the delivery status of a sent email. */\n async get(id: string): Promise<ApiResponse<EmailSend>> {\n return this.client.get(`/api/v1/emails/${encodeURIComponent(id)}`);\n }\n\n /** Send the same template to multiple recipients (max 100). Returns HTTP 202. */\n async batch(input: BatchSendInput): Promise<ApiResponse<BatchSendSummary>> {\n return this.client.post(\"/api/v1/emails/batch\", input);\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse } from \"../types/common\";\nimport type {\n ConsentRecord,\n ConsentResult,\n CookieConsentInput,\n GdprExport,\n RecordConsentInput,\n} from \"../types/gdpr\";\n\nexport class Gdpr {\n constructor(private client: BaseClient) {}\n\n /** Request a workspace data export. Runs asynchronously. */\n async requestExport(): Promise<ApiResponse<{ request_id: string; status: string }>> {\n return this.client.post(\"/api/v1/gdpr/export\");\n }\n\n /** List all workspace export requests. */\n async listExports(): Promise<ApiResponse<GdprExport[]>> {\n return this.client.get(\"/api/v1/gdpr/exports\");\n }\n\n /** Get the status of a specific export. */\n async getExport(id: string): Promise<ApiResponse<GdprExport>> {\n return this.client.get(`/api/v1/gdpr/exports/${encodeURIComponent(id)}`);\n }\n\n /** Record a GDPR consent decision for a contact by email. */\n async recordConsent(input: RecordConsentInput): Promise<ApiResponse<ConsentResult>> {\n return this.client.post(\"/api/v1/gdpr/consent\", input);\n }\n\n /** Get all consent records for a contact by email. */\n async getConsent(email: string): Promise<ApiResponse<ConsentRecord[]>> {\n return this.client.get(`/api/v1/gdpr/consent/${encodeURIComponent(email)}`);\n }\n\n /** Record cookie consent from an external site (legacy endpoint). */\n async cookieConsent(input: CookieConsentInput): Promise<{ success: boolean; logId?: string }> {\n return this.client.post(\"/api/cookie-consent\", input);\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse, PaginatedResponse } from \"../types/common\";\nimport type {\n Channel,\n CreatePostInput,\n ListPostsOptions,\n Post,\n PostDetail,\n PublishResult,\n SchedulePostInput,\n ScheduleResult,\n UpdatePostInput,\n} from \"../types/posts\";\n\nexport class Posts {\n constructor(private client: BaseClient) {}\n\n /** List posts with cursor-based pagination and optional filters. */\n async list(options?: ListPostsOptions): Promise<PaginatedResponse<Post>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n if (options?.status) params.status = options.status;\n if (options?.type) params.type = options.type;\n return this.client.get(\"/api/v1/posts\", params);\n }\n\n /** Create a new post with content and target channels. */\n async create(input: CreatePostInput): Promise<ApiResponse<{ id: string }>> {\n return this.client.post(\"/api/v1/posts\", input);\n }\n\n /** Get a post by ID, including its per-channel variants. */\n async get(id: string): Promise<ApiResponse<PostDetail>> {\n return this.client.get(`/api/v1/posts/${encodeURIComponent(id)}`);\n }\n\n /** Update a draft post's title or content. */\n async update(id: string, input: UpdatePostInput): Promise<ApiResponse<{ success: boolean }>> {\n return this.client.patch(`/api/v1/posts/${encodeURIComponent(id)}`, input);\n }\n\n /** Delete a post. */\n async remove(id: string): Promise<ApiResponse<{ success: boolean }>> {\n return this.client.delete(`/api/v1/posts/${encodeURIComponent(id)}`);\n }\n\n /** Schedule a post for future publication. */\n async schedule(id: string, input: SchedulePostInput): Promise<ApiResponse<ScheduleResult>> {\n return this.client.post(`/api/v1/posts/${encodeURIComponent(id)}/schedule`, input);\n }\n\n /** Publish a post immediately to all target channels. */\n async publish(id: string): Promise<ApiResponse<PublishResult>> {\n return this.client.post(`/api/v1/posts/${encodeURIComponent(id)}/publish`);\n }\n\n /** List connected publishing channels for this workspace. */\n async channels(): Promise<ApiResponse<Channel[]>> {\n return this.client.get(\"/api/v1/posts/channels\");\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse } from \"../types/common\";\nimport type { Workspace } from \"../types/workspaces\";\n\nexport class Workspaces {\n constructor(private client: BaseClient) {}\n\n /** List workspaces accessible to the current API key or OAuth token. */\n async list(): Promise<ApiResponse<Workspace[]>> {\n return this.client.get(\"/api/v1/me/workspaces\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,QAAgB,MAAc,SAAiB,SAAmB;AAC5E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,UAAU;AAAA,EACjB;AACF;;;ACbO,IAAM,aAAN,MAAiB;AAAA,EACb;AAAA,EAET,YAAY,QAAsB;AAChC,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,MAAM,IAAO,MAAc,QAAyD;AAClF,UAAM,MAAM,KAAK,SAAS,MAAM,MAAM;AACtC,WAAO,KAAK,QAAW,KAAK,EAAE,QAAQ,MAAM,CAAC;AAAA,EAC/C;AAAA,EAEA,MAAM,KAAQ,MAAc,MAA4B;AACtD,WAAO,KAAK,QAAW,KAAK,SAAS,IAAI,GAAG;AAAA,MAC1C,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC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AA,EACA;AAAA,EAET,YAAY,OAAe,SAAwB;AACjD,QAAI,CAAC,OAAO;AACV,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,SAAS,IAAI,WAAW;AAAA,MAC5B,UAAU,SAAS,WAAW,8BAA8B,QAAQ,OAAO,EAAE;AAAA,MAC7E;AAAA,MACA,aAAa,SAAS;AAAA,MACtB,SAAS,SAAS,WAAW;AAAA,MAC7B,WAAW;AAAA,IACb,CAAC;AAED,SAAK,SAAS,IAAI,OAAO,MAAM;AAC/B,SAAK,WAAW,IAAI,SAAS,MAAM;AACnC,SAAK,QAAQ,IAAI,MAAM,MAAM;AAC7B,SAAK,OAAO,IAAI,KAAK,MAAM;AAC3B,SAAK,QAAQ,IAAI,MAAM,MAAM;AAC7B,SAAK,aAAa,IAAI,WAAW,MAAM;AAAA,EACzC;AACF;AA4EO,SAAS,kBAAkB,QAAgB,SAA+B;AAC/E,SAAO,IAAI,MAAM,QAAQ,OAAO;AAClC;AAEA,IAAO,cAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/types/common.ts","../../src/client.ts","../../src/resources/contacts.ts","../../src/resources/deals.ts","../../src/resources/emails.ts","../../src/resources/gdpr.ts","../../src/resources/posts.ts","../../src/resources/workspaces.ts"],"sourcesContent":["/**\n * Official TypeScript SDK for the Medal Social API.\n *\n * Provides typed access to posts, emails, contacts, deals, GDPR compliance,\n * and workspace management. Works in Node.js, Deno, Bun, Cloudflare Workers,\n * and modern browsers.\n *\n * @example\n * ```ts\n * import { Medal } from \"@medalsocial/sdk\";\n *\n * const medal = new Medal(\"medal_xxx\");\n * const { data: post } = await medal.posts.create({\n * content: \"Hello world!\",\n * channel_ids: [\"ch_1\"],\n * });\n * ```\n *\n * @module\n */\nimport { BaseClient } from \"./client\";\nimport { Contacts } from \"./resources/contacts\";\nimport { Deals } from \"./resources/deals\";\nimport { Emails } from \"./resources/emails\";\nimport { Gdpr } from \"./resources/gdpr\";\nimport { Posts } from \"./resources/posts\";\nimport { Workspaces } from \"./resources/workspaces\";\n\n/** Options for configuring the {@link Medal} client. */\nexport interface MedalOptions {\n /** Override the base URL (defaults to https://io.medalsocial.com). */\n baseUrl?: string;\n /** Request timeout in ms (default 30000). */\n timeout?: number;\n /**\n * Workspace ID — required for OAuth access tokens, ignored for API keys.\n * API keys are scoped to a single workspace, so the workspace is inferred.\n * OAuth tokens can access multiple workspaces, so you must specify which one.\n */\n workspaceId?: string;\n}\n\n/**\n * Medal Social SDK client.\n *\n * Supports both API key and OAuth access token authentication:\n *\n * @example API Key (recommended for server-side)\n * ```ts\n * import { Medal } from '@medalsocial/sdk';\n *\n * // API keys start with medal_ and are scoped to one workspace\n * const medal = new Medal('medal_xxx');\n * ```\n *\n * @example OAuth Access Token\n * ```ts\n * // OAuth tokens require a workspaceId\n * const medal = new Medal('oauth_access_token', {\n * workspaceId: 'workspace_id_here',\n * });\n * ```\n *\n * @example Full usage\n * ```ts\n * const medal = new Medal('medal_xxx');\n *\n * // Posts — create, schedule, publish\n * const { data: post } = await medal.posts.create({\n * content: 'Hello world!',\n * channel_ids: ['ch_1'],\n * });\n * await medal.posts.schedule(post.id, { scheduled_at: '2026-03-15T10:00:00Z' });\n *\n * // Emails — send transactional emails\n * await medal.emails.send({\n * template_slug: 'welcome',\n * to: 'user@example.com',\n * variables: { name: 'John' },\n * });\n *\n * // Contacts, Deals, GDPR, Workspaces\n * const contacts = await medal.contacts.list({ status: 'lead' });\n * const { data: deal } = await medal.deals.create({ title: 'Acme', value: 50000 });\n * await medal.gdpr.recordConsent({ email: 'u@x.com', consent_type: 'marketing_email', granted: true });\n * const { data: workspaces } = await medal.workspaces.list();\n * ```\n */\nexport class Medal {\n readonly emails: Emails;\n readonly contacts: Contacts;\n readonly deals: Deals;\n readonly gdpr: Gdpr;\n readonly posts: Posts;\n readonly workspaces: Workspaces;\n\n constructor(token: string, options?: MedalOptions) {\n if (!token) {\n throw new Error(\n \"Authentication token is required. Pass your medal_xxx API key or OAuth access token as the first argument.\",\n );\n }\n\n const client = new BaseClient({\n baseUrl: (options?.baseUrl ?? \"https://io.medalsocial.com\").replace(/\\/$/, \"\"),\n token,\n workspaceId: options?.workspaceId,\n timeout: options?.timeout ?? 30000,\n userAgent: \"medalsocial-sdk/1.0.0 (+https://github.com/Medal-Social/MedalSocial)\",\n });\n\n this.emails = new Emails(client);\n this.contacts = new Contacts(client);\n this.deals = new Deals(client);\n this.gdpr = new Gdpr(client);\n this.posts = new Posts(client);\n this.workspaces = new Workspaces(client);\n }\n}\n\n// Re-export all types\nexport { MedalApiError } from \"./types/common\";\nexport type { ApiResponse, PaginatedResponse, PaginationOptions } from \"./types/common\";\nexport type {\n SendEmailInput,\n EmailSendResult,\n EmailSend,\n BatchSendInput,\n BatchSendSummary,\n BatchSendResult,\n EmailTemplate,\n EmailTemplateDetail,\n GetTemplateOptions,\n} from \"./types/emails\";\nexport type {\n Contact,\n ContactCreateResult,\n ContactUpdateResult,\n ContactRemoveResult,\n ContactNoteResult,\n ContactStatus,\n EmailStatus,\n CreateContactInput,\n UpdateContactInput,\n ListContactsOptions,\n ImportContactInput,\n ImportContactsResult,\n Activity,\n AddNoteInput,\n} from \"./types/contacts\";\nexport type {\n Deal,\n DealCreateResult,\n DealUpdateResult,\n DealRemoveResult,\n DealStatus,\n CreateDealInput,\n UpdateDealInput,\n ListDealsOptions,\n} from \"./types/deals\";\nexport type {\n GdprExport,\n ConsentType,\n RecordConsentInput,\n ConsentRecord,\n ConsentResult,\n ContactConsents,\n CookieConsentInput,\n CookieCategoryConsent,\n} from \"./types/gdpr\";\nexport type {\n Post,\n PostType,\n PostVariant,\n PostDetail,\n Channel,\n CreatePostInput,\n UpdatePostInput,\n SchedulePostInput,\n ListPostsOptions,\n ScheduleResult,\n PublishResult,\n} from \"./types/posts\";\nexport type { Workspace } from \"./types/workspaces\";\n\n// Resource class re-exports (for advanced usage)\nexport { Emails } from \"./resources/emails\";\nexport { Contacts } from \"./resources/contacts\";\nexport { Deals } from \"./resources/deals\";\nexport { Gdpr } from \"./resources/gdpr\";\nexport { Posts } from \"./resources/posts\";\nexport { Workspaces } from \"./resources/workspaces\";\nexport { BaseClient } from \"./client\";\n\n/** Convenience factory — equivalent to `new Medal(apiKey, options)`. */\nexport function createMedalClient(apiKey: string, options?: MedalOptions): Medal {\n return new Medal(apiKey, options);\n}\n\nexport default Medal;\n","/** Successful API response wrapper */\nexport interface ApiResponse<T> {\n data: T;\n}\n\n/** Paginated API response */\nexport interface PaginatedResponse<T> {\n data: T[];\n pagination: {\n has_more: boolean;\n next_cursor: string | null;\n };\n}\n\n/** API error thrown by the client */\nexport class MedalApiError extends Error {\n readonly status: number;\n readonly code: string;\n readonly details?: unknown;\n\n constructor(status: number, code: string, message: string, details?: unknown) {\n super(message);\n this.name = \"MedalApiError\";\n this.status = status;\n this.code = code;\n this.details = details;\n }\n}\n\n/** Pagination options for list endpoints */\nexport interface PaginationOptions {\n limit?: number;\n cursor?: string;\n}\n","import { MedalApiError } from \"./types/common\";\n\n/** Configuration for the low-level HTTP client. */\nexport interface ClientConfig {\n baseUrl: string;\n token: string;\n workspaceId?: string;\n timeout: number;\n userAgent: string;\n}\n\n/**\n * Low-level HTTP client used by all resource classes.\n * Handles authentication, retries, timeout, and error parsing.\n */\nexport class BaseClient {\n /** Resolved client configuration. */\n readonly config: ClientConfig;\n\n constructor(config: ClientConfig) {\n this.config = config;\n }\n\n /** Execute an authenticated GET request and return the parsed JSON body. */\n async get<T>(path: string, params?: Record<string, string | undefined>): Promise<T> {\n const url = this.buildUrl(path, params);\n return this.request<T>(url, { method: \"GET\" });\n }\n\n /** Execute an authenticated POST request with a JSON body. */\n async post<T>(path: string, body?: unknown): Promise<T> {\n return this.request<T>(this.buildUrl(path), {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n }\n\n /** Execute an authenticated PATCH request with a JSON body. */\n async patch<T>(path: string, body: unknown): Promise<T> {\n return this.request<T>(this.buildUrl(path), {\n method: \"PATCH\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(body),\n });\n }\n\n /** Execute an authenticated DELETE request. */\n async delete<T>(path: string): Promise<T> {\n return this.request<T>(this.buildUrl(path), { method: \"DELETE\" });\n }\n\n private buildUrl(path: string, params?: Record<string, string | undefined>): string {\n const url = new URL(`${this.config.baseUrl}${path}`);\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n url.searchParams.set(key, value);\n }\n }\n }\n return url.toString();\n }\n\n private async request<T>(url: string, init: RequestInit): Promise<T> {\n const maxAttempts = 3;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n const headers = new Headers(init.headers);\n headers.set(\"authorization\", `Bearer ${this.config.token}`);\n if (this.config.workspaceId) {\n headers.set(\"x-workspace-id\", this.config.workspaceId);\n }\n try {\n headers.set(\"user-agent\", this.config.userAgent);\n } catch {\n // Browsers disallow setting user-agent\n }\n\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.config.timeout);\n\n let res: Response;\n try {\n res = await fetch(url, { ...init, headers, signal: controller.signal });\n } finally {\n clearTimeout(timeout);\n }\n\n // Retry on 429 / 5xx (but not on the final attempt)\n if (\n (res.status === 429 || (res.status >= 500 && res.status <= 599)) &&\n attempt < maxAttempts\n ) {\n const retryAfter = res.headers.get(\"retry-after\");\n let delayMs = 0;\n if (retryAfter) {\n const seconds = Number(retryAfter);\n delayMs = Number.isFinite(seconds) ? seconds * 1000 : 0;\n }\n if (delayMs <= 0) {\n delayMs = 250 * attempt;\n }\n await new Promise((r) => setTimeout(r, delayMs));\n continue;\n }\n\n // Parse response\n const text = await res.text();\n let parsed: unknown;\n try {\n parsed = text ? JSON.parse(text) : undefined;\n } catch {\n parsed = text;\n }\n\n if (!res.ok) {\n const body = parsed as\n | { error?: { code?: string; message?: string; details?: unknown } }\n | undefined;\n throw new MedalApiError(\n res.status,\n body?.error?.code ?? \"UNKNOWN_ERROR\",\n body?.error?.message ?? `HTTP ${res.status}: ${res.statusText}`,\n body?.error?.details,\n );\n }\n\n return parsed as T;\n }\n\n /* v8 ignore next -- unreachable: loop always returns or throws */\n throw new Error(\"Request failed after retries\");\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse, PaginatedResponse, PaginationOptions } from \"../types/common\";\nimport type {\n Activity,\n AddNoteInput,\n Contact,\n ContactCreateResult,\n ContactNoteResult,\n ContactRemoveResult,\n ContactUpdateResult,\n CreateContactInput,\n ImportContactInput,\n ImportContactsResult,\n ListContactsOptions,\n UpdateContactInput,\n} from \"../types/contacts\";\n\n/** Manage contacts in the workspace CRM. */\nexport class Contacts {\n constructor(private client: BaseClient) {}\n\n /** List contacts with cursor-based pagination and optional filters. */\n async list(options?: ListContactsOptions): Promise<PaginatedResponse<Contact>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n if (options?.status) params.status = options.status;\n if (options?.email_status) params.email_status = options.email_status;\n if (options?.label_ids) params.label_ids = options.label_ids.join(\",\");\n if (options?.search) params.search = options.search;\n return this.client.get(\"/api/v1/contacts\", params);\n }\n\n /** Create a new contact. Email must be unique in the workspace. */\n async create(input: CreateContactInput): Promise<ApiResponse<ContactCreateResult>> {\n return this.client.post(\"/api/v1/contacts\", input);\n }\n\n /** Get a contact by ID. */\n async get(id: string): Promise<ApiResponse<Contact>> {\n return this.client.get(`/api/v1/contacts/${encodeURIComponent(id)}`);\n }\n\n /** Update one or more fields on a contact. */\n async update(id: string, input: UpdateContactInput): Promise<ApiResponse<ContactUpdateResult>> {\n return this.client.patch(`/api/v1/contacts/${encodeURIComponent(id)}`, input);\n }\n\n /** Permanently delete a contact. */\n async remove(id: string): Promise<ApiResponse<ContactRemoveResult>> {\n return this.client.delete(`/api/v1/contacts/${encodeURIComponent(id)}`);\n }\n\n /** Get the activity timeline for a contact. */\n async activities(id: string, options?: PaginationOptions): Promise<PaginatedResponse<Activity>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n return this.client.get(`/api/v1/contacts/${encodeURIComponent(id)}/activities`, params);\n }\n\n /** Add a note to a contact's timeline. */\n async addNote(id: string, input: AddNoteInput): Promise<ApiResponse<ContactNoteResult>> {\n return this.client.post(`/api/v1/contacts/${encodeURIComponent(id)}/notes`, input);\n }\n\n /** Bulk import contacts (max 500). Duplicates are skipped. */\n async import(contacts: ImportContactInput[]): Promise<ApiResponse<ImportContactsResult>> {\n return this.client.post(\"/api/v1/contacts/import\", { contacts });\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse, PaginatedResponse } from \"../types/common\";\nimport type {\n CreateDealInput,\n Deal,\n DealCreateResult,\n DealRemoveResult,\n DealUpdateResult,\n ListDealsOptions,\n UpdateDealInput,\n} from \"../types/deals\";\n\n/** Manage sponsorship deals in the workspace. */\nexport class Deals {\n constructor(private client: BaseClient) {}\n\n /** List deals with cursor-based pagination and optional filters. */\n async list(options?: ListDealsOptions): Promise<PaginatedResponse<Deal>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n if (options?.status) params.status = options.status;\n if (options?.search) params.search = options.search;\n return this.client.get(\"/api/v1/deals\", params);\n }\n\n /** Create a new deal. */\n async create(input: CreateDealInput): Promise<ApiResponse<DealCreateResult>> {\n return this.client.post(\"/api/v1/deals\", input);\n }\n\n /** Get a deal by ID. */\n async get(id: string): Promise<ApiResponse<Deal>> {\n return this.client.get(`/api/v1/deals/${encodeURIComponent(id)}`);\n }\n\n /** Update one or more fields on a deal. Set contact_id to null to unlink. */\n async update(id: string, input: UpdateDealInput): Promise<ApiResponse<DealUpdateResult>> {\n return this.client.patch(`/api/v1/deals/${encodeURIComponent(id)}`, input);\n }\n\n /** Permanently delete a deal. */\n async remove(id: string): Promise<ApiResponse<DealRemoveResult>> {\n return this.client.delete(`/api/v1/deals/${encodeURIComponent(id)}`);\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse } from \"../types/common\";\nimport type {\n BatchSendInput,\n BatchSendSummary,\n EmailSend,\n EmailSendResult,\n EmailTemplate,\n EmailTemplateDetail,\n GetTemplateOptions,\n SendEmailInput,\n} from \"../types/emails\";\n\n/** Manage email templates stored in the workspace. */\nclass EmailTemplates {\n constructor(private client: BaseClient) {}\n\n /** List all active email templates in the workspace. */\n async list(): Promise<ApiResponse<EmailTemplate[]>> {\n return this.client.get(\"/api/v1/emails/templates\");\n }\n\n /** Get a specific email template by slug, optionally with locale resolution. */\n async get(slug: string, options?: GetTemplateOptions): Promise<ApiResponse<EmailTemplateDetail>> {\n const params: Record<string, string | undefined> = {};\n if (options?.locale) params.locale = options.locale;\n if (options?.fallback_locale) params.fallback_locale = options.fallback_locale;\n return this.client.get(`/api/v1/emails/templates/${encodeURIComponent(slug)}`, params);\n }\n}\n\n/** Send transactional emails and manage templates. */\nexport class Emails {\n readonly templates: EmailTemplates;\n\n constructor(private client: BaseClient) {\n this.templates = new EmailTemplates(client);\n }\n\n /** Send a transactional email using a template. Returns a queued job ID (HTTP 202). */\n async send(input: SendEmailInput): Promise<ApiResponse<EmailSendResult>> {\n return this.client.post(\"/api/v1/emails\", input);\n }\n\n /** Get the delivery status of a sent email. */\n async get(id: string): Promise<ApiResponse<EmailSend>> {\n return this.client.get(`/api/v1/emails/${encodeURIComponent(id)}`);\n }\n\n /** Send the same template to multiple recipients (max 100). Returns HTTP 202. */\n async batch(input: BatchSendInput): Promise<ApiResponse<BatchSendSummary>> {\n return this.client.post(\"/api/v1/emails/batch\", input);\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse } from \"../types/common\";\nimport type {\n ConsentRecord,\n ConsentResult,\n CookieConsentInput,\n GdprExport,\n RecordConsentInput,\n} from \"../types/gdpr\";\n\n/** Manage GDPR compliance — data exports, consent records, and cookie consent. */\nexport class Gdpr {\n constructor(private client: BaseClient) {}\n\n /** Request a workspace data export. Runs asynchronously. */\n async requestExport(): Promise<ApiResponse<{ request_id: string; status: string }>> {\n return this.client.post(\"/api/v1/gdpr/export\");\n }\n\n /** List all workspace export requests. */\n async listExports(): Promise<ApiResponse<GdprExport[]>> {\n return this.client.get(\"/api/v1/gdpr/exports\");\n }\n\n /** Get the status of a specific export. */\n async getExport(id: string): Promise<ApiResponse<GdprExport>> {\n return this.client.get(`/api/v1/gdpr/exports/${encodeURIComponent(id)}`);\n }\n\n /** Record a GDPR consent decision for a contact by email. */\n async recordConsent(input: RecordConsentInput): Promise<ApiResponse<ConsentResult>> {\n return this.client.post(\"/api/v1/gdpr/consent\", input);\n }\n\n /** Get all consent records for a contact by email. */\n async getConsent(email: string): Promise<ApiResponse<ConsentRecord[]>> {\n return this.client.get(`/api/v1/gdpr/consent/${encodeURIComponent(email)}`);\n }\n\n /** Record cookie consent from an external site (legacy endpoint). */\n async cookieConsent(input: CookieConsentInput): Promise<{ success: boolean; logId?: string }> {\n return this.client.post(\"/api/cookie-consent\", input);\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse, PaginatedResponse } from \"../types/common\";\nimport type {\n Channel,\n CreatePostInput,\n ListPostsOptions,\n Post,\n PostDetail,\n PublishResult,\n SchedulePostInput,\n ScheduleResult,\n UpdatePostInput,\n} from \"../types/posts\";\n\n/** Create and publish posts across connected channels. */\nexport class Posts {\n constructor(private client: BaseClient) {}\n\n /** List posts with cursor-based pagination and optional filters. */\n async list(options?: ListPostsOptions): Promise<PaginatedResponse<Post>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n if (options?.status) params.status = options.status;\n if (options?.type) params.type = options.type;\n return this.client.get(\"/api/v1/posts\", params);\n }\n\n /** Create a new post with content and target channels. */\n async create(input: CreatePostInput): Promise<ApiResponse<{ id: string }>> {\n return this.client.post(\"/api/v1/posts\", input);\n }\n\n /** Get a post by ID, including its per-channel variants. */\n async get(id: string): Promise<ApiResponse<PostDetail>> {\n return this.client.get(`/api/v1/posts/${encodeURIComponent(id)}`);\n }\n\n /** Update a draft post's title or content. */\n async update(id: string, input: UpdatePostInput): Promise<ApiResponse<{ success: boolean }>> {\n return this.client.patch(`/api/v1/posts/${encodeURIComponent(id)}`, input);\n }\n\n /** Delete a post. */\n async remove(id: string): Promise<ApiResponse<{ success: boolean }>> {\n return this.client.delete(`/api/v1/posts/${encodeURIComponent(id)}`);\n }\n\n /** Schedule a post for future publication. */\n async schedule(id: string, input: SchedulePostInput): Promise<ApiResponse<ScheduleResult>> {\n return this.client.post(`/api/v1/posts/${encodeURIComponent(id)}/schedule`, input);\n }\n\n /** Publish a post immediately to all target channels. */\n async publish(id: string): Promise<ApiResponse<PublishResult>> {\n return this.client.post(`/api/v1/posts/${encodeURIComponent(id)}/publish`);\n }\n\n /** List connected publishing channels for this workspace. */\n async channels(): Promise<ApiResponse<Channel[]>> {\n return this.client.get(\"/api/v1/posts/channels\");\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse } from \"../types/common\";\nimport type { Workspace } from \"../types/workspaces\";\n\n/** Access workspaces for the authenticated credential. */\nexport class Workspaces {\n constructor(private client: BaseClient) {}\n\n /** List workspaces accessible to the current API key or OAuth token. */\n async list(): Promise<ApiResponse<Workspace[]>> {\n return this.client.get(\"/api/v1/me/workspaces\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,QAAgB,MAAc,SAAiB,SAAmB;AAC5E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SA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F;AAAA;AAAA,EAGA,MAAM,QAAQ,IAAiD;AAC7D,WAAO,KAAK,OAAO,KAAK,iBAAiB,mBAAmB,EAAE,CAAC,UAAU;AAAA,EAC3E;AAAA;AAAA,EAGA,MAAM,WAA4C;AAChD,WAAO,KAAK,OAAO,IAAI,wBAAwB;AAAA,EACjD;AACF;;;ACzDO,IAAM,aAAN,MAAiB;AAAA,EACtB,YAAoB,QAAoB;AAApB;AAAA,EAAqB;AAAA;AAAA,EAGzC,MAAM,OAA0C;AAC9C,WAAO,KAAK,OAAO,IAAI,uBAAuB;AAAA,EAChD;AACF;;;AR4EO,IAAM,QAAN,MAAY;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,OAAe,SAAwB;AACjD,QAAI,CAAC,OAAO;AACV,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,SAAS,IAAI,WAAW;AAAA,MAC5B,UAAU,SAAS,WAAW,8BAA8B,QAAQ,OAAO,EAAE;AAAA,MAC7E;AAAA,MACA,aAAa,SAAS;AAAA,MACtB,SAAS,SAAS,WAAW;AAAA,MAC7B,WAAW;AAAA,IACb,CAAC;AAED,SAAK,SAAS,IAAI,OAAO,MAAM;AAC/B,SAAK,WAAW,IAAI,SAAS,MAAM;AACnC,SAAK,QAAQ,IAAI,MAAM,MAAM;AAC7B,SAAK,OAAO,IAAI,KAAK,MAAM;AAC3B,SAAK,QAAQ,IAAI,MAAM,MAAM;AAC7B,SAAK,aAAa,IAAI,WAAW,MAAM;AAAA,EACzC;AACF;AA6EO,SAAS,kBAAkB,QAAgB,SAA+B;AAC/E,SAAO,IAAI,MAAM,QAAQ,OAAO;AAClC;AAEA,IAAO,cAAQ;","names":[]}
|
package/dist/src/index.mjs
CHANGED
|
@@ -14,14 +14,17 @@ var MedalApiError = class extends Error {
|
|
|
14
14
|
|
|
15
15
|
// src/client.ts
|
|
16
16
|
var BaseClient = class {
|
|
17
|
+
/** Resolved client configuration. */
|
|
17
18
|
config;
|
|
18
19
|
constructor(config) {
|
|
19
20
|
this.config = config;
|
|
20
21
|
}
|
|
22
|
+
/** Execute an authenticated GET request and return the parsed JSON body. */
|
|
21
23
|
async get(path, params) {
|
|
22
24
|
const url = this.buildUrl(path, params);
|
|
23
25
|
return this.request(url, { method: "GET" });
|
|
24
26
|
}
|
|
27
|
+
/** Execute an authenticated POST request with a JSON body. */
|
|
25
28
|
async post(path, body) {
|
|
26
29
|
return this.request(this.buildUrl(path), {
|
|
27
30
|
method: "POST",
|
|
@@ -29,6 +32,7 @@ var BaseClient = class {
|
|
|
29
32
|
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
30
33
|
});
|
|
31
34
|
}
|
|
35
|
+
/** Execute an authenticated PATCH request with a JSON body. */
|
|
32
36
|
async patch(path, body) {
|
|
33
37
|
return this.request(this.buildUrl(path), {
|
|
34
38
|
method: "PATCH",
|
|
@@ -36,6 +40,7 @@ var BaseClient = class {
|
|
|
36
40
|
body: JSON.stringify(body)
|
|
37
41
|
});
|
|
38
42
|
}
|
|
43
|
+
/** Execute an authenticated DELETE request. */
|
|
39
44
|
async delete(path) {
|
|
40
45
|
return this.request(this.buildUrl(path), { method: "DELETE" });
|
|
41
46
|
}
|
package/dist/src/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/common.ts","../../src/client.ts","../../src/resources/contacts.ts","../../src/resources/deals.ts","../../src/resources/emails.ts","../../src/resources/gdpr.ts","../../src/resources/posts.ts","../../src/resources/workspaces.ts","../../src/index.ts"],"sourcesContent":["/** Successful API response wrapper */\nexport interface ApiResponse<T> {\n data: T;\n}\n\n/** Paginated API response */\nexport interface PaginatedResponse<T> {\n data: T[];\n pagination: {\n has_more: boolean;\n next_cursor: string | null;\n };\n}\n\n/** API error thrown by the client */\nexport class MedalApiError extends Error {\n readonly status: number;\n readonly code: string;\n readonly details?: unknown;\n\n constructor(status: number, code: string, message: string, details?: unknown) {\n super(message);\n this.name = \"MedalApiError\";\n this.status = status;\n this.code = code;\n this.details = details;\n }\n}\n\n/** Pagination options for list endpoints */\nexport interface PaginationOptions {\n limit?: number;\n cursor?: string;\n}\n","import { MedalApiError } from \"./types/common\";\n\nexport interface ClientConfig {\n baseUrl: string;\n token: string;\n workspaceId?: string;\n timeout: number;\n userAgent: string;\n}\n\n/**\n * Low-level HTTP client used by all resource classes.\n * Handles authentication, retries, timeout, and error parsing.\n */\nexport class BaseClient {\n readonly config: ClientConfig;\n\n constructor(config: ClientConfig) {\n this.config = config;\n }\n\n async get<T>(path: string, params?: Record<string, string | undefined>): Promise<T> {\n const url = this.buildUrl(path, params);\n return this.request<T>(url, { method: \"GET\" });\n }\n\n async post<T>(path: string, body?: unknown): Promise<T> {\n return this.request<T>(this.buildUrl(path), {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n }\n\n async patch<T>(path: string, body: unknown): Promise<T> {\n return this.request<T>(this.buildUrl(path), {\n method: \"PATCH\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(body),\n });\n }\n\n async delete<T>(path: string): Promise<T> {\n return this.request<T>(this.buildUrl(path), { method: \"DELETE\" });\n }\n\n private buildUrl(path: string, params?: Record<string, string | undefined>): string {\n const url = new URL(`${this.config.baseUrl}${path}`);\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n url.searchParams.set(key, value);\n }\n }\n }\n return url.toString();\n }\n\n private async request<T>(url: string, init: RequestInit): Promise<T> {\n const maxAttempts = 3;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n const headers = new Headers(init.headers);\n headers.set(\"authorization\", `Bearer ${this.config.token}`);\n if (this.config.workspaceId) {\n headers.set(\"x-workspace-id\", this.config.workspaceId);\n }\n try {\n headers.set(\"user-agent\", this.config.userAgent);\n } catch {\n // Browsers disallow setting user-agent\n }\n\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.config.timeout);\n\n let res: Response;\n try {\n res = await fetch(url, { ...init, headers, signal: controller.signal });\n } finally {\n clearTimeout(timeout);\n }\n\n // Retry on 429 / 5xx (but not on the final attempt)\n if (\n (res.status === 429 || (res.status >= 500 && res.status <= 599)) &&\n attempt < maxAttempts\n ) {\n const retryAfter = res.headers.get(\"retry-after\");\n let delayMs = 0;\n if (retryAfter) {\n const seconds = Number(retryAfter);\n delayMs = Number.isFinite(seconds) ? seconds * 1000 : 0;\n }\n if (delayMs <= 0) {\n delayMs = 250 * attempt;\n }\n await new Promise((r) => setTimeout(r, delayMs));\n continue;\n }\n\n // Parse response\n const text = await res.text();\n let parsed: unknown;\n try {\n parsed = text ? JSON.parse(text) : undefined;\n } catch {\n parsed = text;\n }\n\n if (!res.ok) {\n const body = parsed as\n | { error?: { code?: string; message?: string; details?: unknown } }\n | undefined;\n throw new MedalApiError(\n res.status,\n body?.error?.code ?? \"UNKNOWN_ERROR\",\n body?.error?.message ?? `HTTP ${res.status}: ${res.statusText}`,\n body?.error?.details,\n );\n }\n\n return parsed as T;\n }\n\n /* v8 ignore next -- unreachable: loop always returns or throws */\n throw new Error(\"Request failed after retries\");\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse, PaginatedResponse, PaginationOptions } from \"../types/common\";\nimport type {\n Activity,\n AddNoteInput,\n Contact,\n ContactCreateResult,\n ContactNoteResult,\n ContactRemoveResult,\n ContactUpdateResult,\n CreateContactInput,\n ImportContactInput,\n ImportContactsResult,\n ListContactsOptions,\n UpdateContactInput,\n} from \"../types/contacts\";\n\nexport class Contacts {\n constructor(private client: BaseClient) {}\n\n /** List contacts with cursor-based pagination and optional filters. */\n async list(options?: ListContactsOptions): Promise<PaginatedResponse<Contact>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n if (options?.status) params.status = options.status;\n if (options?.email_status) params.email_status = options.email_status;\n if (options?.label_ids) params.label_ids = options.label_ids.join(\",\");\n if (options?.search) params.search = options.search;\n return this.client.get(\"/api/v1/contacts\", params);\n }\n\n /** Create a new contact. Email must be unique in the workspace. */\n async create(input: CreateContactInput): Promise<ApiResponse<ContactCreateResult>> {\n return this.client.post(\"/api/v1/contacts\", input);\n }\n\n /** Get a contact by ID. */\n async get(id: string): Promise<ApiResponse<Contact>> {\n return this.client.get(`/api/v1/contacts/${encodeURIComponent(id)}`);\n }\n\n /** Update one or more fields on a contact. */\n async update(id: string, input: UpdateContactInput): Promise<ApiResponse<ContactUpdateResult>> {\n return this.client.patch(`/api/v1/contacts/${encodeURIComponent(id)}`, input);\n }\n\n /** Permanently delete a contact. */\n async remove(id: string): Promise<ApiResponse<ContactRemoveResult>> {\n return this.client.delete(`/api/v1/contacts/${encodeURIComponent(id)}`);\n }\n\n /** Get the activity timeline for a contact. */\n async activities(id: string, options?: PaginationOptions): Promise<PaginatedResponse<Activity>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n return this.client.get(`/api/v1/contacts/${encodeURIComponent(id)}/activities`, params);\n }\n\n /** Add a note to a contact's timeline. */\n async addNote(id: string, input: AddNoteInput): Promise<ApiResponse<ContactNoteResult>> {\n return this.client.post(`/api/v1/contacts/${encodeURIComponent(id)}/notes`, input);\n }\n\n /** Bulk import contacts (max 500). Duplicates are skipped. */\n async import(contacts: ImportContactInput[]): Promise<ApiResponse<ImportContactsResult>> {\n return this.client.post(\"/api/v1/contacts/import\", { contacts });\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse, PaginatedResponse } from \"../types/common\";\nimport type {\n CreateDealInput,\n Deal,\n DealCreateResult,\n DealRemoveResult,\n DealUpdateResult,\n ListDealsOptions,\n UpdateDealInput,\n} from \"../types/deals\";\n\nexport class Deals {\n constructor(private client: BaseClient) {}\n\n /** List deals with cursor-based pagination and optional filters. */\n async list(options?: ListDealsOptions): Promise<PaginatedResponse<Deal>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n if (options?.status) params.status = options.status;\n if (options?.search) params.search = options.search;\n return this.client.get(\"/api/v1/deals\", params);\n }\n\n /** Create a new deal. */\n async create(input: CreateDealInput): Promise<ApiResponse<DealCreateResult>> {\n return this.client.post(\"/api/v1/deals\", input);\n }\n\n /** Get a deal by ID. */\n async get(id: string): Promise<ApiResponse<Deal>> {\n return this.client.get(`/api/v1/deals/${encodeURIComponent(id)}`);\n }\n\n /** Update one or more fields on a deal. Set contact_id to null to unlink. */\n async update(id: string, input: UpdateDealInput): Promise<ApiResponse<DealUpdateResult>> {\n return this.client.patch(`/api/v1/deals/${encodeURIComponent(id)}`, input);\n }\n\n /** Permanently delete a deal. */\n async remove(id: string): Promise<ApiResponse<DealRemoveResult>> {\n return this.client.delete(`/api/v1/deals/${encodeURIComponent(id)}`);\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse } from \"../types/common\";\nimport type {\n BatchSendInput,\n BatchSendSummary,\n EmailSend,\n EmailSendResult,\n EmailTemplate,\n EmailTemplateDetail,\n GetTemplateOptions,\n SendEmailInput,\n} from \"../types/emails\";\n\nclass EmailTemplates {\n constructor(private client: BaseClient) {}\n\n /** List all active email templates in the workspace. */\n async list(): Promise<ApiResponse<EmailTemplate[]>> {\n return this.client.get(\"/api/v1/emails/templates\");\n }\n\n /** Get a specific email template by slug, optionally with locale resolution. */\n async get(slug: string, options?: GetTemplateOptions): Promise<ApiResponse<EmailTemplateDetail>> {\n const params: Record<string, string | undefined> = {};\n if (options?.locale) params.locale = options.locale;\n if (options?.fallback_locale) params.fallback_locale = options.fallback_locale;\n return this.client.get(`/api/v1/emails/templates/${encodeURIComponent(slug)}`, params);\n }\n}\n\nexport class Emails {\n readonly templates: EmailTemplates;\n\n constructor(private client: BaseClient) {\n this.templates = new EmailTemplates(client);\n }\n\n /** Send a transactional email using a template. Returns a queued job ID (HTTP 202). */\n async send(input: SendEmailInput): Promise<ApiResponse<EmailSendResult>> {\n return this.client.post(\"/api/v1/emails\", input);\n }\n\n /** Get the delivery status of a sent email. */\n async get(id: string): Promise<ApiResponse<EmailSend>> {\n return this.client.get(`/api/v1/emails/${encodeURIComponent(id)}`);\n }\n\n /** Send the same template to multiple recipients (max 100). Returns HTTP 202. */\n async batch(input: BatchSendInput): Promise<ApiResponse<BatchSendSummary>> {\n return this.client.post(\"/api/v1/emails/batch\", input);\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse } from \"../types/common\";\nimport type {\n ConsentRecord,\n ConsentResult,\n CookieConsentInput,\n GdprExport,\n RecordConsentInput,\n} from \"../types/gdpr\";\n\nexport class Gdpr {\n constructor(private client: BaseClient) {}\n\n /** Request a workspace data export. Runs asynchronously. */\n async requestExport(): Promise<ApiResponse<{ request_id: string; status: string }>> {\n return this.client.post(\"/api/v1/gdpr/export\");\n }\n\n /** List all workspace export requests. */\n async listExports(): Promise<ApiResponse<GdprExport[]>> {\n return this.client.get(\"/api/v1/gdpr/exports\");\n }\n\n /** Get the status of a specific export. */\n async getExport(id: string): Promise<ApiResponse<GdprExport>> {\n return this.client.get(`/api/v1/gdpr/exports/${encodeURIComponent(id)}`);\n }\n\n /** Record a GDPR consent decision for a contact by email. */\n async recordConsent(input: RecordConsentInput): Promise<ApiResponse<ConsentResult>> {\n return this.client.post(\"/api/v1/gdpr/consent\", input);\n }\n\n /** Get all consent records for a contact by email. */\n async getConsent(email: string): Promise<ApiResponse<ConsentRecord[]>> {\n return this.client.get(`/api/v1/gdpr/consent/${encodeURIComponent(email)}`);\n }\n\n /** Record cookie consent from an external site (legacy endpoint). */\n async cookieConsent(input: CookieConsentInput): Promise<{ success: boolean; logId?: string }> {\n return this.client.post(\"/api/cookie-consent\", input);\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse, PaginatedResponse } from \"../types/common\";\nimport type {\n Channel,\n CreatePostInput,\n ListPostsOptions,\n Post,\n PostDetail,\n PublishResult,\n SchedulePostInput,\n ScheduleResult,\n UpdatePostInput,\n} from \"../types/posts\";\n\nexport class Posts {\n constructor(private client: BaseClient) {}\n\n /** List posts with cursor-based pagination and optional filters. */\n async list(options?: ListPostsOptions): Promise<PaginatedResponse<Post>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n if (options?.status) params.status = options.status;\n if (options?.type) params.type = options.type;\n return this.client.get(\"/api/v1/posts\", params);\n }\n\n /** Create a new post with content and target channels. */\n async create(input: CreatePostInput): Promise<ApiResponse<{ id: string }>> {\n return this.client.post(\"/api/v1/posts\", input);\n }\n\n /** Get a post by ID, including its per-channel variants. */\n async get(id: string): Promise<ApiResponse<PostDetail>> {\n return this.client.get(`/api/v1/posts/${encodeURIComponent(id)}`);\n }\n\n /** Update a draft post's title or content. */\n async update(id: string, input: UpdatePostInput): Promise<ApiResponse<{ success: boolean }>> {\n return this.client.patch(`/api/v1/posts/${encodeURIComponent(id)}`, input);\n }\n\n /** Delete a post. */\n async remove(id: string): Promise<ApiResponse<{ success: boolean }>> {\n return this.client.delete(`/api/v1/posts/${encodeURIComponent(id)}`);\n }\n\n /** Schedule a post for future publication. */\n async schedule(id: string, input: SchedulePostInput): Promise<ApiResponse<ScheduleResult>> {\n return this.client.post(`/api/v1/posts/${encodeURIComponent(id)}/schedule`, input);\n }\n\n /** Publish a post immediately to all target channels. */\n async publish(id: string): Promise<ApiResponse<PublishResult>> {\n return this.client.post(`/api/v1/posts/${encodeURIComponent(id)}/publish`);\n }\n\n /** List connected publishing channels for this workspace. */\n async channels(): Promise<ApiResponse<Channel[]>> {\n return this.client.get(\"/api/v1/posts/channels\");\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse } from \"../types/common\";\nimport type { Workspace } from \"../types/workspaces\";\n\nexport class Workspaces {\n constructor(private client: BaseClient) {}\n\n /** List workspaces accessible to the current API key or OAuth token. */\n async list(): Promise<ApiResponse<Workspace[]>> {\n return this.client.get(\"/api/v1/me/workspaces\");\n }\n}\n","import { BaseClient } from \"./client\";\nimport { Contacts } from \"./resources/contacts\";\nimport { Deals } from \"./resources/deals\";\nimport { Emails } from \"./resources/emails\";\nimport { Gdpr } from \"./resources/gdpr\";\nimport { Posts } from \"./resources/posts\";\nimport { Workspaces } from \"./resources/workspaces\";\n\nexport interface MedalOptions {\n /** Override the base URL (defaults to https://api.medalsocial.com). */\n baseUrl?: string;\n /** Request timeout in ms (default 30000). */\n timeout?: number;\n /**\n * Workspace ID — required for OAuth access tokens, ignored for API keys.\n * API keys are scoped to a single workspace, so the workspace is inferred.\n * OAuth tokens can access multiple workspaces, so you must specify which one.\n */\n workspaceId?: string;\n}\n\n/**\n * Medal Social SDK client.\n *\n * Supports both API key and OAuth access token authentication:\n *\n * @example API Key (recommended for server-side)\n * ```ts\n * import { Medal } from '@medalsocial/sdk';\n *\n * // API keys start with medal_ and are scoped to one workspace\n * const medal = new Medal('medal_xxx');\n * ```\n *\n * @example OAuth Access Token\n * ```ts\n * // OAuth tokens require a workspaceId\n * const medal = new Medal('oauth_access_token', {\n * workspaceId: 'workspace_id_here',\n * });\n * ```\n *\n * @example Full usage\n * ```ts\n * const medal = new Medal('medal_xxx');\n *\n * // Posts — create, schedule, publish\n * const { data: post } = await medal.posts.create({\n * content: 'Hello world!',\n * channel_ids: ['ch_1'],\n * });\n * await medal.posts.schedule(post.id, { scheduled_at: '2026-03-15T10:00:00Z' });\n *\n * // Emails — send transactional emails\n * await medal.emails.send({\n * template_slug: 'welcome',\n * to: 'user@example.com',\n * variables: { name: 'John' },\n * });\n *\n * // Contacts, Deals, GDPR, Workspaces\n * const contacts = await medal.contacts.list({ status: 'lead' });\n * const { data: deal } = await medal.deals.create({ title: 'Acme', value: 50000 });\n * await medal.gdpr.recordConsent({ email: 'u@x.com', consent_type: 'marketing_email', granted: true });\n * const { data: workspaces } = await medal.workspaces.list();\n * ```\n */\nexport class Medal {\n readonly emails: Emails;\n readonly contacts: Contacts;\n readonly deals: Deals;\n readonly gdpr: Gdpr;\n readonly posts: Posts;\n readonly workspaces: Workspaces;\n\n constructor(token: string, options?: MedalOptions) {\n if (!token) {\n throw new Error(\n \"Authentication token is required. Pass your medal_xxx API key or OAuth access token as the first argument.\",\n );\n }\n\n const client = new BaseClient({\n baseUrl: (options?.baseUrl ?? \"https://io.medalsocial.com\").replace(/\\/$/, \"\"),\n token,\n workspaceId: options?.workspaceId,\n timeout: options?.timeout ?? 30000,\n userAgent: \"medalsocial-sdk/1.0.0 (+https://github.com/Medal-Social/MedalSocial)\",\n });\n\n this.emails = new Emails(client);\n this.contacts = new Contacts(client);\n this.deals = new Deals(client);\n this.gdpr = new Gdpr(client);\n this.posts = new Posts(client);\n this.workspaces = new Workspaces(client);\n }\n}\n\n// Re-export all types\nexport { MedalApiError } from \"./types/common\";\nexport type { ApiResponse, PaginatedResponse, PaginationOptions } from \"./types/common\";\nexport type {\n SendEmailInput,\n EmailSendResult,\n EmailSend,\n BatchSendInput,\n BatchSendSummary,\n BatchSendResult,\n EmailTemplate,\n EmailTemplateDetail,\n GetTemplateOptions,\n} from \"./types/emails\";\nexport type {\n Contact,\n ContactCreateResult,\n ContactUpdateResult,\n ContactRemoveResult,\n ContactNoteResult,\n ContactStatus,\n EmailStatus,\n CreateContactInput,\n UpdateContactInput,\n ListContactsOptions,\n ImportContactInput,\n ImportContactsResult,\n Activity,\n AddNoteInput,\n} from \"./types/contacts\";\nexport type {\n Deal,\n DealCreateResult,\n DealUpdateResult,\n DealRemoveResult,\n DealStatus,\n CreateDealInput,\n UpdateDealInput,\n ListDealsOptions,\n} from \"./types/deals\";\nexport type {\n GdprExport,\n ConsentType,\n RecordConsentInput,\n ConsentRecord,\n ConsentResult,\n ContactConsents,\n CookieConsentInput,\n CookieCategoryConsent,\n} from \"./types/gdpr\";\nexport type {\n Post,\n PostType,\n PostVariant,\n PostDetail,\n Channel,\n CreatePostInput,\n UpdatePostInput,\n SchedulePostInput,\n ListPostsOptions,\n ScheduleResult,\n PublishResult,\n} from \"./types/posts\";\nexport type { Workspace } from \"./types/workspaces\";\n\n// Resource class re-exports (for advanced usage)\nexport { Emails } from \"./resources/emails\";\nexport { Contacts } from \"./resources/contacts\";\nexport { Deals } from \"./resources/deals\";\nexport { Gdpr } from \"./resources/gdpr\";\nexport { Posts } from \"./resources/posts\";\nexport { Workspaces } from \"./resources/workspaces\";\nexport { BaseClient } from \"./client\";\n\nexport function createMedalClient(apiKey: string, options?: MedalOptions): Medal {\n return new Medal(apiKey, options);\n}\n\nexport default Medal;\n"],"mappings":";AAeO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,QAAgB,MAAc,SAAiB,SAAmB;AAC5E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,UAAU;AAAA,EACjB;AACF;;;ACbO,IAAM,aAAN,MAAiB;AAAA,EACb;AAAA,EAET,YAAY,QAAsB;AAChC,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,MAAM,IAAO,MAAc,QAAyD;AAClF,UAAM,MAAM,KAAK,SAAS,MAAM,MAAM;AACtC,WAAO,KAAK,QAAW,KAAK,EAAE,QAAQ,MAAM,CAAC;AAAA,EAC/C;AAAA,EAEA,MAAM,KAAQ,MAAc,MAA4B;AACtD,WAAO,KAAK,QAAW,KAAK,SAAS,IAAI,GAAG;AAAA,MAC1C,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC9C,MAAM,SAAS,SAAY,KAAK,UAAU,IAAI,IAAI;AAAA,IACpD,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,MAAS,MAAc,MAA2B;AACtD,WAAO,KAAK,QAAW,KAAK,SAAS,IAAI,GAAG;AAAA,MAC1C,QAAQ;AAAA,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,OAAO,EAAE;AAAA,MAC7E;AAAA,MACA,aAAa,SAAS;AAAA,MACtB,SAAS,SAAS,WAAW;AAAA,MAC7B,WAAW;AAAA,IACb,CAAC;AAED,SAAK,SAAS,IAAI,OAAO,MAAM;AAC/B,SAAK,WAAW,IAAI,SAAS,MAAM;AACnC,SAAK,QAAQ,IAAI,MAAM,MAAM;AAC7B,SAAK,OAAO,IAAI,KAAK,MAAM;AAC3B,SAAK,QAAQ,IAAI,MAAM,MAAM;AAC7B,SAAK,aAAa,IAAI,WAAW,MAAM;AAAA,EACzC;AACF;AA4EO,SAAS,kBAAkB,QAAgB,SAA+B;AAC/E,SAAO,IAAI,MAAM,QAAQ,OAAO;AAClC;AAEA,IAAO,cAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/common.ts","../../src/client.ts","../../src/resources/contacts.ts","../../src/resources/deals.ts","../../src/resources/emails.ts","../../src/resources/gdpr.ts","../../src/resources/posts.ts","../../src/resources/workspaces.ts","../../src/index.ts"],"sourcesContent":["/** Successful API response wrapper */\nexport interface ApiResponse<T> {\n data: T;\n}\n\n/** Paginated API response */\nexport interface PaginatedResponse<T> {\n data: T[];\n pagination: {\n has_more: boolean;\n next_cursor: string | null;\n };\n}\n\n/** API error thrown by the client */\nexport class MedalApiError extends Error {\n readonly status: number;\n readonly code: string;\n readonly details?: unknown;\n\n constructor(status: number, code: string, message: string, details?: unknown) {\n super(message);\n this.name = \"MedalApiError\";\n this.status = status;\n this.code = code;\n this.details = details;\n }\n}\n\n/** Pagination options for list endpoints */\nexport interface PaginationOptions {\n limit?: number;\n cursor?: string;\n}\n","import { MedalApiError } from \"./types/common\";\n\n/** Configuration for the low-level HTTP client. */\nexport interface ClientConfig {\n baseUrl: string;\n token: string;\n workspaceId?: string;\n timeout: number;\n userAgent: string;\n}\n\n/**\n * Low-level HTTP client used by all resource classes.\n * Handles authentication, retries, timeout, and error parsing.\n */\nexport class BaseClient {\n /** Resolved client configuration. */\n readonly config: ClientConfig;\n\n constructor(config: ClientConfig) {\n this.config = config;\n }\n\n /** Execute an authenticated GET request and return the parsed JSON body. */\n async get<T>(path: string, params?: Record<string, string | undefined>): Promise<T> {\n const url = this.buildUrl(path, params);\n return this.request<T>(url, { method: \"GET\" });\n }\n\n /** Execute an authenticated POST request with a JSON body. */\n async post<T>(path: string, body?: unknown): Promise<T> {\n return this.request<T>(this.buildUrl(path), {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n }\n\n /** Execute an authenticated PATCH request with a JSON body. */\n async patch<T>(path: string, body: unknown): Promise<T> {\n return this.request<T>(this.buildUrl(path), {\n method: \"PATCH\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(body),\n });\n }\n\n /** Execute an authenticated DELETE request. */\n async delete<T>(path: string): Promise<T> {\n return this.request<T>(this.buildUrl(path), { method: \"DELETE\" });\n }\n\n private buildUrl(path: string, params?: Record<string, string | undefined>): string {\n const url = new URL(`${this.config.baseUrl}${path}`);\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n url.searchParams.set(key, value);\n }\n }\n }\n return url.toString();\n }\n\n private async request<T>(url: string, init: RequestInit): Promise<T> {\n const maxAttempts = 3;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n const headers = new Headers(init.headers);\n headers.set(\"authorization\", `Bearer ${this.config.token}`);\n if (this.config.workspaceId) {\n headers.set(\"x-workspace-id\", this.config.workspaceId);\n }\n try {\n headers.set(\"user-agent\", this.config.userAgent);\n } catch {\n // Browsers disallow setting user-agent\n }\n\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.config.timeout);\n\n let res: Response;\n try {\n res = await fetch(url, { ...init, headers, signal: controller.signal });\n } finally {\n clearTimeout(timeout);\n }\n\n // Retry on 429 / 5xx (but not on the final attempt)\n if (\n (res.status === 429 || (res.status >= 500 && res.status <= 599)) &&\n attempt < maxAttempts\n ) {\n const retryAfter = res.headers.get(\"retry-after\");\n let delayMs = 0;\n if (retryAfter) {\n const seconds = Number(retryAfter);\n delayMs = Number.isFinite(seconds) ? seconds * 1000 : 0;\n }\n if (delayMs <= 0) {\n delayMs = 250 * attempt;\n }\n await new Promise((r) => setTimeout(r, delayMs));\n continue;\n }\n\n // Parse response\n const text = await res.text();\n let parsed: unknown;\n try {\n parsed = text ? JSON.parse(text) : undefined;\n } catch {\n parsed = text;\n }\n\n if (!res.ok) {\n const body = parsed as\n | { error?: { code?: string; message?: string; details?: unknown } }\n | undefined;\n throw new MedalApiError(\n res.status,\n body?.error?.code ?? \"UNKNOWN_ERROR\",\n body?.error?.message ?? `HTTP ${res.status}: ${res.statusText}`,\n body?.error?.details,\n );\n }\n\n return parsed as T;\n }\n\n /* v8 ignore next -- unreachable: loop always returns or throws */\n throw new Error(\"Request failed after retries\");\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse, PaginatedResponse, PaginationOptions } from \"../types/common\";\nimport type {\n Activity,\n AddNoteInput,\n Contact,\n ContactCreateResult,\n ContactNoteResult,\n ContactRemoveResult,\n ContactUpdateResult,\n CreateContactInput,\n ImportContactInput,\n ImportContactsResult,\n ListContactsOptions,\n UpdateContactInput,\n} from \"../types/contacts\";\n\n/** Manage contacts in the workspace CRM. */\nexport class Contacts {\n constructor(private client: BaseClient) {}\n\n /** List contacts with cursor-based pagination and optional filters. */\n async list(options?: ListContactsOptions): Promise<PaginatedResponse<Contact>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n if (options?.status) params.status = options.status;\n if (options?.email_status) params.email_status = options.email_status;\n if (options?.label_ids) params.label_ids = options.label_ids.join(\",\");\n if (options?.search) params.search = options.search;\n return this.client.get(\"/api/v1/contacts\", params);\n }\n\n /** Create a new contact. Email must be unique in the workspace. */\n async create(input: CreateContactInput): Promise<ApiResponse<ContactCreateResult>> {\n return this.client.post(\"/api/v1/contacts\", input);\n }\n\n /** Get a contact by ID. */\n async get(id: string): Promise<ApiResponse<Contact>> {\n return this.client.get(`/api/v1/contacts/${encodeURIComponent(id)}`);\n }\n\n /** Update one or more fields on a contact. */\n async update(id: string, input: UpdateContactInput): Promise<ApiResponse<ContactUpdateResult>> {\n return this.client.patch(`/api/v1/contacts/${encodeURIComponent(id)}`, input);\n }\n\n /** Permanently delete a contact. */\n async remove(id: string): Promise<ApiResponse<ContactRemoveResult>> {\n return this.client.delete(`/api/v1/contacts/${encodeURIComponent(id)}`);\n }\n\n /** Get the activity timeline for a contact. */\n async activities(id: string, options?: PaginationOptions): Promise<PaginatedResponse<Activity>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n return this.client.get(`/api/v1/contacts/${encodeURIComponent(id)}/activities`, params);\n }\n\n /** Add a note to a contact's timeline. */\n async addNote(id: string, input: AddNoteInput): Promise<ApiResponse<ContactNoteResult>> {\n return this.client.post(`/api/v1/contacts/${encodeURIComponent(id)}/notes`, input);\n }\n\n /** Bulk import contacts (max 500). Duplicates are skipped. */\n async import(contacts: ImportContactInput[]): Promise<ApiResponse<ImportContactsResult>> {\n return this.client.post(\"/api/v1/contacts/import\", { contacts });\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse, PaginatedResponse } from \"../types/common\";\nimport type {\n CreateDealInput,\n Deal,\n DealCreateResult,\n DealRemoveResult,\n DealUpdateResult,\n ListDealsOptions,\n UpdateDealInput,\n} from \"../types/deals\";\n\n/** Manage sponsorship deals in the workspace. */\nexport class Deals {\n constructor(private client: BaseClient) {}\n\n /** List deals with cursor-based pagination and optional filters. */\n async list(options?: ListDealsOptions): Promise<PaginatedResponse<Deal>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n if (options?.status) params.status = options.status;\n if (options?.search) params.search = options.search;\n return this.client.get(\"/api/v1/deals\", params);\n }\n\n /** Create a new deal. */\n async create(input: CreateDealInput): Promise<ApiResponse<DealCreateResult>> {\n return this.client.post(\"/api/v1/deals\", input);\n }\n\n /** Get a deal by ID. */\n async get(id: string): Promise<ApiResponse<Deal>> {\n return this.client.get(`/api/v1/deals/${encodeURIComponent(id)}`);\n }\n\n /** Update one or more fields on a deal. Set contact_id to null to unlink. */\n async update(id: string, input: UpdateDealInput): Promise<ApiResponse<DealUpdateResult>> {\n return this.client.patch(`/api/v1/deals/${encodeURIComponent(id)}`, input);\n }\n\n /** Permanently delete a deal. */\n async remove(id: string): Promise<ApiResponse<DealRemoveResult>> {\n return this.client.delete(`/api/v1/deals/${encodeURIComponent(id)}`);\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse } from \"../types/common\";\nimport type {\n BatchSendInput,\n BatchSendSummary,\n EmailSend,\n EmailSendResult,\n EmailTemplate,\n EmailTemplateDetail,\n GetTemplateOptions,\n SendEmailInput,\n} from \"../types/emails\";\n\n/** Manage email templates stored in the workspace. */\nclass EmailTemplates {\n constructor(private client: BaseClient) {}\n\n /** List all active email templates in the workspace. */\n async list(): Promise<ApiResponse<EmailTemplate[]>> {\n return this.client.get(\"/api/v1/emails/templates\");\n }\n\n /** Get a specific email template by slug, optionally with locale resolution. */\n async get(slug: string, options?: GetTemplateOptions): Promise<ApiResponse<EmailTemplateDetail>> {\n const params: Record<string, string | undefined> = {};\n if (options?.locale) params.locale = options.locale;\n if (options?.fallback_locale) params.fallback_locale = options.fallback_locale;\n return this.client.get(`/api/v1/emails/templates/${encodeURIComponent(slug)}`, params);\n }\n}\n\n/** Send transactional emails and manage templates. */\nexport class Emails {\n readonly templates: EmailTemplates;\n\n constructor(private client: BaseClient) {\n this.templates = new EmailTemplates(client);\n }\n\n /** Send a transactional email using a template. Returns a queued job ID (HTTP 202). */\n async send(input: SendEmailInput): Promise<ApiResponse<EmailSendResult>> {\n return this.client.post(\"/api/v1/emails\", input);\n }\n\n /** Get the delivery status of a sent email. */\n async get(id: string): Promise<ApiResponse<EmailSend>> {\n return this.client.get(`/api/v1/emails/${encodeURIComponent(id)}`);\n }\n\n /** Send the same template to multiple recipients (max 100). Returns HTTP 202. */\n async batch(input: BatchSendInput): Promise<ApiResponse<BatchSendSummary>> {\n return this.client.post(\"/api/v1/emails/batch\", input);\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse } from \"../types/common\";\nimport type {\n ConsentRecord,\n ConsentResult,\n CookieConsentInput,\n GdprExport,\n RecordConsentInput,\n} from \"../types/gdpr\";\n\n/** Manage GDPR compliance — data exports, consent records, and cookie consent. */\nexport class Gdpr {\n constructor(private client: BaseClient) {}\n\n /** Request a workspace data export. Runs asynchronously. */\n async requestExport(): Promise<ApiResponse<{ request_id: string; status: string }>> {\n return this.client.post(\"/api/v1/gdpr/export\");\n }\n\n /** List all workspace export requests. */\n async listExports(): Promise<ApiResponse<GdprExport[]>> {\n return this.client.get(\"/api/v1/gdpr/exports\");\n }\n\n /** Get the status of a specific export. */\n async getExport(id: string): Promise<ApiResponse<GdprExport>> {\n return this.client.get(`/api/v1/gdpr/exports/${encodeURIComponent(id)}`);\n }\n\n /** Record a GDPR consent decision for a contact by email. */\n async recordConsent(input: RecordConsentInput): Promise<ApiResponse<ConsentResult>> {\n return this.client.post(\"/api/v1/gdpr/consent\", input);\n }\n\n /** Get all consent records for a contact by email. */\n async getConsent(email: string): Promise<ApiResponse<ConsentRecord[]>> {\n return this.client.get(`/api/v1/gdpr/consent/${encodeURIComponent(email)}`);\n }\n\n /** Record cookie consent from an external site (legacy endpoint). */\n async cookieConsent(input: CookieConsentInput): Promise<{ success: boolean; logId?: string }> {\n return this.client.post(\"/api/cookie-consent\", input);\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse, PaginatedResponse } from \"../types/common\";\nimport type {\n Channel,\n CreatePostInput,\n ListPostsOptions,\n Post,\n PostDetail,\n PublishResult,\n SchedulePostInput,\n ScheduleResult,\n UpdatePostInput,\n} from \"../types/posts\";\n\n/** Create and publish posts across connected channels. */\nexport class Posts {\n constructor(private client: BaseClient) {}\n\n /** List posts with cursor-based pagination and optional filters. */\n async list(options?: ListPostsOptions): Promise<PaginatedResponse<Post>> {\n const params: Record<string, string | undefined> = {};\n if (options?.limit !== undefined) params.limit = String(options.limit);\n if (options?.cursor) params.cursor = options.cursor;\n if (options?.status) params.status = options.status;\n if (options?.type) params.type = options.type;\n return this.client.get(\"/api/v1/posts\", params);\n }\n\n /** Create a new post with content and target channels. */\n async create(input: CreatePostInput): Promise<ApiResponse<{ id: string }>> {\n return this.client.post(\"/api/v1/posts\", input);\n }\n\n /** Get a post by ID, including its per-channel variants. */\n async get(id: string): Promise<ApiResponse<PostDetail>> {\n return this.client.get(`/api/v1/posts/${encodeURIComponent(id)}`);\n }\n\n /** Update a draft post's title or content. */\n async update(id: string, input: UpdatePostInput): Promise<ApiResponse<{ success: boolean }>> {\n return this.client.patch(`/api/v1/posts/${encodeURIComponent(id)}`, input);\n }\n\n /** Delete a post. */\n async remove(id: string): Promise<ApiResponse<{ success: boolean }>> {\n return this.client.delete(`/api/v1/posts/${encodeURIComponent(id)}`);\n }\n\n /** Schedule a post for future publication. */\n async schedule(id: string, input: SchedulePostInput): Promise<ApiResponse<ScheduleResult>> {\n return this.client.post(`/api/v1/posts/${encodeURIComponent(id)}/schedule`, input);\n }\n\n /** Publish a post immediately to all target channels. */\n async publish(id: string): Promise<ApiResponse<PublishResult>> {\n return this.client.post(`/api/v1/posts/${encodeURIComponent(id)}/publish`);\n }\n\n /** List connected publishing channels for this workspace. */\n async channels(): Promise<ApiResponse<Channel[]>> {\n return this.client.get(\"/api/v1/posts/channels\");\n }\n}\n","import type { BaseClient } from \"../client\";\nimport type { ApiResponse } from \"../types/common\";\nimport type { Workspace } from \"../types/workspaces\";\n\n/** Access workspaces for the authenticated credential. */\nexport class Workspaces {\n constructor(private client: BaseClient) {}\n\n /** List workspaces accessible to the current API key or OAuth token. */\n async list(): Promise<ApiResponse<Workspace[]>> {\n return this.client.get(\"/api/v1/me/workspaces\");\n }\n}\n","/**\n * Official TypeScript SDK for the Medal Social API.\n *\n * Provides typed access to posts, emails, contacts, deals, GDPR compliance,\n * and workspace management. Works in Node.js, Deno, Bun, Cloudflare Workers,\n * and modern browsers.\n *\n * @example\n * ```ts\n * import { Medal } from \"@medalsocial/sdk\";\n *\n * const medal = new Medal(\"medal_xxx\");\n * const { data: post } = await medal.posts.create({\n * content: \"Hello world!\",\n * channel_ids: [\"ch_1\"],\n * });\n * ```\n *\n * @module\n */\nimport { BaseClient } from \"./client\";\nimport { Contacts } from \"./resources/contacts\";\nimport { Deals } from \"./resources/deals\";\nimport { Emails } from \"./resources/emails\";\nimport { Gdpr } from \"./resources/gdpr\";\nimport { Posts } from \"./resources/posts\";\nimport { Workspaces } from \"./resources/workspaces\";\n\n/** Options for configuring the {@link Medal} client. */\nexport interface MedalOptions {\n /** Override the base URL (defaults to https://io.medalsocial.com). */\n baseUrl?: string;\n /** Request timeout in ms (default 30000). */\n timeout?: number;\n /**\n * Workspace ID — required for OAuth access tokens, ignored for API keys.\n * API keys are scoped to a single workspace, so the workspace is inferred.\n * OAuth tokens can access multiple workspaces, so you must specify which one.\n */\n workspaceId?: string;\n}\n\n/**\n * Medal Social SDK client.\n *\n * Supports both API key and OAuth access token authentication:\n *\n * @example API Key (recommended for server-side)\n * ```ts\n * import { Medal } from '@medalsocial/sdk';\n *\n * // API keys start with medal_ and are scoped to one workspace\n * const medal = new Medal('medal_xxx');\n * ```\n *\n * @example OAuth Access Token\n * ```ts\n * // OAuth tokens require a workspaceId\n * const medal = new Medal('oauth_access_token', {\n * workspaceId: 'workspace_id_here',\n * });\n * ```\n *\n * @example Full usage\n * ```ts\n * const medal = new Medal('medal_xxx');\n *\n * // Posts — create, schedule, publish\n * const { data: post } = await medal.posts.create({\n * content: 'Hello world!',\n * channel_ids: ['ch_1'],\n * });\n * await medal.posts.schedule(post.id, { scheduled_at: '2026-03-15T10:00:00Z' });\n *\n * // Emails — send transactional emails\n * await medal.emails.send({\n * template_slug: 'welcome',\n * to: 'user@example.com',\n * variables: { name: 'John' },\n * });\n *\n * // Contacts, Deals, GDPR, Workspaces\n * const contacts = await medal.contacts.list({ status: 'lead' });\n * const { data: deal } = await medal.deals.create({ title: 'Acme', value: 50000 });\n * await medal.gdpr.recordConsent({ email: 'u@x.com', consent_type: 'marketing_email', granted: true });\n * const { data: workspaces } = await medal.workspaces.list();\n * ```\n */\nexport class Medal {\n readonly emails: Emails;\n readonly contacts: Contacts;\n readonly deals: Deals;\n readonly gdpr: Gdpr;\n readonly posts: Posts;\n readonly workspaces: Workspaces;\n\n constructor(token: string, options?: MedalOptions) {\n if (!token) {\n throw new Error(\n \"Authentication token is required. Pass your medal_xxx API key or OAuth access token as the first argument.\",\n );\n }\n\n const client = new BaseClient({\n baseUrl: (options?.baseUrl ?? \"https://io.medalsocial.com\").replace(/\\/$/, \"\"),\n token,\n workspaceId: options?.workspaceId,\n timeout: options?.timeout ?? 30000,\n userAgent: \"medalsocial-sdk/1.0.0 (+https://github.com/Medal-Social/MedalSocial)\",\n });\n\n this.emails = new Emails(client);\n this.contacts = new Contacts(client);\n this.deals = new Deals(client);\n this.gdpr = new Gdpr(client);\n this.posts = new Posts(client);\n this.workspaces = new Workspaces(client);\n }\n}\n\n// Re-export all types\nexport { MedalApiError } from \"./types/common\";\nexport type { ApiResponse, PaginatedResponse, PaginationOptions } from \"./types/common\";\nexport type {\n SendEmailInput,\n EmailSendResult,\n EmailSend,\n BatchSendInput,\n BatchSendSummary,\n BatchSendResult,\n EmailTemplate,\n EmailTemplateDetail,\n GetTemplateOptions,\n} from \"./types/emails\";\nexport type {\n Contact,\n ContactCreateResult,\n ContactUpdateResult,\n ContactRemoveResult,\n ContactNoteResult,\n ContactStatus,\n EmailStatus,\n CreateContactInput,\n UpdateContactInput,\n ListContactsOptions,\n ImportContactInput,\n ImportContactsResult,\n Activity,\n AddNoteInput,\n} from \"./types/contacts\";\nexport type {\n Deal,\n DealCreateResult,\n DealUpdateResult,\n DealRemoveResult,\n DealStatus,\n CreateDealInput,\n UpdateDealInput,\n ListDealsOptions,\n} from \"./types/deals\";\nexport type {\n GdprExport,\n ConsentType,\n RecordConsentInput,\n ConsentRecord,\n ConsentResult,\n ContactConsents,\n CookieConsentInput,\n CookieCategoryConsent,\n} from \"./types/gdpr\";\nexport type {\n Post,\n PostType,\n PostVariant,\n PostDetail,\n Channel,\n CreatePostInput,\n UpdatePostInput,\n SchedulePostInput,\n ListPostsOptions,\n ScheduleResult,\n PublishResult,\n} from \"./types/posts\";\nexport type { Workspace } from \"./types/workspaces\";\n\n// Resource class re-exports (for advanced usage)\nexport { Emails } from \"./resources/emails\";\nexport { Contacts } from \"./resources/contacts\";\nexport { Deals } from \"./resources/deals\";\nexport { Gdpr } from \"./resources/gdpr\";\nexport { Posts } from \"./resources/posts\";\nexport { Workspaces } from \"./resources/workspaces\";\nexport { BaseClient } from \"./client\";\n\n/** Convenience factory — equivalent to `new Medal(apiKey, options)`. */\nexport function createMedalClient(apiKey: string, options?: MedalOptions): Medal {\n return new Medal(apiKey, options);\n}\n\nexport default Medal;\n"],"mappings":";AAeO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,QAAgB,MAAc,SAAiB,SAAmB;AAC5E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,UAAU;AAAA,EACjB;AACF;;;ACZO,IAAM,aAAN,MAAiB;AAAA;AAAA,EAEb;AAAA,EAET,YAAY,QAAsB;AAChC,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA,EAGA,MAAM,IAAO,MAAc,QAAyD;AAClF,UAAM,MAAM,KAAK,SAAS,MAAM,MAAM;AACtC,WAAO,KAAK,QAAW,KAAK,EAAE,QAAQ,MAAM,CAAC;AAAA,EAC/C;AAAA;AAAA,EAGA,MAA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