@tiledev/sdk-apptile-live-selling 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +443 -34
- package/dist/auctionComments.d.ts +25 -0
- package/dist/auctionComments.d.ts.map +1 -0
- package/dist/auctionComments.js +28 -0
- package/dist/auctionComments.js.map +1 -0
- package/dist/auctionRules.d.ts +76 -0
- package/dist/auctionRules.d.ts.map +1 -0
- package/dist/auctionRules.js +106 -0
- package/dist/auctionRules.js.map +1 -0
- package/dist/auctions.d.ts.map +1 -1
- package/dist/auctions.js +19 -10
- package/dist/auctions.js.map +1 -1
- package/dist/client.d.ts +51 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +123 -23
- package/dist/client.js.map +1 -1
- package/dist/commentHistory.d.ts +66 -0
- package/dist/commentHistory.d.ts.map +1 -0
- package/dist/commentHistory.js +125 -0
- package/dist/commentHistory.js.map +1 -0
- package/dist/engine.native.d.ts.map +1 -1
- package/dist/engine.native.js +17 -845
- package/dist/engine.native.js.map +1 -1
- package/dist/giveawayPrize.d.ts +13 -0
- package/dist/giveawayPrize.d.ts.map +1 -0
- package/dist/giveawayPrize.js +18 -0
- package/dist/giveawayPrize.js.map +1 -0
- package/dist/giveawayPrizeLines.d.ts +67 -0
- package/dist/giveawayPrizeLines.d.ts.map +1 -0
- package/dist/giveawayPrizeLines.js +48 -0
- package/dist/giveawayPrizeLines.js.map +1 -0
- package/dist/giveawayRoster.d.ts +53 -0
- package/dist/giveawayRoster.d.ts.map +1 -0
- package/dist/giveawayRoster.js +93 -0
- package/dist/giveawayRoster.js.map +1 -0
- package/dist/heldComments.d.ts +29 -0
- package/dist/heldComments.d.ts.map +1 -0
- package/dist/heldComments.js +61 -0
- package/dist/heldComments.js.map +1 -0
- package/dist/hiddenShows.d.ts +34 -0
- package/dist/hiddenShows.d.ts.map +1 -0
- package/dist/hiddenShows.js +42 -0
- package/dist/hiddenShows.js.map +1 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +86 -3
- package/dist/index.js.map +1 -1
- package/dist/liveShow.d.ts +58 -0
- package/dist/liveShow.d.ts.map +1 -0
- package/dist/liveShow.js +55 -0
- package/dist/liveShow.js.map +1 -0
- package/dist/pipWindow.d.ts +85 -0
- package/dist/pipWindow.d.ts.map +1 -0
- package/dist/pipWindow.js +88 -0
- package/dist/pipWindow.js.map +1 -0
- package/dist/polls.d.ts.map +1 -1
- package/dist/polls.js +3 -0
- package/dist/polls.js.map +1 -1
- package/dist/react/LiveSellingProvider.d.ts +10 -1
- package/dist/react/LiveSellingProvider.d.ts.map +1 -1
- package/dist/react/LiveSellingProvider.js +6 -2
- package/dist/react/LiveSellingProvider.js.map +1 -1
- package/dist/react/LiveVideoTarget.d.ts.map +1 -1
- package/dist/react/LiveVideoTarget.js +41 -3
- package/dist/react/LiveVideoTarget.js.map +1 -1
- package/dist/react/clocks.d.ts +29 -0
- package/dist/react/clocks.d.ts.map +1 -0
- package/dist/react/clocks.js +124 -0
- package/dist/react/clocks.js.map +1 -0
- package/dist/react/index.d.ts +7 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +15 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.web.d.ts +9 -2
- package/dist/react/index.web.d.ts.map +1 -1
- package/dist/react/index.web.js +27 -4
- package/dist/react/index.web.js.map +1 -1
- package/dist/react/startSignIn.d.ts +3 -0
- package/dist/react/startSignIn.d.ts.map +1 -0
- package/dist/react/startSignIn.js +19 -0
- package/dist/react/startSignIn.js.map +1 -0
- package/dist/react/useAuctionBidGate.d.ts +54 -4
- package/dist/react/useAuctionBidGate.d.ts.map +1 -1
- package/dist/react/useAuctionBidGate.js +169 -25
- package/dist/react/useAuctionBidGate.js.map +1 -1
- package/dist/react/useAuctionWins.d.ts +9 -1
- package/dist/react/useAuctionWins.d.ts.map +1 -1
- package/dist/react/useAuctionWins.js +9 -3
- package/dist/react/useAuctionWins.js.map +1 -1
- package/dist/react/useGiveawayEntry.d.ts +59 -0
- package/dist/react/useGiveawayEntry.d.ts.map +1 -0
- package/dist/react/useGiveawayEntry.js +170 -0
- package/dist/react/useGiveawayEntry.js.map +1 -0
- package/dist/react/useGiveawayPrize.d.ts +12 -0
- package/dist/react/useGiveawayPrize.d.ts.map +1 -0
- package/dist/react/useGiveawayPrize.js +53 -0
- package/dist/react/useGiveawayPrize.js.map +1 -0
- package/dist/react/useHiddenShows.d.ts +10 -0
- package/dist/react/useHiddenShows.d.ts.map +1 -0
- package/dist/react/useHiddenShows.js +30 -0
- package/dist/react/useHiddenShows.js.map +1 -0
- package/dist/react/useLiveSession.d.ts +7 -3
- package/dist/react/useLiveSession.d.ts.map +1 -1
- package/dist/react/useLiveSession.js +522 -157
- package/dist/react/useLiveSession.js.map +1 -1
- package/dist/react/useLiveShow.d.ts +3 -0
- package/dist/react/useLiveShow.d.ts.map +1 -0
- package/dist/react/useLiveShow.js +21 -0
- package/dist/react/useLiveShow.js.map +1 -0
- package/dist/react/useLiveStreams.d.ts.map +1 -1
- package/dist/react/useLiveStreams.js +6 -2
- package/dist/react/useLiveStreams.js.map +1 -1
- package/dist/react/useOngoingLive.d.ts +1 -0
- package/dist/react/useOngoingLive.d.ts.map +1 -1
- package/dist/react/useOngoingLive.js +7 -1
- package/dist/react/useOngoingLive.js.map +1 -1
- package/dist/react/useReplays.d.ts +12 -0
- package/dist/react/useReplays.d.ts.map +1 -1
- package/dist/react/useReplays.js +56 -24
- package/dist/react/useReplays.js.map +1 -1
- package/dist/react/useStreamInfo.d.ts +13 -2
- package/dist/react/useStreamInfo.d.ts.map +1 -1
- package/dist/react/useStreamInfo.js +31 -5
- package/dist/react/useStreamInfo.js.map +1 -1
- package/dist/replayPages.d.ts +31 -0
- package/dist/replayPages.d.ts.map +1 -0
- package/dist/replayPages.js +34 -0
- package/dist/replayPages.js.map +1 -0
- package/dist/replays.d.ts +7 -0
- package/dist/replays.d.ts.map +1 -1
- package/dist/replays.js +52 -22
- package/dist/replays.js.map +1 -1
- package/dist/session.d.ts +39 -6
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +209 -22
- package/dist/session.js.map +1 -1
- package/dist/sessionTypes.d.ts +190 -14
- package/dist/sessionTypes.d.ts.map +1 -1
- package/dist/sessionTypes.js +2 -1
- package/dist/sessionTypes.js.map +1 -1
- package/dist/shopifyCommerce.d.ts +149 -0
- package/dist/shopifyCommerce.d.ts.map +1 -0
- package/dist/shopifyCommerce.js +123 -0
- package/dist/shopifyCommerce.js.map +1 -0
- package/dist/shopifyIdentity.d.ts +51 -0
- package/dist/shopifyIdentity.d.ts.map +1 -0
- package/dist/shopifyIdentity.js +52 -0
- package/dist/shopifyIdentity.js.map +1 -0
- package/dist/shopifyIds.d.ts +9 -0
- package/dist/shopifyIds.d.ts.map +1 -0
- package/dist/shopifyIds.js +18 -0
- package/dist/shopifyIds.js.map +1 -0
- package/dist/showLinks.d.ts +24 -0
- package/dist/showLinks.d.ts.map +1 -0
- package/dist/showLinks.js +23 -0
- package/dist/showLinks.js.map +1 -0
- package/dist/showLots.d.ts +28 -0
- package/dist/showLots.d.ts.map +1 -0
- package/dist/showLots.js +51 -0
- package/dist/showLots.js.map +1 -0
- package/dist/showNames.d.ts +45 -0
- package/dist/showNames.d.ts.map +1 -0
- package/dist/showNames.js +74 -0
- package/dist/showNames.js.map +1 -0
- package/dist/streams.d.ts +27 -1
- package/dist/streams.d.ts.map +1 -1
- package/dist/streams.js +90 -21
- package/dist/streams.js.map +1 -1
- package/dist/types.d.ts +195 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/dist/wire.d.ts +31 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +25 -0
- package/dist/wire.js.map +1 -1
- package/dist/zego.d.ts +3 -1
- package/dist/zego.d.ts.map +1 -1
- package/dist/zego.js +1 -1
- package/dist/zegoEngine.d.ts +168 -0
- package/dist/zegoEngine.d.ts.map +1 -0
- package/dist/zegoEngine.js +1052 -0
- package/dist/zegoEngine.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WIN_INDEX_KEY = exports.WINNING_BID_KEY = exports.AUCTION_CART_SOURCE_TYPE = void 0;
|
|
4
|
+
exports.liveProductFromShopify = liveProductFromShopify;
|
|
5
|
+
exports.chargedVariantId = chargedVariantId;
|
|
6
|
+
exports.createShopifyLiveCommerce = createShopifyLiveCommerce;
|
|
7
|
+
const shopifyIds_1 = require("./shopifyIds");
|
|
8
|
+
/** The attributes the order webhook matches on (`source_type`, `auction_id`). They must never change. */
|
|
9
|
+
exports.AUCTION_CART_SOURCE_TYPE = 'auction';
|
|
10
|
+
/** The line attribute the store's cart transform reprices a won lot to. */
|
|
11
|
+
exports.WINNING_BID_KEY = '_winningBid';
|
|
12
|
+
/** The line attribute that keeps two identical wins on two lines. */
|
|
13
|
+
exports.WIN_INDEX_KEY = '_winIndex';
|
|
14
|
+
/** A Shopify product as the session's thinner shape, with the product itself kept on `raw`. */
|
|
15
|
+
function liveProductFromShopify(product) {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
return {
|
|
18
|
+
id: product.id,
|
|
19
|
+
storeProductId: (0, shopifyIds_1.bareId)(product.id),
|
|
20
|
+
title: product.title,
|
|
21
|
+
price: product.priceRange.min.amount,
|
|
22
|
+
currencyCode: product.priceRange.min.currencyCode,
|
|
23
|
+
imageUrl: (_b = (_a = product.featuredImage) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : null,
|
|
24
|
+
variants: product.variants.map((variant) => {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
return ({
|
|
27
|
+
id: variant.id,
|
|
28
|
+
title: variant.title,
|
|
29
|
+
price: variant.price.amount,
|
|
30
|
+
available: variant.availableForSale,
|
|
31
|
+
imageUrl: (_b = (_a = variant.image) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : null,
|
|
32
|
+
});
|
|
33
|
+
}),
|
|
34
|
+
raw: product,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The variant a win is charged on, chosen as `useAuctionWins` chooses the one it shows: the recorded
|
|
39
|
+
* one when it belongs to the product, else the first that can be sold, else the first. The checkout
|
|
40
|
+
* can be handed the raw ledger, so it chooses again rather than trusting the id. Null when the product
|
|
41
|
+
* is gone from the store.
|
|
42
|
+
*/
|
|
43
|
+
function chargedVariantId(product, win) {
|
|
44
|
+
var _a, _b, _c;
|
|
45
|
+
if (!product)
|
|
46
|
+
return null;
|
|
47
|
+
if (win.variantId) {
|
|
48
|
+
const wanted = (0, shopifyIds_1.bareId)(String(win.variantId));
|
|
49
|
+
const recorded = product.variants.find((variant) => (0, shopifyIds_1.bareId)(variant.id) === wanted);
|
|
50
|
+
if (recorded)
|
|
51
|
+
return recorded.id;
|
|
52
|
+
}
|
|
53
|
+
return (_c = (_b = ((_a = product.variants.find((variant) => variant.availableForSale)) !== null && _a !== void 0 ? _a : product.variants[0])) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The commerce adapter for a store on `@tiledev/sdk-shopify`.
|
|
57
|
+
*
|
|
58
|
+
* - **`productsByIds`:** one `products.byIds` read, the bare ids made into product GIDs, the photos at
|
|
59
|
+
* `imageTransform`.
|
|
60
|
+
* - **`createAuctionCheckout`:** a cart of its own for the wins, never the shopping cart, so a stepper
|
|
61
|
+
* can't change a settled price.
|
|
62
|
+
* - **Each win is a line of one,** stamped for the store's cart transform: `_winningBid` (the bid it
|
|
63
|
+
* reprices the line to) or `prizeWriteKey` (a prize), plus `_winIndex`, which stops Shopify merging
|
|
64
|
+
* two identical wins into one line (the same lot won twice must cost twice).
|
|
65
|
+
* - **The giveaway discount codes** go on the cart.
|
|
66
|
+
* - **The cart says what it is:** `source_name`, `source_type: "auction"` and `auction_id` (the
|
|
67
|
+
* show), which the order webhook matches to clear the winner's record. A checkout it can't match
|
|
68
|
+
* leaves the shopper blocked from bidding after paying.
|
|
69
|
+
* - **The buyer** is attached when there is one, so the checkout is theirs; a guest cart when there
|
|
70
|
+
* isn't, or when reading it fails.
|
|
71
|
+
*/
|
|
72
|
+
function createShopifyLiveCommerce(options) {
|
|
73
|
+
const { shopify, cartSourceName, prizeWriteKey, buyer, imageTransform, extraLineAttributes, extraCartAttributes } = options;
|
|
74
|
+
async function productsByIds(storeProductIds) {
|
|
75
|
+
if (storeProductIds.length === 0)
|
|
76
|
+
return [];
|
|
77
|
+
const products = await shopify.products.byIds(storeProductIds.map(shopifyIds_1.productGid), imageTransform ? { imageTransform } : undefined);
|
|
78
|
+
return products.map(liveProductFromShopify);
|
|
79
|
+
}
|
|
80
|
+
async function createAuctionCheckout(wins, auctionId) {
|
|
81
|
+
if (wins.length === 0)
|
|
82
|
+
throw new Error('Nothing to check out');
|
|
83
|
+
const products = await shopify.products.byIds([...new Set(wins.map((win) => (0, shopifyIds_1.productGid)(win.productGid)))]);
|
|
84
|
+
const productsById = new Map(products.map((product) => [(0, shopifyIds_1.bareId)(product.id), product]));
|
|
85
|
+
const discountCodes = new Set();
|
|
86
|
+
const lines = [];
|
|
87
|
+
wins.forEach((win, index) => {
|
|
88
|
+
const variantId = chargedVariantId(productsById.get((0, shopifyIds_1.bareId)(win.productGid)), win);
|
|
89
|
+
if (!variantId)
|
|
90
|
+
return;
|
|
91
|
+
if (win.discountCode)
|
|
92
|
+
discountCodes.add(win.discountCode);
|
|
93
|
+
lines.push({
|
|
94
|
+
merchandiseId: variantId,
|
|
95
|
+
quantity: 1,
|
|
96
|
+
attributes: [
|
|
97
|
+
win.isGiveaway
|
|
98
|
+
? { key: prizeWriteKey, value: 'true' }
|
|
99
|
+
: { key: exports.WINNING_BID_KEY, value: String(win.winningBid) },
|
|
100
|
+
{ key: exports.WIN_INDEX_KEY, value: String(index) },
|
|
101
|
+
...(extraLineAttributes ? extraLineAttributes(win) : []),
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
if (lines.length === 0)
|
|
106
|
+
throw new Error('None of the won items can be sold');
|
|
107
|
+
const buyerIdentity = await buyer().catch(() => null);
|
|
108
|
+
const cart = await shopify.cart.create({
|
|
109
|
+
lines,
|
|
110
|
+
discountCodes: [...discountCodes],
|
|
111
|
+
attributes: [
|
|
112
|
+
{ key: 'source_name', value: cartSourceName },
|
|
113
|
+
{ key: 'source_type', value: exports.AUCTION_CART_SOURCE_TYPE },
|
|
114
|
+
{ key: 'auction_id', value: auctionId },
|
|
115
|
+
...(extraCartAttributes ? extraCartAttributes(lines) : []),
|
|
116
|
+
],
|
|
117
|
+
...(buyerIdentity ? { buyerIdentity } : {}),
|
|
118
|
+
});
|
|
119
|
+
return { checkoutUrl: cart.checkoutUrl, cartId: cart.id };
|
|
120
|
+
}
|
|
121
|
+
return { productsByIds, createAuctionCheckout };
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=shopifyCommerce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shopifyCommerce.js","sourceRoot":"","sources":["../src/shopifyCommerce.ts"],"names":[],"mappings":";;;AAwHA,wDAiBC;AAQD,4CAQC;AAmBD,8DAyDC;AAxND,6CAAkD;AAmGlD,yGAAyG;AAC5F,QAAA,wBAAwB,GAAG,SAAS,CAAC;AAClD,2EAA2E;AAC9D,QAAA,eAAe,GAAG,aAAa,CAAC;AAC7C,qEAAqE;AACxD,QAAA,aAAa,GAAG,WAAW,CAAC;AAEzC,+FAA+F;AAC/F,SAAgB,sBAAsB,CAAC,OAA8B;;IACnE,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,cAAc,EAAE,IAAA,mBAAM,EAAC,OAAO,CAAC,EAAE,CAAC;QAClC,KAAK,EAAE,OAAO,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Aa,CAAC;YACjC,UAAU,EAAE;gBACV,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,cAAc,EAAE;gBAC7C,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,gCAAwB,EAAE;gBACvD,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE;gBACvC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aAC3D;YACD,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5C,CAAC,CAAC;QACH,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IAC5D,CAAC;IAED,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who is watching, bidding and paying, for an app signed in through `@tiledev/sdk-shopify`.
|
|
3
|
+
*
|
|
4
|
+
* A function the app calls with a reader, not a hook: a hook would have to call sdk-shopify's
|
|
5
|
+
* `useCustomer()` itself, from whichever copy of sdk-shopify this package found, which may not be the
|
|
6
|
+
* one the app signed in with (see `shopifyCommerce.ts`). The app keeps its own `useCustomer()` result
|
|
7
|
+
* in a ref and passes `() => ref.current`.
|
|
8
|
+
*/
|
|
9
|
+
import type { CustomerAccountRequest } from './types';
|
|
10
|
+
import type { IdentityAdapter } from './sessionTypes';
|
|
11
|
+
import type { ShopifyBuyer } from './shopifyCommerce';
|
|
12
|
+
/** The parts of sdk-shopify's `useCustomer()` result this file reads. */
|
|
13
|
+
export interface ShopifyCustomerSession {
|
|
14
|
+
loggedIn: boolean;
|
|
15
|
+
/** How the shopper signed in: `'shopify'` (Shopify's own sign-in) or `'password'`; null when signed out. */
|
|
16
|
+
sessionKind: string | null;
|
|
17
|
+
customer: {
|
|
18
|
+
id: string;
|
|
19
|
+
email: string | null;
|
|
20
|
+
firstName: string | null;
|
|
21
|
+
lastName: string | null;
|
|
22
|
+
} | null;
|
|
23
|
+
/** A usable access token, refreshed when needed; null when signed out. */
|
|
24
|
+
getAccessToken(): Promise<string | null>;
|
|
25
|
+
/** A Customer Account API call for the signed-in shopper. */
|
|
26
|
+
request<T>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
27
|
+
}
|
|
28
|
+
export interface ShopifyLiveIdentity {
|
|
29
|
+
/** For `LiveSellingConfig.identity`. */
|
|
30
|
+
identity: Required<IdentityAdapter>;
|
|
31
|
+
/** For `LiveSellingConfig.customerAccountRequest`: the customer's own `request`. */
|
|
32
|
+
customerAccountRequest: CustomerAccountRequest;
|
|
33
|
+
/** For `createShopifyLiveCommerce`'s `buyer`: the customer's access token and email; null when signed out. */
|
|
34
|
+
buyer: () => Promise<ShopifyBuyer | null>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The identity, the Customer Account transport and the buyer, from the signed-in customer.
|
|
38
|
+
*
|
|
39
|
+
* `readCustomer` is called each time the SDK asks, so each answer is about the customer as they are
|
|
40
|
+
* then: sign in or out and the next bid, entry or checkout sees it.
|
|
41
|
+
*
|
|
42
|
+
* - **The bidder** is the customer's bare numeric id, the id the host's broadcast echoes back, and the
|
|
43
|
+
* customer reference is their GID. Both only for a Shopify sign-in: the winner's record is on the
|
|
44
|
+
* Customer Account API, so an email-and-password session can't bid or enter.
|
|
45
|
+
* - **The name** is first and last name, else the first name, else the part of their email before the
|
|
46
|
+
* @ (`viewerNameFor`, 0.9.0); never the whole email. Null when signed out. Before 0.9.0 it was first
|
|
47
|
+
* and last name or null, and a first name typed as an email was published whole.
|
|
48
|
+
* - **The buyer** is the customer's access token and email, for the wins cart.
|
|
49
|
+
*/
|
|
50
|
+
export declare function createShopifyLiveIdentity(readCustomer: () => ShopifyCustomerSession): ShopifyLi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AAsB,GAAG,mBAAmB,CA8BzG"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createShopifyLiveIdentity = createShopifyLiveIdentity;
|
|
4
|
+
const shopifyIds_1 = require("./shopifyIds");
|
|
5
|
+
const showNames_1 = require("./showNames");
|
|
6
|
+
/**
|
|
7
|
+
* The identity, the Customer Account transport and the buyer, from the signed-in customer.
|
|
8
|
+
*
|
|
9
|
+
* `readCustomer` is called each time the SDK asks, so each answer is about the customer as they are
|
|
10
|
+
* then: sign in or out and the next bid, entry or checkout sees it.
|
|
11
|
+
*
|
|
12
|
+
* - **The bidder** is the customer's bare numeric id, the id the host's broadcast echoes back, and the
|
|
13
|
+
* customer reference is their GID. Both only for a Shopify sign-in: the winner's record is on the
|
|
14
|
+
* Customer Account API, so an email-and-password session can't bid or enter.
|
|
15
|
+
* - **The name** is first and last name, else the first name, else the part of their email before the
|
|
16
|
+
* @ (`viewerNameFor`, 0.9.0); never the whole email. Null when signed out. Before 0.9.0 it was first
|
|
17
|
+
* and last name or null, and a first name typed as an email was published whole.
|
|
18
|
+
* - **The buyer** is the customer's access token and email, for the wins cart.
|
|
19
|
+
*/
|
|
20
|
+
function createShopifyLiveIdentity(readCustomer) {
|
|
21
|
+
const signedInWithShopify = () => {
|
|
22
|
+
const current = readCustomer();
|
|
23
|
+
return current.loggedIn && current.sessionKind === 'shopify';
|
|
24
|
+
};
|
|
25
|
+
function customerAccountRequest(query, variables) {
|
|
26
|
+
return readCustomer().request(query, variables);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
identity: {
|
|
30
|
+
bidderId: () => {
|
|
31
|
+
const customer = readCustomer().customer;
|
|
32
|
+
return signedInWithShopify() && customer ? (0, shopifyIds_1.bareId)(customer.id) : null;
|
|
33
|
+
},
|
|
34
|
+
customerRef: () => { var _a, _b; return (signedInWithShopify() ? (_b = (_a = readCustomer().customer) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null : null); },
|
|
35
|
+
customerName: () => (0, showNames_1.viewerNameFor)(readCustomer().customer),
|
|
36
|
+
customerEmail: () => { var _a, _b; return (_b = (_a = readCustomer().customer) === null || _a === void 0 ? void 0 : _a.email) !== null && _b !== void 0 ? _b : null; },
|
|
37
|
+
},
|
|
38
|
+
customerAccountRequest,
|
|
39
|
+
buyer: async () => {
|
|
40
|
+
var _a;
|
|
41
|
+
const current = readCustomer();
|
|
42
|
+
if (!current.loggedIn)
|
|
43
|
+
return null;
|
|
44
|
+
const token = await current.getAccessToken();
|
|
45
|
+
if (!token)
|
|
46
|
+
return null;
|
|
47
|
+
const email = (_a = current.customer) === null || _a === void 0 ? void 0 : _a.email;
|
|
48
|
+
return { customerAccessToken: token, ...(email ? { email } : {}) };
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=shopifyIdentity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shopifyIdentity.js","sourceRoot":"","sources":["../src/shopifyIdentity.ts"],"names":[],"mappings":";;AAiDA,8DA8BC;AApED,6CAAsC;AACtC,2CAA4C;AAuB5C;;;;;;;;;;;;;GAaG;AACH,SAAgB,yBAAyB,CAAC,YAA0C;IAClF,MAAM,mBAAmB,GAAG,GAAG,EAAE;QAC/B,MAAM,OAAO,GAAG,YAAY,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC;IAC/D,CAAC,CAAC;IAEF,SAAS,sBAAsB,CAAI,KAAa,EAAE,SAAmC;QACnF,OAAO,YAAY,EAAE,CAAC,OAAO,CAAI,KAAK,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;IAED,OAAO;QACL,QAAQ,EAAE;YACR,QAAQ,EAAE,GAAG,EAAE;gBACb,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC,QAAQ,CAAC;gBACzC,OAAO,mBAAmB,EAAE,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAA,mBAAM,EAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACxE,CAAC;YACD,WAAW,EAAE,GAAG,EAAE,eAAC,OAAA,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC,MAAA,MAAA,YAAY,EAAE,CAAC,QAAQ,0CAAE,EAAE,mCAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA,EAAA;YACvF,YAAY,EAAE,GAAG,EAAE,CAAC,IAAA,yBAAa,EAAC,YAAY,EAAE,CAAC,QAAQ,CAAC;YAC1D,aAAa,EAAE,GAAG,EAAE,eAAC,OAAA,MAAA,MAAA,YAAY,EAAE,CAAC,QAAQ,0CAAE,KAAK,mCAAI,IAAI,CAAA,EAAA;SAC5D;QACD,sBAAsB;QACtB,KAAK,EAAE,KAAK,IAAI,EAAE;;YAChB,MAAM,OAAO,GAAG,YAAY,EAAE,CAAC;YAC/B,IAAI,CAAC,OAAO,CAAC,QAAQ;gBAAE,OAAO,IAAI,CAAC;YACnC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC;YAC7C,IAAI,CAAC,KAAK;gBAAE,OAAO,IAAI,CAAC;YACxB,MAAM,KAAK,GAAG,MAAA,OAAO,CAAC,QAAQ,0CAAE,KAAK,CAAC;YACtC,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;QACrE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shopify ids, in the two forms they arrive in. The gateway and the host's dashboard use the bare
|
|
3
|
+
* number (`42`); the Storefront API uses the GID (`gid://shopify/Product/42`).
|
|
4
|
+
*/
|
|
5
|
+
/** The bare number at the end of an id, whichever form it arrives in: `gid://shopify/Product/42` and `42` are both `42`. */
|
|
6
|
+
export declare function bareId(id: string): string;
|
|
7
|
+
/** A product GID, from a bare id or a GID. */
|
|
8
|
+
export declare function productGid(id: string): string;
|
|
9
|
+
//# sourceMappingURL=shopifyIds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shopifyIds.d.ts","sourceRoot":"","sources":["../src/shopifyIds.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4HAA4H;AAC5H,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED,8CAA8C;AAC9C,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE7C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shopify ids, in the two forms they arrive in. The gateway and the host's dashboard use the bare
|
|
4
|
+
* number (`42`); the Storefront API uses the GID (`gid://shopify/Product/42`).
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.bareId = bareId;
|
|
8
|
+
exports.productGid = productGid;
|
|
9
|
+
/** The bare number at the end of an id, whichever form it arrives in: `gid://shopify/Product/42` and `42` are both `42`. */
|
|
10
|
+
function bareId(id) {
|
|
11
|
+
var _a;
|
|
12
|
+
return (_a = id.split('/').pop()) !== null && _a !== void 0 ? _a : id;
|
|
13
|
+
}
|
|
14
|
+
/** A product GID, from a bare id or a GID. */
|
|
15
|
+
function productGid(id) {
|
|
16
|
+
return id.startsWith('gid://') ? id : `gid://shopify/Product/${bareId(id)}`;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=shopifyIds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shopifyIds.js","sourceRoot":"","sources":["../src/shopifyIds.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAGH,wBAEC;AAGD,gCAEC;AARD,4HAA4H;AAC5H,SAAgB,MAAM,CAAC,EAAU;;IAC/B,OAAO,MAAA,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,mCAAI,EAAE,CAAC;AACnC,CAAC;AAED,8CAA8C;AAC9C,SAAgB,UAAU,CAAC,EAAU;IACnC,OAAO,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,yBAAyB,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a link about a show should go (0.9.0): `streams.destinationFor`'s rule, moved from amore-v2's
|
|
3
|
+
* and Freckled Poppy's `resolveLiveTarget`.
|
|
4
|
+
*
|
|
5
|
+
* Every push a store sends about a show points at the show (`live-selling/<streamingId>`), and most are
|
|
6
|
+
* opened after it ended, so what the shopper wants is usually its recording. One read of the record
|
|
7
|
+
* answers it: it carries the recording's id (`replayFeedId`, the same as `Replay.id`). No search of the
|
|
8
|
+
* replay feed is needed, and one wouldn't do: the feed is paged, and an old show is past the pages read.
|
|
9
|
+
*
|
|
10
|
+
* Pure, so it loads in plain Node for tests and in an app's own test runner.
|
|
11
|
+
*/
|
|
12
|
+
import type { LiveStream, ShowLinkDestination } from './types';
|
|
13
|
+
/**
|
|
14
|
+
* The destination for a show's record:
|
|
15
|
+
*
|
|
16
|
+
* - none (unknown, unreadable, or hidden from this viewer, which `destinationFor` treats as none):
|
|
17
|
+
* the list of shows;
|
|
18
|
+
* - on air: the live player;
|
|
19
|
+
* - ended, with a recording: its replay;
|
|
20
|
+
* - anything else (scheduled, or ended with no recording): the list of shows, which says what is on
|
|
21
|
+
* now and what has been.
|
|
22
|
+
*/
|
|
23
|
+
export declare function showLinkDestination(show: Pick<LiveStream, 'status' | 'replayFeedId'> | null): ShowLinkDestination;
|
|
24
|
+
//# sourceMappingURL=showLinks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"showLinks.d.ts","sourceRoot":"","sources":["../src/showLinks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,GAAG,cAAc,CAAC,GAAG,IAAI,GAAG,mBAAmB,CAKjH"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.showLinkDestination = showLinkDestination;
|
|
4
|
+
/**
|
|
5
|
+
* The destination for a show's record:
|
|
6
|
+
*
|
|
7
|
+
* - none (unknown, unreadable, or hidden from this viewer, which `destinationFor` treats as none):
|
|
8
|
+
* the list of shows;
|
|
9
|
+
* - on air: the live player;
|
|
10
|
+
* - ended, with a recording: its replay;
|
|
11
|
+
* - anything else (scheduled, or ended with no recording): the list of shows, which says what is on
|
|
12
|
+
* now and what has been.
|
|
13
|
+
*/
|
|
14
|
+
function showLinkDestination(show) {
|
|
15
|
+
if (!show)
|
|
16
|
+
return { to: 'showList' };
|
|
17
|
+
if (show.status === 'live')
|
|
18
|
+
return { to: 'livePlayer' };
|
|
19
|
+
if (show.status === 'ended' && show.replayFeedId)
|
|
20
|
+
return { to: 'replay', feedId: show.replayFeedId };
|
|
21
|
+
return { to: 'showList' };
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=showLinks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"showLinks.js","sourceRoot":"","sources":["../src/showLinks.ts"],"names":[],"mappings":";;AAuBA,kDAKC;AAfD;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CAAC,IAAwD;IAC1F,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;IACrC,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC;IACxD,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,IAAI,IAAI,CAAC,YAAY;QAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC;IACrG,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A show's lots as a screen lists them (0.9.0).
|
|
3
|
+
*
|
|
4
|
+
* Pure, so it loads in plain Node for tests and in an app's own test runner.
|
|
5
|
+
*/
|
|
6
|
+
import type { LiveProduct } from './sessionTypes';
|
|
7
|
+
import type { LiveStreamProduct } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* The list with the featured item lifted to the front, the rest in the host's order: a shopper who
|
|
10
|
+
* opens the shop wants what the host is holding up. It lifts one item; it doesn't sort. The same
|
|
11
|
+
* array when there is nothing to move (no featured item, not in the list, or already first). Works on
|
|
12
|
+
* the session's products or on the catalogue's own (`raw`), matched by `id`.
|
|
13
|
+
*
|
|
14
|
+
* Amore's shop sheet and Freckled Poppy's (`LiveShopSheet01`) each did this.
|
|
15
|
+
*/
|
|
16
|
+
export declare function featuredFirst<Item extends {
|
|
17
|
+
id: string;
|
|
18
|
+
}>(items: Item[], featuredId: string | null | undefined): Item[];
|
|
19
|
+
/**
|
|
20
|
+
* The record's per-lot fields joined onto the commerce adapter's products: the lot number (`sellId`)
|
|
21
|
+
* and, on an auction, the opening bid (`baseBidPrice`). The adapter is asked for products by id and
|
|
22
|
+
* knows nothing of either. Matched by `storeProductId`.
|
|
23
|
+
*
|
|
24
|
+
* The same array when the record has neither field for any lot, so an app on a gateway that issues
|
|
25
|
+
* none keeps the adapter's own objects.
|
|
26
|
+
*/
|
|
27
|
+
export declare function withLotFieldsFromRecord<Raw>(products: LiveProduct<Raw>[], recordLots: Pick<LiveStreamProduct, 'storeProductId' | 'sellId' | 'baseBidPrice'>[]): LiveProduct<Raw>[];
|
|
28
|
+
//# sourceMappingURL=showLots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"showLots.d.ts","sourceRoot":"","sources":["../src/showLots.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,EAAE,CAKvH;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EACzC,QAAQ,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,EAC5B,UAAU,EAAE,IAAI,CAAC,iBAAiB,EAAE,gBAAgB,GAAG,QAAQ,GAAG,cAAc,CAAC,EAAE,GAClF,WAAW,CAAC,GAAG,CAAC,EAAE,CAiBpB"}
|
package/dist/showLots.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.featuredFirst = featuredFirst;
|
|
4
|
+
exports.withLotFieldsFromRecord = withLotFieldsFromRecord;
|
|
5
|
+
/**
|
|
6
|
+
* The list with the featured item lifted to the front, the rest in the host's order: a shopper who
|
|
7
|
+
* opens the shop wants what the host is holding up. It lifts one item; it doesn't sort. The same
|
|
8
|
+
* array when there is nothing to move (no featured item, not in the list, or already first). Works on
|
|
9
|
+
* the session's products or on the catalogue's own (`raw`), matched by `id`.
|
|
10
|
+
*
|
|
11
|
+
* Amore's shop sheet and Freckled Poppy's (`LiveShopSheet01`) each did this.
|
|
12
|
+
*/
|
|
13
|
+
function featuredFirst(items, featuredId) {
|
|
14
|
+
if (!featuredId)
|
|
15
|
+
return items;
|
|
16
|
+
const at = items.findIndex((item) => item.id === featuredId);
|
|
17
|
+
if (at <= 0)
|
|
18
|
+
return items;
|
|
19
|
+
return [items[at], ...items.slice(0, at), ...items.slice(at + 1)];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The record's per-lot fields joined onto the commerce adapter's products: the lot number (`sellId`)
|
|
23
|
+
* and, on an auction, the opening bid (`baseBidPrice`). The adapter is asked for products by id and
|
|
24
|
+
* knows nothing of either. Matched by `storeProductId`.
|
|
25
|
+
*
|
|
26
|
+
* The same array when the record has neither field for any lot, so an app on a gateway that issues
|
|
27
|
+
* none keeps the adapter's own objects.
|
|
28
|
+
*/
|
|
29
|
+
function withLotFieldsFromRecord(products, recordLots) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const byLot = new Map();
|
|
32
|
+
for (const lot of recordLots) {
|
|
33
|
+
if (lot.sellId || lot.baseBidPrice != null) {
|
|
34
|
+
byLot.set(lot.storeProductId, { sellId: (_a = lot.sellId) !== null && _a !== void 0 ? _a : null, baseBidPrice: (_b = lot.baseBidPrice) !== null && _b !== void 0 ? _b : null });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (!byLot.size)
|
|
38
|
+
return products;
|
|
39
|
+
return products.map((product) => {
|
|
40
|
+
var _a, _b, _c, _d;
|
|
41
|
+
const fields = byLot.get(product.storeProductId);
|
|
42
|
+
if (!fields)
|
|
43
|
+
return product;
|
|
44
|
+
return {
|
|
45
|
+
...product,
|
|
46
|
+
sellId: (_b = (_a = fields.sellId) !== null && _a !== void 0 ? _a : product.sellId) !== null && _b !== void 0 ? _b : null,
|
|
47
|
+
baseBidPrice: (_d = (_c = fields.baseBidPrice) !== null && _c !== void 0 ? _c : product.baseBidPrice) !== null && _d !== void 0 ? _d : null,
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=showLots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"showLots.js","sourceRoot":"","sources":["../src/showLots.ts"],"names":[],"mappings":";;AAgBA,sCAKC;AAUD,0DAoBC;AA3CD;;;;;;;GAOG;AACH,SAAgB,aAAa,CAA8B,KAAa,EAAE,UAAqC;IAC7G,IAAI,CAAC,UAAU;QAAE,OAAO,KAAK,CAAC;IAC9B,MAAM,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,UAAU,CAAC,CAAC;IAC7D,IAAI,EAAE,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1B,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CACrC,QAA4B,EAC5B,UAAmF;;IAEnF,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkE,CAAC;IACxF,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,YAAY,IAAI,IAAI,EAAE,CAAC;YAC3C,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,MAAA,GAAG,CAAC,MAAM,mCAAI,IAAI,EAAE,YAAY,EAAE,MAAA,GAAG,CAAC,YAAY,mCAAI,IAAI,EAAE,CAAC,CAAC;QACxG,CAAC;IACH,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,IAAI;QAAE,OAAO,QAAQ,CAAC;IACjC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;;QAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC;QAC5B,OAAO;YACL,GAAG,OAAO;YACV,MAAM,EAAE,MAAA,MAAA,MAAM,CAAC,MAAM,mCAAI,OAAO,CAAC,MAAM,mCAAI,IAAI;YAC/C,YAAY,EAAE,MAAA,MAAA,MAAM,CAAC,YAAY,mCAAI,OAAO,CAAC,YAAY,mCAAI,IAAI;SAClE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names the room shows to everyone, made safe to show (0.9.0).
|
|
3
|
+
*
|
|
4
|
+
* A live room publishes each viewer's name to everyone watching, so this is a privacy boundary, not
|
|
5
|
+
* formatting: an email address must never reach a screen. The SDK applies `publicName` to every name
|
|
6
|
+
* it hands out (comments and the room's history, cart cards, reactions, the auction's leader and
|
|
7
|
+
* winner, the giveaway's winner and entrants, a replay's chat) and to the name it publishes for this
|
|
8
|
+
* viewer. Names from older apps, or already stored in a room's history, arrive as whatever they sent,
|
|
9
|
+
* which is how a full address was once shown to a room (Freckled Poppy's DEL-2758).
|
|
10
|
+
*
|
|
11
|
+
* Pure, so it loads in plain Node for tests and in an app's own test runner.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* A name as it may be shown: trimmed; an email keeps only the part before the @ ("jane@x.com" →
|
|
15
|
+
* "jane"); a name that starts with @ is a handle the viewer chose ("@jane") and stays whole; a real
|
|
16
|
+
* name ("Jane Doe") is unchanged. Null when nothing usable is left.
|
|
17
|
+
*/
|
|
18
|
+
export declare function publicName(name: string | null | undefined): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* The first word of a name, for a place with no room for the rest (a card that shares one line with a
|
|
21
|
+
* product title): "Jane Doe" → "Jane". Made safe first, so never an email. Null when nothing is left.
|
|
22
|
+
*/
|
|
23
|
+
export declare function firstNameOf(name: string | null | undefined): string | null;
|
|
24
|
+
/** What a signed-in viewer is called in the room: the parts of a customer this reads. */
|
|
25
|
+
export interface NamedCustomer {
|
|
26
|
+
firstName?: string | null;
|
|
27
|
+
lastName?: string | null;
|
|
28
|
+
email?: string | null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The name a signed-in customer comments, bids and enters under: first and last name, else the first
|
|
32
|
+
* name alone, else the part of their email before the @. Never the whole email. Null when signed out
|
|
33
|
+
* (or nothing is usable), which leaves the session's own choice in charge: a name typed on this phone.
|
|
34
|
+
*
|
|
35
|
+
* The same rule amore-v2 (`liveViewerName`) and Freckled Poppy (`LiveSessionHost`) kept apart; pass it
|
|
36
|
+
* to `LiveSessionProvider`'s `viewerName`, and `createShopifyLiveIdentity`'s `customerName` uses it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function viewerNameFor(customer: NamedCustomer | null | undefined): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Two names the room shows, compared as a person reads them: spaces and capitals aside ("Jane Doe "
|
|
41
|
+
* is "jane doe"). False when either is empty. How a giveaway's winner is matched to this shopper when
|
|
42
|
+
* the record doesn't name them by id (`isYourGiveawayWin`); amore-v2's rule.
|
|
43
|
+
*/
|
|
44
|
+
export declare function sameRoomName(first: string | null | undefined, second: string | null | undefined): boolean;
|
|
45
|
+
//# sourceMappingURL=showNames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"showNames.d.ts","sourceRoot":"","sources":["../src/showNames.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAKzE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAE1E;AAED,yFAAyF;AACzF,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAOvF;AAQD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAGzG"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Names the room shows to everyone, made safe to show (0.9.0).
|
|
4
|
+
*
|
|
5
|
+
* A live room publishes each viewer's name to everyone watching, so this is a privacy boundary, not
|
|
6
|
+
* formatting: an email address must never reach a screen. The SDK applies `publicName` to every name
|
|
7
|
+
* it hands out (comments and the room's history, cart cards, reactions, the auction's leader and
|
|
8
|
+
* winner, the giveaway's winner and entrants, a replay's chat) and to the name it publishes for this
|
|
9
|
+
* viewer. Names from older apps, or already stored in a room's history, arrive as whatever they sent,
|
|
10
|
+
* which is how a full address was once shown to a room (Freckled Poppy's DEL-2758).
|
|
11
|
+
*
|
|
12
|
+
* Pure, so it loads in plain Node for tests and in an app's own test runner.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.publicName = publicName;
|
|
16
|
+
exports.firstNameOf = firstNameOf;
|
|
17
|
+
exports.viewerNameFor = viewerNameFor;
|
|
18
|
+
exports.sameRoomName = sameRoomName;
|
|
19
|
+
/**
|
|
20
|
+
* A name as it may be shown: trimmed; an email keeps only the part before the @ ("jane@x.com" →
|
|
21
|
+
* "jane"); a name that starts with @ is a handle the viewer chose ("@jane") and stays whole; a real
|
|
22
|
+
* name ("Jane Doe") is unchanged. Null when nothing usable is left.
|
|
23
|
+
*/
|
|
24
|
+
function publicName(name) {
|
|
25
|
+
var _a;
|
|
26
|
+
const trimmed = typeof name === 'string' ? name.trim() : '';
|
|
27
|
+
if (!trimmed)
|
|
28
|
+
return null;
|
|
29
|
+
if (trimmed.startsWith('@'))
|
|
30
|
+
return trimmed;
|
|
31
|
+
return ((_a = trimmed.split('@')[0]) === null || _a === void 0 ? void 0 : _a.trim()) || null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The first word of a name, for a place with no room for the rest (a card that shares one line with a
|
|
35
|
+
* product title): "Jane Doe" → "Jane". Made safe first, so never an email. Null when nothing is left.
|
|
36
|
+
*/
|
|
37
|
+
function firstNameOf(name) {
|
|
38
|
+
var _a;
|
|
39
|
+
return ((_a = publicName(name)) === null || _a === void 0 ? void 0 : _a.split(/\s+/)[0]) || null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The name a signed-in customer comments, bids and enters under: first and last name, else the first
|
|
43
|
+
* name alone, else the part of their email before the @. Never the whole email. Null when signed out
|
|
44
|
+
* (or nothing is usable), which leaves the session's own choice in charge: a name typed on this phone.
|
|
45
|
+
*
|
|
46
|
+
* The same rule amore-v2 (`liveViewerName`) and Freckled Poppy (`LiveSessionHost`) kept apart; pass it
|
|
47
|
+
* to `LiveSessionProvider`'s `viewerName`, and `createShopifyLiveIdentity`'s `customerName` uses it.
|
|
48
|
+
*/
|
|
49
|
+
function viewerNameFor(customer) {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
if (!customer)
|
|
52
|
+
return null;
|
|
53
|
+
const fullName = [customer.firstName, customer.lastName]
|
|
54
|
+
.map((part) => (typeof part === 'string' ? part.trim() : ''))
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.join(' ');
|
|
57
|
+
return (_b = (_a = publicName(fullName)) !== null && _a !== void 0 ? _a : publicName(customer.firstName)) !== null && _b !== void 0 ? _b : partBeforeTheAt(customer.email);
|
|
58
|
+
}
|
|
59
|
+
/** An email's part before the @, never a bare "@example.com" (which `publicName` would keep as a handle). */
|
|
60
|
+
function partBeforeTheAt(email) {
|
|
61
|
+
var _a;
|
|
62
|
+
const trimmed = typeof email === 'string' ? email.trim() : '';
|
|
63
|
+
return ((_a = trimmed.split('@')[0]) === null || _a === void 0 ? void 0 : _a.trim()) || null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Two names the room shows, compared as a person reads them: spaces and capitals aside ("Jane Doe "
|
|
67
|
+
* is "jane doe"). False when either is empty. How a giveaway's winner is matched to this shopper when
|
|
68
|
+
* the record doesn't name them by id (`isYourGiveawayWin`); amore-v2's rule.
|
|
69
|
+
*/
|
|
70
|
+
function sameRoomName(first, second) {
|
|
71
|
+
const plain = (name) => (name !== null && name !== void 0 ? name : '').trim().replace(/\s+/g, ' ').toLowerCase();
|
|
72
|
+
return plain(first) !== '' && plain(first) === plain(second);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=showNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"showNames.js","sourceRoot":"","sources":["../src/showNames.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAOH,gCAKC;AAMD,kCAEC;AAiBD,sCAOC;AAaD,oCAGC;AA1DD;;;;GAIG;AACH,SAAgB,UAAU,CAAC,IAA+B;;IACxD,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5D,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,O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C;IAC9F,MAAM,KAAK,GAAG,CAAC,IAA+B,EAAE,EAAE,CAAC,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1G,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/streams.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ type RawStreamProduct = {
|
|
|
14
14
|
sell_id?: string | number | null;
|
|
15
15
|
start_time?: number | null;
|
|
16
16
|
base_bid_price?: number | string | null;
|
|
17
|
+
/** The lot's bid step: how much each bid must add. */
|
|
18
|
+
bid_incrementer?: number | string | null;
|
|
17
19
|
auction_winner?: unknown[] | null;
|
|
18
20
|
/** `"url"` marks a lot that is a link rather than a catalogue product. */
|
|
19
21
|
product_type?: string | null;
|
|
@@ -24,14 +26,31 @@ type RawGiveawayProduct = {
|
|
|
24
26
|
variant_id?: string | null;
|
|
25
27
|
giveawayStatus?: string | null;
|
|
26
28
|
product_name?: string | null;
|
|
27
|
-
|
|
29
|
+
/** A bare string on the rows seen so far, but the same field is `{ url }` on a catalogue lot. */
|
|
30
|
+
product_thumbnail?: string | {
|
|
31
|
+
url?: string | null;
|
|
32
|
+
} | null;
|
|
28
33
|
product_variant_title?: string | null;
|
|
34
|
+
/** The given-away variant's price (`"22.0"`): what every record seen carries (2026-10-06). */
|
|
35
|
+
variant_price?: number | string | null;
|
|
36
|
+
/** The name the SDK read before 0.9.0, kept as a fallback; no record seen has it. */
|
|
29
37
|
product_variant_price?: number | string | null;
|
|
38
|
+
/** The given-away variant's own photo. */
|
|
39
|
+
variant_image?: string | {
|
|
40
|
+
url?: string | null;
|
|
41
|
+
} | null;
|
|
42
|
+
/** When the host started this giveaway, an ISO time (`"2026-10-05T06:26:49.473Z"`). */
|
|
43
|
+
giveawayStartTime?: string | number | null;
|
|
30
44
|
users?: {
|
|
31
45
|
displayName?: string | null;
|
|
32
46
|
userId?: string | null;
|
|
33
47
|
}[] | null;
|
|
34
48
|
moderatorInCharge?: string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Who won, once drawn: a customer GID (`"gid://shopify/Customer/42"`), or `"No One Joined"` for a
|
|
51
|
+
* draw nobody entered; absent while open (shows `h2rorgm7po`, `dq9r6hd8ml`, read 2026-10-06).
|
|
52
|
+
*/
|
|
53
|
+
winner?: string | null;
|
|
35
54
|
};
|
|
36
55
|
type RawProductSegment = {
|
|
37
56
|
product_id: string;
|
|
@@ -58,6 +77,8 @@ type RawLiveStream = {
|
|
|
58
77
|
product_info?: RawStreamProduct[] | null;
|
|
59
78
|
product_segments?: RawProductSegment[] | null;
|
|
60
79
|
meta?: Record<string, unknown> | null;
|
|
80
|
+
/** `{ id, comment, name }` while something is pinned; null or absent otherwise. */
|
|
81
|
+
pinned_comment?: unknown;
|
|
61
82
|
};
|
|
62
83
|
/** A co-host slot on the record. `status` is the host's own, and only `active` is on air. */
|
|
63
84
|
type RawGuestHost = {
|
|
@@ -67,6 +88,11 @@ type RawGuestHost = {
|
|
|
67
88
|
type RawLiveStreams = {
|
|
68
89
|
data?: RawLiveStream[] | null;
|
|
69
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* The winner's bare customer id from the record's `winner`: the number at the end of a GID, or a bare
|
|
93
|
+
* number. Anything else (`"No One Joined"`, absent) is no winner.
|
|
94
|
+
*/
|
|
95
|
+
export declare function winnerIdOf(winner: unknown): string | null;
|
|
70
96
|
export declare function toLiveStreamProduct(raw: RawStreamProduct): LiveStreamProduct | null;
|
|
71
97
|
/**
|
|
72
98
|
* Entrants for one giveaway lot, out of the flat `meta` bag. The host writes one
|