@travories/frontend-sdk 0.1.1 → 0.1.3
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/index.d.mts +199 -10
- package/dist/index.d.ts +199 -10
- package/dist/index.js +465 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +461 -45
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -183,6 +183,56 @@ interface HomeSectionsResponse {
|
|
|
183
183
|
trending: HomePackageCard[];
|
|
184
184
|
moreToExplore: HomePackageCard[];
|
|
185
185
|
}
|
|
186
|
+
interface AgencyHostDetails {
|
|
187
|
+
id: string;
|
|
188
|
+
username: string;
|
|
189
|
+
agencyName: string;
|
|
190
|
+
agencyCreatedDate: string;
|
|
191
|
+
rating: number;
|
|
192
|
+
review: number;
|
|
193
|
+
description: string;
|
|
194
|
+
logo: TravoriesImage | null;
|
|
195
|
+
slug: string;
|
|
196
|
+
}
|
|
197
|
+
interface AgencyHostResponse {
|
|
198
|
+
success: boolean;
|
|
199
|
+
message: string;
|
|
200
|
+
hostDetails: AgencyHostDetails;
|
|
201
|
+
}
|
|
202
|
+
interface AgencyAssociationItem {
|
|
203
|
+
id: string;
|
|
204
|
+
name: string;
|
|
205
|
+
url: string;
|
|
206
|
+
image: TravoriesImage | null;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The bundle `client.agencies.getBundle()` returns — drives `<AgencyDetailView />`.
|
|
210
|
+
* `packages` are this agency's tour packages (`HomePackageCard` shape so the
|
|
211
|
+
* landing carousel components can render them directly).
|
|
212
|
+
*/
|
|
213
|
+
interface AgencyBundle {
|
|
214
|
+
agency: AgencyHostDetails;
|
|
215
|
+
associations: AgencyAssociationItem[];
|
|
216
|
+
packages: HomePackageCard[];
|
|
217
|
+
}
|
|
218
|
+
/** One row in the booking's traveler breakdown. `name` is the category label. */
|
|
219
|
+
interface BookingTraveler {
|
|
220
|
+
/** "Adult" | "Senior Citizen" | "Children" | "Infant" */
|
|
221
|
+
name: string;
|
|
222
|
+
count: number;
|
|
223
|
+
}
|
|
224
|
+
interface BookingInitiateRequest {
|
|
225
|
+
/** Package slug (NOT the package UUID — the BE looks it up by slug). */
|
|
226
|
+
packageId: string;
|
|
227
|
+
/** ISO date string, e.g. "2027-08-15". */
|
|
228
|
+
arrivalDate: string;
|
|
229
|
+
travelers: BookingTraveler[];
|
|
230
|
+
}
|
|
231
|
+
interface BookingInitiateResponse {
|
|
232
|
+
message: string;
|
|
233
|
+
/** Booking UUID. Used to build the payment URL: `/package/<data>/payment`. */
|
|
234
|
+
data: string;
|
|
235
|
+
}
|
|
186
236
|
|
|
187
237
|
declare class PackagesResource {
|
|
188
238
|
private http;
|
|
@@ -211,10 +261,54 @@ declare class PackagesResource {
|
|
|
211
261
|
getBundle(slug: string, options?: HttpRequestOptions): Promise<PackageBundle | null>;
|
|
212
262
|
}
|
|
213
263
|
|
|
264
|
+
/** All agency-scoped endpoints live here so the resource stays focused. */
|
|
265
|
+
declare class AgenciesResource {
|
|
266
|
+
private http;
|
|
267
|
+
constructor(http: HttpClient);
|
|
268
|
+
/** Public profile of an agency by its slug. Null on 404. */
|
|
269
|
+
getBySlug(slug: string, options?: HttpRequestOptions): Promise<AgencyHostResponse | null>;
|
|
270
|
+
/** Partner / association badges shown on the agency profile. */
|
|
271
|
+
getAssociations(slug: string, options?: HttpRequestOptions): Promise<AgencyAssociationItem[]>;
|
|
272
|
+
/**
|
|
273
|
+
* Packages published by this agency. Returns the same card shape as the home
|
|
274
|
+
* sections so `<PackagesCarousel>` / `<PackageCard>` render them directly.
|
|
275
|
+
*/
|
|
276
|
+
getPackages(slug: string, params?: {
|
|
277
|
+
limit?: number;
|
|
278
|
+
page?: number;
|
|
279
|
+
}, options?: HttpRequestOptions): Promise<HomePackageCard[]>;
|
|
280
|
+
/**
|
|
281
|
+
* Convenience: fetch the full agency bundle (profile + associations + their
|
|
282
|
+
* packages) in parallel. Drives `<AgencyDetailView />`.
|
|
283
|
+
*/
|
|
284
|
+
getBundle(slug: string, params?: {
|
|
285
|
+
packagesLimit?: number;
|
|
286
|
+
}, options?: HttpRequestOptions): Promise<AgencyBundle | null>;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Booking-related endpoints. Currently exposes the kickoff step (`initiate`);
|
|
291
|
+
* the rest of the flow (payment, confirmation) lives on travories.com today.
|
|
292
|
+
*/
|
|
293
|
+
declare class BookingsResource {
|
|
294
|
+
private http;
|
|
295
|
+
constructor(http: HttpClient);
|
|
296
|
+
/**
|
|
297
|
+
* Open a booking. The BE returns a booking UUID — combine it with
|
|
298
|
+
* `https://travories.com/package/<id>/payment`
|
|
299
|
+
* to send the user into the existing payment flow.
|
|
300
|
+
*
|
|
301
|
+
* Throws (not silent) so the consumer can surface errors to the user. Wrap
|
|
302
|
+
* in try/catch in your `onReserve` handler.
|
|
303
|
+
*/
|
|
304
|
+
initiate(payload: BookingInitiateRequest, options?: HttpRequestOptions): Promise<BookingInitiateResponse>;
|
|
305
|
+
}
|
|
306
|
+
|
|
214
307
|
interface TravoriesClientConfig extends HttpClientConfig {
|
|
215
308
|
}
|
|
216
309
|
/**
|
|
217
|
-
* Main entry point for the Travories SDK.
|
|
310
|
+
* Main entry point for the Travories SDK. Holds the HTTP client and exposes
|
|
311
|
+
* resource modules grouped by domain (packages, agencies).
|
|
218
312
|
*
|
|
219
313
|
* @example
|
|
220
314
|
* ```ts
|
|
@@ -222,17 +316,20 @@ interface TravoriesClientConfig extends HttpClientConfig {
|
|
|
222
316
|
* baseUrl: "https://api.travories.com",
|
|
223
317
|
* });
|
|
224
318
|
*
|
|
225
|
-
* const pkg
|
|
319
|
+
* const pkg = await travories.packages.getBySlug("everest-base-camp");
|
|
320
|
+
* const agency = await travories.agencies.getBySlug("travel-route-pvt-ltd");
|
|
226
321
|
* ```
|
|
227
322
|
*/
|
|
228
323
|
declare class TravoriesClient {
|
|
229
324
|
private http;
|
|
230
325
|
packages: PackagesResource;
|
|
326
|
+
agencies: AgenciesResource;
|
|
327
|
+
bookings: BookingsResource;
|
|
231
328
|
constructor(config: TravoriesClientConfig);
|
|
232
|
-
/** Shortcut for `client.packages.getBySlug(slug)`. */
|
|
233
329
|
getPackageBySlug: (slug: string) => Promise<TravoriesPackage | null>;
|
|
234
|
-
/** Shortcut for `client.packages.getBundle(slug)` — package + host + attractions in one call. */
|
|
235
330
|
getPackageBundle: (slug: string) => Promise<PackageBundle | null>;
|
|
331
|
+
getAgencyBySlug: (slug: string) => Promise<AgencyHostResponse | null>;
|
|
332
|
+
getAgencyBundle: (slug: string) => Promise<AgencyBundle | null>;
|
|
236
333
|
}
|
|
237
334
|
/** Factory form, in case you prefer a function over `new`. */
|
|
238
335
|
declare function createTravoriesClient(config: TravoriesClientConfig): TravoriesClient;
|
|
@@ -276,6 +373,19 @@ interface UseHomeSectionsResult {
|
|
|
276
373
|
*/
|
|
277
374
|
declare function useHomeSections(client: TravoriesClient | null): UseHomeSectionsResult;
|
|
278
375
|
|
|
376
|
+
interface UseAgencyBundleResult {
|
|
377
|
+
data: AgencyBundle | null;
|
|
378
|
+
loading: boolean;
|
|
379
|
+
error: Error | null;
|
|
380
|
+
refetch: () => void;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Fetches an agency profile + associations + their packages in one call.
|
|
384
|
+
* Re-runs when `slug` or `client` changes. Pass `null` slug or client to skip
|
|
385
|
+
* the fetch (useful when consumer already has data via `initialBundle`).
|
|
386
|
+
*/
|
|
387
|
+
declare function useAgencyBundle(client: TravoriesClient | null, slug: string | null | undefined): UseAgencyBundleResult;
|
|
388
|
+
|
|
279
389
|
interface HomeSectionsProps {
|
|
280
390
|
/** Required when `initialSections` is not provided. */
|
|
281
391
|
client?: TravoriesClient;
|
|
@@ -391,7 +501,9 @@ interface PackageCardProps {
|
|
|
391
501
|
* in a new tab. Requires `href`. `onSelect` is NOT called on a normal click
|
|
392
502
|
* in this mode — the browser handles navigation. */
|
|
393
503
|
openInNewTab?: boolean;
|
|
394
|
-
/** When true, show the heart (wishlist) icon. Default
|
|
504
|
+
/** When true, show the heart (wishlist) icon. Default `false` — wishlist
|
|
505
|
+
* state is user-specific and requires the consumer to wire auth + storage.
|
|
506
|
+
* Pass `liked` + `onLike` together to opt in. */
|
|
395
507
|
showHeart?: boolean;
|
|
396
508
|
/** Initial wishlist state. */
|
|
397
509
|
liked?: boolean;
|
|
@@ -420,6 +532,13 @@ interface PackageDetailViewProps {
|
|
|
420
532
|
currency?: string;
|
|
421
533
|
/** Called when the user hits Reserve. If omitted, the button shows a disabled state. */
|
|
422
534
|
onReserve?: (pkg: TravoriesPackage) => void;
|
|
535
|
+
/** Called when the user clicks the host card. Receives the host. */
|
|
536
|
+
onSelectHost?: (host: PackageHost) => void;
|
|
537
|
+
/** When set, host card renders as `<a href={agencyHrefFor(host)}>` — enables
|
|
538
|
+
* cmd/ctrl-click → open in new tab natively. */
|
|
539
|
+
agencyHrefFor?: (host: PackageHost) => string;
|
|
540
|
+
/** Open host link in a new tab (requires `agencyHrefFor`). */
|
|
541
|
+
openAgencyInNewTab?: boolean;
|
|
423
542
|
/** Optional extra class on the root wrapper. */
|
|
424
543
|
className?: string;
|
|
425
544
|
/** Loading state override. */
|
|
@@ -427,7 +546,7 @@ interface PackageDetailViewProps {
|
|
|
427
546
|
/** Not-found state override. */
|
|
428
547
|
renderNotFound?: () => React.ReactNode;
|
|
429
548
|
}
|
|
430
|
-
declare function PackageDetailView({ client, slug, initialBundle, currency, onReserve, className, renderLoading, renderNotFound, }: PackageDetailViewProps): react_jsx_runtime.JSX.Element;
|
|
549
|
+
declare function PackageDetailView({ client, slug, initialBundle, currency, onReserve, onSelectHost, agencyHrefFor, openAgencyInNewTab, className, renderLoading, renderNotFound, }: PackageDetailViewProps): react_jsx_runtime.JSX.Element;
|
|
431
550
|
|
|
432
551
|
/**
|
|
433
552
|
* Legacy view-model types — identical shape to frontend's `types/package.ts`.
|
|
@@ -578,8 +697,28 @@ interface PackageExcludedAndToPackProps {
|
|
|
578
697
|
}
|
|
579
698
|
declare const PackageExcludedAndToPack: React.FC<PackageExcludedAndToPackProps>;
|
|
580
699
|
|
|
700
|
+
/**
|
|
701
|
+
* Common shape both `PackageHost` (returned by the package detail endpoint)
|
|
702
|
+
* and `AgencyHostDetails` (returned by the agency profile endpoint) satisfy.
|
|
703
|
+
* `agencyName` is optional — when present it's preferred over `username`.
|
|
704
|
+
*/
|
|
705
|
+
interface HostCardData {
|
|
706
|
+
username: string;
|
|
707
|
+
agencyName?: string;
|
|
708
|
+
agencyCreatedDate: string;
|
|
709
|
+
rating: number;
|
|
710
|
+
review: number;
|
|
711
|
+
logo: TravoriesImage | null;
|
|
712
|
+
slug: string;
|
|
713
|
+
}
|
|
581
714
|
interface HostCardProps {
|
|
582
|
-
hostData: PackageHost;
|
|
715
|
+
hostData: HostCardData | PackageHost | AgencyHostDetails;
|
|
716
|
+
/** Called when the user clicks the card. Receives the host slug. */
|
|
717
|
+
onAgencyClick?: (slug: string) => void;
|
|
718
|
+
/** When set, the card wraps in `<a href>` so cmd/ctrl-click opens in a new tab. */
|
|
719
|
+
href?: string;
|
|
720
|
+
/** When true (with `href`), the anchor gets `target="_blank"`. */
|
|
721
|
+
openInNewTab?: boolean;
|
|
583
722
|
className?: string;
|
|
584
723
|
}
|
|
585
724
|
declare const HostCard: React.FC<HostCardProps>;
|
|
@@ -605,14 +744,15 @@ interface BookingCardLiteProps {
|
|
|
605
744
|
DescriptionData: DescriptionData;
|
|
606
745
|
currency?: string;
|
|
607
746
|
/** Called when user clicks Book/Reserve. Receives the picked values so the
|
|
608
|
-
* consumer can wire their own booking flow.
|
|
747
|
+
* consumer can wire their own booking flow. Return a `Promise` to make the
|
|
748
|
+
* button show an "Initiating…" state until it resolves. */
|
|
609
749
|
onReserve?: (payload: {
|
|
610
750
|
arrival: string;
|
|
611
751
|
departure: string;
|
|
612
752
|
travelers: TravelerOption[];
|
|
613
753
|
totalCost: number;
|
|
614
754
|
pricePerPerson: number;
|
|
615
|
-
}) => void
|
|
755
|
+
}) => void | Promise<void>;
|
|
616
756
|
}
|
|
617
757
|
/**
|
|
618
758
|
* High-fidelity port of frontend `BookingForm.tsx` — visual only.
|
|
@@ -625,9 +765,58 @@ declare const buildGalleryMedia: (pkg: TravoriesPackage) => MediaItem[];
|
|
|
625
765
|
declare const buildTopData: (pkg: TravoriesPackage, host: PackageHost | null) => TopData;
|
|
626
766
|
declare const buildDescriptionData: (pkg: TravoriesPackage) => DescriptionData;
|
|
627
767
|
|
|
768
|
+
interface AgencyDetailViewProps {
|
|
769
|
+
/** Required when `initialBundle` is not provided. */
|
|
770
|
+
client?: TravoriesClient;
|
|
771
|
+
/** Agency slug to fetch. */
|
|
772
|
+
slug?: string;
|
|
773
|
+
/** Pre-fetched bundle (SSR pattern). When set, no client-side fetch runs. */
|
|
774
|
+
initialBundle?: AgencyBundle | null;
|
|
775
|
+
/** Currency code for package cards (default "USD"). */
|
|
776
|
+
currency?: string;
|
|
777
|
+
/** Called when the user clicks a package card. */
|
|
778
|
+
onSelectPackage?: (pkg: HomePackageCard) => void;
|
|
779
|
+
/** When set, package cards render as `<a href>` instead of buttons. */
|
|
780
|
+
packageHrefFor?: (pkg: HomePackageCard) => string;
|
|
781
|
+
/** Open package cards in a new tab. Requires `packageHrefFor`. */
|
|
782
|
+
openPackagesInNewTab?: boolean;
|
|
783
|
+
/** Optional class on the root scope wrapper. */
|
|
784
|
+
className?: string;
|
|
785
|
+
/** Render override for the loading state. */
|
|
786
|
+
renderLoading?: () => React.ReactNode;
|
|
787
|
+
/** Render override for the not-found state. */
|
|
788
|
+
renderNotFound?: () => React.ReactNode;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Public agency profile page — drop-in equivalent to `<PackageDetailView />`
|
|
792
|
+
* for the agency route. Pass `client` + `slug` to let the SDK fetch, or
|
|
793
|
+
* `initialBundle` to use server-fetched data (no client-side fetch).
|
|
794
|
+
*
|
|
795
|
+
* Sections rendered (top → bottom):
|
|
796
|
+
* 1. Breadcrumb + title
|
|
797
|
+
* 2. HostCard (left) | Overview block (right)
|
|
798
|
+
* 3. Agency associations / partner badges (if any)
|
|
799
|
+
* 4. Popular packages carousel
|
|
800
|
+
*
|
|
801
|
+
* Reviews / ratings are intentionally not included in this view — they require
|
|
802
|
+
* user-data plumbing that's out of scope for a static SDK component.
|
|
803
|
+
*/
|
|
804
|
+
declare function AgencyDetailView({ client, slug, initialBundle, currency, onSelectPackage, packageHrefFor, openPackagesInNewTab, className, renderLoading, renderNotFound, }: AgencyDetailViewProps): react_jsx_runtime.JSX.Element;
|
|
805
|
+
|
|
806
|
+
interface AgencyAssociationsProps {
|
|
807
|
+
associations: AgencyAssociationItem[];
|
|
808
|
+
title?: string;
|
|
809
|
+
className?: string;
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Partner / affiliation badge strip for an agency. Each badge is a link to the
|
|
813
|
+
* partner site (opens in a new tab). Renders nothing if `associations` is empty.
|
|
814
|
+
*/
|
|
815
|
+
declare const AgencyAssociations: React.FC<AgencyAssociationsProps>;
|
|
816
|
+
|
|
628
817
|
declare function pickImageUrl(img: TravoriesImage | null | undefined): string;
|
|
629
818
|
declare function startingPrice(prices: PackagePriceTier[] | undefined): number;
|
|
630
819
|
declare function formatCurrency(amount: number, currency?: string): string;
|
|
631
820
|
declare function formatRating(rating: number | undefined): string;
|
|
632
821
|
|
|
633
|
-
export { BookingCardLite, type DescriptionData, DescriptionSection, GallerySection, type HomePackageCard, type HomeSectionKey, HomeSections, type HomeSectionsContextValue, type HomeSectionsProps, HomeSectionsProvider, type HomeSectionsProviderProps, type HomeSectionsResponse, HostAbout, HostCard, type HttpClientConfig, type HttpRequestOptions, Itinerary, type MajorAttractionItem, type MajorAttractionsResponse, type MediaItem, type PackageBundle, PackageCard, type PackageDay, type PackageDayLocation, PackageDetailView, type PackageDetailViewProps, type PackageDiscount, PackageExcludedAndToPack, type PackageHost, type PackageHostResponse, PackageIncluded, PackageMap, PackageOverview, type PackagePriceTier, type PackageRoute, type PackageRouteGeometry, type PackageRoutesDay, type PackageRoutesResponse, PackagesCarousel, PackagesResource, PackagesSection, type PackagesSectionProps, type ThingItem, type TopData, TopSection, TravoriesApiError, TravoriesClient, type TravoriesClientConfig, type TravoriesImage, type TravoriesImageUrls, type TravoriesPackage, type UseHomeSectionsResult, type UsePackageBundleResult, type UsePackageBySlugResult, buildDescriptionData, buildGalleryMedia, buildTopData, createTravoriesClient, formatCurrency, formatRating, pickImageUrl, startingPrice, useHomeSections, useHomeSectionsContext, usePackageBundle, usePackageBySlug };
|
|
822
|
+
export { AgenciesResource, type AgencyAssociationItem, AgencyAssociations, type AgencyBundle, AgencyDetailView, type AgencyDetailViewProps, type AgencyHostDetails, type AgencyHostResponse, BookingCardLite, type BookingInitiateRequest, type BookingInitiateResponse, type BookingTraveler, BookingsResource, type DescriptionData, DescriptionSection, GallerySection, type HomePackageCard, type HomeSectionKey, HomeSections, type HomeSectionsContextValue, type HomeSectionsProps, HomeSectionsProvider, type HomeSectionsProviderProps, type HomeSectionsResponse, HostAbout, HostCard, type HttpClientConfig, type HttpRequestOptions, Itinerary, type MajorAttractionItem, type MajorAttractionsResponse, type MediaItem, type PackageBundle, PackageCard, type PackageDay, type PackageDayLocation, PackageDetailView, type PackageDetailViewProps, type PackageDiscount, PackageExcludedAndToPack, type PackageHost, type PackageHostResponse, PackageIncluded, PackageMap, PackageOverview, type PackagePriceTier, type PackageRoute, type PackageRouteGeometry, type PackageRoutesDay, type PackageRoutesResponse, PackagesCarousel, PackagesResource, PackagesSection, type PackagesSectionProps, type ThingItem, type TopData, TopSection, TravoriesApiError, TravoriesClient, type TravoriesClientConfig, type TravoriesImage, type TravoriesImageUrls, type TravoriesPackage, type UseAgencyBundleResult, type UseHomeSectionsResult, type UsePackageBundleResult, type UsePackageBySlugResult, buildDescriptionData, buildGalleryMedia, buildTopData, createTravoriesClient, formatCurrency, formatRating, pickImageUrl, startingPrice, useAgencyBundle, useHomeSections, useHomeSectionsContext, usePackageBundle, usePackageBySlug };
|
package/dist/index.d.ts
CHANGED
|
@@ -183,6 +183,56 @@ interface HomeSectionsResponse {
|
|
|
183
183
|
trending: HomePackageCard[];
|
|
184
184
|
moreToExplore: HomePackageCard[];
|
|
185
185
|
}
|
|
186
|
+
interface AgencyHostDetails {
|
|
187
|
+
id: string;
|
|
188
|
+
username: string;
|
|
189
|
+
agencyName: string;
|
|
190
|
+
agencyCreatedDate: string;
|
|
191
|
+
rating: number;
|
|
192
|
+
review: number;
|
|
193
|
+
description: string;
|
|
194
|
+
logo: TravoriesImage | null;
|
|
195
|
+
slug: string;
|
|
196
|
+
}
|
|
197
|
+
interface AgencyHostResponse {
|
|
198
|
+
success: boolean;
|
|
199
|
+
message: string;
|
|
200
|
+
hostDetails: AgencyHostDetails;
|
|
201
|
+
}
|
|
202
|
+
interface AgencyAssociationItem {
|
|
203
|
+
id: string;
|
|
204
|
+
name: string;
|
|
205
|
+
url: string;
|
|
206
|
+
image: TravoriesImage | null;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The bundle `client.agencies.getBundle()` returns — drives `<AgencyDetailView />`.
|
|
210
|
+
* `packages` are this agency's tour packages (`HomePackageCard` shape so the
|
|
211
|
+
* landing carousel components can render them directly).
|
|
212
|
+
*/
|
|
213
|
+
interface AgencyBundle {
|
|
214
|
+
agency: AgencyHostDetails;
|
|
215
|
+
associations: AgencyAssociationItem[];
|
|
216
|
+
packages: HomePackageCard[];
|
|
217
|
+
}
|
|
218
|
+
/** One row in the booking's traveler breakdown. `name` is the category label. */
|
|
219
|
+
interface BookingTraveler {
|
|
220
|
+
/** "Adult" | "Senior Citizen" | "Children" | "Infant" */
|
|
221
|
+
name: string;
|
|
222
|
+
count: number;
|
|
223
|
+
}
|
|
224
|
+
interface BookingInitiateRequest {
|
|
225
|
+
/** Package slug (NOT the package UUID — the BE looks it up by slug). */
|
|
226
|
+
packageId: string;
|
|
227
|
+
/** ISO date string, e.g. "2027-08-15". */
|
|
228
|
+
arrivalDate: string;
|
|
229
|
+
travelers: BookingTraveler[];
|
|
230
|
+
}
|
|
231
|
+
interface BookingInitiateResponse {
|
|
232
|
+
message: string;
|
|
233
|
+
/** Booking UUID. Used to build the payment URL: `/package/<data>/payment`. */
|
|
234
|
+
data: string;
|
|
235
|
+
}
|
|
186
236
|
|
|
187
237
|
declare class PackagesResource {
|
|
188
238
|
private http;
|
|
@@ -211,10 +261,54 @@ declare class PackagesResource {
|
|
|
211
261
|
getBundle(slug: string, options?: HttpRequestOptions): Promise<PackageBundle | null>;
|
|
212
262
|
}
|
|
213
263
|
|
|
264
|
+
/** All agency-scoped endpoints live here so the resource stays focused. */
|
|
265
|
+
declare class AgenciesResource {
|
|
266
|
+
private http;
|
|
267
|
+
constructor(http: HttpClient);
|
|
268
|
+
/** Public profile of an agency by its slug. Null on 404. */
|
|
269
|
+
getBySlug(slug: string, options?: HttpRequestOptions): Promise<AgencyHostResponse | null>;
|
|
270
|
+
/** Partner / association badges shown on the agency profile. */
|
|
271
|
+
getAssociations(slug: string, options?: HttpRequestOptions): Promise<AgencyAssociationItem[]>;
|
|
272
|
+
/**
|
|
273
|
+
* Packages published by this agency. Returns the same card shape as the home
|
|
274
|
+
* sections so `<PackagesCarousel>` / `<PackageCard>` render them directly.
|
|
275
|
+
*/
|
|
276
|
+
getPackages(slug: string, params?: {
|
|
277
|
+
limit?: number;
|
|
278
|
+
page?: number;
|
|
279
|
+
}, options?: HttpRequestOptions): Promise<HomePackageCard[]>;
|
|
280
|
+
/**
|
|
281
|
+
* Convenience: fetch the full agency bundle (profile + associations + their
|
|
282
|
+
* packages) in parallel. Drives `<AgencyDetailView />`.
|
|
283
|
+
*/
|
|
284
|
+
getBundle(slug: string, params?: {
|
|
285
|
+
packagesLimit?: number;
|
|
286
|
+
}, options?: HttpRequestOptions): Promise<AgencyBundle | null>;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Booking-related endpoints. Currently exposes the kickoff step (`initiate`);
|
|
291
|
+
* the rest of the flow (payment, confirmation) lives on travories.com today.
|
|
292
|
+
*/
|
|
293
|
+
declare class BookingsResource {
|
|
294
|
+
private http;
|
|
295
|
+
constructor(http: HttpClient);
|
|
296
|
+
/**
|
|
297
|
+
* Open a booking. The BE returns a booking UUID — combine it with
|
|
298
|
+
* `https://travories.com/package/<id>/payment`
|
|
299
|
+
* to send the user into the existing payment flow.
|
|
300
|
+
*
|
|
301
|
+
* Throws (not silent) so the consumer can surface errors to the user. Wrap
|
|
302
|
+
* in try/catch in your `onReserve` handler.
|
|
303
|
+
*/
|
|
304
|
+
initiate(payload: BookingInitiateRequest, options?: HttpRequestOptions): Promise<BookingInitiateResponse>;
|
|
305
|
+
}
|
|
306
|
+
|
|
214
307
|
interface TravoriesClientConfig extends HttpClientConfig {
|
|
215
308
|
}
|
|
216
309
|
/**
|
|
217
|
-
* Main entry point for the Travories SDK.
|
|
310
|
+
* Main entry point for the Travories SDK. Holds the HTTP client and exposes
|
|
311
|
+
* resource modules grouped by domain (packages, agencies).
|
|
218
312
|
*
|
|
219
313
|
* @example
|
|
220
314
|
* ```ts
|
|
@@ -222,17 +316,20 @@ interface TravoriesClientConfig extends HttpClientConfig {
|
|
|
222
316
|
* baseUrl: "https://api.travories.com",
|
|
223
317
|
* });
|
|
224
318
|
*
|
|
225
|
-
* const pkg
|
|
319
|
+
* const pkg = await travories.packages.getBySlug("everest-base-camp");
|
|
320
|
+
* const agency = await travories.agencies.getBySlug("travel-route-pvt-ltd");
|
|
226
321
|
* ```
|
|
227
322
|
*/
|
|
228
323
|
declare class TravoriesClient {
|
|
229
324
|
private http;
|
|
230
325
|
packages: PackagesResource;
|
|
326
|
+
agencies: AgenciesResource;
|
|
327
|
+
bookings: BookingsResource;
|
|
231
328
|
constructor(config: TravoriesClientConfig);
|
|
232
|
-
/** Shortcut for `client.packages.getBySlug(slug)`. */
|
|
233
329
|
getPackageBySlug: (slug: string) => Promise<TravoriesPackage | null>;
|
|
234
|
-
/** Shortcut for `client.packages.getBundle(slug)` — package + host + attractions in one call. */
|
|
235
330
|
getPackageBundle: (slug: string) => Promise<PackageBundle | null>;
|
|
331
|
+
getAgencyBySlug: (slug: string) => Promise<AgencyHostResponse | null>;
|
|
332
|
+
getAgencyBundle: (slug: string) => Promise<AgencyBundle | null>;
|
|
236
333
|
}
|
|
237
334
|
/** Factory form, in case you prefer a function over `new`. */
|
|
238
335
|
declare function createTravoriesClient(config: TravoriesClientConfig): TravoriesClient;
|
|
@@ -276,6 +373,19 @@ interface UseHomeSectionsResult {
|
|
|
276
373
|
*/
|
|
277
374
|
declare function useHomeSections(client: TravoriesClient | null): UseHomeSectionsResult;
|
|
278
375
|
|
|
376
|
+
interface UseAgencyBundleResult {
|
|
377
|
+
data: AgencyBundle | null;
|
|
378
|
+
loading: boolean;
|
|
379
|
+
error: Error | null;
|
|
380
|
+
refetch: () => void;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Fetches an agency profile + associations + their packages in one call.
|
|
384
|
+
* Re-runs when `slug` or `client` changes. Pass `null` slug or client to skip
|
|
385
|
+
* the fetch (useful when consumer already has data via `initialBundle`).
|
|
386
|
+
*/
|
|
387
|
+
declare function useAgencyBundle(client: TravoriesClient | null, slug: string | null | undefined): UseAgencyBundleResult;
|
|
388
|
+
|
|
279
389
|
interface HomeSectionsProps {
|
|
280
390
|
/** Required when `initialSections` is not provided. */
|
|
281
391
|
client?: TravoriesClient;
|
|
@@ -391,7 +501,9 @@ interface PackageCardProps {
|
|
|
391
501
|
* in a new tab. Requires `href`. `onSelect` is NOT called on a normal click
|
|
392
502
|
* in this mode — the browser handles navigation. */
|
|
393
503
|
openInNewTab?: boolean;
|
|
394
|
-
/** When true, show the heart (wishlist) icon. Default
|
|
504
|
+
/** When true, show the heart (wishlist) icon. Default `false` — wishlist
|
|
505
|
+
* state is user-specific and requires the consumer to wire auth + storage.
|
|
506
|
+
* Pass `liked` + `onLike` together to opt in. */
|
|
395
507
|
showHeart?: boolean;
|
|
396
508
|
/** Initial wishlist state. */
|
|
397
509
|
liked?: boolean;
|
|
@@ -420,6 +532,13 @@ interface PackageDetailViewProps {
|
|
|
420
532
|
currency?: string;
|
|
421
533
|
/** Called when the user hits Reserve. If omitted, the button shows a disabled state. */
|
|
422
534
|
onReserve?: (pkg: TravoriesPackage) => void;
|
|
535
|
+
/** Called when the user clicks the host card. Receives the host. */
|
|
536
|
+
onSelectHost?: (host: PackageHost) => void;
|
|
537
|
+
/** When set, host card renders as `<a href={agencyHrefFor(host)}>` — enables
|
|
538
|
+
* cmd/ctrl-click → open in new tab natively. */
|
|
539
|
+
agencyHrefFor?: (host: PackageHost) => string;
|
|
540
|
+
/** Open host link in a new tab (requires `agencyHrefFor`). */
|
|
541
|
+
openAgencyInNewTab?: boolean;
|
|
423
542
|
/** Optional extra class on the root wrapper. */
|
|
424
543
|
className?: string;
|
|
425
544
|
/** Loading state override. */
|
|
@@ -427,7 +546,7 @@ interface PackageDetailViewProps {
|
|
|
427
546
|
/** Not-found state override. */
|
|
428
547
|
renderNotFound?: () => React.ReactNode;
|
|
429
548
|
}
|
|
430
|
-
declare function PackageDetailView({ client, slug, initialBundle, currency, onReserve, className, renderLoading, renderNotFound, }: PackageDetailViewProps): react_jsx_runtime.JSX.Element;
|
|
549
|
+
declare function PackageDetailView({ client, slug, initialBundle, currency, onReserve, onSelectHost, agencyHrefFor, openAgencyInNewTab, className, renderLoading, renderNotFound, }: PackageDetailViewProps): react_jsx_runtime.JSX.Element;
|
|
431
550
|
|
|
432
551
|
/**
|
|
433
552
|
* Legacy view-model types — identical shape to frontend's `types/package.ts`.
|
|
@@ -578,8 +697,28 @@ interface PackageExcludedAndToPackProps {
|
|
|
578
697
|
}
|
|
579
698
|
declare const PackageExcludedAndToPack: React.FC<PackageExcludedAndToPackProps>;
|
|
580
699
|
|
|
700
|
+
/**
|
|
701
|
+
* Common shape both `PackageHost` (returned by the package detail endpoint)
|
|
702
|
+
* and `AgencyHostDetails` (returned by the agency profile endpoint) satisfy.
|
|
703
|
+
* `agencyName` is optional — when present it's preferred over `username`.
|
|
704
|
+
*/
|
|
705
|
+
interface HostCardData {
|
|
706
|
+
username: string;
|
|
707
|
+
agencyName?: string;
|
|
708
|
+
agencyCreatedDate: string;
|
|
709
|
+
rating: number;
|
|
710
|
+
review: number;
|
|
711
|
+
logo: TravoriesImage | null;
|
|
712
|
+
slug: string;
|
|
713
|
+
}
|
|
581
714
|
interface HostCardProps {
|
|
582
|
-
hostData: PackageHost;
|
|
715
|
+
hostData: HostCardData | PackageHost | AgencyHostDetails;
|
|
716
|
+
/** Called when the user clicks the card. Receives the host slug. */
|
|
717
|
+
onAgencyClick?: (slug: string) => void;
|
|
718
|
+
/** When set, the card wraps in `<a href>` so cmd/ctrl-click opens in a new tab. */
|
|
719
|
+
href?: string;
|
|
720
|
+
/** When true (with `href`), the anchor gets `target="_blank"`. */
|
|
721
|
+
openInNewTab?: boolean;
|
|
583
722
|
className?: string;
|
|
584
723
|
}
|
|
585
724
|
declare const HostCard: React.FC<HostCardProps>;
|
|
@@ -605,14 +744,15 @@ interface BookingCardLiteProps {
|
|
|
605
744
|
DescriptionData: DescriptionData;
|
|
606
745
|
currency?: string;
|
|
607
746
|
/** Called when user clicks Book/Reserve. Receives the picked values so the
|
|
608
|
-
* consumer can wire their own booking flow.
|
|
747
|
+
* consumer can wire their own booking flow. Return a `Promise` to make the
|
|
748
|
+
* button show an "Initiating…" state until it resolves. */
|
|
609
749
|
onReserve?: (payload: {
|
|
610
750
|
arrival: string;
|
|
611
751
|
departure: string;
|
|
612
752
|
travelers: TravelerOption[];
|
|
613
753
|
totalCost: number;
|
|
614
754
|
pricePerPerson: number;
|
|
615
|
-
}) => void
|
|
755
|
+
}) => void | Promise<void>;
|
|
616
756
|
}
|
|
617
757
|
/**
|
|
618
758
|
* High-fidelity port of frontend `BookingForm.tsx` — visual only.
|
|
@@ -625,9 +765,58 @@ declare const buildGalleryMedia: (pkg: TravoriesPackage) => MediaItem[];
|
|
|
625
765
|
declare const buildTopData: (pkg: TravoriesPackage, host: PackageHost | null) => TopData;
|
|
626
766
|
declare const buildDescriptionData: (pkg: TravoriesPackage) => DescriptionData;
|
|
627
767
|
|
|
768
|
+
interface AgencyDetailViewProps {
|
|
769
|
+
/** Required when `initialBundle` is not provided. */
|
|
770
|
+
client?: TravoriesClient;
|
|
771
|
+
/** Agency slug to fetch. */
|
|
772
|
+
slug?: string;
|
|
773
|
+
/** Pre-fetched bundle (SSR pattern). When set, no client-side fetch runs. */
|
|
774
|
+
initialBundle?: AgencyBundle | null;
|
|
775
|
+
/** Currency code for package cards (default "USD"). */
|
|
776
|
+
currency?: string;
|
|
777
|
+
/** Called when the user clicks a package card. */
|
|
778
|
+
onSelectPackage?: (pkg: HomePackageCard) => void;
|
|
779
|
+
/** When set, package cards render as `<a href>` instead of buttons. */
|
|
780
|
+
packageHrefFor?: (pkg: HomePackageCard) => string;
|
|
781
|
+
/** Open package cards in a new tab. Requires `packageHrefFor`. */
|
|
782
|
+
openPackagesInNewTab?: boolean;
|
|
783
|
+
/** Optional class on the root scope wrapper. */
|
|
784
|
+
className?: string;
|
|
785
|
+
/** Render override for the loading state. */
|
|
786
|
+
renderLoading?: () => React.ReactNode;
|
|
787
|
+
/** Render override for the not-found state. */
|
|
788
|
+
renderNotFound?: () => React.ReactNode;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Public agency profile page — drop-in equivalent to `<PackageDetailView />`
|
|
792
|
+
* for the agency route. Pass `client` + `slug` to let the SDK fetch, or
|
|
793
|
+
* `initialBundle` to use server-fetched data (no client-side fetch).
|
|
794
|
+
*
|
|
795
|
+
* Sections rendered (top → bottom):
|
|
796
|
+
* 1. Breadcrumb + title
|
|
797
|
+
* 2. HostCard (left) | Overview block (right)
|
|
798
|
+
* 3. Agency associations / partner badges (if any)
|
|
799
|
+
* 4. Popular packages carousel
|
|
800
|
+
*
|
|
801
|
+
* Reviews / ratings are intentionally not included in this view — they require
|
|
802
|
+
* user-data plumbing that's out of scope for a static SDK component.
|
|
803
|
+
*/
|
|
804
|
+
declare function AgencyDetailView({ client, slug, initialBundle, currency, onSelectPackage, packageHrefFor, openPackagesInNewTab, className, renderLoading, renderNotFound, }: AgencyDetailViewProps): react_jsx_runtime.JSX.Element;
|
|
805
|
+
|
|
806
|
+
interface AgencyAssociationsProps {
|
|
807
|
+
associations: AgencyAssociationItem[];
|
|
808
|
+
title?: string;
|
|
809
|
+
className?: string;
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Partner / affiliation badge strip for an agency. Each badge is a link to the
|
|
813
|
+
* partner site (opens in a new tab). Renders nothing if `associations` is empty.
|
|
814
|
+
*/
|
|
815
|
+
declare const AgencyAssociations: React.FC<AgencyAssociationsProps>;
|
|
816
|
+
|
|
628
817
|
declare function pickImageUrl(img: TravoriesImage | null | undefined): string;
|
|
629
818
|
declare function startingPrice(prices: PackagePriceTier[] | undefined): number;
|
|
630
819
|
declare function formatCurrency(amount: number, currency?: string): string;
|
|
631
820
|
declare function formatRating(rating: number | undefined): string;
|
|
632
821
|
|
|
633
|
-
export { BookingCardLite, type DescriptionData, DescriptionSection, GallerySection, type HomePackageCard, type HomeSectionKey, HomeSections, type HomeSectionsContextValue, type HomeSectionsProps, HomeSectionsProvider, type HomeSectionsProviderProps, type HomeSectionsResponse, HostAbout, HostCard, type HttpClientConfig, type HttpRequestOptions, Itinerary, type MajorAttractionItem, type MajorAttractionsResponse, type MediaItem, type PackageBundle, PackageCard, type PackageDay, type PackageDayLocation, PackageDetailView, type PackageDetailViewProps, type PackageDiscount, PackageExcludedAndToPack, type PackageHost, type PackageHostResponse, PackageIncluded, PackageMap, PackageOverview, type PackagePriceTier, type PackageRoute, type PackageRouteGeometry, type PackageRoutesDay, type PackageRoutesResponse, PackagesCarousel, PackagesResource, PackagesSection, type PackagesSectionProps, type ThingItem, type TopData, TopSection, TravoriesApiError, TravoriesClient, type TravoriesClientConfig, type TravoriesImage, type TravoriesImageUrls, type TravoriesPackage, type UseHomeSectionsResult, type UsePackageBundleResult, type UsePackageBySlugResult, buildDescriptionData, buildGalleryMedia, buildTopData, createTravoriesClient, formatCurrency, formatRating, pickImageUrl, startingPrice, useHomeSections, useHomeSectionsContext, usePackageBundle, usePackageBySlug };
|
|
822
|
+
export { AgenciesResource, type AgencyAssociationItem, AgencyAssociations, type AgencyBundle, AgencyDetailView, type AgencyDetailViewProps, type AgencyHostDetails, type AgencyHostResponse, BookingCardLite, type BookingInitiateRequest, type BookingInitiateResponse, type BookingTraveler, BookingsResource, type DescriptionData, DescriptionSection, GallerySection, type HomePackageCard, type HomeSectionKey, HomeSections, type HomeSectionsContextValue, type HomeSectionsProps, HomeSectionsProvider, type HomeSectionsProviderProps, type HomeSectionsResponse, HostAbout, HostCard, type HttpClientConfig, type HttpRequestOptions, Itinerary, type MajorAttractionItem, type MajorAttractionsResponse, type MediaItem, type PackageBundle, PackageCard, type PackageDay, type PackageDayLocation, PackageDetailView, type PackageDetailViewProps, type PackageDiscount, PackageExcludedAndToPack, type PackageHost, type PackageHostResponse, PackageIncluded, PackageMap, PackageOverview, type PackagePriceTier, type PackageRoute, type PackageRouteGeometry, type PackageRoutesDay, type PackageRoutesResponse, PackagesCarousel, PackagesResource, PackagesSection, type PackagesSectionProps, type ThingItem, type TopData, TopSection, TravoriesApiError, TravoriesClient, type TravoriesClientConfig, type TravoriesImage, type TravoriesImageUrls, type TravoriesPackage, type UseAgencyBundleResult, type UseHomeSectionsResult, type UsePackageBundleResult, type UsePackageBySlugResult, buildDescriptionData, buildGalleryMedia, buildTopData, createTravoriesClient, formatCurrency, formatRating, pickImageUrl, startingPrice, useAgencyBundle, useHomeSections, useHomeSectionsContext, usePackageBundle, usePackageBySlug };
|