@cowliss/sdk 0.6.0 → 0.8.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/README.md +14 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +14 -0
- package/dist/types.d.ts +27 -4
- package/dist/version.autogenerated.d.ts +1 -1
- package/dist/version.autogenerated.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,6 +36,20 @@ 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:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
await cow.emails.send({
|
|
44
|
+
to: "ada@example.com",
|
|
45
|
+
template: { key: "receipt", props: { orderId: "A-2291" } },
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
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.
|
|
52
|
+
|
|
39
53
|
Every call carries `identifiers`, a map from kind to value. Cowliss generates
|
|
40
54
|
the profile id and resolves the map to it, so a call that carries two
|
|
41
55
|
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, TrackInput } from "./types.js";
|
|
1
|
+
import type { BatchBody, BatchResultDto, ErrorCode, EventDto, IdentifyInput, 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:
|
|
@@ -89,6 +89,18 @@ export declare class Cow {
|
|
|
89
89
|
* server-side. Historical timestamps pass through for backfill scripts.
|
|
90
90
|
*/
|
|
91
91
|
track(input: WithDefaultSource<TrackInput>): Promise<EventDto>;
|
|
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.
|
|
96
|
+
*
|
|
97
|
+
* Synchronous like the rest of the client: the promise resolves once the
|
|
98
|
+
* message has been handed over, and `deliveryId` is the row that records
|
|
99
|
+
* what happened to it.
|
|
100
|
+
*/
|
|
101
|
+
emails: {
|
|
102
|
+
send: (input: WithDefaultSource<SendEmailInput>) => Promise<SendEmailResult>;
|
|
103
|
+
};
|
|
92
104
|
/**
|
|
93
105
|
* Batch import: one source's identify and track calls in one request.
|
|
94
106
|
* Track items must carry an explicit messageId: the API requires it and
|
package/dist/index.js
CHANGED
|
@@ -111,6 +111,20 @@ export class Cow {
|
|
|
111
111
|
return this.#post("/v1/track", { data: { ...input, sourceId: this.#sourceFor(input), messageId } }, messageId);
|
|
112
112
|
});
|
|
113
113
|
}
|
|
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.
|
|
118
|
+
*
|
|
119
|
+
* Synchronous like the rest of the client: the promise resolves once the
|
|
120
|
+
* message has been handed over, and `deliveryId` is the row that records
|
|
121
|
+
* what happened to it.
|
|
122
|
+
*/
|
|
123
|
+
emails = {
|
|
124
|
+
send: (input) => this.#watch(async () => this.#post("/v1/emails", {
|
|
125
|
+
data: { ...input, sourceId: this.#sourceFor(input) },
|
|
126
|
+
})),
|
|
127
|
+
};
|
|
114
128
|
/**
|
|
115
129
|
* Batch import: one source's identify and track calls in one request.
|
|
116
130
|
* Track items must carry an explicit messageId: the API requires it and
|
package/dist/types.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
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" | "
|
|
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" | "artifact_too_large";
|
|
17
17
|
export type IdentifierKind = "anonymousId" | "userId" | "clerkId" | "email";
|
|
18
18
|
/**
|
|
19
19
|
* The named identifiers a call carries, at least one. Cowliss generates the
|
|
@@ -57,10 +57,9 @@ export type EventDto = {
|
|
|
57
57
|
receivedAt: string;
|
|
58
58
|
messageId: string | null;
|
|
59
59
|
};
|
|
60
|
-
/** The
|
|
60
|
+
/** The consent purpose every org holds, as a caller patches it. */
|
|
61
61
|
export type ConsentPatch = {
|
|
62
|
-
|
|
63
|
-
dataProcessing?: boolean;
|
|
62
|
+
marketing?: boolean;
|
|
64
63
|
};
|
|
65
64
|
export type IdentifyInput = {
|
|
66
65
|
sourceId: string;
|
|
@@ -126,6 +125,30 @@ export type BatchItemResult = {
|
|
|
126
125
|
export type BatchResultDto = {
|
|
127
126
|
results: BatchItemResult[];
|
|
128
127
|
};
|
|
128
|
+
/** One transactional email: a pushed template, or a body written inline. */
|
|
129
|
+
export type SendEmailInput = {
|
|
130
|
+
sourceId: string;
|
|
131
|
+
to: string | string[];
|
|
132
|
+
cc?: string | string[];
|
|
133
|
+
bcc?: string | string[];
|
|
134
|
+
replyTo?: string | string[];
|
|
135
|
+
/** An address on a domain this organization verified. There is no other. */
|
|
136
|
+
from: string;
|
|
137
|
+
/** Required with an inline body; refused beside a template, which writes it. */
|
|
138
|
+
subject?: string;
|
|
139
|
+
html?: string;
|
|
140
|
+
text?: string;
|
|
141
|
+
headers?: Record<string, string>;
|
|
142
|
+
/** A template key this organization pushed, and the props it declares. */
|
|
143
|
+
template?: {
|
|
144
|
+
key: string;
|
|
145
|
+
props?: Record<string, unknown>;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
export type SendEmailResult = {
|
|
149
|
+
/** The delivery this send left behind: the row in Deliveries. */
|
|
150
|
+
deliveryId: string;
|
|
151
|
+
};
|
|
129
152
|
/**
|
|
130
153
|
* The two runtime constants in this file, and the reason they live beside
|
|
131
154
|
* the types rather than in `@cowliss/shared`: this module is the SDK's one
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.8.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.8.0";
|