@cowliss/cli 0.1.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.
Files changed (31) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +105 -0
  3. package/dist/guest/constants-OZrYz4I2.d.ts +42 -0
  4. package/dist/guest/driver-BOe7jBFw.js +5647 -0
  5. package/dist/guest/driver.d.ts +21 -0
  6. package/dist/guest/driver.js +3 -0
  7. package/dist/guest/emails.d.ts +24 -0
  8. package/dist/guest/emails.js +0 -0
  9. package/dist/guest/index-heC1gFE_.d.ts +296 -0
  10. package/dist/guest/journeys-CxuS-mHn.js +571 -0
  11. package/dist/guest/journeys.d.ts +127 -0
  12. package/dist/guest/journeys.js +3 -0
  13. package/dist/guest/prelude.d.ts +1 -0
  14. package/dist/guest/prelude.js +91 -0
  15. package/dist/guest/wasi.d.ts +6 -0
  16. package/dist/guest/wasi.js +43 -0
  17. package/dist/index.js +11235 -0
  18. package/examples/abandoned-checkout/emails/abandoned-checkout.tsx +104 -0
  19. package/examples/abandoned-checkout/journeys/abandoned-checkout.ts +39 -0
  20. package/examples/abandoned-checkout/scenarios/abandoned-checkout.recovered.json +10 -0
  21. package/examples/abandoned-checkout/scenarios/abandoned-checkout.timeout.json +16 -0
  22. package/examples/activity-decay/journeys/activity-decay.ts +36 -0
  23. package/examples/activity-decay/scenarios/activity-decay.json +8 -0
  24. package/examples/cross-app-pitch/emails/cross-app-pitch.tsx +77 -0
  25. package/examples/cross-app-pitch/journeys/cross-app-pitch.ts +30 -0
  26. package/examples/cross-app-pitch/scenarios/cross-app-pitch.json +16 -0
  27. package/examples/winback/emails/winback.tsx +78 -0
  28. package/examples/winback/journeys/winback.ts +33 -0
  29. package/examples/winback/scenarios/winback.json +18 -0
  30. package/package.json +82 -0
  31. package/project/tsconfig.json +18 -0
@@ -0,0 +1,21 @@
1
+ import { a as ManifestOutput, i as JourneyStepOutput, o as TemplateRenderOutput } from "./index-heC1gFE_.js";
2
+ //#region src/guest/driver.d.ts
3
+ /**
4
+ * The in-process driver: JSON in, JSON out (spec: Guest protocol). One
5
+ * bundle is one module is one journey or one template, and this turns the
6
+ * three inputs into the three outputs. `wasi.ts` wraps it for the sandbox;
7
+ * the simulator and the tests call `runGuest` directly.
8
+ *
9
+ * Every output is validated with the shared schema before it leaves, so a
10
+ * guest bug surfaces here rather than as a host-side parse failure.
11
+ */
12
+ /** A compiled bundle's module namespace, as `import * as module` sees it. */
13
+ type GuestModule = Record<string, unknown>;
14
+ type GuestOutput = JourneyStepOutput | TemplateRenderOutput | ManifestOutput;
15
+ /**
16
+ * Runs one guest invocation. `module` is the tenant module namespace the
17
+ * bundle's entry imported; `input` is the raw JSON the host handed over.
18
+ */
19
+ declare function runGuest(module: GuestModule, input: unknown): Promise<GuestOutput>;
20
+ //#endregion
21
+ export { GuestModule, GuestOutput, runGuest };
@@ -0,0 +1,3 @@
1
+ import { t as runGuest } from "./driver-BOe7jBFw.js";
2
+
3
+ export { runGuest };
@@ -0,0 +1,24 @@
1
+ import { r as SendClass } from "./constants-OZrYz4I2.js";
2
+ import { z } from "zod";
3
+ import { ReactElement } from "react";
4
+ //#region src/guest/emails.d.ts
5
+ /** A template's subject line, computed from the props it declares. */
6
+ type Subject<Schema extends z.ZodType> = (props: z.infer<Schema>) => string;
7
+ /**
8
+ * The shape `emails/<key>.tsx` exports. `cow build` reads `props` (turned
9
+ * into JSON Schema in the manifest and into `.cow/types.d.ts`), `subject`,
10
+ * and the optional metadata below it; the sandbox renders `default`.
11
+ */
12
+ type Template<Schema extends z.ZodType = z.ZodType> = {
13
+ default: (props: z.infer<Schema>) => ReactElement;
14
+ props: Schema;
15
+ subject: Subject<Schema> | string;
16
+ /** Defaults to "marketing". */
17
+ sendClass?: SendClass;
18
+ /** The author's labels; the dashboard's only grouping. Defaults to none. */
19
+ tags?: string[];
20
+ /** True asks the host to mint a signed `verifyUrl` prop at send time. */
21
+ verifyLink?: boolean;
22
+ };
23
+ //#endregion
24
+ export { type SendClass, Subject, Template };
File without changes
@@ -0,0 +1,296 @@
1
+ import { z } from "zod";
2
+ //#region ../../packages/shared/src/journeys-v2/guest.d.ts
3
+ /**
4
+ * The guest protocol (spec: Guest protocol): the JSON a compiled module
5
+ * reads on stdin and writes on stdout. The sandbox worker parses every byte
6
+ * a guest returns with these schemas before anything acts on it; the guest
7
+ * SDK and the Node simulator produce and consume the same shapes.
8
+ */
9
+ /** A duration as journey code writes it: an ms-style string ("2d") or milliseconds. */
10
+ declare const durationSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
11
+ type Duration = z.infer<typeof durationSchema>;
12
+ /** The event a journey runs for, or waits on: name, properties, and when. */
13
+ declare const guestEventSchema: z.ZodObject<{
14
+ name: z.ZodString;
15
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
16
+ timestamp: z.ZodNumber;
17
+ }, z.core.$strip>;
18
+ type GuestEvent = z.infer<typeof guestEventSchema>;
19
+ declare const journeyStepOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
20
+ status: z.ZodLiteral<"suspend">;
21
+ call: z.ZodDiscriminatedUnion<[z.ZodObject<{
22
+ name: z.ZodLiteral<"sleep">;
23
+ args: z.ZodObject<{
24
+ duration: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
25
+ }, z.core.$strict>;
26
+ }, z.core.$strip>, z.ZodObject<{
27
+ name: z.ZodLiteral<"waitForEvent">;
28
+ args: z.ZodObject<{
29
+ event: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
30
+ timeout: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
31
+ }, z.core.$strict>;
32
+ }, z.core.$strip>, z.ZodObject<{
33
+ name: z.ZodLiteral<"email.send">;
34
+ args: z.ZodObject<{
35
+ template: z.ZodString;
36
+ props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
37
+ }, z.core.$strict>;
38
+ }, z.core.$strip>, z.ZodObject<{
39
+ name: z.ZodLiteral<"webhook.send">;
40
+ args: z.ZodObject<{
41
+ destination: z.ZodString;
42
+ payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
43
+ }, z.core.$strict>;
44
+ }, z.core.$strip>, z.ZodObject<{
45
+ name: z.ZodLiteral<"traits.set">;
46
+ args: z.ZodObject<{
47
+ key: z.ZodString;
48
+ value: z.ZodUnknown;
49
+ }, z.core.$strict>;
50
+ }, z.core.$strip>, z.ZodObject<{
51
+ name: z.ZodLiteral<"traits.unset">;
52
+ args: z.ZodObject<{
53
+ key: z.ZodString;
54
+ }, z.core.$strict>;
55
+ }, z.core.$strip>, z.ZodObject<{
56
+ name: z.ZodLiteral<"profile.get">;
57
+ args: z.ZodObject<{}, z.core.$strict>;
58
+ }, z.core.$strip>, z.ZodObject<{
59
+ name: z.ZodLiteral<"profiles.get">;
60
+ args: z.ZodObject<{
61
+ id: z.ZodString;
62
+ }, z.core.$strict>;
63
+ }, z.core.$strip>, z.ZodObject<{
64
+ name: z.ZodLiteral<"events.track">;
65
+ args: z.ZodObject<{
66
+ event: z.ZodString;
67
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
68
+ }, z.core.$strict>;
69
+ }, z.core.$strip>, z.ZodObject<{
70
+ name: z.ZodLiteral<"restart">;
71
+ args: z.ZodObject<{
72
+ event: z.ZodOptional<z.ZodObject<{
73
+ name: z.ZodString;
74
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
75
+ timestamp: z.ZodNumber;
76
+ }, z.core.$strip>>;
77
+ }, z.core.$strict>;
78
+ }, z.core.$strip>], "name">;
79
+ logs: z.ZodDefault<z.ZodArray<z.ZodObject<{
80
+ level: z.ZodEnum<{
81
+ debug: "debug";
82
+ error: "error";
83
+ info: "info";
84
+ warn: "warn";
85
+ }>;
86
+ message: z.ZodString;
87
+ }, z.core.$strip>>>;
88
+ }, z.core.$strip>, z.ZodObject<{
89
+ status: z.ZodLiteral<"done">;
90
+ logs: z.ZodDefault<z.ZodArray<z.ZodObject<{
91
+ level: z.ZodEnum<{
92
+ debug: "debug";
93
+ error: "error";
94
+ info: "info";
95
+ warn: "warn";
96
+ }>;
97
+ message: z.ZodString;
98
+ }, z.core.$strip>>>;
99
+ }, z.core.$strip>, z.ZodObject<{
100
+ status: z.ZodLiteral<"error">;
101
+ error: z.ZodObject<{
102
+ code: z.ZodEnum<{
103
+ journey_error: "journey_error";
104
+ journey_nondeterministic: "journey_nondeterministic";
105
+ }>;
106
+ message: z.ZodString;
107
+ stack: z.ZodOptional<z.ZodString>;
108
+ }, z.core.$strip>;
109
+ nondeterministic: z.ZodOptional<z.ZodObject<{
110
+ expected: z.ZodDiscriminatedUnion<[z.ZodObject<{
111
+ name: z.ZodLiteral<"sleep">;
112
+ args: z.ZodObject<{
113
+ duration: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
114
+ }, z.core.$strict>;
115
+ }, z.core.$strip>, z.ZodObject<{
116
+ name: z.ZodLiteral<"waitForEvent">;
117
+ args: z.ZodObject<{
118
+ event: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
119
+ timeout: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
120
+ }, z.core.$strict>;
121
+ }, z.core.$strip>, z.ZodObject<{
122
+ name: z.ZodLiteral<"email.send">;
123
+ args: z.ZodObject<{
124
+ template: z.ZodString;
125
+ props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
126
+ }, z.core.$strict>;
127
+ }, z.core.$strip>, z.ZodObject<{
128
+ name: z.ZodLiteral<"webhook.send">;
129
+ args: z.ZodObject<{
130
+ destination: z.ZodString;
131
+ payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
132
+ }, z.core.$strict>;
133
+ }, z.core.$strip>, z.ZodObject<{
134
+ name: z.ZodLiteral<"traits.set">;
135
+ args: z.ZodObject<{
136
+ key: z.ZodString;
137
+ value: z.ZodUnknown;
138
+ }, z.core.$strict>;
139
+ }, z.core.$strip>, z.ZodObject<{
140
+ name: z.ZodLiteral<"traits.unset">;
141
+ args: z.ZodObject<{
142
+ key: z.ZodString;
143
+ }, z.core.$strict>;
144
+ }, z.core.$strip>, z.ZodObject<{
145
+ name: z.ZodLiteral<"profile.get">;
146
+ args: z.ZodObject<{}, z.core.$strict>;
147
+ }, z.core.$strip>, z.ZodObject<{
148
+ name: z.ZodLiteral<"profiles.get">;
149
+ args: z.ZodObject<{
150
+ id: z.ZodString;
151
+ }, z.core.$strict>;
152
+ }, z.core.$strip>, z.ZodObject<{
153
+ name: z.ZodLiteral<"events.track">;
154
+ args: z.ZodObject<{
155
+ event: z.ZodString;
156
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
157
+ }, z.core.$strict>;
158
+ }, z.core.$strip>, z.ZodObject<{
159
+ name: z.ZodLiteral<"restart">;
160
+ args: z.ZodObject<{
161
+ event: z.ZodOptional<z.ZodObject<{
162
+ name: z.ZodString;
163
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
164
+ timestamp: z.ZodNumber;
165
+ }, z.core.$strip>>;
166
+ }, z.core.$strict>;
167
+ }, z.core.$strip>], "name">;
168
+ actual: z.ZodDiscriminatedUnion<[z.ZodObject<{
169
+ name: z.ZodLiteral<"sleep">;
170
+ args: z.ZodObject<{
171
+ duration: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
172
+ }, z.core.$strict>;
173
+ }, z.core.$strip>, z.ZodObject<{
174
+ name: z.ZodLiteral<"waitForEvent">;
175
+ args: z.ZodObject<{
176
+ event: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
177
+ timeout: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
178
+ }, z.core.$strict>;
179
+ }, z.core.$strip>, z.ZodObject<{
180
+ name: z.ZodLiteral<"email.send">;
181
+ args: z.ZodObject<{
182
+ template: z.ZodString;
183
+ props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
184
+ }, z.core.$strict>;
185
+ }, z.core.$strip>, z.ZodObject<{
186
+ name: z.ZodLiteral<"webhook.send">;
187
+ args: z.ZodObject<{
188
+ destination: z.ZodString;
189
+ payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
190
+ }, z.core.$strict>;
191
+ }, z.core.$strip>, z.ZodObject<{
192
+ name: z.ZodLiteral<"traits.set">;
193
+ args: z.ZodObject<{
194
+ key: z.ZodString;
195
+ value: z.ZodUnknown;
196
+ }, z.core.$strict>;
197
+ }, z.core.$strip>, z.ZodObject<{
198
+ name: z.ZodLiteral<"traits.unset">;
199
+ args: z.ZodObject<{
200
+ key: z.ZodString;
201
+ }, z.core.$strict>;
202
+ }, z.core.$strip>, z.ZodObject<{
203
+ name: z.ZodLiteral<"profile.get">;
204
+ args: z.ZodObject<{}, z.core.$strict>;
205
+ }, z.core.$strip>, z.ZodObject<{
206
+ name: z.ZodLiteral<"profiles.get">;
207
+ args: z.ZodObject<{
208
+ id: z.ZodString;
209
+ }, z.core.$strict>;
210
+ }, z.core.$strip>, z.ZodObject<{
211
+ name: z.ZodLiteral<"events.track">;
212
+ args: z.ZodObject<{
213
+ event: z.ZodString;
214
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
215
+ }, z.core.$strict>;
216
+ }, z.core.$strip>, z.ZodObject<{
217
+ name: z.ZodLiteral<"restart">;
218
+ args: z.ZodObject<{
219
+ event: z.ZodOptional<z.ZodObject<{
220
+ name: z.ZodString;
221
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
222
+ timestamp: z.ZodNumber;
223
+ }, z.core.$strip>>;
224
+ }, z.core.$strict>;
225
+ }, z.core.$strip>], "name">;
226
+ }, z.core.$strip>>;
227
+ logs: z.ZodDefault<z.ZodArray<z.ZodObject<{
228
+ level: z.ZodEnum<{
229
+ debug: "debug";
230
+ error: "error";
231
+ info: "info";
232
+ warn: "warn";
233
+ }>;
234
+ message: z.ZodString;
235
+ }, z.core.$strip>>>;
236
+ }, z.core.$strip>], "status">;
237
+ type JourneyStepOutput = z.infer<typeof journeyStepOutputSchema>;
238
+ declare const templateRenderOutputSchema: z.ZodObject<{
239
+ subject: z.ZodString;
240
+ html: z.ZodString;
241
+ text: z.ZodString;
242
+ }, z.core.$strip>;
243
+ type TemplateRenderOutput = z.infer<typeof templateRenderOutputSchema>;
244
+ /**
245
+ * A module's self-report. The host knows which key it ran, so the report
246
+ * carries the config only.
247
+ */
248
+ declare const manifestOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
249
+ tags: z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodString>>, z.ZodTransform<string[], string[]>>;
250
+ trigger: z.ZodUnion<readonly [z.ZodObject<{
251
+ event: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
252
+ appId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
253
+ }, z.core.$strict>, z.ZodObject<{
254
+ segment: z.ZodString;
255
+ }, z.core.$strict>]>;
256
+ purpose: z.ZodEnum<{
257
+ dataProcessing: "dataProcessing";
258
+ emailMarketing: "emailMarketing";
259
+ }>;
260
+ environments: z.ZodArray<z.ZodEnum<{
261
+ development: "development";
262
+ production: "production";
263
+ }>>;
264
+ kind: z.ZodLiteral<"journey">;
265
+ }, z.core.$strip>, z.ZodObject<{
266
+ tags: z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodString>>, z.ZodTransform<string[], string[]>>;
267
+ sendClass: z.ZodEnum<{
268
+ marketing: "marketing";
269
+ transactional: "transactional";
270
+ }>;
271
+ verifyLink: z.ZodBoolean;
272
+ propsSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
273
+ kind: z.ZodLiteral<"template">;
274
+ }, z.core.$strip>], "kind">;
275
+ type ManifestOutput = z.infer<typeof manifestOutputSchema>;
276
+ //#endregion
277
+ //#region ../../packages/shared/src/journeys-v2/manifest.d.ts
278
+ /**
279
+ * What starts a journey: an event (optionally narrowed to an app id or a
280
+ * list of them) or a segment entry. The registry DTO in `../journeys`
281
+ * reuses it.
282
+ *
283
+ * Both members are strict, so a journey holding the retired `source` key
284
+ * fails to compile a release instead of silently triggering on every app.
285
+ * There is deliberately no pipe filter: a trigger narrows by the app the
286
+ * write is attributed to, the same token a segment definition names.
287
+ */
288
+ declare const triggerSchema: z.ZodUnion<readonly [z.ZodObject<{
289
+ event: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
290
+ appId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
291
+ }, z.core.$strict>, z.ZodObject<{
292
+ segment: z.ZodString;
293
+ }, z.core.$strict>]>;
294
+ type Trigger = z.infer<typeof triggerSchema>;
295
+ //#endregion
296
+ export { ManifestOutput as a, JourneyStepOutput as i, Duration as n, TemplateRenderOutput as o, GuestEvent as r, Trigger as t };