@cowliss/sdk 0.19.0 → 0.21.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 +13 -0
- package/README.md +7 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +16 -0
- package/dist/types.d.ts +36 -1
- 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,19 @@
|
|
|
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.21.0 (2026-10-02)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- Plan constants, plan_limit, meta warnings and root-domain helper
|
|
12
|
+
- **Emails:** Test sends with `test: true` and reserved test addresses
|
|
13
|
+
|
|
14
|
+
## 0.20.0 (2026-10-02)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- cow.templates.preview renders a template with your own props
|
|
19
|
+
|
|
7
20
|
## 0.19.0 (2026-10-02)
|
|
8
21
|
|
|
9
22
|
### 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:
|
|
@@ -106,12 +106,26 @@ export declare class Cow {
|
|
|
106
106
|
*
|
|
107
107
|
* Addressed to `{ email }` that no profile in the app holds yet, the send
|
|
108
108
|
* creates that profile first, as `identify` would.
|
|
109
|
+
*
|
|
110
|
+
* `test: true` asks "would this exact send work?": every check runs and
|
|
111
|
+
* refuses as it would, and the answer carries `status` (`would_send` or
|
|
112
|
+
* the skip) and `rendered`, but nothing is sent or created. An address at
|
|
113
|
+
* `test.cowliss.com` is the other half: a real send whose outcome the
|
|
114
|
+
* address picks (`delivered@`, `bounced@`, `complained@`, `suppressed@`).
|
|
109
115
|
*/
|
|
110
116
|
emails: {
|
|
111
117
|
send: ({ idempotencyKey, ...input }: WithDefaultSource<SendEmailInput> & {
|
|
112
118
|
idempotencyKey?: string;
|
|
113
119
|
}) => Promise<SendEmailResult>;
|
|
114
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* Templates as a send renders them. `preview` renders a pushed template
|
|
123
|
+
* with your own props, exactly as `emails.send` to an address would, and
|
|
124
|
+
* sends nothing: for showing your operators the message before it goes.
|
|
125
|
+
*/
|
|
126
|
+
templates: {
|
|
127
|
+
preview: (input: WithDefaultSource<PreviewEmailInput>) => Promise<TemplatePreview>;
|
|
128
|
+
};
|
|
115
129
|
/**
|
|
116
130
|
* One person's email preferences, `to` naming them as in `emails.send`.
|
|
117
131
|
*
|
package/dist/index.js
CHANGED
|
@@ -128,10 +128,26 @@ export class Cow {
|
|
|
128
128
|
*
|
|
129
129
|
* Addressed to `{ email }` that no profile in the app holds yet, the send
|
|
130
130
|
* creates that profile first, as `identify` would.
|
|
131
|
+
*
|
|
132
|
+
* `test: true` asks "would this exact send work?": every check runs and
|
|
133
|
+
* refuses as it would, and the answer carries `status` (`would_send` or
|
|
134
|
+
* the skip) and `rendered`, but nothing is sent or created. An address at
|
|
135
|
+
* `test.cowliss.com` is the other half: a real send whose outcome the
|
|
136
|
+
* address picks (`delivered@`, `bounced@`, `complained@`, `suppressed@`).
|
|
131
137
|
*/
|
|
132
138
|
emails = {
|
|
133
139
|
send: ({ idempotencyKey, ...input }) => this.#watch(async () => this.#post("/v1/emails", { data: { ...input, sourceId: this.#sourceFor(input) } }, idempotencyKey ?? crypto.randomUUID())),
|
|
134
140
|
};
|
|
141
|
+
/**
|
|
142
|
+
* Templates as a send renders them. `preview` renders a pushed template
|
|
143
|
+
* with your own props, exactly as `emails.send` to an address would, and
|
|
144
|
+
* sends nothing: for showing your operators the message before it goes.
|
|
145
|
+
*/
|
|
146
|
+
templates = {
|
|
147
|
+
preview: (input) => this.#watch(async () => this.#post("/v1/email-previews", {
|
|
148
|
+
data: { ...input, sourceId: this.#sourceFor(input) },
|
|
149
|
+
})),
|
|
150
|
+
};
|
|
135
151
|
/**
|
|
136
152
|
* One person's email preferences, `to` naming them as in `emails.send`.
|
|
137
153
|
*
|
package/dist/types.d.ts
CHANGED
|
@@ -13,8 +13,13 @@
|
|
|
13
13
|
* typecheck here rather than at a customer's call site.
|
|
14
14
|
*/
|
|
15
15
|
/** The API's error-code enum, as the SDK surfaces it on `CowError.code`. */
|
|
16
|
-
export type ErrorCode = "malformed_request" | "invalid_key" | "forbidden" | "not_found" | "conflict" | "payload_too_large" | "validation_failed" | "trait_validation_failed" | "event_denied" | "trait_denied" | "over_quota" | "rate_limited" | "dependency_unavailable" | "internal" | "journey_fuel_exceeded" | "journey_timeout" | "journey_memory_exceeded" | "journey_error" | "journey_output_invalid" | "journey_nondeterministic" | "push_invalid" | "version_not_ready" | "version_outdated" | "source_inactive" | "artifact_too_large";
|
|
16
|
+
export type ErrorCode = "malformed_request" | "invalid_key" | "forbidden" | "not_found" | "conflict" | "payload_too_large" | "validation_failed" | "trait_validation_failed" | "event_denied" | "trait_denied" | "over_quota" | "rate_limited" | "dependency_unavailable" | "internal" | "journey_fuel_exceeded" | "journey_timeout" | "journey_memory_exceeded" | "journey_error" | "journey_output_invalid" | "journey_nondeterministic" | "push_invalid" | "version_not_ready" | "version_outdated" | "source_inactive" | "artifact_too_large" | "plan_limit";
|
|
17
17
|
export type IdentifierKind = "anonymousId" | "userId" | "clerkId" | "email";
|
|
18
|
+
/**
|
|
19
|
+
* What became of a send: handed over and how it settled, a check that
|
|
20
|
+
* skipped it, or (for a test send) the dry-run twin of either.
|
|
21
|
+
*/
|
|
22
|
+
export type DeliveryStatus = "sent" | "delivered" | "bounced" | "complained" | "failed" | "skipped_disabled" | "skipped_paused" | "skipped_suppressed" | "skipped_quota" | "skipped_unknown_purpose" | "skipped_frequency_cap" | "skipped_consent" | "skipped_domain" | "skipped_ssrf" | "would_send" | "would_skip_disabled" | "would_skip_paused" | "would_skip_suppressed" | "would_skip_quota" | "would_skip_unknown_purpose" | "would_skip_frequency_cap" | "would_skip_consent" | "would_skip_domain" | "would_skip_ssrf";
|
|
18
23
|
/**
|
|
19
24
|
* The named identifiers a call carries, at least one. Cowliss generates the
|
|
20
25
|
* profile id and resolves the map to it; a call carrying two identifiers is
|
|
@@ -156,10 +161,40 @@ export type SendEmailInput = {
|
|
|
156
161
|
key: string;
|
|
157
162
|
props?: Record<string, unknown>;
|
|
158
163
|
};
|
|
164
|
+
/**
|
|
165
|
+
* A dry run: every check the real send makes and the same refusals, one
|
|
166
|
+
* delivery row with the outcome, and nothing sent, no profile created, no
|
|
167
|
+
* idempotency key spent and no credit used.
|
|
168
|
+
*/
|
|
169
|
+
test?: boolean;
|
|
159
170
|
};
|
|
160
171
|
export type SendEmailResult = {
|
|
161
172
|
/** The delivery this send left behind: the row in Deliveries. */
|
|
162
173
|
deliveryId: string;
|
|
174
|
+
/** `sent`, or the skip a check recorded; on a test, `would_send` or `would_skip_*`. */
|
|
175
|
+
status: DeliveryStatus;
|
|
176
|
+
/** A test send only: `to` named an `email` nobody holds, which the send would create. */
|
|
177
|
+
wouldCreateProfile?: boolean;
|
|
178
|
+
/** A test send only: the message the real send would carry. */
|
|
179
|
+
rendered?: {
|
|
180
|
+
subject: string;
|
|
181
|
+
html: string;
|
|
182
|
+
text: string;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
/** A template key and the props a send would pass it. */
|
|
186
|
+
export type PreviewEmailInput = {
|
|
187
|
+
sourceId: string;
|
|
188
|
+
key: string;
|
|
189
|
+
props?: Record<string, unknown>;
|
|
190
|
+
};
|
|
191
|
+
/** What a send of the template would carry. */
|
|
192
|
+
export type TemplatePreview = {
|
|
193
|
+
subject: string;
|
|
194
|
+
html: string;
|
|
195
|
+
text: string;
|
|
196
|
+
/** The version that rendered it: the latest one that finished compiling. */
|
|
197
|
+
versionId: string;
|
|
163
198
|
};
|
|
164
199
|
/** One profile, named the way a send to a profile names it. */
|
|
165
200
|
export type PreferencesLinkInput = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.21.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.21.0";
|