sinfactura-types 1.10.334 → 1.10.336
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/dist/cart.d.ts +60 -1
- package/dist/cjs/marketing.js +26 -1
- package/dist/lot.d.ts +26 -0
- package/dist/marketing.d.ts +96 -4
- package/dist/marketing.js +25 -0
- package/package.json +1 -1
package/dist/cart.d.ts
CHANGED
|
@@ -34,6 +34,26 @@ declare global {
|
|
|
34
34
|
terminalId?: string;
|
|
35
35
|
status?: 'active' | 'abandoned' | 'converted' | 'parked';
|
|
36
36
|
parkedBy?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Epoch ms this ABANDONED cart's lines were folded into another cart by
|
|
39
|
+
* `POST /basket` `{ mode: 'resume' }`. Set once and never cleared.
|
|
40
|
+
*
|
|
41
|
+
* ⚠️ **It is a CONSUMPTION marker, not a timestamp anyone should render.**
|
|
42
|
+
* The fold uses `merge`, which SUMS, and the abandoned row survives with
|
|
43
|
+
* its lines for as long as the recovery link does — so without a marker a
|
|
44
|
+
* refresh, a back-navigation or a component that mounts twice would re-add
|
|
45
|
+
* every quantity, for days. The resume write sets this under
|
|
46
|
+
* `attribute_not_exists(resumedAt)`, so exactly one caller can ever win and
|
|
47
|
+
* every replay answers the cart the shopper already has.
|
|
48
|
+
*
|
|
49
|
+
* ⚠️ Absent on the OTHER resume path — a shopper with no second cart has
|
|
50
|
+
* their own cart reinstated in place, which adds nothing and needs no
|
|
51
|
+
* marker. So absence means "never folded", never "never resumed".
|
|
52
|
+
*
|
|
53
|
+
* ⚠️ Nothing on the till side reads or writes it; it is unrelated to
|
|
54
|
+
* `parkedAt` and to the POS un-park verb, which happens to share the word.
|
|
55
|
+
*/
|
|
56
|
+
resumedAt?: number;
|
|
37
57
|
parkedAt?: number;
|
|
38
58
|
version?: number;
|
|
39
59
|
lines: CartLine[];
|
|
@@ -717,7 +737,46 @@ declare global {
|
|
|
717
737
|
* at the DynamoDB marshaller instead of at validation.
|
|
718
738
|
* - `merge.items` is `min(1).max(50)`.
|
|
719
739
|
*/
|
|
720
|
-
type CartActionRequest = CartActionAddLine | CartActionChangeQuantity | CartActionRemoveLine | CartActionClear | CartActionMerge | CartActionSaveLine | CartActionRestoreLine | CartActionRemoveSavedLine | CartActionApplyCoupon | CartActionRemoveCoupon | CartActionApplyPromotion | CartActionRemovePromotion | CartActionSetLineDiscount;
|
|
740
|
+
type CartActionRequest = CartActionAddLine | CartActionChangeQuantity | CartActionRemoveLine | CartActionClear | CartActionMerge | CartActionSaveLine | CartActionRestoreLine | CartActionRemoveSavedLine | CartActionApplyCoupon | CartActionRemoveCoupon | CartActionApplyPromotion | CartActionRemovePromotion | CartActionSetLineDiscount | CartActionResume;
|
|
741
|
+
/**
|
|
742
|
+
* Reinstates a cart an abandoned-cart recovery email is about.
|
|
743
|
+
*
|
|
744
|
+
* ⚠️ **WEB-ONLY, and the one member of this union that is.** Everything else
|
|
745
|
+
* here is served by both `/basket` and `/baskets`; this mode exists only on
|
|
746
|
+
* the storefront's `POST /basket`. The operator router already routes the
|
|
747
|
+
* string `'resume'` to a DIFFERENT verb — un-parking a held POS ticket, which
|
|
748
|
+
* takes `{ cartId, terminalId }` and is not published in this union at all —
|
|
749
|
+
* so an app client sending this body reaches that handler and is refused by
|
|
750
|
+
* its schema. Do not read the shared name as a shared shape.
|
|
751
|
+
*
|
|
752
|
+
* ⚠️ **Honest about what it does NOT do:** it takes no `cartId`, because the
|
|
753
|
+
* caller is not trusted to name a cart. The opaque `token` came from a link in
|
|
754
|
+
* an email, is HMAC-signed, expires, and carries `{ storeId, cartId }` and
|
|
755
|
+
* nothing about a person.
|
|
756
|
+
*
|
|
757
|
+
* ⚠️ **Every refusal is the SAME 4xx and the same bare code** — an invalid or
|
|
758
|
+
* expired token, a cart that no longer exists, a cart already converted to an
|
|
759
|
+
* order, and a cart belonging to a DIFFERENT customer are indistinguishable on
|
|
760
|
+
* the wire, deliberately. A recovery email gets forwarded; the response must
|
|
761
|
+
* never tell the reader whether the cart is real. A consumer must therefore
|
|
762
|
+
* render exactly one neutral message and must not try to explain the failure.
|
|
763
|
+
*
|
|
764
|
+
* ⚠️ On success it answers the ordinary {@link CartActionResponse}. If the
|
|
765
|
+
* caller already holds another cart with lines, the recovered lines are FOLDED
|
|
766
|
+
* into it with `merge` semantics — so the response can legitimately carry
|
|
767
|
+
* `droppedSkus` for products that have disappeared since the cart went cold,
|
|
768
|
+
* and the returned cart may be a different `cartId` from the one the token
|
|
769
|
+
* named.
|
|
770
|
+
*
|
|
771
|
+
* ⚠️ `version` and `idempotencyKey` are inherited from
|
|
772
|
+
* {@link CartActionBase} and are accepted, but a resume names no line, so
|
|
773
|
+
* there is nothing for a client to rebase against.
|
|
774
|
+
*/
|
|
775
|
+
interface CartActionResume extends CartActionBase {
|
|
776
|
+
mode: 'resume';
|
|
777
|
+
/** The opaque signed token from the recovery email's link. Never a cart id. */
|
|
778
|
+
token: string;
|
|
779
|
+
}
|
|
721
780
|
/**
|
|
722
781
|
* Fields common to every action.
|
|
723
782
|
*
|
package/dist/cjs/marketing.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CART_APPLICABLE_PROMOTION_TYPES = exports.PROMOTION_TYPES = exports.AUTOMATION_RULE_STATUSES = exports.AUTOMATION_SEND_STATUSES = exports.ATTRIBUTION_WINDOW_HOURS = exports.RFM_SEGMENT_LABELS = exports.AUTOMATION_TRIGGERS = void 0;
|
|
3
|
+
exports.ABANDONED_CART_SNAPSHOT_NAME_MAX = exports.ABANDONED_CART_SNAPSHOT_MAX_LINES = exports.CART_APPLICABLE_PROMOTION_TYPES = exports.PROMOTION_TYPES = exports.AUTOMATION_RULE_STATUSES = exports.AUTOMATION_SEND_STATUSES = exports.ATTRIBUTION_WINDOW_HOURS = exports.RFM_SEGMENT_LABELS = exports.AUTOMATION_TRIGGERS = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* The {@link AutomationTrigger} vocabulary as a RUNTIME value, so the api's Zod
|
|
6
6
|
* enum, the configuration screen's picker and the published union all derive
|
|
@@ -98,3 +98,28 @@ exports.CART_APPLICABLE_PROMOTION_TYPES = [
|
|
|
98
98
|
'freeShipping',
|
|
99
99
|
'bundle',
|
|
100
100
|
];
|
|
101
|
+
/**
|
|
102
|
+
* How many cart lines an `'ABANDONED_CART'` send stores and renders, at most —
|
|
103
|
+
* see {@link AutomationSendCart.lines}.
|
|
104
|
+
*
|
|
105
|
+
* ⚠️ **A storage and transport bound, not an editorial one.** The snapshot is
|
|
106
|
+
* copied onto three DynamoDB rows and into an SQS message, and SQS's ceiling is
|
|
107
|
+
* 256 KB per message with the whole batch sharing it; a 46-line cart (the cart
|
|
108
|
+
* cap) of long product names would be several kilobytes of that, per send, for
|
|
109
|
+
* a mail nobody reads past the fold. Five lines plus an "and N more" count says
|
|
110
|
+
* everything a recovery nudge needs and keeps every row and message small.
|
|
111
|
+
*
|
|
112
|
+
* ⚠️ Lowering it is forward-only like everything else here: rows already
|
|
113
|
+
* written keep however many lines they were captured with, and a renderer must
|
|
114
|
+
* not assume `lines.length <= ` this value.
|
|
115
|
+
*/
|
|
116
|
+
exports.ABANDONED_CART_SNAPSHOT_MAX_LINES = 5;
|
|
117
|
+
/**
|
|
118
|
+
* How many characters of a product NAME the snapshot keeps.
|
|
119
|
+
*
|
|
120
|
+
* Same reasoning as the line cap: a name is tenant-authored and effectively
|
|
121
|
+
* unbounded on the product row, and it is the only variable-length field in the
|
|
122
|
+
* snapshot. Truncation happens at CAPTURE so the bound is a property of what is
|
|
123
|
+
* stored, not of what one renderer happens to do with it.
|
|
124
|
+
*/
|
|
125
|
+
exports.ABANDONED_CART_SNAPSHOT_NAME_MAX = 80;
|
package/dist/lot.d.ts
CHANGED
|
@@ -100,6 +100,32 @@ declare global {
|
|
|
100
100
|
* operator quoted.
|
|
101
101
|
*/
|
|
102
102
|
landedUnitCost?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Optimistic-concurrency counter, bumped by EVERY movement that carries
|
|
105
|
+
* this `lotId`.
|
|
106
|
+
*
|
|
107
|
+
* ⚠️ **It is NOT a remaining figure and carries no units.** Remaining stays
|
|
108
|
+
* derived from the ledger ({@link LotWithRemaining.remaining}); this number
|
|
109
|
+
* only says how many lot-stamped movements the batch has seen, which is
|
|
110
|
+
* exactly what a compare-and-set needs and nothing a screen should render.
|
|
111
|
+
* Reading it as a quantity is the one misuse it invites.
|
|
112
|
+
*
|
|
113
|
+
* ⚠️ **What it is FOR.** A consume refuses a draw above the derived
|
|
114
|
+
* remaining, and that refusal is a read — no stored figure exists for a
|
|
115
|
+
* `ConditionExpression` to compare against. So the write instead conditions
|
|
116
|
+
* on the version it read still being the stored one: two simultaneous
|
|
117
|
+
* consumes of one batch can no longer both be admitted, because the second
|
|
118
|
+
* loses the compare-and-set, re-derives remaining and is answered against
|
|
119
|
+
* the fresh figure.
|
|
120
|
+
*
|
|
121
|
+
* ⚠️ **OPTIONAL, and absence means "never versioned" — never zero units and
|
|
122
|
+
* never a failed read.** The platform is forward-only and no row is
|
|
123
|
+
* migrated, so every lot written before this counter existed carries none;
|
|
124
|
+
* the first lot-stamped movement against such a lot conditions on the
|
|
125
|
+
* attribute NOT existing and writes the first version. A writer must never
|
|
126
|
+
* seed it, and a reader must never default it to a number it then compares.
|
|
127
|
+
*/
|
|
128
|
+
version?: number;
|
|
103
129
|
/** Operator note about the batch. ⚠️ Never personal data — this row has no TTL and is not scrubbed. */
|
|
104
130
|
notes?: string;
|
|
105
131
|
/** Soft delete. A lot is never hard-deleted: movement rows reference `lotId` permanently. */
|
package/dist/marketing.d.ts
CHANGED
|
@@ -521,16 +521,61 @@ declare global {
|
|
|
521
521
|
* and the analytics tab pages them. Modelled on {@link CampaignRecipient},
|
|
522
522
|
* which is the nearest precedent for a per-send record.
|
|
523
523
|
*
|
|
524
|
-
* ⚠️ **
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
524
|
+
* ⚠️ **These rows are WRITTEN now** — this docblock said "nothing writes
|
|
525
|
+
* these yet" long after the writers landed, which is exactly the rank-2 trap
|
|
526
|
+
* of a shape published ahead of its consumer and then never revisited. The
|
|
527
|
+
* lane is live end to end: a trigger arms a `'queued'` row (the cap row and
|
|
528
|
+
* the analytics row together, plus an internal due row), a cron re-checks the
|
|
529
|
+
* rule, the cap and consent at due time and enqueues, and the transport
|
|
530
|
+
* worker settles the row `'sent'`, `'failed'` or `'skipped'`.
|
|
528
531
|
*
|
|
529
532
|
* ⚠️ **Consent is re-checked LIVE at send time and never inherited.** A send
|
|
530
533
|
* the rule matched but consent refused is recorded `'skipped'` with a reason
|
|
531
534
|
* rather than dropped, so the refusal is auditable — and an ABSENT marketing
|
|
532
535
|
* channel is NOT consent.
|
|
533
536
|
*/
|
|
537
|
+
/**
|
|
538
|
+
* ONE line of the cart, frozen at the instant the sweep called it cold.
|
|
539
|
+
*
|
|
540
|
+
* ⚠️ **A SNAPSHOT, never a pointer.** The cart it was taken from goes on
|
|
541
|
+
* moving — a price list changes, a product is renamed, the shopper empties
|
|
542
|
+
* it — and the recovery mail has to describe what the shopper actually
|
|
543
|
+
* walked away from, hours or days earlier. Nothing refreshes these values
|
|
544
|
+
* and no reader may treat them as the cart's current state.
|
|
545
|
+
*/
|
|
546
|
+
interface AutomationSendCartLine {
|
|
547
|
+
/** Product name AS IT WAS. Truncated on capture; renders HTML-escaped. */
|
|
548
|
+
name: string;
|
|
549
|
+
/** Not necessarily an integer — weight-priced products carry fractions. */
|
|
550
|
+
quantity: number;
|
|
551
|
+
/** UNIT price at capture, in the cart's own currency. Never a line total. */
|
|
552
|
+
price: number;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* The cart an `'ABANDONED_CART'` send is about. Absent on every other
|
|
556
|
+
* trigger, and absent on `'ABANDONED_CART'` rows queued before this field
|
|
557
|
+
* existed — the send renders exactly as it used to when it is missing
|
|
558
|
+
* (forward-only; nothing backfills).
|
|
559
|
+
*/
|
|
560
|
+
interface AutomationSendCart {
|
|
561
|
+
cartId: string;
|
|
562
|
+
/**
|
|
563
|
+
* The FIRST {@link ABANDONED_CART_SNAPSHOT_MAX_LINES} lines only, in cart
|
|
564
|
+
* order. Bounded because this value is copied onto three stored rows and
|
|
565
|
+
* into an SQS message, and an unbounded cart would push the message past
|
|
566
|
+
* its 256 KB ceiling — where the failure is a marketing send that silently
|
|
567
|
+
* never leaves. {@link AutomationSendCart.moreLines} carries the remainder
|
|
568
|
+
* as a count so the mail can say "and N more" rather than lie by omission.
|
|
569
|
+
*/
|
|
570
|
+
lines: AutomationSendCartLine[];
|
|
571
|
+
/** How many further lines the cart held beyond `lines`. Absent means none. */
|
|
572
|
+
moreLines?: number;
|
|
573
|
+
/**
|
|
574
|
+
* The cart's own currency catalogId, for formatting `price`. Absent on a
|
|
575
|
+
* cart that never carried one; a renderer falls back to the store's.
|
|
576
|
+
*/
|
|
577
|
+
currency?: string;
|
|
578
|
+
}
|
|
534
579
|
interface AutomationSend {
|
|
535
580
|
storeId: string;
|
|
536
581
|
automationRuleId: string;
|
|
@@ -581,6 +626,28 @@ declare global {
|
|
|
581
626
|
* current cadence.
|
|
582
627
|
*/
|
|
583
628
|
reorderContext?: ReorderCadence;
|
|
629
|
+
/**
|
|
630
|
+
* The cart this send is trying to recover — its id and a frozen line
|
|
631
|
+
* snapshot. Set on an `'ABANDONED_CART'` send armed by `cartSweep`, absent
|
|
632
|
+
* on every other trigger.
|
|
633
|
+
*
|
|
634
|
+
* ⚠️ **It is what the mail renders from, and there is no second source.**
|
|
635
|
+
* The transport worker never reads the cart — by the time it runs, the row
|
|
636
|
+
* may be gone (the sweep stamps a `ttl` on it) and its contents may have
|
|
637
|
+
* moved on regardless. A send with no `cart` renders the operator's
|
|
638
|
+
* template alone, exactly as every send did before this shipped.
|
|
639
|
+
*
|
|
640
|
+
* ⚠️ **It is NOT persisted on the stored send rows, and a reader must not
|
|
641
|
+
* expect it there.** The api writes it only onto the internal DUE row —
|
|
642
|
+
* which is consumed and deleted when the message is sent — and onto the
|
|
643
|
+
* queued message itself. The cap row and the analytics row, which have no
|
|
644
|
+
* expiry and are what `GET /automation-rules?mode=sends` returns, carry no
|
|
645
|
+
* cart at all: a person's shopping list must not outlive the cart it came
|
|
646
|
+
* from, and has no place in a report about a RULE. So this field is
|
|
647
|
+
* populated in FLIGHT and is always absent on a send read back from
|
|
648
|
+
* storage.
|
|
649
|
+
*/
|
|
650
|
+
cart?: AutomationSendCart;
|
|
584
651
|
/**
|
|
585
652
|
* The order attributed to this send, if one was.
|
|
586
653
|
*
|
|
@@ -927,4 +994,29 @@ export declare const PROMOTION_TYPES: readonly ["coupon", "buyXGetY", "freeShipp
|
|
|
927
994
|
* disagree about the same cut.
|
|
928
995
|
*/
|
|
929
996
|
export declare const CART_APPLICABLE_PROMOTION_TYPES: readonly ["buyXGetY", "freeShipping", "bundle"];
|
|
997
|
+
/**
|
|
998
|
+
* How many cart lines an `'ABANDONED_CART'` send stores and renders, at most —
|
|
999
|
+
* see {@link AutomationSendCart.lines}.
|
|
1000
|
+
*
|
|
1001
|
+
* ⚠️ **A storage and transport bound, not an editorial one.** The snapshot is
|
|
1002
|
+
* copied onto three DynamoDB rows and into an SQS message, and SQS's ceiling is
|
|
1003
|
+
* 256 KB per message with the whole batch sharing it; a 46-line cart (the cart
|
|
1004
|
+
* cap) of long product names would be several kilobytes of that, per send, for
|
|
1005
|
+
* a mail nobody reads past the fold. Five lines plus an "and N more" count says
|
|
1006
|
+
* everything a recovery nudge needs and keeps every row and message small.
|
|
1007
|
+
*
|
|
1008
|
+
* ⚠️ Lowering it is forward-only like everything else here: rows already
|
|
1009
|
+
* written keep however many lines they were captured with, and a renderer must
|
|
1010
|
+
* not assume `lines.length <= ` this value.
|
|
1011
|
+
*/
|
|
1012
|
+
export declare const ABANDONED_CART_SNAPSHOT_MAX_LINES = 5;
|
|
1013
|
+
/**
|
|
1014
|
+
* How many characters of a product NAME the snapshot keeps.
|
|
1015
|
+
*
|
|
1016
|
+
* Same reasoning as the line cap: a name is tenant-authored and effectively
|
|
1017
|
+
* unbounded on the product row, and it is the only variable-length field in the
|
|
1018
|
+
* snapshot. Truncation happens at CAPTURE so the bound is a property of what is
|
|
1019
|
+
* stored, not of what one renderer happens to do with it.
|
|
1020
|
+
*/
|
|
1021
|
+
export declare const ABANDONED_CART_SNAPSHOT_NAME_MAX = 80;
|
|
930
1022
|
export {};
|
package/dist/marketing.js
CHANGED
|
@@ -95,3 +95,28 @@ export const CART_APPLICABLE_PROMOTION_TYPES = [
|
|
|
95
95
|
'freeShipping',
|
|
96
96
|
'bundle',
|
|
97
97
|
];
|
|
98
|
+
/**
|
|
99
|
+
* How many cart lines an `'ABANDONED_CART'` send stores and renders, at most —
|
|
100
|
+
* see {@link AutomationSendCart.lines}.
|
|
101
|
+
*
|
|
102
|
+
* ⚠️ **A storage and transport bound, not an editorial one.** The snapshot is
|
|
103
|
+
* copied onto three DynamoDB rows and into an SQS message, and SQS's ceiling is
|
|
104
|
+
* 256 KB per message with the whole batch sharing it; a 46-line cart (the cart
|
|
105
|
+
* cap) of long product names would be several kilobytes of that, per send, for
|
|
106
|
+
* a mail nobody reads past the fold. Five lines plus an "and N more" count says
|
|
107
|
+
* everything a recovery nudge needs and keeps every row and message small.
|
|
108
|
+
*
|
|
109
|
+
* ⚠️ Lowering it is forward-only like everything else here: rows already
|
|
110
|
+
* written keep however many lines they were captured with, and a renderer must
|
|
111
|
+
* not assume `lines.length <= ` this value.
|
|
112
|
+
*/
|
|
113
|
+
export const ABANDONED_CART_SNAPSHOT_MAX_LINES = 5;
|
|
114
|
+
/**
|
|
115
|
+
* How many characters of a product NAME the snapshot keeps.
|
|
116
|
+
*
|
|
117
|
+
* Same reasoning as the line cap: a name is tenant-authored and effectively
|
|
118
|
+
* unbounded on the product row, and it is the only variable-length field in the
|
|
119
|
+
* snapshot. Truncation happens at CAPTURE so the bound is a property of what is
|
|
120
|
+
* stored, not of what one renderer happens to do with it.
|
|
121
|
+
*/
|
|
122
|
+
export const ABANDONED_CART_SNAPSHOT_NAME_MAX = 80;
|