@staycore/booking-sdk 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.
Files changed (50) hide show
  1. package/README.md +120 -0
  2. package/dist/client.d.ts +42 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +94 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/errors.d.ts +15 -0
  7. package/dist/errors.d.ts.map +1 -0
  8. package/dist/errors.js +25 -0
  9. package/dist/errors.js.map +1 -0
  10. package/dist/index.d.ts +7 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +6 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/react/index.d.ts +8 -0
  15. package/dist/react/index.d.ts.map +1 -0
  16. package/dist/react/index.js +7 -0
  17. package/dist/react/index.js.map +1 -0
  18. package/dist/react/provider.d.ts +8 -0
  19. package/dist/react/provider.d.ts.map +1 -0
  20. package/dist/react/provider.js +20 -0
  21. package/dist/react/provider.js.map +1 -0
  22. package/dist/react/useAsync.d.ts +29 -0
  23. package/dist/react/useAsync.d.ts.map +1 -0
  24. package/dist/react/useAsync.js +63 -0
  25. package/dist/react/useAsync.js.map +1 -0
  26. package/dist/react/useAvailability.d.ts +5 -0
  27. package/dist/react/useAvailability.d.ts.map +1 -0
  28. package/dist/react/useAvailability.js +7 -0
  29. package/dist/react/useAvailability.js.map +1 -0
  30. package/dist/react/useCheckout.d.ts +10 -0
  31. package/dist/react/useCheckout.d.ts.map +1 -0
  32. package/dist/react/useCheckout.js +31 -0
  33. package/dist/react/useCheckout.js.map +1 -0
  34. package/dist/react/useOrgConfig.d.ts +5 -0
  35. package/dist/react/useOrgConfig.d.ts.map +1 -0
  36. package/dist/react/useOrgConfig.js +7 -0
  37. package/dist/react/useOrgConfig.js.map +1 -0
  38. package/dist/react/usePrice.d.ts +5 -0
  39. package/dist/react/usePrice.d.ts.map +1 -0
  40. package/dist/react/usePrice.js +11 -0
  41. package/dist/react/usePrice.js.map +1 -0
  42. package/dist/react/useProperties.d.ts +5 -0
  43. package/dist/react/useProperties.d.ts.map +1 -0
  44. package/dist/react/useProperties.js +7 -0
  45. package/dist/react/useProperties.js.map +1 -0
  46. package/dist/types.d.ts +147 -0
  47. package/dist/types.d.ts.map +1 -0
  48. package/dist/types.js +12 -0
  49. package/dist/types.js.map +1 -0
  50. package/package.json +64 -0
package/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # @staycore/booking-sdk
2
+
3
+ > TypeScript SDK for the **Stay'Core PMS** public booking engine API (v1).
4
+
5
+ [![npm](https://img.shields.io/npm/v/@staycore/booking-sdk)](https://www.npmjs.com/package/@staycore/booking-sdk)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ Connect any web app (Vite / Next.js / Remix / Astro / vanilla browser / Node service / edge runtime) to the Stay'Core direct booking engine in a few lines.
9
+
10
+ ---
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ pnpm add @staycore/booking-sdk
16
+ # or
17
+ npm install @staycore/booking-sdk
18
+ ```
19
+
20
+ ## Quickstart (vanilla)
21
+
22
+ ```ts
23
+ import { createPmsClient } from '@staycore/booking-sdk';
24
+
25
+ const pms = createPmsClient({ orgSlug: 'mon-org' });
26
+
27
+ const config = await pms.config();
28
+ const properties = await pms.properties.list();
29
+ const price = await pms.price.compute(properties[0].id, {
30
+ check_in: '2026-08-01',
31
+ check_out: '2026-08-05',
32
+ guests_count: 2,
33
+ });
34
+
35
+ const checkout = await pms.checkout.create({
36
+ property_id: properties[0].id,
37
+ guest_name: 'Jean Dupont',
38
+ guest_email: 'jean@example.com',
39
+ check_in: '2026-08-01',
40
+ check_out: '2026-08-05',
41
+ guests_count: 2,
42
+ });
43
+
44
+ // checkout.client_secret → Stripe Elements
45
+ ```
46
+
47
+ ## React hooks
48
+
49
+ ```tsx
50
+ import {
51
+ StayCoreProvider,
52
+ useProperties,
53
+ useAvailability,
54
+ usePrice,
55
+ useCheckout,
56
+ } from '@staycore/booking-sdk/react';
57
+
58
+ function App() {
59
+ return (
60
+ <StayCoreProvider orgSlug="mon-org">
61
+ <Booking />
62
+ </StayCoreProvider>
63
+ );
64
+ }
65
+
66
+ function Booking() {
67
+ const { data: properties, isLoading } = useProperties();
68
+ // …
69
+ }
70
+ ```
71
+
72
+ ## API surface
73
+
74
+ ```ts
75
+ pms.config() // GET /book/{slug}
76
+ pms.properties.list() // GET /book/{slug}/properties
77
+ pms.availability.get(propertyId) // GET /book/{slug}/properties/{id}/availability
78
+ pms.price.compute(propertyId, params) // GET /book/{slug}/properties/{id}/price?...
79
+ pms.checkout.create(payload) // POST /book/{slug}/checkout
80
+ pms.coupon.validate(payload) // POST /book/{slug}/validate-coupon
81
+ pms.booking.get(token) // GET /book/{slug}/booking/{token}
82
+ pms.booking.confirm(token) // POST /book/{slug}/booking/{token}/confirm
83
+ ```
84
+
85
+ ## Error handling
86
+
87
+ ```ts
88
+ import { StayCoreApiError } from '@staycore/booking-sdk';
89
+
90
+ try {
91
+ await pms.checkout.create(payload);
92
+ } catch (err) {
93
+ if (err instanceof StayCoreApiError) {
94
+ console.error(err.status, err.message, err.body);
95
+ if (err.isClientError) /* show user error */;
96
+ }
97
+ }
98
+ ```
99
+
100
+ ## Custom base URL / advanced options
101
+
102
+ ```ts
103
+ createPmsClient({
104
+ orgSlug: 'mon-org',
105
+ baseUrl: 'https://api.stay-core.com/api/v1', // default
106
+ timeoutMs: 30000,
107
+ defaultHeaders: { 'Accept-Language': 'fr' },
108
+ fetch: customFetch, // node < 18 / monkey-patched
109
+ });
110
+ ```
111
+
112
+ ## Versioning
113
+
114
+ The SDK targets `/api/v1/book/...` — a frozen, additive route group on the Stay'Core backend, guarded by [`BookingContractTest.php`](https://github.com/Keenqo-Dev-Team/staycore-pms/blob/develop/backend/tests/Feature/Api/V1/BookingContractTest.php).
115
+
116
+ Breaking changes would require `/api/v2/...` and a major version bump (`@staycore/booking-sdk@2.x`).
117
+
118
+ ## License
119
+
120
+ MIT © [Keenqo](https://keenqo.fr) — Stay'Core
@@ -0,0 +1,42 @@
1
+ import type { AvailabilityCalendar, BookingStatus, CheckoutRequest, CheckoutResponse, CouponValidationRequest, CouponValidationResult, OrgConfig, PriceQuote, PriceQuoteRequest, Property } from './types.js';
2
+ export type StayCoreClientOptions = {
3
+ /** Organization slug as registered in the Stay'Core PMS. */
4
+ orgSlug: string;
5
+ /** Override the API base URL. Default: `https://api.stay-core.com/api/v1`. */
6
+ baseUrl?: string;
7
+ /**
8
+ * Optional `fetch` implementation. Falls back to globalThis.fetch (Node 20+,
9
+ * all browsers, Cloudflare Workers, Vercel Edge, etc.).
10
+ */
11
+ fetch?: typeof globalThis.fetch;
12
+ /** Extra headers attached to every request (e.g. `Accept-Language`). */
13
+ defaultHeaders?: Record<string, string>;
14
+ /** Request timeout in milliseconds. Default: 15000. */
15
+ timeoutMs?: number;
16
+ };
17
+ export type StayCoreClient = {
18
+ readonly orgSlug: string;
19
+ readonly baseUrl: string;
20
+ config: () => Promise<OrgConfig>;
21
+ properties: {
22
+ list: () => Promise<Property[]>;
23
+ };
24
+ availability: {
25
+ get: (propertyId: number) => Promise<AvailabilityCalendar>;
26
+ };
27
+ price: {
28
+ compute: (propertyId: number, params: PriceQuoteRequest) => Promise<PriceQuote>;
29
+ };
30
+ checkout: {
31
+ create: (payload: CheckoutRequest) => Promise<CheckoutResponse>;
32
+ };
33
+ coupon: {
34
+ validate: (payload: CouponValidationRequest) => Promise<CouponValidationResult>;
35
+ };
36
+ booking: {
37
+ get: (token: string) => Promise<BookingStatus>;
38
+ confirm: (token: string) => Promise<BookingStatus>;
39
+ };
40
+ };
41
+ export declare function createPmsClient(options: StayCoreClientOptions): StayCoreClient;
42
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,oBAAoB,EACpB,aAA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AC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;QAC/C,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;KACpD,CAAC;CACH,CAAC;AAoBF,wBAAgB,eAAe,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAkG9E"}
package/dist/client.js ADDED
@@ -0,0 +1,94 @@
1
+ import { StayCoreApiError } from './errors.js';
2
+ const DEFAULT_BASE_URL = 'https://api.stay-core.com/api/v1';
3
+ const DEFAULT_TIMEOUT_MS = 15_000;
4
+ function joinUrl(base, path) {
5
+ const cleanBase = base.replace(/\/$/, '');
6
+ const cleanPath = path.startsWith('/') ? path : `/${path}`;
7
+ return `${cleanBase}${cleanPath}`;
8
+ }
9
+ function toQueryString(params) {
10
+ if (!params)
11
+ return '';
12
+ const entries = Object.entries(params).filter(([, v]) => v !== undefined && v !== null && v !== '');
13
+ if (entries.length === 0)
14
+ return '';
15
+ const search = new URLSearchParams();
16
+ for (const [k, v] of entries)
17
+ search.set(k, String(v));
18
+ return `?${search.toString()}`;
19
+ }
20
+ export function createPmsClient(options) {
21
+ if (!options.orgSlug) {
22
+ throw new Error('createPmsClient: orgSlug is required.');
23
+ }
24
+ const baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
25
+ const fetchFn = options.fetch ?? globalThis.fetch;
26
+ if (!fetchFn) {
27
+ throw new Error('createPmsClient: no fetch implementation found. Pass options.fetch on Node <18.');
28
+ }
29
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
30
+ const orgPath = `/book/${encodeURIComponent(options.orgSlug)}`;
31
+ async function request(method, path, init) {
32
+ const url = joinUrl(baseUrl, `${orgPath}${path}${toQueryString(init?.query)}`);
33
+ const controller = new AbortController();
34
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
35
+ let response;
36
+ try {
37
+ response = await fetchFn(url, {
38
+ method,
39
+ signal: controller.signal,
40
+ headers: {
41
+ Accept: 'application/json',
42
+ ...(init?.body ? { 'Content-Type': 'application/json' } : {}),
43
+ ...options.defaultHeaders,
44
+ },
45
+ body: init?.body ? JSON.stringify(init.body) : undefined,
46
+ });
47
+ }
48
+ catch (err) {
49
+ clearTimeout(timer);
50
+ const message = err instanceof Error ? err.message : 'Network error';
51
+ throw new StayCoreApiError(message, 0, null, `${method} ${path}`);
52
+ }
53
+ clearTimeout(timer);
54
+ let body = null;
55
+ try {
56
+ body = (await response.json());
57
+ }
58
+ catch {
59
+ // Body is not JSON — keep `body` null.
60
+ }
61
+ if (!response.ok || !body || body.success === false) {
62
+ const message = body && 'message' in body && body.message
63
+ ? body.message
64
+ : `HTTP ${response.status} on ${method} ${path}`;
65
+ throw new StayCoreApiError(message, response.status, body, `${method} ${path}`);
66
+ }
67
+ return body.data;
68
+ }
69
+ return {
70
+ orgSlug: options.orgSlug,
71
+ baseUrl,
72
+ config: () => request('GET', ''),
73
+ properties: {
74
+ list: () => request('GET', '/properties'),
75
+ },
76
+ availability: {
77
+ get: (propertyId) => request('GET', `/properties/${propertyId}/availability`),
78
+ },
79
+ price: {
80
+ compute: (propertyId, params) => request('GET', `/properties/${propertyId}/price`, { query: params }),
81
+ },
82
+ checkout: {
83
+ create: (payload) => request('POST', '/checkout', { body: payload }),
84
+ },
85
+ coupon: {
86
+ validate: (payload) => request('POST', '/validate-coupon', { body: payload }),
87
+ },
88
+ booking: {
89
+ get: (token) => request('GET', `/booking/${encodeURIComponent(token)}`),
90
+ confirm: (token) => request('POST', `/booking/${encodeURIComponent(token)}/confirm`),
91
+ },
92
+ };
93
+ }
94
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAwD/C,MAAM,gBAAgB,GAAG,kCAAkC,CAAC;AAC5D,MAAM,kBAAkB,GAAG,MAAM,C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E,CAC9B,OAAO,CAAa,KAAK,EAAE,eAAe,UAAU,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;SACnF;QAED,QAAQ,EAAE;YACR,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAmB,MAAM,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;SACvF;QAED,MAAM,EAAE;YACN,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CACpB,OAAO,CAAyB,MAAM,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;SACjF;QAED,OAAO,EAAE;YACP,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CACb,OAAO,CAAgB,KAAK,EAAE,YAAY,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;YACxE,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,OAAO,CAAgB,MAAM,EAAE,YAAY,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC;SAClF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Error class raised by {@link createPmsClient} when the Stay'Core API returns
3
+ * a non-2xx response or `{ success: false }` envelope.
4
+ */
5
+ export declare class StayCoreApiError extends Error {
6
+ readonly status: number;
7
+ readonly body: unknown;
8
+ readonly endpoint: string;
9
+ constructor(message: string, status: number, body: unknown, endpoint: string);
10
+ /** True if the error is a 4xx (caller fault). */
11
+ get isClientError(): boolean;
12
+ /** True if the error is a 5xx (server fault, may be retried). */
13
+ get isServerError(): boolean;
14
+ }
15
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,IAAI,EAAE,OAAO,CAAC;IAC9B,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAErB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM;IAQ5E,iDAAiD;IACjD,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,iEAAiE;IACjE,IAAI,aAAa,IAAI,OAAO,CAE3B;CACF"}
package/dist/errors.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Error class raised by {@link createPmsClient} when the Stay'Core API returns
3
+ * a non-2xx response or `{ success: false }` envelope.
4
+ */
5
+ export class StayCoreApiError extends Error {
6
+ status;
7
+ body;
8
+ endpoint;
9
+ constructor(message, status, body, endpoint) {
10
+ super(message);
11
+ this.name = 'StayCoreApiError';
12
+ this.status = status;
13
+ this.body = body;
14
+ this.endpoint = endpoint;
15
+ }
16
+ /** True if the error is a 4xx (caller fault). */
17
+ get isClientError() {
18
+ return this.status >= 400 && this.status < 500;
19
+ }
20
+ /** True if the error is a 5xx (server fault, may be retried). */
21
+ get isServerError() {
22
+ return this.status >= 500;
23
+ }
24
+ }
25
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzB,MAAM,CAAS;IACf,IAAI,CAAU;IACd,QAAQ,CAAS;IAEjC,YAAY,OAAe,EAAE,MAAc,EAAE,IAAa,EAAE,QAAgB;QAC1E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,iDAAiD;IACjD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;IACjD,CAAC;IAED,iEAAiE;IACjE,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ export { createPmsClient } from './client.js';
2
+ export type { StayCoreClient, StayCoreClientOptions } from './client.js';
3
+ export { StayCoreApiError } from './errors.js';
4
+ export * from './types.js';
5
+ export declare const SDK_VERSION = "0.1.0";
6
+ export declare const API_VERSION = "v1";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,cAAc,YAAY,CAAC;AAE3B,eAAO,MAAM,WAAW,UAAU,CAAC;AACnC,eAAO,MAAM,WAAW,OAAO,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { createPmsClient } from './client.js';
2
+ export { StayCoreApiError } from './errors.js';
3
+ export * from './types.js';
4
+ export const SDK_VERSION = '0.1.0';
5
+ export const API_VERSION = 'v1';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,cAAc,YAAY,CAAC;AAE3B,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { StayCoreProvider, useStayCore } from './provider.js';
2
+ export { useOrgConfig } from './useOrgConfig.js';
3
+ export { useProperties } from './useProperties.js';
4
+ export { useAvailability } from './useAvailability.js';
5
+ export { usePrice } from './usePrice.js';
6
+ export { useCheckout } from './useCheckout.js';
7
+ export type { AsyncState } from './useAsync.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { StayCoreProvider, useStayCore } from './provider.js';
2
+ export { useOrgConfig } from './useOrgConfig.js';
3
+ export { useProperties } from './useProperties.js';
4
+ export { useAvailability } from './useAvailability.js';
5
+ export { usePrice } from './usePrice.js';
6
+ export { useCheckout } from './useCheckout.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type StayCoreClient, type StayCoreClientOptions } from '../client.js';
3
+ export type StayCoreProviderProps = StayCoreClientOptions & {
4
+ children: ReactNode;
5
+ };
6
+ export declare function StayCoreProvider({ children, ...options }: StayCoreProviderProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function useStayCore(): StayCoreClient;
8
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAmB,KAAK,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAIhG,MAAM,MAAM,qBAAqB,GAAG,qBAAqB,GAAG;IAC1D,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,EAAE,qBAAqB,2CAO/E;AAED,wBAAgB,WAAW,IAAI,cAAc,CAQ5C"}
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo } from 'react';
3
+ import { createPmsClient } from '../client.js';
4
+ const StayCoreContext = createContext(null);
5
+ export function StayCoreProvider({ children, ...options }) {
6
+ const client = useMemo(() => createPmsClient(options), [
7
+ options.orgSlug,
8
+ options.baseUrl,
9
+ options.timeoutMs,
10
+ ]);
11
+ return _jsx(StayCoreContext.Provider, { value: client, children: children });
12
+ }
13
+ export function useStayCore() {
14
+ const client = useContext(StayCoreContext);
15
+ if (!client) {
16
+ throw new Error('useStayCore: no <StayCoreProvider> found. Wrap your tree with <StayCoreProvider orgSlug="..." />.');
17
+ }
18
+ return client;
19
+ }
20
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAmD,MAAM,cAAc,CAAC;AAEhG,MAAM,eAAe,GAAG,aAAa,CAAwB,IAAI,CAAC,CAAC;AAMnE,MAAM,UAAU,gBAAgB,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAyB;IAC9E,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE;QACrD,OAAO,CAAC,OAAO;QACf,OAAO,CAAC,OAAO;QACf,OAAO,CAAC,SAAS;KAClB,CAAC,CAAC;IACH,OAAO,KAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YAAG,QAAQ,GAA4B,CAAC;AACxF,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,MAAM,MAAM,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAC3C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,mGAAmG,CACpG,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,29 @@
1
+ export type AsyncState<T> = {
2
+ status: 'idle';
3
+ data: null;
4
+ error: null;
5
+ isLoading: false;
6
+ } | {
7
+ status: 'loading';
8
+ data: null;
9
+ error: null;
10
+ isLoading: true;
11
+ } | {
12
+ status: 'success';
13
+ data: T;
14
+ error: null;
15
+ isLoading: false;
16
+ } | {
17
+ status: 'error';
18
+ data: null;
19
+ error: Error;
20
+ isLoading: false;
21
+ };
22
+ /**
23
+ * Tiny async runner with cancellation. Re-fires when `key` changes; pass
24
+ * `null` to skip the fetch (useful when required params are not ready).
25
+ */
26
+ export declare function useAsync<T>(factory: () => Promise<T>, key: string | null): AsyncState<T> & {
27
+ refresh: () => void;
28
+ };
29
+ //# sourceMappingURL=useAsync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAsync.d.ts","sourceRoot":"","sources":["../../src/react/useAsync.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,CAAC,CAAC,IACpB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,KAAK,CAAA;CAAE,GAC7D;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,IAAI,CAAA;CAAE,GAC/D;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,KAAK,CAAA;CAAE,GAC7D;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,KAAK,CAAA;CAAE,CAAC;AAIpE;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACzB,GAAG,EAAE,MAAM,GAAG,IAAI,GACjB,UAAU,CAAC,CAAC,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAwDzC"}
@@ -0,0 +1,63 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ const IDLE = { status: 'idle', data: null, error: null, isLoading: false };
3
+ /**
4
+ * Tiny async runner with cancellation. Re-fires when `key` changes; pass
5
+ * `null` to skip the fetch (useful when required params are not ready).
6
+ */
7
+ export function useAsync(factory, key) {
8
+ const [state, setState] = useState(IDLE);
9
+ const tickRef = useRef(0);
10
+ useEffect(() => {
11
+ if (key === null) {
12
+ setState(IDLE);
13
+ return;
14
+ }
15
+ const tick = ++tickRef.current;
16
+ setState({ status: 'loading', data: null, error: null, isLoading: true });
17
+ factory()
18
+ .then((data) => {
19
+ if (tick !== tickRef.current)
20
+ return;
21
+ setState({ status: 'success', data, error: null, isLoading: false });
22
+ })
23
+ .catch((error) => {
24
+ if (tick !== tickRef.current)
25
+ return;
26
+ setState({
27
+ status: 'error',
28
+ data: null,
29
+ error: error instanceof Error ? error : new Error(String(error)),
30
+ isLoading: false,
31
+ });
32
+ });
33
+ return () => {
34
+ tickRef.current++;
35
+ };
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ }, [key]);
38
+ const refresh = () => {
39
+ tickRef.current++;
40
+ if (key !== null) {
41
+ const tick = tickRef.current;
42
+ setState({ status: 'loading', data: null, error: null, isLoading: true });
43
+ factory()
44
+ .then((data) => {
45
+ if (tick !== tickRef.current)
46
+ return;
47
+ setState({ status: 'success', data, error: null, isLoading: false });
48
+ })
49
+ .catch((error) => {
50
+ if (tick !== tickRef.current)
51
+ return;
52
+ setState({
53
+ status: 'error',
54
+ data: null,
55
+ error: error instanceof Error ? error : new Error(String(error)),
56
+ isLoading: false,
57
+ });
58
+ });
59
+ }
60
+ };
61
+ return { ...state, refresh };
62
+ }
63
+ //# sourceMappingURL=useAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAsync.js","sourceRoot":"","sources":["../../src/react/useAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQpD,MAAM,IAAI,GAAsB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAE9F;;;GAGG;AACH,MAAM,UAAU,QAAQ,CACtB,OAAyB,EACzB,GAAkB;IAElB,MAAM,CAAC,KAAK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CAAC,OAAO,EAAE,CAAC;QAClB,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;YAC7B,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1E,OAAO,EAAE;iBACN,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;gBACb,IAAI,IAAI,KAAK,OAAO,CAAC,OAAO;oBAAE,OAAO;gBACrC,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;YACvE,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;gBACxB,IAAI,IAAI,KAAK,OAAO,CAAC,OAAO;oBAAE,OAAO;gBACrC,QAAQ,CAAC;oBACP,MAAM,EAAE,OAAO;oBACf,IAAI,EAAE,IAAI;oBACV,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBAChE,SAAS,EAAE,KAAK;iBACjB,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { AvailabilityCalendar } from '../types.js';
2
+ export declare function useAvailability(propertyId: number | null | undefined): import("./useAsync.js").AsyncState<AvailabilityCalendar> & {
3
+ refresh: () => void;
4
+ };
5
+ //# sourceMappingURL=useAvailability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAvailability.d.ts","sourceRoot":"","sources":["../../src/react/useAvailability.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;;EAMpE"}
@@ -0,0 +1,7 @@
1
+ import { useStayCore } from './provider.js';
2
+ import { useAsync } from './useAsync.js';
3
+ export function useAvailability(propertyId) {
4
+ const client = useStayCore();
5
+ return useAsync(() => client.availability.get(propertyId), propertyId == null ? null : `availability:${client.orgSlug}:${propertyId}`);
6
+ }
7
+ //# sourceMappingURL=useAvailability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAvailability.js","sourceRoot":"","sources":["../../src/react/useAvailability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,MAAM,UAAU,eAAe,CAAC,UAAqC;IACnE,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,OAAO,QAAQ,CACb,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,UAAoB,CAAC,EACnD,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,MAAM,CAAC,OAAO,IAAI,UAAU,EAAE,CAC3E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { CheckoutRequest, CheckoutResponse } from '../types.js';
2
+ import type { AsyncState } from './useAsync.js';
3
+ /**
4
+ * Mutation hook for the checkout endpoint. Returns `{ submit, ...state }`.
5
+ */
6
+ export declare function useCheckout(): AsyncState<CheckoutResponse> & {
7
+ submit: (payload: CheckoutRequest) => Promise<CheckoutResponse>;
8
+ reset: () => void;
9
+ };
10
+ //# sourceMappingURL=useCheckout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCheckout.d.ts","sourceRoot":"","sources":["../../src/react/useCheckout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAShD;;GAEG;AACH,wBAAgB,WAAW,IAAI,UAAU,CAAC,gBAAgB,CAAC,GAAG;IAC5D,MAAM,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChE,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAuBA"}
@@ -0,0 +1,31 @@
1
+ import { useCallback, useState } from 'react';
2
+ import { useStayCore } from './provider.js';
3
+ const IDLE = {
4
+ status: 'idle',
5
+ data: null,
6
+ error: null,
7
+ isLoading: false,
8
+ };
9
+ /**
10
+ * Mutation hook for the checkout endpoint. Returns `{ submit, ...state }`.
11
+ */
12
+ export function useCheckout() {
13
+ const client = useStayCore();
14
+ const [state, setState] = useState(IDLE);
15
+ const submit = useCallback(async (payload) => {
16
+ setState({ status: 'loading', data: null, error: null, isLoading: true });
17
+ try {
18
+ const data = await client.checkout.create(payload);
19
+ setState({ status: 'success', data, error: null, isLoading: false });
20
+ return data;
21
+ }
22
+ catch (error) {
23
+ const err = error instanceof Error ? error : new Error(String(error));
24
+ setState({ status: 'error', data: null, error: err, isLoading: false });
25
+ throw err;
26
+ }
27
+ }, [client]);
28
+ const reset = useCallback(() => setState(IDLE), []);
29
+ return { ...state, submit, reset };
30
+ }
31
+ //# sourceMappingURL=useCheckout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCheckout.js","sourceRoot":"","sources":["../../src/react/useCheckout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,MAAM,IAAI,GAAiC;IACzC,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,IA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 -0,0 +1,5 @@
1
+ import type { OrgConfig } from '../types.js';
2
+ export declare function useOrgConfig(): import("./useAsync.js").AsyncState<OrgConfig> & {
3
+ refresh: () => void;
4
+ };
5
+ //# sourceMappingURL=useOrgConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOrgConfig.d.ts","sourceRoot":"","sources":["../../src/react/useOrgConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,wBAAgB,YAAY;;EAG3B"}
@@ -0,0 +1,7 @@
1
+ import { useStayCore } from './provider.js';
2
+ import { useAsync } from './useAsync.js';
3
+ export function useOrgConfig() {
4
+ const client = useStayCore();
5
+ return useAsync(() => client.config(), `config:${client.orgSlug}`);
6
+ }
7
+ //# sourceMappingURL=useOrgConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOrgConfig.js","sourceRoot":"","sources":["../../src/react/useOrgConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,MAAM,UAAU,YAAY;IAC1B,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,OAAO,QAAQ,CAAY,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAChF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { PriceQuote, PriceQuoteRequest } from '../types.js';
2
+ export declare function usePrice(propertyId: number | null | undefined, params: PriceQuoteRequest | null): import("./useAsync.js").AsyncState<PriceQuote> & {
3
+ refresh: () => void;
4
+ };
5
+ //# sourceMappingURL=usePrice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePrice.d.ts","sourceRoot":"","sources":["../../src/react/usePrice.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEjE,wBAAgB,QAAQ,CACtB,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACrC,MAAM,EAAE,iBAAiB,GAAG,IAAI;;EAWjC"}
@@ -0,0 +1,11 @@
1
+ import { useStayCore } from './provider.js';
2
+ import { useAsync } from './useAsync.js';
3
+ export function usePrice(propertyId, params) {
4
+ const client = useStayCore();
5
+ const enabled = propertyId != null && params != null && params.check_in && params.check_out;
6
+ const key = enabled
7
+ ? `price:${client.orgSlug}:${propertyId}:${params.check_in}:${params.check_out}:${params.guests_count ?? ''}:${params.coupon_code ?? ''}`
8
+ : null;
9
+ return useAsync(() => client.price.compute(propertyId, params), key);
10
+ }
11
+ //# sourceMappingURL=usePrice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePrice.js","sourceRoot":"","sources":["../../src/react/usePrice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,MAAM,UAAU,QAAQ,CACtB,UAAqC,EACrC,MAAgC;IAEhC,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,UAAU,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC;IAC5F,MAAM,GAAG,GAAG,OAAO;QACjB,CAAC,CAAC,SAAS,MAAM,CAAC,OAAO,IAAI,UAAU,IAAI,MAAO,CAAC,QAAQ,IAAI,MAAO,CAAC,SAAS,IAAI,MAAO,CAAC,YAAY,IAAI,EAAE,IAAI,MAAO,CAAC,WAAW,IAAI,EAAE,EAAE;QAC7I,CAAC,CAAC,IAAI,CAAC;IACT,OAAO,QAAQ,CACb,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,UAAoB,EAAE,MAA2B,CAAC,EAC7E,GAAG,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Property } from '../types.js';
2
+ export declare function useProperties(): import("./useAsync.js").AsyncState<Property[]> & {
3
+ refresh: () => void;
4
+ };
5
+ //# sourceMappingURL=useProperties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useProperties.d.ts","sourceRoot":"","sources":["../../src/react/useProperties.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAgB,aAAa;;EAG5B"}
@@ -0,0 +1,7 @@
1
+ import { useStayCore } from './provider.js';
2
+ import { useAsync } from './useAsync.js';
3
+ export function useProperties() {
4
+ const client = useStayCore();
5
+ return useAsync(() => client.properties.list(), `properties:${client.orgSlug}`);
6
+ }
7
+ //# sourceMappingURL=useProperties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useProperties.js","sourceRoot":"","sources":["../../src/react/useProperties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,MAAM,UAAU,aAAa;IAC3B,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,OAAO,QAAQ,CAAa,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,cAAc,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAC9F,CAAC"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Types for the Stay'Core public booking engine API v1.
3
+ *
4
+ * Source of truth: backend/app/Http/Controllers/Api/BookingEngineController.php
5
+ * Contract guard: backend/tests/Feature/Api/V1/BookingContractTest.php
6
+ *
7
+ * Every response from /api/v1/book/{slug}/* follows the envelope:
8
+ * { success: true, data: T, message?: string }
9
+ * { success: false, message: string }
10
+ */
11
+ export type ApiSuccess<T> = {
12
+ success: true;
13
+ data: T;
14
+ message?: string;
15
+ };
16
+ export type ApiFailure = {
17
+ success: false;
18
+ message: string;
19
+ };
20
+ export type ApiResponse<T> = ApiSuccess<T> | ApiFailure;
21
+ export type OrgConfig = {
22
+ organization: {
23
+ name: string;
24
+ slug: string;
25
+ logo: string | null;
26
+ };
27
+ config: {
28
+ payment_mode: 'full' | 'deposit' | 'request';
29
+ default_locale: 'fr' | 'en';
30
+ branding: Record<string, unknown> | null;
31
+ terms_url: string | null;
32
+ min_stay_nights: number | null;
33
+ max_stay_nights: number | null;
34
+ };
35
+ stripe_public_key: string | null;
36
+ };
37
+ export type Property = {
38
+ id: number;
39
+ name: string;
40
+ description?: string | null;
41
+ city?: string | null;
42
+ country?: string | null;
43
+ address?: string | null;
44
+ image_url?: string | null;
45
+ max_guests?: number | null;
46
+ bedrooms?: number | null;
47
+ bathrooms?: number | null;
48
+ amenities?: string[];
49
+ /** Extra fields injected by the org config (branding overrides etc.). */
50
+ [key: string]: unknown;
51
+ };
52
+ export type AvailabilityCalendarDay = {
53
+ date: string;
54
+ available: boolean;
55
+ /** Reason if unavailable: 'booked' | 'blocked' | 'min_stay' | 'past' | … */
56
+ reason?: string;
57
+ price?: number;
58
+ };
59
+ export type AvailabilityCalendar = {
60
+ property_id: number;
61
+ days: AvailabilityCalendarDay[];
62
+ /** Months range covered by the calendar (YYYY-MM). */
63
+ start_month?: string;
64
+ end_month?: string;
65
+ };
66
+ export type PriceQuoteRequest = {
67
+ check_in: string;
68
+ check_out: string;
69
+ guests_count?: number;
70
+ coupon_code?: string;
71
+ };
72
+ export type PriceQuote = {
73
+ nights: number;
74
+ subtotal: number;
75
+ total: number;
76
+ nightly_average: number;
77
+ cleaning_fee?: number;
78
+ service_fee?: number;
79
+ tourism_tax?: number;
80
+ discount?: number;
81
+ coupon?: {
82
+ code: string;
83
+ discount_amount: number;
84
+ type: 'percent' | 'fixed';
85
+ } | null;
86
+ coupon_error?: string;
87
+ currency?: string;
88
+ [key: string]: unknown;
89
+ };
90
+ export type CheckoutRequest = {
91
+ property_id: number;
92
+ guest_name: string;
93
+ guest_email: string;
94
+ guest_phone?: string;
95
+ check_in: string;
96
+ check_out: string;
97
+ guests_count: number;
98
+ message?: string;
99
+ locale?: 'fr' | 'en';
100
+ coupon_code?: string;
101
+ };
102
+ export type CheckoutResponse = {
103
+ booking_token: string;
104
+ payment_mode: 'full' | 'deposit' | 'request';
105
+ total_amount: number;
106
+ deposit_amount?: number;
107
+ remaining_amount?: number;
108
+ charge_amount?: number;
109
+ client_secret?: string;
110
+ stripe_public_key?: string | null;
111
+ currency?: string;
112
+ };
113
+ export type CouponValidationRequest = {
114
+ code: string;
115
+ property_id?: number;
116
+ check_in?: string;
117
+ check_out?: string;
118
+ guests_count?: number;
119
+ };
120
+ export type CouponValidationResult = {
121
+ valid: boolean;
122
+ reason?: string;
123
+ coupon?: {
124
+ code: string;
125
+ type: 'percent' | 'fixed';
126
+ value: number;
127
+ } | null;
128
+ };
129
+ export type BookingStatus = {
130
+ token: string;
131
+ status: 'pending' | 'confirmed' | 'cancelled' | 'declined' | string;
132
+ payment_status: 'pending' | 'paid' | 'partial' | 'failed' | null;
133
+ payment_mode: 'full' | 'deposit' | 'request';
134
+ guest_name: string;
135
+ guest_email: string;
136
+ check_in: string;
137
+ check_out: string;
138
+ guests_count: number;
139
+ total_amount: number;
140
+ deposit_amount?: number;
141
+ remaining_amount?: number;
142
+ currency?: string;
143
+ property?: Pick<Property, 'id' | 'name' | 'image_url' | 'city' | 'country' | 'address'>;
144
+ paid_at?: string | null;
145
+ created_at?: string;
146
+ };
147
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAC1B,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,C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QAC1B,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,IAAI,CAAC;CACV,CAAC;AAOF,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;IACpE,cAAc,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,IAAI,CAAC;IACjE,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC;IACxF,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Types for the Stay'Core public booking engine API v1.
3
+ *
4
+ * Source of truth: backend/app/Http/Controllers/Api/BookingEngineController.php
5
+ * Contract guard: backend/tests/Feature/Api/V1/BookingContractTest.php
6
+ *
7
+ * Every response from /api/v1/book/{slug}/* follows the envelope:
8
+ * { success: true, data: T, message?: string }
9
+ * { success: false, message: string }
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@staycore/booking-sdk",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for the Stay'Core PMS public booking engine API (v1)",
5
+ "license": "MIT",
6
+ "author": "Keenqo <david@keenqo.fr>",
7
+ "homepage": "https://github.com/Keenqo-Dev-Team/staycore-booking-toolkit/tree/main/packages/sdk",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/Keenqo-Dev-Team/staycore-booking-toolkit.git",
11
+ "directory": "packages/sdk"
12
+ },
13
+ "type": "module",
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js"
20
+ },
21
+ "./react": {
22
+ "types": "./dist/react/index.d.ts",
23
+ "import": "./dist/react/index.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "README.md"
29
+ ],
30
+ "scripts": {
31
+ "build": "tsc -p tsconfig.json",
32
+ "dev": "tsc -p tsconfig.json --watch",
33
+ "lint": "echo \"(lint placeholder)\"",
34
+ "typecheck": "tsc -p tsconfig.json --noEmit",
35
+ "test": "vitest run",
36
+ "test:watch": "vitest",
37
+ "clean": "rm -rf dist"
38
+ },
39
+ "peerDependencies": {
40
+ "react": ">=18"
41
+ },
42
+ "peerDependenciesMeta": {
43
+ "react": {
44
+ "optional": true
45
+ }
46
+ },
47
+ "devDependencies": {
48
+ "@types/react": "^18.3.5",
49
+ "react": "^18.3.1",
50
+ "typescript": "^5.7.2",
51
+ "vitest": "^3.0.5"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "keywords": [
57
+ "staycore",
58
+ "booking",
59
+ "pms",
60
+ "react",
61
+ "sdk",
62
+ "vacation-rental"
63
+ ]
64
+ }