@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
package/dist/index.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addCartItem,
|
|
3
|
+
addCustomerAddress,
|
|
4
|
+
addCustomerFavourite,
|
|
5
|
+
cancelCustomerBooking,
|
|
6
|
+
createBooking,
|
|
7
|
+
createCart,
|
|
8
|
+
createCheckout,
|
|
9
|
+
createProductComment,
|
|
10
|
+
deleteCustomerAddress,
|
|
11
|
+
deleteCustomerPaymentMethod,
|
|
12
|
+
deleteProductComment,
|
|
13
|
+
destroyCart,
|
|
14
|
+
getBookingPlan,
|
|
15
|
+
getBookingSlots,
|
|
16
|
+
getCart,
|
|
17
|
+
getCategories,
|
|
18
|
+
getCategory,
|
|
19
|
+
getCheckout,
|
|
20
|
+
getCombos,
|
|
21
|
+
getCustomerAccount,
|
|
22
|
+
getCustomerAddresses,
|
|
23
|
+
getCustomerBookings,
|
|
24
|
+
getCustomerFavouriteIds,
|
|
25
|
+
getCustomerFavourites,
|
|
26
|
+
getCustomerOrder,
|
|
27
|
+
getCustomerOrders,
|
|
28
|
+
getCustomerPaymentMethods,
|
|
29
|
+
getDictionaries,
|
|
30
|
+
getDictionary,
|
|
31
|
+
getDiningTable,
|
|
32
|
+
getDiscountRules,
|
|
33
|
+
getLocations,
|
|
34
|
+
getOrderTimes,
|
|
35
|
+
getProduct,
|
|
36
|
+
getProductComments,
|
|
37
|
+
getProductFeedback,
|
|
38
|
+
getProductSettings,
|
|
39
|
+
getProducts,
|
|
40
|
+
getSiteInfo,
|
|
41
|
+
getTerms,
|
|
42
|
+
listDictionaries,
|
|
43
|
+
lookupImages,
|
|
44
|
+
rateProduct,
|
|
45
|
+
removeCartItem,
|
|
46
|
+
removeCustomerFavourite,
|
|
47
|
+
requestSignInCode,
|
|
48
|
+
resetSiteData,
|
|
49
|
+
setCartBooking,
|
|
50
|
+
setCartItemQuantity,
|
|
51
|
+
setCheckoutEmail,
|
|
52
|
+
setCustomerBookingPreorder,
|
|
53
|
+
signInWithApple,
|
|
54
|
+
signInWithGoogle,
|
|
55
|
+
trackOrder,
|
|
56
|
+
unrateProduct,
|
|
57
|
+
updateCustomerProfile,
|
|
58
|
+
verifyDiningTableCode,
|
|
59
|
+
verifySignInCode,
|
|
60
|
+
voteProductComment
|
|
61
|
+
} from "./chunks/chunk-ZITPZDI7.js";
|
|
62
|
+
import "./chunks/chunk-DUVULZ6N.js";
|
|
63
|
+
import {
|
|
64
|
+
createPublicApiClient
|
|
65
|
+
} from "./chunks/chunk-5DN7L6LX.js";
|
|
66
|
+
import {
|
|
67
|
+
runWithRequestCache
|
|
68
|
+
} from "./chunks/chunk-2BH4QPV2.js";
|
|
69
|
+
import {
|
|
70
|
+
countryFromHeaders,
|
|
71
|
+
getVisitorCountryResolver,
|
|
72
|
+
setVisitorCountryResolver
|
|
73
|
+
} from "./chunks/chunk-2554RPSS.js";
|
|
74
|
+
import {
|
|
75
|
+
getCompanyApiKey,
|
|
76
|
+
setCompanyApiKey
|
|
77
|
+
} from "./chunks/chunk-TSERNR4R.js";
|
|
78
|
+
import {
|
|
79
|
+
getCustomerTokenResolver,
|
|
80
|
+
setCustomerTokenResolver
|
|
81
|
+
} from "./chunks/chunk-OFFTL6RC.js";
|
|
82
|
+
import {
|
|
83
|
+
PublicApiError
|
|
84
|
+
} from "./chunks/chunk-GJZ7EZEF.js";
|
|
85
|
+
import {
|
|
86
|
+
getLanguageResolver,
|
|
87
|
+
setLanguageResolver
|
|
88
|
+
} from "./chunks/chunk-HFEQWXG6.js";
|
|
89
|
+
import {
|
|
90
|
+
MAX_LIMIT
|
|
91
|
+
} from "./chunks/chunk-3KEEGSMP.js";
|
|
92
|
+
export {
|
|
93
|
+
MAX_LIMIT,
|
|
94
|
+
PublicApiError,
|
|
95
|
+
addCartItem,
|
|
96
|
+
addCustomerAddress,
|
|
97
|
+
addCustomerFavourite,
|
|
98
|
+
cancelCustomerBooking,
|
|
99
|
+
countryFromHeaders,
|
|
100
|
+
createBooking,
|
|
101
|
+
createCart,
|
|
102
|
+
createCheckout,
|
|
103
|
+
createProductComment,
|
|
104
|
+
createPublicApiClient,
|
|
105
|
+
deleteCustomerAddress,
|
|
106
|
+
deleteCustomerPaymentMethod,
|
|
107
|
+
deleteProductComment,
|
|
108
|
+
destroyCart,
|
|
109
|
+
getBookingPlan,
|
|
110
|
+
getBookingSlots,
|
|
111
|
+
getCart,
|
|
112
|
+
getCategories,
|
|
113
|
+
getCategory,
|
|
114
|
+
getCheckout,
|
|
115
|
+
getCombos,
|
|
116
|
+
getCompanyApiKey,
|
|
117
|
+
getCustomerAccount,
|
|
118
|
+
getCustomerAddresses,
|
|
119
|
+
getCustomerBookings,
|
|
120
|
+
getCustomerFavouriteIds,
|
|
121
|
+
getCustomerFavourites,
|
|
122
|
+
getCustomerOrder,
|
|
123
|
+
getCustomerOrders,
|
|
124
|
+
getCustomerPaymentMethods,
|
|
125
|
+
getCustomerTokenResolver,
|
|
126
|
+
getDictionaries,
|
|
127
|
+
getDictionary,
|
|
128
|
+
getDiningTable,
|
|
129
|
+
getDiscountRules,
|
|
130
|
+
getLanguageResolver,
|
|
131
|
+
getLocations,
|
|
132
|
+
getOrderTimes,
|
|
133
|
+
getProduct,
|
|
134
|
+
getProductComments,
|
|
135
|
+
getProductFeedback,
|
|
136
|
+
getProductSettings,
|
|
137
|
+
getProducts,
|
|
138
|
+
getSiteInfo,
|
|
139
|
+
getTerms,
|
|
140
|
+
getVisitorCountryResolver,
|
|
141
|
+
listDictionaries,
|
|
142
|
+
lookupImages,
|
|
143
|
+
rateProduct,
|
|
144
|
+
removeCartItem,
|
|
145
|
+
removeCustomerFavourite,
|
|
146
|
+
requestSignInCode,
|
|
147
|
+
resetSiteData,
|
|
148
|
+
runWithRequestCache,
|
|
149
|
+
setCartBooking,
|
|
150
|
+
setCartItemQuantity,
|
|
151
|
+
setCheckoutEmail,
|
|
152
|
+
setCompanyApiKey,
|
|
153
|
+
setCustomerBookingPreorder,
|
|
154
|
+
setCustomerTokenResolver,
|
|
155
|
+
setLanguageResolver,
|
|
156
|
+
setVisitorCountryResolver,
|
|
157
|
+
signInWithApple,
|
|
158
|
+
signInWithGoogle,
|
|
159
|
+
trackOrder,
|
|
160
|
+
unrateProduct,
|
|
161
|
+
updateCustomerProfile,
|
|
162
|
+
verifyDiningTableCode,
|
|
163
|
+
verifySignInCode,
|
|
164
|
+
voteProductComment
|
|
165
|
+
};
|
|
166
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The language the site is being read in, for the calls that answer in one.
|
|
3
|
+
*
|
|
4
|
+
* The public API resolves every name, description and dictionary entry into the language named
|
|
5
|
+
* by the `x-language` header, and falls back to English without it — so a site that never said
|
|
6
|
+
* which language it was in was an English site, whatever the shop wrote in.
|
|
7
|
+
*
|
|
8
|
+
* Which language a visitor is reading is the SITE's knowledge — a cookie, a path segment, a
|
|
9
|
+
* header of its own — and it is per request, not per process. So the site hands in a resolver,
|
|
10
|
+
* asked at the moment of each call, the same way the key is supplied: once, where the site sets
|
|
11
|
+
* itself up, rather than as a parameter every call has to remember.
|
|
12
|
+
*
|
|
13
|
+
* The resolver is not asked for the company lookup (`getSiteInfo`), which needs no language,
|
|
14
|
+
* so it may itself read the company's default language without looping.
|
|
15
|
+
*/
|
|
16
|
+
export type LanguageResolver = () => string | null | undefined | Promise<string | null | undefined>;
|
|
17
|
+
export declare function setLanguageResolver(next: LanguageResolver | null): void;
|
|
18
|
+
/**
|
|
19
|
+
* The resolver in force, so a caller can override it for one render and put it back.
|
|
20
|
+
*
|
|
21
|
+
* The render tier does this: it sets a resolver that returns the request's language, renders, and
|
|
22
|
+
* restores the site's own resolver in a `finally`. Without the getter there is no way to restore
|
|
23
|
+
* exactly what was there before.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getLanguageResolver(): LanguageResolver | null;
|
|
26
|
+
/** The language to send, or undefined for the API's default. Never throws. */
|
|
27
|
+
export declare function resolveLanguage(): Promise<string | undefined>;
|
package/dist/language.js
ADDED
package/dist/params.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning a caller's parameters into a query string, defensively.
|
|
3
|
+
*
|
|
4
|
+
* Written for the worst caller there is: page code inside the sandbox, which can send any
|
|
5
|
+
* JSON at all. Every value is checked here rather than trusted, because the check that
|
|
6
|
+
* matters is the one on this side of the boundary.
|
|
7
|
+
*/
|
|
8
|
+
/** The largest page the API will be asked for, whatever a caller requests. */
|
|
9
|
+
export declare const MAX_LIMIT = 200;
|
|
10
|
+
/**
|
|
11
|
+
* A path segment supplied by a caller goes into a URL, so it is validated rather than
|
|
12
|
+
* escaped: an id is a slug, a UUID or an entity's number, and anything else is a mistake or an attempt to reach a
|
|
13
|
+
* different endpoint by writing `../`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function segment(value: unknown, name: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* A NAME a caller looks something up by — a category, a product, one of the shop's lists.
|
|
18
|
+
*
|
|
19
|
+
* `segment` is for ids, which are `[A-Za-z0-9_-]` by construction. A name is not: it is free
|
|
20
|
+
* text a shop typed, in whatever language it writes in, and "Pizza sizes", "Añadidos" and
|
|
21
|
+
* "Пиццы" are all ordinary ones. Refusing them is how a page asking for a real category got
|
|
22
|
+
* "invalid name" thrown at it.
|
|
23
|
+
*
|
|
24
|
+
* These names travel in the QUERY STRING, where `URLSearchParams` does the encoding — so this
|
|
25
|
+
* only has to refuse what is not a name at all: nothing, something absurdly long, or a
|
|
26
|
+
* control character.
|
|
27
|
+
*/
|
|
28
|
+
export declare function label(value: unknown, name: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* `{ id }` or `{ name }` as query parameters — exactly one of them.
|
|
31
|
+
*
|
|
32
|
+
* Refused here rather than left to the server's 400: a page that passes both has a bug the
|
|
33
|
+
* server would report as "data unavailable (400)", which reads like an outage.
|
|
34
|
+
*/
|
|
35
|
+
export declare function idOrName(params: unknown): Record<string, string>;
|
|
36
|
+
/**
|
|
37
|
+
* The `include` parameter: which optional parts of a response to carry.
|
|
38
|
+
*
|
|
39
|
+
* `undefined` means EVERY part in `allowed` — the shape a page written before `include`
|
|
40
|
+
* existed relies on. An empty list means none, and sends nothing (the API's own default).
|
|
41
|
+
* Anything outside `allowed` is refused rather than dropped, so a typo cannot silently cost
|
|
42
|
+
* a page its images.
|
|
43
|
+
*/
|
|
44
|
+
export declare function include<T extends string>(value: readonly T[] | undefined, allowed: readonly T[]): Record<string, string>;
|
|
45
|
+
/** Bound the paging so one call cannot ask for an entire catalogue. */
|
|
46
|
+
export declare function paging(params: {
|
|
47
|
+
page?: unknown;
|
|
48
|
+
limit?: unknown;
|
|
49
|
+
}): Record<string, string>;
|
|
50
|
+
/** A string parameter, included only when it is one. */
|
|
51
|
+
export declare function text(key: string, value: unknown): Record<string, string>;
|
|
52
|
+
/** One of a fixed set of words, included only when it is one of them. */
|
|
53
|
+
export declare function oneOf(key: string, value: unknown, allowed: readonly string[]): Record<string, string>;
|
|
54
|
+
/** A whole number within bounds, included only when it is one — clamped, not refused. */
|
|
55
|
+
export declare function whole(key: string, value: unknown, min: number, max: number): Record<string, string>;
|
|
56
|
+
/** A boolean parameter, included only when it is explicitly true. */
|
|
57
|
+
export declare function flag(key: string, value: unknown): Record<string, string>;
|
|
58
|
+
export declare function trimSlash(value: string): string;
|
package/dist/params.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MAX_LIMIT,
|
|
3
|
+
flag,
|
|
4
|
+
idOrName,
|
|
5
|
+
include,
|
|
6
|
+
label,
|
|
7
|
+
oneOf,
|
|
8
|
+
paging,
|
|
9
|
+
segment,
|
|
10
|
+
text,
|
|
11
|
+
trimSlash,
|
|
12
|
+
whole
|
|
13
|
+
} from "./chunks/chunk-3KEEGSMP.js";
|
|
14
|
+
export {
|
|
15
|
+
MAX_LIMIT,
|
|
16
|
+
flag,
|
|
17
|
+
idOrName,
|
|
18
|
+
include,
|
|
19
|
+
label,
|
|
20
|
+
oneOf,
|
|
21
|
+
paging,
|
|
22
|
+
segment,
|
|
23
|
+
text,
|
|
24
|
+
trimSlash,
|
|
25
|
+
whole
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=params.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A per-render dedup cache for GET reads — alive ONLY for the duration of one render.
|
|
3
|
+
*
|
|
4
|
+
* `React.cache()` — which the site's data readers rely on to share one fetch across the many
|
|
5
|
+
* components that need it — does NOTHING under `react-dom/static.prerender` (it is an RSC-only
|
|
6
|
+
* feature with no cache scope here). Without a replacement, one page render fired the SAME
|
|
7
|
+
* `getDictionary` / `getSiteInfo` / `getProducts` request dozens of times.
|
|
8
|
+
*
|
|
9
|
+
* This is that replacement, at the one place every read passes through. The SSR bootstrap wraps a
|
|
10
|
+
* render in `runWithRequestCache`, which turns the cache ON for exactly that render and OFF again
|
|
11
|
+
* when it settles (success OR error). Outside a render — the browser, a standalone script, the
|
|
12
|
+
* long-lived multi-tenant RPC server — the cache is simply absent (`store === null`), so `memoGet`
|
|
13
|
+
* is a pure passthrough and no request state is ever held between renders or shared between them.
|
|
14
|
+
*
|
|
15
|
+
* SAFETY (why a module-level Map does not leak across tenants or parallel calls):
|
|
16
|
+
* - Scope: the Map exists only while a render runs and is dropped in `finally`, so nothing lingers
|
|
17
|
+
* after a render and nothing exists when no render is running.
|
|
18
|
+
* - Tenant: the memo KEY includes the company key + product-sample dataset + language, not just the
|
|
19
|
+
* URL (see `request()` in `client.ts`) — `getSiteInfo` is `/company` for every tenant, so a
|
|
20
|
+
* URL-only key WOULD collide. Two tenants can never read each other's entry even if a `store`
|
|
21
|
+
* were momentarily shared.
|
|
22
|
+
* - Concurrency: the platform renders each page in its own sandbox process (one render at a time)
|
|
23
|
+
* and the dev server serialises renders, so the module `store` belongs to one render. Even if two
|
|
24
|
+
* renders ever overlapped in one process, `runWithRequestCache` save/restores the previous store
|
|
25
|
+
* and the tenant-scoped keys mean the worst case is a few extra fetches — never wrong data.
|
|
26
|
+
* - Only reads are memoised (GETs, and the few POSTs that only read - see `READ_POSTS` in
|
|
27
|
+
* `client.ts`); mutations never reach here.
|
|
28
|
+
* - A failed read IS remembered, for this render only: every component asking again would get
|
|
29
|
+
* the same answer - a shop over its daily allowance gets 429 - and each retry is one more
|
|
30
|
+
* counted call. The next render asks afresh.
|
|
31
|
+
*
|
|
32
|
+
* Deliberately dependency-free (no `async_hooks` — a Node builtin the platform's render sandbox
|
|
33
|
+
* cannot import).
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Run one render with GET dedup enabled, then tear the cache down.
|
|
37
|
+
*
|
|
38
|
+
* `finally` guarantees the cache is dropped even if the render throws. `previous` is restored
|
|
39
|
+
* rather than forced to `null` so a nested or overlapping scope leaves things as it found them.
|
|
40
|
+
*/
|
|
41
|
+
export declare function runWithRequestCache<T>(render: () => Promise<T>): Promise<T>;
|
|
42
|
+
/**
|
|
43
|
+
* Return the memoised result for `key`, or compute and store it. When no render scope is active
|
|
44
|
+
* (`store === null`), it just runs `compute` — no caching, no state, no staleness.
|
|
45
|
+
*/
|
|
46
|
+
export declare function memoGet<T>(key: string, compute: () => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import type { CreateBookingParams, CustomerTokenParams, SetBookingPreorderParams, CustomerHistoryParams, CustomerBookingsParams, AddCustomerAddressParams, CreateProductCommentParams, DeleteProductCommentParams, GetProductCommentsParams, GetProductFeedbackParams, RateProductParams, UnrateProductParams, VoteProductCommentParams, GetBookingPlanParams, GetBookingSlotsParams, GetOrderTimesParams, GetCategoryParams, GetDictionaryParams, GetProductParams, ListCategoriesParams, ListCombosParams, ListProductsParams, RequestSignInCodeParams, SignInWithAppleParams, SignInWithGoogleParams, UpdateCustomerProfileParams, VerifySignInCodeParams } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Every export below is `async`, and that is load-bearing rather than stylistic.
|
|
4
|
+
*
|
|
5
|
+
* A page handles an unavailable call with `.catch()` or a rejection handler. If a missing
|
|
6
|
+
* environment variable were THROWN synchronously, it would throw before the caller had a
|
|
7
|
+
* handler attached, and a page's `.catch()` would never run.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getSiteInfo(): Promise<import("./types").PublicSiteInfo>;
|
|
10
|
+
/** Categories. Every optional part (`include`) unless the page narrows it. */
|
|
11
|
+
export declare function getCategories(params?: ListCategoriesParams): Promise<import("./types").PublicCategory[]>;
|
|
12
|
+
/** One category by `{ id }` or `{ name }`. */
|
|
13
|
+
export declare function getCategory(params: GetCategoryParams): Promise<import("./types").PublicCategory>;
|
|
14
|
+
/** One product by `{ id }` or `{ name }` — see `getCategory` for how a name is matched. */
|
|
15
|
+
export declare function getProduct(params: GetProductParams): Promise<import("./types").PublicProduct>;
|
|
16
|
+
/** The shop's locations, in its order — for a "find us" list or a map. */
|
|
17
|
+
export declare function getLocations(): Promise<import("./types").PublicStoreLocation[]>;
|
|
18
|
+
/** A table a guest is ordering from, by the id on its QR code. */
|
|
19
|
+
export declare function getDiningTable(params: {
|
|
20
|
+
tableId: string;
|
|
21
|
+
}): Promise<import("./types").PublicDiningTable>;
|
|
22
|
+
/** Checks the code staff gave a guest at this table; rejects a wrong one. Books nothing. */
|
|
23
|
+
export declare function verifyDiningTableCode(params: {
|
|
24
|
+
tableId: string;
|
|
25
|
+
code: string;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
/** The shop's terms and privacy policy: whether they must be accepted, and the text (Markdown). */
|
|
28
|
+
export declare function getTerms(params?: {
|
|
29
|
+
language?: string;
|
|
30
|
+
}): Promise<import("./types").PublicTerms>;
|
|
31
|
+
/** When an order can be for: now, and the later times on the location's clock. */
|
|
32
|
+
export declare function getOrderTimes(params?: GetOrderTimesParams): Promise<import("./types").PublicOrderTimes>;
|
|
33
|
+
/** The times a party can book on a day at a location, each free or full. */
|
|
34
|
+
export declare function getBookingSlots(params: GetBookingSlotsParams): Promise<import("./types").PublicBookingSlots>;
|
|
35
|
+
/** The location's floor plan at a time, which tables are free, and the best fit. */
|
|
36
|
+
export declare function getBookingPlan(params: GetBookingPlanParams): Promise<import("./types").PublicBookingPlan>;
|
|
37
|
+
/** Book a table — confirmed at once; 409 when none is free any more. */
|
|
38
|
+
export declare function createBooking(params: CreateBookingParams): Promise<import("./types").PublicBooking>;
|
|
39
|
+
/**
|
|
40
|
+
* Signing a customer in — the ways `getSiteInfo().customerSignInMethods` turns on.
|
|
41
|
+
*
|
|
42
|
+
* An emailed code (`requestSignInCode`, then `verifySignInCode`), Google (`signInWithGoogle`) or
|
|
43
|
+
* Apple (`signInWithApple`) answers with a `token`. Keep it in an httpOnly cookie set by the
|
|
44
|
+
* site's SERVER — never in page script — and pass it as `customerToken` to `createCheckout`,
|
|
45
|
+
* `createBooking` and the account calls: what is made with it belongs to the customer.
|
|
46
|
+
*/
|
|
47
|
+
export declare function requestSignInCode(params: RequestSignInCodeParams): Promise<{
|
|
48
|
+
expiresIn: number;
|
|
49
|
+
}>;
|
|
50
|
+
export declare function verifySignInCode(params: VerifySignInCodeParams): Promise<import("./types").PublicCustomerSession>;
|
|
51
|
+
export declare function signInWithGoogle(params: SignInWithGoogleParams): Promise<import("./types").PublicCustomerSession>;
|
|
52
|
+
export declare function signInWithApple(params: SignInWithAppleParams): Promise<import("./types").PublicCustomerSession>;
|
|
53
|
+
/** The signed-in customer, with their recent orders and bookings. */
|
|
54
|
+
export declare function getCustomerAccount(params: CustomerTokenParams): Promise<import("./types").PublicCustomerAccount>;
|
|
55
|
+
/** The signed-in customer's orders on this site, newest first. */
|
|
56
|
+
export declare function getCustomerOrders(params: CustomerTokenParams & CustomerHistoryParams): Promise<import("./types").CustomerPage<import("./types").PublicCustomerOrder>>;
|
|
57
|
+
/** One of their orders, with its lines. */
|
|
58
|
+
export declare function getCustomerOrder(params: CustomerTokenParams & {
|
|
59
|
+
orderId: string;
|
|
60
|
+
}): Promise<import("./types").PublicCustomerOrderDetail>;
|
|
61
|
+
/** Their bookings — upcoming by default. */
|
|
62
|
+
export declare function getCustomerBookings(params: CustomerTokenParams & CustomerBookingsParams): Promise<import("./types").CustomerPage<import("./types").PublicCustomerBooking>>;
|
|
63
|
+
/** Calls off one of their bookings, while it is still ahead. */
|
|
64
|
+
export declare function cancelCustomerBooking(params: CustomerTokenParams & {
|
|
65
|
+
bookingId: string;
|
|
66
|
+
}): Promise<import("./types").PublicCustomerBooking>;
|
|
67
|
+
/** Sets the dishes they order ahead for one of their bookings, replacing what was there. */
|
|
68
|
+
export declare function setCustomerBookingPreorder(params: SetBookingPreorderParams): Promise<{
|
|
69
|
+
preorder: import("./types").PublicBookingPreorder | null;
|
|
70
|
+
}>;
|
|
71
|
+
/** The places they have had orders delivered to, or saved - the one used last first. */
|
|
72
|
+
export declare function getCustomerAddresses(params: CustomerTokenParams): Promise<{
|
|
73
|
+
data: import("./types").PublicCustomerAddress[];
|
|
74
|
+
}>;
|
|
75
|
+
/** Saves an address for them. */
|
|
76
|
+
export declare function addCustomerAddress(params: AddCustomerAddressParams): Promise<import("./types").PublicCustomerAddress>;
|
|
77
|
+
/** Forgets one of their addresses. */
|
|
78
|
+
export declare function deleteCustomerAddress(params: CustomerTokenParams & {
|
|
79
|
+
customerAddressId: string;
|
|
80
|
+
}): Promise<void>;
|
|
81
|
+
/** The cards they saved paying here - nothing that can pay. */
|
|
82
|
+
export declare function getCustomerPaymentMethods(params: CustomerTokenParams): Promise<{
|
|
83
|
+
data: import("./types").PublicCustomerPaymentMethod[];
|
|
84
|
+
}>;
|
|
85
|
+
/** Removes one of their saved cards; refused for one an upcoming booking keeps. */
|
|
86
|
+
export declare function deleteCustomerPaymentMethod(params: CustomerTokenParams & {
|
|
87
|
+
paymentMethodId: string;
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
/** Their favourite products, as `getProducts` lists them - limited to the ones they added. */
|
|
90
|
+
export declare function getCustomerFavourites(params: CustomerTokenParams & ListProductsParams): Promise<import("./types").Paginated<import("./types").PublicProduct>>;
|
|
91
|
+
/** Just their favourites' ids, newest first - to fill in the hearts on a listing. */
|
|
92
|
+
export declare function getCustomerFavouriteIds(params: CustomerTokenParams): Promise<{
|
|
93
|
+
productIds: string[];
|
|
94
|
+
}>;
|
|
95
|
+
/** Adds a product to their favourites; one already there stays once. */
|
|
96
|
+
export declare function addCustomerFavourite(params: CustomerTokenParams & {
|
|
97
|
+
productId: string;
|
|
98
|
+
}): Promise<void>;
|
|
99
|
+
/** Takes a product out of their favourites; one not there is no error. */
|
|
100
|
+
export declare function removeCustomerFavourite(params: CustomerTokenParams & {
|
|
101
|
+
productId: string;
|
|
102
|
+
}): Promise<void>;
|
|
103
|
+
/** Changes the signed-in customer's name or phone. */
|
|
104
|
+
export declare function updateCustomerProfile(params: UpdateCustomerProfileParams): Promise<import("./types").PublicCustomer>;
|
|
105
|
+
/**
|
|
106
|
+
* What customers say about a product — only what the shop turned on for it
|
|
107
|
+
* (`getProductFeedback`). Anyone may read; a comment needs a signed-in customer's token.
|
|
108
|
+
*/
|
|
109
|
+
export declare function getProductFeedback(params: GetProductFeedbackParams): Promise<import("./types").PublicProductFeedback>;
|
|
110
|
+
/** A product's comments, newest first — or, with `parentId`, one root's replies. */
|
|
111
|
+
export declare function getProductComments(params: GetProductCommentsParams): Promise<import("./types").PublicProductCommentsPage>;
|
|
112
|
+
/** Comment on a product as the signed-in customer, or reply with `parentId`. */
|
|
113
|
+
export declare function createProductComment(params: CreateProductCommentParams): Promise<import("./types").PublicProductComment>;
|
|
114
|
+
/** Remove one of the signed-in customer's own comments. */
|
|
115
|
+
export declare function deleteProductComment(params: DeleteProductCommentParams): Promise<void>;
|
|
116
|
+
/** The signed-in customer's vote on a product, the shop's way - stars or a like. */
|
|
117
|
+
export declare function rateProduct(params: RateProductParams): Promise<import("./types").PublicProductRating>;
|
|
118
|
+
/** Take the signed-in customer's vote on a product back. */
|
|
119
|
+
export declare function unrateProduct(params: UnrateProductParams): Promise<import("./types").PublicProductRating>;
|
|
120
|
+
/** The signed-in customer's vote on a comment; 0 takes it back. */
|
|
121
|
+
export declare function voteProductComment(params: VoteProductCommentParams): Promise<import("./types").PublicCommentVoteResult>;
|
|
122
|
+
/**
|
|
123
|
+
* The shop's settings catalogue: which fields it keeps on a product, what each holds, which it
|
|
124
|
+
* shows. `{ tagsOnly: true }` for just the yes/no fields `getProducts({ tags })` filters on.
|
|
125
|
+
*/
|
|
126
|
+
export declare function getProductSettings(params?: {
|
|
127
|
+
tagsOnly?: boolean;
|
|
128
|
+
}): Promise<import("./types").PublicProductSettingDefinition[]>;
|
|
129
|
+
/** The combos on sale now, with their slots — optionally only those shown in one category. */
|
|
130
|
+
export declare function getCombos(params?: ListCombosParams): Promise<import("./types").PublicCombo[]>;
|
|
131
|
+
/** The discount rules on now, for badging the products they target. */
|
|
132
|
+
export declare function getDiscountRules(): Promise<import("./types").PublicDiscountRule[]>;
|
|
133
|
+
/** Every list the shop can read, with columns but no entries. */
|
|
134
|
+
export declare function listDictionaries(): Promise<import("./types").PublicDictionarySummary[]>;
|
|
135
|
+
/** One list, with its entries, by `{ identifier }` — or by `{ id }` / `{ name }`. */
|
|
136
|
+
export declare function getDictionary(params: GetDictionaryParams): Promise<import("./types").PublicDictionary>;
|
|
137
|
+
/** Several lists in one request, by identifier — the batch form of `getDictionary`. */
|
|
138
|
+
export declare function getDictionaries(params: {
|
|
139
|
+
identifiers: string[];
|
|
140
|
+
}): Promise<import("./types").PublicDictionary[]>;
|
|
141
|
+
/**
|
|
142
|
+
* Size and resized copies of pictures held only as URLs, for `Image` — see the client's
|
|
143
|
+
* `lookupImages`.
|
|
144
|
+
*/
|
|
145
|
+
export declare function lookupImages(params: {
|
|
146
|
+
urls: string[];
|
|
147
|
+
}): Promise<import("./types").PublicImage[]>;
|
|
148
|
+
/** Products, paginated. Every optional part (`include`) unless the page narrows it. */
|
|
149
|
+
export declare function getProducts(params?: ListProductsParams): Promise<import("./types").Paginated<import("./types").PublicProduct>>;
|
|
150
|
+
/**
|
|
151
|
+
* The cart, through the same environment-configured client.
|
|
152
|
+
*
|
|
153
|
+
* `createCart()` first; everything after it needs the id it returns. That id is the CREDENTIAL
|
|
154
|
+
* for the cart — there is no visitor account — so it belongs in a cookie or in storage the
|
|
155
|
+
* page controls, never in a URL a visitor might share and never in anything rendered.
|
|
156
|
+
*
|
|
157
|
+
* The server also sets it as a cookie, so a browser calling from the same site can rely on
|
|
158
|
+
* that. This client passes it explicitly anyway: a server component has no cookie jar, and an
|
|
159
|
+
* explicit id cannot be quietly swapped for whatever the jar last held.
|
|
160
|
+
*/
|
|
161
|
+
export declare function createCart(): Promise<import("./types").PublicCart>;
|
|
162
|
+
export declare function getCart(params: {
|
|
163
|
+
cartId: string;
|
|
164
|
+
}): Promise<import("./types").PublicCart>;
|
|
165
|
+
export declare function addCartItem(params: {
|
|
166
|
+
cartId: string;
|
|
167
|
+
productId: string;
|
|
168
|
+
quantity?: number;
|
|
169
|
+
variantId?: string;
|
|
170
|
+
variant?: string;
|
|
171
|
+
}): Promise<import("./types").PublicCart>;
|
|
172
|
+
export declare function setCartItemQuantity(params: {
|
|
173
|
+
cartId: string;
|
|
174
|
+
cartItemId: string;
|
|
175
|
+
quantity: number;
|
|
176
|
+
}): Promise<import("./types").PublicCart>;
|
|
177
|
+
export declare function removeCartItem(params: {
|
|
178
|
+
cartId: string;
|
|
179
|
+
cartItemId: string;
|
|
180
|
+
}): Promise<import("./types").PublicCart>;
|
|
181
|
+
export declare function setCartBooking(params: {
|
|
182
|
+
cartId: string;
|
|
183
|
+
bookingId: string | null;
|
|
184
|
+
}): Promise<import("./types").PublicCart>;
|
|
185
|
+
export declare function destroyCart(params: {
|
|
186
|
+
cartId: string;
|
|
187
|
+
}): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Read a checkout: the order as it will be charged, and — while it can still be paid — the
|
|
190
|
+
* Stripe secrets to charge it with.
|
|
191
|
+
*
|
|
192
|
+
* This is what a site's OWN checkout page uses instead of sending the shopper to the hosted
|
|
193
|
+
* one: read it in a server component, pass `payment` down to a `"use client"` component, and
|
|
194
|
+
* mount Stripe's `<Elements>` / `<PaymentElement>` on it. The card is typed into Stripe's
|
|
195
|
+
* iframe; page code never sees it. Read it again when the shopper comes back from payment —
|
|
196
|
+
* `status` is `paid`, `failed` or still `pending` while the bank confirms.
|
|
197
|
+
*/
|
|
198
|
+
export declare function getCheckout(params: {
|
|
199
|
+
checkoutId: string;
|
|
200
|
+
}): Promise<import("./types").PublicCheckoutSession>;
|
|
201
|
+
/**
|
|
202
|
+
* Find a placed order for the shop's tracking page - no sign-in: `code`, its delivery's tracking
|
|
203
|
+
* number (`K7P-QX9-M2T`, in the order's emails and on the customer's order), with the order's
|
|
204
|
+
* `email` - while the shop allows it (`getSiteInfo().publicOrderTracking`); or `checkoutId` alone
|
|
205
|
+
* (the confirmation link's). Answers as `getCustomerOrder` does, `shipment` set once a carrier
|
|
206
|
+
* has the parcel. Any mismatch rejects with a 404 (`order_track_not_found`).
|
|
207
|
+
*/
|
|
208
|
+
export declare function trackOrder(params: {
|
|
209
|
+
code?: string;
|
|
210
|
+
email?: string;
|
|
211
|
+
checkoutId?: string;
|
|
212
|
+
}): Promise<import("./types").PublicCustomerOrderDetail>;
|
|
213
|
+
/**
|
|
214
|
+
* Record who is paying, from the site's own payment page. Answers with the checkout as
|
|
215
|
+
* `getCheckout` does, now offering the cards that shopper saved at this shop.
|
|
216
|
+
*/
|
|
217
|
+
export declare function setCheckoutEmail(params: {
|
|
218
|
+
checkoutId: string;
|
|
219
|
+
email: string;
|
|
220
|
+
}): Promise<import("./types").PublicCheckoutSession>;
|
|
221
|
+
/**
|
|
222
|
+
* Pay for the basket: creates a checkout from the cart and answers with `checkoutUrl`, the
|
|
223
|
+
* hosted page the shopper's browser should be sent to — or, with `getCheckout`, the id of a
|
|
224
|
+
* checkout the site takes the payment for itself.
|
|
225
|
+
*
|
|
226
|
+
* Return that address from the server action and leave for it in the client —
|
|
227
|
+
* `window.location.assign(checkoutUrl)`. NOT `redirect()`: the payment page is a separate app
|
|
228
|
+
* under `/c/` on the same host, and a router navigation would ask this site to render it.
|
|
229
|
+
*/
|
|
230
|
+
export declare function createCheckout(params: {
|
|
231
|
+
cartId: string;
|
|
232
|
+
customerEmail?: string;
|
|
233
|
+
successUrl?: string;
|
|
234
|
+
cancelUrl?: string;
|
|
235
|
+
}): Promise<import("./types").PublicCheckout>;
|
|
236
|
+
/** Drop the cached client. For tests, and for a process that changes its environment. */
|
|
237
|
+
export declare function resetSiteData(): void;
|