@cowliss/sdk 0.17.0 → 0.18.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 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.18.0 (2026-10-01)
8
+
9
+ ### Features
10
+
11
+ - cow.preferences.link asks for one profile's email preferences page
12
+
7
13
  ## 0.17.0 (2026-10-01)
8
14
 
9
15
  ### Features
package/README.md CHANGED
@@ -60,6 +60,14 @@ 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
+ Send someone to their hosted email preferences page from your own "Manage
64
+ email preferences" button. The link works for an hour, so ask for it on the
65
+ click:
66
+
67
+ ```ts
68
+ const { url, expiresAt } = await cow.preferences.link({ to: { userId: "shop_1" } });
69
+ ```
70
+
63
71
  Every call carries `identifiers`, a map from kind to value. Cowliss generates
64
72
  the profile id and resolves the map to it, so a call that carries two
65
73
  identifiers is what links two profiles. There is no alias call.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BatchBody, BatchResultDto, ErrorCode, EventDto, IdentifyInput, ProfileDto, SendEmailInput, SendEmailResult, TrackInput } from "./types.js";
1
+ import type { BatchBody, BatchResultDto, ErrorCode, EventDto, IdentifyInput, PreferencesLink, PreferencesLinkInput, ProfileDto, SendEmailInput, SendEmailResult, 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:
@@ -103,6 +103,15 @@ export declare class Cow {
103
103
  emails: {
104
104
  send: (input: WithDefaultSource<SendEmailInput>) => Promise<SendEmailResult>;
105
105
  };
106
+ /**
107
+ * A link to one person's hosted email preferences page, for your app's own
108
+ * "Manage email preferences" button: `to` is one identifier naming them,
109
+ * as in `emails.send`. The page lists every purpose their app declares as
110
+ * a switch, and the link works for an hour, so ask for it when they click.
111
+ */
112
+ preferences: {
113
+ link: (input: WithDefaultSource<PreferencesLinkInput>) => Promise<PreferencesLink>;
114
+ };
106
115
  /**
107
116
  * Batch import: one source's identify and track calls in one request.
108
117
  * Track items must carry an explicit messageId: the API requires it and
package/dist/index.js CHANGED
@@ -127,6 +127,17 @@ export class Cow {
127
127
  data: { ...input, sourceId: this.#sourceFor(input) },
128
128
  })),
129
129
  };
130
+ /**
131
+ * A link to one person's hosted email preferences page, for your app's own
132
+ * "Manage email preferences" button: `to` is one identifier naming them,
133
+ * as in `emails.send`. The page lists every purpose their app declares as
134
+ * a switch, and the link works for an hour, so ask for it when they click.
135
+ */
136
+ preferences = {
137
+ link: (input) => this.#watch(async () => this.#post("/v1/preferences-links", {
138
+ data: { ...input, sourceId: this.#sourceFor(input) },
139
+ })),
140
+ };
130
141
  /**
131
142
  * Batch import: one source's identify and track calls in one request.
132
143
  * Track items must carry an explicit messageId: the API requires it and
package/dist/types.d.ts CHANGED
@@ -161,6 +161,18 @@ export type SendEmailResult = {
161
161
  /** The delivery this send left behind: the row in Deliveries. */
162
162
  deliveryId: string;
163
163
  };
164
+ /** One profile, named the way a send to a profile names it. */
165
+ export type PreferencesLinkInput = {
166
+ sourceId: string;
167
+ /** Exactly one identifier naming a profile in the source's app. */
168
+ to: Identifiers;
169
+ };
170
+ export type PreferencesLink = {
171
+ /** The hosted preferences page for that profile. */
172
+ url: string;
173
+ /** ISO 8601: when the link stops working, an hour after it was minted. */
174
+ expiresAt: string;
175
+ };
164
176
  /**
165
177
  * The two runtime constants in this file, and the reason they live beside
166
178
  * the types rather than in `@cowliss/shared`: this module is the SDK's one
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.17.0";
1
+ export declare const SDK_VERSION = "0.18.0";
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/version.ts from package.json. Do not edit.
2
- export const SDK_VERSION = "0.17.0";
2
+ export const SDK_VERSION = "0.18.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowliss/sdk",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {