@estoreclub/api 0.0.0-stage → 0.1.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/bridgeClient.d.ts +10 -0
- package/dist/bridgeClient.js +10 -0
- package/dist/bridgeClient.js.map +7 -0
- package/dist/chunks/chunk-2554RPSS.js +45 -0
- package/dist/chunks/chunk-2554RPSS.js.map +7 -0
- package/dist/chunks/chunk-2BH4QPV2.js +27 -0
- package/dist/chunks/chunk-2BH4QPV2.js.map +7 -0
- package/dist/chunks/chunk-3KEEGSMP.js +86 -0
- package/dist/chunks/chunk-3KEEGSMP.js.map +7 -0
- package/dist/chunks/chunk-5DN7L6LX.js +861 -0
- package/dist/chunks/chunk-5DN7L6LX.js.map +7 -0
- package/dist/chunks/chunk-DUVULZ6N.js +111 -0
- package/dist/chunks/chunk-DUVULZ6N.js.map +7 -0
- package/dist/chunks/chunk-GJZ7EZEF.js +25 -0
- package/dist/chunks/chunk-GJZ7EZEF.js.map +7 -0
- package/dist/chunks/chunk-HFEQWXG6.js +24 -0
- package/dist/chunks/chunk-HFEQWXG6.js.map +7 -0
- package/dist/chunks/chunk-OFFTL6RC.js +24 -0
- package/dist/chunks/chunk-OFFTL6RC.js.map +7 -0
- package/dist/chunks/chunk-TSERNR4R.js +15 -0
- package/dist/chunks/chunk-TSERNR4R.js.map +7 -0
- package/dist/chunks/chunk-ZITPZDI7.js +280 -0
- package/dist/chunks/chunk-ZITPZDI7.js.map +7 -0
- package/dist/client.d.ts +407 -0
- package/dist/client.js +14 -0
- package/dist/client.js.map +7 -0
- package/dist/companyApiKey.d.ts +9 -0
- package/dist/companyApiKey.js +9 -0
- package/dist/companyApiKey.js.map +7 -0
- package/dist/customerToken.d.ts +18 -0
- package/dist/customerToken.js +11 -0
- package/dist/customerToken.js.map +7 -0
- package/dist/errors.d.ts +41 -0
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +7 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +166 -0
- package/dist/index.js.map +7 -0
- package/dist/language.d.ts +27 -0
- package/dist/language.js +11 -0
- package/dist/language.js.map +7 -0
- package/dist/params.d.ts +58 -0
- package/dist/params.js +27 -0
- package/dist/params.js.map +7 -0
- package/dist/requestCache.d.ts +46 -0
- package/dist/requestCache.js +9 -0
- package/dist/requestCache.js.map +7 -0
- package/dist/siteData.d.ts +237 -0
- package/dist/siteData.js +132 -0
- package/dist/siteData.js.map +7 -0
- package/dist/types.d.ts +2123 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +7 -0
- package/dist/visitorCountry.d.ts +25 -0
- package/dist/visitorCountry.js +15 -0
- package/dist/visitorCountry.js.map +7 -0
- package/package.json +64 -4
- package/README.md +0 -3
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createBridgeClient,
|
|
3
|
+
hasServiceBridge
|
|
4
|
+
} from "./chunk-DUVULZ6N.js";
|
|
5
|
+
import {
|
|
6
|
+
createPublicApiClient
|
|
7
|
+
} from "./chunk-5DN7L6LX.js";
|
|
8
|
+
import {
|
|
9
|
+
getCompanyApiKey
|
|
10
|
+
} from "./chunk-TSERNR4R.js";
|
|
11
|
+
import {
|
|
12
|
+
PublicApiError
|
|
13
|
+
} from "./chunk-GJZ7EZEF.js";
|
|
14
|
+
|
|
15
|
+
// packages/api/src/siteData.ts
|
|
16
|
+
var client = null;
|
|
17
|
+
function api() {
|
|
18
|
+
if (client) return client;
|
|
19
|
+
if (hasServiceBridge()) {
|
|
20
|
+
client = createBridgeClient();
|
|
21
|
+
return client;
|
|
22
|
+
}
|
|
23
|
+
const env = globalThis.process?.env ?? {};
|
|
24
|
+
const companyApiKey = env.COMPANY_API_KEY ?? "";
|
|
25
|
+
const runtimeKey = getCompanyApiKey();
|
|
26
|
+
const productSample = env.COMPANY_SAMPLE_PRODUCTS?.trim();
|
|
27
|
+
if (!companyApiKey && !runtimeKey && !productSample) {
|
|
28
|
+
throw new PublicApiError("not configured - set COMPANY_API_KEY");
|
|
29
|
+
}
|
|
30
|
+
client = createPublicApiClient({
|
|
31
|
+
baseUrl: env.NEXT_PUBLIC_SERVER_URL ?? "http://localhost:4000",
|
|
32
|
+
// A key set at runtime is left out of the config on purpose — the client reads it per
|
|
33
|
+
// request, so a later `setCompanyApiKey()` still applies to this cached client.
|
|
34
|
+
...companyApiKey ? { companyApiKey } : {},
|
|
35
|
+
...productSample ? { productSample } : {},
|
|
36
|
+
// Set by `scripts/build-templates.mjs` for the preview export, which has no request time.
|
|
37
|
+
...env.TEMPLATE_EXPORT ? { cache: "force-cache" } : {}
|
|
38
|
+
});
|
|
39
|
+
return client;
|
|
40
|
+
}
|
|
41
|
+
async function getSiteInfo() {
|
|
42
|
+
return api().getSiteInfo();
|
|
43
|
+
}
|
|
44
|
+
async function getCategories(params = {}) {
|
|
45
|
+
return api().getCategories(params);
|
|
46
|
+
}
|
|
47
|
+
async function getCategory(params) {
|
|
48
|
+
return api().getCategory(params);
|
|
49
|
+
}
|
|
50
|
+
async function getProduct(params) {
|
|
51
|
+
return api().getProduct(params);
|
|
52
|
+
}
|
|
53
|
+
async function getLocations() {
|
|
54
|
+
return api().getLocations();
|
|
55
|
+
}
|
|
56
|
+
async function getDiningTable(params) {
|
|
57
|
+
return api().getDiningTable(params);
|
|
58
|
+
}
|
|
59
|
+
async function verifyDiningTableCode(params) {
|
|
60
|
+
return api().verifyDiningTableCode(params);
|
|
61
|
+
}
|
|
62
|
+
async function getTerms(params = {}) {
|
|
63
|
+
return api().getTerms(params);
|
|
64
|
+
}
|
|
65
|
+
async function getOrderTimes(params = {}) {
|
|
66
|
+
return api().getOrderTimes(params);
|
|
67
|
+
}
|
|
68
|
+
async function getBookingSlots(params) {
|
|
69
|
+
return api().getBookingSlots(params);
|
|
70
|
+
}
|
|
71
|
+
async function getBookingPlan(params) {
|
|
72
|
+
return api().getBookingPlan(params);
|
|
73
|
+
}
|
|
74
|
+
async function createBooking(params) {
|
|
75
|
+
return api().createBooking(params);
|
|
76
|
+
}
|
|
77
|
+
async function requestSignInCode(params) {
|
|
78
|
+
return api().requestSignInCode(params);
|
|
79
|
+
}
|
|
80
|
+
async function verifySignInCode(params) {
|
|
81
|
+
return api().verifySignInCode(params);
|
|
82
|
+
}
|
|
83
|
+
async function signInWithGoogle(params) {
|
|
84
|
+
return api().signInWithGoogle(params);
|
|
85
|
+
}
|
|
86
|
+
async function signInWithApple(params) {
|
|
87
|
+
return api().signInWithApple(params);
|
|
88
|
+
}
|
|
89
|
+
async function getCustomerAccount(params) {
|
|
90
|
+
return api().getCustomerAccount(params);
|
|
91
|
+
}
|
|
92
|
+
async function getCustomerOrders(params) {
|
|
93
|
+
return api().getCustomerOrders(params);
|
|
94
|
+
}
|
|
95
|
+
async function getCustomerOrder(params) {
|
|
96
|
+
return api().getCustomerOrder(params);
|
|
97
|
+
}
|
|
98
|
+
async function getCustomerBookings(params) {
|
|
99
|
+
return api().getCustomerBookings(params);
|
|
100
|
+
}
|
|
101
|
+
async function cancelCustomerBooking(params) {
|
|
102
|
+
return api().cancelCustomerBooking(params);
|
|
103
|
+
}
|
|
104
|
+
async function setCustomerBookingPreorder(params) {
|
|
105
|
+
return api().setCustomerBookingPreorder(params);
|
|
106
|
+
}
|
|
107
|
+
async function getCustomerAddresses(params) {
|
|
108
|
+
return api().getCustomerAddresses(params);
|
|
109
|
+
}
|
|
110
|
+
async function addCustomerAddress(params) {
|
|
111
|
+
return api().addCustomerAddress(params);
|
|
112
|
+
}
|
|
113
|
+
async function deleteCustomerAddress(params) {
|
|
114
|
+
return api().deleteCustomerAddress(params);
|
|
115
|
+
}
|
|
116
|
+
async function getCustomerPaymentMethods(params) {
|
|
117
|
+
return api().getCustomerPaymentMethods(params);
|
|
118
|
+
}
|
|
119
|
+
async function deleteCustomerPaymentMethod(params) {
|
|
120
|
+
return api().deleteCustomerPaymentMethod(params);
|
|
121
|
+
}
|
|
122
|
+
async function getCustomerFavourites(params) {
|
|
123
|
+
return api().getCustomerFavourites(params);
|
|
124
|
+
}
|
|
125
|
+
async function getCustomerFavouriteIds(params) {
|
|
126
|
+
return api().getCustomerFavouriteIds(params);
|
|
127
|
+
}
|
|
128
|
+
async function addCustomerFavourite(params) {
|
|
129
|
+
return api().addCustomerFavourite(params);
|
|
130
|
+
}
|
|
131
|
+
async function removeCustomerFavourite(params) {
|
|
132
|
+
return api().removeCustomerFavourite(params);
|
|
133
|
+
}
|
|
134
|
+
async function updateCustomerProfile(params) {
|
|
135
|
+
return api().updateCustomerProfile(params);
|
|
136
|
+
}
|
|
137
|
+
async function getProductFeedback(params) {
|
|
138
|
+
return api().getProductFeedback(params);
|
|
139
|
+
}
|
|
140
|
+
async function getProductComments(params) {
|
|
141
|
+
return api().getProductComments(params);
|
|
142
|
+
}
|
|
143
|
+
async function createProductComment(params) {
|
|
144
|
+
return api().createProductComment(params);
|
|
145
|
+
}
|
|
146
|
+
async function deleteProductComment(params) {
|
|
147
|
+
return api().deleteProductComment(params);
|
|
148
|
+
}
|
|
149
|
+
async function rateProduct(params) {
|
|
150
|
+
return api().rateProduct(params);
|
|
151
|
+
}
|
|
152
|
+
async function unrateProduct(params) {
|
|
153
|
+
return api().unrateProduct(params);
|
|
154
|
+
}
|
|
155
|
+
async function voteProductComment(params) {
|
|
156
|
+
return api().voteProductComment(params);
|
|
157
|
+
}
|
|
158
|
+
async function getProductSettings(params = {}) {
|
|
159
|
+
return api().getProductSettings(params);
|
|
160
|
+
}
|
|
161
|
+
async function getCombos(params = {}) {
|
|
162
|
+
return api().getCombos(params);
|
|
163
|
+
}
|
|
164
|
+
async function getDiscountRules() {
|
|
165
|
+
return api().getDiscountRules();
|
|
166
|
+
}
|
|
167
|
+
async function listDictionaries() {
|
|
168
|
+
return api().listDictionaries();
|
|
169
|
+
}
|
|
170
|
+
async function getDictionary(params) {
|
|
171
|
+
return api().getDictionary(params);
|
|
172
|
+
}
|
|
173
|
+
async function getDictionaries(params) {
|
|
174
|
+
return api().getDictionaries(params);
|
|
175
|
+
}
|
|
176
|
+
async function lookupImages(params) {
|
|
177
|
+
return api().lookupImages(params);
|
|
178
|
+
}
|
|
179
|
+
async function getProducts(params = {}) {
|
|
180
|
+
return api().getProducts(params);
|
|
181
|
+
}
|
|
182
|
+
async function createCart() {
|
|
183
|
+
return api().createCart();
|
|
184
|
+
}
|
|
185
|
+
async function getCart(params) {
|
|
186
|
+
return api().getCart(params);
|
|
187
|
+
}
|
|
188
|
+
async function addCartItem(params) {
|
|
189
|
+
return api().addCartItem(params);
|
|
190
|
+
}
|
|
191
|
+
async function setCartItemQuantity(params) {
|
|
192
|
+
return api().setCartItemQuantity(params);
|
|
193
|
+
}
|
|
194
|
+
async function removeCartItem(params) {
|
|
195
|
+
return api().removeCartItem(params);
|
|
196
|
+
}
|
|
197
|
+
async function setCartBooking(params) {
|
|
198
|
+
return api().setCartBooking(params);
|
|
199
|
+
}
|
|
200
|
+
async function destroyCart(params) {
|
|
201
|
+
return api().destroyCart(params);
|
|
202
|
+
}
|
|
203
|
+
async function getCheckout(params) {
|
|
204
|
+
return api().getCheckout(params);
|
|
205
|
+
}
|
|
206
|
+
async function trackOrder(params) {
|
|
207
|
+
return api().trackOrder(params);
|
|
208
|
+
}
|
|
209
|
+
async function setCheckoutEmail(params) {
|
|
210
|
+
return api().setCheckoutEmail(params);
|
|
211
|
+
}
|
|
212
|
+
async function createCheckout(params) {
|
|
213
|
+
return api().createCheckout(params);
|
|
214
|
+
}
|
|
215
|
+
function resetSiteData() {
|
|
216
|
+
client = null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export {
|
|
220
|
+
getSiteInfo,
|
|
221
|
+
getCategories,
|
|
222
|
+
getCategory,
|
|
223
|
+
getProduct,
|
|
224
|
+
getLocations,
|
|
225
|
+
getDiningTable,
|
|
226
|
+
verifyDiningTableCode,
|
|
227
|
+
getTerms,
|
|
228
|
+
getOrderTimes,
|
|
229
|
+
getBookingSlots,
|
|
230
|
+
getBookingPlan,
|
|
231
|
+
createBooking,
|
|
232
|
+
requestSignInCode,
|
|
233
|
+
verifySignInCode,
|
|
234
|
+
signInWithGoogle,
|
|
235
|
+
signInWithApple,
|
|
236
|
+
getCustomerAccount,
|
|
237
|
+
getCustomerOrders,
|
|
238
|
+
getCustomerOrder,
|
|
239
|
+
getCustomerBookings,
|
|
240
|
+
cancelCustomerBooking,
|
|
241
|
+
setCustomerBookingPreorder,
|
|
242
|
+
getCustomerAddresses,
|
|
243
|
+
addCustomerAddress,
|
|
244
|
+
deleteCustomerAddress,
|
|
245
|
+
getCustomerPaymentMethods,
|
|
246
|
+
deleteCustomerPaymentMethod,
|
|
247
|
+
getCustomerFavourites,
|
|
248
|
+
getCustomerFavouriteIds,
|
|
249
|
+
addCustomerFavourite,
|
|
250
|
+
removeCustomerFavourite,
|
|
251
|
+
updateCustomerProfile,
|
|
252
|
+
getProductFeedback,
|
|
253
|
+
getProductComments,
|
|
254
|
+
createProductComment,
|
|
255
|
+
deleteProductComment,
|
|
256
|
+
rateProduct,
|
|
257
|
+
unrateProduct,
|
|
258
|
+
voteProductComment,
|
|
259
|
+
getProductSettings,
|
|
260
|
+
getCombos,
|
|
261
|
+
getDiscountRules,
|
|
262
|
+
listDictionaries,
|
|
263
|
+
getDictionary,
|
|
264
|
+
getDictionaries,
|
|
265
|
+
lookupImages,
|
|
266
|
+
getProducts,
|
|
267
|
+
createCart,
|
|
268
|
+
getCart,
|
|
269
|
+
addCartItem,
|
|
270
|
+
setCartItemQuantity,
|
|
271
|
+
removeCartItem,
|
|
272
|
+
setCartBooking,
|
|
273
|
+
destroyCart,
|
|
274
|
+
getCheckout,
|
|
275
|
+
trackOrder,
|
|
276
|
+
setCheckoutEmail,
|
|
277
|
+
createCheckout,
|
|
278
|
+
resetSiteData
|
|
279
|
+
};
|
|
280
|
+
//# sourceMappingURL=chunk-ZITPZDI7.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../packages/api/src/siteData.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n CreateBookingParams,\n CustomerTokenParams,\n SetBookingPreorderParams,\n CustomerHistoryParams,\n CustomerBookingsParams,\n AddCustomerAddressParams,\n CreateProductCommentParams,\n DeleteProductCommentParams,\n GetProductCommentsParams,\n GetProductFeedbackParams,\n RateProductParams,\n UnrateProductParams,\n VoteProductCommentParams,\n GetBookingPlanParams,\n GetBookingSlotsParams,\n GetOrderTimesParams,\n GetCategoryParams,\n GetDictionaryParams,\n GetProductParams,\n ListCategoriesParams,\n ListCombosParams,\n ListProductsParams,\n RequestSignInCodeParams,\n SignInWithAppleParams,\n SignInWithGoogleParams,\n UpdateCustomerProfileParams,\n VerifySignInCodeParams,\n} from \"./types\";\n\nimport { createPublicApiClient, type PublicApiClient } from \"./client\";\nimport { createBridgeClient, hasServiceBridge } from \"./bridgeClient\";\nimport { getCompanyApiKey } from \"./companyApiKey\";\nimport { PublicApiError } from \"./errors\";\n\n/**\n * The site's own data, for a page that just wants to read it.\n *\n * `createPublicApiClient` needs a base URL and a key. A page should not be\n * assembling those \u2014 so this module does it once, from the environment, and exposes the four\n * reads a page actually makes. It is what page code imports:\n *\n * ```ts\n * import { getProducts, getSiteInfo } from \"@estoreclub/api\";\n * ```\n *\n * NEXT_PUBLIC_SERVER_URL the API, default http://localhost:4000\n * COMPANY_API_KEY this site's own key, and the only credential involved\n * COMPANY_SAMPLE_PRODUCTS optional: a product sample's slug (`sample-pizza`) to read INSTEAD of\n * the company's own catalogue \u2014 the menu the template was designed\n * around. Site info still comes from the company; checkout is off\n *\n * There is no `SITE_DOMAIN`, and no platform key. Every public route authenticates with\n * `x-company-api-key` and the server resolves the company from it, so the key is the whole\n * answer to \"whose data is this?\". Resolving a host or a deployment id INTO that key is the\n * job of the trusted layer in front of the page \u2014 the preview's route handler, a site's own\n * server \u2014 which sets it here, either in the environment or through `setCompanyApiKey()`.\n *\n * **SERVER ONLY.** Importing this from a `\"use client\"` file would put the key in a bundle the\n * visitor can read. Fetch in a server component and pass the result down as props.\n *\n * With no key set every call rejects. That is the honest answer, and a page is expected to\n * handle it: catch the rejection and render an empty state, rather than invent content.\n */\nlet client: PublicApiClient | null = null;\n\nfunction api(): PublicApiClient {\n if (client) return client;\n\n /**\n * Inside the render sandbox, the data bridge answers instead of `fetch`.\n *\n * When the host installed `globalThis.__service`, every call is forwarded to the trusted\n * parent, which holds the company key and makes the request. No key is read here and none is\n * needed \u2014 which is the whole point: page code in the sandbox never touches the credential.\n * The environment path below is for a site running standalone (`next dev`), where the author\n * IS the trusted layer and sets `COMPANY_API_KEY` themselves.\n */\n if (hasServiceBridge()) {\n client = createBridgeClient();\n\n return client;\n }\n\n const env =\n (globalThis as { process?: { env?: Record<string, string | undefined> } })\n .process?.env ?? {};\n const companyApiKey = env.COMPANY_API_KEY ?? \"\";\n\n // A key set at runtime counts as configured: the host may have called `setCompanyApiKey()`\n // with something it resolved itself, and there would be nothing in the environment to see.\n const runtimeKey = getCompanyApiKey();\n\n const productSample = env.COMPANY_SAMPLE_PRODUCTS?.trim();\n\n // Said plainly, and once: the alternative is four identical 401s that read like an outage. A\n // sample needs no key - its showcase is the site (a template preview).\n if (!companyApiKey && !runtimeKey && !productSample) {\n throw new PublicApiError(\"not configured - set COMPANY_API_KEY\");\n }\n\n client = createPublicApiClient({\n baseUrl: env.NEXT_PUBLIC_SERVER_URL ?? \"http://localhost:4000\",\n // A key set at runtime is left out of the config on purpose \u2014 the client reads it per\n // request, so a later `setCompanyApiKey()` still applies to this cached client.\n ...(companyApiKey ? { companyApiKey } : {}),\n ...(productSample ? { productSample } : {}),\n // Set by `scripts/build-templates.mjs` for the preview export, which has no request time.\n ...(env.TEMPLATE_EXPORT ? { cache: \"force-cache\" as const } : {}),\n });\n\n return client;\n}\n\n/**\n * Every export below is `async`, and that is load-bearing rather than stylistic.\n *\n * A page handles an unavailable call with `.catch()` or a rejection handler. If a missing\n * environment variable were THROWN synchronously, it would throw before the caller had a\n * handler attached, and a page's `.catch()` would never run.\n */\nexport async function getSiteInfo() {\n return api().getSiteInfo();\n}\n\n/** Categories. Every optional part (`include`) unless the page narrows it. */\nexport async function getCategories(params: ListCategoriesParams = {}) {\n return api().getCategories(params);\n}\n\n/** One category by `{ id }` or `{ name }`. */\nexport async function getCategory(params: GetCategoryParams) {\n return api().getCategory(params);\n}\n\n/** One product by `{ id }` or `{ name }` \u2014 see `getCategory` for how a name is matched. */\nexport async function getProduct(params: GetProductParams) {\n return api().getProduct(params);\n}\n\n/** The shop's locations, in its order \u2014 for a \"find us\" list or a map. */\nexport async function getLocations() {\n return api().getLocations();\n}\n\n/** A table a guest is ordering from, by the id on its QR code. */\nexport async function getDiningTable(params: { tableId: string }) {\n return api().getDiningTable(params);\n}\n\n/** Checks the code staff gave a guest at this table; rejects a wrong one. Books nothing. */\nexport async function verifyDiningTableCode(params: {\n tableId: string;\n code: string;\n}) {\n return api().verifyDiningTableCode(params);\n}\n\n/** The shop's terms and privacy policy: whether they must be accepted, and the text (Markdown). */\nexport async function getTerms(params: { language?: string } = {}) {\n return api().getTerms(params);\n}\n\n/** When an order can be for: now, and the later times on the location's clock. */\nexport async function getOrderTimes(params: GetOrderTimesParams = {}) {\n return api().getOrderTimes(params);\n}\n\n/** The times a party can book on a day at a location, each free or full. */\nexport async function getBookingSlots(params: GetBookingSlotsParams) {\n return api().getBookingSlots(params);\n}\n\n/** The location's floor plan at a time, which tables are free, and the best fit. */\nexport async function getBookingPlan(params: GetBookingPlanParams) {\n return api().getBookingPlan(params);\n}\n\n/** Book a table \u2014 confirmed at once; 409 when none is free any more. */\nexport async function createBooking(params: CreateBookingParams) {\n return api().createBooking(params);\n}\n\n/**\n * Signing a customer in \u2014 the ways `getSiteInfo().customerSignInMethods` turns on.\n *\n * An emailed code (`requestSignInCode`, then `verifySignInCode`), Google (`signInWithGoogle`) or\n * Apple (`signInWithApple`) answers with a `token`. Keep it in an httpOnly cookie set by the\n * site's SERVER \u2014 never in page script \u2014 and pass it as `customerToken` to `createCheckout`,\n * `createBooking` and the account calls: what is made with it belongs to the customer.\n */\nexport async function requestSignInCode(params: RequestSignInCodeParams) {\n return api().requestSignInCode(params);\n}\n\nexport async function verifySignInCode(params: VerifySignInCodeParams) {\n return api().verifySignInCode(params);\n}\n\nexport async function signInWithGoogle(params: SignInWithGoogleParams) {\n return api().signInWithGoogle(params);\n}\n\nexport async function signInWithApple(params: SignInWithAppleParams) {\n return api().signInWithApple(params);\n}\n\n/** The signed-in customer, with their recent orders and bookings. */\nexport async function getCustomerAccount(params: CustomerTokenParams) {\n return api().getCustomerAccount(params);\n}\n\n/** The signed-in customer's orders on this site, newest first. */\nexport async function getCustomerOrders(\n params: CustomerTokenParams & CustomerHistoryParams,\n) {\n return api().getCustomerOrders(params);\n}\n\n/** One of their orders, with its lines. */\nexport async function getCustomerOrder(\n params: CustomerTokenParams & { orderId: string },\n) {\n return api().getCustomerOrder(params);\n}\n\n/** Their bookings \u2014 upcoming by default. */\nexport async function getCustomerBookings(\n params: CustomerTokenParams & CustomerBookingsParams,\n) {\n return api().getCustomerBookings(params);\n}\n\n/** Calls off one of their bookings, while it is still ahead. */\nexport async function cancelCustomerBooking(\n params: CustomerTokenParams & { bookingId: string },\n) {\n return api().cancelCustomerBooking(params);\n}\n\n/** Sets the dishes they order ahead for one of their bookings, replacing what was there. */\nexport async function setCustomerBookingPreorder(\n params: SetBookingPreorderParams,\n) {\n return api().setCustomerBookingPreorder(params);\n}\n\n/** The places they have had orders delivered to, or saved - the one used last first. */\nexport async function getCustomerAddresses(params: CustomerTokenParams) {\n return api().getCustomerAddresses(params);\n}\n\n/** Saves an address for them. */\nexport async function addCustomerAddress(params: AddCustomerAddressParams) {\n return api().addCustomerAddress(params);\n}\n\n/** Forgets one of their addresses. */\nexport async function deleteCustomerAddress(\n params: CustomerTokenParams & { customerAddressId: string },\n) {\n return api().deleteCustomerAddress(params);\n}\n\n/** The cards they saved paying here - nothing that can pay. */\nexport async function getCustomerPaymentMethods(params: CustomerTokenParams) {\n return api().getCustomerPaymentMethods(params);\n}\n\n/** Removes one of their saved cards; refused for one an upcoming booking keeps. */\nexport async function deleteCustomerPaymentMethod(\n params: CustomerTokenParams & { paymentMethodId: string },\n) {\n return api().deleteCustomerPaymentMethod(params);\n}\n\n/** Their favourite products, as `getProducts` lists them - limited to the ones they added. */\nexport async function getCustomerFavourites(\n params: CustomerTokenParams & ListProductsParams,\n) {\n return api().getCustomerFavourites(params);\n}\n\n/** Just their favourites' ids, newest first - to fill in the hearts on a listing. */\nexport async function getCustomerFavouriteIds(params: CustomerTokenParams) {\n return api().getCustomerFavouriteIds(params);\n}\n\n/** Adds a product to their favourites; one already there stays once. */\nexport async function addCustomerFavourite(\n params: CustomerTokenParams & { productId: string },\n) {\n return api().addCustomerFavourite(params);\n}\n\n/** Takes a product out of their favourites; one not there is no error. */\nexport async function removeCustomerFavourite(\n params: CustomerTokenParams & { productId: string },\n) {\n return api().removeCustomerFavourite(params);\n}\n\n/** Changes the signed-in customer's name or phone. */\nexport async function updateCustomerProfile(\n params: UpdateCustomerProfileParams,\n) {\n return api().updateCustomerProfile(params);\n}\n\n/**\n * What customers say about a product \u2014 only what the shop turned on for it\n * (`getProductFeedback`). Anyone may read; a comment needs a signed-in customer's token.\n */\nexport async function getProductFeedback(params: GetProductFeedbackParams) {\n return api().getProductFeedback(params);\n}\n\n/** A product's comments, newest first \u2014 or, with `parentId`, one root's replies. */\nexport async function getProductComments(params: GetProductCommentsParams) {\n return api().getProductComments(params);\n}\n\n/** Comment on a product as the signed-in customer, or reply with `parentId`. */\nexport async function createProductComment(params: CreateProductCommentParams) {\n return api().createProductComment(params);\n}\n\n/** Remove one of the signed-in customer's own comments. */\nexport async function deleteProductComment(params: DeleteProductCommentParams) {\n return api().deleteProductComment(params);\n}\n\n/** The signed-in customer's vote on a product, the shop's way - stars or a like. */\nexport async function rateProduct(params: RateProductParams) {\n return api().rateProduct(params);\n}\n\n/** Take the signed-in customer's vote on a product back. */\nexport async function unrateProduct(params: UnrateProductParams) {\n return api().unrateProduct(params);\n}\n\n/** The signed-in customer's vote on a comment; 0 takes it back. */\nexport async function voteProductComment(params: VoteProductCommentParams) {\n return api().voteProductComment(params);\n}\n\n/**\n * The shop's settings catalogue: which fields it keeps on a product, what each holds, which it\n * shows. `{ tagsOnly: true }` for just the yes/no fields `getProducts({ tags })` filters on.\n */\nexport async function getProductSettings(params: { tagsOnly?: boolean } = {}) {\n return api().getProductSettings(params);\n}\n\n/** The combos on sale now, with their slots \u2014 optionally only those shown in one category. */\nexport async function getCombos(params: ListCombosParams = {}) {\n return api().getCombos(params);\n}\n\n/** The discount rules on now, for badging the products they target. */\nexport async function getDiscountRules() {\n return api().getDiscountRules();\n}\n\n/** Every list the shop can read, with columns but no entries. */\nexport async function listDictionaries() {\n return api().listDictionaries();\n}\n\n/** One list, with its entries, by `{ identifier }` \u2014 or by `{ id }` / `{ name }`. */\nexport async function getDictionary(params: GetDictionaryParams) {\n return api().getDictionary(params);\n}\n\n/** Several lists in one request, by identifier \u2014 the batch form of `getDictionary`. */\nexport async function getDictionaries(params: { identifiers: string[] }) {\n return api().getDictionaries(params);\n}\n\n/**\n * Size and resized copies of pictures held only as URLs, for `Image` \u2014 see the client's\n * `lookupImages`.\n */\nexport async function lookupImages(params: { urls: string[] }) {\n return api().lookupImages(params);\n}\n\n/** Products, paginated. Every optional part (`include`) unless the page narrows it. */\nexport async function getProducts(params: ListProductsParams = {}) {\n return api().getProducts(params);\n}\n\n/**\n * The cart, through the same environment-configured client.\n *\n * `createCart()` first; everything after it needs the id it returns. That id is the CREDENTIAL\n * for the cart \u2014 there is no visitor account \u2014 so it belongs in a cookie or in storage the\n * page controls, never in a URL a visitor might share and never in anything rendered.\n *\n * The server also sets it as a cookie, so a browser calling from the same site can rely on\n * that. This client passes it explicitly anyway: a server component has no cookie jar, and an\n * explicit id cannot be quietly swapped for whatever the jar last held.\n */\nexport async function createCart() {\n return api().createCart();\n}\n\nexport async function getCart(params: { cartId: string }) {\n return api().getCart(params);\n}\n\nexport async function addCartItem(params: {\n cartId: string;\n productId: string;\n quantity?: number;\n variantId?: string;\n variant?: string;\n}) {\n return api().addCartItem(params);\n}\n\nexport async function setCartItemQuantity(params: {\n cartId: string;\n cartItemId: string;\n quantity: number;\n}) {\n return api().setCartItemQuantity(params);\n}\n\nexport async function removeCartItem(params: {\n cartId: string;\n cartItemId: string;\n}) {\n return api().removeCartItem(params);\n}\n\nexport async function setCartBooking(params: {\n cartId: string;\n bookingId: string | null;\n}) {\n return api().setCartBooking(params);\n}\n\nexport async function destroyCart(params: { cartId: string }) {\n return api().destroyCart(params);\n}\n\n/**\n * Read a checkout: the order as it will be charged, and \u2014 while it can still be paid \u2014 the\n * Stripe secrets to charge it with.\n *\n * This is what a site's OWN checkout page uses instead of sending the shopper to the hosted\n * one: read it in a server component, pass `payment` down to a `\"use client\"` component, and\n * mount Stripe's `<Elements>` / `<PaymentElement>` on it. The card is typed into Stripe's\n * iframe; page code never sees it. Read it again when the shopper comes back from payment \u2014\n * `status` is `paid`, `failed` or still `pending` while the bank confirms.\n */\nexport async function getCheckout(params: { checkoutId: string }) {\n return api().getCheckout(params);\n}\n\n/**\n * Find a placed order for the shop's tracking page - no sign-in: `code`, its delivery's tracking\n * number (`K7P-QX9-M2T`, in the order's emails and on the customer's order), with the order's\n * `email` - while the shop allows it (`getSiteInfo().publicOrderTracking`); or `checkoutId` alone\n * (the confirmation link's). Answers as `getCustomerOrder` does, `shipment` set once a carrier\n * has the parcel. Any mismatch rejects with a 404 (`order_track_not_found`).\n */\nexport async function trackOrder(params: {\n code?: string;\n email?: string;\n checkoutId?: string;\n}) {\n return api().trackOrder(params);\n}\n\n/**\n * Record who is paying, from the site's own payment page. Answers with the checkout as\n * `getCheckout` does, now offering the cards that shopper saved at this shop.\n */\nexport async function setCheckoutEmail(params: {\n checkoutId: string;\n email: string;\n}) {\n return api().setCheckoutEmail(params);\n}\n\n/**\n * Pay for the basket: creates a checkout from the cart and answers with `checkoutUrl`, the\n * hosted page the shopper's browser should be sent to \u2014 or, with `getCheckout`, the id of a\n * checkout the site takes the payment for itself.\n *\n * Return that address from the server action and leave for it in the client \u2014\n * `window.location.assign(checkoutUrl)`. NOT `redirect()`: the payment page is a separate app\n * under `/c/` on the same host, and a router navigation would ask this site to render it.\n */\nexport async function createCheckout(params: {\n cartId: string;\n customerEmail?: string;\n successUrl?: string;\n cancelUrl?: string;\n}) {\n return api().createCheckout(params);\n}\n\n/** Drop the cached client. For tests, and for a process that changes its environment. */\nexport function resetSiteData(): void {\n client = null;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAgEA,IAAI,SAAiC;AAErC,SAAS,MAAuB;AAC9B,MAAI,OAAQ,QAAO;AAWnB,MAAI,iBAAiB,GAAG;AACtB,aAAS,mBAAmB;AAE5B,WAAO;AAAA,EACT;AAEA,QAAM,MACH,WACE,SAAS,OAAO,CAAC;AACtB,QAAM,gBAAgB,IAAI,mBAAmB;AAI7C,QAAM,aAAa,iBAAiB;AAEpC,QAAM,gBAAgB,IAAI,yBAAyB,KAAK;AAIxD,MAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,eAAe;AACnD,UAAM,IAAI,eAAe,sCAAsC;AAAA,EACjE;AAEA,WAAS,sBAAsB;AAAA,IAC7B,SAAS,IAAI,0BAA0B;AAAA;AAAA;AAAA,IAGvC,GAAI,gBAAgB,EAAE,cAAc,IAAI,CAAC;AAAA,IACzC,GAAI,gBAAgB,EAAE,cAAc,IAAI,CAAC;AAAA;AAAA,IAEzC,GAAI,IAAI,kBAAkB,EAAE,OAAO,cAAuB,IAAI,CAAC;AAAA,EACjE,CAAC;AAED,SAAO;AACT;AASA,eAAsB,cAAc;AAClC,SAAO,IAAI,EAAE,YAAY;AAC3B;AAGA,eAAsB,cAAc,SAA+B,CAAC,GAAG;AACrE,SAAO,IAAI,EAAE,cAAc,MAAM;AACnC;AAGA,eAAsB,YAAY,QAA2B;AAC3D,SAAO,IAAI,EAAE,YAAY,MAAM;AACjC;AAG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