smartletter 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,2912 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Resend: () => Smartletter,
34
+ Smartletter: () => Smartletter,
35
+ WebhookVerificationError: () => WebhookVerificationError
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+
39
+ // src/case.ts
40
+ function toWire(value, tree) {
41
+ if (!tree || value === null || typeof value !== "object") return value;
42
+ if (Array.isArray(value)) return value.map((item) => toWire(item, tree));
43
+ if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) return value;
44
+ const out = {};
45
+ for (const [key, v] of Object.entries(value)) {
46
+ const node = tree[key];
47
+ out[node ? node.wire : key] = node ? toWire(v, node.items ?? node.props) : v;
48
+ }
49
+ return out;
50
+ }
51
+
52
+ // src/client.ts
53
+ var UNRESOLVED_MESSAGE = "Unable to fetch data. The request could not be resolved.";
54
+ var DEFAULT_BASE_URL = "https://api.smartletter.ai";
55
+ function env(name) {
56
+ return typeof process !== "undefined" ? process.env?.[name] || void 0 : void 0;
57
+ }
58
+ function camel(snake) {
59
+ return snake.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
60
+ }
61
+ function applicationError(message, statusCode) {
62
+ return { name: "application_error", message, statusCode };
63
+ }
64
+ function isEmptyObject(value) {
65
+ return !!value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0;
66
+ }
67
+ var Client = class {
68
+ key;
69
+ baseUrl;
70
+ userAgent;
71
+ constructor(key, options = {}) {
72
+ const resendKey = env("RESEND_API_KEY");
73
+ const resolved = key || env("SMARTLETTER_API_KEY") || (resendKey && /^(sl_|re_)/.test(resendKey) ? resendKey : void 0);
74
+ if (!resolved) {
75
+ throw new Error(
76
+ 'Missing API key. Pass it to the constructor `new Smartletter("sl_123")` or set SMARTLETTER_API_KEY.'
77
+ );
78
+ }
79
+ if (resolved.startsWith("re_")) {
80
+ throw new Error("This is a Resend key (re_\u2026). Create a Smartletter key (sl_\u2026) in Settings \u2192 API keys.");
81
+ }
82
+ this.key = resolved;
83
+ this.baseUrl = (options.baseUrl || env("SMARTLETTER_BASE_URL") || DEFAULT_BASE_URL).replace(/\/+$/, "");
84
+ this.userAgent = options.userAgent ?? `smartletter-node/${"1.0.0"}`;
85
+ }
86
+ async call(op, args, options = {}) {
87
+ const headers = new Headers(options.headers);
88
+ headers.set("Authorization", `Bearer ${this.key}`);
89
+ headers.set("User-Agent", this.userAgent);
90
+ if (options.idempotencyKey) headers.set("Idempotency-Key", options.idempotencyKey);
91
+ let path = op.path;
92
+ let rest = args;
93
+ if (op.pathParams.length > 0 && !Array.isArray(args)) {
94
+ const copy = { ...args ?? {} };
95
+ for (const wireName of op.pathParams) {
96
+ const name = camel(wireName);
97
+ const value = copy[name] ?? copy[wireName];
98
+ if (value === void 0 || value === null || value === "") {
99
+ return {
100
+ data: null,
101
+ error: { name: "missing_required_field", statusCode: null, message: `Missing \`${name}\` field.` },
102
+ headers: null
103
+ };
104
+ }
105
+ path = path.replace(`{${wireName}}`, encodeURIComponent(String(value)));
106
+ delete copy[name];
107
+ delete copy[wireName];
108
+ }
109
+ rest = copy;
110
+ }
111
+ let url = `${this.baseUrl}${path}`;
112
+ let body;
113
+ if (op.rawBody) {
114
+ body = args;
115
+ if (body !== void 0) headers.set("Content-Type", "application/octet-stream");
116
+ } else if (op.method === "GET") {
117
+ const params = new URLSearchParams();
118
+ const wire = toWire(rest, op.query) ?? {};
119
+ for (const [k, v] of Object.entries(wire)) {
120
+ if (v === void 0 || v === null) continue;
121
+ params.set(k, String(v));
122
+ }
123
+ const qs = params.toString();
124
+ if (qs) url += `?${qs}`;
125
+ } else if (rest !== void 0 && !isEmptyObject(rest)) {
126
+ const wire = op.bodyIsArray && Array.isArray(rest) ? rest.map((i) => toWire(i, op.body)) : toWire(rest, op.body);
127
+ body = JSON.stringify(wire);
128
+ headers.set("Content-Type", "application/json");
129
+ }
130
+ const unresolved = {
131
+ data: null,
132
+ error: applicationError(UNRESOLVED_MESSAGE, null),
133
+ headers: null
134
+ };
135
+ let response;
136
+ try {
137
+ response = await fetch(url, { method: op.method, headers, body, signal: options.signal });
138
+ } catch {
139
+ return unresolved;
140
+ }
141
+ const responseHeaders = Object.fromEntries(response.headers);
142
+ if (!response.ok) {
143
+ let text2;
144
+ try {
145
+ text2 = await response.text();
146
+ } catch (err) {
147
+ const message = err instanceof Error ? err.message : response.statusText;
148
+ return { data: null, error: applicationError(message, response.status), headers: responseHeaders };
149
+ }
150
+ try {
151
+ return { data: null, error: JSON.parse(text2), headers: responseHeaders };
152
+ } catch {
153
+ return {
154
+ data: null,
155
+ error: applicationError(
156
+ "Internal server error. We are unable to process your request right now, please try again later.",
157
+ response.status
158
+ ),
159
+ headers: responseHeaders
160
+ };
161
+ }
162
+ }
163
+ let text;
164
+ try {
165
+ text = await response.text();
166
+ } catch {
167
+ return unresolved;
168
+ }
169
+ if (op.responseType === "text") return { data: text, error: null, headers: responseHeaders };
170
+ if (text === "") return { data: null, error: null, headers: responseHeaders };
171
+ try {
172
+ return { data: JSON.parse(text), error: null, headers: responseHeaders };
173
+ } catch {
174
+ return { ...unresolved, headers: responseHeaders };
175
+ }
176
+ }
177
+ };
178
+
179
+ // src/generated/operations.ts
180
+ var OPERATIONS = {
181
+ "emails.send": {
182
+ id: "emails.send",
183
+ method: "POST",
184
+ path: "/emails",
185
+ pathParams: [],
186
+ paginated: false,
187
+ idempotent: true,
188
+ body: {
189
+ from: {
190
+ wire: "from"
191
+ },
192
+ to: {
193
+ wire: "to"
194
+ },
195
+ subject: {
196
+ wire: "subject"
197
+ },
198
+ template: {
199
+ wire: "template",
200
+ props: {
201
+ id: {
202
+ wire: "id"
203
+ },
204
+ variables: {
205
+ wire: "variables"
206
+ }
207
+ }
208
+ },
209
+ html: {
210
+ wire: "html"
211
+ },
212
+ text: {
213
+ wire: "text"
214
+ },
215
+ cc: {
216
+ wire: "cc"
217
+ },
218
+ bcc: {
219
+ wire: "bcc"
220
+ },
221
+ replyTo: {
222
+ wire: "reply_to"
223
+ },
224
+ headers: {
225
+ wire: "headers"
226
+ },
227
+ tags: {
228
+ wire: "tags",
229
+ items: {
230
+ name: {
231
+ wire: "name"
232
+ },
233
+ value: {
234
+ wire: "value"
235
+ }
236
+ }
237
+ },
238
+ scheduledAt: {
239
+ wire: "scheduled_at"
240
+ },
241
+ attachments: {
242
+ wire: "attachments",
243
+ items: {
244
+ content: {
245
+ wire: "content"
246
+ },
247
+ path: {
248
+ wire: "path"
249
+ },
250
+ filename: {
251
+ wire: "filename"
252
+ },
253
+ contentType: {
254
+ wire: "content_type"
255
+ },
256
+ contentId: {
257
+ wire: "content_id"
258
+ }
259
+ }
260
+ }
261
+ }
262
+ },
263
+ "batch.send": {
264
+ id: "batch.send",
265
+ method: "POST",
266
+ path: "/emails/batch",
267
+ pathParams: [],
268
+ paginated: false,
269
+ idempotent: true,
270
+ bodyIsArray: true,
271
+ body: {
272
+ from: {
273
+ wire: "from"
274
+ },
275
+ to: {
276
+ wire: "to"
277
+ },
278
+ subject: {
279
+ wire: "subject"
280
+ },
281
+ template: {
282
+ wire: "template",
283
+ props: {
284
+ id: {
285
+ wire: "id"
286
+ },
287
+ variables: {
288
+ wire: "variables"
289
+ }
290
+ }
291
+ },
292
+ html: {
293
+ wire: "html"
294
+ },
295
+ text: {
296
+ wire: "text"
297
+ },
298
+ cc: {
299
+ wire: "cc"
300
+ },
301
+ bcc: {
302
+ wire: "bcc"
303
+ },
304
+ replyTo: {
305
+ wire: "reply_to"
306
+ },
307
+ headers: {
308
+ wire: "headers"
309
+ },
310
+ tags: {
311
+ wire: "tags",
312
+ items: {
313
+ name: {
314
+ wire: "name"
315
+ },
316
+ value: {
317
+ wire: "value"
318
+ }
319
+ }
320
+ },
321
+ scheduledAt: {
322
+ wire: "scheduled_at"
323
+ }
324
+ }
325
+ },
326
+ "emails.list": {
327
+ id: "emails.list",
328
+ method: "GET",
329
+ path: "/emails",
330
+ pathParams: [],
331
+ paginated: true,
332
+ idempotent: false,
333
+ query: {
334
+ limit: {
335
+ wire: "limit"
336
+ },
337
+ after: {
338
+ wire: "after"
339
+ },
340
+ before: {
341
+ wire: "before"
342
+ }
343
+ }
344
+ },
345
+ "emails.get": {
346
+ id: "emails.get",
347
+ method: "GET",
348
+ path: "/emails/{id}",
349
+ pathParams: ["id"],
350
+ paginated: false,
351
+ idempotent: false
352
+ },
353
+ "emails.update": {
354
+ id: "emails.update",
355
+ method: "PATCH",
356
+ path: "/emails/{id}",
357
+ pathParams: ["id"],
358
+ paginated: false,
359
+ idempotent: false,
360
+ body: {
361
+ scheduledAt: {
362
+ wire: "scheduled_at"
363
+ }
364
+ }
365
+ },
366
+ "emails.cancel": {
367
+ id: "emails.cancel",
368
+ method: "POST",
369
+ path: "/emails/{id}/cancel",
370
+ pathParams: ["id"],
371
+ paginated: false,
372
+ idempotent: false
373
+ },
374
+ "templates.create": {
375
+ id: "templates.create",
376
+ method: "POST",
377
+ path: "/templates",
378
+ pathParams: [],
379
+ paginated: false,
380
+ idempotent: false,
381
+ body: {
382
+ name: {
383
+ wire: "name"
384
+ },
385
+ alias: {
386
+ wire: "alias"
387
+ },
388
+ from: {
389
+ wire: "from"
390
+ },
391
+ subject: {
392
+ wire: "subject"
393
+ },
394
+ replyTo: {
395
+ wire: "reply_to"
396
+ },
397
+ html: {
398
+ wire: "html"
399
+ },
400
+ text: {
401
+ wire: "text"
402
+ },
403
+ variables: {
404
+ wire: "variables",
405
+ items: {
406
+ key: {
407
+ wire: "key"
408
+ },
409
+ type: {
410
+ wire: "type"
411
+ },
412
+ fallbackValue: {
413
+ wire: "fallback_value"
414
+ },
415
+ required: {
416
+ wire: "required"
417
+ }
418
+ }
419
+ }
420
+ }
421
+ },
422
+ "templates.list": {
423
+ id: "templates.list",
424
+ method: "GET",
425
+ path: "/templates",
426
+ pathParams: [],
427
+ paginated: true,
428
+ idempotent: false,
429
+ query: {
430
+ limit: {
431
+ wire: "limit"
432
+ },
433
+ after: {
434
+ wire: "after"
435
+ },
436
+ before: {
437
+ wire: "before"
438
+ }
439
+ }
440
+ },
441
+ "templates.get": {
442
+ id: "templates.get",
443
+ method: "GET",
444
+ path: "/templates/{id}",
445
+ pathParams: ["id"],
446
+ paginated: false,
447
+ idempotent: false
448
+ },
449
+ "templates.update": {
450
+ id: "templates.update",
451
+ method: "PATCH",
452
+ path: "/templates/{id}",
453
+ pathParams: ["id"],
454
+ paginated: false,
455
+ idempotent: false,
456
+ body: {
457
+ name: {
458
+ wire: "name"
459
+ },
460
+ alias: {
461
+ wire: "alias"
462
+ },
463
+ from: {
464
+ wire: "from"
465
+ },
466
+ subject: {
467
+ wire: "subject"
468
+ },
469
+ replyTo: {
470
+ wire: "reply_to"
471
+ },
472
+ html: {
473
+ wire: "html"
474
+ },
475
+ text: {
476
+ wire: "text"
477
+ },
478
+ variables: {
479
+ wire: "variables",
480
+ items: {
481
+ key: {
482
+ wire: "key"
483
+ },
484
+ type: {
485
+ wire: "type"
486
+ },
487
+ fallbackValue: {
488
+ wire: "fallback_value"
489
+ },
490
+ required: {
491
+ wire: "required"
492
+ }
493
+ }
494
+ },
495
+ changeNote: {
496
+ wire: "change_note"
497
+ }
498
+ }
499
+ },
500
+ "templates.remove": {
501
+ id: "templates.remove",
502
+ method: "DELETE",
503
+ path: "/templates/{id}",
504
+ pathParams: ["id"],
505
+ paginated: false,
506
+ idempotent: false
507
+ },
508
+ "templates.publish": {
509
+ id: "templates.publish",
510
+ method: "POST",
511
+ path: "/templates/{id}/publish",
512
+ pathParams: ["id"],
513
+ paginated: false,
514
+ idempotent: false,
515
+ body: {
516
+ versionId: {
517
+ wire: "version_id"
518
+ }
519
+ }
520
+ },
521
+ "templates.duplicate": {
522
+ id: "templates.duplicate",
523
+ method: "POST",
524
+ path: "/templates/{id}/duplicate",
525
+ pathParams: ["id"],
526
+ paginated: false,
527
+ idempotent: false
528
+ },
529
+ "templates.versions": {
530
+ id: "templates.versions",
531
+ method: "GET",
532
+ path: "/templates/{id}/versions",
533
+ pathParams: ["id"],
534
+ paginated: true,
535
+ idempotent: false,
536
+ query: {
537
+ limit: {
538
+ wire: "limit"
539
+ },
540
+ after: {
541
+ wire: "after"
542
+ },
543
+ before: {
544
+ wire: "before"
545
+ }
546
+ }
547
+ },
548
+ "newsletters.list": {
549
+ id: "newsletters.list",
550
+ method: "GET",
551
+ path: "/newsletters",
552
+ pathParams: [],
553
+ paginated: true,
554
+ idempotent: false,
555
+ query: {
556
+ limit: {
557
+ wire: "limit"
558
+ },
559
+ after: {
560
+ wire: "after"
561
+ },
562
+ before: {
563
+ wire: "before"
564
+ },
565
+ status: {
566
+ wire: "status"
567
+ }
568
+ }
569
+ },
570
+ "newsletters.create": {
571
+ id: "newsletters.create",
572
+ method: "POST",
573
+ path: "/newsletters",
574
+ pathParams: [],
575
+ paginated: false,
576
+ idempotent: false,
577
+ body: {
578
+ subject: {
579
+ wire: "subject"
580
+ },
581
+ preheader: {
582
+ wire: "preheader"
583
+ },
584
+ segmentId: {
585
+ wire: "segment_id"
586
+ },
587
+ topicId: {
588
+ wire: "topic_id"
589
+ },
590
+ markdown: {
591
+ wire: "markdown"
592
+ },
593
+ html: {
594
+ wire: "html"
595
+ },
596
+ blocks: {
597
+ wire: "blocks",
598
+ items: {
599
+ kind: {
600
+ wire: "kind"
601
+ },
602
+ level: {
603
+ wire: "level"
604
+ },
605
+ text: {
606
+ wire: "text"
607
+ },
608
+ ordered: {
609
+ wire: "ordered"
610
+ },
611
+ items: {
612
+ wire: "items"
613
+ },
614
+ url: {
615
+ wire: "url"
616
+ },
617
+ alt: {
618
+ wire: "alt"
619
+ },
620
+ label: {
621
+ wire: "label"
622
+ },
623
+ title: {
624
+ wire: "title"
625
+ },
626
+ imageUrl: {
627
+ wire: "imageUrl"
628
+ },
629
+ price: {
630
+ wire: "price"
631
+ },
632
+ description: {
633
+ wire: "description"
634
+ },
635
+ ctaLabel: {
636
+ wire: "ctaLabel"
637
+ },
638
+ html: {
639
+ wire: "html"
640
+ },
641
+ columns: {
642
+ wire: "columns"
643
+ }
644
+ }
645
+ },
646
+ audienceFilterId: {
647
+ wire: "audience_filter_id"
648
+ },
649
+ abTest: {
650
+ wire: "ab_test",
651
+ props: {
652
+ variants: {
653
+ wire: "variants",
654
+ items: {
655
+ subject: {
656
+ wire: "subject"
657
+ },
658
+ preheader: {
659
+ wire: "preheader"
660
+ }
661
+ }
662
+ },
663
+ samplePct: {
664
+ wire: "sample_pct"
665
+ },
666
+ metric: {
667
+ wire: "metric"
668
+ },
669
+ waitHours: {
670
+ wire: "wait_hours"
671
+ },
672
+ winnerMode: {
673
+ wire: "winner_mode"
674
+ }
675
+ }
676
+ }
677
+ }
678
+ },
679
+ "newsletters.get": {
680
+ id: "newsletters.get",
681
+ method: "GET",
682
+ path: "/newsletters/{id}",
683
+ pathParams: ["id"],
684
+ paginated: false,
685
+ idempotent: false
686
+ },
687
+ "newsletters.update": {
688
+ id: "newsletters.update",
689
+ method: "PATCH",
690
+ path: "/newsletters/{id}",
691
+ pathParams: ["id"],
692
+ paginated: false,
693
+ idempotent: false,
694
+ body: {
695
+ subject: {
696
+ wire: "subject"
697
+ },
698
+ preheader: {
699
+ wire: "preheader"
700
+ },
701
+ topicId: {
702
+ wire: "topic_id"
703
+ },
704
+ markdown: {
705
+ wire: "markdown"
706
+ },
707
+ html: {
708
+ wire: "html"
709
+ },
710
+ blocks: {
711
+ wire: "blocks",
712
+ items: {
713
+ kind: {
714
+ wire: "kind"
715
+ },
716
+ level: {
717
+ wire: "level"
718
+ },
719
+ text: {
720
+ wire: "text"
721
+ },
722
+ ordered: {
723
+ wire: "ordered"
724
+ },
725
+ items: {
726
+ wire: "items"
727
+ },
728
+ url: {
729
+ wire: "url"
730
+ },
731
+ alt: {
732
+ wire: "alt"
733
+ },
734
+ label: {
735
+ wire: "label"
736
+ },
737
+ title: {
738
+ wire: "title"
739
+ },
740
+ imageUrl: {
741
+ wire: "imageUrl"
742
+ },
743
+ price: {
744
+ wire: "price"
745
+ },
746
+ description: {
747
+ wire: "description"
748
+ },
749
+ ctaLabel: {
750
+ wire: "ctaLabel"
751
+ },
752
+ html: {
753
+ wire: "html"
754
+ },
755
+ columns: {
756
+ wire: "columns"
757
+ }
758
+ }
759
+ },
760
+ audienceFilterId: {
761
+ wire: "audience_filter_id"
762
+ },
763
+ abTest: {
764
+ wire: "ab_test",
765
+ props: {
766
+ variants: {
767
+ wire: "variants",
768
+ items: {
769
+ subject: {
770
+ wire: "subject"
771
+ },
772
+ preheader: {
773
+ wire: "preheader"
774
+ }
775
+ }
776
+ },
777
+ samplePct: {
778
+ wire: "sample_pct"
779
+ },
780
+ metric: {
781
+ wire: "metric"
782
+ },
783
+ waitHours: {
784
+ wire: "wait_hours"
785
+ },
786
+ winnerMode: {
787
+ wire: "winner_mode"
788
+ }
789
+ }
790
+ }
791
+ }
792
+ },
793
+ "newsletters.remove": {
794
+ id: "newsletters.remove",
795
+ method: "DELETE",
796
+ path: "/newsletters/{id}",
797
+ pathParams: ["id"],
798
+ paginated: false,
799
+ idempotent: false
800
+ },
801
+ "newsletters.duplicate": {
802
+ id: "newsletters.duplicate",
803
+ method: "POST",
804
+ path: "/newsletters/{id}/duplicate",
805
+ pathParams: ["id"],
806
+ paginated: false,
807
+ idempotent: false
808
+ },
809
+ "newsletters.review": {
810
+ id: "newsletters.review",
811
+ method: "GET",
812
+ path: "/newsletters/{id}/review",
813
+ pathParams: ["id"],
814
+ paginated: false,
815
+ idempotent: false
816
+ },
817
+ "newsletters.test": {
818
+ id: "newsletters.test",
819
+ method: "POST",
820
+ path: "/newsletters/{id}/test",
821
+ pathParams: ["id"],
822
+ paginated: false,
823
+ idempotent: false
824
+ },
825
+ "newsletters.send": {
826
+ id: "newsletters.send",
827
+ method: "POST",
828
+ path: "/newsletters/{id}/send",
829
+ pathParams: ["id"],
830
+ paginated: false,
831
+ idempotent: true,
832
+ body: {
833
+ audienceLimit: {
834
+ wire: "audience_limit"
835
+ }
836
+ }
837
+ },
838
+ "newsletters.schedule": {
839
+ id: "newsletters.schedule",
840
+ method: "POST",
841
+ path: "/newsletters/{id}/schedule",
842
+ pathParams: ["id"],
843
+ paginated: false,
844
+ idempotent: true,
845
+ body: {
846
+ scheduledAt: {
847
+ wire: "scheduled_at"
848
+ },
849
+ audienceLimit: {
850
+ wire: "audience_limit"
851
+ }
852
+ }
853
+ },
854
+ "newsletters.unschedule": {
855
+ id: "newsletters.unschedule",
856
+ method: "POST",
857
+ path: "/newsletters/{id}/unschedule",
858
+ pathParams: ["id"],
859
+ paginated: false,
860
+ idempotent: false
861
+ },
862
+ "newsletters.pause": {
863
+ id: "newsletters.pause",
864
+ method: "POST",
865
+ path: "/newsletters/{id}/pause",
866
+ pathParams: ["id"],
867
+ paginated: false,
868
+ idempotent: false
869
+ },
870
+ "newsletters.resume": {
871
+ id: "newsletters.resume",
872
+ method: "POST",
873
+ path: "/newsletters/{id}/resume",
874
+ pathParams: ["id"],
875
+ paginated: false,
876
+ idempotent: false
877
+ },
878
+ "newsletters.sendMore": {
879
+ id: "newsletters.sendMore",
880
+ method: "POST",
881
+ path: "/newsletters/{id}/send-more",
882
+ pathParams: ["id"],
883
+ paginated: false,
884
+ idempotent: true,
885
+ body: {
886
+ count: {
887
+ wire: "count"
888
+ }
889
+ }
890
+ },
891
+ "newsletters.report": {
892
+ id: "newsletters.report",
893
+ method: "GET",
894
+ path: "/newsletters/{id}/report",
895
+ pathParams: ["id"],
896
+ paginated: false,
897
+ idempotent: false
898
+ },
899
+ "newsletters.abWinner": {
900
+ id: "newsletters.abWinner",
901
+ method: "POST",
902
+ path: "/newsletters/{id}/ab-winner",
903
+ pathParams: ["id"],
904
+ paginated: false,
905
+ idempotent: false,
906
+ body: {
907
+ variant: {
908
+ wire: "variant"
909
+ }
910
+ }
911
+ },
912
+ "contacts.list": {
913
+ id: "contacts.list",
914
+ method: "GET",
915
+ path: "/contacts",
916
+ pathParams: [],
917
+ paginated: true,
918
+ idempotent: false,
919
+ query: {
920
+ limit: {
921
+ wire: "limit"
922
+ },
923
+ after: {
924
+ wire: "after"
925
+ },
926
+ before: {
927
+ wire: "before"
928
+ },
929
+ segmentId: {
930
+ wire: "segment_id"
931
+ },
932
+ status: {
933
+ wire: "status"
934
+ },
935
+ search: {
936
+ wire: "search"
937
+ },
938
+ tag: {
939
+ wire: "tag"
940
+ }
941
+ }
942
+ },
943
+ "contacts.create": {
944
+ id: "contacts.create",
945
+ method: "POST",
946
+ path: "/contacts",
947
+ pathParams: [],
948
+ paginated: false,
949
+ idempotent: true,
950
+ body: {
951
+ email: {
952
+ wire: "email"
953
+ },
954
+ segmentId: {
955
+ wire: "segment_id"
956
+ },
957
+ name: {
958
+ wire: "name"
959
+ },
960
+ firstName: {
961
+ wire: "first_name"
962
+ },
963
+ lastName: {
964
+ wire: "last_name"
965
+ },
966
+ language: {
967
+ wire: "language"
968
+ },
969
+ customFields: {
970
+ wire: "custom_fields"
971
+ },
972
+ tags: {
973
+ wire: "tags"
974
+ }
975
+ }
976
+ },
977
+ "contacts.import": {
978
+ id: "contacts.import",
979
+ method: "POST",
980
+ path: "/contacts/import",
981
+ pathParams: [],
982
+ paginated: false,
983
+ idempotent: true,
984
+ body: {
985
+ segmentId: {
986
+ wire: "segment_id"
987
+ },
988
+ consent: {
989
+ wire: "consent"
990
+ },
991
+ contacts: {
992
+ wire: "contacts",
993
+ items: {
994
+ email: {
995
+ wire: "email"
996
+ },
997
+ name: {
998
+ wire: "name"
999
+ },
1000
+ firstName: {
1001
+ wire: "first_name"
1002
+ },
1003
+ lastName: {
1004
+ wire: "last_name"
1005
+ },
1006
+ language: {
1007
+ wire: "language"
1008
+ },
1009
+ customFields: {
1010
+ wire: "custom_fields"
1011
+ },
1012
+ openRate: {
1013
+ wire: "open_rate"
1014
+ },
1015
+ clickRate: {
1016
+ wire: "click_rate"
1017
+ },
1018
+ lastActivityAt: {
1019
+ wire: "last_activity_at"
1020
+ },
1021
+ tags: {
1022
+ wire: "tags"
1023
+ },
1024
+ status: {
1025
+ wire: "status"
1026
+ },
1027
+ unsubscribedAt: {
1028
+ wire: "unsubscribed_at"
1029
+ }
1030
+ }
1031
+ }
1032
+ }
1033
+ },
1034
+ "contacts.export": {
1035
+ id: "contacts.export",
1036
+ method: "GET",
1037
+ path: "/contacts/export",
1038
+ pathParams: [],
1039
+ paginated: false,
1040
+ idempotent: false,
1041
+ query: {
1042
+ segmentId: {
1043
+ wire: "segment_id"
1044
+ },
1045
+ status: {
1046
+ wire: "status"
1047
+ }
1048
+ },
1049
+ responseType: "text"
1050
+ },
1051
+ "contacts.get": {
1052
+ id: "contacts.get",
1053
+ method: "GET",
1054
+ path: "/contacts/{id}",
1055
+ pathParams: ["id"],
1056
+ paginated: false,
1057
+ idempotent: false
1058
+ },
1059
+ "contacts.unsubscribe": {
1060
+ id: "contacts.unsubscribe",
1061
+ method: "POST",
1062
+ path: "/contacts/{id}/unsubscribe",
1063
+ pathParams: ["id"],
1064
+ paginated: false,
1065
+ idempotent: false
1066
+ },
1067
+ "contacts.reactivate": {
1068
+ id: "contacts.reactivate",
1069
+ method: "POST",
1070
+ path: "/contacts/{id}/reactivate",
1071
+ pathParams: ["id"],
1072
+ paginated: false,
1073
+ idempotent: false
1074
+ },
1075
+ "contacts.remove": {
1076
+ id: "contacts.remove",
1077
+ method: "DELETE",
1078
+ path: "/contacts/{id}",
1079
+ pathParams: ["id"],
1080
+ paginated: false,
1081
+ idempotent: false
1082
+ },
1083
+ "contacts.update": {
1084
+ id: "contacts.update",
1085
+ method: "PATCH",
1086
+ path: "/contacts/{id}",
1087
+ pathParams: ["id"],
1088
+ paginated: false,
1089
+ idempotent: false,
1090
+ body: {
1091
+ firstName: {
1092
+ wire: "first_name"
1093
+ },
1094
+ lastName: {
1095
+ wire: "last_name"
1096
+ },
1097
+ name: {
1098
+ wire: "name"
1099
+ },
1100
+ language: {
1101
+ wire: "language"
1102
+ },
1103
+ customFields: {
1104
+ wire: "custom_fields"
1105
+ },
1106
+ tags: {
1107
+ wire: "tags"
1108
+ },
1109
+ addTags: {
1110
+ wire: "add_tags"
1111
+ },
1112
+ removeTags: {
1113
+ wire: "remove_tags"
1114
+ }
1115
+ }
1116
+ },
1117
+ "contactFields.list": {
1118
+ id: "contactFields.list",
1119
+ method: "GET",
1120
+ path: "/contact-fields",
1121
+ pathParams: [],
1122
+ paginated: false,
1123
+ idempotent: false
1124
+ },
1125
+ "contactFields.create": {
1126
+ id: "contactFields.create",
1127
+ method: "POST",
1128
+ path: "/contact-fields",
1129
+ pathParams: [],
1130
+ paginated: false,
1131
+ idempotent: false,
1132
+ body: {
1133
+ key: {
1134
+ wire: "key"
1135
+ },
1136
+ label: {
1137
+ wire: "label"
1138
+ },
1139
+ type: {
1140
+ wire: "type"
1141
+ },
1142
+ options: {
1143
+ wire: "options"
1144
+ },
1145
+ defaultValue: {
1146
+ wire: "default_value"
1147
+ },
1148
+ inSignup: {
1149
+ wire: "in_signup"
1150
+ }
1151
+ }
1152
+ },
1153
+ "contactFields.update": {
1154
+ id: "contactFields.update",
1155
+ method: "PATCH",
1156
+ path: "/contact-fields/{id}",
1157
+ pathParams: ["id"],
1158
+ paginated: false,
1159
+ idempotent: false,
1160
+ body: {
1161
+ label: {
1162
+ wire: "label"
1163
+ },
1164
+ options: {
1165
+ wire: "options"
1166
+ },
1167
+ defaultValue: {
1168
+ wire: "default_value"
1169
+ },
1170
+ inSignup: {
1171
+ wire: "in_signup"
1172
+ },
1173
+ position: {
1174
+ wire: "position"
1175
+ }
1176
+ }
1177
+ },
1178
+ "contactFields.remove": {
1179
+ id: "contactFields.remove",
1180
+ method: "DELETE",
1181
+ path: "/contact-fields/{id}",
1182
+ pathParams: ["id"],
1183
+ paginated: false,
1184
+ idempotent: false
1185
+ },
1186
+ "events.send": {
1187
+ id: "events.send",
1188
+ method: "POST",
1189
+ path: "/events",
1190
+ pathParams: [],
1191
+ paginated: false,
1192
+ idempotent: true,
1193
+ body: {
1194
+ email: {
1195
+ wire: "email"
1196
+ },
1197
+ contactId: {
1198
+ wire: "contact_id"
1199
+ },
1200
+ event: {
1201
+ wire: "event"
1202
+ },
1203
+ properties: {
1204
+ wire: "properties"
1205
+ },
1206
+ occurredAt: {
1207
+ wire: "occurred_at"
1208
+ },
1209
+ createContact: {
1210
+ wire: "create_contact"
1211
+ },
1212
+ segmentId: {
1213
+ wire: "segment_id"
1214
+ }
1215
+ }
1216
+ },
1217
+ "audienceFilters.list": {
1218
+ id: "audienceFilters.list",
1219
+ method: "GET",
1220
+ path: "/audience-filters",
1221
+ pathParams: [],
1222
+ paginated: true,
1223
+ idempotent: false,
1224
+ query: {
1225
+ limit: {
1226
+ wire: "limit"
1227
+ },
1228
+ after: {
1229
+ wire: "after"
1230
+ },
1231
+ before: {
1232
+ wire: "before"
1233
+ }
1234
+ }
1235
+ },
1236
+ "audienceFilters.create": {
1237
+ id: "audienceFilters.create",
1238
+ method: "POST",
1239
+ path: "/audience-filters",
1240
+ pathParams: [],
1241
+ paginated: false,
1242
+ idempotent: false,
1243
+ body: {
1244
+ name: {
1245
+ wire: "name"
1246
+ },
1247
+ description: {
1248
+ wire: "description"
1249
+ },
1250
+ rules: {
1251
+ wire: "rules"
1252
+ }
1253
+ }
1254
+ },
1255
+ "audienceFilters.get": {
1256
+ id: "audienceFilters.get",
1257
+ method: "GET",
1258
+ path: "/audience-filters/{id}",
1259
+ pathParams: ["id"],
1260
+ paginated: false,
1261
+ idempotent: false
1262
+ },
1263
+ "audienceFilters.update": {
1264
+ id: "audienceFilters.update",
1265
+ method: "PATCH",
1266
+ path: "/audience-filters/{id}",
1267
+ pathParams: ["id"],
1268
+ paginated: false,
1269
+ idempotent: false,
1270
+ body: {
1271
+ name: {
1272
+ wire: "name"
1273
+ },
1274
+ description: {
1275
+ wire: "description"
1276
+ },
1277
+ rules: {
1278
+ wire: "rules"
1279
+ }
1280
+ }
1281
+ },
1282
+ "audienceFilters.remove": {
1283
+ id: "audienceFilters.remove",
1284
+ method: "DELETE",
1285
+ path: "/audience-filters/{id}",
1286
+ pathParams: ["id"],
1287
+ paginated: false,
1288
+ idempotent: false
1289
+ },
1290
+ "audienceFilters.count": {
1291
+ id: "audienceFilters.count",
1292
+ method: "POST",
1293
+ path: "/audience-filters/count",
1294
+ pathParams: [],
1295
+ paginated: false,
1296
+ idempotent: false,
1297
+ body: {
1298
+ filterId: {
1299
+ wire: "filter_id"
1300
+ },
1301
+ rules: {
1302
+ wire: "rules"
1303
+ },
1304
+ segmentId: {
1305
+ wire: "segment_id"
1306
+ }
1307
+ }
1308
+ },
1309
+ "signups.create": {
1310
+ id: "signups.create",
1311
+ method: "POST",
1312
+ path: "/signups",
1313
+ pathParams: [],
1314
+ paginated: false,
1315
+ idempotent: true,
1316
+ body: {
1317
+ email: {
1318
+ wire: "email"
1319
+ },
1320
+ name: {
1321
+ wire: "name"
1322
+ },
1323
+ firstName: {
1324
+ wire: "first_name"
1325
+ },
1326
+ segmentId: {
1327
+ wire: "segment_id"
1328
+ },
1329
+ language: {
1330
+ wire: "language"
1331
+ },
1332
+ sourceUrl: {
1333
+ wire: "source_url"
1334
+ },
1335
+ customFields: {
1336
+ wire: "custom_fields"
1337
+ }
1338
+ }
1339
+ },
1340
+ "segments.list": {
1341
+ id: "segments.list",
1342
+ method: "GET",
1343
+ path: "/segments",
1344
+ pathParams: [],
1345
+ paginated: true,
1346
+ idempotent: false,
1347
+ query: {
1348
+ limit: {
1349
+ wire: "limit"
1350
+ },
1351
+ after: {
1352
+ wire: "after"
1353
+ },
1354
+ before: {
1355
+ wire: "before"
1356
+ }
1357
+ }
1358
+ },
1359
+ "segments.create": {
1360
+ id: "segments.create",
1361
+ method: "POST",
1362
+ path: "/segments",
1363
+ pathParams: [],
1364
+ paginated: false,
1365
+ idempotent: false,
1366
+ body: {
1367
+ name: {
1368
+ wire: "name"
1369
+ },
1370
+ slug: {
1371
+ wire: "slug"
1372
+ },
1373
+ language: {
1374
+ wire: "language"
1375
+ },
1376
+ description: {
1377
+ wire: "description"
1378
+ },
1379
+ themes: {
1380
+ wire: "themes"
1381
+ }
1382
+ }
1383
+ },
1384
+ "topics.list": {
1385
+ id: "topics.list",
1386
+ method: "GET",
1387
+ path: "/topics",
1388
+ pathParams: [],
1389
+ paginated: false,
1390
+ idempotent: false,
1391
+ query: {
1392
+ segmentId: {
1393
+ wire: "segment_id"
1394
+ }
1395
+ }
1396
+ },
1397
+ "segments.archive.get": {
1398
+ id: "segments.archive.get",
1399
+ method: "GET",
1400
+ path: "/segments/{id}/archive",
1401
+ pathParams: ["id"],
1402
+ paginated: false,
1403
+ idempotent: false
1404
+ },
1405
+ "segments.archive.update": {
1406
+ id: "segments.archive.update",
1407
+ method: "PATCH",
1408
+ path: "/segments/{id}/archive",
1409
+ pathParams: ["id"],
1410
+ paginated: false,
1411
+ idempotent: false,
1412
+ body: {
1413
+ enabled: {
1414
+ wire: "enabled"
1415
+ },
1416
+ slug: {
1417
+ wire: "slug"
1418
+ },
1419
+ description: {
1420
+ wire: "description"
1421
+ },
1422
+ author: {
1423
+ wire: "author"
1424
+ },
1425
+ about: {
1426
+ wire: "about"
1427
+ },
1428
+ avatarUrl: {
1429
+ wire: "avatar_url"
1430
+ },
1431
+ links: {
1432
+ wire: "links",
1433
+ props: {
1434
+ website: {
1435
+ wire: "website"
1436
+ },
1437
+ x: {
1438
+ wire: "x"
1439
+ },
1440
+ linkedin: {
1441
+ wire: "linkedin"
1442
+ },
1443
+ youtube: {
1444
+ wire: "youtube"
1445
+ },
1446
+ instagram: {
1447
+ wire: "instagram"
1448
+ },
1449
+ github: {
1450
+ wire: "github"
1451
+ },
1452
+ bluesky: {
1453
+ wire: "bluesky"
1454
+ }
1455
+ }
1456
+ }
1457
+ }
1458
+ },
1459
+ "newsletters.archive.update": {
1460
+ id: "newsletters.archive.update",
1461
+ method: "PATCH",
1462
+ path: "/newsletters/{id}/archive",
1463
+ pathParams: ["id"],
1464
+ paginated: false,
1465
+ idempotent: false,
1466
+ body: {
1467
+ pinned: {
1468
+ wire: "pinned"
1469
+ },
1470
+ hidden: {
1471
+ wire: "hidden"
1472
+ }
1473
+ }
1474
+ },
1475
+ "segments.domain.get": {
1476
+ id: "segments.domain.get",
1477
+ method: "GET",
1478
+ path: "/segments/{id}/domain",
1479
+ pathParams: ["id"],
1480
+ paginated: false,
1481
+ idempotent: false
1482
+ },
1483
+ "segments.domain.set": {
1484
+ id: "segments.domain.set",
1485
+ method: "POST",
1486
+ path: "/segments/{id}/domain",
1487
+ pathParams: ["id"],
1488
+ paginated: false,
1489
+ idempotent: false,
1490
+ body: {
1491
+ domain: {
1492
+ wire: "domain"
1493
+ }
1494
+ }
1495
+ },
1496
+ "segments.domain.remove": {
1497
+ id: "segments.domain.remove",
1498
+ method: "DELETE",
1499
+ path: "/segments/{id}/domain",
1500
+ pathParams: ["id"],
1501
+ paginated: false,
1502
+ idempotent: false
1503
+ },
1504
+ "suppressions.list": {
1505
+ id: "suppressions.list",
1506
+ method: "GET",
1507
+ path: "/suppressions",
1508
+ pathParams: [],
1509
+ paginated: true,
1510
+ idempotent: false,
1511
+ query: {
1512
+ limit: {
1513
+ wire: "limit"
1514
+ },
1515
+ after: {
1516
+ wire: "after"
1517
+ },
1518
+ before: {
1519
+ wire: "before"
1520
+ },
1521
+ reason: {
1522
+ wire: "reason"
1523
+ }
1524
+ }
1525
+ },
1526
+ "suppressions.create": {
1527
+ id: "suppressions.create",
1528
+ method: "POST",
1529
+ path: "/suppressions",
1530
+ pathParams: [],
1531
+ paginated: false,
1532
+ idempotent: false,
1533
+ body: {
1534
+ email: {
1535
+ wire: "email"
1536
+ },
1537
+ reason: {
1538
+ wire: "reason"
1539
+ },
1540
+ notes: {
1541
+ wire: "notes"
1542
+ }
1543
+ }
1544
+ },
1545
+ "suppressions.remove": {
1546
+ id: "suppressions.remove",
1547
+ method: "DELETE",
1548
+ path: "/suppressions/{id}",
1549
+ pathParams: ["id"],
1550
+ paginated: false,
1551
+ idempotent: false
1552
+ },
1553
+ "images.list": {
1554
+ id: "images.list",
1555
+ method: "GET",
1556
+ path: "/images",
1557
+ pathParams: [],
1558
+ paginated: true,
1559
+ idempotent: false,
1560
+ query: {
1561
+ limit: {
1562
+ wire: "limit"
1563
+ },
1564
+ after: {
1565
+ wire: "after"
1566
+ },
1567
+ before: {
1568
+ wire: "before"
1569
+ }
1570
+ }
1571
+ },
1572
+ "images.create": {
1573
+ id: "images.create",
1574
+ method: "POST",
1575
+ path: "/images",
1576
+ pathParams: [],
1577
+ paginated: false,
1578
+ idempotent: false,
1579
+ rawBody: true
1580
+ },
1581
+ "stats.overview": {
1582
+ id: "stats.overview",
1583
+ method: "GET",
1584
+ path: "/stats/overview",
1585
+ pathParams: [],
1586
+ paginated: false,
1587
+ idempotent: false
1588
+ },
1589
+ "domains.create": {
1590
+ id: "domains.create",
1591
+ method: "POST",
1592
+ path: "/domains",
1593
+ pathParams: [],
1594
+ paginated: false,
1595
+ idempotent: false,
1596
+ body: {
1597
+ name: {
1598
+ wire: "name"
1599
+ },
1600
+ trackingSubdomain: {
1601
+ wire: "tracking_subdomain"
1602
+ }
1603
+ }
1604
+ },
1605
+ "domains.list": {
1606
+ id: "domains.list",
1607
+ method: "GET",
1608
+ path: "/domains",
1609
+ pathParams: [],
1610
+ paginated: true,
1611
+ idempotent: false,
1612
+ query: {
1613
+ limit: {
1614
+ wire: "limit"
1615
+ },
1616
+ after: {
1617
+ wire: "after"
1618
+ },
1619
+ before: {
1620
+ wire: "before"
1621
+ }
1622
+ }
1623
+ },
1624
+ "domains.get": {
1625
+ id: "domains.get",
1626
+ method: "GET",
1627
+ path: "/domains/{id}",
1628
+ pathParams: ["id"],
1629
+ paginated: false,
1630
+ idempotent: false
1631
+ },
1632
+ "domains.verify": {
1633
+ id: "domains.verify",
1634
+ method: "POST",
1635
+ path: "/domains/{id}/verify",
1636
+ pathParams: ["id"],
1637
+ paginated: false,
1638
+ idempotent: false
1639
+ },
1640
+ "apiKeys.create": {
1641
+ id: "apiKeys.create",
1642
+ method: "POST",
1643
+ path: "/api-keys",
1644
+ pathParams: [],
1645
+ paginated: false,
1646
+ idempotent: false,
1647
+ body: {
1648
+ name: {
1649
+ wire: "name"
1650
+ },
1651
+ permission: {
1652
+ wire: "permission"
1653
+ },
1654
+ domainId: {
1655
+ wire: "domain_id"
1656
+ }
1657
+ }
1658
+ },
1659
+ "apiKeys.list": {
1660
+ id: "apiKeys.list",
1661
+ method: "GET",
1662
+ path: "/api-keys",
1663
+ pathParams: [],
1664
+ paginated: true,
1665
+ idempotent: false,
1666
+ query: {
1667
+ limit: {
1668
+ wire: "limit"
1669
+ },
1670
+ after: {
1671
+ wire: "after"
1672
+ },
1673
+ before: {
1674
+ wire: "before"
1675
+ }
1676
+ }
1677
+ },
1678
+ "apiKeys.update": {
1679
+ id: "apiKeys.update",
1680
+ method: "PATCH",
1681
+ path: "/api-keys/{id}",
1682
+ pathParams: ["id"],
1683
+ paginated: false,
1684
+ idempotent: false,
1685
+ body: {
1686
+ name: {
1687
+ wire: "name"
1688
+ }
1689
+ }
1690
+ },
1691
+ "apiKeys.remove": {
1692
+ id: "apiKeys.remove",
1693
+ method: "DELETE",
1694
+ path: "/api-keys/{id}",
1695
+ pathParams: ["id"],
1696
+ paginated: false,
1697
+ idempotent: false
1698
+ },
1699
+ "logs.list": {
1700
+ id: "logs.list",
1701
+ method: "GET",
1702
+ path: "/logs",
1703
+ pathParams: [],
1704
+ paginated: true,
1705
+ idempotent: false,
1706
+ query: {
1707
+ limit: {
1708
+ wire: "limit"
1709
+ },
1710
+ after: {
1711
+ wire: "after"
1712
+ },
1713
+ before: {
1714
+ wire: "before"
1715
+ }
1716
+ }
1717
+ },
1718
+ "logs.get": {
1719
+ id: "logs.get",
1720
+ method: "GET",
1721
+ path: "/logs/{id}",
1722
+ pathParams: ["id"],
1723
+ paginated: false,
1724
+ idempotent: false
1725
+ },
1726
+ "usage.get": {
1727
+ id: "usage.get",
1728
+ method: "GET",
1729
+ path: "/usage",
1730
+ pathParams: [],
1731
+ paginated: false,
1732
+ idempotent: false
1733
+ },
1734
+ "sequences.list": {
1735
+ id: "sequences.list",
1736
+ method: "GET",
1737
+ path: "/sequences",
1738
+ pathParams: [],
1739
+ paginated: false,
1740
+ idempotent: false,
1741
+ query: {
1742
+ includeArchived: {
1743
+ wire: "include_archived"
1744
+ }
1745
+ }
1746
+ },
1747
+ "sequences.create": {
1748
+ id: "sequences.create",
1749
+ method: "POST",
1750
+ path: "/sequences",
1751
+ pathParams: [],
1752
+ paginated: false,
1753
+ idempotent: false,
1754
+ body: {
1755
+ name: {
1756
+ wire: "name"
1757
+ },
1758
+ description: {
1759
+ wire: "description"
1760
+ },
1761
+ segmentId: {
1762
+ wire: "segment_id"
1763
+ },
1764
+ topicId: {
1765
+ wire: "topic_id"
1766
+ },
1767
+ trigger: {
1768
+ wire: "trigger",
1769
+ props: {
1770
+ type: {
1771
+ wire: "type"
1772
+ },
1773
+ includeImports: {
1774
+ wire: "include_imports"
1775
+ },
1776
+ topicId: {
1777
+ wire: "topic_id"
1778
+ },
1779
+ leadMagnetId: {
1780
+ wire: "lead_magnet_id"
1781
+ },
1782
+ event: {
1783
+ wire: "event"
1784
+ },
1785
+ newsletterId: {
1786
+ wire: "newsletter_id"
1787
+ },
1788
+ filterId: {
1789
+ wire: "filter_id"
1790
+ },
1791
+ includeExisting: {
1792
+ wire: "include_existing"
1793
+ }
1794
+ }
1795
+ },
1796
+ reentry: {
1797
+ wire: "reentry",
1798
+ props: {
1799
+ mode: {
1800
+ wire: "mode"
1801
+ },
1802
+ days: {
1803
+ wire: "days"
1804
+ }
1805
+ }
1806
+ },
1807
+ exit: {
1808
+ wire: "exit",
1809
+ props: {
1810
+ events: {
1811
+ wire: "events"
1812
+ },
1813
+ filterId: {
1814
+ wire: "filter_id"
1815
+ }
1816
+ }
1817
+ },
1818
+ steps: {
1819
+ wire: "steps",
1820
+ items: {
1821
+ id: {
1822
+ wire: "id"
1823
+ },
1824
+ type: {
1825
+ wire: "type"
1826
+ },
1827
+ subject: {
1828
+ wire: "subject"
1829
+ },
1830
+ preheader: {
1831
+ wire: "preheader"
1832
+ },
1833
+ markdown: {
1834
+ wire: "markdown"
1835
+ },
1836
+ html: {
1837
+ wire: "html"
1838
+ },
1839
+ doc: {
1840
+ wire: "doc"
1841
+ },
1842
+ templateId: {
1843
+ wire: "template_id"
1844
+ },
1845
+ amount: {
1846
+ wire: "amount"
1847
+ },
1848
+ unit: {
1849
+ wire: "unit"
1850
+ },
1851
+ until: {
1852
+ wire: "until",
1853
+ props: {
1854
+ time: {
1855
+ wire: "time"
1856
+ },
1857
+ weekdays: {
1858
+ wire: "weekdays"
1859
+ },
1860
+ timezone: {
1861
+ wire: "timezone"
1862
+ }
1863
+ }
1864
+ },
1865
+ event: {
1866
+ wire: "event"
1867
+ },
1868
+ timeoutHours: {
1869
+ wire: "timeout_hours"
1870
+ },
1871
+ onTimeout: {
1872
+ wire: "on_timeout"
1873
+ },
1874
+ filterId: {
1875
+ wire: "filter_id"
1876
+ },
1877
+ rule: {
1878
+ wire: "rule"
1879
+ },
1880
+ yes: {
1881
+ wire: "yes"
1882
+ },
1883
+ no: {
1884
+ wire: "no"
1885
+ },
1886
+ action: {
1887
+ wire: "action"
1888
+ },
1889
+ key: {
1890
+ wire: "key"
1891
+ },
1892
+ value: {
1893
+ wire: "value"
1894
+ },
1895
+ topicId: {
1896
+ wire: "topic_id"
1897
+ },
1898
+ webhookId: {
1899
+ wire: "webhook_id"
1900
+ }
1901
+ }
1902
+ }
1903
+ }
1904
+ },
1905
+ "sequences.get": {
1906
+ id: "sequences.get",
1907
+ method: "GET",
1908
+ path: "/sequences/{id}",
1909
+ pathParams: ["id"],
1910
+ paginated: false,
1911
+ idempotent: false
1912
+ },
1913
+ "sequences.update": {
1914
+ id: "sequences.update",
1915
+ method: "PATCH",
1916
+ path: "/sequences/{id}",
1917
+ pathParams: ["id"],
1918
+ paginated: false,
1919
+ idempotent: false,
1920
+ body: {
1921
+ name: {
1922
+ wire: "name"
1923
+ },
1924
+ description: {
1925
+ wire: "description"
1926
+ },
1927
+ segmentId: {
1928
+ wire: "segment_id"
1929
+ },
1930
+ topicId: {
1931
+ wire: "topic_id"
1932
+ },
1933
+ trigger: {
1934
+ wire: "trigger",
1935
+ props: {
1936
+ type: {
1937
+ wire: "type"
1938
+ },
1939
+ includeImports: {
1940
+ wire: "include_imports"
1941
+ },
1942
+ topicId: {
1943
+ wire: "topic_id"
1944
+ },
1945
+ leadMagnetId: {
1946
+ wire: "lead_magnet_id"
1947
+ },
1948
+ event: {
1949
+ wire: "event"
1950
+ },
1951
+ newsletterId: {
1952
+ wire: "newsletter_id"
1953
+ },
1954
+ filterId: {
1955
+ wire: "filter_id"
1956
+ },
1957
+ includeExisting: {
1958
+ wire: "include_existing"
1959
+ }
1960
+ }
1961
+ },
1962
+ reentry: {
1963
+ wire: "reentry",
1964
+ props: {
1965
+ mode: {
1966
+ wire: "mode"
1967
+ },
1968
+ days: {
1969
+ wire: "days"
1970
+ }
1971
+ }
1972
+ },
1973
+ exit: {
1974
+ wire: "exit",
1975
+ props: {
1976
+ events: {
1977
+ wire: "events"
1978
+ },
1979
+ filterId: {
1980
+ wire: "filter_id"
1981
+ }
1982
+ }
1983
+ },
1984
+ steps: {
1985
+ wire: "steps",
1986
+ items: {
1987
+ id: {
1988
+ wire: "id"
1989
+ },
1990
+ type: {
1991
+ wire: "type"
1992
+ },
1993
+ subject: {
1994
+ wire: "subject"
1995
+ },
1996
+ preheader: {
1997
+ wire: "preheader"
1998
+ },
1999
+ markdown: {
2000
+ wire: "markdown"
2001
+ },
2002
+ html: {
2003
+ wire: "html"
2004
+ },
2005
+ doc: {
2006
+ wire: "doc"
2007
+ },
2008
+ templateId: {
2009
+ wire: "template_id"
2010
+ },
2011
+ amount: {
2012
+ wire: "amount"
2013
+ },
2014
+ unit: {
2015
+ wire: "unit"
2016
+ },
2017
+ until: {
2018
+ wire: "until",
2019
+ props: {
2020
+ time: {
2021
+ wire: "time"
2022
+ },
2023
+ weekdays: {
2024
+ wire: "weekdays"
2025
+ },
2026
+ timezone: {
2027
+ wire: "timezone"
2028
+ }
2029
+ }
2030
+ },
2031
+ event: {
2032
+ wire: "event"
2033
+ },
2034
+ timeoutHours: {
2035
+ wire: "timeout_hours"
2036
+ },
2037
+ onTimeout: {
2038
+ wire: "on_timeout"
2039
+ },
2040
+ filterId: {
2041
+ wire: "filter_id"
2042
+ },
2043
+ rule: {
2044
+ wire: "rule"
2045
+ },
2046
+ yes: {
2047
+ wire: "yes"
2048
+ },
2049
+ no: {
2050
+ wire: "no"
2051
+ },
2052
+ action: {
2053
+ wire: "action"
2054
+ },
2055
+ key: {
2056
+ wire: "key"
2057
+ },
2058
+ value: {
2059
+ wire: "value"
2060
+ },
2061
+ topicId: {
2062
+ wire: "topic_id"
2063
+ },
2064
+ webhookId: {
2065
+ wire: "webhook_id"
2066
+ }
2067
+ }
2068
+ }
2069
+ }
2070
+ },
2071
+ "sequences.remove": {
2072
+ id: "sequences.remove",
2073
+ method: "DELETE",
2074
+ path: "/sequences/{id}",
2075
+ pathParams: ["id"],
2076
+ paginated: false,
2077
+ idempotent: false
2078
+ },
2079
+ "sequences.activate": {
2080
+ id: "sequences.activate",
2081
+ method: "POST",
2082
+ path: "/sequences/{id}/activate",
2083
+ pathParams: ["id"],
2084
+ paginated: false,
2085
+ idempotent: false
2086
+ },
2087
+ "sequences.pause": {
2088
+ id: "sequences.pause",
2089
+ method: "POST",
2090
+ path: "/sequences/{id}/pause",
2091
+ pathParams: ["id"],
2092
+ paginated: false,
2093
+ idempotent: false
2094
+ },
2095
+ "sequences.archive": {
2096
+ id: "sequences.archive",
2097
+ method: "POST",
2098
+ path: "/sequences/{id}/archive",
2099
+ pathParams: ["id"],
2100
+ paginated: false,
2101
+ idempotent: false
2102
+ },
2103
+ "sequences.enrollments": {
2104
+ id: "sequences.enrollments",
2105
+ method: "GET",
2106
+ path: "/sequences/{id}/enrollments",
2107
+ pathParams: ["id"],
2108
+ paginated: false,
2109
+ idempotent: false,
2110
+ query: {
2111
+ status: {
2112
+ wire: "status"
2113
+ },
2114
+ limit: {
2115
+ wire: "limit"
2116
+ }
2117
+ }
2118
+ },
2119
+ "sequences.enroll": {
2120
+ id: "sequences.enroll",
2121
+ method: "POST",
2122
+ path: "/sequences/{id}/enrollments",
2123
+ pathParams: ["id"],
2124
+ paginated: false,
2125
+ idempotent: false,
2126
+ body: {
2127
+ email: {
2128
+ wire: "email"
2129
+ },
2130
+ contactId: {
2131
+ wire: "contact_id"
2132
+ }
2133
+ }
2134
+ },
2135
+ "sequences.unenroll": {
2136
+ id: "sequences.unenroll",
2137
+ method: "DELETE",
2138
+ path: "/sequences/{id}/enrollments/{enrollment_id}",
2139
+ pathParams: ["id", "enrollment_id"],
2140
+ paginated: false,
2141
+ idempotent: false
2142
+ },
2143
+ "sequences.stats": {
2144
+ id: "sequences.stats",
2145
+ method: "GET",
2146
+ path: "/sequences/{id}/stats",
2147
+ pathParams: ["id"],
2148
+ paginated: false,
2149
+ idempotent: false
2150
+ },
2151
+ "webhooks.create": {
2152
+ id: "webhooks.create",
2153
+ method: "POST",
2154
+ path: "/webhooks",
2155
+ pathParams: [],
2156
+ paginated: false,
2157
+ idempotent: false,
2158
+ body: {
2159
+ endpoint: {
2160
+ wire: "endpoint"
2161
+ },
2162
+ events: {
2163
+ wire: "events"
2164
+ },
2165
+ description: {
2166
+ wire: "description"
2167
+ },
2168
+ includeNewsletters: {
2169
+ wire: "include_newsletters"
2170
+ },
2171
+ segmentIds: {
2172
+ wire: "segment_ids"
2173
+ },
2174
+ domains: {
2175
+ wire: "domains"
2176
+ }
2177
+ }
2178
+ },
2179
+ "webhooks.list": {
2180
+ id: "webhooks.list",
2181
+ method: "GET",
2182
+ path: "/webhooks",
2183
+ pathParams: [],
2184
+ paginated: true,
2185
+ idempotent: false,
2186
+ query: {
2187
+ limit: {
2188
+ wire: "limit"
2189
+ },
2190
+ after: {
2191
+ wire: "after"
2192
+ },
2193
+ before: {
2194
+ wire: "before"
2195
+ }
2196
+ }
2197
+ },
2198
+ "webhooks.get": {
2199
+ id: "webhooks.get",
2200
+ method: "GET",
2201
+ path: "/webhooks/{id}",
2202
+ pathParams: ["id"],
2203
+ paginated: false,
2204
+ idempotent: false
2205
+ },
2206
+ "webhooks.update": {
2207
+ id: "webhooks.update",
2208
+ method: "PATCH",
2209
+ path: "/webhooks/{id}",
2210
+ pathParams: ["id"],
2211
+ paginated: false,
2212
+ idempotent: false,
2213
+ body: {
2214
+ endpoint: {
2215
+ wire: "endpoint"
2216
+ },
2217
+ events: {
2218
+ wire: "events"
2219
+ },
2220
+ status: {
2221
+ wire: "status"
2222
+ },
2223
+ description: {
2224
+ wire: "description"
2225
+ },
2226
+ includeNewsletters: {
2227
+ wire: "include_newsletters"
2228
+ },
2229
+ segmentIds: {
2230
+ wire: "segment_ids"
2231
+ },
2232
+ domains: {
2233
+ wire: "domains"
2234
+ }
2235
+ }
2236
+ },
2237
+ "webhooks.remove": {
2238
+ id: "webhooks.remove",
2239
+ method: "DELETE",
2240
+ path: "/webhooks/{id}",
2241
+ pathParams: ["id"],
2242
+ paginated: false,
2243
+ idempotent: false
2244
+ },
2245
+ "webhooks.rotateSigningSecret": {
2246
+ id: "webhooks.rotateSigningSecret",
2247
+ method: "POST",
2248
+ path: "/webhooks/{id}/signing-secret/rotate",
2249
+ pathParams: ["id"],
2250
+ paginated: false,
2251
+ idempotent: false
2252
+ },
2253
+ "webhooks.test": {
2254
+ id: "webhooks.test",
2255
+ method: "POST",
2256
+ path: "/webhooks/{id}/test",
2257
+ pathParams: ["id"],
2258
+ paginated: false,
2259
+ idempotent: false,
2260
+ body: {
2261
+ type: {
2262
+ wire: "type"
2263
+ }
2264
+ }
2265
+ },
2266
+ "webhooks.deliveries": {
2267
+ id: "webhooks.deliveries",
2268
+ method: "GET",
2269
+ path: "/webhooks/{id}/deliveries",
2270
+ pathParams: ["id"],
2271
+ paginated: true,
2272
+ idempotent: false,
2273
+ query: {
2274
+ limit: {
2275
+ wire: "limit"
2276
+ },
2277
+ after: {
2278
+ wire: "after"
2279
+ },
2280
+ before: {
2281
+ wire: "before"
2282
+ },
2283
+ status: {
2284
+ wire: "status"
2285
+ }
2286
+ }
2287
+ },
2288
+ "webhooks.retryDelivery": {
2289
+ id: "webhooks.retryDelivery",
2290
+ method: "POST",
2291
+ path: "/webhooks/{id}/deliveries/{delivery_id}/retry",
2292
+ pathParams: ["id", "delivery_id"],
2293
+ paginated: false,
2294
+ idempotent: false
2295
+ },
2296
+ "inboxes.list": {
2297
+ id: "inboxes.list",
2298
+ method: "GET",
2299
+ path: "/inboxes",
2300
+ pathParams: [],
2301
+ paginated: false,
2302
+ idempotent: false
2303
+ },
2304
+ "inboxes.create": {
2305
+ id: "inboxes.create",
2306
+ method: "POST",
2307
+ path: "/inboxes",
2308
+ pathParams: [],
2309
+ paginated: false,
2310
+ idempotent: false,
2311
+ body: {
2312
+ name: {
2313
+ wire: "name"
2314
+ },
2315
+ displayName: {
2316
+ wire: "display_name"
2317
+ },
2318
+ description: {
2319
+ wire: "description"
2320
+ },
2321
+ domainId: {
2322
+ wire: "domain_id"
2323
+ },
2324
+ replyFrom: {
2325
+ wire: "reply_from"
2326
+ }
2327
+ }
2328
+ },
2329
+ "inboxes.get": {
2330
+ id: "inboxes.get",
2331
+ method: "GET",
2332
+ path: "/inboxes/{id}",
2333
+ pathParams: ["id"],
2334
+ paginated: false,
2335
+ idempotent: false
2336
+ },
2337
+ "inboxes.update": {
2338
+ id: "inboxes.update",
2339
+ method: "PATCH",
2340
+ path: "/inboxes/{id}",
2341
+ pathParams: ["id"],
2342
+ paginated: false,
2343
+ idempotent: false,
2344
+ body: {
2345
+ displayName: {
2346
+ wire: "display_name"
2347
+ },
2348
+ description: {
2349
+ wire: "description"
2350
+ },
2351
+ replyFrom: {
2352
+ wire: "reply_from"
2353
+ },
2354
+ status: {
2355
+ wire: "status"
2356
+ }
2357
+ }
2358
+ },
2359
+ "inboxes.remove": {
2360
+ id: "inboxes.remove",
2361
+ method: "DELETE",
2362
+ path: "/inboxes/{id}",
2363
+ pathParams: ["id"],
2364
+ paginated: false,
2365
+ idempotent: false
2366
+ },
2367
+ "threads.list": {
2368
+ id: "threads.list",
2369
+ method: "GET",
2370
+ path: "/threads",
2371
+ pathParams: [],
2372
+ paginated: false,
2373
+ idempotent: false,
2374
+ query: {
2375
+ inboxId: {
2376
+ wire: "inbox_id"
2377
+ },
2378
+ status: {
2379
+ wire: "status"
2380
+ },
2381
+ label: {
2382
+ wire: "label"
2383
+ },
2384
+ spam: {
2385
+ wire: "spam"
2386
+ },
2387
+ assigneeAgent: {
2388
+ wire: "assignee_agent"
2389
+ },
2390
+ unread: {
2391
+ wire: "unread"
2392
+ },
2393
+ limit: {
2394
+ wire: "limit"
2395
+ },
2396
+ after: {
2397
+ wire: "after"
2398
+ }
2399
+ }
2400
+ },
2401
+ "threads.get": {
2402
+ id: "threads.get",
2403
+ method: "GET",
2404
+ path: "/threads/{id}",
2405
+ pathParams: ["id"],
2406
+ paginated: false,
2407
+ idempotent: false
2408
+ },
2409
+ "threads.update": {
2410
+ id: "threads.update",
2411
+ method: "PATCH",
2412
+ path: "/threads/{id}",
2413
+ pathParams: ["id"],
2414
+ paginated: false,
2415
+ idempotent: false,
2416
+ body: {
2417
+ status: {
2418
+ wire: "status"
2419
+ },
2420
+ labels: {
2421
+ wire: "labels"
2422
+ },
2423
+ addLabels: {
2424
+ wire: "add_labels"
2425
+ },
2426
+ removeLabels: {
2427
+ wire: "remove_labels"
2428
+ },
2429
+ assigneeAgent: {
2430
+ wire: "assignee_agent"
2431
+ },
2432
+ assigneeUserId: {
2433
+ wire: "assignee_user_id"
2434
+ },
2435
+ spam: {
2436
+ wire: "spam"
2437
+ },
2438
+ unread: {
2439
+ wire: "unread"
2440
+ }
2441
+ }
2442
+ },
2443
+ "threads.reply": {
2444
+ id: "threads.reply",
2445
+ method: "POST",
2446
+ path: "/threads/{id}/reply",
2447
+ pathParams: ["id"],
2448
+ paginated: false,
2449
+ idempotent: false,
2450
+ body: {
2451
+ text: {
2452
+ wire: "text"
2453
+ },
2454
+ html: {
2455
+ wire: "html"
2456
+ },
2457
+ messageId: {
2458
+ wire: "message_id"
2459
+ },
2460
+ replyAll: {
2461
+ wire: "reply_all"
2462
+ },
2463
+ cc: {
2464
+ wire: "cc"
2465
+ },
2466
+ quote: {
2467
+ wire: "quote"
2468
+ },
2469
+ draft: {
2470
+ wire: "draft"
2471
+ },
2472
+ status: {
2473
+ wire: "status"
2474
+ }
2475
+ }
2476
+ },
2477
+ "messages.get": {
2478
+ id: "messages.get",
2479
+ method: "GET",
2480
+ path: "/messages/{id}",
2481
+ pathParams: ["id"],
2482
+ paginated: false,
2483
+ idempotent: false
2484
+ },
2485
+ "messages.update": {
2486
+ id: "messages.update",
2487
+ method: "PATCH",
2488
+ path: "/messages/{id}",
2489
+ pathParams: ["id"],
2490
+ paginated: false,
2491
+ idempotent: false,
2492
+ body: {
2493
+ text: {
2494
+ wire: "text"
2495
+ },
2496
+ html: {
2497
+ wire: "html"
2498
+ },
2499
+ cc: {
2500
+ wire: "cc"
2501
+ }
2502
+ }
2503
+ },
2504
+ "messages.send": {
2505
+ id: "messages.send",
2506
+ method: "POST",
2507
+ path: "/messages/{id}/send",
2508
+ pathParams: ["id"],
2509
+ paginated: false,
2510
+ idempotent: false,
2511
+ body: {
2512
+ status: {
2513
+ wire: "status"
2514
+ }
2515
+ }
2516
+ },
2517
+ "messages.remove": {
2518
+ id: "messages.remove",
2519
+ method: "DELETE",
2520
+ path: "/messages/{id}",
2521
+ pathParams: ["id"],
2522
+ paginated: false,
2523
+ idempotent: false
2524
+ },
2525
+ "messages.attachment": {
2526
+ id: "messages.attachment",
2527
+ method: "GET",
2528
+ path: "/messages/{id}/attachments/{attachment_id}",
2529
+ pathParams: ["id", "attachment_id"],
2530
+ paginated: false,
2531
+ idempotent: false
2532
+ }
2533
+ };
2534
+ var OPERATION_IDS = Object.keys(OPERATIONS);
2535
+
2536
+ // src/emails.ts
2537
+ var RENDER_ERROR = "Failed to render React component. Make sure to install `@react-email/render` or `@react-email/components`.";
2538
+ var RenderError = class extends Error {
2539
+ };
2540
+ async function renderReact(node) {
2541
+ let renderFn;
2542
+ try {
2543
+ ({ render: renderFn } = await import("@react-email/render"));
2544
+ } catch {
2545
+ throw new RenderError(RENDER_ERROR);
2546
+ }
2547
+ if (typeof renderFn !== "function") throw new RenderError(RENDER_ERROR);
2548
+ try {
2549
+ return await renderFn(node);
2550
+ } catch (err) {
2551
+ throw new RenderError(err instanceof Error ? err.message : String(err));
2552
+ }
2553
+ }
2554
+ function toBase64(bytes) {
2555
+ if (typeof Buffer !== "undefined") return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
2556
+ let binary = "";
2557
+ for (let i = 0; i < bytes.length; i += 32768) {
2558
+ binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
2559
+ }
2560
+ return btoa(binary);
2561
+ }
2562
+ async function prepare(email) {
2563
+ const { react, attachments, ...rest } = email;
2564
+ const out = { ...rest };
2565
+ if (react) out.html = await renderReact(react);
2566
+ if (attachments) {
2567
+ out.attachments = attachments.map((a) => a.content instanceof Uint8Array ? { ...a, content: toBase64(a.content) } : a);
2568
+ }
2569
+ return out;
2570
+ }
2571
+ function renderFailure(err) {
2572
+ if (!(err instanceof RenderError)) return void 0;
2573
+ return { data: null, error: { name: "application_error", statusCode: null, message: err.message }, headers: null };
2574
+ }
2575
+ function makeEmailsSend(client) {
2576
+ return async (payload, options) => {
2577
+ try {
2578
+ const body = await prepare(payload);
2579
+ return await client.call(OPERATIONS["emails.send"], body, options);
2580
+ } catch (err) {
2581
+ const failure = renderFailure(err);
2582
+ if (failure) return failure;
2583
+ throw err;
2584
+ }
2585
+ };
2586
+ }
2587
+ function makeBatchSend(client) {
2588
+ return async (emails, options = {}) => {
2589
+ try {
2590
+ const body = [];
2591
+ for (const email of emails) body.push(await prepare(email));
2592
+ const { batchValidation, ...requestOptions } = options;
2593
+ const headers = new Headers({ "x-batch-validation": batchValidation ?? "strict" });
2594
+ for (const [key, value] of new Headers(requestOptions.headers)) headers.set(key, value);
2595
+ return await client.call(OPERATIONS["batch.send"], body, { ...requestOptions, headers });
2596
+ } catch (err) {
2597
+ const failure = renderFailure(err);
2598
+ if (failure) return failure;
2599
+ throw err;
2600
+ }
2601
+ };
2602
+ }
2603
+
2604
+ // src/webhooks/sha256.ts
2605
+ var K = new Uint32Array([
2606
+ 1116352408,
2607
+ 1899447441,
2608
+ 3049323471,
2609
+ 3921009573,
2610
+ 961987163,
2611
+ 1508970993,
2612
+ 2453635748,
2613
+ 2870763221,
2614
+ 3624381080,
2615
+ 310598401,
2616
+ 607225278,
2617
+ 1426881987,
2618
+ 1925078388,
2619
+ 2162078206,
2620
+ 2614888103,
2621
+ 3248222580,
2622
+ 3835390401,
2623
+ 4022224774,
2624
+ 264347078,
2625
+ 604807628,
2626
+ 770255983,
2627
+ 1249150122,
2628
+ 1555081692,
2629
+ 1996064986,
2630
+ 2554220882,
2631
+ 2821834349,
2632
+ 2952996808,
2633
+ 3210313671,
2634
+ 3336571891,
2635
+ 3584528711,
2636
+ 113926993,
2637
+ 338241895,
2638
+ 666307205,
2639
+ 773529912,
2640
+ 1294757372,
2641
+ 1396182291,
2642
+ 1695183700,
2643
+ 1986661051,
2644
+ 2177026350,
2645
+ 2456956037,
2646
+ 2730485921,
2647
+ 2820302411,
2648
+ 3259730800,
2649
+ 3345764771,
2650
+ 3516065817,
2651
+ 3600352804,
2652
+ 4094571909,
2653
+ 275423344,
2654
+ 430227734,
2655
+ 506948616,
2656
+ 659060556,
2657
+ 883997877,
2658
+ 958139571,
2659
+ 1322822218,
2660
+ 1537002063,
2661
+ 1747873779,
2662
+ 1955562222,
2663
+ 2024104815,
2664
+ 2227730452,
2665
+ 2361852424,
2666
+ 2428436474,
2667
+ 2756734187,
2668
+ 3204031479,
2669
+ 3329325298
2670
+ ]);
2671
+ var rotr = (x, n) => x >>> n | x << 32 - n;
2672
+ function sha256(data) {
2673
+ const h = new Uint32Array([
2674
+ 1779033703,
2675
+ 3144134277,
2676
+ 1013904242,
2677
+ 2773480762,
2678
+ 1359893119,
2679
+ 2600822924,
2680
+ 528734635,
2681
+ 1541459225
2682
+ ]);
2683
+ const padded = new Uint8Array(data.length + 9 + 63 >> 6 << 6);
2684
+ padded.set(data);
2685
+ padded[data.length] = 128;
2686
+ const view = new DataView(padded.buffer);
2687
+ view.setUint32(padded.length - 8, Math.floor(data.length / 536870912));
2688
+ view.setUint32(padded.length - 4, data.length << 3 >>> 0);
2689
+ const w = new Uint32Array(64);
2690
+ for (let off = 0; off < padded.length; off += 64) {
2691
+ for (let i = 0; i < 16; i++) w[i] = view.getUint32(off + i * 4);
2692
+ for (let i = 16; i < 64; i++) {
2693
+ const a2 = w[i - 15];
2694
+ const b2 = w[i - 2];
2695
+ const s0 = rotr(a2, 7) ^ rotr(a2, 18) ^ a2 >>> 3;
2696
+ const s1 = rotr(b2, 17) ^ rotr(b2, 19) ^ b2 >>> 10;
2697
+ w[i] = w[i - 16] + s0 + w[i - 7] + s1 | 0;
2698
+ }
2699
+ let [a, b, c, d, e, f, g, hh] = h;
2700
+ for (let i = 0; i < 64; i++) {
2701
+ const t1 = hh + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + (e & f ^ ~e & g) + K[i] + w[i] | 0;
2702
+ const t2 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + (a & b ^ a & c ^ b & c) | 0;
2703
+ hh = g;
2704
+ g = f;
2705
+ f = e;
2706
+ e = d + t1 | 0;
2707
+ d = c;
2708
+ c = b;
2709
+ b = a;
2710
+ a = t1 + t2 | 0;
2711
+ }
2712
+ h[0] = h[0] + a | 0;
2713
+ h[1] = h[1] + b | 0;
2714
+ h[2] = h[2] + c | 0;
2715
+ h[3] = h[3] + d | 0;
2716
+ h[4] = h[4] + e | 0;
2717
+ h[5] = h[5] + f | 0;
2718
+ h[6] = h[6] + g | 0;
2719
+ h[7] = h[7] + hh | 0;
2720
+ }
2721
+ const out = new Uint8Array(32);
2722
+ const outView = new DataView(out.buffer);
2723
+ for (let i = 0; i < 8; i++) outView.setUint32(i * 4, h[i]);
2724
+ return out;
2725
+ }
2726
+ function hmacSha256(key, message) {
2727
+ const block = new Uint8Array(64);
2728
+ block.set(key.length > 64 ? sha256(key) : key);
2729
+ const inner = new Uint8Array(64 + message.length);
2730
+ const outer = new Uint8Array(64 + 32);
2731
+ for (let i = 0; i < 64; i++) {
2732
+ inner[i] = block[i] ^ 54;
2733
+ outer[i] = block[i] ^ 92;
2734
+ }
2735
+ inner.set(message, 64);
2736
+ outer.set(sha256(inner), 64);
2737
+ return sha256(outer);
2738
+ }
2739
+
2740
+ // src/webhooks/verify.ts
2741
+ var TOLERANCE_SECONDS = 5 * 60;
2742
+ var PREFIX = "whsec_";
2743
+ var B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2744
+ var WebhookVerificationError = class _WebhookVerificationError extends Error {
2745
+ constructor(message) {
2746
+ super(message);
2747
+ Object.setPrototypeOf(this, _WebhookVerificationError.prototype);
2748
+ this.name = "WebhookVerificationError";
2749
+ }
2750
+ };
2751
+ function base64Decode(input) {
2752
+ const clean = input.replace(/=+$/, "");
2753
+ if (input.length < 4 || input.length - clean.length > 2) throw new Error("Base64Coder: incorrect padding");
2754
+ if (clean.length % 4 === 1) throw new Error("Base64Coder: incorrect characters for decoding");
2755
+ const out = new Uint8Array(Math.floor(clean.length * 3 / 4));
2756
+ let acc = 0;
2757
+ let bits = 0;
2758
+ let n = 0;
2759
+ for (let i = 0; i < clean.length; i++) {
2760
+ const v = B64.indexOf(clean[i]);
2761
+ if (v < 0) throw new Error("Base64Coder: incorrect characters for decoding");
2762
+ acc = acc << 6 | v;
2763
+ bits += 6;
2764
+ if (bits >= 8) {
2765
+ bits -= 8;
2766
+ out[n++] = acc >> bits & 255;
2767
+ acc &= (1 << bits) - 1;
2768
+ }
2769
+ }
2770
+ return out;
2771
+ }
2772
+ function base64Encode(bytes) {
2773
+ let out = "";
2774
+ for (let i = 0; i < bytes.length; i += 3) {
2775
+ const n = bytes[i] << 16 | (bytes[i + 1] ?? 0) << 8 | (bytes[i + 2] ?? 0);
2776
+ out += B64[n >> 18 & 63] + B64[n >> 12 & 63];
2777
+ out += i + 1 < bytes.length ? B64[n >> 6 & 63] : "=";
2778
+ out += i + 2 < bytes.length ? B64[n & 63] : "=";
2779
+ }
2780
+ return out;
2781
+ }
2782
+ function timingSafeEqual(a, b) {
2783
+ if (a.length !== b.length) return false;
2784
+ let diff = 0;
2785
+ for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i];
2786
+ return diff === 0;
2787
+ }
2788
+ function toPayloadString(payload) {
2789
+ if (typeof payload === "string") return payload;
2790
+ if (payload?.constructor?.name === "Buffer") return String(payload);
2791
+ throw new Error("Expected payload to be of type string or Buffer.");
2792
+ }
2793
+ function verify(input) {
2794
+ const secret = input.webhookSecret;
2795
+ if (typeof secret !== "string") throw new Error("Expected secret to be of type string");
2796
+ const key = base64Decode(secret.startsWith(PREFIX) ? secret.slice(PREFIX.length) : secret);
2797
+ if (key.length === 0) throw new Error("Secret can't be empty.");
2798
+ const { id, timestamp: timestampHeader, signature } = input.headers ?? {};
2799
+ if (!signature || !id || !timestampHeader) throw new WebhookVerificationError("Missing required headers");
2800
+ const now = Math.floor(Date.now() / 1e3);
2801
+ const timestamp = parseInt(timestampHeader, 10);
2802
+ if (Number.isNaN(timestamp)) throw new WebhookVerificationError("Invalid Signature Headers");
2803
+ if (now - timestamp > TOLERANCE_SECONDS) throw new WebhookVerificationError("Message timestamp too old");
2804
+ if (timestamp > now + TOLERANCE_SECONDS) throw new WebhookVerificationError("Message timestamp too new");
2805
+ const body = toPayloadString(input.payload);
2806
+ const encoder = new TextEncoder();
2807
+ const expected = encoder.encode(
2808
+ base64Encode(hmacSha256(key, encoder.encode(`${id}.${timestamp}.${body}`)))
2809
+ );
2810
+ for (const candidate of signature.split(" ")) {
2811
+ const [version, value] = candidate.split(",");
2812
+ if (version !== "v1") continue;
2813
+ if (timingSafeEqual(encoder.encode(value ?? ""), expected)) {
2814
+ return body === "" ? void 0 : JSON.parse(body);
2815
+ }
2816
+ }
2817
+ throw new WebhookVerificationError("No matching signature found");
2818
+ }
2819
+
2820
+ // src/resources.ts
2821
+ function camel2(snake) {
2822
+ return snake.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
2823
+ }
2824
+ var CALL_STYLE_OVERRIDES = {
2825
+ "apiKeys.update": "idBody",
2826
+ "templates.update": "idBody",
2827
+ "webhooks.update": "idBody",
2828
+ // Resend : `publish(identifier, requestOptions?)`. Le `versionId` optionnel de Smartletter n'y a pas de place.
2829
+ "templates.publish": "id"
2830
+ };
2831
+ function callStyle(op) {
2832
+ const forced = CALL_STYLE_OVERRIDES[op.id];
2833
+ if (forced) return forced;
2834
+ return op.pathParams.length === 1 && !op.body && !op.query && !op.rawBody && !op.bodyIsArray ? "id" : "params";
2835
+ }
2836
+ function makeLeaf(client, op) {
2837
+ const style = callStyle(op);
2838
+ if (style === "id") {
2839
+ const name = camel2(op.pathParams[0]);
2840
+ return (id, options) => client.call(op, { [name]: id }, options);
2841
+ }
2842
+ if (style === "idBody") {
2843
+ const name = camel2(op.pathParams[0]);
2844
+ return (id, payload, options) => client.call(op, { ...payload, [name]: id }, options);
2845
+ }
2846
+ return (args, options) => {
2847
+ const needsObject = op.pathParams.length > 0 && args === void 0;
2848
+ return client.call(op, needsObject ? {} : args, options);
2849
+ };
2850
+ }
2851
+ function chainable(promise, publish) {
2852
+ return Object.assign(promise, {
2853
+ async publish(options) {
2854
+ const { data, error } = await promise;
2855
+ if (error) return { data: null, error, headers: null };
2856
+ return publish(data.id, options);
2857
+ }
2858
+ });
2859
+ }
2860
+ function makeTemplateMethods(templates) {
2861
+ const create = templates.create;
2862
+ const duplicate = templates.duplicate;
2863
+ const publish = templates.publish;
2864
+ const createWithReact = async (payload, options) => {
2865
+ try {
2866
+ const { react, ...rest } = payload ?? {};
2867
+ const body = react ? { ...rest, html: await renderReact(react) } : payload;
2868
+ return await create(body, options);
2869
+ } catch (err) {
2870
+ const failure = renderFailure(err);
2871
+ if (failure) return failure;
2872
+ throw err;
2873
+ }
2874
+ };
2875
+ templates.create = ((payload, options) => chainable(createWithReact(payload, options), publish));
2876
+ templates.duplicate = ((id, options) => chainable(duplicate(id, options), publish));
2877
+ }
2878
+ function buildResources(client) {
2879
+ const root = {};
2880
+ for (const op of Object.values(OPERATIONS)) {
2881
+ const segments = op.id.split(".");
2882
+ const leaf = segments.pop();
2883
+ let node = root;
2884
+ for (const segment of segments) {
2885
+ const next = node[segment];
2886
+ node = node[segment] = typeof next === "object" ? next : {};
2887
+ }
2888
+ node[leaf] = makeLeaf(client, op);
2889
+ }
2890
+ root.emails.send = makeEmailsSend(client);
2891
+ root.batch.send = makeBatchSend(client);
2892
+ root.emails.create = root.emails.send;
2893
+ root.batch.create = root.batch.send;
2894
+ makeTemplateMethods(root.templates);
2895
+ root.webhooks.verify = verify;
2896
+ return root;
2897
+ }
2898
+
2899
+ // src/index.ts
2900
+ var Smartletter = class extends Client {
2901
+ constructor(key, options = {}) {
2902
+ super(key, options);
2903
+ Object.assign(this, buildResources(this));
2904
+ }
2905
+ };
2906
+ // Annotate the CommonJS export names for ESM import in node:
2907
+ 0 && (module.exports = {
2908
+ Resend,
2909
+ Smartletter,
2910
+ WebhookVerificationError
2911
+ });
2912
+ //# sourceMappingURL=index.cjs.map