@cowliss/sdk 0.15.1 → 0.17.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 ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ <!-- GENERATED by `pnpm release` from the commit log (apps/docs/scripts/changelog.ts). Do not edit. -->
4
+
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
+
7
+ ## 0.17.0 (2026-10-01)
8
+
9
+ ### Features
10
+
11
+ - **Emails:** cow.emails.send can address a profile instead of an address
12
+ - Identify takes consent by purpose path, such as "marketing.newsletter"
13
+ - A changelog in each package and on the docs site
package/README.md CHANGED
@@ -36,19 +36,29 @@ await cow.track({
36
36
  });
37
37
  ```
38
38
 
39
- Send a transactional message from your own code, with a template you pushed
40
- or a body written inline:
39
+ Send a message from your own code, with a template you pushed or a body
40
+ written inline. Address an email address for mail nobody can turn off, such
41
+ as a receipt, or a profile for mail its recipient can, such as a weekly
42
+ report:
41
43
 
42
44
  ```ts
43
45
  await cow.emails.send({
44
46
  to: "ada@example.com",
47
+ from: "Acme <hello@acme.com>",
45
48
  template: { key: "receipt", props: { orderId: "A-2291" } },
46
49
  });
50
+
51
+ await cow.emails.send({
52
+ to: { userId: "shop_1" },
53
+ from: "Acme <hello@acme.com>",
54
+ template: { key: "weekly-report", props: { visits: 120 } },
55
+ });
47
56
  ```
48
57
 
49
58
  It resolves once the message has been handed over, and answers with the
50
- delivery id. Mail that follows a rule or a wait belongs in a journey, which
51
- is where consent and frequency live.
59
+ delivery id. A message to a profile goes to its `email` trait, skips anyone
60
+ who turned that purpose off, and carries an unsubscribe link. Mail that
61
+ follows a rule or a wait belongs in a journey.
52
62
 
53
63
  Every call carries `identifiers`, a map from kind to value. Cowliss generates
54
64
  the profile id and resolves the map to it, so a call that carries two
package/dist/index.d.ts CHANGED
@@ -90,9 +90,11 @@ export declare class Cow {
90
90
  */
91
91
  track(input: WithDefaultSource<TrackInput>): Promise<EventDto>;
92
92
  /**
93
- * The transactional send a developer's own code makes: a receipt, a
94
- * password reset, an export that is ready. Mail that follows a rule or a
95
- * wait belongs in a journey, which is where consent and frequency live.
93
+ * The send a developer's own code makes: a receipt, a password reset, an
94
+ * export that is ready, a weekly report. Address an address for mail
95
+ * nobody can turn off, or a profile (`to: { userId }`) for mail its
96
+ * recipient can, which then asks their consent and carries an unsubscribe
97
+ * link. Mail that follows a rule or a wait belongs in a journey.
96
98
  *
97
99
  * Synchronous like the rest of the client: the promise resolves once the
98
100
  * message has been handed over, and `deliveryId` is the row that records
package/dist/index.js CHANGED
@@ -112,9 +112,11 @@ export class Cow {
112
112
  });
113
113
  }
114
114
  /**
115
- * The transactional send a developer's own code makes: a receipt, a
116
- * password reset, an export that is ready. Mail that follows a rule or a
117
- * wait belongs in a journey, which is where consent and frequency live.
115
+ * The send a developer's own code makes: a receipt, a password reset, an
116
+ * export that is ready, a weekly report. Address an address for mail
117
+ * nobody can turn off, or a profile (`to: { userId }`) for mail its
118
+ * recipient can, which then asks their consent and carries an unsubscribe
119
+ * link. Mail that follows a rule or a wait belongs in a journey.
118
120
  *
119
121
  * Synchronous like the rest of the client: the promise resolves once the
120
122
  * message has been handed over, and `deliveryId` is the row that records
package/dist/types.d.ts CHANGED
@@ -57,10 +57,13 @@ export type EventDto = {
57
57
  receivedAt: string;
58
58
  messageId: string | null;
59
59
  };
60
- /** The consent purpose every org holds, as a caller patches it. */
61
- export type ConsentPatch = {
62
- marketing?: boolean;
63
- };
60
+ /**
61
+ * A purpose path: one of the two roots, or a name your app's `cow.json`
62
+ * declares under one, such as `"marketing.newsletter"`.
63
+ */
64
+ export type PurposePath = "marketing" | "transactional" | `marketing.${string}` | `transactional.${string}`;
65
+ /** What a person agreed to, per purpose path, as a caller patches it. */
66
+ export type ConsentPatch = Partial<Record<PurposePath, boolean>>;
64
67
  export type IdentifyInput = {
65
68
  sourceId: string;
66
69
  identifiers: Identifiers;
@@ -69,8 +72,9 @@ export type IdentifyInput = {
69
72
  * What this person agreed to, as a merge patch: a purpose the call omits
70
73
  * keeps the value it had, so a later identify is never an accidental
71
74
  * revocation. Omitting it entirely leaves consent untouched, which on a
72
- * first write means marketing denied and data processing granted. At least
73
- * one purpose when present.
75
+ * first write means every marketing purpose off and every transactional
76
+ * one on. A name your app does not declare is refused. At least one
77
+ * purpose when present.
74
78
  */
75
79
  consent?: ConsentPatch;
76
80
  /** ISO 8601 UTC. A past timestamp backdates a first-write profile. */
@@ -125,10 +129,18 @@ export type BatchItemResult = {
125
129
  export type BatchResultDto = {
126
130
  results: BatchItemResult[];
127
131
  };
128
- /** One transactional email: a pushed template, or a body written inline. */
132
+ /** One email: a pushed template, or a body written inline. */
129
133
  export type SendEmailInput = {
130
134
  sourceId: string;
131
- to: string | string[];
135
+ /**
136
+ * An address or a list of them, or exactly one identifier naming a profile
137
+ * in the source's app, such as `{ userId: "shop_1" }`. A profile is mailed at
138
+ * its `email` trait and is the only recipient a template with a purpose
139
+ * they can turn off may go to; a bare address takes bare `transactional`
140
+ * templates and inline bodies alone. `cc` and `bcc` are refused beside a
141
+ * profile.
142
+ */
143
+ to: string | string[] | Identifiers;
132
144
  cc?: string | string[];
133
145
  bcc?: string | string[];
134
146
  replyTo?: string | string[];
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.15.1";
1
+ export declare const SDK_VERSION = "0.17.0";
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/version.ts from package.json. Do not edit.
2
- export const SDK_VERSION = "0.15.1";
2
+ export const SDK_VERSION = "0.17.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowliss/sdk",
3
- "version": "0.15.1",
3
+ "version": "0.17.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -30,7 +30,8 @@
30
30
  "files": [
31
31
  "dist",
32
32
  "LICENSE",
33
- "README.md"
33
+ "README.md",
34
+ "CHANGELOG.md"
34
35
  ],
35
36
  "scripts": {
36
37
  "build": "tsx scripts/version.ts && tsc -b tsconfig.json --force",