@tiledev/sdk-apptile-live-selling 0.11.0 → 0.12.1
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 +68 -1
- package/dist/auctions.d.ts.map +1 -1
- package/dist/auctions.js +22 -1
- package/dist/auctions.js.map +1 -1
- package/dist/commentLinkCards.d.ts +11 -0
- package/dist/commentLinkCards.d.ts.map +1 -0
- package/dist/commentLinkCards.js +70 -0
- package/dist/commentLinkCards.js.map +1 -0
- package/dist/commentLinks.d.ts +29 -0
- package/dist/commentLinks.d.ts.map +1 -1
- package/dist/commentLinks.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -3
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +5 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +11 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.web.d.ts +5 -0
- package/dist/react/index.web.d.ts.map +1 -1
- package/dist/react/index.web.js +12 -1
- package/dist/react/index.web.js.map +1 -1
- package/dist/react/useCommentLinkCards.d.ts +6 -0
- package/dist/react/useCommentLinkCards.d.ts.map +1 -0
- package/dist/react/useCommentLinkCards.js +67 -0
- package/dist/react/useCommentLinkCards.js.map +1 -0
- package/dist/react/useMySilentAuctionBids.d.ts +29 -0
- package/dist/react/useMySilentAuctionBids.d.ts.map +1 -0
- package/dist/react/useMySilentAuctionBids.js +157 -0
- package/dist/react/useMySilentAuctionBids.js.map +1 -0
- package/dist/react/useSilentAuctionLot.d.ts +42 -0
- package/dist/react/useSilentAuctionLot.d.ts.map +1 -0
- package/dist/react/useSilentAuctionLot.js +152 -0
- package/dist/react/useSilentAuctionLot.js.map +1 -0
- package/dist/react/useSilentAuctionLots.d.ts +39 -0
- package/dist/react/useSilentAuctionLots.d.ts.map +1 -0
- package/dist/react/useSilentAuctionLots.js +63 -0
- package/dist/react/useSilentAuctionLots.js.map +1 -0
- package/dist/react/useSilentAuctionRounds.d.ts +14 -0
- package/dist/react/useSilentAuctionRounds.d.ts.map +1 -0
- package/dist/react/useSilentAuctionRounds.js +44 -0
- package/dist/react/useSilentAuctionRounds.js.map +1 -0
- package/dist/replays.d.ts +7 -0
- package/dist/replays.d.ts.map +1 -1
- package/dist/replays.js +16 -0
- package/dist/replays.js.map +1 -1
- package/dist/sessionTypes.d.ts +9 -0
- package/dist/sessionTypes.d.ts.map +1 -1
- package/dist/sessionTypes.js.map +1 -1
- package/dist/shopifyCommerce.d.ts +43 -1
- package/dist/shopifyCommerce.d.ts.map +1 -1
- package/dist/shopifyCommerce.js +62 -2
- package/dist/shopifyCommerce.js.map +1 -1
- package/dist/silentAuctionFeed.d.ts +47 -0
- package/dist/silentAuctionFeed.d.ts.map +1 -0
- package/dist/silentAuctionFeed.js +232 -0
- package/dist/silentAuctionFeed.js.map +1 -0
- package/dist/silentAuctionRules.d.ts +207 -0
- package/dist/silentAuctionRules.d.ts.map +1 -0
- package/dist/silentAuctionRules.js +425 -0
- package/dist/silentAuctionRules.js.map +1 -0
- package/dist/silentAuctions.d.ts +65 -0
- package/dist/silentAuctions.d.ts.map +1 -0
- package/dist/silentAuctions.js +272 -0
- package/dist/silentAuctions.js.map +1 -0
- package/dist/types.d.ts +40 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSilentAuctionFeed = createSilentAuctionFeed;
|
|
4
|
+
/**
|
|
5
|
+
* A store's silent-auction lots with their products, read a page at a time (0.12.0, moved from Sparkl's
|
|
6
|
+
* `useAuctionProducts` on 2026-10-17). Framework-free so it is tested in Node; `useSilentAuctionLots`
|
|
7
|
+
* drives it from a screen.
|
|
8
|
+
*
|
|
9
|
+
* - **The first page first:** the service lists every lot in one cheap read; their products are read 20
|
|
10
|
+
* at a time through the commerce adapter (`productsByIds`), and the list is drawn as soon as one page
|
|
11
|
+
* has a product. The rest are read in the background (`readAhead`), one page after another.
|
|
12
|
+
* - **Never a spinner for ever:** after `firstPaintBudgetMs` (4 s) the load stops counting as loading,
|
|
13
|
+
* and `readingAhead` stays up until it lands.
|
|
14
|
+
* - **A poll moves only the auction half:** each shown lot gets its fresh bid, close time and leader,
|
|
15
|
+
* keeping its product; lots that have just opened inside the shown window are added. A failed poll
|
|
16
|
+
* keeps what is shown. A poll stands down while a load or a read-ahead is running.
|
|
17
|
+
* - **Newest wins:** every load starts a new generation, and an answer from an older one is dropped.
|
|
18
|
+
* `stop()` (the screen went away) does the same.
|
|
19
|
+
* - **Sold-out lots are left out** unless `keepSoldOut` (My Bids keeps them: a won lot is usually sold out).
|
|
20
|
+
*/
|
|
21
|
+
const client_1 = require("./client");
|
|
22
|
+
const silentAuctionRules_1 = require("./silentAuctionRules");
|
|
23
|
+
const silentAuctions_1 = require("./silentAuctions");
|
|
24
|
+
const IDLE = { items: [], status: 'idle', refreshing: false, readingAhead: false, hasMore: false };
|
|
25
|
+
/** A product can be bought: one of its variants can be sold (a product with no variants listed counts). */
|
|
26
|
+
function inStock(product) {
|
|
27
|
+
return product.variants.length === 0 || product.variants.some((variant) => variant.available);
|
|
28
|
+
}
|
|
29
|
+
function sortForPages(lots, order) {
|
|
30
|
+
if (!order || order === 'service')
|
|
31
|
+
return lots.slice();
|
|
32
|
+
const field = order === 'startsAt' ? 'startsAt' : 'endsAt';
|
|
33
|
+
return lots.slice().sort((a, b) => { var _a, _b; return ((_a = a[field]) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER) - ((_b = b[field]) !== null && _b !== void 0 ? _b : Number.MAX_SAFE_INTEGER); });
|
|
34
|
+
}
|
|
35
|
+
function createSilentAuctionFeed(options = {}) {
|
|
36
|
+
const { filter = 'current', pageOrder = 'service', readAhead = true, keepSoldOut = false, pageSize = 20, firstPaintBudgetMs = 4000 } = options;
|
|
37
|
+
let state = { ...IDLE, items: [] };
|
|
38
|
+
const listeners = new Set();
|
|
39
|
+
let generation = 0;
|
|
40
|
+
let loadingAll = false;
|
|
41
|
+
/** How far through the sorted list the shown items reach, and how long it is. */
|
|
42
|
+
let consumed = 0;
|
|
43
|
+
let total = 0;
|
|
44
|
+
/** The newest read-ahead, so an older one finishing can't put the flag down for a newer one. */
|
|
45
|
+
let readAheadRun = 0;
|
|
46
|
+
/** The newest read-ahead is still reading. */
|
|
47
|
+
let readAheadLive = false;
|
|
48
|
+
function set(next) {
|
|
49
|
+
state = { ...state, ...next, hasMore: consumed < total };
|
|
50
|
+
for (const listener of listeners)
|
|
51
|
+
listener();
|
|
52
|
+
}
|
|
53
|
+
/** One page's lots with their products; a page whose read fails gives none, and is reported. */
|
|
54
|
+
async function withProducts(lots) {
|
|
55
|
+
const commerce = (0, client_1.getCommerce)();
|
|
56
|
+
const ids = [...new Set(lots.filter((lot) => lot.productGid && lot.storeProductId).map((lot) => lot.storeProductId))];
|
|
57
|
+
if (!commerce || ids.length === 0)
|
|
58
|
+
return [];
|
|
59
|
+
let products = [];
|
|
60
|
+
try {
|
|
61
|
+
products = await commerce.productsByIds(ids);
|
|
62
|
+
}
|
|
63
|
+
catch (caught) {
|
|
64
|
+
(0, client_1.getLogger)().error(caught, { at: 'silentAuctionFeed.products', count: ids.length });
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
const byId = new Map(products.map((product) => [product.storeProductId, product]));
|
|
68
|
+
const items = [];
|
|
69
|
+
for (const lot of lots) {
|
|
70
|
+
const product = lot.storeProductId ? byId.get(lot.storeProductId) : undefined;
|
|
71
|
+
if (!product)
|
|
72
|
+
continue;
|
|
73
|
+
if (!keepSoldOut && !inStock(product))
|
|
74
|
+
continue;
|
|
75
|
+
items.push({ lot, product: product });
|
|
76
|
+
}
|
|
77
|
+
return items;
|
|
78
|
+
}
|
|
79
|
+
async function readRest(mine, sorted) {
|
|
80
|
+
if (!readAhead)
|
|
81
|
+
return;
|
|
82
|
+
const run = ++readAheadRun;
|
|
83
|
+
readAheadLive = true;
|
|
84
|
+
set({ readingAhead: true });
|
|
85
|
+
try {
|
|
86
|
+
while (generation === mine && consumed < sorted.length) {
|
|
87
|
+
const from = consumed;
|
|
88
|
+
const page = sorted.slice(from, from + pageSize);
|
|
89
|
+
const items = await withProducts(page);
|
|
90
|
+
if (generation !== mine)
|
|
91
|
+
return;
|
|
92
|
+
consumed = from + page.length;
|
|
93
|
+
set({ items: state.items.concat(items) });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
if (readAheadRun === run) {
|
|
98
|
+
readAheadLive = false;
|
|
99
|
+
set({ readingAhead: false });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function load({ userInitiated = false } = {}) {
|
|
104
|
+
const mine = ++generation;
|
|
105
|
+
const current = () => generation === mine;
|
|
106
|
+
loadingAll = true;
|
|
107
|
+
if (state.items.length === 0)
|
|
108
|
+
set({ status: 'loading', refreshing: false });
|
|
109
|
+
else if (userInitiated)
|
|
110
|
+
set({ refreshing: true });
|
|
111
|
+
const settle = () => {
|
|
112
|
+
if (!current())
|
|
113
|
+
return;
|
|
114
|
+
loadingAll = false;
|
|
115
|
+
set({ refreshing: false, status: state.status === 'failed' ? 'failed' : 'ready' });
|
|
116
|
+
};
|
|
117
|
+
const run = async () => {
|
|
118
|
+
let lots;
|
|
119
|
+
try {
|
|
120
|
+
lots = await silentAuctions_1.silentAuctions.lots(filter);
|
|
121
|
+
}
|
|
122
|
+
catch (caught) {
|
|
123
|
+
if (!current())
|
|
124
|
+
return;
|
|
125
|
+
(0, client_1.getLogger)().error(caught, { at: 'silentAuctionFeed.load', filter });
|
|
126
|
+
consumed = 0;
|
|
127
|
+
total = 0;
|
|
128
|
+
set({ items: [], status: 'failed' });
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (!current())
|
|
132
|
+
return;
|
|
133
|
+
const sorted = sortForPages(lots, pageOrder);
|
|
134
|
+
if (sorted.length === 0) {
|
|
135
|
+
consumed = 0;
|
|
136
|
+
total = 0;
|
|
137
|
+
set({ items: [], status: 'ready' });
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// Pages until one has a product: a page of sold-out or unpublished lots draws nothing.
|
|
141
|
+
let items = [];
|
|
142
|
+
let read = 0;
|
|
143
|
+
while (read < sorted.length && items.length === 0) {
|
|
144
|
+
const page = sorted.slice(read, read + pageSize);
|
|
145
|
+
items = items.concat(await withProducts(page));
|
|
146
|
+
if (!current())
|
|
147
|
+
return;
|
|
148
|
+
read += page.length;
|
|
149
|
+
}
|
|
150
|
+
consumed = read;
|
|
151
|
+
total = sorted.length;
|
|
152
|
+
set({ items, status: 'ready' });
|
|
153
|
+
// Not awaited: the load is done the moment the first page can be drawn.
|
|
154
|
+
void readRest(mine, sorted);
|
|
155
|
+
};
|
|
156
|
+
let budget;
|
|
157
|
+
const outOfTime = new Promise((resolve) => {
|
|
158
|
+
budget = setTimeout(() => resolve('budget'), firstPaintBudgetMs);
|
|
159
|
+
});
|
|
160
|
+
const work = run().then(() => 'work');
|
|
161
|
+
const first = await Promise.race([work, outOfTime]);
|
|
162
|
+
if (first === 'budget') {
|
|
163
|
+
if (current() && state.status === 'loading')
|
|
164
|
+
set({ status: 'ready', refreshing: false, readingAhead: true });
|
|
165
|
+
await work;
|
|
166
|
+
// The budget put `readingAhead` up; it comes down here unless a read-ahead has taken it over.
|
|
167
|
+
if (current() && !readAheadLive)
|
|
168
|
+
set({ readingAhead: false });
|
|
169
|
+
}
|
|
170
|
+
clearTimeout(budget);
|
|
171
|
+
settle();
|
|
172
|
+
}
|
|
173
|
+
async function poll() {
|
|
174
|
+
if (loadingAll || state.readingAhead || state.status === 'idle')
|
|
175
|
+
return;
|
|
176
|
+
const mine = generation;
|
|
177
|
+
const current = () => generation === mine && !loadingAll;
|
|
178
|
+
let lots;
|
|
179
|
+
try {
|
|
180
|
+
lots = await silentAuctions_1.silentAuctions.lots(filter);
|
|
181
|
+
}
|
|
182
|
+
catch (caught) {
|
|
183
|
+
// A failed tick keeps what is shown.
|
|
184
|
+
(0, client_1.getLogger)().error(caught, { at: 'silentAuctionFeed.poll', filter });
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (!current())
|
|
188
|
+
return;
|
|
189
|
+
const sorted = sortForPages(lots, pageOrder);
|
|
190
|
+
const shown = Math.max(consumed, pageSize);
|
|
191
|
+
const window = sorted.slice(0, shown);
|
|
192
|
+
const byKey = new Map();
|
|
193
|
+
for (const lot of sorted) {
|
|
194
|
+
const key = (0, silentAuctionRules_1.lotKey)(lot);
|
|
195
|
+
if (key)
|
|
196
|
+
byKey.set(key, lot);
|
|
197
|
+
}
|
|
198
|
+
const refreshed = state.items.map((item) => {
|
|
199
|
+
const key = (0, silentAuctionRules_1.lotKey)(item.lot);
|
|
200
|
+
const fresh = key ? byKey.get(key) : undefined;
|
|
201
|
+
return fresh ? { ...item, lot: fresh } : item;
|
|
202
|
+
});
|
|
203
|
+
const known = new Set(state.items.map((item) => (0, silentAuctionRules_1.lotKey)(item.lot)));
|
|
204
|
+
const opened = window.filter((lot) => lot.productGid && !known.has((0, silentAuctionRules_1.lotKey)(lot)));
|
|
205
|
+
const added = opened.length ? await withProducts(opened) : [];
|
|
206
|
+
if (!current())
|
|
207
|
+
return;
|
|
208
|
+
consumed = Math.min(shown, sorted.length);
|
|
209
|
+
total = sorted.length;
|
|
210
|
+
set({ items: refreshed.concat(added), status: 'ready' });
|
|
211
|
+
if (consumed < total)
|
|
212
|
+
void readRest(mine, sorted);
|
|
213
|
+
}
|
|
214
|
+
function stop() {
|
|
215
|
+
generation += 1;
|
|
216
|
+
loadingAll = false;
|
|
217
|
+
readAheadRun += 1;
|
|
218
|
+
readAheadLive = false;
|
|
219
|
+
set({ refreshing: false, readingAhead: false, status: state.status === 'loading' ? 'idle' : state.status });
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
getState: () => state,
|
|
223
|
+
subscribe(listener) {
|
|
224
|
+
listeners.add(listener);
|
|
225
|
+
return () => listeners.delete(listener);
|
|
226
|
+
},
|
|
227
|
+
load,
|
|
228
|
+
poll,
|
|
229
|
+
stop,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=silentAuctionFeed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"silentAuctionFeed.js","sourceRoot":"","sources":["../src/silentAuctionFeed.ts"],"names":[],"mappings":";;AAgFA,0DAwLC;AAxQD;;;;;;;;;;;;;;;;GAgBG;AACH,qCAAkD;AAElD,6DAAqE;AACrE,qDAAkD;AA+ClD,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAW,CAAC;AAE5G,2GAA2G;AAC3G,SAAS,OAAO,CAAC,OAA6B;IAC5C,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAChG,CAAC;AAED,SAAS,YAAY,CAAC,IAAwB,EAAE,KAA4C;IAC1F,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACvD,MAAM,KAAK,GAAG,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC3D,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,eAAC,OAAA,CAAC,MAAA,CAAC,CAAC,KAAK,CAAC,mCAAI,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAA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CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IAED,SAAS,IAAI;QACX,UAAU,IAAI,CAAC,CAAC;QAChB,UAAU,GAAG,KAAK,CAAC;QACnB,YAAY,IAAI,CAAC,CAAC;QAClB,aAAa,GAAG,KAAK,CAAC;QACtB,GAAG,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9G,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;QACrB,SAAS,CAAC,QAAQ;YAChB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI;QACJ,IAAI;QACJ,IAAI;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/** One lot on the auction service, read from whichever shape it came in. */
|
|
2
|
+
export interface SilentAuctionLot {
|
|
3
|
+
/** The store's bare product id ("123"), when the service gave one. */
|
|
4
|
+
storeProductId: string | null;
|
|
5
|
+
/** The product's GID, when one can be made. */
|
|
6
|
+
productGid: string | null;
|
|
7
|
+
productHandle: string | null;
|
|
8
|
+
/** The round this lot is in. With the product, what a bid is recorded against. */
|
|
9
|
+
auctionId: string | null;
|
|
10
|
+
streamId: string | null;
|
|
11
|
+
lotNumber: number | null;
|
|
12
|
+
/** When bidding opens, epoch ms; null when it is open already. */
|
|
13
|
+
startsAt: number | null;
|
|
14
|
+
/** When bidding closes, epoch ms. Null means no clock, read as closed. */
|
|
15
|
+
endsAt: number | null;
|
|
16
|
+
startingPrice: number | null;
|
|
17
|
+
highestBid: number | null;
|
|
18
|
+
bidIncrement: number | null;
|
|
19
|
+
/** The highest bid the round allows, inclusive. Null when there is none (see `bidCapState`). */
|
|
20
|
+
biddingCap: number | null;
|
|
21
|
+
/** The leading customer's bare id. */
|
|
22
|
+
highestBidderId: string | null;
|
|
23
|
+
/** The variant the leading bid was placed on, bare. */
|
|
24
|
+
highestBidVariantId: string | null;
|
|
25
|
+
/** Anti-sniping: a bid inside the trigger window pushes the close back by the duration. */
|
|
26
|
+
extendedBidding: {
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
triggerMs: number | null;
|
|
29
|
+
durationMs: number | null;
|
|
30
|
+
};
|
|
31
|
+
/** When the service flagged a bidding war on this lot, as it sent it; null when it hasn't. */
|
|
32
|
+
biddingWarAt: string | number | null;
|
|
33
|
+
/** How long the winner has to pay once the lot closes, ms. */
|
|
34
|
+
purchaseWindowMs: number | null;
|
|
35
|
+
/** The service's own record. */
|
|
36
|
+
raw: unknown;
|
|
37
|
+
}
|
|
38
|
+
export type SilentAuctionPhase = 'upcoming' | 'live' | 'ended';
|
|
39
|
+
/** A Shopify product GID from a GID or a bare numeric id; null for anything else (a `prod-1` key). */
|
|
40
|
+
export declare function lotProductGid(value: unknown): string | null;
|
|
41
|
+
/** One lot, from any of the service's shapes (the list, `/product/{id}`, the bulk read). */
|
|
42
|
+
export declare function toSilentAuctionLot(raw: unknown): SilentAuctionLot;
|
|
43
|
+
/** The lots in a list response: a bare array, or one wrapped in `items`, `products`, `auctionProducts` or `data`. */
|
|
44
|
+
export declare function lotsFromResponse(json: unknown): SilentAuctionLot[];
|
|
45
|
+
/** The key a lot keeps across reads: its product and its round. */
|
|
46
|
+
export declare function lotKey(lot: Pick<SilentAuctionLot, 'productGid' | 'auctionId'>): string | null;
|
|
47
|
+
/** Ms until the lot closes, never below zero. No close time reads as zero. */
|
|
48
|
+
export declare function timeLeftMs(lot: Pick<SilentAuctionLot, 'endsAt'>, nowMs: number): number;
|
|
49
|
+
/** Upcoming before it opens, live until it closes, ended after (or when it has no close time). */
|
|
50
|
+
export declare function lotPhase(lot: Pick<SilentAuctionLot, 'startsAt' | 'endsAt'>, nowMs: number): SilentAuctionPhase;
|
|
51
|
+
/** Inside the anti-sniping window: a bid now pushes the close back. A 0 or unset trigger is always open. */
|
|
52
|
+
export declare function inExtensionWindow(lot: Pick<SilentAuctionLot, 'endsAt' | 'extendedBidding'>, nowMs: number): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether a new close time is an anti-sniping extension rather than a host's edit: it moved later,
|
|
55
|
+
* while the lot was still open and inside its trigger window.
|
|
56
|
+
*/
|
|
57
|
+
export declare function wasExtended(previousEndsAt: number | null, lot: Pick<SilentAuctionLot, 'endsAt' | 'extendedBidding'>, nowMs: number): boolean;
|
|
58
|
+
/** What the one-tap bid offers: the standing bid plus the increment, else the starting price. */
|
|
59
|
+
export declare function nextBid(lot: Pick<SilentAuctionLot, 'highestBid' | 'bidIncrement' | 'startingPrice'>): number;
|
|
60
|
+
/** The bid cap, as the two bid controls have to read it (Sparkl's SPR-37). */
|
|
61
|
+
export interface BidCapState {
|
|
62
|
+
/** A ceiling applies at all. */
|
|
63
|
+
hasCap: boolean;
|
|
64
|
+
/** The one-tap bid's offer is already over the ceiling: there is no bid left to place. */
|
|
65
|
+
overCap: boolean;
|
|
66
|
+
/** No typed amount can both beat the standing bid and stay within the ceiling. */
|
|
67
|
+
noCustomRoom: boolean;
|
|
68
|
+
/** The ceiling, for formatting; NaN when there is none. */
|
|
69
|
+
ceiling: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The bid cap for an offer of `offered` (what the one-tap bid offers).
|
|
73
|
+
*
|
|
74
|
+
* - **A numeric 0 is a ceiling;** null, undefined and a blank string are none. `Number("")` is 0, so
|
|
75
|
+
* coercing first would turn an unset field into a ceiling of 0 and lock out every bid.
|
|
76
|
+
* - **The cap is inclusive:** a bid of exactly the cap is legal (`overCap` is `>`). The service agreed
|
|
77
|
+
* on 2026-09-14; if either end changes, a bid at the ceiling silently goes nowhere again.
|
|
78
|
+
* - **The keypad's test is stricter** (`noCustomRoom`, `>=`): it needs an amount above the offer and
|
|
79
|
+
* within the cap, and at offer === cap there is none, while the one-tap bid is still live.
|
|
80
|
+
*/
|
|
81
|
+
export declare function bidCapState(offered: number, cap: unknown): BidCapState;
|
|
82
|
+
/** Whether this customer holds the leading bid (ids compared bare). */
|
|
83
|
+
export declare function isLeading(lot: Pick<SilentAuctionLot, 'highestBidderId'>, customerId: string | null | undefined): boolean;
|
|
84
|
+
/** The one status a lot's card shows, of six. */
|
|
85
|
+
export type SilentAuctionLotStatus = 'upcoming' | 'live' | 'endingSoon' | 'biddingWar' | 'endedWon' | 'endedLost';
|
|
86
|
+
/**
|
|
87
|
+
* A lot's card status: ended (won by this customer, or lost), upcoming, inside its anti-sniping window
|
|
88
|
+
* (a bidding war once the service has flagged one, else ending soon), or live. Without a trigger window
|
|
89
|
+
* there are no urgency states.
|
|
90
|
+
*/
|
|
91
|
+
export declare function lotStatus(lot: SilentAuctionLot, nowMs: number, customerId: string | null | undefined): SilentAuctionLotStatus;
|
|
92
|
+
/**
|
|
93
|
+
* The lots page's orders (Sparkl's filter pills): `newest` (all lots, live first, the latest to open
|
|
94
|
+
* first), `endingSoon` (open lots, the soonest to close first), `wishlisted` (the shopper's wishlisted
|
|
95
|
+
* lots), `upcoming` (the service's upcoming list; see `upcomingGroups`).
|
|
96
|
+
*/
|
|
97
|
+
export type SilentAuctionOrder = 'newest' | 'endingSoon' | 'wishlisted' | 'upcoming';
|
|
98
|
+
/**
|
|
99
|
+
* The lots in a page's order. Live lots first, then those not open yet (soonest first), then closed ones
|
|
100
|
+
* (latest closed first). `endingSoon` leaves out lots not open yet; `wishlisted` keeps only
|
|
101
|
+
* `wishlistedProductIds` (bare or GIDs); `upcoming` keeps every lot of the service's upcoming list, which
|
|
102
|
+
* is lots not open yet (0.12.1: 0.12.0 left them out too, so the list was always empty).
|
|
103
|
+
*/
|
|
104
|
+
export declare function orderLots<T extends {
|
|
105
|
+
lot: SilentAuctionLot;
|
|
106
|
+
}>(items: T[], order: SilentAuctionOrder, nowMs: number, wishlistedProductIds?: Iterable<string>): T[];
|
|
107
|
+
/** Upcoming lots grouped by round, the soonest round first; within a round, the service's order. */
|
|
108
|
+
export declare function upcomingGroups<T extends {
|
|
109
|
+
lot: SilentAuctionLot;
|
|
110
|
+
}>(items: T[]): {
|
|
111
|
+
auctionId: string;
|
|
112
|
+
startsAt: number | null;
|
|
113
|
+
items: T[];
|
|
114
|
+
}[];
|
|
115
|
+
/**
|
|
116
|
+
* My Bids' three tabs: active (not closed, the soonest to close first), won (closed and this customer
|
|
117
|
+
* leads, the latest first), lost (closed otherwise, the latest first). A lot with no close time is
|
|
118
|
+
* closed, as `lotPhase` reads it.
|
|
119
|
+
*/
|
|
120
|
+
export declare function myBidsTabs<T extends {
|
|
121
|
+
lot: SilentAuctionLot;
|
|
122
|
+
}>(items: T[], customerId: string | null | undefined, nowMs: number): {
|
|
123
|
+
active: T[];
|
|
124
|
+
won: T[];
|
|
125
|
+
lost: T[];
|
|
126
|
+
};
|
|
127
|
+
/** What the product page knows when it decides its bottom bar. */
|
|
128
|
+
export interface ProductPageBuyBarInput {
|
|
129
|
+
/** The product's lot, or null when it has never been in a round. */
|
|
130
|
+
lot: Pick<SilentAuctionLot, 'startsAt' | 'endsAt'> | null;
|
|
131
|
+
/** Whether the lot read has answered. `failed` only before any answer. */
|
|
132
|
+
lotStatus: 'loading' | 'ready' | 'failed';
|
|
133
|
+
/** The store marks this product as a lot (its `auction.winners` or `auction.allowedQty` metafields). */
|
|
134
|
+
auctionManaged: boolean;
|
|
135
|
+
/** A winner is recorded on the product itself. */
|
|
136
|
+
productHasWinner: boolean;
|
|
137
|
+
/** A winner is recorded on the chosen variant. */
|
|
138
|
+
variantHasWinner: boolean;
|
|
139
|
+
/** The chosen variant's `auction.allowedQty`; null when it has none (not the same as 0). */
|
|
140
|
+
allowedQty: number | null;
|
|
141
|
+
soldOut: boolean;
|
|
142
|
+
nowMs: number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Which bottom bar the product page draws: the bid console, Add to Cart, or neither. They aren't
|
|
146
|
+
* opposites: before a round opens neither shows; a round that closed with stock left goes back to a
|
|
147
|
+
* normal sale; a product with a recorded winner keeps the console. A recorded winner blocks a variant
|
|
148
|
+
* only once the round permits no more of it (`allowedQty` ≤ 0; none recorded counts as 0). While the
|
|
149
|
+
* lot read hasn't answered for a managed product, neither shows rather than guess.
|
|
150
|
+
*/
|
|
151
|
+
export declare function productPageBuyBar(input: ProductPageBuyBarInput): {
|
|
152
|
+
console: boolean;
|
|
153
|
+
addToCart: boolean;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* The customer metafield that records which lots they bid on: `auction.apptile_silent_auction_bids`.
|
|
157
|
+
* The auction service keeps no per-bidder index, so this is the only record, written on every bid and
|
|
158
|
+
* read by My Bids.
|
|
159
|
+
*/
|
|
160
|
+
export declare const BID_RECORD_NAMESPACE = "auction";
|
|
161
|
+
export declare const BID_RECORD_KEY = "apptile_silent_auction_bids";
|
|
162
|
+
/** The record's entries, from a JSON array or the comma-separated string an older client left. Deduplicated. */
|
|
163
|
+
export declare function bidRecordEntries(raw: unknown): string[];
|
|
164
|
+
/** One record entry, `<bare product id>-<auction id>`, or null when the halves can't make a queryable one. */
|
|
165
|
+
export declare function bidRecordEntry(productId: string | null | undefined, auctionId: string | null | undefined): string | null;
|
|
166
|
+
/**
|
|
167
|
+
* The entries the service can be asked about, and how many couldn't be (a bid the shopper placed and
|
|
168
|
+
* won't see, so a list missing them says so).
|
|
169
|
+
*/
|
|
170
|
+
export declare function queryableBidEntries(raw: unknown): {
|
|
171
|
+
entries: string[];
|
|
172
|
+
skipped: number;
|
|
173
|
+
};
|
|
174
|
+
/** One lot as the rounds endpoint lists it. */
|
|
175
|
+
export interface SilentAuctionRoundLot {
|
|
176
|
+
storeProductId: string;
|
|
177
|
+
thumbnailUrl: string | null;
|
|
178
|
+
lotNumber: number | null;
|
|
179
|
+
startingBid: number | null;
|
|
180
|
+
bidIncrement: number | null;
|
|
181
|
+
startsAt: number | null;
|
|
182
|
+
endsAt: number | null;
|
|
183
|
+
}
|
|
184
|
+
/** One round of a store's silent auction: its name, status, times, notification and lots. */
|
|
185
|
+
export interface SilentAuctionRound {
|
|
186
|
+
id: string | null;
|
|
187
|
+
name: string | null;
|
|
188
|
+
streamingId: string | null;
|
|
189
|
+
/** `ACTIVE` while bidding is open, `SCHEDULED` before it starts. */
|
|
190
|
+
status: string | null;
|
|
191
|
+
startsAt: number | null;
|
|
192
|
+
endsAt: number | null;
|
|
193
|
+
notification: {
|
|
194
|
+
title?: string;
|
|
195
|
+
body?: string;
|
|
196
|
+
thumbnailUrl?: string;
|
|
197
|
+
} | null;
|
|
198
|
+
startNotification: {
|
|
199
|
+
title?: string;
|
|
200
|
+
body?: string;
|
|
201
|
+
thumbnailUrl?: string;
|
|
202
|
+
} | null;
|
|
203
|
+
lots: SilentAuctionRoundLot[];
|
|
204
|
+
}
|
|
205
|
+
/** One round, from the rounds endpoint's `auctions[i]`. */
|
|
206
|
+
export declare function toSilentAuctionRound(raw: unknown): SilentAuctionRound;
|
|
207
|
+
//# sourceMappingURL=silentAuctionRules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"silentAuctionRules.d.ts","sourceRoot":"","sources":["../src/silentAuctionRules.ts"],"names":[],"mappings":"AAUA,4EAA4E;AAC5E,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,+CAA+C;IAC/C,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,kFAAkF;IAClF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,kEAAkE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