@tratto/email 1.1.0 → 1.1.1

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/README.md CHANGED
@@ -281,6 +281,16 @@ await tratto.templates.testSend(tpl.id, 'me@example.com', { name: 'Alice' });
281
281
  await tratto.templates.delete(tpl.id);
282
282
  ```
283
283
 
284
+ Templates created from `markdown` come back with `format: 'emailmd'`, the
285
+ markdown in `source`, the rendered HTML in `html`, and — when part of the
286
+ markdown could not be rendered — a `renderWarnings: string[]` array on the
287
+ template object. The field is absent when there is nothing to report:
288
+
289
+ ```ts
290
+ const tpl = await tratto.templates.create({ name: 'Welcome', markdown: '# Hi {{name}}' });
291
+ if (tpl.renderWarnings?.length) console.warn(tpl.renderWarnings);
292
+ ```
293
+
284
294
  ---
285
295
 
286
296
  ### Webhooks
@@ -342,7 +352,9 @@ console.log('Open rate:', summary.openRate);
342
352
  const points = await tratto.analytics.getTimeseries('7d');
343
353
  ```
344
354
 
345
- Supported periods: `'7d'` | `'30d'` | `'90d'`. Results are cached server-side for 1 hour.
355
+ Supported periods: `'7d'` | `'30d'` | `'90d'` | `'180d'` | `'1y'` (default `'30d'`).
356
+ `'180d'` and `'1y'` read the long-term aggregate, which holds live data only:
357
+ they are rejected for test-mode keys. Results are cached server-side for 1 hour.
346
358
 
347
359
  ---
348
360
 
@@ -434,8 +446,6 @@ import type {
434
446
  Template,
435
447
  Webhook,
436
448
  Domain,
437
- ApiKey,
438
- ApiKeyCreated,
439
449
  AnalyticsSummary,
440
450
  TimeseriesPoint,
441
451
  Flow,
package/dist/index.d.mts CHANGED
@@ -176,6 +176,14 @@ interface Campaign {
176
176
  sentAt: string | null;
177
177
  stats: CampaignStats;
178
178
  createdAt: string;
179
+ /**
180
+ * The editable markdown of an emailmd campaign (its own copy — editing it
181
+ * never touches the template). Returned by `get()` only: `list()` omits
182
+ * `source` and `renderWarnings` to keep the payload small.
183
+ */
184
+ source?: string;
185
+ /** Markdown that could not be rendered. Returned by `get()` only, absent when empty. */
186
+ renderWarnings?: string[];
179
187
  }
180
188
  interface CampaignStatsDetail {
181
189
  campaignId: string;
@@ -306,7 +314,8 @@ interface ListDomainsParams {
306
314
  after?: string;
307
315
  limit?: number;
308
316
  }
309
- type AnalyticsPeriod = '7d' | '30d' | '90d';
317
+ /** `'180d'` and `'1y'` read the long-term aggregate (live data only) and are rejected for test-mode keys. */
318
+ type AnalyticsPeriod = '7d' | '30d' | '90d' | '180d' | '1y';
310
319
  interface AnalyticsSummary {
311
320
  period: AnalyticsPeriod;
312
321
  totalSent: number;
package/dist/index.d.ts CHANGED
@@ -176,6 +176,14 @@ interface Campaign {
176
176
  sentAt: string | null;
177
177
  stats: CampaignStats;
178
178
  createdAt: string;
179
+ /**
180
+ * The editable markdown of an emailmd campaign (its own copy — editing it
181
+ * never touches the template). Returned by `get()` only: `list()` omits
182
+ * `source` and `renderWarnings` to keep the payload small.
183
+ */
184
+ source?: string;
185
+ /** Markdown that could not be rendered. Returned by `get()` only, absent when empty. */
186
+ renderWarnings?: string[];
179
187
  }
180
188
  interface CampaignStatsDetail {
181
189
  campaignId: string;
@@ -306,7 +314,8 @@ interface ListDomainsParams {
306
314
  after?: string;
307
315
  limit?: number;
308
316
  }
309
- type AnalyticsPeriod = '7d' | '30d' | '90d';
317
+ /** `'180d'` and `'1y'` read the long-term aggregate (live data only) and are rejected for test-mode keys. */
318
+ type AnalyticsPeriod = '7d' | '30d' | '90d' | '180d' | '1y';
310
319
  interface AnalyticsSummary {
311
320
  period: AnalyticsPeriod;
312
321
  totalSent: number;
package/dist/index.js CHANGED
@@ -36,6 +36,9 @@ var TrattoError = class extends Error {
36
36
  }
37
37
  };
38
38
 
39
+ // package.json
40
+ var version = "1.1.1";
41
+
39
42
  // src/resources/base.ts
40
43
  var BaseResource = class {
41
44
  constructor(apiKey, baseUrl) {
@@ -47,7 +50,7 @@ var BaseResource = class {
47
50
  const contentType = options?.contentType ?? (hasBody ? "application/json" : void 0);
48
51
  const headers = {
49
52
  Authorization: `Bearer ${this.apiKey}`,
50
- "User-Agent": "@tratto/email/0.1.0",
53
+ "User-Agent": `@tratto/email/${version}`,
51
54
  ...contentType ? { "Content-Type": contentType } : {},
52
55
  ...options?.headers
53
56
  };
@@ -227,8 +230,8 @@ var TemplatesResource = class extends BaseResource {
227
230
  listVersions(id) {
228
231
  return this.fetchData("GET", `/v1/templates/${id}/versions`);
229
232
  }
230
- getVersion(id, version) {
231
- return this.fetchData("GET", `/v1/templates/${id}/versions/${version}`);
233
+ getVersion(id, version2) {
234
+ return this.fetchData("GET", `/v1/templates/${id}/versions/${version2}`);
232
235
  }
233
236
  testSend(id, to, variables = {}) {
234
237
  return this.fetchData(
package/dist/index.mjs CHANGED
@@ -9,6 +9,9 @@ var TrattoError = class extends Error {
9
9
  }
10
10
  };
11
11
 
12
+ // package.json
13
+ var version = "1.1.1";
14
+
12
15
  // src/resources/base.ts
13
16
  var BaseResource = class {
14
17
  constructor(apiKey, baseUrl) {
@@ -20,7 +23,7 @@ var BaseResource = class {
20
23
  const contentType = options?.contentType ?? (hasBody ? "application/json" : void 0);
21
24
  const headers = {
22
25
  Authorization: `Bearer ${this.apiKey}`,
23
- "User-Agent": "@tratto/email/0.1.0",
26
+ "User-Agent": `@tratto/email/${version}`,
24
27
  ...contentType ? { "Content-Type": contentType } : {},
25
28
  ...options?.headers
26
29
  };
@@ -200,8 +203,8 @@ var TemplatesResource = class extends BaseResource {
200
203
  listVersions(id) {
201
204
  return this.fetchData("GET", `/v1/templates/${id}/versions`);
202
205
  }
203
- getVersion(id, version) {
204
- return this.fetchData("GET", `/v1/templates/${id}/versions/${version}`);
206
+ getVersion(id, version2) {
207
+ return this.fetchData("GET", `/v1/templates/${id}/versions/${version2}`);
205
208
  }
206
209
  testSend(id, to, variables = {}) {
207
210
  return this.fetchData(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tratto/email",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Tratto Node.js SDK \u2014 send transactional and marketing email",
5
5
  "author": "Tratto <hello@tratto.email>",
6
6
  "license": "MIT",