@curless/hotel-storefront 0.80.2 → 0.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/account/index.d.ts +14 -0
  2. package/dist/account/index.d.ts.map +1 -1
  3. package/dist/account/index.js +427 -43
  4. package/dist/account/index.js.map +1 -1
  5. package/dist/account/pages.d.ts +15 -2
  6. package/dist/account/pages.d.ts.map +1 -1
  7. package/dist/account/pages.js +13 -10
  8. package/dist/account/pages.js.map +1 -1
  9. package/dist/account/wallet-pages.d.ts +84 -0
  10. package/dist/account/wallet-pages.d.ts.map +1 -0
  11. package/dist/account/wallet-pages.js +229 -0
  12. package/dist/account/wallet-pages.js.map +1 -0
  13. package/dist/account/wallet.d.ts +163 -0
  14. package/dist/account/wallet.d.ts.map +1 -0
  15. package/dist/account/wallet.js +365 -0
  16. package/dist/account/wallet.js.map +1 -0
  17. package/dist/backend.d.ts +18 -0
  18. package/dist/backend.d.ts.map +1 -1
  19. package/dist/backend.js.map +1 -1
  20. package/dist/card-v168.generated.d.ts +6 -0
  21. package/dist/card-v168.generated.d.ts.map +1 -0
  22. package/dist/card-v168.generated.js +10 -0
  23. package/dist/card-v168.generated.js.map +1 -0
  24. package/dist/card.generated.d.ts +1 -1
  25. package/dist/card.generated.js +2 -2
  26. package/dist/card.generated.js.map +1 -1
  27. package/dist/config.d.ts +48 -2
  28. package/dist/config.d.ts.map +1 -1
  29. package/dist/config.js +14 -1
  30. package/dist/config.js.map +1 -1
  31. package/dist/huazhu/ari-sync.d.ts.map +1 -1
  32. package/dist/huazhu/ari-sync.js +15 -4
  33. package/dist/huazhu/ari-sync.js.map +1 -1
  34. package/dist/huazhu/check.d.ts.map +1 -1
  35. package/dist/huazhu/check.js +4 -1
  36. package/dist/huazhu/check.js.map +1 -1
  37. package/dist/huazhu/client.d.ts +48 -2
  38. package/dist/huazhu/client.d.ts.map +1 -1
  39. package/dist/huazhu/client.js +263 -3
  40. package/dist/huazhu/client.js.map +1 -1
  41. package/dist/huazhu/make.d.ts.map +1 -1
  42. package/dist/huazhu/make.js +6 -1
  43. package/dist/huazhu/make.js.map +1 -1
  44. package/dist/legal.d.ts.map +1 -1
  45. package/dist/legal.js +26 -4
  46. package/dist/legal.js.map +1 -1
  47. package/dist/otaless/client.d.ts +109 -0
  48. package/dist/otaless/client.d.ts.map +1 -1
  49. package/dist/otaless/client.js +44 -4
  50. package/dist/otaless/client.js.map +1 -1
  51. package/dist/otaless/fake.d.ts +92 -0
  52. package/dist/otaless/fake.d.ts.map +1 -1
  53. package/dist/otaless/fake.js +265 -0
  54. package/dist/otaless/fake.js.map +1 -1
  55. package/dist/otaless/make.d.ts +40 -1
  56. package/dist/otaless/make.d.ts.map +1 -1
  57. package/dist/otaless/make.js +150 -2
  58. package/dist/otaless/make.js.map +1 -1
  59. package/dist/otaless/shop-answers.d.ts +72 -0
  60. package/dist/otaless/shop-answers.d.ts.map +1 -0
  61. package/dist/otaless/shop-answers.js +344 -0
  62. package/dist/otaless/shop-answers.js.map +1 -0
  63. package/dist/otaless/shop-client.d.ts +133 -0
  64. package/dist/otaless/shop-client.d.ts.map +1 -0
  65. package/dist/otaless/shop-client.js +201 -0
  66. package/dist/otaless/shop-client.js.map +1 -0
  67. package/dist/otaless/shop-fake.d.ts +100 -0
  68. package/dist/otaless/shop-fake.d.ts.map +1 -0
  69. package/dist/otaless/shop-fake.js +259 -0
  70. package/dist/otaless/shop-fake.js.map +1 -0
  71. package/dist/otaless/shop-service.d.ts +105 -0
  72. package/dist/otaless/shop-service.d.ts.map +1 -0
  73. package/dist/otaless/shop-service.js +187 -0
  74. package/dist/otaless/shop-service.js.map +1 -0
  75. package/dist/otaless/shop.d.ts +160 -0
  76. package/dist/otaless/shop.d.ts.map +1 -0
  77. package/dist/otaless/shop.js +715 -0
  78. package/dist/otaless/shop.js.map +1 -0
  79. package/dist/otaless/wallet.d.ts +160 -0
  80. package/dist/otaless/wallet.d.ts.map +1 -0
  81. package/dist/otaless/wallet.js +650 -0
  82. package/dist/otaless/wallet.js.map +1 -0
  83. package/dist/server.d.ts +14 -3
  84. package/dist/server.d.ts.map +1 -1
  85. package/dist/server.js +41 -12
  86. package/dist/server.js.map +1 -1
  87. package/dist/surface.d.ts +7 -0
  88. package/dist/surface.d.ts.map +1 -1
  89. package/dist/surface.js +14 -0
  90. package/dist/surface.js.map +1 -1
  91. package/dist/tools.d.ts +98 -93
  92. package/dist/tools.d.ts.map +1 -1
  93. package/dist/tools.js +239 -1
  94. package/dist/tools.js.map +1 -1
  95. package/package.json +1 -1
@@ -0,0 +1,72 @@
1
+ import type { ShopBuyAnswer, ShopOrderOutcome, ShopOrderPreview } from './shop-service.js';
2
+ import type { ShopItem, ShopOrder, ShopOrderStatus, ShopWhy } from './shop.js';
3
+ export type Said = {
4
+ structured: Record<string, unknown>;
5
+ text: string;
6
+ isError?: true;
7
+ };
8
+ /** An amount with its currency, two decimals: `US$89.00`, `JPY 1200.00` (the shop's own figures, never rounded). */
9
+ export declare const shopMoney: (cents: number, currency: string) => string;
10
+ export declare const statusWords: (s: ShopOrderStatus) => string;
11
+ export declare const itemForStructure: (i: ShopItem) => {
12
+ imageUrl?: string | undefined;
13
+ description?: string | undefined;
14
+ category?: string | undefined;
15
+ unit?: string | undefined;
16
+ id: string;
17
+ name: string;
18
+ price: string;
19
+ priceMinor: number;
20
+ currency: string;
21
+ available: boolean;
22
+ options: string[];
23
+ };
24
+ export declare const orderForStructure: (o: ShopOrder) => {
25
+ checkoutUrl?: string | undefined;
26
+ checkoutHost?: string | undefined;
27
+ id: string;
28
+ name: string;
29
+ total: string;
30
+ totalMinor: number;
31
+ currency: string;
32
+ status: ShopOrderStatus;
33
+ statusWords: string;
34
+ };
35
+ export declare const orderLine: (o: ShopOrder) => string;
36
+ export declare const shopSignInAnswer: (base: Record<string, unknown>) => Said;
37
+ export declare const listAnswer: (base: Record<string, unknown>, r: {
38
+ ok: true;
39
+ items: ShopItem[];
40
+ } | {
41
+ ok: false;
42
+ why: ShopWhy | "not-found";
43
+ }, asked: {
44
+ query?: string;
45
+ category?: string;
46
+ maxPrice?: number;
47
+ }, buyOpen: boolean) => Said;
48
+ export declare const itemAnswer: (base: Record<string, unknown>, r: {
49
+ ok: true;
50
+ item: ShopItem;
51
+ } | {
52
+ ok: false;
53
+ why: ShopWhy | "not-found";
54
+ }, asked: string, buyOpen: boolean) => Said;
55
+ /** The shop-orders part of the bookings list: text lines and the structured array. */
56
+ export declare const ordersPart: (r: {
57
+ ok: true;
58
+ orders: ShopOrder[];
59
+ } | {
60
+ ok: false;
61
+ why: ShopWhy | "not-found";
62
+ }) => {
63
+ text: string;
64
+ structured: Record<string, unknown>;
65
+ } | undefined;
66
+ export declare const previewAnswer: (base: Record<string, unknown>, p: ShopOrderPreview, cancelTool: string, clock: (iso: string) => string) => Said;
67
+ export declare const finishAnswer: (base: Record<string, unknown>, o: ShopOrderOutcome, previewTool: string, ordersTool: string) => Said;
68
+ export declare const buyAnswer: (base: Record<string, unknown>, r: ShopBuyAnswer, used: {
69
+ ordersTool: string;
70
+ signIn?: string;
71
+ }) => Said;
72
+ //# sourceMappingURL=shop-answers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shop-answers.d.ts","sourceRoot":"","sources":["../../src/otaless/shop-answers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAS/E,MAAM,MAAM,IAAI,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB,CAAC;AAGF,oHAAoH;AACpH,eAAO,MAAM,SAAS,GAAI,OAAO,MA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AE,EAAE,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,OAAO,GAAG,WAAW,CAAA;CAAE,KAC/E;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,SAqB1D,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,gBAAgB,EACnB,YAAY,MAAM,EAClB,OAAO,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,KAC7B,IAyCF,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,gBAAgB,EACnB,aAAa,MAAM,EACnB,YAAY,MAAM,KACjB,IA0EF,CAAC;AAEF,eAAO,MAAM,SAAS,GACpB,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,aAAa,EAChB,MAAM;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAC5C,IA6GF,CAAC"}
@@ -0,0 +1,344 @@
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
+ failed: 'failed - nothing was taken',
16
+ unknown: 'status not known',
17
+ })[s];
18
+ const hostOf = (url) => {
19
+ try {
20
+ return new URL(url).host;
21
+ }
22
+ catch {
23
+ return '';
24
+ }
25
+ };
26
+ export const itemForStructure = (i) => ({
27
+ id: i.id,
28
+ name: i.name,
29
+ price: shopMoney(i.priceCents, i.currency),
30
+ priceMinor: i.priceCents,
31
+ currency: i.currency,
32
+ available: i.available,
33
+ options: i.options,
34
+ ...(i.unit ? { unit: i.unit } : {}),
35
+ ...(i.category ? { category: i.category } : {}),
36
+ ...(i.description ? { description: i.description } : {}),
37
+ // Already only a picture on an allowed host (shop.ts): listed here, drawn nowhere.
38
+ ...(i.imageUrl ? { imageUrl: i.imageUrl } : {}),
39
+ });
40
+ export const orderForStructure = (o) => ({
41
+ id: o.id,
42
+ name: o.name,
43
+ total: shopMoney(o.totalCents, o.currency),
44
+ totalMinor: o.totalCents,
45
+ currency: o.currency,
46
+ status: o.status,
47
+ statusWords: statusWords(o.status),
48
+ ...(o.checkoutUrl ? { checkoutUrl: o.checkoutUrl, checkoutHost: hostOf(o.checkoutUrl) } : {}),
49
+ });
50
+ 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}\``;
51
+ export const orderLine = (o) => `- ${o.name || 'Shop order'} — ${shopMoney(o.totalCents, o.currency)}, ${statusWords(o.status)}; order id \`${o.id}\`${o.checkoutUrl
52
+ ? `; payment page (on ${hostOf(o.checkoutUrl)}, the guest pays there): ${o.checkoutUrl}`
53
+ : ''}`;
54
+ const WHAT_IT_IS = "These are add-on goods from Otaless's shop, sold beside the hotel rooms - not hotel rooms or rates.";
55
+ const NOT_OPEN = 'Buying is not open here yet: nothing in the shop can be ordered through this connector.';
56
+ /**
57
+ * ⚠️ THE SHOP'S OWN SIGN-IN IS NOT OFFERED HERE YET (live walkthrough 11-23: the shop answers
58
+ * `sign_in_required` to the platform sign-in alone). Say exactly that - not "could not be read",
59
+ * not "sign in again" (the guest IS signed in; signing in here will not help).
60
+ */
61
+ const SHOP_SIGN_IN = "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.";
62
+ /** The error code of a refusal: `shop-<why>`, with the shop's own sign-in as `shop-sign-in`. */
63
+ const whyCode = (why) => (why === 'shop-sign-in' ? why : `shop-${why}`);
64
+ export const shopSignInAnswer = (base) => ({
65
+ structured: { view: 'error', ...base, error: 'shop-sign-in', detail: SHOP_SIGN_IN },
66
+ text: SHOP_SIGN_IN,
67
+ isError: true,
68
+ });
69
+ const whyReading = (why) => why === 'not-found'
70
+ ? 'No shop item matches that id.'
71
+ : why === 'shop-sign-in'
72
+ ? SHOP_SIGN_IN
73
+ : why === 'busy'
74
+ ? 'The shop is busy just now; ask again in a minute.'
75
+ : why === 'not-signed-in' || why === 'session-expired'
76
+ ? "The guest's sign-in is not valid for the shop just now; they sign in again."
77
+ : why === 'not-enabled'
78
+ ? 'There is no shop here.'
79
+ : 'The shop did not answer just now; nothing was changed.';
80
+ export const listAnswer = (base, r, asked, buyOpen) => {
81
+ if (!r.ok)
82
+ return {
83
+ structured: { view: 'error', ...base, error: whyCode(r.why), detail: whyReading(r.why) },
84
+ text: whyReading(r.why),
85
+ isError: true,
86
+ };
87
+ const filters = [
88
+ asked.query ? `matching "${asked.query}"` : '',
89
+ asked.category ? `in ${asked.category}` : '',
90
+ asked.maxPrice !== undefined ? `up to ${asked.maxPrice}` : '',
91
+ ]
92
+ .filter(Boolean)
93
+ .join(', ');
94
+ return {
95
+ structured: {
96
+ view: 'shop-items',
97
+ ...base,
98
+ items: r.items.map(itemForStructure),
99
+ count: r.items.length,
100
+ buyOpen,
101
+ ...(asked.query ? { query: asked.query } : {}),
102
+ },
103
+ text: [
104
+ WHAT_IT_IS,
105
+ r.items.length
106
+ ? `${r.items.length} item${r.items.length === 1 ? '' : 's'}${filters ? ` ${filters}` : ''}:`
107
+ : `Nothing in the shop${filters ? ` ${filters}` : ''}.`,
108
+ ...r.items.map(itemLine),
109
+ buyOpen ? '' : NOT_OPEN,
110
+ ]
111
+ .filter(Boolean)
112
+ .join('\n'),
113
+ };
114
+ };
115
+ export const itemAnswer = (base, r, asked, buyOpen) => {
116
+ if (!r.ok)
117
+ return {
118
+ structured: {
119
+ view: r.why === 'not-found' ? 'shop-item-not-found' : 'error',
120
+ ...base,
121
+ ...(r.why === 'not-found' ? { query: asked } : { error: whyCode(r.why) }),
122
+ detail: whyReading(r.why),
123
+ },
124
+ text: whyReading(r.why),
125
+ ...(r.why === 'not-found' ? {} : { isError: true }),
126
+ };
127
+ const i = r.item;
128
+ return {
129
+ structured: { view: 'shop-item', ...base, item: itemForStructure(i), buyOpen },
130
+ text: [
131
+ WHAT_IT_IS,
132
+ itemLine(i),
133
+ i.description ? `The shop's own description: "${i.description.slice(0, 400)}"` : '',
134
+ buyOpen ? '' : NOT_OPEN,
135
+ ]
136
+ .filter(Boolean)
137
+ .join('\n'),
138
+ };
139
+ };
140
+ /** The shop-orders part of the bookings list: text lines and the structured array. */
141
+ export const ordersPart = (r) => {
142
+ if (!r.ok) {
143
+ // Nobody signed in: there is nothing to say about shop orders.
144
+ if (r.why === 'not-signed-in')
145
+ return undefined;
146
+ // ⚠️ NOT "COULD NOT BE READ JUST NOW": that says try again, and trying again will not help.
147
+ if (r.why === 'shop-sign-in')
148
+ return { text: SHOP_SIGN_IN, structured: { shopOrdersNeedShopSignIn: true } };
149
+ return {
150
+ text: 'Shop orders could not be read just now - they are not listed, which does not mean there are none.',
151
+ structured: { shopOrdersUnavailable: true },
152
+ };
153
+ }
154
+ return {
155
+ text: r.orders.length
156
+ ? [
157
+ 'Shop orders (add-on goods, separate from the hotel bookings above):',
158
+ ...r.orders.map(orderLine),
159
+ ].join('\n')
160
+ : 'No shop orders on this account.',
161
+ structured: { shopOrders: r.orders.map(orderForStructure) },
162
+ };
163
+ };
164
+ export const previewAnswer = (base, p, cancelTool, clock) => {
165
+ if (!p.ok) {
166
+ const text = p.why === 'not-open'
167
+ ? `Shop order ${p.order?.name || ''} (\`${p.order?.id}\`) is ${p.order ? statusWords(p.order.status) : 'not open'}: there is nothing to cancel or refund.`
168
+ : p.why === 'not-found'
169
+ ? 'No shop order of this account matches that id.'
170
+ : whyReading(p.why);
171
+ return {
172
+ structured: {
173
+ view: 'error',
174
+ ...base,
175
+ error: whyCode(p.why),
176
+ detail: text,
177
+ ...(p.order ? { shopOrder: orderForStructure(p.order) } : {}),
178
+ },
179
+ text,
180
+ ...(p.why === 'not-found' ? {} : { isError: true }),
181
+ };
182
+ }
183
+ const total = shopMoney(p.order.totalCents, p.order.currency);
184
+ const what = `${p.order.name || 'Shop order'} (\`${p.order.id}\`)`;
185
+ const text = p.kind === 'cancel'
186
+ ? `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)}).`
187
+ : `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)}).`;
188
+ return {
189
+ structured: {
190
+ view: 'shop-order-preview',
191
+ ...base,
192
+ shopOrder: orderForStructure(p.order),
193
+ kind: p.kind === 'cancel' ? 'cancel-unpaid' : 'full-refund',
194
+ charged: p.kind === 'cancel' ? '0' : total,
195
+ ...(p.kind === 'refund'
196
+ ? { refund: total, refundMinor: p.order.totalCents, pointsTakenBack: true }
197
+ : {}),
198
+ until: p.until,
199
+ toolToConfirm: cancelTool,
200
+ },
201
+ text,
202
+ };
203
+ };
204
+ export const finishAnswer = (base, o, previewTool, ordersTool) => {
205
+ const err = (code, text) => ({
206
+ structured: { view: 'error', ...base, error: code, detail: text },
207
+ text,
208
+ isError: true,
209
+ });
210
+ if (o.outcome === 'cancelled')
211
+ return {
212
+ structured: {
213
+ view: 'shop-order-done',
214
+ ...base,
215
+ done: 'cancelled',
216
+ shopOrder: { ...orderForStructure(o.order), status: 'cancelled', statusWords: 'cancelled' },
217
+ },
218
+ text: `Shop order ${o.order.name || ''} (\`${o.order.id}\`) is cancelled. Nothing was charged.`,
219
+ };
220
+ if (o.outcome === 'refunded') {
221
+ const asked = shopMoney(o.order.totalCents, o.order.currency);
222
+ const said = o.refundCents !== undefined && o.refundCents !== o.order.totalCents
223
+ ? ` The shop reports ${shopMoney(o.refundCents, o.order.currency)} instead - a person here will look at it.`
224
+ : '';
225
+ return {
226
+ structured: {
227
+ view: 'shop-order-done',
228
+ ...base,
229
+ done: 'refunded',
230
+ refund: asked,
231
+ refundMinor: o.order.totalCents,
232
+ ...(o.refundCents !== undefined ? { shopSaidMinor: o.refundCents } : {}),
233
+ shopOrder: { ...orderForStructure(o.order), status: 'refunded', statusWords: 'refunded' },
234
+ },
235
+ 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}`,
236
+ };
237
+ }
238
+ if (o.outcome === 'unknown')
239
+ return {
240
+ structured: {
241
+ view: 'shop-order-unknown',
242
+ ...base,
243
+ done: 'unknown',
244
+ kind: o.kind,
245
+ shopOrder: orderForStructure(o.order),
246
+ },
247
+ text: `It is not known whether the ${o.kind === 'cancel' ? 'cancellation' : 'refund'} of \`${o.order.id}\` went through: the shop did not answer. 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.`,
248
+ };
249
+ switch (o.why) {
250
+ case 'refund-preview':
251
+ 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.`);
252
+ case 'in-progress':
253
+ return err('shop-in-progress', 'That is already being done; nothing was sent again.');
254
+ case 'checking':
255
+ return err('shop-checking', `That was done a moment ago and is not sent again; look at the orders (${ordersTool}) for where it stands.`);
256
+ case 'not-open':
257
+ return err('shop-not-open', 'That order is no longer one that can be cancelled or refunded.');
258
+ case 'not-found':
259
+ return err('shop-not-found', 'No shop order of this account matches that id; nothing was done.');
260
+ default:
261
+ return err(whyCode(o.why), o.why === 'failed'
262
+ ? 'The shop did not take it; nothing was changed.'
263
+ : `${whyReading(o.why)} Nothing was changed.`);
264
+ }
265
+ };
266
+ export const buyAnswer = (base, r, used) => {
267
+ const err = (code, text) => ({
268
+ structured: { view: 'error', ...base, error: code, detail: text },
269
+ text,
270
+ isError: true,
271
+ });
272
+ const done = (outcome, text, more = {}) => ({
273
+ structured: { view: 'shop-buy', ...base, outcome, ...more },
274
+ text,
275
+ });
276
+ switch (r.outcome) {
277
+ case 'off':
278
+ return err('shop-buy-off', `${NOT_OPEN} Nothing was ordered.`);
279
+ case 'shop-sign-in':
280
+ return err('shop-sign-in', `Nothing was ordered. ${SHOP_SIGN_IN}`);
281
+ case 'busy':
282
+ return err('shop-busy', 'The shop is busy; nothing was ordered. Try again in a minute.');
283
+ case 'not-signed-in':
284
+ case 'session-expired':
285
+ 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)` : ''}.`);
286
+ case 'booking-refused':
287
+ return err(`shop-booking-${r.why}`, r.why === 'not-found'
288
+ ? "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."
289
+ : r.why === 'not-live'
290
+ ? 'Nothing was ordered: that hotel booking is not live (it must be confirmed or awaiting payment).'
291
+ : 'Nothing was ordered: that hotel booking has already ended (check-out has passed).');
292
+ case 'refused': {
293
+ const words = {
294
+ quantity: 'The quantity must be a whole number from 1 to 10.',
295
+ 'confirmation-code': 'The hotel booking code is missing or not valid.',
296
+ shown: 'The price the guest was shown is missing or not valid; list the item again.',
297
+ 'not-found': 'That item is not in the shop.',
298
+ unavailable: 'That item is not available now.',
299
+ option: "That is not one of the item's options; the item's own options are in its listing.",
300
+ 'in-progress': 'An order of this item is being made already; nothing was sent again.',
301
+ checking: `An order of this item was just tried and is not sent again; look at the orders (${used.ordersTool}) first.`,
302
+ backend: 'The shop did not take the order.',
303
+ };
304
+ return err(`shop-${r.why}`, `Nothing was ordered. ${words[r.why] ?? ''}`.trim());
305
+ }
306
+ case 'price-changed':
307
+ return done('price-changed', r.now
308
+ ? `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.`
309
+ : 'Nothing was ordered: the price has changed. List the item again.', r.now
310
+ ? {
311
+ now: {
312
+ price: shopMoney(r.now.unitCents, r.now.currency),
313
+ priceMinor: r.now.unitCents,
314
+ currency: r.now.currency,
315
+ },
316
+ }
317
+ : {});
318
+ case 'awaiting-payment': {
319
+ const host = hostOf(r.checkoutUrl);
320
+ 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 });
321
+ }
322
+ case 'wrong-amount':
323
+ case 'bad-link': {
324
+ const why = r.outcome === 'wrong-amount'
325
+ ? 'the amount or currency was not what the guest was shown'
326
+ : 'its payment page was not one that is accepted here';
327
+ return r.cancelled
328
+ ? done(r.outcome, `The order was cancelled: ${why}. Nothing was charged. No payment link is given.`, { cancelled: true, needsPerson: false })
329
+ : 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 } : {}) });
330
+ }
331
+ case 'charged-without-asking': {
332
+ const amount = r.totalCents !== undefined && r.currency ? shopMoney(r.totalCents, r.currency) : undefined;
333
+ return done('charged-without-asking', `The shop's backend charged a card on the guest's account by itself${amount ? ` (${amount})` : ''}, without the guest choosing it on a payment page${r.overShown ? ' - and more than they were shown' : ''}. The order is kept (order id \`${r.order.id}\`) and a person here will look at it. Say exactly that; do not call it a normal payment.`, {
334
+ order: orderForStructure(r.order),
335
+ needsPerson: true,
336
+ overShown: r.overShown,
337
+ ...(amount ? { charged: amount } : {}),
338
+ });
339
+ }
340
+ case 'unknown':
341
+ 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 });
342
+ }
343
+ };
344
+ //# sourceMappingURL=shop-answers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shop-answers.js","sourceRoot":"","sources":["../../src/otaless/shop-answers.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,GAA2B,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;AACnG,oHAAoH;AACpH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,QAAgB,EAAU,EAAE;IACnE,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9B,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACnC,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,CAAC,EAAE,CAAC;AACjD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAkB,EAAU,EAAE,CACxD,CAAC;IACC,kBAAkB,EAAE,kBAAkB;IACtC,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,oBAAoB;IAC/B,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,QAAQ,E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AAK,wBAAwB,CAAC,CAAC,CAAC;YAC9B,MAAM,MAAM,GACV,CAAC,CAAC,UAAU,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,wBAAwB,EACxB,qEAAqE,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,oDAAoD,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,EAAE,mCAAmC,CAAC,CAAC,KAAK,CAAC,EAAE,2FAA2F,EAClV;gBACE,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC;gBACjC,WAAW,EAAE,IAAI;gBACjB,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;IACx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