@cowliss/sdk 0.19.0 → 0.20.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/CHANGELOG.md +6 -0
- package/README.md +7 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +10 -0
- package/dist/types.d.ts +14 -0
- package/dist/version.autogenerated.d.ts +1 -1
- package/dist/version.autogenerated.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
What changed in each version of `@cowliss/sdk` after 0.16.0, newest first. Earlier versions are listed on [npm](https://www.npmjs.com/package/@cowliss/sdk?activeTab=versions).
|
|
6
6
|
|
|
7
|
+
## 0.20.0 (2026-10-02)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- cow.templates.preview renders a template with your own props
|
|
12
|
+
|
|
7
13
|
## 0.19.0 (2026-10-02)
|
|
8
14
|
|
|
9
15
|
### Features
|
package/README.md
CHANGED
|
@@ -60,6 +60,13 @@ delivery id. A message to a profile goes to its `email` trait, skips anyone
|
|
|
60
60
|
who turned that purpose off, and carries an unsubscribe link. Mail that
|
|
61
61
|
follows a rule or a wait belongs in a journey.
|
|
62
62
|
|
|
63
|
+
Render a pushed template with your own props, exactly as a send to an address
|
|
64
|
+
would, without sending it:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
const { subject, html } = await cow.templates.preview({ key: "receipt", props: { name: "Ada" } });
|
|
68
|
+
```
|
|
69
|
+
|
|
63
70
|
Send someone to their hosted email preferences page from your own "Manage
|
|
64
71
|
email preferences" button. The link works for an hour, so ask for it on the
|
|
65
72
|
click:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BatchBody, BatchResultDto, ErrorCode, EventDto, GetPreferencesInput, IdentifyInput, Preferences, PreferencesLink, PreferencesLinkInput, ProfileDto, SendEmailInput, SendEmailResult, SetPreferencesInput, TrackInput } from "./types.js";
|
|
1
|
+
import type { BatchBody, BatchResultDto, ErrorCode, EventDto, GetPreferencesInput, IdentifyInput, Preferences, PreferencesLink, PreferencesLinkInput, PreviewEmailInput, ProfileDto, SendEmailInput, SendEmailResult, SetPreferencesInput, TemplatePreview, TrackInput } from "./types.js";
|
|
2
2
|
export type * from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* The Cowliss TS client SDK. Small typed surface over the ingestion API:
|
|
@@ -112,6 +112,14 @@ export declare class Cow {
|
|
|
112
112
|
idempotencyKey?: string;
|
|
113
113
|
}) => Promise<SendEmailResult>;
|
|
114
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* Templates as a send renders them. `preview` renders a pushed template
|
|
117
|
+
* with your own props, exactly as `emails.send` to an address would, and
|
|
118
|
+
* sends nothing: for showing your operators the message before it goes.
|
|
119
|
+
*/
|
|
120
|
+
templates: {
|
|
121
|
+
preview: (input: WithDefaultSource<PreviewEmailInput>) => Promise<TemplatePreview>;
|
|
122
|
+
};
|
|
115
123
|
/**
|
|
116
124
|
* One person's email preferences, `to` naming them as in `emails.send`.
|
|
117
125
|
*
|
package/dist/index.js
CHANGED
|
@@ -132,6 +132,16 @@ export class Cow {
|
|
|
132
132
|
emails = {
|
|
133
133
|
send: ({ idempotencyKey, ...input }) => this.#watch(async () => this.#post("/v1/emails", { data: { ...input, sourceId: this.#sourceFor(input) } }, idempotencyKey ?? crypto.randomUUID())),
|
|
134
134
|
};
|
|
135
|
+
/**
|
|
136
|
+
* Templates as a send renders them. `preview` renders a pushed template
|
|
137
|
+
* with your own props, exactly as `emails.send` to an address would, and
|
|
138
|
+
* sends nothing: for showing your operators the message before it goes.
|
|
139
|
+
*/
|
|
140
|
+
templates = {
|
|
141
|
+
preview: (input) => this.#watch(async () => this.#post("/v1/email-previews", {
|
|
142
|
+
data: { ...input, sourceId: this.#sourceFor(input) },
|
|
143
|
+
})),
|
|
144
|
+
};
|
|
135
145
|
/**
|
|
136
146
|
* One person's email preferences, `to` naming them as in `emails.send`.
|
|
137
147
|
*
|
package/dist/types.d.ts
CHANGED
|
@@ -161,6 +161,20 @@ export type SendEmailResult = {
|
|
|
161
161
|
/** The delivery this send left behind: the row in Deliveries. */
|
|
162
162
|
deliveryId: string;
|
|
163
163
|
};
|
|
164
|
+
/** A template key and the props a send would pass it. */
|
|
165
|
+
export type PreviewEmailInput = {
|
|
166
|
+
sourceId: string;
|
|
167
|
+
key: string;
|
|
168
|
+
props?: Record<string, unknown>;
|
|
169
|
+
};
|
|
170
|
+
/** What a send of the template would carry. */
|
|
171
|
+
export type TemplatePreview = {
|
|
172
|
+
subject: string;
|
|
173
|
+
html: string;
|
|
174
|
+
text: string;
|
|
175
|
+
/** The version that rendered it: the latest one that finished compiling. */
|
|
176
|
+
versionId: string;
|
|
177
|
+
};
|
|
164
178
|
/** One profile, named the way a send to a profile names it. */
|
|
165
179
|
export type PreferencesLinkInput = {
|
|
166
180
|
sourceId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.20.0";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by scripts/version.ts from package.json. Do not edit.
|
|
2
|
-
export const SDK_VERSION = "0.
|
|
2
|
+
export const SDK_VERSION = "0.20.0";
|