@stack0/sdk 0.5.1 → 0.5.3

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.js CHANGED
@@ -79,14 +79,644 @@ var HttpClient = class {
79
79
  }
80
80
  };
81
81
 
82
+ // src/mail/audiences.ts
83
+ var Audiences = class {
84
+ constructor(http) {
85
+ this.http = http;
86
+ }
87
+ /**
88
+ * List all audiences
89
+ */
90
+ async list(request = {}) {
91
+ const params = new URLSearchParams();
92
+ if (request.environment) params.set("environment", request.environment);
93
+ if (request.limit) params.set("limit", request.limit.toString());
94
+ if (request.offset) params.set("offset", request.offset.toString());
95
+ if (request.search) params.set("search", request.search);
96
+ const query = params.toString();
97
+ return this.http.get(`/mail/audiences${query ? `?${query}` : ""}`);
98
+ }
99
+ /**
100
+ * Get an audience by ID
101
+ */
102
+ async get(id) {
103
+ return this.http.get(`/mail/audiences/${id}`);
104
+ }
105
+ /**
106
+ * Create a new audience
107
+ */
108
+ async create(request) {
109
+ return this.http.post("/mail/audiences", request);
110
+ }
111
+ /**
112
+ * Update an audience
113
+ */
114
+ async update(request) {
115
+ const { id, ...data } = request;
116
+ return this.http.put(`/mail/audiences/${id}`, data);
117
+ }
118
+ /**
119
+ * Delete an audience
120
+ */
121
+ async delete(id) {
122
+ return this.http.delete(`/mail/audiences/${id}`);
123
+ }
124
+ /**
125
+ * List contacts in an audience
126
+ */
127
+ async listContacts(request) {
128
+ const { id, ...params } = request;
129
+ const searchParams = new URLSearchParams();
130
+ if (params.environment) searchParams.set("environment", params.environment);
131
+ if (params.limit) searchParams.set("limit", params.limit.toString());
132
+ if (params.offset) searchParams.set("offset", params.offset.toString());
133
+ if (params.search) searchParams.set("search", params.search);
134
+ if (params.status) searchParams.set("status", params.status);
135
+ const query = searchParams.toString();
136
+ return this.http.get(`/mail/audiences/${id}/contacts${query ? `?${query}` : ""}`);
137
+ }
138
+ /**
139
+ * Add contacts to an audience
140
+ */
141
+ async addContacts(request) {
142
+ const { id, contactIds } = request;
143
+ return this.http.post(`/mail/audiences/${id}/contacts`, { contactIds });
144
+ }
145
+ /**
146
+ * Remove contacts from an audience
147
+ */
148
+ async removeContacts(request) {
149
+ const { id, contactIds } = request;
150
+ return this.http.deleteWithBody(`/mail/audiences/${id}/contacts`, {
151
+ contactIds
152
+ });
153
+ }
154
+ };
155
+
156
+ // src/mail/campaigns.ts
157
+ var Campaigns = class {
158
+ constructor(http) {
159
+ this.http = http;
160
+ }
161
+ /**
162
+ * List all campaigns
163
+ */
164
+ async list(request = {}) {
165
+ const params = new URLSearchParams();
166
+ if (request.environment) params.set("environment", request.environment);
167
+ if (request.limit) params.set("limit", request.limit.toString());
168
+ if (request.offset) params.set("offset", request.offset.toString());
169
+ if (request.search) params.set("search", request.search);
170
+ if (request.status) params.set("status", request.status);
171
+ const query = params.toString();
172
+ return this.http.get(`/mail/campaigns${query ? `?${query}` : ""}`);
173
+ }
174
+ /**
175
+ * Get a campaign by ID
176
+ */
177
+ async get(id) {
178
+ return this.http.get(`/mail/campaigns/${id}`);
179
+ }
180
+ /**
181
+ * Create a new campaign
182
+ */
183
+ async create(request) {
184
+ return this.http.post("/mail/campaigns", request);
185
+ }
186
+ /**
187
+ * Update a campaign
188
+ */
189
+ async update(request) {
190
+ const { id, ...data } = request;
191
+ return this.http.put(`/mail/campaigns/${id}`, data);
192
+ }
193
+ /**
194
+ * Delete a campaign
195
+ */
196
+ async delete(id) {
197
+ return this.http.delete(`/mail/campaigns/${id}`);
198
+ }
199
+ /**
200
+ * Send a campaign
201
+ */
202
+ async send(request) {
203
+ const { id, ...data } = request;
204
+ return this.http.post(`/mail/campaigns/${id}/send`, data);
205
+ }
206
+ /**
207
+ * Pause a sending campaign
208
+ */
209
+ async pause(id) {
210
+ return this.http.post(`/mail/campaigns/${id}/pause`, {});
211
+ }
212
+ /**
213
+ * Cancel a campaign
214
+ */
215
+ async cancel(id) {
216
+ return this.http.post(`/mail/campaigns/${id}/cancel`, {});
217
+ }
218
+ /**
219
+ * Duplicate a campaign
220
+ */
221
+ async duplicate(id) {
222
+ return this.http.post(`/mail/campaigns/${id}/duplicate`, {});
223
+ }
224
+ /**
225
+ * Get campaign statistics
226
+ */
227
+ async getStats(id) {
228
+ return this.http.get(`/mail/campaigns/${id}/stats`);
229
+ }
230
+ };
231
+
232
+ // src/mail/contacts.ts
233
+ var Contacts = class {
234
+ constructor(http) {
235
+ this.http = http;
236
+ }
237
+ /**
238
+ * List all contacts
239
+ */
240
+ async list(request = {}) {
241
+ const params = new URLSearchParams();
242
+ if (request.environment) params.set("environment", request.environment);
243
+ if (request.limit) params.set("limit", request.limit.toString());
244
+ if (request.offset) params.set("offset", request.offset.toString());
245
+ if (request.search) params.set("search", request.search);
246
+ if (request.status) params.set("status", request.status);
247
+ const query = params.toString();
248
+ return this.http.get(`/mail/contacts${query ? `?${query}` : ""}`);
249
+ }
250
+ /**
251
+ * Get a contact by ID
252
+ */
253
+ async get(id) {
254
+ return this.http.get(`/mail/contacts/${id}`);
255
+ }
256
+ /**
257
+ * Create a new contact
258
+ */
259
+ async create(request) {
260
+ return this.http.post("/mail/contacts", request);
261
+ }
262
+ /**
263
+ * Update a contact
264
+ */
265
+ async update(request) {
266
+ const { id, ...data } = request;
267
+ return this.http.put(`/mail/contacts/${id}`, data);
268
+ }
269
+ /**
270
+ * Delete a contact
271
+ */
272
+ async delete(id) {
273
+ return this.http.delete(`/mail/contacts/${id}`);
274
+ }
275
+ /**
276
+ * Import contacts in bulk
277
+ */
278
+ async import(request) {
279
+ return this.http.post("/mail/contacts/import", request);
280
+ }
281
+ };
282
+
283
+ // src/mail/domains.ts
284
+ var Domains = class {
285
+ constructor(http) {
286
+ this.http = http;
287
+ }
288
+ /**
289
+ * List all domains for the organization
290
+ */
291
+ async list(request) {
292
+ const params = new URLSearchParams();
293
+ params.set("projectSlug", request.projectSlug);
294
+ if (request.environment) params.set("environment", request.environment);
295
+ return this.http.get(`/mail/domains?${params.toString()}`);
296
+ }
297
+ /**
298
+ * Add a new domain
299
+ */
300
+ async add(request) {
301
+ return this.http.post("/mail/domains", request);
302
+ }
303
+ /**
304
+ * Get DNS records for a domain
305
+ */
306
+ async getDnsRecords(domainId) {
307
+ return this.http.get(`/mail/domains/${domainId}/dns`);
308
+ }
309
+ /**
310
+ * Verify a domain
311
+ */
312
+ async verify(domainId) {
313
+ return this.http.post(`/mail/domains/${domainId}/verify`, {});
314
+ }
315
+ /**
316
+ * Delete a domain
317
+ */
318
+ async delete(domainId) {
319
+ return this.http.delete(`/mail/domains/${domainId}`);
320
+ }
321
+ /**
322
+ * Set a domain as the default
323
+ */
324
+ async setDefault(domainId) {
325
+ return this.http.post(`/mail/domains/${domainId}/default`, {});
326
+ }
327
+ };
328
+
329
+ // src/mail/events.ts
330
+ var Events = class {
331
+ constructor(http) {
332
+ this.http = http;
333
+ }
334
+ // ============================================================================
335
+ // EVENT DEFINITIONS
336
+ // ============================================================================
337
+ /**
338
+ * List all event definitions
339
+ */
340
+ async list(request = {}) {
341
+ const params = new URLSearchParams();
342
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
343
+ if (request.environment) params.set("environment", request.environment);
344
+ if (request.limit) params.set("limit", request.limit.toString());
345
+ if (request.offset) params.set("offset", request.offset.toString());
346
+ if (request.search) params.set("search", request.search);
347
+ const query = params.toString();
348
+ return this.http.get(`/mail/events${query ? `?${query}` : ""}`);
349
+ }
350
+ /**
351
+ * Get an event definition by ID
352
+ */
353
+ async get(id) {
354
+ return this.http.get(`/mail/events/${id}`);
355
+ }
356
+ /**
357
+ * Create a new event definition
358
+ */
359
+ async create(request) {
360
+ return this.http.post("/mail/events", request);
361
+ }
362
+ /**
363
+ * Update an event definition
364
+ */
365
+ async update(request) {
366
+ const { id, ...data } = request;
367
+ return this.http.put(`/mail/events/${id}`, data);
368
+ }
369
+ /**
370
+ * Delete an event definition
371
+ */
372
+ async delete(id) {
373
+ return this.http.delete(`/mail/events/${id}`);
374
+ }
375
+ // ============================================================================
376
+ // EVENT TRACKING
377
+ // ============================================================================
378
+ /**
379
+ * Track a single event
380
+ * This can trigger email sequences configured to listen for this event
381
+ */
382
+ async track(request) {
383
+ return this.http.post("/mail/events/track", request);
384
+ }
385
+ /**
386
+ * Track multiple events in a batch (max 100)
387
+ */
388
+ async trackBatch(request) {
389
+ return this.http.post("/mail/events/track/batch", request);
390
+ }
391
+ // ============================================================================
392
+ // EVENT OCCURRENCES
393
+ // ============================================================================
394
+ /**
395
+ * List event occurrences
396
+ */
397
+ async listOccurrences(request = {}) {
398
+ const params = new URLSearchParams();
399
+ if (request.eventId) params.set("eventId", request.eventId);
400
+ if (request.contactId) params.set("contactId", request.contactId);
401
+ if (request.limit) params.set("limit", request.limit.toString());
402
+ if (request.offset) params.set("offset", request.offset.toString());
403
+ if (request.startDate) {
404
+ params.set("startDate", request.startDate instanceof Date ? request.startDate.toISOString() : request.startDate);
405
+ }
406
+ if (request.endDate) {
407
+ params.set("endDate", request.endDate instanceof Date ? request.endDate.toISOString() : request.endDate);
408
+ }
409
+ const query = params.toString();
410
+ return this.http.get(`/mail/events/occurrences${query ? `?${query}` : ""}`);
411
+ }
412
+ // ============================================================================
413
+ // ANALYTICS
414
+ // ============================================================================
415
+ /**
416
+ * Get analytics for an event
417
+ */
418
+ async getAnalytics(id) {
419
+ return this.http.get(`/mail/events/analytics/${id}`);
420
+ }
421
+ };
422
+
423
+ // src/mail/sequences.ts
424
+ var Sequences = class {
425
+ constructor(http) {
426
+ this.http = http;
427
+ }
428
+ // ============================================================================
429
+ // SEQUENCE CRUD
430
+ // ============================================================================
431
+ /**
432
+ * List all sequences
433
+ */
434
+ async list(request = {}) {
435
+ const params = new URLSearchParams();
436
+ if (request.environment) params.set("environment", request.environment);
437
+ if (request.limit) params.set("limit", request.limit.toString());
438
+ if (request.offset) params.set("offset", request.offset.toString());
439
+ if (request.search) params.set("search", request.search);
440
+ if (request.status) params.set("status", request.status);
441
+ if (request.triggerType) params.set("triggerType", request.triggerType);
442
+ const query = params.toString();
443
+ return this.http.get(`/mail/sequences${query ? `?${query}` : ""}`);
444
+ }
445
+ /**
446
+ * Get a sequence by ID with all nodes and connections
447
+ */
448
+ async get(id) {
449
+ return this.http.get(`/mail/sequences/${id}`);
450
+ }
451
+ /**
452
+ * Create a new sequence
453
+ */
454
+ async create(request) {
455
+ return this.http.post("/mail/sequences", request);
456
+ }
457
+ /**
458
+ * Update a sequence
459
+ */
460
+ async update(request) {
461
+ const { id, ...data } = request;
462
+ return this.http.put(`/mail/sequences/${id}`, data);
463
+ }
464
+ /**
465
+ * Delete a sequence
466
+ */
467
+ async delete(id) {
468
+ return this.http.delete(`/mail/sequences/${id}`);
469
+ }
470
+ // ============================================================================
471
+ // SEQUENCE LIFECYCLE
472
+ // ============================================================================
473
+ /**
474
+ * Publish (activate) a sequence
475
+ */
476
+ async publish(id) {
477
+ return this.http.post(`/mail/sequences/${id}/publish`, {});
478
+ }
479
+ /**
480
+ * Pause an active sequence
481
+ */
482
+ async pause(id) {
483
+ return this.http.post(`/mail/sequences/${id}/pause`, {});
484
+ }
485
+ /**
486
+ * Resume a paused sequence
487
+ */
488
+ async resume(id) {
489
+ return this.http.post(`/mail/sequences/${id}/resume`, {});
490
+ }
491
+ /**
492
+ * Archive a sequence
493
+ */
494
+ async archive(id) {
495
+ return this.http.post(`/mail/sequences/${id}/archive`, {});
496
+ }
497
+ /**
498
+ * Duplicate a sequence
499
+ */
500
+ async duplicate(id, name) {
501
+ return this.http.post(`/mail/sequences/${id}/duplicate`, { name });
502
+ }
503
+ // ============================================================================
504
+ // NODE MANAGEMENT
505
+ // ============================================================================
506
+ /**
507
+ * Create a new node in a sequence
508
+ */
509
+ async createNode(request) {
510
+ const { id, ...data } = request;
511
+ return this.http.post(`/mail/sequences/${id}/nodes`, data);
512
+ }
513
+ /**
514
+ * Update a node
515
+ */
516
+ async updateNode(request) {
517
+ const { id, nodeId, ...data } = request;
518
+ return this.http.put(`/mail/sequences/${id}/nodes/${nodeId}`, data);
519
+ }
520
+ /**
521
+ * Update node position (for visual editor)
522
+ */
523
+ async updateNodePosition(request) {
524
+ const { id, nodeId, positionX, positionY } = request;
525
+ return this.http.put(`/mail/sequences/${id}/nodes/${nodeId}/position`, { positionX, positionY });
526
+ }
527
+ /**
528
+ * Delete a node
529
+ */
530
+ async deleteNode(sequenceId, nodeId) {
531
+ return this.http.delete(`/mail/sequences/${sequenceId}/nodes/${nodeId}`);
532
+ }
533
+ // ============================================================================
534
+ // NODE CONFIGURATIONS
535
+ // ============================================================================
536
+ /**
537
+ * Set email node content
538
+ */
539
+ async setNodeEmail(sequenceId, request) {
540
+ const { nodeId, ...data } = request;
541
+ return this.http.put(`/mail/sequences/${sequenceId}/nodes/${nodeId}/email`, data);
542
+ }
543
+ /**
544
+ * Set timer node configuration
545
+ */
546
+ async setNodeTimer(sequenceId, request) {
547
+ const { nodeId, ...data } = request;
548
+ return this.http.put(`/mail/sequences/${sequenceId}/nodes/${nodeId}/timer`, data);
549
+ }
550
+ /**
551
+ * Set filter node configuration
552
+ */
553
+ async setNodeFilter(sequenceId, request) {
554
+ const { nodeId, ...data } = request;
555
+ return this.http.put(`/mail/sequences/${sequenceId}/nodes/${nodeId}/filter`, data);
556
+ }
557
+ /**
558
+ * Set branch node configuration
559
+ */
560
+ async setNodeBranch(sequenceId, request) {
561
+ const { nodeId, ...data } = request;
562
+ return this.http.put(`/mail/sequences/${sequenceId}/nodes/${nodeId}/branch`, data);
563
+ }
564
+ /**
565
+ * Set experiment node configuration
566
+ */
567
+ async setNodeExperiment(sequenceId, request) {
568
+ const { nodeId, ...data } = request;
569
+ return this.http.put(`/mail/sequences/${sequenceId}/nodes/${nodeId}/experiment`, data);
570
+ }
571
+ // ============================================================================
572
+ // CONNECTIONS
573
+ // ============================================================================
574
+ /**
575
+ * Create a connection between nodes
576
+ */
577
+ async createConnection(request) {
578
+ const { id, ...data } = request;
579
+ return this.http.post(`/mail/sequences/${id}/connections`, data);
580
+ }
581
+ /**
582
+ * Delete a connection
583
+ */
584
+ async deleteConnection(sequenceId, connectionId) {
585
+ return this.http.delete(`/mail/sequences/${sequenceId}/connections/${connectionId}`);
586
+ }
587
+ // ============================================================================
588
+ // SEQUENCE ENTRIES (CONTACTS IN SEQUENCE)
589
+ // ============================================================================
590
+ /**
591
+ * List contacts in a sequence
592
+ */
593
+ async listEntries(request) {
594
+ const { id, ...params } = request;
595
+ const searchParams = new URLSearchParams();
596
+ if (params.limit) searchParams.set("limit", params.limit.toString());
597
+ if (params.offset) searchParams.set("offset", params.offset.toString());
598
+ if (params.status) searchParams.set("status", params.status);
599
+ const query = searchParams.toString();
600
+ return this.http.get(`/mail/sequences/${id}/entries${query ? `?${query}` : ""}`);
601
+ }
602
+ /**
603
+ * Add a contact to a sequence
604
+ */
605
+ async addContact(request) {
606
+ const { id, contactId } = request;
607
+ return this.http.post(`/mail/sequences/${id}/add-contact`, { contactId });
608
+ }
609
+ /**
610
+ * Remove a contact from a sequence
611
+ */
612
+ async removeContact(request) {
613
+ const { id, entryId, reason } = request;
614
+ return this.http.post(`/mail/sequences/${id}/remove-contact`, {
615
+ entryId,
616
+ reason
617
+ });
618
+ }
619
+ // ============================================================================
620
+ // ANALYTICS
621
+ // ============================================================================
622
+ /**
623
+ * Get sequence analytics
624
+ */
625
+ async getAnalytics(id) {
626
+ return this.http.get(`/mail/sequences/${id}/analytics`);
627
+ }
628
+ };
629
+
630
+ // src/mail/templates.ts
631
+ var Templates = class {
632
+ constructor(http) {
633
+ this.http = http;
634
+ }
635
+ /**
636
+ * List all templates
637
+ */
638
+ async list(request = {}) {
639
+ const params = new URLSearchParams();
640
+ if (request.environment) params.set("environment", request.environment);
641
+ if (request.limit) params.set("limit", request.limit.toString());
642
+ if (request.offset) params.set("offset", request.offset.toString());
643
+ if (request.isActive !== void 0) params.set("isActive", request.isActive.toString());
644
+ if (request.search) params.set("search", request.search);
645
+ const query = params.toString();
646
+ return this.http.get(`/mail/templates${query ? `?${query}` : ""}`);
647
+ }
648
+ /**
649
+ * Get a template by ID
650
+ */
651
+ async get(id) {
652
+ return this.http.get(`/mail/templates/${id}`);
653
+ }
654
+ /**
655
+ * Get a template by slug
656
+ */
657
+ async getBySlug(slug) {
658
+ return this.http.get(`/mail/templates/slug/${slug}`);
659
+ }
660
+ /**
661
+ * Create a new template
662
+ */
663
+ async create(request) {
664
+ return this.http.post("/mail/templates", request);
665
+ }
666
+ /**
667
+ * Update a template
668
+ */
669
+ async update(request) {
670
+ const { id, ...data } = request;
671
+ return this.http.put(`/mail/templates/${id}`, data);
672
+ }
673
+ /**
674
+ * Delete a template
675
+ */
676
+ async delete(id) {
677
+ return this.http.delete(`/mail/templates/${id}`);
678
+ }
679
+ /**
680
+ * Preview a template with variables
681
+ */
682
+ async preview(request) {
683
+ const { id, variables } = request;
684
+ return this.http.post(`/mail/templates/${id}/preview`, { variables });
685
+ }
686
+ };
687
+
82
688
  // src/mail/client.ts
83
689
  var Mail = class {
84
690
  http;
691
+ /** Manage sending domains */
692
+ domains;
693
+ /** Manage email templates */
694
+ templates;
695
+ /** Manage contact audiences/lists */
696
+ audiences;
697
+ /** Manage contacts */
698
+ contacts;
699
+ /** Manage email campaigns */
700
+ campaigns;
701
+ /** Manage automated email sequences */
702
+ sequences;
703
+ /** Track and manage custom events */
704
+ events;
85
705
  constructor(config) {
86
706
  this.http = new HttpClient(config);
707
+ this.domains = new Domains(this.http);
708
+ this.templates = new Templates(this.http);
709
+ this.audiences = new Audiences(this.http);
710
+ this.contacts = new Contacts(this.http);
711
+ this.campaigns = new Campaigns(this.http);
712
+ this.sequences = new Sequences(this.http);
713
+ this.events = new Events(this.http);
87
714
  }
715
+ // ============================================================================
716
+ // TRANSACTIONAL EMAILS
717
+ // ============================================================================
88
718
  /**
89
- * Send an email
719
+ * Send a single email
90
720
  *
91
721
  * @example
92
722
  * ```typescript
@@ -99,11 +729,40 @@ var Mail = class {
99
729
  * ```
100
730
  */
101
731
  async send(request) {
102
- const response = await this.http.post("/mail/send", request);
103
- if (typeof response.createdAt === "string") {
104
- response.createdAt = new Date(response.createdAt);
105
- }
106
- return response;
732
+ return this.http.post("/mail/send", request);
733
+ }
734
+ /**
735
+ * Send multiple emails in a batch (up to 100)
736
+ * Each email can have different content and recipients
737
+ *
738
+ * @example
739
+ * ```typescript
740
+ * const result = await mail.sendBatch({
741
+ * emails: [
742
+ * { from: 'noreply@example.com', to: 'user1@example.com', subject: 'Hello', html: '<p>Hi User 1</p>' },
743
+ * { from: 'noreply@example.com', to: 'user2@example.com', subject: 'Hello', html: '<p>Hi User 2</p>' },
744
+ * ]
745
+ * });
746
+ * ```
747
+ */
748
+ async sendBatch(request) {
749
+ return this.http.post("/mail/send/batch", request);
750
+ }
751
+ /**
752
+ * Send a broadcast email (same content to multiple recipients, up to 1000)
753
+ *
754
+ * @example
755
+ * ```typescript
756
+ * const result = await mail.sendBroadcast({
757
+ * from: 'noreply@example.com',
758
+ * to: ['user1@example.com', 'user2@example.com', 'user3@example.com'],
759
+ * subject: 'Newsletter',
760
+ * html: '<p>Our latest updates...</p>',
761
+ * });
762
+ * ```
763
+ */
764
+ async sendBroadcast(request) {
765
+ return this.http.post("/mail/send/broadcast", request);
107
766
  }
108
767
  /**
109
768
  * Get email details by ID
@@ -115,14 +774,87 @@ var Mail = class {
115
774
  * ```
116
775
  */
117
776
  async get(id) {
118
- const response = await this.http.get(`/mail/${id}`);
119
- const dateFields = ["createdAt", "sentAt", "deliveredAt", "openedAt", "clickedAt", "bouncedAt"];
120
- for (const field of dateFields) {
121
- if (response[field] && typeof response[field] === "string") {
122
- response[field] = new Date(response[field]);
123
- }
777
+ return this.http.get(`/mail/${id}`);
778
+ }
779
+ /**
780
+ * List emails with optional filters
781
+ *
782
+ * @example
783
+ * ```typescript
784
+ * const result = await mail.list({
785
+ * status: 'delivered',
786
+ * limit: 50,
787
+ * });
788
+ * ```
789
+ */
790
+ async list(request = {}) {
791
+ const params = new URLSearchParams();
792
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
793
+ if (request.environment) params.set("environment", request.environment);
794
+ if (request.limit) params.set("limit", request.limit.toString());
795
+ if (request.offset) params.set("offset", request.offset.toString());
796
+ if (request.status) params.set("status", request.status);
797
+ if (request.from) params.set("from", request.from);
798
+ if (request.to) params.set("to", request.to);
799
+ if (request.subject) params.set("subject", request.subject);
800
+ if (request.tag) params.set("tag", request.tag);
801
+ if (request.startDate) {
802
+ params.set("startDate", request.startDate instanceof Date ? request.startDate.toISOString() : request.startDate);
124
803
  }
125
- return response;
804
+ if (request.endDate) {
805
+ params.set("endDate", request.endDate instanceof Date ? request.endDate.toISOString() : request.endDate);
806
+ }
807
+ if (request.sortBy) params.set("sortBy", request.sortBy);
808
+ if (request.sortOrder) params.set("sortOrder", request.sortOrder);
809
+ const query = params.toString();
810
+ return this.http.get(`/mail${query ? `?${query}` : ""}`);
811
+ }
812
+ /**
813
+ * Resend a previously sent email
814
+ */
815
+ async resend(id) {
816
+ return this.http.post(`/mail/${id}/resend`, {});
817
+ }
818
+ /**
819
+ * Cancel a scheduled email
820
+ */
821
+ async cancel(id) {
822
+ return this.http.post(`/mail/${id}/cancel`, {});
823
+ }
824
+ // ============================================================================
825
+ // ANALYTICS
826
+ // ============================================================================
827
+ /**
828
+ * Get overall email analytics
829
+ */
830
+ async getAnalytics() {
831
+ return this.http.get("/mail/analytics");
832
+ }
833
+ /**
834
+ * Get time series analytics (daily breakdown)
835
+ */
836
+ async getTimeSeriesAnalytics(request = {}) {
837
+ const params = new URLSearchParams();
838
+ if (request.days) params.set("days", request.days.toString());
839
+ const query = params.toString();
840
+ return this.http.get(`/mail/analytics/timeseries${query ? `?${query}` : ""}`);
841
+ }
842
+ /**
843
+ * Get hourly analytics
844
+ */
845
+ async getHourlyAnalytics() {
846
+ return this.http.get("/mail/analytics/hourly");
847
+ }
848
+ /**
849
+ * List unique senders with their statistics
850
+ */
851
+ async listSenders(request = {}) {
852
+ const params = new URLSearchParams();
853
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
854
+ if (request.environment) params.set("environment", request.environment);
855
+ if (request.search) params.set("search", request.search);
856
+ const query = params.toString();
857
+ return this.http.get(`/mail/senders${query ? `?${query}` : ""}`);
126
858
  }
127
859
  };
128
860
 
@@ -870,6 +1602,224 @@ var CDN = class {
870
1602
  }
871
1603
  return bundle;
872
1604
  }
1605
+ // ============================================================================
1606
+ // Usage Methods
1607
+ // ============================================================================
1608
+ /**
1609
+ * Get current usage stats for the billing period
1610
+ *
1611
+ * @example
1612
+ * ```typescript
1613
+ * const usage = await cdn.getUsage({
1614
+ * projectSlug: 'my-project',
1615
+ * });
1616
+ * console.log(`Bandwidth: ${usage.bandwidthFormatted}`);
1617
+ * console.log(`Estimated cost: ${usage.estimatedCostFormatted}`);
1618
+ * ```
1619
+ */
1620
+ async getUsage(request = {}) {
1621
+ const params = new URLSearchParams();
1622
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
1623
+ if (request.environment) params.set("environment", request.environment);
1624
+ if (request.periodStart) {
1625
+ const date = request.periodStart instanceof Date ? request.periodStart.toISOString() : request.periodStart;
1626
+ params.set("periodStart", date);
1627
+ }
1628
+ if (request.periodEnd) {
1629
+ const date = request.periodEnd instanceof Date ? request.periodEnd.toISOString() : request.periodEnd;
1630
+ params.set("periodEnd", date);
1631
+ }
1632
+ const query = params.toString();
1633
+ const response = await this.http.get(`/cdn/usage${query ? `?${query}` : ""}`);
1634
+ return this.convertUsageDates(response);
1635
+ }
1636
+ /**
1637
+ * Get usage history (time series data for charts)
1638
+ *
1639
+ * @example
1640
+ * ```typescript
1641
+ * const history = await cdn.getUsageHistory({
1642
+ * projectSlug: 'my-project',
1643
+ * days: 30,
1644
+ * });
1645
+ * console.log(`Total requests: ${history.totals.requests}`);
1646
+ * ```
1647
+ */
1648
+ async getUsageHistory(request = {}) {
1649
+ const params = new URLSearchParams();
1650
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
1651
+ if (request.environment) params.set("environment", request.environment);
1652
+ if (request.days) params.set("days", request.days.toString());
1653
+ if (request.granularity) params.set("granularity", request.granularity);
1654
+ const query = params.toString();
1655
+ const response = await this.http.get(`/cdn/usage/history${query ? `?${query}` : ""}`);
1656
+ return {
1657
+ ...response,
1658
+ data: response.data.map((point) => this.convertUsageDataPointDates(point))
1659
+ };
1660
+ }
1661
+ /**
1662
+ * Get storage breakdown by type or folder
1663
+ *
1664
+ * @example
1665
+ * ```typescript
1666
+ * const breakdown = await cdn.getStorageBreakdown({
1667
+ * projectSlug: 'my-project',
1668
+ * groupBy: 'type',
1669
+ * });
1670
+ * breakdown.items.forEach(item => {
1671
+ * console.log(`${item.key}: ${item.sizeFormatted} (${item.percentage}%)`);
1672
+ * });
1673
+ * ```
1674
+ */
1675
+ async getStorageBreakdown(request = {}) {
1676
+ const params = new URLSearchParams();
1677
+ if (request.projectSlug) params.set("projectSlug", request.projectSlug);
1678
+ if (request.environment) params.set("environment", request.environment);
1679
+ if (request.groupBy) params.set("groupBy", request.groupBy);
1680
+ const query = params.toString();
1681
+ return this.http.get(`/cdn/usage/storage-breakdown${query ? `?${query}` : ""}`);
1682
+ }
1683
+ convertUsageDates(usage) {
1684
+ if (typeof usage.periodStart === "string") {
1685
+ usage.periodStart = new Date(usage.periodStart);
1686
+ }
1687
+ if (typeof usage.periodEnd === "string") {
1688
+ usage.periodEnd = new Date(usage.periodEnd);
1689
+ }
1690
+ return usage;
1691
+ }
1692
+ convertUsageDataPointDates(point) {
1693
+ if (typeof point.timestamp === "string") {
1694
+ point.timestamp = new Date(point.timestamp);
1695
+ }
1696
+ return point;
1697
+ }
1698
+ // ============================================================================
1699
+ // Additional Folder Methods
1700
+ // ============================================================================
1701
+ /**
1702
+ * Get a folder by ID
1703
+ *
1704
+ * @example
1705
+ * ```typescript
1706
+ * const folder = await cdn.getFolder('folder-id');
1707
+ * console.log(`Folder: ${folder.name}, Assets: ${folder.assetCount}`);
1708
+ * ```
1709
+ */
1710
+ async getFolder(id) {
1711
+ const response = await this.http.get(`/cdn/folders/${id}`);
1712
+ return this.convertFolderDates(response);
1713
+ }
1714
+ /**
1715
+ * Get a folder by its path
1716
+ *
1717
+ * @example
1718
+ * ```typescript
1719
+ * const folder = await cdn.getFolderByPath('/images/avatars');
1720
+ * ```
1721
+ */
1722
+ async getFolderByPath(path) {
1723
+ const encodedPath = encodeURIComponent(path);
1724
+ const response = await this.http.get(`/cdn/folders/path/${encodedPath}`);
1725
+ return this.convertFolderDates(response);
1726
+ }
1727
+ /**
1728
+ * Update a folder's name
1729
+ *
1730
+ * @example
1731
+ * ```typescript
1732
+ * const folder = await cdn.updateFolder({
1733
+ * id: 'folder-id',
1734
+ * name: 'New Folder Name',
1735
+ * });
1736
+ * ```
1737
+ */
1738
+ async updateFolder(request) {
1739
+ const { id, ...data } = request;
1740
+ const response = await this.http.patch(`/cdn/folders/${id}`, data);
1741
+ return this.convertFolderDates(response);
1742
+ }
1743
+ /**
1744
+ * List folders with optional filters
1745
+ *
1746
+ * @example
1747
+ * ```typescript
1748
+ * const { folders, total } = await cdn.listFolders({
1749
+ * parentId: null, // root level
1750
+ * limit: 50,
1751
+ * });
1752
+ * ```
1753
+ */
1754
+ async listFolders(request = {}) {
1755
+ const params = new URLSearchParams();
1756
+ if (request.parentId !== void 0) params.set("parentId", request.parentId ?? "");
1757
+ if (request.limit) params.set("limit", request.limit.toString());
1758
+ if (request.offset) params.set("offset", request.offset.toString());
1759
+ if (request.search) params.set("search", request.search);
1760
+ const query = params.toString();
1761
+ const response = await this.http.get(`/cdn/folders${query ? `?${query}` : ""}`);
1762
+ return {
1763
+ ...response,
1764
+ folders: response.folders.map((folder) => this.convertFolderListItemDates(folder))
1765
+ };
1766
+ }
1767
+ /**
1768
+ * Move a folder to a new parent
1769
+ *
1770
+ * @example
1771
+ * ```typescript
1772
+ * await cdn.moveFolder({
1773
+ * id: 'folder-id',
1774
+ * newParentId: 'new-parent-id', // or null for root
1775
+ * });
1776
+ * ```
1777
+ */
1778
+ async moveFolder(request) {
1779
+ return this.http.post("/cdn/folders/move", request);
1780
+ }
1781
+ convertFolderListItemDates(folder) {
1782
+ if (typeof folder.createdAt === "string") {
1783
+ folder.createdAt = new Date(folder.createdAt);
1784
+ }
1785
+ return folder;
1786
+ }
1787
+ // ============================================================================
1788
+ // Additional Video Methods
1789
+ // ============================================================================
1790
+ /**
1791
+ * List all thumbnails for a video asset
1792
+ *
1793
+ * @example
1794
+ * ```typescript
1795
+ * const { thumbnails } = await cdn.listThumbnails('video-asset-id');
1796
+ * thumbnails.forEach(thumb => {
1797
+ * console.log(`${thumb.timestamp}s: ${thumb.url}`);
1798
+ * });
1799
+ * ```
1800
+ */
1801
+ async listThumbnails(assetId) {
1802
+ const response = await this.http.get(`/cdn/video/${assetId}/thumbnails`);
1803
+ return response;
1804
+ }
1805
+ // ============================================================================
1806
+ // Additional Private Files Methods
1807
+ // ============================================================================
1808
+ /**
1809
+ * Move private files to a different folder
1810
+ *
1811
+ * @example
1812
+ * ```typescript
1813
+ * const result = await cdn.movePrivateFiles({
1814
+ * fileIds: ['file-1', 'file-2'],
1815
+ * folder: '/confidential/archive',
1816
+ * });
1817
+ * console.log(`Moved ${result.movedCount} files`);
1818
+ * ```
1819
+ */
1820
+ async movePrivateFiles(request) {
1821
+ return this.http.post("/cdn/private/move", request);
1822
+ }
873
1823
  };
874
1824
 
875
1825
  // src/screenshots/client.ts
@@ -2914,13 +3864,20 @@ var Stack0 = class {
2914
3864
  };
2915
3865
  var src_default = Stack0;
2916
3866
 
3867
+ exports.Audiences = Audiences;
2917
3868
  exports.CDN = CDN;
3869
+ exports.Campaigns = Campaigns;
3870
+ exports.Contacts = Contacts;
3871
+ exports.Domains = Domains;
3872
+ exports.Events = Events;
2918
3873
  exports.Extraction = Extraction;
2919
3874
  exports.Integrations = Integrations;
2920
3875
  exports.Mail = Mail;
2921
3876
  exports.Marketing = Marketing;
2922
3877
  exports.Screenshots = Screenshots;
3878
+ exports.Sequences = Sequences;
2923
3879
  exports.Stack0 = Stack0;
3880
+ exports.Templates = Templates;
2924
3881
  exports.Webdata = Webdata;
2925
3882
  exports.default = src_default;
2926
3883
  //# sourceMappingURL=index.js.map