@tiledev/sdk-apptile-live-selling 0.15.4 → 0.16.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 (173) hide show
  1. package/README.md +48 -5
  2. package/dist/attribution.d.ts +16 -2
  3. package/dist/attribution.d.ts.map +1 -1
  4. package/dist/attribution.js +10 -4
  5. package/dist/attribution.js.map +1 -1
  6. package/dist/auctions.d.ts.map +1 -1
  7. package/dist/auctions.js +2 -1
  8. package/dist/auctions.js.map +1 -1
  9. package/dist/cartAttributes.d.ts +10 -0
  10. package/dist/cartAttributes.d.ts.map +1 -1
  11. package/dist/cartAttributes.js +20 -1
  12. package/dist/cartAttributes.js.map +1 -1
  13. package/dist/checkoutRefused.d.ts +9 -0
  14. package/dist/checkoutRefused.d.ts.map +1 -0
  15. package/dist/checkoutRefused.js +16 -0
  16. package/dist/checkoutRefused.js.map +1 -0
  17. package/dist/clips.d.ts +4 -2
  18. package/dist/clips.d.ts.map +1 -1
  19. package/dist/clips.js +76 -15
  20. package/dist/clips.js.map +1 -1
  21. package/dist/giveawayPrizes.d.ts +20 -0
  22. package/dist/giveawayPrizes.d.ts.map +1 -0
  23. package/dist/giveawayPrizes.js +50 -0
  24. package/dist/giveawayPrizes.js.map +1 -0
  25. package/dist/index.d.ts +13 -7
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +36 -4
  28. package/dist/index.js.map +1 -1
  29. package/dist/livePages.d.ts +11 -1
  30. package/dist/livePages.d.ts.map +1 -1
  31. package/dist/livePages.js +29 -0
  32. package/dist/livePages.js.map +1 -1
  33. package/dist/liveShow.d.ts +7 -0
  34. package/dist/liveShow.d.ts.map +1 -1
  35. package/dist/liveShow.js +10 -0
  36. package/dist/liveShow.js.map +1 -1
  37. package/dist/missedPolls.d.ts +27 -0
  38. package/dist/missedPolls.d.ts.map +1 -0
  39. package/dist/missedPolls.js +16 -0
  40. package/dist/missedPolls.js.map +1 -0
  41. package/dist/pageOptions.d.ts +31 -0
  42. package/dist/pageOptions.d.ts.map +1 -1
  43. package/dist/pageOptions.js +25 -1
  44. package/dist/pageOptions.js.map +1 -1
  45. package/dist/pageTypes.d.ts +1 -1
  46. package/dist/pageTypes.d.ts.map +1 -1
  47. package/dist/react/LiveSellingProvider.d.ts +16 -2
  48. package/dist/react/LiveSellingProvider.d.ts.map +1 -1
  49. package/dist/react/LiveSellingProvider.js +15 -4
  50. package/dist/react/LiveSellingProvider.js.map +1 -1
  51. package/dist/react/index.d.ts +6 -5
  52. package/dist/react/index.d.ts.map +1 -1
  53. package/dist/react/index.js +6 -2
  54. package/dist/react/index.js.map +1 -1
  55. package/dist/react/index.web.d.ts +5 -4
  56. package/dist/react/index.web.d.ts.map +1 -1
  57. package/dist/react/index.web.js +5 -2
  58. package/dist/react/index.web.js.map +1 -1
  59. package/dist/react/replayPlayer.d.ts +2 -0
  60. package/dist/react/replayPlayer.d.ts.map +1 -1
  61. package/dist/react/replayPlayer.js +11 -1
  62. package/dist/react/replayPlayer.js.map +1 -1
  63. package/dist/react/shopifyProviders.d.ts +18 -5
  64. package/dist/react/shopifyProviders.d.ts.map +1 -1
  65. package/dist/react/shopifyProviders.js +17 -4
  66. package/dist/react/shopifyProviders.js.map +1 -1
  67. package/dist/react/showPages.d.ts.map +1 -1
  68. package/dist/react/showPages.js +4 -2
  69. package/dist/react/showPages.js.map +1 -1
  70. package/dist/react/useAuctionBidGate.d.ts +8 -2
  71. package/dist/react/useAuctionBidGate.d.ts.map +1 -1
  72. package/dist/react/useAuctionBidGate.js +59 -2
  73. package/dist/react/useAuctionBidGate.js.map +1 -1
  74. package/dist/react/useAuctionWins.d.ts +5 -3
  75. package/dist/react/useAuctionWins.d.ts.map +1 -1
  76. package/dist/react/useAuctionWins.js +7 -2
  77. package/dist/react/useAuctionWins.js.map +1 -1
  78. package/dist/react/useClips.d.ts +7 -1
  79. package/dist/react/useClips.d.ts.map +1 -1
  80. package/dist/react/useClips.js +20 -7
  81. package/dist/react/useClips.js.map +1 -1
  82. package/dist/react/useFeaturedClip.d.ts +5 -1
  83. package/dist/react/useFeaturedClip.d.ts.map +1 -1
  84. package/dist/react/useFeaturedClip.js +6 -4
  85. package/dist/react/useFeaturedClip.js.map +1 -1
  86. package/dist/react/useGiveawayPrizes.d.ts +4 -0
  87. package/dist/react/useGiveawayPrizes.d.ts.map +1 -0
  88. package/dist/react/useGiveawayPrizes.js +58 -0
  89. package/dist/react/useGiveawayPrizes.js.map +1 -0
  90. package/dist/react/useLiveAuction.d.ts.map +1 -1
  91. package/dist/react/useLiveAuction.js +12 -6
  92. package/dist/react/useLiveAuction.js.map +1 -1
  93. package/dist/react/useLiveChat.d.ts +1 -1
  94. package/dist/react/useLiveChat.d.ts.map +1 -1
  95. package/dist/react/useLiveChat.js +30 -9
  96. package/dist/react/useLiveChat.js.map +1 -1
  97. package/dist/react/useLivePage.d.ts +8 -6
  98. package/dist/react/useLivePage.d.ts.map +1 -1
  99. package/dist/react/useLivePage.js +33 -18
  100. package/dist/react/useLivePage.js.map +1 -1
  101. package/dist/react/useLiveSession.d.ts.map +1 -1
  102. package/dist/react/useLiveSession.js +51 -0
  103. package/dist/react/useLiveSession.js.map +1 -1
  104. package/dist/react/useLiveShop.d.ts +2 -1
  105. package/dist/react/useLiveShop.d.ts.map +1 -1
  106. package/dist/react/useLiveShop.js +4 -2
  107. package/dist/react/useLiveShop.js.map +1 -1
  108. package/dist/react/useReplayPage.d.ts +22 -3
  109. package/dist/react/useReplayPage.d.ts.map +1 -1
  110. package/dist/react/useReplayPage.js +109 -102
  111. package/dist/react/useReplayPage.js.map +1 -1
  112. package/dist/react/useSilentAuctionLot.d.ts +2 -0
  113. package/dist/react/useSilentAuctionLot.d.ts.map +1 -1
  114. package/dist/react/useSilentAuctionLot.js +17 -1
  115. package/dist/react/useSilentAuctionLot.js.map +1 -1
  116. package/dist/react/useSilentAuctionLots.d.ts +2 -0
  117. package/dist/react/useSilentAuctionLots.d.ts.map +1 -1
  118. package/dist/react/useSilentAuctionLots.js +1 -0
  119. package/dist/react/useSilentAuctionLots.js.map +1 -1
  120. package/dist/react/useSilentAuctionRounds.d.ts +2 -1
  121. package/dist/react/useSilentAuctionRounds.d.ts.map +1 -1
  122. package/dist/react/useSilentAuctionRounds.js +1 -1
  123. package/dist/react/useSilentAuctionRounds.js.map +1 -1
  124. package/dist/react/useStreamInfo.d.ts.map +1 -1
  125. package/dist/react/useStreamInfo.js +5 -3
  126. package/dist/react/useStreamInfo.js.map +1 -1
  127. package/dist/shopifyCommerce.d.ts +18 -5
  128. package/dist/shopifyCommerce.d.ts.map +1 -1
  129. package/dist/shopifyCommerce.js +45 -11
  130. package/dist/shopifyCommerce.js.map +1 -1
  131. package/dist/showCredit.d.ts +4 -2
  132. package/dist/showCredit.d.ts.map +1 -1
  133. package/dist/showCredit.js +2 -2
  134. package/dist/showCredit.js.map +1 -1
  135. package/dist/showLots.d.ts +16 -0
  136. package/dist/showLots.d.ts.map +1 -1
  137. package/dist/showLots.js +19 -0
  138. package/dist/showLots.js.map +1 -1
  139. package/dist/silentAuctionFeed.d.ts +2 -0
  140. package/dist/silentAuctionFeed.d.ts.map +1 -1
  141. package/dist/silentAuctionFeed.js +12 -2
  142. package/dist/silentAuctionFeed.js.map +1 -1
  143. package/dist/silentAuctionRules.d.ts +46 -0
  144. package/dist/silentAuctionRules.d.ts.map +1 -1
  145. package/dist/silentAuctionRules.js +65 -1
  146. package/dist/silentAuctionRules.js.map +1 -1
  147. package/dist/storeData.d.ts +16 -0
  148. package/dist/storeData.d.ts.map +1 -0
  149. package/dist/storeData.js +19 -0
  150. package/dist/storeData.js.map +1 -0
  151. package/dist/types.d.ts +27 -0
  152. package/dist/types.d.ts.map +1 -1
  153. package/dist/types.js.map +1 -1
  154. package/dist/ui/LiveBubble.d.ts +7 -1
  155. package/dist/ui/LiveBubble.d.ts.map +1 -1
  156. package/dist/ui/LiveBubble.js +19 -4
  157. package/dist/ui/LiveBubble.js.map +1 -1
  158. package/dist/unreadRoomMessages.d.ts +26 -0
  159. package/dist/unreadRoomMessages.d.ts.map +1 -0
  160. package/dist/unreadRoomMessages.js +62 -0
  161. package/dist/unreadRoomMessages.js.map +1 -0
  162. package/dist/viewerRules.d.ts +38 -0
  163. package/dist/viewerRules.d.ts.map +1 -0
  164. package/dist/viewerRules.js +46 -0
  165. package/dist/viewerRules.js.map +1 -0
  166. package/dist/winsAttribution.d.ts +22 -0
  167. package/dist/winsAttribution.d.ts.map +1 -0
  168. package/dist/winsAttribution.js +49 -0
  169. package/dist/winsAttribution.js.map +1 -0
  170. package/dist/zegoEngine.d.ts.map +1 -1
  171. package/dist/zegoEngine.js +14 -7
  172. package/dist/zegoEngine.js.map +1 -1
  173. package/package.json +4 -4
package/README.md CHANGED
@@ -470,7 +470,8 @@ const routes: LiveSellingRoutes = {
470
470
  openReplay: (feedId) => navigationRef.dispatch(CommonActions.navigate('Replay', { feedId }, { pop: true })),
471
471
  replaceWithReplay: (feedId, nav) => nav.dispatch(StackActions.replace('Replay', { feedId })),
472
472
  backToLiveTab: (nav) => nav.dispatch(StackActions.popTo('Tabs', { screen: 'LiveTab' })),
473
- openHome: (nav) => nav.navigate('Tabs', { screen: 'Home' }),
473
+ // Back to the tabs already there: a navigate pushes a second Tabs over Live (0.16.0: every back goes Home).
474
+ openHome: (nav) => nav.dispatch(StackActions.popTo('Tabs', { screen: 'Home' })),
474
475
  openCart: ({ itemsYouWon }, nav) => nav.navigate('Cart', itemsYouWon ? { screen: 'ItemsYouWon' } : undefined),
475
476
  openVariantPage: (params, nav) => nav.navigate('VariantSelector', params),
476
477
  openSignIn: (method, nav) => nav.navigate('SignIn', { method }),
@@ -493,6 +494,10 @@ const routes: LiveSellingRoutes = {
493
494
  shopName={APP_NAME}
494
495
  // 0.15.0: the names nobody watching may go by, from a list the app publishes (`blockedNamesFrom`).
495
496
  blockedNames={blockedNamesFrom(publishedBlockedNames)}
497
+ // 0.16.0, optional: a limit on each viewer's reactions, refilled when the host features another product;
498
+ // past it a tap sends nothing and onReactionLimitReached is called. Unset: no limit.
499
+ reactionLimit={15}
500
+ onReactionLimitReached={() => showToast('Please wait before reacting again.')}
496
501
  >
497
502
  <ShopifyLiveSessionProvider>
498
503
  <ReplayPlayerProvider>
@@ -692,6 +697,7 @@ typed with `useAuctionWins<Product>()` / `useLiveSession<Product>()`.
692
697
  | `shopify` | yes | The app's sdk-shopify client (`shopify`): its `products.byIds` and `cart.create` |
693
698
  | `cartSourceName` | yes | `source_name` on the wins cart |
694
699
  | `prizeWriteKey` | yes | The line attribute this store's cart transform reads for a prize. No default: a wrong one charges a winner full price |
700
+ | `winningBidKey` | no | The line attribute the store's cart transform reprices a win by. Default `_winningBid` (0.16.0) |
695
701
  | `buyer` | yes | Who pays: `{ customerAccessToken, email? }`, or null for a guest cart. `createShopifyLiveIdentity(...).buyer` |
696
702
  | `imageTransform` | no | The products' photo size, passed to `products.byIds` |
697
703
  | `extraLineAttributes` | no | `(win) => ShopifyAttribute[]`: more attributes on each win's line, after the adapter's own (a final-sale stamp, say) |
@@ -701,8 +707,9 @@ typed with `useAuctionWins<Product>()` / `useLiveSession<Product>()`.
701
707
  left out, and each `LiveProduct` keeps the Shopify `Product` on `raw`. Each variant carries its own
702
708
  photo, when it has one (`imageUrl`, 0.9.0).
703
709
  - `createAuctionCheckout(wins, auctionId)`: the contract above. A cart of its own; each win a line of
704
- one stamped `_winningBid` (or `prizeWriteKey: "true"`) and `_winIndex`; the giveaway discount codes;
705
- `source_name`, `source_type: "auction"`, `auction_id`; the buyer when there is one (a guest cart when
710
+ one stamped `_winningBid` (`winningBidKey`; or `prizeWriteKey: "true"`), `_winIndex` and a silent
711
+ auction's `_lotNumber` (0.16.0); the giveaway discount codes; `source_name`, `source_type: "auction"`,
712
+ `auction_id` (every show the lines were won on, comma-joined, 0.16.0); the buyer when there is one (a guest cart when
706
713
  there isn't, or reading it fails). Each win is charged on the variant `useAuctionWins` shows: the
707
714
  recorded one when it belongs to the product, else the first that can be sold, else the first. Throws
708
715
  when there is nothing to check out or none of the wins can be sold.
@@ -787,13 +794,18 @@ const gate = useAuctionBidGate({
787
794
  screenOnShow: isFocused, // back on show still signed out: the held bid is dropped
788
795
  });
789
796
 
790
- // gate.blocker: 'signIn' | 'unpaidWins' | 'terms' | 'variant' | null
797
+ // gate.blocker: 'signIn' | 'blocked' | 'checkingAccount' | 'accountUnknown' | 'unpaidWins' | 'terms' | 'variant' | null
791
798
  gate.requestBid(); // the round's minimum — the slide gesture
792
799
  gate.requestBid(250); // a custom bid
793
800
  gate.refusal; // { id, reason: 'outbid' | 'overCap', amount } | null (atAmountShown)
794
801
  gate.bidOnItsWay; // true for BID_ON_ITS_WAY_MS (1.2 s) after a bid goes
795
802
  ```
796
803
 
804
+ The store's bar (0.16.0): the provider's `viewerRestrictions` (on Shopify, the customer's `BIDBLOCKED` /
805
+ `APPBLOCKED` tags, read by `viewerRestrictionsFromTags`). Barred, a bid stops at `blocked`, before unpaid wins. Not read yet, it waits at
806
+ `checkingAccount` ("Checking your account…") while they are read again, then goes on (or stops at `blocked`);
807
+ not read within `ACCOUNT_CHECK_LIMIT_MS` (10 s) it is dropped at `accountUnknown`.
808
+
797
809
  Signed in → nothing outstanding on another stream → rules accepted once per install → a variant chosen
798
810
  (once per round, not per bid). The requested bid is held while you clear the blockers and then placed, so
799
811
  finishing the last panel completes the bid they originally asked for. A held bid belongs to its round:
@@ -877,8 +889,11 @@ const lots = useSilentAuctionLots({ order, screenOnShow: useIsFocused(), pollInt
877
889
  // lots.status, lots.items ({ lot, product }), lots.upcoming, lots.refresh(), lots.readingAhead, lots.hasMore
878
890
 
879
891
  // The product page's console.
892
+ // The page reads the auction metafields on its own read (0.16.0; never with every product: winners' emails):
893
+ const page = useProductPage(handle, { metafields: AUCTION_METAFIELDS.product, variantMetafields: AUCTION_METAFIELDS.variant });
880
894
  const auction = useSilentAuctionLot(product?.id ?? null, { customerId, signedIn, email, variantId, screenOnShow: useIsFocused() });
881
- const bar = productPageBuyBar({ lot: auction.lot, lotStatus: auction.status, ...gatesFromTheProduct, nowMs: Date.now() });
895
+ const bar = productPageBuyBar({ lot: auction.lot, lotStatus: auction.status, ...productAuctionGates(page.product, variantId), nowMs: Date.now() });
896
+ // A copy read without them (a card's, the device's) is not known: neither bar shows until the page's read lands.
882
897
  // auction.nextBid, auction.bidCap, auction.leading, auction.phase, auction.extended, auction.placeBid(amount?)
883
898
 
884
899
  // My Bids.
@@ -1109,6 +1124,34 @@ can be driven with no room, socket or React — from Node, import it as
1109
1124
  - **Consuming via `file:` or a workspace link?** Hoist `@types/react`. The `.d.ts` otherwise resolves
1110
1125
  against the SDK's own nested copy, and React 18's `ReactNode` isn't assignable to React 19's.
1111
1126
 
1127
+ **A product's featured clip** (0.15.3; read as 33.2.0 did since 0.16.0): `useFeaturedClip(product.id, { enabled })`
1128
+ (or `liveSelling.clips.featuredForProduct`) is the clip the merchant ranked first for that product, cut to its
1129
+ window (`videoUrl`, `startMs`, `endMs`), with its products and `recordingId` / `streamingId` to open it on Replay
1130
+ (the route's `clip`), or null. `isCopyOfClip(media, clip)` spots Shopify's own copy of it among the product's videos.
1131
+
1132
+ **The store-data standard** (0.16.0, `storeData.ts`): `BID_BLOCKED_TAG`, `APP_BLOCKED_TAG`, `LOT_TAG`,
1133
+ `AUCTION_METAFIELDS` and `viewerRestrictionsFrom(tags)`. Every store sets its Shopify data up to match;
1134
+ sdk-shopify names none of them, so the app passes them where it reads (the product page's own metafields, a
1135
+ search `queryTemplate` such as `{query}* -tag:${LOT_TAG}` for a store that hides lots from search).
1136
+
1137
+ **A wins checkout that can't be trusted is refused** (0.16.0): `createAuctionCheckout` throws
1138
+ `CheckoutRefusedError` (its message is for the shopper) for a won item that can't be bought any more, a win with
1139
+ no winning price above 0, or no auction id; `useAuctionWins().error` shows the message.
1140
+
1141
+ **Also new in 0.16.0** (details in the CHANGELOG):
1142
+
1143
+ | What | Where |
1144
+ | --- | --- |
1145
+ | A barred or not-yet-read viewer's bid | the gate's `blocked`, `checkingAccount`, `accountUnknown` steps; `ACCOUNT_CHECK_LIMIT_MS`, `RESTRICTIONS_REFRESH_MS` |
1146
+ | The reaction limit | `reactionButton.limitNotice` (`{ id, message }`); `createReactionBudget()` |
1147
+ | Recent clips for a store with no reel | `clips.recent()`, `useClips({ source: 'recent', enabled })` |
1148
+ | Replay of a clip | the Replay route's `clip` (a `ClipItem`); `replayClipWindow`, `replayOfClip` |
1149
+ | Replay's taps and end | `useReplayPage({ tapVideo: 'showControls', controlsShowMs })`; `player.finished` |
1150
+ | A silent auction's last bid variant | `useSilentAuctionLot().bidVariantId` |
1151
+ | Lots kept on a failed refresh | `useSilentAuctionLots().refreshFailed` |
1152
+ | The wins cart | `_lotNumber` (`LOT_NUMBER_KEY`), `winningBidKey`, `auctionIdsOf`, `CheckoutRefusedError` |
1153
+ | Giveaway prizes onto the cart | `config.giveawayPrizes`, `collectGiveawayPrizes`, `useGiveawayPrizes({ active })` (default: the screen's focus) |
1154
+
1112
1155
  ## Not included
1113
1156
 
1114
1157
  UI beyond the bubbles (`/ui`) · a storefront · navigation (the pages take the app's `routes`) · a static
@@ -6,13 +6,27 @@ export type AttributionSource = {
6
6
  } | {
7
7
  type: 'replay';
8
8
  showId: string;
9
+ } | {
10
+ type: 'auction';
11
+ showId: string;
12
+ } | {
13
+ type: 'auction-replay';
14
+ showId: string;
15
+ } | {
16
+ type: 'silent-auction';
17
+ showId: string;
9
18
  } | {
10
19
  type: 'app';
11
20
  };
21
+ /** A show on air: `auction` for an auction show (`isAuction`), else `live`; by its streamingId. */
12
22
  export declare function liveAttributionSourceFor(stream: {
13
23
  streamingId: string;
14
24
  status: LiveStreamStatus;
25
+ isAuction?: boolean;
15
26
  } | null): AttributionSource | null;
16
- /** Takes the streamingId of the show the replay is of, never the replay feed id. */
17
- export declare function replayAttributionSourceFor(showStreamingId: string | null): AttributionSource | null;
27
+ /**
28
+ * Takes the streamingId of the show the replay is of, never the replay feed id: `auction-replay` for an
29
+ * auction show's recording, else `replay`.
30
+ */
31
+ export declare function replayAttributionSourceFor(showStreamingId: string | null, isAuction?: boolean): AttributionSource | null;
18
32
  //# sourceMappingURL=attribution.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../src/attribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,uGAAuG;AACvG,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAEpB,wBAAgB,wBAAwB,CACtC,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,GAAG,IAAI,GAC/D,iBAAiB,GAAG,IAAI,CAE1B;AAED,oFAAoF;AACpF,wBAAgB,0BAA0B,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,iBAAiB,GAAG,IAAI,CAEnG"}
1
+ {"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../src/attribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,uGAAuG;AACvG,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAEpB,mGAAmG;AACnG,wBAAgB,wBAAwB,CACtC,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GACpF,iBAAiB,GAAG,IAAI,CAG1B;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,UAAQ,GAAG,iBAAiB,GAAG,IAAI,CAEtH"}
@@ -2,11 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.liveAttributionSourceFor = liveAttributionSourceFor;
4
4
  exports.replayAttributionSourceFor = replayAttributionSourceFor;
5
+ /** A show on air: `auction` for an auction show (`isAuction`), else `live`; by its streamingId. */
5
6
  function liveAttributionSourceFor(stream) {
6
- return (stream === null || stream === void 0 ? void 0 : stream.status) === 'live' ? { type: 'live', showId: stream.streamingId } : null;
7
+ if ((stream === null || stream === void 0 ? void 0 : stream.status) !== 'live')
8
+ return null;
9
+ return { type: stream.isAuction ? 'auction' : 'live', showId: stream.streamingId };
7
10
  }
8
- /** Takes the streamingId of the show the replay is of, never the replay feed id. */
9
- function replayAttributionSourceFor(showStreamingId) {
10
- return showStreamingId ? { type: 'replay', showId: showStreamingId } : null;
11
+ /**
12
+ * Takes the streamingId of the show the replay is of, never the replay feed id: `auction-replay` for an
13
+ * auction show's recording, else `replay`.
14
+ */
15
+ function replayAttributionSourceFor(showStreamingId, isAuction = false) {
16
+ return showStreamingId ? { type: isAuction ? 'auction-replay' : 'replay', showId: showStreamingId } : null;
11
17
  }
12
18
  //# sourceMappingURL=attribution.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"attribution.js","sourceRoot":"","sources":["../src/attribution.ts"],"names":[],"mappings":";;AAQA,4DAIC;AAGD,gEAEC;AATD,SAAgB,wBAAwB,CACtC,MAAgE;IAEhE,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,MAAK,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACzF,CAAC;AAED,oFAAoF;AACpF,SAAgB,0BAA0B,CAAC,eAA8B;IACvE,OAAO,eAAe,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9E,CAAC"}
1
+ {"version":3,"file":"attribution.js","sourceRoot":"","sources":["../src/attribution.ts"],"names":[],"mappings":";;AAYA,4DAKC;AAMD,gEAEC;AAdD,mGAAmG;AACnG,SAAgB,wBAAwB,CACtC,MAAqF;IAErF,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,MAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;AACrF,CAAC;AAED;;;GAGG;AACH,SAAgB,0BAA0B,CAAC,eAA8B,EAAE,SAAS,GAAG,KAAK;IAC1F,OAAO,eAAe,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7G,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"auctions.d.ts","sourceRoot":"","sources":["../src/auctions.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAA+B,WAAW,EAAE,MAAM,SAAS,CAAC;AA8FxE,eAAO,MAAM,QAAQ,EAAE,WAkGtB,CAAC"}
1
+ {"version":3,"file":"auctions.d.ts","sourceRoot":"","sources":["../src/auctions.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAA+B,WAAW,EAAE,MAAM,SAAS,CAAC;AA8FxE,eAAO,MAAM,QAAQ,EAAE,WAkGtB,CAAC"}
package/dist/auctions.js CHANGED
@@ -13,6 +13,7 @@ exports.auctions = void 0;
13
13
  * token and so goes through the injected `customerAccountRequest`.
14
14
  */
15
15
  const client_1 = require("./client");
16
+ const cartAttributes_1 = require("./cartAttributes");
16
17
  const TERMS_KEY = 'auction.termsAccepted';
17
18
  // ─── Unpaid wins (customer-account metafield) ────────────────────────────────
18
19
  const UNPAID_WINS_QUERY = /* GraphQL */ `
@@ -25,7 +26,7 @@ const UNPAID_WINS_QUERY = /* GraphQL */ `
25
26
  }
26
27
  `;
27
28
  /** A silent auction's wins are recorded under a key of their own, `silent_…` (0.12.0). */
28
- const SILENT_KEY_PREFIX = 'silent_';
29
+ const SILENT_KEY_PREFIX = cartAttributes_1.SILENT_AUCTION_KEY_PREFIX;
29
30
  async function fetchWinnerMetafield() {
30
31
  var _a, _b;
31
32
  const customerAccountRequest = (0, client_1.getCustomerAccountRequest)();
@@ -1 +1 @@
1
- {"version":3,"file":"auctions.js","sourceRoot":"","sources":["../src/auctions.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,qCAOkB;AAKlB,MAAM,SAAS,GAAG,uBAAuB,CAAC;AAE1C,gFAAgF;AAEhF,MAAM,iBAAiB,GAAG,aAAa,CAAC;;;;;;;;CAQvC,CAAC;AAgBF,0FAA0F;AAC1F,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAEpC,KAAK,UAAU,oBAAoB;;IACjC,MAAM,sBAAsB,GAAG,IAAA,kCAAyB,GAAE,CAAC;IAC3D,IAAI,CAAC,sBAAsB;QAAE,OAAO,IAAI,CAAC;IACzC,MAA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AE,OAAO,IAAI,CAAC;QAC9B,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;CACF,CAAC"}
@@ -7,11 +7,21 @@ import type { CartLineAttribute, CommerceAdapter } from './sessionTypes';
7
7
  import type { LiveStreamStatus } from './types';
8
8
  export declare const LIVE_STREAM_ID_ATTRIBUTE = "_stream_id";
9
9
  export declare const REPLAY_ID_ATTRIBUTE = "_replay_id";
10
+ /** A silent auction's win, by the auction's id (its `silent_…` key without the prefix). */
11
+ export declare const SILENT_AUCTION_ID_ATTRIBUTE = "_silent_auction_id";
10
12
  /** Gates on the record's own status, not the session's derived one: only a show on air earns the tag. */
11
13
  export declare function liveCartAttributesFor(stream: {
12
14
  streamingId: string;
13
15
  status: LiveStreamStatus;
14
16
  } | null): CartLineAttribute[];
17
+ /** A silent auction's wins are recorded under a key of their own, `silent_…` (0.12.0): no live show. */
18
+ export declare const SILENT_AUCTION_KEY_PREFIX = "silent_";
19
+ /**
20
+ * Where a won lot came from, for its line of the wins cart (0.16.0), so the order says what sold it: the
21
+ * live show's `_stream_id`, as an add during the show carries it, or a silent auction's
22
+ * `_silent_auction_id`. None without either.
23
+ */
24
+ export declare function wonLotAttributesFor(streamingId: string | null | undefined): CartLineAttribute[];
15
25
  export declare function replayCartAttributesFor(replayId: string | null): CartLineAttribute[];
16
26
  export declare function addLiveLine(adapter: CommerceAdapter<unknown> | null, stream: {
17
27
  streamingId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"cartAttributes.d.ts","sourceRoot":"","sources":["../src/cartAttributes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,wBAAwB,eAAe,CAAC;AACrD,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAEhD,yGAAy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iB,EAAE,CAEpF;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,IAAI,EACxC,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,GAAG,IAAI,EAChE,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC,CAGlB"}
@@ -1,17 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REPLAY_ID_ATTRIBUTE = exports.LIVE_STREAM_ID_ATTRIBUTE = void 0;
3
+ exports.SILENT_AUCTION_KEY_PREFIX = exports.SILENT_AUCTION_ID_ATTRIBUTE = exports.REPLAY_ID_ATTRIBUTE = exports.LIVE_STREAM_ID_ATTRIBUTE = void 0;
4
4
  exports.liveCartAttributesFor = liveCartAttributesFor;
5
+ exports.wonLotAttributesFor = wonLotAttributesFor;
5
6
  exports.replayCartAttributesFor = replayCartAttributesFor;
6
7
  exports.addLiveLine = addLiveLine;
7
8
  exports.LIVE_STREAM_ID_ATTRIBUTE = '_stream_id';
8
9
  exports.REPLAY_ID_ATTRIBUTE = '_replay_id';
10
+ /** A silent auction's win, by the auction's id (its `silent_…` key without the prefix). */
11
+ exports.SILENT_AUCTION_ID_ATTRIBUTE = '_silent_auction_id';
9
12
  /** Gates on the record's own status, not the session's derived one: only a show on air earns the tag. */
10
13
  function liveCartAttributesFor(stream) {
11
14
  return (stream === null || stream === void 0 ? void 0 : stream.status) === 'live'
12
15
  ? [{ key: exports.LIVE_STREAM_ID_ATTRIBUTE, value: stream.streamingId }]
13
16
  : [];
14
17
  }
18
+ /** A silent auction's wins are recorded under a key of their own, `silent_…` (0.12.0): no live show. */
19
+ exports.SILENT_AUCTION_KEY_PREFIX = 'silent_';
20
+ /**
21
+ * Where a won lot came from, for its line of the wins cart (0.16.0), so the order says what sold it: the
22
+ * live show's `_stream_id`, as an add during the show carries it, or a silent auction's
23
+ * `_silent_auction_id`. None without either.
24
+ */
25
+ function wonLotAttributesFor(streamingId) {
26
+ const id = streamingId === null || streamingId === void 0 ? void 0 : streamingId.trim();
27
+ if (!id)
28
+ return [];
29
+ if (!id.startsWith(exports.SILENT_AUCTION_KEY_PREFIX))
30
+ return [{ key: exports.LIVE_STREAM_ID_ATTRIBUTE, value: id }];
31
+ const auctionId = id.slice(exports.SILENT_AUCTION_KEY_PREFIX.length).trim();
32
+ return auctionId ? [{ key: exports.SILENT_AUCTION_ID_ATTRIBUTE, value: auctionId }] : [];
33
+ }
15
34
  function replayCartAttributesFor(replayId) {
16
35
  return replayId ? [{ key: exports.REPLAY_ID_ATTRIBUTE, value: replayId }] : [];
17
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cartAttributes.js","sourceRoot":"","sources":["../src/cartAttributes.ts"],"names":[],"mappings":";;;AAYA,sDAMC;AAED,0DAEC;AAED,kCAOC;AAvBY,QAAA,wBAAwB,GAAG,YAAY,CAAC;AACxC,QAAA,mBAAmB,GAAG,YAAY,CAAC;AAEhD,yGAAyG;AACzG,SAAgB,qBAAqB,CACnC,MAAgE;IAEhE,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,MAAK,MAAM;QAC9B,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,gCAAwB,EAAE,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;QAChE,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED,SAAgB,uBAAuB,CAAC,QAAuB;IAC7D,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,2BAAmB,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACzE,CAAC;AAEM,KAAK,UAAU,WAAW,CAC/B,OAAwC,EACxC,MAAgE,EAChE,SAAiB;IAEjB,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OA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E,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnF,CAAC;AAED,SAAgB,uBAAuB,CAAC,QAAuB;IAC7D,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,2BAAmB,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACzE,CAAC;AAEM,KAAK,UAAU,WAAW,CAC/B,OAAwC,EACxC,MAAgE,EAChE,SAAiB;IAEjB,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAA;QAAE,OAAO,KAAK,CAAC;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC;AACtE,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A wins checkout refused rather than charge a wrong price or leave a lot unsettled (0.16.0, as Spark*l's
3
+ * 33.2.0 refused it): a won item that can't be bought any more, a win with no winning price, or no auction
4
+ * to settle. Its `message` is for the shopper, saying what to do; `useAuctionWins().error` shows it as it is.
5
+ */
6
+ export declare class CheckoutRefusedError extends Error {
7
+ constructor(message: string);
8
+ }
9
+ //# sourceMappingURL=checkoutRefused.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkoutRefused.d.ts","sourceRoot":"","sources":["../src/checkoutRefused.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAI5B"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CheckoutRefusedError = void 0;
4
+ /**
5
+ * A wins checkout refused rather than charge a wrong price or leave a lot unsettled (0.16.0, as Spark*l's
6
+ * 33.2.0 refused it): a won item that can't be bought any more, a win with no winning price, or no auction
7
+ * to settle. Its `message` is for the shopper, saying what to do; `useAuctionWins().error` shows it as it is.
8
+ */
9
+ class CheckoutRefusedError extends Error {
10
+ constructor(message) {
11
+ super(message);
12
+ this.name = 'CheckoutRefusedError';
13
+ }
14
+ }
15
+ exports.CheckoutRefusedError = CheckoutRefusedError;
16
+ //# sourceMappingURL=checkoutRefused.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkoutRefused.js","sourceRoot":"","sources":["../src/checkoutRefused.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AALD,oDAKC"}
package/dist/clips.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import type { ClipItem, ClipsAPI } from './types';
2
2
  /**
3
- * The featured clip among a product's clips: the first with `pdp_rank` 1 (the gateway puts it first),
4
- * active and with a playlist; null when the merchant has featured none. Pure, for tests.
3
+ * The featured clip among a product's clips (`rows`, or the gateway's `{ data: rows }`): the first ranked 1
4
+ * (`pdp_rank` 1 or "1"; the gateway puts it first), active, with a playlist and an id; null when the merchant
5
+ * has featured none. Its window, products and poster as above; `recordingId` / `streamingId` open it on
6
+ * Replay with its chat (0.16.0). Pure, for tests.
5
7
  */
6
8
  export declare function featuredClipOf(rows: unknown): ClipItem | null;
7
9
  /** A Shopify product video is the clip worker's copy of `clip` (its alt names the clip), so not shown twice. */
@@ -1 +1 @@
1
- {"version":3,"file":"clips.d.ts","sourceRoot":"","sources":["../src/clips.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAsClD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI,CAgB7D;AAKD,gHAAgH;AAChH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAGtI;AAKD,eAAO,MAAM,KAAK,EAAE,QAkCnB,CAAC"}
1
+ {"version":3,"file":"clips.d.ts","sourceRoot":"","sources":["../src/clips.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AA+ElD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI,CAoB7D;AAKD,gHAAgH;AAChH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAGtI;AAKD,eAAO,MAAM,KAAK,EAAE,QA2DnB,CAAC"}
package/dist/clips.js CHANGED
@@ -13,28 +13,65 @@ exports.isCopyOfClip = isCopyOfClip;
13
13
  * applied, and each clip silently plays a whole show from the top.
14
14
  */
15
15
  const client_1 = require("./client");
16
+ /** Recordings read, and of those how many asked for their clips, by `clips.recent()`. */
17
+ const RECENT_CLIPS_RECORDINGS = 10;
18
+ const RECENT_CLIPS_PROBES = 4;
19
+ function chunkToClip(chunk, index, recordingId) {
20
+ var _a, _b, _c;
21
+ const source = (chunk.streaming_url || chunk.url || '').trim();
22
+ if (!source)
23
+ return null;
24
+ return {
25
+ id: chunk._id || `${recordingId}-clip-${index}`,
26
+ title: ((_a = chunk.title) === null || _a === void 0 ? void 0 : _a.trim()) || '',
27
+ posterUrl: ((_b = chunk.thumbnail) === null || _b === void 0 ? void 0 : _b.trim()) || ((_c = chunk.thumbnail_image) === null || _c === void 0 ? void 0 : _c.trim()) || null,
28
+ productIds: clipProductIds(chunk),
29
+ recordingId: chunk.feed_id || recordingId,
30
+ ...clipWindowOf(source, chunk),
31
+ };
32
+ }
16
33
  /**
17
- * Splits the trim window off the playlist URL. Read with a regex rather than `URL.searchParams`, which
18
- * React Native does not implement for reading a parsed URL back.
34
+ * A clip's window in its recording, and the playlist without the inert trim params: the row's own segment
35
+ * times when it has both (end after start), else the URL's `?start=&end=` (ms, each on its own). An end at or
36
+ * before the start is dropped. Read with a regex rather than `URL.searchParams`, which React Native does not
37
+ * implement for reading a parsed URL back.
19
38
  */
20
- function readTrimWindow(url) {
39
+ function clipWindowOf(url, segment) {
21
40
  const [videoUrl, query = ''] = url.split('?');
41
+ const start = segment === null || segment === void 0 ? void 0 : segment.segment_start_time;
42
+ const end = segment === null || segment === void 0 ? void 0 : segment.segment_end_time;
43
+ if (typeof start === 'number' && typeof end === 'number' && end > start)
44
+ return { videoUrl, startMs: start, endMs: end };
22
45
  const readMs = (key) => {
23
- const found = query.match(new RegExp(`(?:^|&)${key}=(\\d+)`));
46
+ const found = query.match(new RegExp(`(?:^|&)${key}=(\\d+(?:\\.\\d+)?)`));
24
47
  return found ? Number(found[1]) : null;
25
48
  };
26
- return { videoUrl, startMs: readMs('start'), endMs: readMs('end') };
49
+ const startMs = readMs('start');
50
+ const endMs = readMs('end');
51
+ return { videoUrl, startMs, endMs: endMs !== null && startMs !== null && endMs <= startMs ? null : endMs };
52
+ }
53
+ /** The products a clip sells: its lots (`product_info`, links left out), else `product_ids`; as Shopify gids. */
54
+ function clipProductIds(row) {
55
+ var _a, _b;
56
+ const lots = ((_a = row.product_info) !== null && _a !== void 0 ? _a : [])
57
+ .filter((info) => !!(info === null || info === void 0 ? void 0 : info.store_product_id) && info.product_type !== 'url')
58
+ .map((info) => info.store_product_id);
59
+ return (lots.length ? lots : (_b = row.product_ids) !== null && _b !== void 0 ? _b : []).map(client_1.toProductGid);
27
60
  }
28
61
  /**
29
- * The featured clip among a product's clips: the first with `pdp_rank` 1 (the gateway puts it first),
30
- * active and with a playlist; null when the merchant has featured none. Pure, for tests.
62
+ * The featured clip among a product's clips (`rows`, or the gateway's `{ data: rows }`): the first ranked 1
63
+ * (`pdp_rank` 1 or "1"; the gateway puts it first), active, with a playlist and an id; null when the merchant
64
+ * has featured none. Its window, products and poster as above; `recordingId` / `streamingId` open it on
65
+ * Replay with its chat (0.16.0). Pure, for tests.
31
66
  */
32
67
  function featuredClipOf(rows) {
33
- var _a, _b, _c, _d, _e, _f, _g, _h;
34
- if (!Array.isArray(rows))
68
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
69
+ const list = Array.isArray(rows) ? rows : rows === null || rows === void 0 ? void 0 : rows.data;
70
+ if (!Array.isArray(list))
35
71
  return null;
36
- for (const row of rows) {
37
- if (!row || row.pdp_rank !== 1 || row.is_active === false)
72
+ for (const row of list) {
73
+ // eslint-disable-next-line eqeqeq -- the gateway sends the rank as a number or a string.
74
+ if (!row || row.pdp_rank == null || row.pdp_rank != 1 || row.is_active === false)
38
75
  continue;
39
76
  const url = ((_a = row.streaming_url) === null || _a === void 0 ? void 0 : _a.trim()) || ((_b = row.url) === null || _b === void 0 ? void 0 : _b.trim());
40
77
  const id = ((_c = row._id) === null || _c === void 0 ? void 0 : _c.trim()) || ((_d = row.feed_id) === null || _d === void 0 ? void 0 : _d.trim());
@@ -44,8 +81,10 @@ function featuredClipOf(rows) {
44
81
  id,
45
82
  title: ((_e = row.title) === null || _e === void 0 ? void 0 : _e.trim()) || '',
46
83
  posterUrl: ((_f = row.thumbnail) === null || _f === void 0 ? void 0 : _f.trim()) || ((_g = row.thumbnail_image) === null || _g === void 0 ? void 0 : _g.trim()) || null,
47
- productIds: ((_h = row.product_ids) !== null && _h !== void 0 ? _h : []).map(client_1.toProductGid),
48
- ...readTrimWindow(url),
84
+ productIds: clipProductIds(row),
85
+ recordingId: ((_h = row.feed_id) === null || _h === void 0 ? void 0 : _h.trim()) || null,
86
+ streamingId: ((_j = row.streaming_id) === null || _j === void 0 ? void 0 : _j.trim()) || null,
87
+ ...clipWindowOf(url, row),
49
88
  };
50
89
  }
51
90
  return null;
@@ -83,10 +122,32 @@ exports.clips = {
83
122
  title: ((_a = item.title) === null || _a === void 0 ? void 0 : _a.trim()) || '',
84
123
  posterUrl: ((_b = item.thumbnail) === null || _b === void 0 ? void 0 : _b.trim()) || null,
85
124
  productIds: ((_c = item.product_ids) !== null && _c !== void 0 ? _c : []).map(client_1.toProductGid),
86
- ...readTrimWindow(item.url),
125
+ ...clipWindowOf(item.url),
87
126
  });
88
127
  });
89
128
  },
129
+ async recent({ recordings = RECENT_CLIPS_RECORDINGS, probes = RECENT_CLIPS_PROBES } = {}) {
130
+ var _a, _b, _c, _d;
131
+ const body = await (0, client_1.liveSellingRequest)(
132
+ // The service resolves the company from the header and never reads this path segment.
133
+ '/widget/plugin/shoppable-feeds/app', { params: { limit: recordings } });
134
+ const recordingIds = ((_b = (_a = body.data) === null || _a === void 0 ? void 0 : _a.feeds) !== null && _b !== void 0 ? _b : []).map((feed) => feed === null || feed === void 0 ? void 0 : feed.feed_id).filter((id) => !!id);
135
+ for (const recordingId of recordingIds.slice(0, probes)) {
136
+ let rows = [];
137
+ try {
138
+ const page = await (0, client_1.liveSellingRequest)('/live-streaming/plugin/shoppable-feeds/chunks', { params: { shoppable_feed_id: recordingId, page: 1 } });
139
+ rows = (_d = (_c = page.data) === null || _c === void 0 ? void 0 : _c.streaming_shoppable_feeds) !== null && _d !== void 0 ? _d : [];
140
+ }
141
+ catch {
142
+ // A recording that can't be cut into clips isn't the reel failing: the next one is asked.
143
+ continue;
144
+ }
145
+ const found = rows.map((row, index) => chunkToClip(row, index, recordingId)).filter((clip) => !!clip);
146
+ if (found.length)
147
+ return found;
148
+ }
149
+ return [];
150
+ },
90
151
  async featuredForProduct(productId) {
91
152
  const productNumber = productNumberOf(productId);
92
153
  if (!productNumber)
@@ -94,7 +155,7 @@ exports.clips = {
94
155
  const body = await (0, client_1.liveSellingRequest)('/shoppable-feeds/product/v2', {
95
156
  params: { store_product_id: productNumber, company_id: (0, client_1.getConfig)().companyId },
96
157
  });
97
- return featuredClipOf(body === null || body === void 0 ? void 0 : body.data);
158
+ return featuredClipOf(body);
98
159
  },
99
160
  };
100
161
  //# sourceMappingURL=clips.js.map
package/dist/clips.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"clips.js","sourceRoot":"","sources":["../src/clips.ts"],"names":[],"mappings":";;;AAoDA,wCAgBC;AAMD,oCAGC;AA7ED;;;;;;;;GAQG;AACH,qCAAuE;AAYvE;;;GAGG;AACH,SAAS,cAAc,CAAC,GAAW;IACjC,MAAM,CAAC,QAAQ,EAAE,KAAK,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,EAAE;QAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC;QAC9D,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACzC,CAAC,CAAC;IACF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACtE,CAAC;AAgBD;;;GAGG;AACH,SAAgB,cAAc,CAAC,IAAa;;IAC1C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,IAAiC,EAAE,CAAC;QACpD,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,KAAK,CAAC,IAAI,GAAG,CAAC,SAAS,KAAK,KAAK;YAAE,SAAS;QACpE,MAA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
+ export interface GiveawayPrizesConfig {
2
+ /** The giveaway service's base URL. */
3
+ url: string;
4
+ /** The store's Apptile app id, which the service files claims under. */
5
+ appId: string;
6
+ }
7
+ export interface GiveawayPrizeCollection {
8
+ /** Prizes owed, delivered or not. */
9
+ pending: number;
10
+ /** Claims that landed in the cart on this call: re-read the cart when there are any. */
11
+ delivered: string[];
12
+ }
13
+ /** The service's answer, read. A 409 (the cart is gone) and any other refusal: nothing collected. */
14
+ export declare function prizeCollectionFrom(status: number, body: unknown): GiveawayPrizeCollection | null;
15
+ /**
16
+ * Collects what `customerId` (Shopify's numeric id or GID) has won into `cartId`, or reports what is owed
17
+ * when there is no cart. Null when unconfigured, refused or unreachable; never throws.
18
+ */
19
+ export declare function collectGiveawayPrizes(customerId: string, cartId: string | null): Promise<GiveawayPrizeCollection | null>;
20
+ //# sourceMappingURL=giveawayPrizes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"giveawayPrizes.d.ts","sourceRoot":"","sources":["../src/giveawayPrizes.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB;IACtC,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,wFAAwF;IACxF,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,qGAAqG;AACrG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,uBAAuB,GAAG,IAAI,CAOjG;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAoB9H"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prizeCollectionFrom = prizeCollectionFrom;
4
+ exports.collectGiveawayPrizes = collectGiveawayPrizes;
5
+ /**
6
+ * Giveaway prizes onto the shopper's current cart (0.16.0). A won prize stays a claim on Apptile's
7
+ * giveaway service until an order pays for it, so it can go into whatever cart the shopper has now
8
+ * (the one they entered with is usually checked out by then). Given a cart, the service adds the line,
9
+ * its code and its prize stamp, and says what it delivered; without one it only says what is owed.
10
+ */
11
+ const client_1 = require("./client");
12
+ /** The service's answer, read. A 409 (the cart is gone) and any other refusal: nothing collected. */
13
+ function prizeCollectionFrom(status, body) {
14
+ if (status < 200 || status >= 300)
15
+ return null;
16
+ const record = (body !== null && body !== void 0 ? body : {});
17
+ return {
18
+ pending: typeof record.pending === 'number' ? record.pending : 0,
19
+ delivered: Array.isArray(record.delivered) ? record.delivered.filter((key) => typeof key === 'string') : [],
20
+ };
21
+ }
22
+ /**
23
+ * Collects what `customerId` (Shopify's numeric id or GID) has won into `cartId`, or reports what is owed
24
+ * when there is no cart. Null when unconfigured, refused or unreachable; never throws.
25
+ */
26
+ async function collectGiveawayPrizes(customerId, cartId) {
27
+ const config = (0, client_1.isConfigured)() ? (0, client_1.getConfig)().giveawayPrizes : undefined;
28
+ if (!(config === null || config === void 0 ? void 0 : config.url) || !customerId)
29
+ return null;
30
+ const url = `${config.url.replace(/\/$/, '')}/hydrate`;
31
+ try {
32
+ return await (0, client_1.withRequestTimeout)(url, async (signal) => {
33
+ const response = await fetch(url, {
34
+ method: 'POST',
35
+ headers: { 'content-type': 'application/json' },
36
+ body: JSON.stringify({ appId: config.appId, customerId: customerId.split('/').pop(), cartId }),
37
+ signal,
38
+ });
39
+ const body = await response.json().catch(() => null);
40
+ if (!response.ok && response.status !== 409)
41
+ (0, client_1.getLogger)().error(new Error(`giveaway prizes refused: ${response.status}`), { at: 'giveawayPrizes' });
42
+ return prizeCollectionFrom(response.status, body);
43
+ });
44
+ }
45
+ catch (caught) {
46
+ (0, client_1.getLogger)().error(caught, { at: 'giveaw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