@curless/hotel-storefront 0.80.3 → 0.82.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/dist/account/addon-pages.d.ts +22 -0
- package/dist/account/addon-pages.d.ts.map +1 -0
- package/dist/account/addon-pages.js +282 -0
- package/dist/account/addon-pages.js.map +1 -0
- package/dist/account/index.d.ts +54 -0
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +719 -61
- package/dist/account/index.js.map +1 -1
- package/dist/account/ota-member.d.ts +15 -0
- package/dist/account/ota-member.d.ts.map +1 -1
- package/dist/account/ota-member.js +21 -5
- package/dist/account/ota-member.js.map +1 -1
- package/dist/account/pages.d.ts +39 -4
- package/dist/account/pages.d.ts.map +1 -1
- package/dist/account/pages.js +104 -42
- package/dist/account/pages.js.map +1 -1
- package/dist/account/requests.d.ts +11 -1
- package/dist/account/requests.d.ts.map +1 -1
- package/dist/account/requests.js +2 -1
- package/dist/account/requests.js.map +1 -1
- package/dist/account/wallet-pages.d.ts +84 -0
- package/dist/account/wallet-pages.d.ts.map +1 -0
- package/dist/account/wallet-pages.js +229 -0
- package/dist/account/wallet-pages.js.map +1 -0
- package/dist/account/wallet.d.ts +163 -0
- package/dist/account/wallet.d.ts.map +1 -0
- package/dist/account/wallet.js +365 -0
- package/dist/account/wallet.js.map +1 -0
- package/dist/backend.d.ts +25 -0
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js.map +1 -1
- package/dist/card-v168.generated.d.ts +6 -0
- package/dist/card-v168.generated.d.ts.map +1 -0
- package/dist/card-v168.generated.js +10 -0
- package/dist/card-v168.generated.js.map +1 -0
- package/dist/card.generated.d.ts +1 -1
- package/dist/card.generated.js +2 -2
- package/dist/card.generated.js.map +1 -1
- package/dist/config.d.ts +51 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +21 -1
- package/dist/config.js.map +1 -1
- package/dist/legal.d.ts.map +1 -1
- package/dist/legal.js +33 -4
- package/dist/legal.js.map +1 -1
- package/dist/otaless/addons-answers.d.ts +17 -0
- package/dist/otaless/addons-answers.d.ts.map +1 -0
- package/dist/otaless/addons-answers.js +170 -0
- package/dist/otaless/addons-answers.js.map +1 -0
- package/dist/otaless/addons.d.ts +218 -0
- package/dist/otaless/addons.d.ts.map +1 -0
- package/dist/otaless/addons.js +758 -0
- package/dist/otaless/addons.js.map +1 -0
- package/dist/otaless/booking.d.ts +64 -0
- package/dist/otaless/booking.d.ts.map +1 -1
- package/dist/otaless/booking.js +156 -0
- package/dist/otaless/booking.js.map +1 -1
- package/dist/otaless/client.d.ts +111 -0
- package/dist/otaless/client.d.ts.map +1 -1
- package/dist/otaless/client.js +44 -4
- package/dist/otaless/client.js.map +1 -1
- package/dist/otaless/fake.d.ts +114 -0
- package/dist/otaless/fake.d.ts.map +1 -1
- package/dist/otaless/fake.js +305 -7
- package/dist/otaless/fake.js.map +1 -1
- package/dist/otaless/make.d.ts +41 -1
- package/dist/otaless/make.d.ts.map +1 -1
- package/dist/otaless/make.js +165 -2
- package/dist/otaless/make.js.map +1 -1
- package/dist/otaless/shop-answers.d.ts +81 -0
- package/dist/otaless/shop-answers.d.ts.map +1 -0
- package/dist/otaless/shop-answers.js +378 -0
- package/dist/otaless/shop-answers.js.map +1 -0
- package/dist/otaless/shop-client.d.ts +133 -0
- package/dist/otaless/shop-client.d.ts.map +1 -0
- package/dist/otaless/shop-client.js +201 -0
- package/dist/otaless/shop-client.js.map +1 -0
- package/dist/otaless/shop-fake.d.ts +130 -0
- package/dist/otaless/shop-fake.d.ts.map +1 -0
- package/dist/otaless/shop-fake.js +335 -0
- package/dist/otaless/shop-fake.js.map +1 -0
- package/dist/otaless/shop-service.d.ts +111 -0
- package/dist/otaless/shop-service.d.ts.map +1 -0
- package/dist/otaless/shop-service.js +195 -0
- package/dist/otaless/shop-service.js.map +1 -0
- package/dist/otaless/shop.d.ts +169 -0
- package/dist/otaless/shop.d.ts.map +1 -0
- package/dist/otaless/shop.js +793 -0
- package/dist/otaless/shop.js.map +1 -0
- package/dist/otaless/wallet.d.ts +160 -0
- package/dist/otaless/wallet.d.ts.map +1 -0
- package/dist/otaless/wallet.js +650 -0
- package/dist/otaless/wallet.js.map +1 -0
- package/dist/server.d.ts +14 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +89 -16
- package/dist/server.js.map +1 -1
- package/dist/surface.d.ts +7 -0
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +15 -1
- package/dist/surface.js.map +1 -1
- package/dist/tools.d.ts +223 -99
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +484 -75
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
const SYMBOLS = { USD: 'US$', CNY: 'CN¥', EUR: '€', GBP: '£', HKD: 'HK$' };
|
|
2
|
+
/** An amount with its currency, two decimals: `US$89.00`, `JPY 1200.00` (the shop's own figures, never rounded). */
|
|
3
|
+
export const shopMoney = (cents, currency) => {
|
|
4
|
+
const sym = SYMBOLS[currency];
|
|
5
|
+
const n = (cents / 100).toFixed(2);
|
|
6
|
+
return sym ? `${sym}${n}` : `${currency} ${n}`;
|
|
7
|
+
};
|
|
8
|
+
export const statusWords = (s) => ({
|
|
9
|
+
'awaiting-payment': 'awaiting payment',
|
|
10
|
+
paid: 'paid',
|
|
11
|
+
confirmed: 'confirmed and paid',
|
|
12
|
+
completed: 'completed',
|
|
13
|
+
cancelled: 'cancelled',
|
|
14
|
+
refunded: 'refunded',
|
|
15
|
+
'refund-requested': 'refund requested - not paid back yet',
|
|
16
|
+
failed: 'failed - nothing was taken',
|
|
17
|
+
unknown: 'status not known',
|
|
18
|
+
})[s];
|
|
19
|
+
const hostOf = (url) => {
|
|
20
|
+
try {
|
|
21
|
+
return new URL(url).host;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export const itemForStructure = (i) => ({
|
|
28
|
+
id: i.id,
|
|
29
|
+
name: i.name,
|
|
30
|
+
price: shopMoney(i.priceCents, i.currency),
|
|
31
|
+
priceMinor: i.priceCents,
|
|
32
|
+
currency: i.currency,
|
|
33
|
+
available: i.available,
|
|
34
|
+
options: i.options,
|
|
35
|
+
...(i.unit ? { unit: i.unit } : {}),
|
|
36
|
+
...(i.category ? { category: i.category } : {}),
|
|
37
|
+
...(i.description ? { description: i.description } : {}),
|
|
38
|
+
// Already only a picture on an allowed host (shop.ts): listed here, drawn nowhere.
|
|
39
|
+
...(i.imageUrl ? { imageUrl: i.imageUrl } : {}),
|
|
40
|
+
});
|
|
41
|
+
export const orderForStructure = (o) => ({
|
|
42
|
+
id: o.id,
|
|
43
|
+
name: o.name,
|
|
44
|
+
total: shopMoney(o.totalCents, o.currency),
|
|
45
|
+
totalMinor: o.totalCents,
|
|
46
|
+
currency: o.currency,
|
|
47
|
+
status: o.status,
|
|
48
|
+
statusWords: statusWords(o.status),
|
|
49
|
+
...(o.checkoutUrl ? { checkoutUrl: o.checkoutUrl, checkoutHost: hostOf(o.checkoutUrl) } : {}),
|
|
50
|
+
});
|
|
51
|
+
const itemLine = (i) => `- ${i.name} — ${shopMoney(i.priceCents, i.currency)}${i.unit ? ` per ${i.unit}` : ''}, ${i.available ? 'in stock' : 'not available'}${i.options.length ? `; options: ${i.options.join(' | ')}` : ''}; item id \`${i.id}\``;
|
|
52
|
+
export const orderLine = (o) => `- ${o.name || 'Shop order'} — ${shopMoney(o.totalCents, o.currency)}, ${statusWords(o.status)}; order id \`${o.id}\`${o.checkoutUrl
|
|
53
|
+
? `; payment page (on ${hostOf(o.checkoutUrl)}, the guest pays there): ${o.checkoutUrl}`
|
|
54
|
+
: ''}`;
|
|
55
|
+
const WHAT_IT_IS = "These are add-on goods from Otaless's shop, sold beside the hotel rooms - not hotel rooms or rates.";
|
|
56
|
+
const NOT_OPEN = 'Buying is not open here yet: nothing in the shop can be ordered through this connector.';
|
|
57
|
+
/**
|
|
58
|
+
* ⚠️ THE SHOP WANTS ITS OWN SIGN-IN (live walkthrough 11-23: `sign_in_required` to the platform
|
|
59
|
+
* sign-in alone). Say exactly that - not "could not be read", not "sign in again" (the guest IS
|
|
60
|
+
* signed in; signing in here will not help). Without a link on offer: not offered here yet. With
|
|
61
|
+
* one (0.82.0): link the shop account on our own page - its email and password never in the chat.
|
|
62
|
+
*/
|
|
63
|
+
const shopSignInWords = (link) => link
|
|
64
|
+
? `The shop's orders and purchases need the guest's own Otaless Shop account linked to their account, which is not linked yet. ${link.tool} (group \`${link.group}\`) gives them a one-time page to link it; the shop email and password are typed on that page only, never in the chat. Say so plainly; do not say there are no shop orders.`
|
|
65
|
+
: "The shop's orders need a separate sign-in to the shop, which is not offered here yet - so they cannot be read, changed or cancelled from here. The guest is signed in to their hotel account; that does not open the shop. Say so plainly; do not say there are no shop orders, and do not ask the guest to sign in again.";
|
|
66
|
+
/** The error code of a refusal: `shop-<why>`, with the shop's own sign-in as `shop-sign-in`. */
|
|
67
|
+
const whyCode = (why) => (why === 'shop-sign-in' ? why : `shop-${why}`);
|
|
68
|
+
export const shopSignInAnswer = (base, link) => ({
|
|
69
|
+
structured: { view: 'error', ...base, error: 'shop-sign-in', detail: shopSignInWords(link) },
|
|
70
|
+
text: shopSignInWords(link),
|
|
71
|
+
isError: true,
|
|
72
|
+
});
|
|
73
|
+
const whyReading = (why, link) => why === 'not-found'
|
|
74
|
+
? 'No shop item matches that id.'
|
|
75
|
+
: why === 'shop-sign-in'
|
|
76
|
+
? shopSignInWords(link)
|
|
77
|
+
: why === 'busy'
|
|
78
|
+
? 'The shop is busy just now; ask again in a minute.'
|
|
79
|
+
: why === 'not-signed-in' || why === 'session-expired'
|
|
80
|
+
? "The guest's sign-in is not valid for the shop just now; they sign in again."
|
|
81
|
+
: why === 'not-enabled'
|
|
82
|
+
? 'There is no shop here.'
|
|
83
|
+
: 'The shop did not answer just now; nothing was changed.';
|
|
84
|
+
export const listAnswer = (base, r, asked, buyOpen, link) => {
|
|
85
|
+
if (!r.ok)
|
|
86
|
+
return {
|
|
87
|
+
structured: {
|
|
88
|
+
view: 'error',
|
|
89
|
+
...base,
|
|
90
|
+
error: whyCode(r.why),
|
|
91
|
+
detail: whyReading(r.why, link),
|
|
92
|
+
},
|
|
93
|
+
text: whyReading(r.why, link),
|
|
94
|
+
isError: true,
|
|
95
|
+
};
|
|
96
|
+
const filters = [
|
|
97
|
+
asked.query ? `matching "${asked.query}"` : '',
|
|
98
|
+
asked.category ? `in ${asked.category}` : '',
|
|
99
|
+
asked.maxPrice !== undefined ? `up to ${asked.maxPrice}` : '',
|
|
100
|
+
]
|
|
101
|
+
.filter(Boolean)
|
|
102
|
+
.join(', ');
|
|
103
|
+
return {
|
|
104
|
+
structured: {
|
|
105
|
+
view: 'shop-items',
|
|
106
|
+
...base,
|
|
107
|
+
items: r.items.map(itemForStructure),
|
|
108
|
+
count: r.items.length,
|
|
109
|
+
buyOpen,
|
|
110
|
+
...(asked.query ? { query: asked.query } : {}),
|
|
111
|
+
},
|
|
112
|
+
text: [
|
|
113
|
+
WHAT_IT_IS,
|
|
114
|
+
r.items.length
|
|
115
|
+
? `${r.items.length} item${r.items.length === 1 ? '' : 's'}${filters ? ` ${filters}` : ''}:`
|
|
116
|
+
: `Nothing in the shop${filters ? ` ${filters}` : ''}.`,
|
|
117
|
+
...r.items.map(itemLine),
|
|
118
|
+
buyOpen ? '' : NOT_OPEN,
|
|
119
|
+
]
|
|
120
|
+
.filter(Boolean)
|
|
121
|
+
.join('\n'),
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
export const itemAnswer = (base, r, asked, buyOpen, link) => {
|
|
125
|
+
if (!r.ok)
|
|
126
|
+
return {
|
|
127
|
+
structured: {
|
|
128
|
+
view: r.why === 'not-found' ? 'shop-item-not-found' : 'error',
|
|
129
|
+
...base,
|
|
130
|
+
...(r.why === 'not-found' ? { query: asked } : { error: whyCode(r.why) }),
|
|
131
|
+
detail: whyReading(r.why, link),
|
|
132
|
+
},
|
|
133
|
+
text: whyReading(r.why, link),
|
|
134
|
+
...(r.why === 'not-found' ? {} : { isError: true }),
|
|
135
|
+
};
|
|
136
|
+
const i = r.item;
|
|
137
|
+
return {
|
|
138
|
+
structured: { view: 'shop-item', ...base, item: itemForStructure(i), buyOpen },
|
|
139
|
+
text: [
|
|
140
|
+
WHAT_IT_IS,
|
|
141
|
+
itemLine(i),
|
|
142
|
+
i.description ? `The shop's own description: "${i.description.slice(0, 400)}"` : '',
|
|
143
|
+
buyOpen ? '' : NOT_OPEN,
|
|
144
|
+
]
|
|
145
|
+
.filter(Boolean)
|
|
146
|
+
.join('\n'),
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
/** The shop-orders part of the bookings list: text lines and the structured array. */
|
|
150
|
+
export const ordersPart = (r, link) => {
|
|
151
|
+
if (!r.ok) {
|
|
152
|
+
// Nobody signed in: there is nothing to say about shop orders.
|
|
153
|
+
if (r.why === 'not-signed-in')
|
|
154
|
+
return undefined;
|
|
155
|
+
// ⚠️ NOT "COULD NOT BE READ JUST NOW": that says try again, and trying again will not help.
|
|
156
|
+
if (r.why === 'shop-sign-in')
|
|
157
|
+
return {
|
|
158
|
+
text: shopSignInWords(link),
|
|
159
|
+
structured: { shopOrdersNeedShopSignIn: true, ...(link ? { shopLinkable: true } : {}) },
|
|
160
|
+
};
|
|
161
|
+
return {
|
|
162
|
+
text: 'Shop orders could not be read just now - they are not listed, which does not mean there are none.',
|
|
163
|
+
structured: { shopOrdersUnavailable: true },
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
text: r.orders.length
|
|
168
|
+
? [
|
|
169
|
+
'Shop orders (add-on goods, separate from the hotel bookings above):',
|
|
170
|
+
...r.orders.map(orderLine),
|
|
171
|
+
].join('\n')
|
|
172
|
+
: 'No shop orders on this account.',
|
|
173
|
+
structured: { shopOrders: r.orders.map(orderForStructure) },
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
export const previewAnswer = (base, p, cancelTool, clock, link) => {
|
|
177
|
+
if (!p.ok) {
|
|
178
|
+
const text = p.why === 'not-open'
|
|
179
|
+
? `Shop order ${p.order?.name || ''} (\`${p.order?.id}\`) is ${p.order ? statusWords(p.order.status) : 'not open'}: there is nothing to cancel or refund.`
|
|
180
|
+
: p.why === 'not-found'
|
|
181
|
+
? 'No shop order of this account matches that id.'
|
|
182
|
+
: whyReading(p.why, link);
|
|
183
|
+
return {
|
|
184
|
+
structured: {
|
|
185
|
+
view: 'error',
|
|
186
|
+
...base,
|
|
187
|
+
error: whyCode(p.why),
|
|
188
|
+
detail: text,
|
|
189
|
+
...(p.order ? { shopOrder: orderForStructure(p.order) } : {}),
|
|
190
|
+
},
|
|
191
|
+
text,
|
|
192
|
+
...(p.why === 'not-found' ? {} : { isError: true }),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const total = shopMoney(p.order.totalCents, p.order.currency);
|
|
196
|
+
const what = `${p.order.name || 'Shop order'} (\`${p.order.id}\`)`;
|
|
197
|
+
const text = p.kind === 'cancel'
|
|
198
|
+
? `Cancelling shop order ${what}, ${total}: it has not been paid, so cancelling it charges nothing. Nothing is cancelled yet. Say the word and it is cancelled (${cancelTool} with \`confirmed\`; this can be used until ${clock(p.until)}).`
|
|
199
|
+
: `Refunding shop order ${what}: it was paid, ${total}. Cancelling it asks for a full refund of ${total} to the original payment method; points given for it are taken back. Nothing has been asked yet. Say this to the guest and get their yes, then call ${cancelTool} again with \`confirmed\` (this can be used until ${clock(p.until)}).`;
|
|
200
|
+
return {
|
|
201
|
+
structured: {
|
|
202
|
+
view: 'shop-order-preview',
|
|
203
|
+
...base,
|
|
204
|
+
shopOrder: orderForStructure(p.order),
|
|
205
|
+
kind: p.kind === 'cancel' ? 'cancel-unpaid' : 'full-refund',
|
|
206
|
+
charged: p.kind === 'cancel' ? '0' : total,
|
|
207
|
+
...(p.kind === 'refund'
|
|
208
|
+
? { refund: total, refundMinor: p.order.totalCents, pointsTakenBack: true }
|
|
209
|
+
: {}),
|
|
210
|
+
until: p.until,
|
|
211
|
+
toolToConfirm: cancelTool,
|
|
212
|
+
},
|
|
213
|
+
text,
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
export const finishAnswer = (base, o, previewTool, ordersTool, link) => {
|
|
217
|
+
const err = (code, text) => ({
|
|
218
|
+
structured: { view: 'error', ...base, error: code, detail: text },
|
|
219
|
+
text,
|
|
220
|
+
isError: true,
|
|
221
|
+
});
|
|
222
|
+
if (o.outcome === 'cancelled')
|
|
223
|
+
return {
|
|
224
|
+
structured: {
|
|
225
|
+
view: 'shop-order-done',
|
|
226
|
+
...base,
|
|
227
|
+
done: 'cancelled',
|
|
228
|
+
shopOrder: { ...orderForStructure(o.order), status: 'cancelled', statusWords: 'cancelled' },
|
|
229
|
+
},
|
|
230
|
+
text: `Shop order ${o.order.name || ''} (\`${o.order.id}\`) is cancelled. Nothing was charged.`,
|
|
231
|
+
};
|
|
232
|
+
if (o.outcome === 'refunded') {
|
|
233
|
+
const asked = shopMoney(o.order.totalCents, o.order.currency);
|
|
234
|
+
const said = o.refundCents !== undefined && o.refundCents !== o.order.totalCents
|
|
235
|
+
? ` The shop reports ${shopMoney(o.refundCents, o.order.currency)} instead - a person here will look at it.`
|
|
236
|
+
: '';
|
|
237
|
+
return {
|
|
238
|
+
structured: {
|
|
239
|
+
view: 'shop-order-done',
|
|
240
|
+
...base,
|
|
241
|
+
done: 'refunded',
|
|
242
|
+
refund: asked,
|
|
243
|
+
refundMinor: o.order.totalCents,
|
|
244
|
+
...(o.refundCents !== undefined ? { shopSaidMinor: o.refundCents } : {}),
|
|
245
|
+
shopOrder: { ...orderForStructure(o.order), status: 'refunded', statusWords: 'refunded' },
|
|
246
|
+
},
|
|
247
|
+
text: `The shop accepted a full refund of ${asked} for \`${o.order.id}\`. It goes back to the original payment method; points given for it are taken back.${said}`,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
if (o.outcome === 'requested') {
|
|
251
|
+
const asked = shopMoney(o.order.totalCents, o.order.currency);
|
|
252
|
+
const said = o.refundCents !== undefined && o.refundCents !== o.order.totalCents
|
|
253
|
+
? ` The shop's answer names ${shopMoney(o.refundCents, o.order.currency)} - a person here will look at it.`
|
|
254
|
+
: '';
|
|
255
|
+
return {
|
|
256
|
+
structured: {
|
|
257
|
+
view: 'shop-order-done',
|
|
258
|
+
...base,
|
|
259
|
+
done: 'refund-requested',
|
|
260
|
+
refund: asked,
|
|
261
|
+
refundMinor: o.order.totalCents,
|
|
262
|
+
...(o.refundCents !== undefined ? { shopSaidMinor: o.refundCents } : {}),
|
|
263
|
+
shopOrder: {
|
|
264
|
+
...orderForStructure(o.order),
|
|
265
|
+
status: 'refund-requested',
|
|
266
|
+
statusWords: statusWords('refund-requested'),
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
text: `The shop took the refund request for \`${o.order.id}\`: a full refund of ${asked} to the original payment method, which it has not paid back yet; points given for it are taken back. Say it is requested - never that it is refunded - and that the bookings list shows when it is. It was sent once and is not sent again.${said}`,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
if (o.outcome === 'unknown')
|
|
273
|
+
return {
|
|
274
|
+
structured: {
|
|
275
|
+
view: 'shop-order-unknown',
|
|
276
|
+
...base,
|
|
277
|
+
done: 'unknown',
|
|
278
|
+
kind: o.kind,
|
|
279
|
+
shopOrder: orderForStructure(o.order),
|
|
280
|
+
},
|
|
281
|
+
text: `It is not known whether the ${o.kind === 'cancel' ? 'cancellation' : 'refund'} of \`${o.order.id}\` went through: the shop gave no answer that says so. It was not sent again. Look at the orders in a few minutes (${ordersTool}) and say only what they show - never say it is done before.`,
|
|
282
|
+
};
|
|
283
|
+
switch (o.why) {
|
|
284
|
+
case 'refund-preview':
|
|
285
|
+
return err('refund-preview', `Nothing was cancelled or refunded: it is done only after the guest was shown what it does (${previewTool}, without \`confirmed\`), within ten minutes, for this order and this amount. Show them that first, then ask again once they say yes.`);
|
|
286
|
+
case 'in-progress':
|
|
287
|
+
return err('shop-in-progress', 'That is already being done; nothing was sent again.');
|
|
288
|
+
case 'checking':
|
|
289
|
+
return err('shop-checking', `That was done a moment ago and is not sent again; look at the orders (${ordersTool}) for where it stands.`);
|
|
290
|
+
case 'not-open':
|
|
291
|
+
return err('shop-not-open', 'That order is no longer one that can be cancelled or refunded.');
|
|
292
|
+
case 'not-found':
|
|
293
|
+
return err('shop-not-found', 'No shop order of this account matches that id; nothing was done.');
|
|
294
|
+
default:
|
|
295
|
+
return err(whyCode(o.why), o.why === 'failed'
|
|
296
|
+
? 'The shop did not take it; nothing was changed.'
|
|
297
|
+
: `${whyReading(o.why, link)} Nothing was changed.`);
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
export const buyAnswer = (base, r, used) => {
|
|
301
|
+
const err = (code, text) => ({
|
|
302
|
+
structured: { view: 'error', ...base, error: code, detail: text },
|
|
303
|
+
text,
|
|
304
|
+
isError: true,
|
|
305
|
+
});
|
|
306
|
+
const done = (outcome, text, more = {}) => ({
|
|
307
|
+
structured: { view: 'shop-buy', ...base, outcome, ...more },
|
|
308
|
+
text,
|
|
309
|
+
});
|
|
310
|
+
switch (r.outcome) {
|
|
311
|
+
case 'off':
|
|
312
|
+
return err('shop-buy-off', `${NOT_OPEN} Nothing was ordered.`);
|
|
313
|
+
case 'shop-sign-in':
|
|
314
|
+
return err('shop-sign-in', `Nothing was ordered. ${shopSignInWords(used.shopLink)}`);
|
|
315
|
+
case 'busy':
|
|
316
|
+
return err('shop-busy', 'The shop is busy; nothing was ordered. Try again in a minute.');
|
|
317
|
+
case 'not-signed-in':
|
|
318
|
+
case 'session-expired':
|
|
319
|
+
return err('sign-in', `Nothing was ordered: shop orders need the guest signed in to their account${used.signIn ? ` (${used.signIn} gives them the page)` : ''}.`);
|
|
320
|
+
case 'booking-refused':
|
|
321
|
+
return err(`shop-booking-${r.why}`, r.why === 'not-found'
|
|
322
|
+
? "Nothing was ordered: a shop order goes with the guest's own hotel booking, and no booking of this account has that confirmation code. They need a hotel booking first."
|
|
323
|
+
: r.why === 'not-live'
|
|
324
|
+
? 'Nothing was ordered: that hotel booking is not live (it must be confirmed or awaiting payment).'
|
|
325
|
+
: 'Nothing was ordered: that hotel booking has already ended (check-out has passed).');
|
|
326
|
+
case 'refused': {
|
|
327
|
+
const words = {
|
|
328
|
+
quantity: 'The quantity must be a whole number from 1 to 10.',
|
|
329
|
+
'confirmation-code': 'The hotel booking code is missing or not valid.',
|
|
330
|
+
shown: 'The price the guest was shown is missing or not valid; list the item again.',
|
|
331
|
+
'not-found': 'That item is not in the shop.',
|
|
332
|
+
unavailable: 'That item is not available now.',
|
|
333
|
+
option: "That is not one of the item's options; the item's own options are in its listing.",
|
|
334
|
+
'in-progress': 'An order of this item is being made already; nothing was sent again.',
|
|
335
|
+
checking: `An order of this item was just tried and is not sent again; look at the orders (${used.ordersTool}) first.`,
|
|
336
|
+
backend: 'The shop did not take the order.',
|
|
337
|
+
};
|
|
338
|
+
return err(`shop-${r.why}`, `Nothing was ordered. ${words[r.why] ?? ''}`.trim());
|
|
339
|
+
}
|
|
340
|
+
case 'price-changed':
|
|
341
|
+
return done('price-changed', r.now
|
|
342
|
+
? `Nothing was ordered: the price is now ${shopMoney(r.now.unitCents, r.now.currency)} each, not the one the guest was shown. Say the new price and ask again.`
|
|
343
|
+
: 'Nothing was ordered: the price has changed. List the item again.', r.now
|
|
344
|
+
? {
|
|
345
|
+
now: {
|
|
346
|
+
price: shopMoney(r.now.unitCents, r.now.currency),
|
|
347
|
+
priceMinor: r.now.unitCents,
|
|
348
|
+
currency: r.now.currency,
|
|
349
|
+
},
|
|
350
|
+
}
|
|
351
|
+
: {});
|
|
352
|
+
case 'awaiting-payment': {
|
|
353
|
+
const host = hostOf(r.checkoutUrl);
|
|
354
|
+
return done('awaiting-payment', `The order is made and waiting for payment: ${r.order.name || 'shop order'}, ${shopMoney(r.order.totalCents, r.order.currency)} (order id \`${r.order.id}\`). The guest pays on the shop's checkout page, on ${host}: ${r.checkoutUrl}. Nothing is charged until they pay on that page.`, { order: orderForStructure(r.order), checkoutUrl: r.checkoutUrl, checkoutHost: host });
|
|
355
|
+
}
|
|
356
|
+
case 'wrong-amount':
|
|
357
|
+
case 'bad-link': {
|
|
358
|
+
const why = r.outcome === 'wrong-amount'
|
|
359
|
+
? 'the amount or currency was not what the guest was shown'
|
|
360
|
+
: 'its payment page was not one that is accepted here';
|
|
361
|
+
return r.cancelled
|
|
362
|
+
? done(r.outcome, `The order was cancelled: ${why}. Nothing was charged. No payment link is given.`, { cancelled: true, needsPerson: false })
|
|
363
|
+
: done(r.outcome, `The order could not be cancelled: ${why}. It has been passed to a person here; the guest must not pay it, and no payment link is given.`, { cancelled: false, needsPerson: true, ...(r.orderId ? { orderId: r.orderId } : {}) });
|
|
364
|
+
}
|
|
365
|
+
case 'paid': {
|
|
366
|
+
const amount = r.totalCents !== undefined && r.currency ? shopMoney(r.totalCents, r.currency) : undefined;
|
|
367
|
+
return done('paid', `The shop's backend charged a card on the guest's account${amount ? ` (${amount})` : ''}, as the guest confirmed. The order is kept (order id \`${r.order.id}\`).${r.needsPerson ? `${r.overShown ? ' The charge is MORE than the guest confirmed.' : ' The amount or currency is not the one the guest confirmed.'} Nothing was refunded or cancelled; a person here will look at it. Say exactly that.` : ''}`, {
|
|
368
|
+
order: orderForStructure(r.order),
|
|
369
|
+
needsPerson: r.needsPerson === true,
|
|
370
|
+
overShown: r.overShown,
|
|
371
|
+
...(amount ? { charged: amount } : {}),
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
case 'unknown':
|
|
375
|
+
return done('unknown', `It is not known whether an order was made: the shop did not answer. It was not sent again. Check the orders in a few minutes (${used.ordersTool})${r.needsPerson ? '; a person here has been told to look, and no payment link is given - the guest must not pay anything meanwhile' : ''}.`, { needsPerson: r.needsPerson === true });
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
//# sourceMappingURL=shop-answers.js.map
|
|
@@ -0,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AAU,KAAK,SAAS,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAC7F,OAAO,IAAI,CACT,MAAM,EACN,2DAA2D,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,2DAA2D,CAAC,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,+CAA+C,CAAC,CAAC,CAAC,6DAA6D,sFAAsF,CAAC,CAAC,CAAC,EAAE,EAAE,EAChZ;gBACE,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC;gBACjC,WAAW,EAAE,CAAC,CAAC,WAAW,KAAK,IAAI;gBACnC,SAAS,EAAE,CAAC,CAAC,SAAS;gBACtB,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACvC,CACF,CAAC;QACJ,CAAC;QACD,KAAK,SAAS;YACZ,OAAO,IAAI,CACT,SAAS,EACT,iIAAiI,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,iHAAiH,CAAC,CAAC,CAAC,EAAE,GAAG,EAC7R,EAAE,WAAW,EAAE,CAAC,CAAC,WAAW,KAAK,IAAI,EAAE,CACxC,CAAC;IACN,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { OtalessError } from './client.js';
|
|
2
|
+
/** The add-on service's own codes (document §5.3). */
|
|
3
|
+
export declare const ADDON_CODES: {
|
|
4
|
+
/** 4012: the channel session ran out - the same code as the hotel side's. */
|
|
5
|
+
readonly channelSessionExpired: 4012;
|
|
6
|
+
/** 4020: a virtual card was tried and refused - i.e. the backend TRIED A CARD. */
|
|
7
|
+
readonly vccFailed: 4020;
|
|
8
|
+
readonly orderNotFound: 4021;
|
|
9
|
+
readonly alreadyPaid: 4022;
|
|
10
|
+
readonly cannotRefund: 4023;
|
|
11
|
+
readonly internal: 500;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* ⚠️ THE ANSWER TO A WRITE IS NOT KNOWN (nothing said it was refused): no answer, an answer half
|
|
15
|
+
* read, a 5xx, a reply that is not the backend's, `code` 500, or 10014 (the backend refused a
|
|
16
|
+
* repeat - and the first of them may well have been made, §17.3). The order MAY exist and MAY be
|
|
17
|
+
* paid. Never resent - the caller reconciles through `orders`.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ShopUnknown extends OtalessError {
|
|
20
|
+
readonly unknown: true;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* ⚠️ THE SHOP WANTS ITS OWN SIGN-IN (live walkthrough 11-23): `/addon/*` with the platform token
|
|
24
|
+
* alone answers HTTP 200 `{"code":500,"msg":"sign_in_required"}`. NOTHING WAS MADE (it refused at
|
|
25
|
+
* the door), so it is never `ShopUnknown` even on a write - and it is not "failed" either: the
|
|
26
|
+
* guest is told the shop needs a separate sign-in, not that the shop broke.
|
|
27
|
+
*/
|
|
28
|
+
export declare class ShopSignInRequired extends OtalessError {
|
|
29
|
+
readonly shopSignIn: true;
|
|
30
|
+
}
|
|
31
|
+
/** Whether an error means "the write may have been made" (`ShopUnknown`). */
|
|
32
|
+
export declare const isUnknown: (err: unknown) => err is ShopUnknown;
|
|
33
|
+
/** One product as the backend sends it (`UnifiedAddonProductVo`) - loosely: nothing here is trusted. */
|
|
34
|
+
export type WireProduct = {
|
|
35
|
+
productId?: unknown;
|
|
36
|
+
name?: unknown;
|
|
37
|
+
description?: unknown;
|
|
38
|
+
category?: unknown;
|
|
39
|
+
price?: unknown;
|
|
40
|
+
currency?: unknown;
|
|
41
|
+
imageUrl?: unknown;
|
|
42
|
+
unit?: unknown;
|
|
43
|
+
options?: unknown;
|
|
44
|
+
available?: unknown;
|
|
45
|
+
};
|
|
46
|
+
/** 8's answer (`UnifiedAddonBuyResult`). */
|
|
47
|
+
export type WireBuy = {
|
|
48
|
+
success?: unknown;
|
|
49
|
+
status?: unknown;
|
|
50
|
+
unifiedOrderId?: unknown;
|
|
51
|
+
originalOrderId?: unknown;
|
|
52
|
+
totalAmount?: unknown;
|
|
53
|
+
currency?: unknown;
|
|
54
|
+
checkoutUrl?: unknown;
|
|
55
|
+
isVccPaid?: unknown;
|
|
56
|
+
};
|
|
57
|
+
/** One row of 11 (`UnifiedAddonOrderVo`). ⚠️ `refundUrl` is in the type to be dropped (#115). */
|
|
58
|
+
export type WireShopOrder = {
|
|
59
|
+
orderId?: unknown;
|
|
60
|
+
itemName?: unknown;
|
|
61
|
+
totalAmount?: unknown;
|
|
62
|
+
currency?: unknown;
|
|
63
|
+
status?: unknown;
|
|
64
|
+
refundUrl?: unknown;
|
|
65
|
+
checkoutUrl?: unknown;
|
|
66
|
+
};
|
|
67
|
+
/** 10's answer (`UnifiedAddonPaymentStatusResult`). */
|
|
68
|
+
export type WirePayStatus = {
|
|
69
|
+
success?: unknown;
|
|
70
|
+
status?: unknown;
|
|
71
|
+
pollAgain?: unknown;
|
|
72
|
+
orderId?: unknown;
|
|
73
|
+
};
|
|
74
|
+
/** 12's answer. */
|
|
75
|
+
export type WireShopCancel = {
|
|
76
|
+
success?: unknown;
|
|
77
|
+
status?: unknown;
|
|
78
|
+
};
|
|
79
|
+
/** 13's answer. */
|
|
80
|
+
export type WireShopRefund = {
|
|
81
|
+
success?: unknown;
|
|
82
|
+
status?: unknown;
|
|
83
|
+
refundAmount?: unknown;
|
|
84
|
+
};
|
|
85
|
+
export type ShopClientOptions = {
|
|
86
|
+
baseUrl: string;
|
|
87
|
+
tenant: string;
|
|
88
|
+
fetch?: typeof fetch;
|
|
89
|
+
now?: () => number;
|
|
90
|
+
/** How long one request is waited for. */
|
|
91
|
+
timeoutMs?: number;
|
|
92
|
+
/** How long 8 `/buy` is waited for (a cart and a checkout are made behind it) - at least `timeoutMs`. */
|
|
93
|
+
buyTimeoutMs?: number;
|
|
94
|
+
/** How long a READ refused as a repeat (10014) waits before it is asked once more. */
|
|
95
|
+
repeatPauseMs?: number;
|
|
96
|
+
/** Where a failure's detail goes - the backend's own words among it. Never a token. */
|
|
97
|
+
log?: (line: string) => void;
|
|
98
|
+
};
|
|
99
|
+
/** A request body: what the domain built, sent as it is. */
|
|
100
|
+
export type ShopBody = Record<string, unknown>;
|
|
101
|
+
export type ShopClient = {
|
|
102
|
+
/** 6 - anonymous. */
|
|
103
|
+
products: (body: ShopBody) => Promise<WireProduct[]>;
|
|
104
|
+
/** 7 - anonymous. */
|
|
105
|
+
productDetail: (body: ShopBody) => Promise<WireProduct>;
|
|
106
|
+
/** 8 - a member. ⚠️ NEVER SENT TWICE; its answer may be `ShopUnknown`. */
|
|
107
|
+
buy: (body: ShopBody, token: string) => Promise<WireBuy>;
|
|
108
|
+
/** 10 - a member. ⚠️ ALWAYS `once: true`, whatever the body says: never the backend's 50 s wait. */
|
|
109
|
+
paymentStatus: (body: ShopBody, token: string) => Promise<WirePayStatus>;
|
|
110
|
+
/** 11 - a member. */
|
|
111
|
+
orders: (body: ShopBody, token: string) => Promise<WireShopOrder[]>;
|
|
112
|
+
/** 12 - a member. ⚠️ NEVER SENT TWICE. */
|
|
113
|
+
cancel: (body: ShopBody, token: string) => Promise<WireShopCancel>;
|
|
114
|
+
/** 13 - a member. ⚠️ NEVER SENT TWICE. */
|
|
115
|
+
refund: (body: ShopBody, token: string) => Promise<WireShopRefund>;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* The backend's own limit on every add-on path: `@RateLimiter` 120 a minute per IP, and every guest
|
|
119
|
+
* of ours reaches it from one address - so the whole deployment is held a little under it, over a
|
|
120
|
+
* minute that slides (the hotel client's `PATH_LIMITS`, the same reasoning).
|
|
121
|
+
*/
|
|
122
|
+
export declare const SHOP_PATH_LIMIT = 100;
|
|
123
|
+
export declare const SHOP_PATHS: {
|
|
124
|
+
readonly products: "/api/v1/addon/products";
|
|
125
|
+
readonly productDetail: "/api/v1/addon/product-detail";
|
|
126
|
+
readonly buy: "/api/v1/addon/buy";
|
|
127
|
+
readonly paymentStatus: "/api/v1/addon/paymentStatus";
|
|
128
|
+
readonly orders: "/api/v1/addon/orders";
|
|
129
|
+
readonly cancel: "/api/v1/addon/cancel";
|
|
130
|
+
readonly refund: "/api/v1/addon/refund";
|
|
131
|
+
};
|
|
132
|
+
export declare const createShopClient: (opts: ShopClientOptions) => ShopClient;
|
|
133
|
+
//# sourceMappingURL=shop-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shop-client.d.ts","sourceRoot":"","sources":["../../src/otaless/shop-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,YAAY,EAA4B,MAAM,aAAa,CAAC;AAYjG,sDAAsD;AACtD,eAAO,MAAM,WAAW;IACtB,6EAA6E;;IAE7E,kFAAkF;;;;;;CAM1E,CAAC;AAEX;;;;;GAKG;AACH,qBAAa,WAAY,SAAQ,YAAY;IAC3C,QAAQ,CAAC,OAAO,EAAG,IAAI,CAAU;CAClC;AAED;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,YAAY;IAClD,QAAQ,CAAC,UAAU,EAAG,IAAI,CAAU;CACrC;AAED,6EAA6E;AAC7E,eAAO,MAAM,SAAS,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,WAAyC,CAAC;AAE1F,wGAAwG;AACxG,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,Q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