@cloudexp-io/laudro-sdk 0.0.0-stage → 0.5.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/core.js ADDED
@@ -0,0 +1,180 @@
1
+ import {
2
+ API_ROUTES,
3
+ CACHE_TAGS,
4
+ CacheTag,
5
+ DEFAULT_REVALIDATE_SECONDS,
6
+ HOURS_MAX_DAYS,
7
+ HoursDay,
8
+ HoursInterval,
9
+ HoursKind,
10
+ HoursQuery,
11
+ HoursResponse,
12
+ KindHours,
13
+ LEGACY_PREVIEW_TOKEN_HEADER,
14
+ LaudroApiError,
15
+ LocationHours,
16
+ LunchDay,
17
+ LunchDayResponse,
18
+ LunchItem,
19
+ LunchOffer,
20
+ LunchQuery,
21
+ LunchResponse,
22
+ LunchWeekResponse,
23
+ Menu,
24
+ MenuItem,
25
+ MenuItemVariant,
26
+ MenuKind,
27
+ MenuSection,
28
+ MenusQuery,
29
+ MenusResponse,
30
+ PREVIEW_TOKEN_HEADER,
31
+ Page,
32
+ PageBlock,
33
+ PageKey,
34
+ PreviewCheck,
35
+ PreviewQuery,
36
+ RbApiError,
37
+ WEBHOOK_SIGNATURE_HEADER,
38
+ WEBHOOK_TOLERANCE_SECONDS,
39
+ WebhookPayload,
40
+ buildOpenApi,
41
+ createClient,
42
+ expandCacheTags,
43
+ openNow,
44
+ signFormToken,
45
+ verifyWebhook
46
+ } from "./chunk-5H4Y5WKX.js";
47
+ import {
48
+ Allergen,
49
+ AllergenCode,
50
+ BookingLocation,
51
+ BookingMode,
52
+ BookingProvider,
53
+ BookingRequestCreate,
54
+ BookingResponse,
55
+ ContactCreate,
56
+ Currency,
57
+ DEFAULT_LANG,
58
+ DietTag,
59
+ Email,
60
+ EventKind,
61
+ EventPackage,
62
+ EventPackagesResponse,
63
+ EventRequestCreate,
64
+ FormToken,
65
+ Honeypot,
66
+ IsoDate,
67
+ IsoDateTime,
68
+ IsoWeek,
69
+ Lang,
70
+ LangFallback,
71
+ LangQuery,
72
+ LocalTime,
73
+ Location,
74
+ LocationsResponse,
75
+ Media,
76
+ Money,
77
+ PROBLEM_CONTENT_TYPE,
78
+ PhoneInput,
79
+ Problem,
80
+ ProblemFieldError,
81
+ RequestCreated,
82
+ RestaurantStatus,
83
+ Site,
84
+ TrackEvent,
85
+ TrackName,
86
+ TurnstileToken,
87
+ Uuid,
88
+ WeeklyHours,
89
+ eur,
90
+ parseRetryAfter
91
+ } from "./chunk-6LTB3GRQ.js";
92
+ export {
93
+ API_ROUTES,
94
+ Allergen,
95
+ AllergenCode,
96
+ BookingLocation,
97
+ BookingMode,
98
+ BookingProvider,
99
+ BookingRequestCreate,
100
+ BookingResponse,
101
+ CACHE_TAGS,
102
+ CacheTag,
103
+ ContactCreate,
104
+ Currency,
105
+ DEFAULT_LANG,
106
+ DEFAULT_REVALIDATE_SECONDS,
107
+ DietTag,
108
+ Email,
109
+ EventKind,
110
+ EventPackage,
111
+ EventPackagesResponse,
112
+ EventRequestCreate,
113
+ FormToken,
114
+ HOURS_MAX_DAYS,
115
+ Honeypot,
116
+ HoursDay,
117
+ HoursInterval,
118
+ HoursKind,
119
+ HoursQuery,
120
+ HoursResponse,
121
+ IsoDate,
122
+ IsoDateTime,
123
+ IsoWeek,
124
+ KindHours,
125
+ LEGACY_PREVIEW_TOKEN_HEADER,
126
+ Lang,
127
+ LangFallback,
128
+ LangQuery,
129
+ LaudroApiError,
130
+ LocalTime,
131
+ Location,
132
+ LocationHours,
133
+ LocationsResponse,
134
+ LunchDay,
135
+ LunchDayResponse,
136
+ LunchItem,
137
+ LunchOffer,
138
+ LunchQuery,
139
+ LunchResponse,
140
+ LunchWeekResponse,
141
+ Media,
142
+ Menu,
143
+ MenuItem,
144
+ MenuItemVariant,
145
+ MenuKind,
146
+ MenuSection,
147
+ MenusQuery,
148
+ MenusResponse,
149
+ Money,
150
+ PREVIEW_TOKEN_HEADER,
151
+ PROBLEM_CONTENT_TYPE,
152
+ Page,
153
+ PageBlock,
154
+ PageKey,
155
+ PhoneInput,
156
+ PreviewCheck,
157
+ PreviewQuery,
158
+ Problem,
159
+ ProblemFieldError,
160
+ RbApiError,
161
+ RequestCreated,
162
+ RestaurantStatus,
163
+ Site,
164
+ TrackEvent,
165
+ TrackName,
166
+ TurnstileToken,
167
+ Uuid,
168
+ WEBHOOK_SIGNATURE_HEADER,
169
+ WEBHOOK_TOLERANCE_SECONDS,
170
+ WebhookPayload,
171
+ WeeklyHours,
172
+ buildOpenApi,
173
+ createClient,
174
+ eur,
175
+ expandCacheTags,
176
+ openNow,
177
+ parseRetryAfter,
178
+ signFormToken,
179
+ verifyWebhook
180
+ };
@@ -0,0 +1,37 @@
1
+ import { R as RequestCreated, P as Problem } from './retry-BnQHOsTh.js';
2
+ import { RetryOptions } from './core.js';
3
+ export { B as BookingRequestCreate, C as ContactCreate, E as EventRequestCreate, b as ProblemFieldError, T as TrackEvent } from './retry-BnQHOsTh.js';
4
+ import 'zod';
5
+
6
+ /**
7
+ * Browser-safe form helpers: `@cloudexp-io/laudro-sdk/forms`.
8
+ *
9
+ * The browser never talks to the API and never sees the site secret. A form posts to the
10
+ * site's own route (for example `/api/booking`), and that route calls the server client
11
+ * (`rb.bookingRequests.create`). This entry gives the browser the same zod schemas for
12
+ * client-side checks and a small `submitForm` with the same retry rules.
13
+ */
14
+
15
+ type SubmitResult = {
16
+ ok: true;
17
+ data: RequestCreated;
18
+ } | {
19
+ ok: false;
20
+ status: number;
21
+ problem: Problem | null;
22
+ fieldErrors: Record<string, string>;
23
+ };
24
+ /** Field path to the first message, from a problem+json body. */
25
+ declare function fieldErrors(problem: Problem | null): Record<string, string>;
26
+ /**
27
+ * POST JSON to the site's own form route. Retries a 429 with backoff (honours Retry-After);
28
+ * never retries 5xx, so a booking is not sent twice. Network errors resolve as status 0.
29
+ */
30
+ declare function submitForm(url: string, body: unknown, opts?: {
31
+ fetch?: typeof fetch;
32
+ retry?: RetryOptions;
33
+ headers?: Record<string, string>;
34
+ }): Promise<SubmitResult>;
35
+
36
+ export { Problem, RequestCreated, fieldErrors, submitForm };
37
+ export type { SubmitResult };
package/dist/forms.js ADDED
@@ -0,0 +1,62 @@
1
+ import {
2
+ BookingRequestCreate,
3
+ ContactCreate,
4
+ EventRequestCreate,
5
+ Problem,
6
+ RequestCreated,
7
+ TrackEvent,
8
+ isRetryableWrite,
9
+ withRetry
10
+ } from "./chunk-6LTB3GRQ.js";
11
+
12
+ // src/forms.ts
13
+ function fieldErrors(problem) {
14
+ const out = {};
15
+ for (const e of problem?.errors ?? []) out[e.path] ??= e.message;
16
+ return out;
17
+ }
18
+ async function submitForm(url, body, opts = {}) {
19
+ const doFetch = opts.fetch ?? fetch;
20
+ let res;
21
+ try {
22
+ res = await withRetry(
23
+ () => doFetch(url, {
24
+ method: "POST",
25
+ headers: {
26
+ "content-type": "application/json",
27
+ accept: "application/json",
28
+ ...opts.headers
29
+ },
30
+ body: JSON.stringify(body)
31
+ }),
32
+ { ...opts.retry, retryable: isRetryableWrite, retryNetwork: false }
33
+ );
34
+ } catch {
35
+ return { ok: false, status: 0, problem: null, fieldErrors: {} };
36
+ }
37
+ let json;
38
+ try {
39
+ const text = await res.text();
40
+ json = text ? JSON.parse(text) : null;
41
+ } catch {
42
+ json = null;
43
+ }
44
+ if (res.ok) {
45
+ const data = RequestCreated.safeParse(json);
46
+ if (data.success) return { ok: true, data: data.data };
47
+ return { ok: false, status: res.status, problem: null, fieldErrors: {} };
48
+ }
49
+ const parsed = Problem.safeParse(json);
50
+ const problem = parsed.success ? parsed.data : null;
51
+ return { ok: false, status: res.status, problem, fieldErrors: fieldErrors(problem) };
52
+ }
53
+ export {
54
+ BookingRequestCreate,
55
+ ContactCreate,
56
+ EventRequestCreate,
57
+ Problem,
58
+ RequestCreated,
59
+ TrackEvent,
60
+ fieldErrors,
61
+ submitForm
62
+ };
@@ -0,0 +1,4 @@
1
+ export { createClient } from './next.js';
2
+ export { API_ROUTES, ApiRoute, BookingMode, CACHE_TAGS, CacheTag, DEFAULT_REVALIDATE_SECONDS, HOURS_MAX_DAYS, HoursDay, HoursInterval, HoursKind, HoursQuery, HoursResponse, KindHours, LEGACY_PREVIEW_TOKEN_HEADER, LaudroApiError, LaudroClient, LaudroClientOptions, Location, LocationHours, LocationsResponse, LunchDay, LunchDayResponse, LunchItem, LunchOffer, LunchQuery, LunchResponse, LunchWeekResponse, Menu, MenuItem, MenuItemVariant, MenuKind, MenuSection, MenusQuery, MenusResponse, OpenNow, PREVIEW_TOKEN_HEADER, Page, PageBlock, PageKey, PreviewCheck, PreviewQuery, RbApiError, RbClient, RbClientOptions, RequestOptions, RestaurantStatus, Site, VerifyWebhookResult, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TOLERANCE_SECONDS, WebhookPayload, WriteOptions, buildOpenApi, expandCacheTags, openNow, signFormToken, verifyWebhook } from './core.js';
3
+ export { A as Allergen, c as AllergenCode, d as BookingLocation, e as BookingProvider, B as BookingRequestCreate, f as BookingResponse, C as ContactCreate, g as Currency, D as DEFAULT_LANG, h as DietTag, i as Email, j as EventKind, k as EventPackage, l as EventPackagesResponse, E as EventRequestCreate, F as FormToken, H as Honeypot, I as IsoDate, m as IsoDateTime, n as IsoWeek, o as Lang, p as LangFallback, L as LangQuery, q as LocalTime, M as Media, r as Money, s as PROBLEM_CONTENT_TYPE, t as PhoneInput, P as Problem, b as ProblemFieldError, R as RequestCreated, a as RetryOptions, T as TrackEvent, u as TrackName, v as TurnstileToken, U as Uuid, W as WeeklyHours, w as eur, x as parseRetryAfter } from './retry-BnQHOsTh.js';
4
+ import 'zod';
package/dist/index.js ADDED
@@ -0,0 +1,182 @@
1
+ import {
2
+ createClient
3
+ } from "./chunk-LSPODMW7.js";
4
+ import {
5
+ API_ROUTES,
6
+ CACHE_TAGS,
7
+ CacheTag,
8
+ DEFAULT_REVALIDATE_SECONDS,
9
+ HOURS_MAX_DAYS,
10
+ HoursDay,
11
+ HoursInterval,
12
+ HoursKind,
13
+ HoursQuery,
14
+ HoursResponse,
15
+ KindHours,
16
+ LEGACY_PREVIEW_TOKEN_HEADER,
17
+ LaudroApiError,
18
+ LocationHours,
19
+ LunchDay,
20
+ LunchDayResponse,
21
+ LunchItem,
22
+ LunchOffer,
23
+ LunchQuery,
24
+ LunchResponse,
25
+ LunchWeekResponse,
26
+ Menu,
27
+ MenuItem,
28
+ MenuItemVariant,
29
+ MenuKind,
30
+ MenuSection,
31
+ MenusQuery,
32
+ MenusResponse,
33
+ PREVIEW_TOKEN_HEADER,
34
+ Page,
35
+ PageBlock,
36
+ PageKey,
37
+ PreviewCheck,
38
+ PreviewQuery,
39
+ RbApiError,
40
+ WEBHOOK_SIGNATURE_HEADER,
41
+ WEBHOOK_TOLERANCE_SECONDS,
42
+ WebhookPayload,
43
+ buildOpenApi,
44
+ expandCacheTags,
45
+ openNow,
46
+ signFormToken,
47
+ verifyWebhook
48
+ } from "./chunk-5H4Y5WKX.js";
49
+ import {
50
+ Allergen,
51
+ AllergenCode,
52
+ BookingLocation,
53
+ BookingMode,
54
+ BookingProvider,
55
+ BookingRequestCreate,
56
+ BookingResponse,
57
+ ContactCreate,
58
+ Currency,
59
+ DEFAULT_LANG,
60
+ DietTag,
61
+ Email,
62
+ EventKind,
63
+ EventPackage,
64
+ EventPackagesResponse,
65
+ EventRequestCreate,
66
+ FormToken,
67
+ Honeypot,
68
+ IsoDate,
69
+ IsoDateTime,
70
+ IsoWeek,
71
+ Lang,
72
+ LangFallback,
73
+ LangQuery,
74
+ LocalTime,
75
+ Location,
76
+ LocationsResponse,
77
+ Media,
78
+ Money,
79
+ PROBLEM_CONTENT_TYPE,
80
+ PhoneInput,
81
+ Problem,
82
+ ProblemFieldError,
83
+ RequestCreated,
84
+ RestaurantStatus,
85
+ Site,
86
+ TrackEvent,
87
+ TrackName,
88
+ TurnstileToken,
89
+ Uuid,
90
+ WeeklyHours,
91
+ eur,
92
+ parseRetryAfter
93
+ } from "./chunk-6LTB3GRQ.js";
94
+ export {
95
+ API_ROUTES,
96
+ Allergen,
97
+ AllergenCode,
98
+ BookingLocation,
99
+ BookingMode,
100
+ BookingProvider,
101
+ BookingRequestCreate,
102
+ BookingResponse,
103
+ CACHE_TAGS,
104
+ CacheTag,
105
+ ContactCreate,
106
+ Currency,
107
+ DEFAULT_LANG,
108
+ DEFAULT_REVALIDATE_SECONDS,
109
+ DietTag,
110
+ Email,
111
+ EventKind,
112
+ EventPackage,
113
+ EventPackagesResponse,
114
+ EventRequestCreate,
115
+ FormToken,
116
+ HOURS_MAX_DAYS,
117
+ Honeypot,
118
+ HoursDay,
119
+ HoursInterval,
120
+ HoursKind,
121
+ HoursQuery,
122
+ HoursResponse,
123
+ IsoDate,
124
+ IsoDateTime,
125
+ IsoWeek,
126
+ KindHours,
127
+ LEGACY_PREVIEW_TOKEN_HEADER,
128
+ Lang,
129
+ LangFallback,
130
+ LangQuery,
131
+ LaudroApiError,
132
+ LocalTime,
133
+ Location,
134
+ LocationHours,
135
+ LocationsResponse,
136
+ LunchDay,
137
+ LunchDayResponse,
138
+ LunchItem,
139
+ LunchOffer,
140
+ LunchQuery,
141
+ LunchResponse,
142
+ LunchWeekResponse,
143
+ Media,
144
+ Menu,
145
+ MenuItem,
146
+ MenuItemVariant,
147
+ MenuKind,
148
+ MenuSection,
149
+ MenusQuery,
150
+ MenusResponse,
151
+ Money,
152
+ PREVIEW_TOKEN_HEADER,
153
+ PROBLEM_CONTENT_TYPE,
154
+ Page,
155
+ PageBlock,
156
+ PageKey,
157
+ PhoneInput,
158
+ PreviewCheck,
159
+ PreviewQuery,
160
+ Problem,
161
+ ProblemFieldError,
162
+ RbApiError,
163
+ RequestCreated,
164
+ RestaurantStatus,
165
+ Site,
166
+ TrackEvent,
167
+ TrackName,
168
+ TurnstileToken,
169
+ Uuid,
170
+ WEBHOOK_SIGNATURE_HEADER,
171
+ WEBHOOK_TOLERANCE_SECONDS,
172
+ WebhookPayload,
173
+ WeeklyHours,
174
+ buildOpenApi,
175
+ createClient,
176
+ eur,
177
+ expandCacheTags,
178
+ openNow,
179
+ parseRetryAfter,
180
+ signFormToken,
181
+ verifyWebhook
182
+ };