palbase 0.14.0 → 0.14.2

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 (53) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/backend/engine.js +2 -2
  3. package/dist/backend/env.js +1 -1
  4. package/dist/backend/index.js +3 -3
  5. package/dist/backend/stack.js +1 -1
  6. package/dist/backend/test.js +2 -2
  7. package/dist/chunks/{MDKUD5KF.js → 3AENUHVO.js} +2 -2
  8. package/dist/chunks/{VI7VITLG.js → 427AGWP3.js} +2 -2
  9. package/dist/chunks/{VYPEK5RA.js → 44ULNVPP.js} +1 -1
  10. package/dist/chunks/{YX4W5H7Q.js → 4UQ4J7RV.js} +2 -2
  11. package/dist/chunks/{JGUZOLS4.js → 5H7UNNH6.js} +2 -2
  12. package/dist/chunks/{R2FKMKIY.js → 6NC5RYCS.js} +1 -1
  13. package/dist/chunks/{DQ4XHMZN.js → 7DQ76T2V.js} +2 -2
  14. package/dist/chunks/{OIKBZFMC.js → A46IASZE.js} +2 -2
  15. package/dist/chunks/{FGKFL5W3.js → BRHGS5AI.js} +2 -2
  16. package/dist/chunks/{XA7ML545.js → CUL5OL4P.js} +2 -2
  17. package/dist/chunks/{7MGWLEW2.js → DIOZGDFQ.js} +1 -1
  18. package/dist/chunks/{XUX2HR4Z.js → HHZSOYPP.js} +1 -1
  19. package/dist/chunks/{QGGRIABQ.js → JKWWY2LJ.js} +2 -2
  20. package/dist/chunks/LUFWGH2V.js +2 -0
  21. package/dist/chunks/OMK2YEDZ.js +2 -0
  22. package/dist/chunks/{22WJEDHI.js → P67I4TNQ.js} +1 -1
  23. package/dist/chunks/{KOR6BP5M.js → PRJZTG2I.js} +1 -1
  24. package/dist/chunks/{UUS5URWX.js → QZH6GPCR.js} +2 -2
  25. package/dist/chunks/{AGZIRK5O.js → RD5JFDGQ.js} +2 -2
  26. package/dist/chunks/{FQV5NKI4.js → SBUC7GHR.js} +2 -2
  27. package/dist/chunks/{ZSICMUJY.js → W3OCV3QH.js} +2 -2
  28. package/dist/chunks/{OG5U5HFP.js → WXNFMEW7.js} +2 -2
  29. package/dist/chunks/{HQTKK3LU.js → ZZNGA77G.js} +1 -1
  30. package/dist/cli.js +130 -130
  31. package/dist/refuse/ai.js +1 -1
  32. package/dist/refuse/backend.js +1 -1
  33. package/dist/refuse/server.js +1 -1
  34. package/dist/server/index.js +2 -2
  35. package/dist/server/testing.js +2 -2
  36. package/dist/web/index.js +2 -2
  37. package/dist/web/message.js +2 -2
  38. package/dist/web/palbe.js +2 -2
  39. package/dist/web/paywall.js +2 -2
  40. package/dist/web/push-sw.js +1 -1
  41. package/dist/web/ssr.js +2 -2
  42. package/dist/web/vite.js +2 -2
  43. package/package.json +2 -2
  44. package/types/internal/src/modules/ai.d.ts +3 -7
  45. package/types/internal/src/modules/events.d.ts +4 -3
  46. package/types/internal/src/modules/index.d.ts +1 -0
  47. package/types/internal/src/modules/journeys.d.ts +1223 -0
  48. package/types/internal/src/modules/notify.d.ts +8 -0
  49. package/types/internal/src/modules/secrets.d.ts +1 -1
  50. package/types/internal/src/modules/stores.d.ts +777 -0
  51. package/types/server/src/transit.d.ts +8 -1
  52. package/dist/chunks/5LC7GWQ4.js +0 -2
  53. package/dist/chunks/XMJ4WMD2.js +0 -2
@@ -0,0 +1,1223 @@
1
+ import { type Reply, type Transport } from '../transport.js';
2
+ /**
3
+ * Holds when the person is (in, the default) or is not in an audience.
4
+ */
5
+ export type AudienceCondition = {
6
+ /**
7
+ * The audience's id
8
+ */
9
+ id: string;
10
+ /**
11
+ * false: holds when they are not in it
12
+ */
13
+ in?: boolean;
14
+ };
15
+ /**
16
+ * Sends the person on to then when if holds of them, else to else.
17
+ */
18
+ export type BranchStep = {
19
+ /**
20
+ * The step when it does not: a step's id, or end
21
+ */
22
+ else: string;
23
+ if: Condition;
24
+ /**
25
+ * The step when it holds: a step's id, or end
26
+ */
27
+ then: string;
28
+ };
29
+ /**
30
+ * What a branch asks of a person, one of: a property of theirs; whether they are in an audience; whether they did an event (since they entered, or within a while); all, any or none of others.
31
+ */
32
+ export type Condition = {
33
+ /**
34
+ * Holds when every one holds
35
+ */
36
+ all?: Condition[];
37
+ /**
38
+ * Holds when one holds
39
+ */
40
+ any?: Condition[];
41
+ audience?: AudienceCondition;
42
+ event?: EventCondition;
43
+ not?: Condition;
44
+ property?: PropertyCondition;
45
+ };
46
+ /**
47
+ * A journey's copy: its key, and a new name if it has one.
48
+ */
49
+ export type CopyWrite = {
50
+ /**
51
+ * The copy's key
52
+ */
53
+ key: string;
54
+ /**
55
+ * The copy's name; the journey's unless it says
56
+ */
57
+ name?: string;
58
+ };
59
+ /**
60
+ * Gives the person their code of one of the project's coupons: {{coupon}} in the messages after it.
61
+ */
62
+ export type CouponStep = {
63
+ /**
64
+ * The coupon's key
65
+ */
66
+ key: string;
67
+ };
68
+ /**
69
+ * A journey: who enters (entry), the steps each person who entered goes through from start, what the journey is for (goal) and what takes a person out (exit). Steps are keyed by id; each does one thing and names the step after it (next; none, or end, ends the person's run). A person is in a journey once at a time.
70
+ */
71
+ export type Definition = {
72
+ entry: Entry;
73
+ exit?: Exit;
74
+ goal?: Goal;
75
+ /**
76
+ * The journey's name, 1 to 200 bytes
77
+ */
78
+ name: string;
79
+ reentry?: Reentry;
80
+ /**
81
+ * The first step's id
82
+ */
83
+ start: string;
84
+ /**
85
+ * The steps by id (a-z, 0-9 and _, starting with a letter; end is taken): 100 at most, every one reachable from start, no way back to a step already taken but through a wait.
86
+ */
87
+ steps: {
88
+ [key: string]: Step;
89
+ };
90
+ };
91
+ /**
92
+ * A definition: a draft's new one, or one to check.
93
+ */
94
+ export type DefinitionWrite = {
95
+ definition: Definition;
96
+ };
97
+ /**
98
+ * An email from one of the project's email templates.
99
+ */
100
+ export type EmailStep = {
101
+ /**
102
+ * The message category
103
+ */
104
+ category?: string;
105
+ /**
106
+ * The template's key
107
+ */
108
+ template: string;
109
+ /**
110
+ * The template's variables; {{coupon}} is the code a coupon step gave
111
+ */
112
+ variables?: {
113
+ [key: string]: string;
114
+ };
115
+ };
116
+ /**
117
+ * Who enters, one of: a person who does an event; who comes to be in an audience; who has not done an event for a while; an audience's members when the journey is published.
118
+ */
119
+ export type Entry = {
120
+ /**
121
+ * An audience's id: who comes to be in it enters
122
+ */
123
+ audience?: string;
124
+ event?: EventMatch;
125
+ inactive?: Inactive;
126
+ /**
127
+ * An audience's id: its members enter when the journey is published
128
+ */
129
+ members_of?: string;
130
+ };
131
+ /**
132
+ * A journey's way in.
133
+ */
134
+ export type EntryInfo = {
135
+ /**
136
+ * The event's name, or the audience's id
137
+ */
138
+ key: string;
139
+ /**
140
+ * event, audience, inactive or members_of
141
+ */
142
+ kind: "event" | "audience" | "inactive" | "members_of";
143
+ };
144
+ /**
145
+ * The error envelope every error answers.
146
+ */
147
+ export type ErrorResponse = {
148
+ /**
149
+ * Machine-readable error code (snake_case)
150
+ */
151
+ error: string;
152
+ /**
153
+ * Human-readable explanation
154
+ */
155
+ error_description: string;
156
+ /**
157
+ * Correlation ID
158
+ */
159
+ request_id: string;
160
+ /**
161
+ * Seconds to wait before retrying, when the refusal ends with time.
162
+ */
163
+ retry_after?: number;
164
+ /**
165
+ * HTTP status code
166
+ */
167
+ status: number;
168
+ };
169
+ /**
170
+ * Holds when the person did the event since they entered the journey, or within a while.
171
+ */
172
+ export type EventCondition = {
173
+ /**
174
+ * The event's name
175
+ */
176
+ name: string;
177
+ /**
178
+ * Properties the event must have, each equal
179
+ */
180
+ where?: {
181
+ [key: string]: unknown;
182
+ };
183
+ /**
184
+ * How long back, an ISO 8601 duration: PT30M, PT2H, P2D, P1W; since entering unless it says
185
+ */
186
+ within?: string;
187
+ };
188
+ /**
189
+ * An event by its name (an app's event, or a module's: purchases.purchase.completed, purchases.coupon.redeemed, audience.entered), with properties it must have, each equal.
190
+ */
191
+ export type EventMatch = {
192
+ /**
193
+ * The event's name
194
+ */
195
+ name: string;
196
+ /**
197
+ * Properties the event must have, each equal to its value
198
+ */
199
+ where?: {
200
+ [key: string]: unknown;
201
+ };
202
+ };
203
+ /**
204
+ * Tells the project's backend: a journey.event (a webhook, or an @On) with the name and data.
205
+ */
206
+ export type EventStep = {
207
+ /**
208
+ * Data it carries
209
+ */
210
+ data?: {
211
+ [key: string]: unknown;
212
+ };
213
+ /**
214
+ * The event's own name
215
+ */
216
+ name: string;
217
+ };
218
+ /**
219
+ * What takes a person out before the end.
220
+ */
221
+ export type Exit = {
222
+ /**
223
+ * An audience's id: leaving it takes them out
224
+ */
225
+ audience_left?: string;
226
+ /**
227
+ * Events that take them out
228
+ */
229
+ events?: EventMatch[];
230
+ };
231
+ /**
232
+ * What the journey is for: an event of the person's within a while of entering. A run that sees it ends converted; one that completed before it is counted converted too.
233
+ */
234
+ export type Goal = {
235
+ event: EventMatch;
236
+ /**
237
+ * How long after entering it counts, an ISO 8601 duration: PT30M, PT2H, P2D, P1W; 30 days unless it says, 90 days at most
238
+ */
239
+ within?: string;
240
+ };
241
+ /**
242
+ * One of the project's in-app campaigns made for journeys, shown to the person the next time it is triggered in their app.
243
+ */
244
+ export type InAppStep = {
245
+ /**
246
+ * The campaign's id: an in-app campaign made for journeys (for_journeys)
247
+ */
248
+ campaign: string;
249
+ /**
250
+ * For how many days it waits to be shown; 7 unless it says
251
+ */
252
+ days?: number;
253
+ };
254
+ /**
255
+ * The runs open now.
256
+ */
257
+ export type InProgress = {
258
+ /**
259
+ * Taking a step
260
+ */
261
+ active: number;
262
+ /**
263
+ * Waiting to enter until the project has monthly people again
264
+ */
265
+ held: number;
266
+ /**
267
+ * At a wait
268
+ */
269
+ waiting: number;
270
+ };
271
+ /**
272
+ * Enters a person who has not done an event for a while: the moment the while passes since their last one.
273
+ */
274
+ export type Inactive = {
275
+ /**
276
+ * The event's name ($session_start: who has not opened the app)
277
+ */
278
+ event: string;
279
+ /**
280
+ * How long, an ISO 8601 duration: PT30M, PT2H, P2D, P1W; 1 hour to 90 days
281
+ */
282
+ for: string;
283
+ };
284
+ /**
285
+ * A message to the person's inbox.
286
+ */
287
+ export type InboxStep = {
288
+ /**
289
+ * The body by locale; 2,000 bytes each
290
+ */
291
+ body: {
292
+ [key: string]: string;
293
+ };
294
+ /**
295
+ * The message category
296
+ */
297
+ category?: string;
298
+ /**
299
+ * Data the app receives with it
300
+ */
301
+ data?: {
302
+ [key: string]: string;
303
+ };
304
+ /**
305
+ * Where opening it goes
306
+ */
307
+ deep_link?: string;
308
+ /**
309
+ * Days it stays in the inbox
310
+ */
311
+ expires_in_days?: number;
312
+ /**
313
+ * An image's https URL
314
+ */
315
+ image?: string;
316
+ /**
317
+ * The title by locale; 200 bytes each
318
+ */
319
+ title: {
320
+ [key: string]: string;
321
+ };
322
+ /**
323
+ * Variables the words use
324
+ */
325
+ variables?: {
326
+ [key: string]: string;
327
+ };
328
+ };
329
+ /**
330
+ * A definition that breaks a rule: the error envelope (invalid_journey, the first problem in error_description) and every problem, each at its path with what to do about it.
331
+ */
332
+ export type InvalidJourney = {
333
+ /**
334
+ * invalid_journey
335
+ */
336
+ error: string;
337
+ /**
338
+ * The first problem: its path and what is wrong
339
+ */
340
+ error_description: string;
341
+ /**
342
+ * Every problem found
343
+ */
344
+ problems: Problem[];
345
+ /**
346
+ * Correlation ID
347
+ */
348
+ request_id: string;
349
+ /**
350
+ * 422
351
+ */
352
+ status: number;
353
+ };
354
+ /**
355
+ * A journey whole.
356
+ */
357
+ export type Journey = {
358
+ /**
359
+ * When it was made
360
+ */
361
+ created_at: string;
362
+ definition: Definition;
363
+ entry: EntryInfo;
364
+ /**
365
+ * The journey's key
366
+ */
367
+ key: string;
368
+ /**
369
+ * Its name
370
+ */
371
+ name: string;
372
+ /**
373
+ * When it was published
374
+ */
375
+ published_at: string | null;
376
+ /**
377
+ * draft, live or stopped
378
+ */
379
+ status: "draft" | "live" | "stopped";
380
+ /**
381
+ * When it was stopped
382
+ */
383
+ stopped_at: string | null;
384
+ /**
385
+ * When it last changed
386
+ */
387
+ updated_at: string;
388
+ };
389
+ /**
390
+ * journey.converted: a person's run reached the journey's goal.
391
+ */
392
+ export type JourneyConvertedEvent = {
393
+ /**
394
+ * The journey's key
395
+ */
396
+ journey: string;
397
+ /**
398
+ * The journey's id
399
+ */
400
+ journey_id: string;
401
+ /**
402
+ * The run's id
403
+ */
404
+ run_id: string;
405
+ /**
406
+ * The person
407
+ */
408
+ user_id: string;
409
+ };
410
+ /**
411
+ * journey.ended: a person's run ended.
412
+ */
413
+ export type JourneyEndedEvent = {
414
+ /**
415
+ * The journey's key
416
+ */
417
+ journey: string;
418
+ /**
419
+ * The journey's id
420
+ */
421
+ journey_id: string;
422
+ /**
423
+ * completed, converted, exited, stopped, or failed (a step failed every try)
424
+ */
425
+ reason: "completed" | "converted" | "exited" | "stopped" | "failed";
426
+ /**
427
+ * The run's id
428
+ */
429
+ run_id: string;
430
+ /**
431
+ * The person
432
+ */
433
+ user_id: string;
434
+ };
435
+ /**
436
+ * journey.entered: a person entered a journey.
437
+ */
438
+ export type JourneyEnteredEvent = {
439
+ /**
440
+ * The journey's key
441
+ */
442
+ journey: string;
443
+ /**
444
+ * The journey's id
445
+ */
446
+ journey_id: string;
447
+ /**
448
+ * The run's id
449
+ */
450
+ run_id: string;
451
+ /**
452
+ * The person
453
+ */
454
+ user_id: string;
455
+ };
456
+ /**
457
+ * journey.event: a journey's event step told the project's backend.
458
+ */
459
+ export type JourneyEventEvent = {
460
+ /**
461
+ * The data it carries
462
+ */
463
+ data?: {
464
+ [key: string]: unknown;
465
+ };
466
+ /**
467
+ * The journey's key
468
+ */
469
+ journey: string;
470
+ /**
471
+ * The journey's id
472
+ */
473
+ journey_id: string;
474
+ /**
475
+ * The step's event name
476
+ */
477
+ name: string;
478
+ /**
479
+ * The run's id
480
+ */
481
+ run_id: string;
482
+ /**
483
+ * The step's id
484
+ */
485
+ step: string;
486
+ /**
487
+ * The person
488
+ */
489
+ user_id: string;
490
+ };
491
+ /**
492
+ * A journey as a list shows it.
493
+ */
494
+ export type JourneyInfo = {
495
+ /**
496
+ * When it was made
497
+ */
498
+ created_at: string;
499
+ entry: EntryInfo;
500
+ /**
501
+ * The journey's key
502
+ */
503
+ key: string;
504
+ /**
505
+ * Its name
506
+ */
507
+ name: string;
508
+ /**
509
+ * When it was published
510
+ */
511
+ published_at: string | null;
512
+ /**
513
+ * draft (changes), live (people enter it; it does not change), stopped (no one is in it; its report stays)
514
+ */
515
+ status: "draft" | "live" | "stopped";
516
+ /**
517
+ * When it was stopped
518
+ */
519
+ stopped_at: string | null;
520
+ /**
521
+ * When it last changed
522
+ */
523
+ updated_at: string;
524
+ };
525
+ /**
526
+ * The project's journeys, newest first.
527
+ */
528
+ export type JourneyList = {
529
+ /**
530
+ * A page of them
531
+ */
532
+ journeys: JourneyInfo[];
533
+ /**
534
+ * The next page's cursor; absent on the last page
535
+ */
536
+ next_cursor?: string;
537
+ };
538
+ /**
539
+ * What came of a journey: who entered, how their runs ended, who is in it now, the goal's conversions, each step's outcomes, and each split's ways with their conversions.
540
+ */
541
+ export type JourneyStats = {
542
+ /**
543
+ * Runs that reached the goal
544
+ */
545
+ converted: number;
546
+ /**
547
+ * Runs ended, by reason: completed, converted, exited, stopped, failed (a step failed every try), erased (the person was deleted)
548
+ */
549
+ ended: {
550
+ [key: string]: number;
551
+ };
552
+ /**
553
+ * People who entered
554
+ */
555
+ entered: number;
556
+ /**
557
+ * Entries held while the project's monthly people were used up
558
+ */
559
+ held: number;
560
+ in_progress: InProgress;
561
+ /**
562
+ * The journey's key
563
+ */
564
+ key: string;
565
+ /**
566
+ * draft, live or stopped
567
+ */
568
+ status: "draft" | "live" | "stopped";
569
+ /**
570
+ * Each step from the start, in order
571
+ */
572
+ steps: StepStats[];
573
+ };
574
+ /**
575
+ * journey.step: a person's run took a step.
576
+ */
577
+ export type JourneyStepEvent = {
578
+ /**
579
+ * The journey's key
580
+ */
581
+ journey: string;
582
+ /**
583
+ * The journey's id
584
+ */
585
+ journey_id: string;
586
+ /**
587
+ * What it does
588
+ */
589
+ kind: string;
590
+ /**
591
+ * What it came to
592
+ */
593
+ outcome: string;
594
+ /**
595
+ * The run's id
596
+ */
597
+ run_id: string;
598
+ /**
599
+ * The step's id
600
+ */
601
+ step: string;
602
+ /**
603
+ * The person
604
+ */
605
+ user_id: string;
606
+ };
607
+ /**
608
+ * A new journey: its key and its definition.
609
+ */
610
+ export type JourneyWrite = {
611
+ definition: Definition;
612
+ /**
613
+ * The journey's own name: 1 to 64 of a-z, 0-9 and _, starting with a letter (winback)
614
+ */
615
+ key: string;
616
+ };
617
+ /**
618
+ * Gives the person one of the catalog's grant offers: an entitlement for a while.
619
+ */
620
+ export type OfferStep = {
621
+ /**
622
+ * The offer's key
623
+ */
624
+ key: string;
625
+ };
626
+ /**
627
+ * One thing wrong with a definition.
628
+ */
629
+ export type Problem = {
630
+ /**
631
+ * What to do about it, when there is a known way
632
+ */
633
+ fix?: string;
634
+ /**
635
+ * What is wrong
636
+ */
637
+ message: string;
638
+ /**
639
+ * Where, as a dotted path into the definition: steps.mail.email.template, entry, goal.within
640
+ */
641
+ path: string;
642
+ };
643
+ /**
644
+ * Compares a person's property (analytics' people) with a value.
645
+ */
646
+ export type PropertyCondition = {
647
+ /**
648
+ * The property's name
649
+ */
650
+ name: string;
651
+ /**
652
+ * eq, ne, gt, gte, lt, lte, contains (a string's), exists, missing
653
+ */
654
+ op: "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "contains" | "exists" | "missing";
655
+ /**
656
+ * The value compared with; none for exists and missing
657
+ */
658
+ value?: unknown;
659
+ };
660
+ /**
661
+ * A push notification to the person's devices: words by locale, or one of the project's push templates. {{coupon}} is the code a coupon step gave.
662
+ */
663
+ export type PushStep = {
664
+ /**
665
+ * The body by locale; 2,000 bytes each
666
+ */
667
+ body?: {
668
+ [key: string]: string;
669
+ };
670
+ /**
671
+ * The message category the person's consent and the send rules read
672
+ */
673
+ category?: string;
674
+ /**
675
+ * Data the app receives with it
676
+ */
677
+ data?: {
678
+ [key: string]: string;
679
+ };
680
+ /**
681
+ * Where tapping it opens
682
+ */
683
+ deep_link?: string;
684
+ /**
685
+ * An image's https URL
686
+ */
687
+ image?: string;
688
+ /**
689
+ * Keeps a copy in the person's inbox too
690
+ */
691
+ inbox?: boolean;
692
+ /**
693
+ * One of the project's push templates, in place of title and body
694
+ */
695
+ template?: string;
696
+ /**
697
+ * The title by locale (BCP 47): en, tr, pt-BR; 200 bytes each
698
+ */
699
+ title?: {
700
+ [key: string]: string;
701
+ };
702
+ /**
703
+ * The template's variables
704
+ */
705
+ variables?: {
706
+ [key: string]: string;
707
+ };
708
+ };
709
+ /**
710
+ * Whether a person who was in the journey enters it again.
711
+ */
712
+ export type Reentry = {
713
+ /**
714
+ * With after: how long, an ISO 8601 duration: PT30M, PT2H, P2D, P1W; 1 hour to 365 days
715
+ */
716
+ after?: string;
717
+ /**
718
+ * once (never again, the default), always (each time, once their run ended), after (once after has passed since they last entered). Whatever it says, a person enters one journey 20 times a day at most: a journey whose own steps cause its entry event does not loop.
719
+ */
720
+ mode: "once" | "always" | "after";
721
+ };
722
+ /**
723
+ * A person's run through a journey: where it is, how it ended, and each step it took.
724
+ */
725
+ export type Run = {
726
+ /**
727
+ * When it reached the goal
728
+ */
729
+ converted_at: string | null;
730
+ /**
731
+ * completed, converted, exited, stopped, or failed (a step failed every try)
732
+ */
733
+ end_reason: string | null;
734
+ /**
735
+ * When it ended
736
+ */
737
+ ended_at: string | null;
738
+ /**
739
+ * When the person entered
740
+ */
741
+ entered_at: string;
742
+ /**
743
+ * The run's id
744
+ */
745
+ id: string;
746
+ /**
747
+ * The journey's key
748
+ */
749
+ journey: string;
750
+ /**
751
+ * held (waiting to enter), active, waiting, ended
752
+ */
753
+ state: "held" | "active" | "waiting" | "ended";
754
+ /**
755
+ * The step it is at
756
+ */
757
+ step: string | null;
758
+ /**
759
+ * The steps it took, in order
760
+ */
761
+ steps: RunStep[];
762
+ /**
763
+ * The person
764
+ */
765
+ user_id: string;
766
+ /**
767
+ * When its wait ends
768
+ */
769
+ wake_at: string | null;
770
+ };
771
+ /**
772
+ * Runs, newest first.
773
+ */
774
+ export type RunList = {
775
+ /**
776
+ * The next page's cursor; absent on the last page
777
+ */
778
+ next_cursor?: string;
779
+ /**
780
+ * A page of them
781
+ */
782
+ runs: Run[];
783
+ };
784
+ /**
785
+ * A step a run took, and what came of it.
786
+ */
787
+ export type RunStep = {
788
+ /**
789
+ * When
790
+ */
791
+ at: string;
792
+ /**
793
+ * What it did: a message's ids and, held through the person's quiet hours, when it goes (held_until); why one was skipped (reason: consent, frequency_cap, preferences, no_address, deleted, quota_exceeded); why an offer was not granted; the event that ended a wait
794
+ */
795
+ detail: {
796
+ [key: string]: unknown;
797
+ };
798
+ /**
799
+ * What it does
800
+ */
801
+ kind: string;
802
+ /**
803
+ * What it came to
804
+ */
805
+ outcome: string;
806
+ /**
807
+ * The step's id
808
+ */
809
+ step: string;
810
+ };
811
+ /**
812
+ * Writes properties of the person's (analytics' people).
813
+ */
814
+ export type SetStep = {
815
+ /**
816
+ * The properties and their values
817
+ */
818
+ properties: {
819
+ [key: string]: unknown;
820
+ };
821
+ };
822
+ /**
823
+ * How and when the run ends.
824
+ */
825
+ export type SimulatedEnd = {
826
+ /**
827
+ * When
828
+ */
829
+ at: string;
830
+ /**
831
+ * completed, converted or exited
832
+ */
833
+ reason: "completed" | "converted" | "exited";
834
+ };
835
+ /**
836
+ * An event the person does.
837
+ */
838
+ export type SimulatedEvent = {
839
+ /**
840
+ * How long after entering, an ISO 8601 duration: PT30M, PT2H, P2D, P1W (PT0M: at once)
841
+ */
842
+ after: string;
843
+ /**
844
+ * The event's name
845
+ */
846
+ name: string;
847
+ /**
848
+ * Its properties
849
+ */
850
+ properties?: {
851
+ [key: string]: unknown;
852
+ };
853
+ };
854
+ /**
855
+ * Who walks: their properties and audiences when they enter, where they are, and what they do after.
856
+ */
857
+ export type SimulatedPerson = {
858
+ /**
859
+ * The audiences they are in
860
+ */
861
+ audiences?: string[];
862
+ /**
863
+ * What they do after entering, 100 at most
864
+ */
865
+ events?: SimulatedEvent[];
866
+ /**
867
+ * Their properties, which branches read
868
+ */
869
+ properties?: {
870
+ [key: string]: unknown;
871
+ };
872
+ /**
873
+ * Their IANA time zone (Europe/Istanbul), which waits until a time of day read
874
+ */
875
+ timezone?: string;
876
+ /**
877
+ * Their id, which chooses their way at a split
878
+ */
879
+ user_id?: string;
880
+ };
881
+ /**
882
+ * A step taken.
883
+ */
884
+ export type SimulatedStep = {
885
+ /**
886
+ * When
887
+ */
888
+ at: string;
889
+ /**
890
+ * What it does: push, inbox, email, in_app, coupon, offer, set, event, wait, branch, split
891
+ */
892
+ kind: string;
893
+ /**
894
+ * What it would have done: the push's title, the email's template
895
+ */
896
+ note: string;
897
+ /**
898
+ * What it came to: sent, given, set, told, waiting, waited, event, timeout, then, else, a split's way
899
+ */
900
+ outcome: string;
901
+ /**
902
+ * The step's id
903
+ */
904
+ step: string;
905
+ };
906
+ /**
907
+ * The person's way through: each step, when, what it came to and what it would have done; how the run ends and when; when the goal came after it completed, if it did.
908
+ */
909
+ export type Simulation = {
910
+ /**
911
+ * When the goal came after the run completed
912
+ */
913
+ converted_at: string | null;
914
+ end: SimulatedEnd;
915
+ /**
916
+ * The steps taken, in order
917
+ */
918
+ steps: SimulatedStep[];
919
+ };
920
+ /**
921
+ * Walks a person through a journey — the project's (key) or one not saved yet (definition) — from start: nothing is sent, given or written.
922
+ */
923
+ export type SimulationWrite = {
924
+ definition?: Definition;
925
+ /**
926
+ * The project's journey to walk; or definition
927
+ */
928
+ key?: string;
929
+ person: SimulatedPerson;
930
+ /**
931
+ * When the person enters; now unless it says
932
+ */
933
+ start?: string;
934
+ };
935
+ /**
936
+ * One of a split's ways.
937
+ */
938
+ export type SplitArm = {
939
+ /**
940
+ * The way's name (a, b, control), reported in the stats
941
+ */
942
+ name: string;
943
+ /**
944
+ * Its next step: a step's id, or end
945
+ */
946
+ next: string;
947
+ /**
948
+ * How many in a hundred take it, 1 to 99
949
+ */
950
+ weight: number;
951
+ };
952
+ /**
953
+ * One step: exactly one of push, inbox, email, in_app, coupon, offer, set, event, wait, branch, split — and next, where the person goes after it (none, or end, ends their run). A message step (push, inbox, email, in_app) is sent by the project's send rules: quiet hours, frequency caps and the person's consent; a message they did not allow is skipped and the run goes on.
954
+ */
955
+ export type Step = {
956
+ branch?: BranchStep;
957
+ coupon?: CouponStep;
958
+ email?: EmailStep;
959
+ event?: EventStep;
960
+ in_app?: InAppStep;
961
+ inbox?: InboxStep;
962
+ /**
963
+ * The next step: a step's id, or end
964
+ */
965
+ next?: string;
966
+ offer?: OfferStep;
967
+ push?: PushStep;
968
+ set?: SetStep;
969
+ /**
970
+ * A/B split: 2 to 5 ways whose weights add up to 100; each person takes one by chance, the same one on every try
971
+ */
972
+ split?: SplitArm[];
973
+ wait?: WaitStep;
974
+ };
975
+ /**
976
+ * A step's outcomes; a split's, each way's conversions too.
977
+ */
978
+ export type StepStats = {
979
+ /**
980
+ * A split's: the runs that took each way and reached the goal
981
+ */
982
+ converted?: {
983
+ [key: string]: number;
984
+ };
985
+ /**
986
+ * What it does
987
+ */
988
+ kind: string;
989
+ /**
990
+ * How many times it came to each outcome: sent, skipped, failed (the module it called refused it for good), given, no_code, granted, not_granted, set, told, waited, event, timeout, then, else, a split's way
991
+ */
992
+ outcomes: {
993
+ [key: string]: number;
994
+ };
995
+ /**
996
+ * The step's id
997
+ */
998
+ step: string;
999
+ };
1000
+ /**
1001
+ * What a definition's check found.
1002
+ */
1003
+ export type Validation = {
1004
+ /**
1005
+ * Every problem, each at its path with what to do about it
1006
+ */
1007
+ problems: Problem[];
1008
+ /**
1009
+ * True when nothing is wrong
1010
+ */
1011
+ valid: boolean;
1012
+ };
1013
+ /**
1014
+ * A definition to check: any JSON object — what breaks the journey's shape (Definition) or its rules is a problem in the answer, not a refusal.
1015
+ */
1016
+ export type ValidationWrite = {
1017
+ /**
1018
+ * The definition to check
1019
+ */
1020
+ definition: {
1021
+ [key: string]: unknown;
1022
+ };
1023
+ };
1024
+ /**
1025
+ * Holds the person, one of: for a while; until a time of day where they are; until an event of theirs, at most timeout (then timeout_next, or the end).
1026
+ */
1027
+ export type WaitStep = {
1028
+ event?: EventMatch;
1029
+ /**
1030
+ * How long, an ISO 8601 duration: PT30M, PT2H, P2D, P1W; 1 minute to 90 days
1031
+ */
1032
+ for?: string;
1033
+ /**
1034
+ * With event: how long at most, an ISO 8601 duration: PT30M, PT2H, P2D, P1W
1035
+ */
1036
+ timeout?: string;
1037
+ /**
1038
+ * With event: the step after the timeout: a step's id, or end
1039
+ */
1040
+ timeout_next?: string;
1041
+ /**
1042
+ * A time of day, HH:MM, in the person's $timezone (UTC when they have none)
1043
+ */
1044
+ until?: string;
1045
+ };
1046
+ /** The events this module sends the project's webhooks (x-palbase-events), by type: each one's payload, the event's data. */
1047
+ export interface Events {
1048
+ /**
1049
+ * journey.converted: a person's run reached the journey's goal.
1050
+ */
1051
+ "journey.converted": JourneyConvertedEvent;
1052
+ /**
1053
+ * journey.ended: a person's run ended (completed, converted, exited, stopped).
1054
+ */
1055
+ "journey.ended": JourneyEndedEvent;
1056
+ /**
1057
+ * journey.entered: a person entered a journey.
1058
+ */
1059
+ "journey.entered": JourneyEnteredEvent;
1060
+ /**
1061
+ * journey.event: a journey's event step told the project's backend.
1062
+ */
1063
+ "journey.event": JourneyEventEvent;
1064
+ /**
1065
+ * journey.step: a person's run took a step.
1066
+ */
1067
+ "journey.step": JourneyStepEvent;
1068
+ }
1069
+ /** Palbase Journeys */
1070
+ export declare function client(t: Transport): {
1071
+ /**
1072
+ * List journeys
1073
+ *
1074
+ * The project's journeys, newest first, a page at a time; status narrows them to drafts, live or stopped ones.
1075
+ */
1076
+ listJourneys(input?: {
1077
+ query?: {
1078
+ status?: "draft" | "live" | "stopped"; /** How many, 1 to 200; 50 unless it says */
1079
+ limit?: number; /** A page's next_cursor, for the page after it */
1080
+ cursor?: string;
1081
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1082
+ signal?: AbortSignal;
1083
+ }): Promise<Reply<200, JourneyList>>;
1084
+ /**
1085
+ * Create a journey
1086
+ *
1087
+ * Makes a draft journey from its definition. A definition that breaks a rule is refused with every problem, each at its path and with what to do about it (422 invalid_journey); POST /journeys/validate checks one without saving it. Nothing runs until it is published. A project keeps 500 journeys (409 too_many_journeys).
1088
+ */
1089
+ createJourney(input: {
1090
+ body: JourneyWrite; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1091
+ signal?: AbortSignal;
1092
+ }): Promise<Reply<201, Journey>>;
1093
+ /**
1094
+ * A person's runs
1095
+ *
1096
+ * A person's runs through every journey, newest first, a page at a time, each with the steps it took and what came of them: what support reads when someone asks what they were sent.
1097
+ */
1098
+ listPersonRuns(input: {
1099
+ path: {
1100
+ user_id: string;
1101
+ };
1102
+ query?: {
1103
+ limit?: number; /** A page's next_cursor, for the page after it */
1104
+ cursor?: string;
1105
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1106
+ signal?: AbortSignal;
1107
+ }): Promise<Reply<200, RunList>>;
1108
+ /**
1109
+ * Walk a person through a journey
1110
+ *
1111
+ * Walks a made-up person through a journey — the project's by key, or a definition not saved yet — as the engine would: each step, when, what it came to and what it would have done, and how the run ends. Waits take their time on paper; nothing is sent, given or written.
1112
+ */
1113
+ simulateJourney(input: {
1114
+ body: SimulationWrite; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1115
+ signal?: AbortSignal;
1116
+ }): Promise<Reply<200, Simulation>>;
1117
+ /**
1118
+ * Check a definition
1119
+ *
1120
+ * Checks a definition without saving it: every problem, each at its path with what to do about it. A valid one is the same journey POST /journeys makes.
1121
+ */
1122
+ validateJourney(input: {
1123
+ body: ValidationWrite; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1124
+ signal?: AbortSignal;
1125
+ }): Promise<Reply<200, Validation>>;
1126
+ /**
1127
+ * Read a journey
1128
+ *
1129
+ * A journey whole, with its definition.
1130
+ */
1131
+ getJourney(input: {
1132
+ path: {
1133
+ key: string;
1134
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1135
+ signal?: AbortSignal;
1136
+ }): Promise<Reply<200, Journey>>;
1137
+ /**
1138
+ * Change a draft
1139
+ *
1140
+ * Replaces a draft's definition. A published journey does not change (409 journey_published): copy it into a new draft, publish that and stop this one.
1141
+ */
1142
+ updateJourney(input: {
1143
+ path: {
1144
+ key: string;
1145
+ };
1146
+ body: DefinitionWrite; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1147
+ signal?: AbortSignal;
1148
+ }): Promise<Reply<200, Journey>>;
1149
+ /**
1150
+ * Delete a journey
1151
+ *
1152
+ * Deletes a journey, its runs and its report; the people in a live one leave it at once, and nothing more is sent them.
1153
+ */
1154
+ deleteJourney(input: {
1155
+ path: {
1156
+ key: string;
1157
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1158
+ signal?: AbortSignal;
1159
+ }): Promise<Reply<204, undefined>>;
1160
+ /**
1161
+ * Copy a journey
1162
+ *
1163
+ * Copies a journey's definition into a new draft: how a live journey is changed (copy, change the copy, publish it, stop the old one).
1164
+ */
1165
+ copyJourney(input: {
1166
+ path: {
1167
+ key: string;
1168
+ };
1169
+ body: CopyWrite; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1170
+ signal?: AbortSignal;
1171
+ }): Promise<Reply<201, Journey>>;
1172
+ /**
1173
+ * Publish a draft
1174
+ *
1175
+ * Makes a draft live: from now people enter it (a members_of journey enters the audience's members at once), and it no longer changes. The Free plan runs 2 journeys at once (402 live_journeys_limit). Each person who enters a journey in a month counts toward the project's monthly journey people; once the Free plan's are used up, new entries wait for the next month while the people in journeys go on. Any project runs 50 journeys at once (409 too_many_live_journeys).
1176
+ */
1177
+ publishJourney(input: {
1178
+ path: {
1179
+ key: string;
1180
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1181
+ signal?: AbortSignal;
1182
+ }): Promise<Reply<200, Journey>>;
1183
+ /**
1184
+ * A journey's runs
1185
+ *
1186
+ * The people's runs through a journey, newest first, a page at a time, each with the steps it took and what came of them; user_id and state narrow them.
1187
+ */
1188
+ listJourneyRuns(input: {
1189
+ path: {
1190
+ key: string;
1191
+ };
1192
+ query?: {
1193
+ user_id?: string; /** held, active, waiting or ended */
1194
+ state?: "held" | "active" | "waiting" | "ended"; /** How many, 1 to 200; 50 unless it says */
1195
+ limit?: number; /** A page's next_cursor, for the page after it */
1196
+ cursor?: string;
1197
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1198
+ signal?: AbortSignal;
1199
+ }): Promise<Reply<200, RunList>>;
1200
+ /**
1201
+ * What came of a journey
1202
+ *
1203
+ * Who entered, how their runs ended, who is in it now, the goal's conversions, each step's outcomes and each split's ways with their conversions.
1204
+ */
1205
+ getJourneyStats(input: {
1206
+ path: {
1207
+ key: string;
1208
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1209
+ signal?: AbortSignal;
1210
+ }): Promise<Reply<200, JourneyStats>>;
1211
+ /**
1212
+ * Stop a journey
1213
+ *
1214
+ * Stops a live journey for good: from now no one enters it and no run of it takes another step; the runs in it end stopped within moments (a page at a time), and its report stays.
1215
+ */
1216
+ stopJourney(input: {
1217
+ path: {
1218
+ key: string;
1219
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1220
+ signal?: AbortSignal;
1221
+ }): Promise<Reply<200, Journey>>;
1222
+ };
1223
+ export type Client = ReturnType<typeof client>;