@cowliss/cli 0.5.0 → 0.7.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 +4 -5
- package/dist/guest/{driver-14FnzM-h.js → driver-C1bsCjZT.js} +7 -3
- package/dist/guest/driver.d.ts +1 -1
- package/dist/guest/driver.js +1 -1
- package/dist/guest/emails.d.ts +6 -0
- package/dist/guest/{index-BDj02EsQ.d.ts → index-3PMqJKmc.d.ts} +111 -16
- package/dist/guest/{journeys-C8j8Sqvl.js → journeys-Dpsp225V.js} +286 -87
- package/dist/guest/journeys.d.ts +52 -23
- package/dist/guest/journeys.js +1 -1
- package/dist/guest/wasi.js +1 -1
- package/dist/index.js +1504 -987
- package/examples/abandoned-checkout/journeys/abandoned-checkout.ts +9 -2
- package/examples/abandoned-checkout/scenarios/abandoned-checkout.timeout.json +1 -2
- package/examples/activity-decay/journeys/activity-decay.ts +13 -3
- package/examples/cross-app-pitch/journeys/cross-app-pitch.ts +10 -5
- package/examples/cross-app-pitch/scenarios/cross-app-pitch.json +1 -1
- package/examples/winback/journeys/winback.ts +10 -3
- package/examples/winback/scenarios/winback.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,8 +44,7 @@ import { defineJourney } from "@cowliss/cli/journeys";
|
|
|
44
44
|
|
|
45
45
|
export default defineJourney({
|
|
46
46
|
trigger: { event: "checkout_started" },
|
|
47
|
-
purpose: "
|
|
48
|
-
senderIdentity: "cowliss-default",
|
|
47
|
+
purpose: "marketing",
|
|
49
48
|
run: async (event, api) => {
|
|
50
49
|
const purchased = await api.waitForEvent("purchase_completed", {
|
|
51
50
|
timeout: "24h",
|
|
@@ -73,11 +72,11 @@ cow build
|
|
|
73
72
|
# upload the project; the server compiles it
|
|
74
73
|
cow push
|
|
75
74
|
|
|
76
|
-
# what the server holds, and what is
|
|
75
|
+
# what the server holds, and what is running
|
|
77
76
|
cow status
|
|
78
77
|
|
|
79
|
-
# turn it on
|
|
80
|
-
cow enable abandoned-checkout
|
|
78
|
+
# turn it on
|
|
79
|
+
cow enable abandoned-checkout
|
|
81
80
|
```
|
|
82
81
|
|
|
83
82
|
A push creates a new version of every journey and template whose code
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as manifestOutputSchema, i as journeyStepOutputSchema, o as templateRenderOutputSchema, r as guestInputSchema, t as CapabilityError } from "./journeys-
|
|
1
|
+
import { a as manifestOutputSchema, i as journeyStepOutputSchema, o as templateRenderOutputSchema, r as guestInputSchema, t as CapabilityError } from "./journeys-Dpsp225V.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { createElement } from "react";
|
|
4
4
|
import { renderToStaticMarkup } from "react-dom/server.browser";
|
|
@@ -124,7 +124,8 @@ function createApi(input, journey) {
|
|
|
124
124
|
args: {
|
|
125
125
|
template: args.template,
|
|
126
126
|
props: args.props,
|
|
127
|
-
|
|
127
|
+
from: args.from ?? journey.from,
|
|
128
|
+
replyTo: args.replyTo
|
|
128
129
|
}
|
|
129
130
|
}),
|
|
130
131
|
webhook: (args) => call({
|
|
@@ -5572,7 +5573,9 @@ function readManifest(module) {
|
|
|
5572
5573
|
kind: "journey",
|
|
5573
5574
|
trigger: journey.trigger,
|
|
5574
5575
|
purpose: journey.purpose,
|
|
5575
|
-
|
|
5576
|
+
enrollment: journey.enrollment,
|
|
5577
|
+
description: journey.description,
|
|
5578
|
+
from: journey.from,
|
|
5576
5579
|
tags: journey.tags
|
|
5577
5580
|
});
|
|
5578
5581
|
}
|
|
@@ -5582,6 +5585,7 @@ function readManifest(module) {
|
|
|
5582
5585
|
tags: template.tags,
|
|
5583
5586
|
sendClass: template.sendClass ?? "marketing",
|
|
5584
5587
|
verifyLink: template.verifyLink ?? false,
|
|
5588
|
+
unsubscribeLink: template.unsubscribeLink ?? false,
|
|
5585
5589
|
propsSchema: z.toJSONSchema(template.props, { target: "draft-2020-12" })
|
|
5586
5590
|
});
|
|
5587
5591
|
}
|
package/dist/guest/driver.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as JourneyStepOutput, o as ManifestOutput, s as TemplateRenderOutput } from "./index-3PMqJKmc.js";
|
|
2
2
|
//#region src/guest/driver.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The in-process driver: JSON in, JSON out (spec: Guest protocol). One
|
package/dist/guest/driver.js
CHANGED
package/dist/guest/emails.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ type Template<Schema extends z.ZodType = z.ZodType> = {
|
|
|
36
36
|
tags?: string[];
|
|
37
37
|
/** True asks the host to mint a signed `verifyUrl` prop at send time. */
|
|
38
38
|
verifyLink?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* True asks the host to mint a signed `unsubscribeUrl` prop at send time,
|
|
41
|
+
* for the author's own footer link. Leave it off and a marketing template
|
|
42
|
+
* still gets a platform footer with the link appended at send time.
|
|
43
|
+
*/
|
|
44
|
+
unsubscribeLink?: boolean;
|
|
39
45
|
};
|
|
40
46
|
//#endregion
|
|
41
47
|
export { type SendClass, Subject, Template };
|
|
@@ -6,9 +6,6 @@ import { z } from "zod";
|
|
|
6
6
|
* a guest returns with these schemas before anything acts on it; the guest
|
|
7
7
|
* SDK and the Node simulator produce and consume the same shapes.
|
|
8
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
9
|
/** The event a journey runs for, or waits on: name, properties, and when. */
|
|
13
10
|
declare const guestEventSchema: z.ZodObject<{
|
|
14
11
|
name: z.ZodString;
|
|
@@ -34,7 +31,8 @@ declare const journeyStepOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
34
31
|
args: z.ZodObject<{
|
|
35
32
|
template: z.ZodString;
|
|
36
33
|
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
37
|
-
|
|
34
|
+
from: z.ZodOptional<z.ZodString>;
|
|
35
|
+
replyTo: z.ZodOptional<z.ZodEmail>;
|
|
38
36
|
}, z.core.$strict>;
|
|
39
37
|
}, z.core.$strip>, z.ZodObject<{
|
|
40
38
|
name: z.ZodLiteral<"send.webhook">;
|
|
@@ -124,7 +122,8 @@ declare const journeyStepOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
124
122
|
args: z.ZodObject<{
|
|
125
123
|
template: z.ZodString;
|
|
126
124
|
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
127
|
-
|
|
125
|
+
from: z.ZodOptional<z.ZodString>;
|
|
126
|
+
replyTo: z.ZodOptional<z.ZodEmail>;
|
|
128
127
|
}, z.core.$strict>;
|
|
129
128
|
}, z.core.$strip>, z.ZodObject<{
|
|
130
129
|
name: z.ZodLiteral<"send.webhook">;
|
|
@@ -183,7 +182,8 @@ declare const journeyStepOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
183
182
|
args: z.ZodObject<{
|
|
184
183
|
template: z.ZodString;
|
|
185
184
|
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
186
|
-
|
|
185
|
+
from: z.ZodOptional<z.ZodString>;
|
|
186
|
+
replyTo: z.ZodOptional<z.ZodEmail>;
|
|
187
187
|
}, z.core.$strict>;
|
|
188
188
|
}, z.core.$strip>, z.ZodObject<{
|
|
189
189
|
name: z.ZodLiteral<"send.webhook">;
|
|
@@ -254,10 +254,45 @@ declare const manifestOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
254
254
|
event: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
255
255
|
appId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
256
256
|
}, z.core.$strict>, z.ZodObject<{
|
|
257
|
-
segment: z.
|
|
257
|
+
segment: z.ZodObject<{
|
|
258
|
+
match: z.ZodDefault<z.ZodEnum<{
|
|
259
|
+
all: "all";
|
|
260
|
+
any: "any";
|
|
261
|
+
}>>;
|
|
262
|
+
appId: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
|
|
263
|
+
predicates: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
264
|
+
kind: z.ZodLiteral<"trait">;
|
|
265
|
+
name: z.ZodString;
|
|
266
|
+
op: z.ZodEnum<{
|
|
267
|
+
contains: "contains";
|
|
268
|
+
eq: "eq";
|
|
269
|
+
exists: "exists";
|
|
270
|
+
gt: "gt";
|
|
271
|
+
gte: "gte";
|
|
272
|
+
lt: "lt";
|
|
273
|
+
lte: "lte";
|
|
274
|
+
neq: "neq";
|
|
275
|
+
notExists: "notExists";
|
|
276
|
+
}>;
|
|
277
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
278
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
279
|
+
kind: z.ZodLiteral<"event">;
|
|
280
|
+
name: z.ZodString;
|
|
281
|
+
op: z.ZodEnum<{
|
|
282
|
+
notPerformed: "notPerformed";
|
|
283
|
+
performed: "performed";
|
|
284
|
+
}>;
|
|
285
|
+
atLeast: z.ZodDefault<z.ZodNumber>;
|
|
286
|
+
withinDays: z.ZodOptional<z.ZodNumber>;
|
|
287
|
+
}, z.core.$strip>], "kind">>;
|
|
288
|
+
}, z.core.$strict>;
|
|
258
289
|
}, z.core.$strict>]>;
|
|
259
290
|
purpose: z.ZodString;
|
|
260
|
-
|
|
291
|
+
enrollment: z.ZodOptional<z.ZodObject<{
|
|
292
|
+
cooldown: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
293
|
+
}, z.core.$strict>>;
|
|
294
|
+
description: z.ZodOptional<z.ZodString>;
|
|
295
|
+
from: z.ZodOptional<z.ZodString>;
|
|
261
296
|
kind: z.ZodLiteral<"journey">;
|
|
262
297
|
}, z.core.$strip>, z.ZodObject<{
|
|
263
298
|
tags: z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodString>>, z.ZodTransform<string[], string[]>>;
|
|
@@ -266,28 +301,88 @@ declare const manifestOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
266
301
|
transactional: "transactional";
|
|
267
302
|
}>;
|
|
268
303
|
verifyLink: z.ZodBoolean;
|
|
304
|
+
unsubscribeLink: z.ZodDefault<z.ZodBoolean>;
|
|
269
305
|
propsSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
270
306
|
kind: z.ZodLiteral<"template">;
|
|
271
307
|
}, z.core.$strip>], "kind">;
|
|
272
308
|
type ManifestOutput = z.infer<typeof manifestOutputSchema>;
|
|
273
309
|
//#endregion
|
|
274
310
|
//#region ../../packages/shared/src/journeys-v2/manifest.d.ts
|
|
311
|
+
/**
|
|
312
|
+
* The pushed manifest (spec: Build; Push and compile): what `cow build`
|
|
313
|
+
* extracts from a project and `cow push` uploads with the bundles. The
|
|
314
|
+
* server validates it with these schemas, compiles every bundle whose key
|
|
315
|
+
* changed, and stores that entry on the version it creates.
|
|
316
|
+
*/
|
|
317
|
+
/**
|
|
318
|
+
* A duration as journey code writes it: an ms-style string ("2d") or
|
|
319
|
+
* milliseconds. It lives here rather than with the guest protocol because a
|
|
320
|
+
* manifest carries one too (a journey's enrollment cooldown) and `./guest`
|
|
321
|
+
* already imports this module, so the other direction would be a cycle.
|
|
322
|
+
*/
|
|
323
|
+
declare const durationSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
324
|
+
type Duration = z.infer<typeof durationSchema>;
|
|
275
325
|
/**
|
|
276
326
|
* What starts a journey: an event (optionally narrowed to an app id or a
|
|
277
|
-
* list of them) or
|
|
278
|
-
* reuses it.
|
|
327
|
+
* list of them), or entry into the segment the trigger itself describes.
|
|
328
|
+
* The registry DTO in `../journeys` reuses it.
|
|
329
|
+
*
|
|
330
|
+
* A segment trigger carries the predicate list, not a name: the push
|
|
331
|
+
* materializes one segment row per journey that inlines a definition, owned
|
|
332
|
+
* by the journey and named after its key, so the segment exists because the
|
|
333
|
+
* journey exists and there is no order to get wrong (ADR 0016). The
|
|
334
|
+
* definition is data — validated here, carried on the version, never
|
|
335
|
+
* compiled and never executed.
|
|
279
336
|
*
|
|
280
|
-
* Both members are strict, so a journey holding the retired `source` key
|
|
281
|
-
* fails to
|
|
282
|
-
*
|
|
283
|
-
* write is attributed to, the same
|
|
337
|
+
* Both members are strict, so a journey holding the retired `source` key, or
|
|
338
|
+
* the retired `{ segment: "name" }` form, fails to build instead of silently
|
|
339
|
+
* triggering on every app or on nothing. There is deliberately no pipe
|
|
340
|
+
* filter: a trigger narrows by the app the write is attributed to, the same
|
|
341
|
+
* token a segment definition names.
|
|
284
342
|
*/
|
|
285
343
|
declare const triggerSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
286
344
|
event: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
287
345
|
appId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
288
346
|
}, z.core.$strict>, z.ZodObject<{
|
|
289
|
-
segment: z.
|
|
347
|
+
segment: z.ZodObject<{
|
|
348
|
+
match: z.ZodDefault<z.ZodEnum<{
|
|
349
|
+
all: "all";
|
|
350
|
+
any: "any";
|
|
351
|
+
}>>;
|
|
352
|
+
appId: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
|
|
353
|
+
predicates: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
354
|
+
kind: z.ZodLiteral<"trait">;
|
|
355
|
+
name: z.ZodString;
|
|
356
|
+
op: z.ZodEnum<{
|
|
357
|
+
contains: "contains";
|
|
358
|
+
eq: "eq";
|
|
359
|
+
exists: "exists";
|
|
360
|
+
gt: "gt";
|
|
361
|
+
gte: "gte";
|
|
362
|
+
lt: "lt";
|
|
363
|
+
lte: "lte";
|
|
364
|
+
neq: "neq";
|
|
365
|
+
notExists: "notExists";
|
|
366
|
+
}>;
|
|
367
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
368
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
369
|
+
kind: z.ZodLiteral<"event">;
|
|
370
|
+
name: z.ZodString;
|
|
371
|
+
op: z.ZodEnum<{
|
|
372
|
+
notPerformed: "notPerformed";
|
|
373
|
+
performed: "performed";
|
|
374
|
+
}>;
|
|
375
|
+
atLeast: z.ZodDefault<z.ZodNumber>;
|
|
376
|
+
withinDays: z.ZodOptional<z.ZodNumber>;
|
|
377
|
+
}, z.core.$strip>], "kind">>;
|
|
378
|
+
}, z.core.$strict>;
|
|
290
379
|
}, z.core.$strict>]>;
|
|
291
380
|
type Trigger = z.infer<typeof triggerSchema>;
|
|
381
|
+
/**
|
|
382
|
+
* A trigger as an author writes it, before zod fills in a predicate's
|
|
383
|
+
* `match` and `atLeast` defaults. `defineJourney` takes this shape;
|
|
384
|
+
* everything downstream reads the parsed `Trigger`.
|
|
385
|
+
*/
|
|
386
|
+
type TriggerInput = z.input<typeof triggerSchema>;
|
|
292
387
|
//#endregion
|
|
293
|
-
export {
|
|
388
|
+
export { JourneyStepOutput as a, GuestEvent as i, Trigger as n, ManifestOutput as o, TriggerInput as r, TemplateRenderOutput as s, Duration as t };
|