@cloudexp-io/laudro-sdk 0.0.0-stage → 0.4.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,178 @@
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
+ LocationHours,
15
+ LunchDay,
16
+ LunchDayResponse,
17
+ LunchItem,
18
+ LunchOffer,
19
+ LunchQuery,
20
+ LunchResponse,
21
+ LunchWeekResponse,
22
+ Menu,
23
+ MenuItem,
24
+ MenuItemVariant,
25
+ MenuKind,
26
+ MenuSection,
27
+ MenusQuery,
28
+ MenusResponse,
29
+ PREVIEW_TOKEN_HEADER,
30
+ Page,
31
+ PageBlock,
32
+ PageKey,
33
+ PreviewCheck,
34
+ PreviewQuery,
35
+ RbApiError,
36
+ WEBHOOK_SIGNATURE_HEADER,
37
+ WEBHOOK_TOLERANCE_SECONDS,
38
+ WebhookPayload,
39
+ buildOpenApi,
40
+ createClient,
41
+ expandCacheTags,
42
+ openNow,
43
+ signFormToken,
44
+ verifyWebhook
45
+ } from "./chunk-4ADLD5ZW.js";
46
+ import {
47
+ Allergen,
48
+ AllergenCode,
49
+ BookingLocation,
50
+ BookingMode,
51
+ BookingProvider,
52
+ BookingRequestCreate,
53
+ BookingResponse,
54
+ ContactCreate,
55
+ Currency,
56
+ DEFAULT_LANG,
57
+ DietTag,
58
+ Email,
59
+ EventKind,
60
+ EventPackage,
61
+ EventPackagesResponse,
62
+ EventRequestCreate,
63
+ FormToken,
64
+ Honeypot,
65
+ IsoDate,
66
+ IsoDateTime,
67
+ IsoWeek,
68
+ Lang,
69
+ LangFallback,
70
+ LangQuery,
71
+ LocalTime,
72
+ Location,
73
+ LocationsResponse,
74
+ Media,
75
+ Money,
76
+ PROBLEM_CONTENT_TYPE,
77
+ PhoneInput,
78
+ Problem,
79
+ ProblemFieldError,
80
+ RequestCreated,
81
+ RestaurantStatus,
82
+ Site,
83
+ TrackEvent,
84
+ TrackName,
85
+ TurnstileToken,
86
+ Uuid,
87
+ WeeklyHours,
88
+ eur,
89
+ parseRetryAfter
90
+ } from "./chunk-6LTB3GRQ.js";
91
+ export {
92
+ API_ROUTES,
93
+ Allergen,
94
+ AllergenCode,
95
+ BookingLocation,
96
+ BookingMode,
97
+ BookingProvider,
98
+ BookingRequestCreate,
99
+ BookingResponse,
100
+ CACHE_TAGS,
101
+ CacheTag,
102
+ ContactCreate,
103
+ Currency,
104
+ DEFAULT_LANG,
105
+ DEFAULT_REVALIDATE_SECONDS,
106
+ DietTag,
107
+ Email,
108
+ EventKind,
109
+ EventPackage,
110
+ EventPackagesResponse,
111
+ EventRequestCreate,
112
+ FormToken,
113
+ HOURS_MAX_DAYS,
114
+ Honeypot,
115
+ HoursDay,
116
+ HoursInterval,
117
+ HoursKind,
118
+ HoursQuery,
119
+ HoursResponse,
120
+ IsoDate,
121
+ IsoDateTime,
122
+ IsoWeek,
123
+ KindHours,
124
+ LEGACY_PREVIEW_TOKEN_HEADER,
125
+ Lang,
126
+ LangFallback,
127
+ LangQuery,
128
+ LocalTime,
129
+ Location,
130
+ LocationHours,
131
+ LocationsResponse,
132
+ LunchDay,
133
+ LunchDayResponse,
134
+ LunchItem,
135
+ LunchOffer,
136
+ LunchQuery,
137
+ LunchResponse,
138
+ LunchWeekResponse,
139
+ Media,
140
+ Menu,
141
+ MenuItem,
142
+ MenuItemVariant,
143
+ MenuKind,
144
+ MenuSection,
145
+ MenusQuery,
146
+ MenusResponse,
147
+ Money,
148
+ PREVIEW_TOKEN_HEADER,
149
+ PROBLEM_CONTENT_TYPE,
150
+ Page,
151
+ PageBlock,
152
+ PageKey,
153
+ PhoneInput,
154
+ PreviewCheck,
155
+ PreviewQuery,
156
+ Problem,
157
+ ProblemFieldError,
158
+ RbApiError,
159
+ RequestCreated,
160
+ RestaurantStatus,
161
+ Site,
162
+ TrackEvent,
163
+ TrackName,
164
+ TurnstileToken,
165
+ Uuid,
166
+ WEBHOOK_SIGNATURE_HEADER,
167
+ WEBHOOK_TOLERANCE_SECONDS,
168
+ WebhookPayload,
169
+ WeeklyHours,
170
+ buildOpenApi,
171
+ createClient,
172
+ eur,
173
+ expandCacheTags,
174
+ openNow,
175
+ parseRetryAfter,
176
+ signFormToken,
177
+ verifyWebhook
178
+ };
@@ -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, 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,180 @@
1
+ import {
2
+ createClient
3
+ } from "./chunk-6J7GJOQI.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
+ LocationHours,
18
+ LunchDay,
19
+ LunchDayResponse,
20
+ LunchItem,
21
+ LunchOffer,
22
+ LunchQuery,
23
+ LunchResponse,
24
+ LunchWeekResponse,
25
+ Menu,
26
+ MenuItem,
27
+ MenuItemVariant,
28
+ MenuKind,
29
+ MenuSection,
30
+ MenusQuery,
31
+ MenusResponse,
32
+ PREVIEW_TOKEN_HEADER,
33
+ Page,
34
+ PageBlock,
35
+ PageKey,
36
+ PreviewCheck,
37
+ PreviewQuery,
38
+ RbApiError,
39
+ WEBHOOK_SIGNATURE_HEADER,
40
+ WEBHOOK_TOLERANCE_SECONDS,
41
+ WebhookPayload,
42
+ buildOpenApi,
43
+ expandCacheTags,
44
+ openNow,
45
+ signFormToken,
46
+ verifyWebhook
47
+ } from "./chunk-4ADLD5ZW.js";
48
+ import {
49
+ Allergen,
50
+ AllergenCode,
51
+ BookingLocation,
52
+ BookingMode,
53
+ BookingProvider,
54
+ BookingRequestCreate,
55
+ BookingResponse,
56
+ ContactCreate,
57
+ Currency,
58
+ DEFAULT_LANG,
59
+ DietTag,
60
+ Email,
61
+ EventKind,
62
+ EventPackage,
63
+ EventPackagesResponse,
64
+ EventRequestCreate,
65
+ FormToken,
66
+ Honeypot,
67
+ IsoDate,
68
+ IsoDateTime,
69
+ IsoWeek,
70
+ Lang,
71
+ LangFallback,
72
+ LangQuery,
73
+ LocalTime,
74
+ Location,
75
+ LocationsResponse,
76
+ Media,
77
+ Money,
78
+ PROBLEM_CONTENT_TYPE,
79
+ PhoneInput,
80
+ Problem,
81
+ ProblemFieldError,
82
+ RequestCreated,
83
+ RestaurantStatus,
84
+ Site,
85
+ TrackEvent,
86
+ TrackName,
87
+ TurnstileToken,
88
+ Uuid,
89
+ WeeklyHours,
90
+ eur,
91
+ parseRetryAfter
92
+ } from "./chunk-6LTB3GRQ.js";
93
+ export {
94
+ API_ROUTES,
95
+ Allergen,
96
+ AllergenCode,
97
+ BookingLocation,
98
+ BookingMode,
99
+ BookingProvider,
100
+ BookingRequestCreate,
101
+ BookingResponse,
102
+ CACHE_TAGS,
103
+ CacheTag,
104
+ ContactCreate,
105
+ Currency,
106
+ DEFAULT_LANG,
107
+ DEFAULT_REVALIDATE_SECONDS,
108
+ DietTag,
109
+ Email,
110
+ EventKind,
111
+ EventPackage,
112
+ EventPackagesResponse,
113
+ EventRequestCreate,
114
+ FormToken,
115
+ HOURS_MAX_DAYS,
116
+ Honeypot,
117
+ HoursDay,
118
+ HoursInterval,
119
+ HoursKind,
120
+ HoursQuery,
121
+ HoursResponse,
122
+ IsoDate,
123
+ IsoDateTime,
124
+ IsoWeek,
125
+ KindHours,
126
+ LEGACY_PREVIEW_TOKEN_HEADER,
127
+ Lang,
128
+ LangFallback,
129
+ LangQuery,
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
+ };