@cowliss/cli 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 CHANGED
@@ -44,7 +44,7 @@ import { defineJourney } from "@cowliss/cli/journeys";
44
44
 
45
45
  export default defineJourney({
46
46
  trigger: { event: "checkout_started" },
47
- purpose: "emailMarketing",
47
+ purpose: "marketing",
48
48
  run: async (event, api) => {
49
49
  const purchased = await api.waitForEvent("purchase_completed", {
50
50
  timeout: "24h",
@@ -1,4 +1,4 @@
1
- import { a as manifestOutputSchema, i as journeyStepOutputSchema, o as templateRenderOutputSchema, r as guestInputSchema, t as CapabilityError } from "./journeys-BrcKEXz0.js";
1
+ import { a as manifestOutputSchema, i as journeyStepOutputSchema, o as templateRenderOutputSchema, r as guestInputSchema, t as CapabilityError } from "./journeys-F8Yk8s1P.js";
2
2
  import { z } from "zod";
3
3
  import { createElement } from "react";
4
4
  import { renderToStaticMarkup } from "react-dom/server.browser";
@@ -5573,6 +5573,8 @@ function readManifest(module) {
5573
5573
  kind: "journey",
5574
5574
  trigger: journey.trigger,
5575
5575
  purpose: journey.purpose,
5576
+ enrollment: journey.enrollment,
5577
+ description: journey.description,
5576
5578
  from: journey.from,
5577
5579
  tags: journey.tags
5578
5580
  });
@@ -5583,6 +5585,7 @@ function readManifest(module) {
5583
5585
  tags: template.tags,
5584
5586
  sendClass: template.sendClass ?? "marketing",
5585
5587
  verifyLink: template.verifyLink ?? false,
5588
+ unsubscribeLink: template.unsubscribeLink ?? false,
5586
5589
  propsSchema: z.toJSONSchema(template.props, { target: "draft-2020-12" })
5587
5590
  });
5588
5591
  }
@@ -1,4 +1,4 @@
1
- import { a as ManifestOutput, i as JourneyStepOutput, o as TemplateRenderOutput } from "./index-CXcCEcAg.js";
1
+ import { a as JourneyStepOutput, o as ManifestOutput, s as TemplateRenderOutput } from "./index-EqBCZnpq.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
@@ -1,3 +1,3 @@
1
- import { t as runGuest } from "./driver-DBt5l1Z5.js";
1
+ import { t as runGuest } from "./driver-BXuYP007.js";
2
2
 
3
3
  export { runGuest };
@@ -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;
@@ -255,11 +252,44 @@ declare const manifestOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
255
252
  tags: z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodString>>, z.ZodTransform<string[], string[]>>;
256
253
  trigger: z.ZodUnion<readonly [z.ZodObject<{
257
254
  event: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
258
- appId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
259
255
  }, z.core.$strict>, z.ZodObject<{
260
- segment: z.ZodString;
256
+ segment: z.ZodObject<{
257
+ match: z.ZodDefault<z.ZodEnum<{
258
+ all: "all";
259
+ any: "any";
260
+ }>>;
261
+ predicates: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
262
+ kind: z.ZodLiteral<"trait">;
263
+ name: z.ZodString;
264
+ op: z.ZodEnum<{
265
+ contains: "contains";
266
+ eq: "eq";
267
+ exists: "exists";
268
+ gt: "gt";
269
+ gte: "gte";
270
+ lt: "lt";
271
+ lte: "lte";
272
+ neq: "neq";
273
+ notExists: "notExists";
274
+ }>;
275
+ value: z.ZodOptional<z.ZodUnknown>;
276
+ }, z.core.$strip>, z.ZodObject<{
277
+ kind: z.ZodLiteral<"event">;
278
+ name: z.ZodString;
279
+ op: z.ZodEnum<{
280
+ notPerformed: "notPerformed";
281
+ performed: "performed";
282
+ }>;
283
+ atLeast: z.ZodDefault<z.ZodNumber>;
284
+ withinDays: z.ZodOptional<z.ZodNumber>;
285
+ }, z.core.$strip>], "kind">>;
286
+ }, z.core.$strict>;
261
287
  }, z.core.$strict>]>;
262
288
  purpose: z.ZodString;
289
+ enrollment: z.ZodOptional<z.ZodObject<{
290
+ cooldown: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
291
+ }, z.core.$strict>>;
292
+ description: z.ZodOptional<z.ZodString>;
263
293
  from: z.ZodOptional<z.ZodString>;
264
294
  kind: z.ZodLiteral<"journey">;
265
295
  }, z.core.$strip>, z.ZodObject<{
@@ -269,6 +299,7 @@ declare const manifestOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
269
299
  transactional: "transactional";
270
300
  }>;
271
301
  verifyLink: z.ZodBoolean;
302
+ unsubscribeLink: z.ZodDefault<z.ZodBoolean>;
272
303
  propsSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
273
304
  kind: z.ZodLiteral<"template">;
274
305
  }, z.core.$strip>], "kind">;
@@ -276,21 +307,81 @@ type ManifestOutput = z.infer<typeof manifestOutputSchema>;
276
307
  //#endregion
277
308
  //#region ../../packages/shared/src/journeys-v2/manifest.d.ts
278
309
  /**
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.
310
+ * The pushed manifest (spec: Build; Push and compile): what `cow build`
311
+ * extracts from a project and `cow push` uploads with the bundles. The
312
+ * server validates it with these schemas, compiles every bundle whose key
313
+ * changed, and stores that entry on the version it creates.
314
+ */
315
+ /**
316
+ * A duration as journey code writes it: an ms-style string ("2d") or
317
+ * milliseconds. It lives here rather than with the guest protocol because a
318
+ * manifest carries one too (a journey's enrollment cooldown) and `./guest`
319
+ * already imports this module, so the other direction would be a cycle.
320
+ */
321
+ declare const durationSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
322
+ type Duration = z.infer<typeof durationSchema>;
323
+ /**
324
+ * What starts a journey: an event, or entry into the segment the trigger
325
+ * itself describes. The registry DTO in `../journeys` reuses it.
326
+ *
327
+ * No trigger names an app (ADR 0022): a repository is one app, the journey
328
+ * row carries its `app_id`, and the runtime compares that with the event's.
329
+ * An `appId` here would be a second way to say it, and the way to leak.
282
330
  *
283
- * Both members are strict, so a journey holding the retired `source` key
284
- * fails to compile 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.
331
+ * A segment trigger carries the predicate list, not a name: the push
332
+ * materializes one segment row per journey that inlines a definition, owned
333
+ * by the journey and named after its key, so the segment exists because the
334
+ * journey exists and there is no order to get wrong (ADR 0016). The
335
+ * definition is data — validated here, carried on the version, never
336
+ * compiled and never executed.
337
+ *
338
+ * Both members are strict, so a journey holding the retired `source` or
339
+ * `appId` key, or the retired `{ segment: "name" }` form, fails to build
340
+ * instead of silently triggering on every app or on nothing. There is
341
+ * deliberately no pipe filter and no app filter: the journey's own app is
342
+ * the only narrowing there is.
287
343
  */
288
344
  declare const triggerSchema: z.ZodUnion<readonly [z.ZodObject<{
289
345
  event: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
290
- appId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
291
346
  }, z.core.$strict>, z.ZodObject<{
292
- segment: z.ZodString;
347
+ segment: z.ZodObject<{
348
+ match: z.ZodDefault<z.ZodEnum<{
349
+ all: "all";
350
+ any: "any";
351
+ }>>;
352
+ predicates: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
353
+ kind: z.ZodLiteral<"trait">;
354
+ name: z.ZodString;
355
+ op: z.ZodEnum<{
356
+ contains: "contains";
357
+ eq: "eq";
358
+ exists: "exists";
359
+ gt: "gt";
360
+ gte: "gte";
361
+ lt: "lt";
362
+ lte: "lte";
363
+ neq: "neq";
364
+ notExists: "notExists";
365
+ }>;
366
+ value: z.ZodOptional<z.ZodUnknown>;
367
+ }, z.core.$strip>, z.ZodObject<{
368
+ kind: z.ZodLiteral<"event">;
369
+ name: z.ZodString;
370
+ op: z.ZodEnum<{
371
+ notPerformed: "notPerformed";
372
+ performed: "performed";
373
+ }>;
374
+ atLeast: z.ZodDefault<z.ZodNumber>;
375
+ withinDays: z.ZodOptional<z.ZodNumber>;
376
+ }, z.core.$strip>], "kind">>;
377
+ }, z.core.$strict>;
293
378
  }, z.core.$strict>]>;
294
379
  type Trigger = z.infer<typeof triggerSchema>;
380
+ /**
381
+ * A trigger as an author writes it, before zod fills in a predicate's
382
+ * `match` and `atLeast` defaults. `defineJourney` takes this shape;
383
+ * everything downstream reads the parsed `Trigger`.
384
+ */
385
+ type TriggerInput = z.input<typeof triggerSchema>;
295
386
  //#endregion
296
- export { ManifestOutput as a, JourneyStepOutput as i, Duration as n, TemplateRenderOutput as o, GuestEvent as r, Trigger as t };
387
+ export { JourneyStepOutput as a, GuestEvent as i, Trigger as n, ManifestOutput as o, TriggerInput as r, TemplateRenderOutput as s, Duration as t };