@suiteop/storefront 0.4.0 → 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.
Files changed (47) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +5 -0
  3. package/dist/astro-content-model.cjs +5 -5
  4. package/dist/astro-content-model.js +4 -4
  5. package/dist/{availability-CnzmxuV3.d.cts → availability-Dh0yLSkj.d.cts} +25 -1
  6. package/dist/{availability-CnzmxuV3.d.ts → availability-Dh0yLSkj.d.ts} +25 -1
  7. package/dist/checkout.cjs +4 -4
  8. package/dist/checkout.js +3 -3
  9. package/dist/chunk-5TUJX6GY.js +5 -0
  10. package/dist/{chunk-HMLBMNGA.js → chunk-7ZAI36LH.js} +1 -1
  11. package/dist/{chunk-LVFRVNT3.cjs → chunk-EHQFWSP6.cjs} +2 -1
  12. package/dist/{chunk-6NFURJXI.js → chunk-IBCBDAGY.js} +2 -2
  13. package/dist/{chunk-TLTL7M3O.js → chunk-IUNIQSFB.js} +2 -2
  14. package/dist/{chunk-USOISC2R.cjs → chunk-J5FZ4WDQ.cjs} +2 -2
  15. package/dist/chunk-LY73ZYN5.cjs +20 -0
  16. package/dist/{chunk-IUJTHNB3.cjs → chunk-NNWJZUQL.cjs} +3 -3
  17. package/dist/{chunk-CTHHMNLE.cjs → chunk-NZWYOV5Y.cjs} +4 -4
  18. package/dist/{chunk-VV2UNVQ2.cjs → chunk-UMCI4YBN.cjs} +2 -2
  19. package/dist/{chunk-ZI2PG7LS.js → chunk-W5K7IDYN.js} +1 -1
  20. package/dist/{chunk-UWUKERLK.js → chunk-YSKWSL2F.js} +4 -4
  21. package/dist/{client-oyYRhUv0.d.ts → client-2KyVv-2l.d.cts} +45 -11
  22. package/dist/{client-CZWN4im4.d.cts → client-C9Igm7O-.d.ts} +45 -11
  23. package/dist/components.cjs +2 -2
  24. package/dist/components.d.cts +1 -1
  25. package/dist/components.d.ts +1 -1
  26. package/dist/components.js +1 -1
  27. package/dist/config.cjs +8 -1
  28. package/dist/config.d.cts +168 -11
  29. package/dist/config.d.ts +168 -11
  30. package/dist/config.js +3 -3
  31. package/dist/content.cjs +11 -11
  32. package/dist/content.d.cts +3 -3
  33. package/dist/content.d.ts +3 -3
  34. package/dist/content.js +4 -4
  35. package/dist/{errors-DoXdi1vS.d.ts → errors-BGgJ--XR.d.ts} +1 -1
  36. package/dist/{errors-CAW7nLHr.d.cts → errors-DpImb0Uf.d.cts} +1 -1
  37. package/dist/index.cjs +21 -21
  38. package/dist/index.d.cts +4 -4
  39. package/dist/index.d.ts +4 -4
  40. package/dist/index.js +4 -4
  41. package/dist/react.cjs +6 -6
  42. package/dist/react.d.cts +3 -3
  43. package/dist/react.d.ts +3 -3
  44. package/dist/react.js +5 -5
  45. package/package.json +1 -1
  46. package/dist/chunk-E5CGGMCO.cjs +0 -19
  47. package/dist/chunk-TRXDDUEL.js +0 -5
package/CHANGELOG.md CHANGED
@@ -2,6 +2,48 @@
2
2
 
3
3
  Hand-written per release. Tag `storefront-sdk@<version>` on `main` publishes it.
4
4
 
5
+ ## 0.5.0
6
+
7
+ - The site config takes optional `layout` (`listings`, the default, `locations`, `areas` or
8
+ `single`) and `theme` (`tide`, the default, `folio`, `hearth`, `circuit`, `noir` or `fjord`).
9
+ A value this version does not know reads as absent, so a site never fails its build on a newer
10
+ one.
11
+ - `colors.primary` is the only colour a config needs: `colors.secondary` (optional) is a second
12
+ accent, and `background`, `foreground`, `accent` and `primaryForeground` become optional
13
+ overrides of the colours the theme derives. `brand.logoOnDarkUrl` (optional) is the logo for
14
+ dark grounds and photo heroes. `fonts` and each of its two fields are optional: absent takes the
15
+ theme's pair. Every config valid for 0.4 stays valid.
16
+ - `@suiteop/storefront/config` exports `resolveStorefrontTheme(config)` and
17
+ `deriveStorefrontTheme(theme, brandHex, options)`: the whole `--so-*` token set (surfaces,
18
+ tints, borders, text, buttons, dark sections, focus, scrims, shadows), the `--t-*` type scale,
19
+ radii and button metrics, the WCAG checks, notes on what the brand colour needed, and the
20
+ overrides refused for failing AA. `STOREFRONT_THEME_RECIPES` holds each theme's recipe.
21
+ - `buildings.availability(id, { checkIn, checkOut, guests })`: every unit of a building for one
22
+ stay in a single call — `available`, `reason`, the stay's `totalMinor` and `currency`, `nights`,
23
+ `maxGuests`, and `nextAvailable`, the first free stay of the same length starting within 60 days
24
+ after the requested check-in. Display only: it reads the synced calendar, and the total is the
25
+ nightly rates plus the cleaning fee, before taxes — `quotes.create` gives the price a guest
26
+ books at. Pages like `listings.list` (`limit` up to 100, default 50). Types
27
+ `StorefrontUnitAvailability`, `StorefrontUnitUnavailableReason` and
28
+ `StorefrontBuildingAvailabilityQuery`.
29
+ - Listing summaries carry `fromPriceMinor` and `currency`, computed as the listing detail computes
30
+ them, so a search page no longer needs one detail request per card. Both are nullish: an older
31
+ API omits them.
32
+ - `listings.list()` takes search filters, all optional: `guests` (sleeps at least), `bedrooms` (at
33
+ least), `currency` (ISO 4217: only listings priced in it), `priceMin` / `priceMax` (on
34
+ `fromPriceMinor`, minor units of `currency`, which they require; an unpriced listing is left
35
+ out), `amenities` (all of them, as `amenities.list()` names them), `bounds`
36
+ (`[swLat, swLng, neLat, neLng]`, wrapping the antimeridian; a listing without coordinates is
37
+ outside), and `location` now takes several areas (any of them). `sort`: `recommended` (the
38
+ manager's order, the default), `price_asc`, `price_desc` (by amount within each currency),
39
+ `rating`; unpriced or unrated listings sort last.
40
+ - `listings.list({ facets: true })` also answers `facets` for a filters sheet: `total`, per-area
41
+ and per-bedroom counts, and a 24-bucket `fromPriceMinor` histogram with its min, max and
42
+ currency (null when the matches price in several currencies and no `currency` picks one). Each
43
+ facet ignores its own filter. Type `StorefrontListingFacets`.
44
+ - `StorefrontListingsQuery` is now the call's own shape (every key optional, `location` a string
45
+ or a list); `listings.list` takes it directly instead of `Partial<StorefrontListingsQuery>`.
46
+
5
47
  ## 0.4.0
6
48
 
7
49
  - `guides.list()` / `guides.get(id)`: the "Things to do" lists the manager shows on the site
package/README.md CHANGED
@@ -225,6 +225,11 @@ import { suiteop } from '@suiteop/storefront/astro'
225
225
  export default defineConfig({ integrations: [suiteop()] })
226
226
  ```
227
227
 
228
+ `layout` and `theme` in the config are optional (`listings` and `tide` when absent).
229
+ `resolveStorefrontTheme(config)` (`@suiteop/storefront/config`) derives the theme's whole token
230
+ set from `colors.primary` — the `--so-*` colours, type scale, radii and button metrics to set on
231
+ `:root` — with WCAG AA checked for every text pair.
232
+
228
233
  `suiteop()` writes `/_suiteop/manifest.json` after every build: the prerendered pages (path,
229
234
  language, title, last change — pages marked `noindex` are left out) and the on-demand routes that
230
235
  expand from catalogue data (`/listing/[id]`, `/building/[id]`). `/_suiteop/*` is reserved for the
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkIUJTHNB3_cjs = require('./chunk-IUJTHNB3.cjs');
4
- require('./chunk-E5CGGMCO.cjs');
5
- require('./chunk-USOISC2R.cjs');
6
- require('./chunk-LVFRVNT3.cjs');
3
+ var chunkNNWJZUQL_cjs = require('./chunk-NNWJZUQL.cjs');
4
+ require('./chunk-LY73ZYN5.cjs');
5
+ require('./chunk-J5FZ4WDQ.cjs');
6
+ require('./chunk-EHQFWSP6.cjs');
7
7
  var definition = require('virtual:suiteop/content');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
10
 
11
11
  var definition__default = /*#__PURE__*/_interopDefault(definition);
12
12
 
13
- var prerender=true;function GET(){return new Response(`${JSON.stringify(chunkIUJTHNB3_cjs.parseContentModel(definition__default.default))}
13
+ var prerender=true;function GET(){return new Response(`${JSON.stringify(chunkNNWJZUQL_cjs.parseContentModel(definition__default.default))}
14
14
  `,{headers:{"content-type":"application/json"}})}
15
15
 
16
16
  exports.GET = GET;
@@ -1,7 +1,7 @@
1
- import { parseContentModel } from './chunk-TLTL7M3O.js';
2
- import './chunk-TRXDDUEL.js';
3
- import './chunk-ZI2PG7LS.js';
4
- import './chunk-6NFURJXI.js';
1
+ import { parseContentModel } from './chunk-IUNIQSFB.js';
2
+ import './chunk-5TUJX6GY.js';
3
+ import './chunk-W5K7IDYN.js';
4
+ import './chunk-IBCBDAGY.js';
5
5
  import definition from 'virtual:suiteop/content';
6
6
 
7
7
  var prerender=true;function GET(){return new Response(`${JSON.stringify(parseContentModel(definition))}
@@ -56,5 +56,29 @@ declare const storefrontAvailabilitySchema: z.ZodObject<{
56
56
  maxGuests: z.ZodNullable<z.ZodNumber>;
57
57
  }, z.core.$strip>;
58
58
  type StorefrontAvailability = z.infer<typeof storefrontAvailabilitySchema>;
59
+ declare const storefrontBuildingAvailabilityQuerySchema: z.ZodObject<{
60
+ checkIn: z.ZodISODate;
61
+ checkOut: z.ZodISODate;
62
+ guests: z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodNumber>;
63
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
64
+ offset: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
65
+ }, z.core.$strip>;
66
+ type StorefrontBuildingAvailabilityQuery = z.infer<typeof storefrontBuildingAvailabilityQuerySchema>;
67
+ declare const STOREFRONT_UNIT_UNAVAILABLE_REASONS: readonly ["not_bookable", "dates_unavailable", "min_nights", "max_guests", "closed_to_arrival", "closed_to_departure", "calendar_unavailable"];
68
+ type StorefrontUnitUnavailableReason = (typeof STOREFRONT_UNIT_UNAVAILABLE_REASONS)[number];
69
+ declare const storefrontUnitAvailabilitySchema: z.ZodObject<{
70
+ listingId: z.ZodUUID;
71
+ available: z.ZodBoolean;
72
+ reason: z.ZodNullable<z.ZodType<(string & {}) | "not_bookable" | "dates_unavailable" | "min_nights" | "max_guests" | "closed_to_arrival" | "closed_to_departure" | "calendar_unavailable", unknown, z.core.$ZodTypeInternals<(string & {}) | "not_bookable" | "dates_unavailable" | "min_nights" | "max_guests" | "closed_to_arrival" | "closed_to_departure" | "calendar_unavailable", unknown>>>;
73
+ totalMinor: z.ZodNullable<z.ZodNumber>;
74
+ currency: z.ZodNullable<z.ZodString>;
75
+ nights: z.ZodNumber;
76
+ nextAvailable: z.ZodNullable<z.ZodObject<{
77
+ checkIn: z.ZodISODate;
78
+ checkOut: z.ZodISODate;
79
+ }, z.core.$strip>>;
80
+ maxGuests: z.ZodNullable<z.ZodNumber>;
81
+ }, z.core.$strip>;
82
+ type StorefrontUnitAvailability = z.infer<typeof storefrontUnitAvailabilitySchema>;
59
83
 
60
- export type { StorefrontAvailability as S, StorefrontCalendar as a, StorefrontCalendarDay as b, StorefrontCalendarQuery as c, StorefrontStay as d, StorefrontUnavailableReason as e };
84
+ export type { StorefrontAvailability as S, StorefrontBuildingAvailabilityQuery as a, StorefrontCalendar as b, StorefrontCalendarDay as c, StorefrontCalendarQuery as d, StorefrontStay as e, StorefrontUnavailableReason as f, StorefrontUnitAvailability as g, StorefrontUnitUnavailableReason as h };
@@ -56,5 +56,29 @@ declare const storefrontAvailabilitySchema: z.ZodObject<{
56
56
  maxGuests: z.ZodNullable<z.ZodNumber>;
57
57
  }, z.core.$strip>;
58
58
  type StorefrontAvailability = z.infer<typeof storefrontAvailabilitySchema>;
59
+ declare const storefrontBuildingAvailabilityQuerySchema: z.ZodObject<{
60
+ checkIn: z.ZodISODate;
61
+ checkOut: z.ZodISODate;
62
+ guests: z.ZodPipe<z.ZodCoercedNumber<unknown>, z.ZodNumber>;
63
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
64
+ offset: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
65
+ }, z.core.$strip>;
66
+ type StorefrontBuildingAvailabilityQuery = z.infer<typeof storefrontBuildingAvailabilityQuerySchema>;
67
+ declare const STOREFRONT_UNIT_UNAVAILABLE_REASONS: readonly ["not_bookable", "dates_unavailable", "min_nights", "max_guests", "closed_to_arrival", "closed_to_departure", "calendar_unavailable"];
68
+ type StorefrontUnitUnavailableReason = (typeof STOREFRONT_UNIT_UNAVAILABLE_REASONS)[number];
69
+ declare const storefrontUnitAvailabilitySchema: z.ZodObject<{
70
+ listingId: z.ZodUUID;
71
+ available: z.ZodBoolean;
72
+ reason: z.ZodNullable<z.ZodType<(string & {}) | "not_bookable" | "dates_unavailable" | "min_nights" | "max_guests" | "closed_to_arrival" | "closed_to_departure" | "calendar_unavailable", unknown, z.core.$ZodTypeInternals<(string & {}) | "not_bookable" | "dates_unavailable" | "min_nights" | "max_guests" | "closed_to_arrival" | "closed_to_departure" | "calendar_unavailable", unknown>>>;
73
+ totalMinor: z.ZodNullable<z.ZodNumber>;
74
+ currency: z.ZodNullable<z.ZodString>;
75
+ nights: z.ZodNumber;
76
+ nextAvailable: z.ZodNullable<z.ZodObject<{
77
+ checkIn: z.ZodISODate;
78
+ checkOut: z.ZodISODate;
79
+ }, z.core.$strip>>;
80
+ maxGuests: z.ZodNullable<z.ZodNumber>;
81
+ }, z.core.$strip>;
82
+ type StorefrontUnitAvailability = z.infer<typeof storefrontUnitAvailabilitySchema>;
59
83
 
60
- export type { StorefrontAvailability as S, StorefrontCalendar as a, StorefrontCalendarDay as b, StorefrontCalendarQuery as c, StorefrontStay as d, StorefrontUnavailableReason as e };
84
+ export type { StorefrontAvailability as S, StorefrontBuildingAvailabilityQuery as a, StorefrontCalendar as b, StorefrontCalendarDay as c, StorefrontCalendarQuery as d, StorefrontStay as e, StorefrontUnavailableReason as f, StorefrontUnitAvailability as g, StorefrontUnitUnavailableReason as h };
package/dist/checkout.cjs CHANGED
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkVV2UNVQ2_cjs = require('./chunk-VV2UNVQ2.cjs');
4
- require('./chunk-USOISC2R.cjs');
5
- require('./chunk-LVFRVNT3.cjs');
3
+ var chunkUMCI4YBN_cjs = require('./chunk-UMCI4YBN.cjs');
4
+ require('./chunk-J5FZ4WDQ.cjs');
5
+ require('./chunk-EHQFWSP6.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, "loadCheckout", {
10
10
  enumerable: true,
11
- get: function () { return chunkVV2UNVQ2_cjs.loadCheckout; }
11
+ get: function () { return chunkUMCI4YBN_cjs.loadCheckout; }
12
12
  });
package/dist/checkout.js CHANGED
@@ -1,3 +1,3 @@
1
- export { loadCheckout } from './chunk-HMLBMNGA.js';
2
- import './chunk-ZI2PG7LS.js';
3
- import './chunk-6NFURJXI.js';
1
+ export { loadCheckout } from './chunk-7ZAI36LH.js';
2
+ import './chunk-W5K7IDYN.js';
3
+ import './chunk-IBCBDAGY.js';
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+
3
+ var emailField=z.string().trim().toLowerCase().pipe(z.email("validation.email_invalid"));z.string().trim().min(1,"validation.email_required").pipe(emailField);var trimmedEmailField=z.string().trim().pipe(z.email("validation.email_invalid"));var requiredTrimmedEmailField=z.string().trim().min(1,"validation.email_required").pipe(trimmedEmailField);z.string().nullish().transform((raw,ctx)=>{if(raw===void 0)return void 0;const trimmed=(raw??"").trim().toLowerCase();if(!trimmed)return null;if(!z.email().safeParse(trimmed).success){ctx.addIssue({code:"custom",message:"validation.email_invalid"});return z.NEVER}return trimmed});var storefrontIdSchema=z.uuid();var storefrontSiteSchema=z.object({id:z.uuid(),name:z.string(),slug:z.string(),isActive:z.boolean(),enableWebChat:z.boolean(),mapEmbedHost:z.string().nullable(),countryCode:z.string().nullish(),bookingsOpen:z.boolean().optional()});var storefrontListingSummarySchema=z.object({id:z.uuid(),buildingId:z.uuid(),sortOrder:z.number().int(),name:z.string(),coverImageUrl:z.string().nullable(),city:z.string().nullable(),state:z.string().nullable(),bedroomCount:z.number().int().nullable(),bathroomCount:z.number().nullable(),maxGuests:z.number().int().nullable(),averageRating:z.number().nullable(),latitude:z.number().nullable(),longitude:z.number().nullable(),bookable:z.boolean(),fromPriceMinor:z.number().int().nonnegative().nullish(),currency:z.string().nullish()});var storefrontImageSchema=z.object({url:z.string(),alt:z.string().nullable(),width:z.number().int().nullable(),height:z.number().int().nullable()});var storefrontListingSchema=storefrontListingSummarySchema.extend({buildingSlug:z.string(),buildingAddress:z.unknown(),description:z.string().nullable(),amenities:z.array(z.string()),pictures:z.unknown(),images:z.array(storefrontImageSchema).optional(),rooms:z.unknown(),houseRules:z.string().nullable(),checkInTime:z.string().nullable(),checkOutTime:z.string().nullable(),beds:z.number().nullable(),countryCode:z.string().nullish()});var STOREFRONT_LISTING_SORTS=["recommended","price_asc","price_desc","rating"];var asList=value=>value===void 0?void 0:Array.isArray(value)?value:[value];var boundsSchema=z.string().transform(value=>value.split(",").map(part=>part.trim()===""?NaN:Number(part))).pipe(z.tuple([z.number().min(-90).max(90),z.number().min(-180).max(180),z.number().min(-90).max(90),z.number().min(-180).max(180)]).refine(([swLat,,neLat])=>swLat<=neLat)).transform(([swLat,swLng,neLat,neLng])=>({swLat,swLng,neLat,neLng}));z.object({location:z.preprocess(value=>asList(value)?.flatMap(v=>typeof v==="string"?v.split(","):[v]),z.array(z.string().trim().min(1).max(200)).min(1).max(50).optional()).optional(),building:z.uuid().optional(),guests:z.coerce.number().int().min(1).max(100).optional(),bedrooms:z.coerce.number().int().min(0).max(50).optional(),currency:z.string().trim().regex(/^[A-Za-z]{3}$/).transform(value=>value.toLowerCase()).optional(),priceMin:z.coerce.number().int().min(0).optional(),priceMax:z.coerce.number().int().min(0).optional(),amenities:z.preprocess(asList,z.array(z.string().trim().min(1).max(200)).min(1).max(30).optional()).optional(),bounds:boundsSchema.optional(),sort:z.enum(STOREFRONT_LISTING_SORTS).optional(),facets:z.enum(["0","1","true","false"]).transform(value=>value==="1"||value==="true").optional(),limit:z.coerce.number().int().min(1).max(100).default(50),offset:z.coerce.number().int().min(0).max(1e4).default(0)}).refine(q=>q.currency!==void 0||q.priceMin===void 0&&q.priceMax===void 0,{path:["currency"],message:"validation.required"}).refine(q=>q.priceMin===void 0||q.priceMax===void 0||q.priceMin<=q.priceMax,{path:["priceMax"],message:"validation.invalid"});var storefrontListingFacetsSchema=z.object({total:z.number().int(),areas:z.array(z.object({id:z.uuid(),slug:z.string().nullable(),count:z.number().int()})),bedrooms:z.array(z.object({bedrooms:z.number().int(),count:z.number().int()})),price:z.object({min:z.number().int(),max:z.number().int(),currency:z.string().nullable(),buckets:z.array(z.number().int()).length(24)}).nullable()});var storefrontBuildingSchema=z.object({id:z.uuid(),locationId:z.uuid().nullable(),nameId:z.uuid().nullable(),descriptionId:z.uuid().nullable(),slug:z.string(),imageId:z.uuid().nullable(),latitude:z.number().nullable(),longitude:z.number().nullable(),address:z.unknown(),name:z.string().nullish(),description:z.string().nullish(),imageUrl:z.string().nullish(),images:z.array(storefrontImageSchema).nullish(),sortOrder:z.number().int().nullish(),listingCount:z.number().int().nullish(),fields:z.record(z.string(),z.record(z.string(),z.unknown())).nullish()});var storefrontLocationSchema=z.object({id:z.uuid(),type:z.string(),parentId:z.uuid().nullable(),nameId:z.uuid().nullable(),slug:z.string().nullable(),imageId:z.uuid().nullable(),latitude:z.number().nullable(),longitude:z.number().nullable(),address:z.unknown(),sortOrder:z.number().int(),name:z.string().nullish(),description:z.string().nullish(),imageUrl:z.string().nullish(),images:z.array(storefrontImageSchema).nullish(),buildingCount:z.number().int().nullish(),fields:z.record(z.string(),z.record(z.string(),z.unknown())).nullish()});z.object({locale:z.string().max(35).optional().catch(void 0)});var storefrontReviewSchema=z.object({id:z.uuid(),listingId:z.uuid().nullable(),reviewedAt:z.string().nullable(),rating:z.number().nullable(),publicReview:z.string(),source:z.string().nullable()});z.object({listingId:z.uuid().optional(),limit:z.coerce.number().int().min(1).max(100).default(20),offset:z.coerce.number().int().min(0).max(1e4).default(0)});z.object({name:z.string().trim().min(1,"validation.name_required").max(200,"validation.name_max_length"),email:requiredTrimmedEmailField,subject:z.string().trim().min(1,"validation.title_required").max(300,"validation.title_max_length"),message:z.string().trim().min(10,"validation.message_min_length").max(1e4,"validation.message_max_length")});var storefrontContactResultSchema=z.object({sent:z.literal(true)});var storefrontContentRefSchema=z.object({kind:z.string(),id:z.uuid(),slug:z.string().nullable()});var storefrontContentItemSchema=z.object({id:z.uuid(),type:z.string(),slug:z.string().nullable(),publishedAt:z.string().nullable(),updatedAt:z.string(),sortOrder:z.number().int(),fields:z.record(z.string(),z.unknown())});var storefrontContentFieldDefSchema=z.object({key:z.string(),type:z.string()}).catchall(z.unknown());var storefrontContentModelSchema=z.object({version:z.number().int(),types:z.array(z.object({key:z.string(),kind:z.string(),fields:z.array(storefrontContentFieldDefSchema)}).catchall(z.unknown()))});z.object({limit:z.coerce.number().int().min(1).max(100).default(20),offset:z.coerce.number().int().min(0).max(1e4).default(0),locale:z.string().max(35).optional().catch(void 0)});z.string().regex(/^[a-z][a-z0-9_]{0,39}$/);z.string().min(1).max(120).regex(/^[a-z0-9-]+$/);
4
+
5
+ export { requiredTrimmedEmailField, storefrontBuildingSchema, storefrontContactResultSchema, storefrontContentItemSchema, storefrontContentModelSchema, storefrontContentRefSchema, storefrontIdSchema, storefrontImageSchema, storefrontListingFacetsSchema, storefrontListingSchema, storefrontListingSummarySchema, storefrontLocationSchema, storefrontReviewSchema, storefrontSiteSchema };
@@ -1,4 +1,4 @@
1
- import { StorefrontError } from './chunk-ZI2PG7LS.js';
1
+ import { StorefrontError } from './chunk-W5K7IDYN.js';
2
2
  import { z } from 'zod';
3
3
 
4
4
  var TAG="suiteop-checkout";var manifestSchema=z.object({v1:z.object({path:z.string().regex(/^\/checkout\/v1\.[0-9a-f]{12}\.js$/),integrity:z.string().regex(/^sha384-[A-Za-z0-9+/]+={0,2}$/)})});var loads=new Map;var requested=new Map;function scriptUrl(url){const n=requested.get(url)??0;requested.set(url,n+1);return n===0?url:`${url}?retry=${n}`}function unavailable(message,cause){return new StorefrontError({status:0,code:"checkout_unavailable",message,cause})}async function fetchEntry(origin,fresh){const res=await fetch(`${origin}/checkout/manifest.json`,{cache:fresh?"no-store":"default",credentials:"omit"});if(!res.ok)throw unavailable(`The checkout manifest answered ${res.status}`);const parsed=manifestSchema.safeParse(await res.json());if(!parsed.success)throw unavailable("The checkout manifest has no usable v1 entry");return parsed.data.v1}function inject(src,integrity){const script=document.createElement("script");script.type="module";script.src=src;script.integrity=integrity;script.crossOrigin="anonymous";const ready=new Promise((resolve,reject)=>{script.addEventListener("error",()=>reject(unavailable(`${src} failed to load`)),{once:true});script.addEventListener("load",()=>customElements.get(TAG)?resolve():reject(unavailable(`${src} defined no <${TAG}>`)),{once:true});void customElements.whenDefined(TAG).then(()=>resolve());});document.head.append(script);return [script,ready]}async function load(origin){if(customElements.get(TAG))return;for(const fresh of [false,true]){try{const entry=await fetchEntry(origin,fresh);const[script,ready]=inject(scriptUrl(`${origin}${entry.path}`),entry.integrity);try{return await ready}catch(err){script.remove();if(fresh)throw err}}catch(err){if(err instanceof StorefrontError)throw err;throw unavailable("The checkout bundle could not be loaded",err)}}}function loadCheckout(options={}){if(typeof window==="undefined"||typeof document==="undefined")return Promise.resolve();let origin;try{origin=new URL(options.origin??window.location.origin).origin;}catch(err){return Promise.reject(unavailable("loadCheckout: origin must be an absolute URL",err))}const key=`${origin}|v${options.major??1}`;const existing=loads.get(key);if(existing)return existing;const loading=load(origin);loads.set(key,loading);loading.catch(()=>{if(loads.get(key)===loading)loads.delete(key);});return loading}
@@ -2,7 +2,7 @@
2
2
 
3
3
  var zod = require('zod');
4
4
 
5
- function openEnum(values){return zod.z.union([zod.z.enum(values),zod.z.string()])}var STOREFRONT_MAX_GUESTS=50;var STOREFRONT_MAX_STAY_NIGHTS=365;var STOREFRONT_CALENDAR_MAX_DAYS=366;var storefrontDateSchema=zod.z.iso.date({message:"validation.storefront.date_invalid"});var storefrontGuestsSchema=zod.z.number({message:"validation.storefront.guests_min"}).int({message:"validation.storefront.guests_min"}).min(1,{message:"validation.storefront.guests_min"}).max(STOREFRONT_MAX_GUESTS,{message:"validation.storefront.guests_max"});function daysBetween(from,to){return Math.round((Date.parse(`${to}T00:00:00Z`)-Date.parse(`${from}T00:00:00Z`))/864e5)}var STOREFRONT_MAX_ADVANCE_YEARS=2;function utcDate(days,years=0){const date=new Date;date.setUTCFullYear(date.getUTCFullYear()+years,date.getUTCMonth(),date.getUTCDate()+days);return date.toISOString().slice(0,10)}function withStayRules(schema){return schema.refine(stay=>stay.checkIn>=utcDate(-1),{path:["checkIn"],message:"validation.storefront.check_in_past"}).refine(stay=>stay.checkIn<=utcDate(0,STOREFRONT_MAX_ADVANCE_YEARS),{path:["checkIn"],message:"validation.storefront.check_in_too_far"}).refine(stay=>daysBetween(stay.checkIn,stay.checkOut)>=1,{path:["checkOut"],message:"validation.storefront.check_out_after_check_in"}).refine(stay=>daysBetween(stay.checkIn,stay.checkOut)<=STOREFRONT_MAX_STAY_NIGHTS,{path:["checkOut"],message:"validation.storefront.stay_too_long"})}withStayRules(zod.z.object({checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:storefrontGuestsSchema}));withStayRules(zod.z.object({checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:zod.z.coerce.number({message:"validation.storefront.guests_min"}).pipe(storefrontGuestsSchema)}));zod.z.object({from:storefrontDateSchema,to:storefrontDateSchema}).refine(range=>daysBetween(range.from,range.to)>=0,{path:["to"],message:"validation.storefront.calendar_range_order"}).refine(range=>daysBetween(range.from,range.to)<STOREFRONT_CALENDAR_MAX_DAYS,{path:["to"],message:"validation.storefront.calendar_range_too_long"});var CALENDAR_DAY_STATUSES=["available","blocked","booked"];var storefrontCalendarDayKnownSchema=zod.z.object({date:storefrontDateSchema,status:zod.z.enum(CALENDAR_DAY_STATUSES),priceMinor:zod.z.number().int().nullable(),currency:zod.z.string().nullable(),minNights:zod.z.number().int().nullable(),closedToArrival:zod.z.boolean().optional(),closedToDeparture:zod.z.boolean().optional()});var storefrontCalendarDaySchema=storefrontCalendarDayKnownSchema.extend({status:openEnum(CALENDAR_DAY_STATUSES)});var storefrontCalendarSchema=zod.z.object({listingId:zod.z.uuid(),bookable:zod.z.boolean(),days:zod.z.array(storefrontCalendarDaySchema)});var STOREFRONT_UNAVAILABLE_REASONS=["not_bookable","dates_unavailable","min_nights","max_guests","closed_to_arrival","closed_to_departure"];zod.z.enum(STOREFRONT_UNAVAILABLE_REASONS);var storefrontAvailabilitySchema=zod.z.object({listingId:zod.z.uuid(),checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:zod.z.number().int(),bookable:zod.z.boolean(),available:zod.z.boolean(),reason:openEnum(STOREFRONT_UNAVAILABLE_REASONS).nullable(),minNights:zod.z.number().int().nullable(),maxGuests:zod.z.number().int().nullable()});
5
+ function openEnum(values){return zod.z.union([zod.z.enum(values),zod.z.string()])}var STOREFRONT_MAX_GUESTS=50;var STOREFRONT_MAX_STAY_NIGHTS=365;var STOREFRONT_CALENDAR_MAX_DAYS=366;var storefrontDateSchema=zod.z.iso.date({message:"validation.storefront.date_invalid"});var storefrontGuestsSchema=zod.z.number({message:"validation.storefront.guests_min"}).int({message:"validation.storefront.guests_min"}).min(1,{message:"validation.storefront.guests_min"}).max(STOREFRONT_MAX_GUESTS,{message:"validation.storefront.guests_max"});function daysBetween(from,to){return Math.round((Date.parse(`${to}T00:00:00Z`)-Date.parse(`${from}T00:00:00Z`))/864e5)}var STOREFRONT_MAX_ADVANCE_YEARS=2;function utcDate(days,years=0){const date=new Date;date.setUTCFullYear(date.getUTCFullYear()+years,date.getUTCMonth(),date.getUTCDate()+days);return date.toISOString().slice(0,10)}function withStayRules(schema){return schema.refine(stay=>stay.checkIn>=utcDate(-1),{path:["checkIn"],message:"validation.storefront.check_in_past"}).refine(stay=>stay.checkIn<=utcDate(0,STOREFRONT_MAX_ADVANCE_YEARS),{path:["checkIn"],message:"validation.storefront.check_in_too_far"}).refine(stay=>daysBetween(stay.checkIn,stay.checkOut)>=1,{path:["checkOut"],message:"validation.storefront.check_out_after_check_in"}).refine(stay=>daysBetween(stay.checkIn,stay.checkOut)<=STOREFRONT_MAX_STAY_NIGHTS,{path:["checkOut"],message:"validation.storefront.stay_too_long"})}withStayRules(zod.z.object({checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:storefrontGuestsSchema}));withStayRules(zod.z.object({checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:zod.z.coerce.number({message:"validation.storefront.guests_min"}).pipe(storefrontGuestsSchema)}));zod.z.object({from:storefrontDateSchema,to:storefrontDateSchema}).refine(range=>daysBetween(range.from,range.to)>=0,{path:["to"],message:"validation.storefront.calendar_range_order"}).refine(range=>daysBetween(range.from,range.to)<STOREFRONT_CALENDAR_MAX_DAYS,{path:["to"],message:"validation.storefront.calendar_range_too_long"});var CALENDAR_DAY_STATUSES=["available","blocked","booked"];var storefrontCalendarDayKnownSchema=zod.z.object({date:storefrontDateSchema,status:zod.z.enum(CALENDAR_DAY_STATUSES),priceMinor:zod.z.number().int().nullable(),currency:zod.z.string().nullable(),minNights:zod.z.number().int().nullable(),closedToArrival:zod.z.boolean().optional(),closedToDeparture:zod.z.boolean().optional()});var storefrontCalendarDaySchema=storefrontCalendarDayKnownSchema.extend({status:openEnum(CALENDAR_DAY_STATUSES)});var storefrontCalendarSchema=zod.z.object({listingId:zod.z.uuid(),bookable:zod.z.boolean(),days:zod.z.array(storefrontCalendarDaySchema)});var STOREFRONT_UNAVAILABLE_REASONS=["not_bookable","dates_unavailable","min_nights","max_guests","closed_to_arrival","closed_to_departure"];zod.z.enum(STOREFRONT_UNAVAILABLE_REASONS);var storefrontAvailabilitySchema=zod.z.object({listingId:zod.z.uuid(),checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:zod.z.number().int(),bookable:zod.z.boolean(),available:zod.z.boolean(),reason:openEnum(STOREFRONT_UNAVAILABLE_REASONS).nullable(),minNights:zod.z.number().int().nullable(),maxGuests:zod.z.number().int().nullable()});var STOREFRONT_BUILDING_AVAILABILITY_MAX_UNITS=100;withStayRules(zod.z.object({checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:zod.z.coerce.number({message:"validation.storefront.guests_min"}).pipe(storefrontGuestsSchema),limit:zod.z.coerce.number().int().min(1).max(STOREFRONT_BUILDING_AVAILABILITY_MAX_UNITS).default(50),offset:zod.z.coerce.number().int().min(0).max(1e4).default(0)}));var STOREFRONT_UNIT_UNAVAILABLE_REASONS=[...STOREFRONT_UNAVAILABLE_REASONS,"calendar_unavailable"];var storefrontUnitAvailabilitySchema=zod.z.object({listingId:zod.z.uuid(),available:zod.z.boolean(),reason:openEnum(STOREFRONT_UNIT_UNAVAILABLE_REASONS).nullable(),totalMinor:zod.z.number().int().nonnegative().nullable(),currency:zod.z.string().nullable(),nights:zod.z.number().int(),nextAvailable:zod.z.object({checkIn:storefrontDateSchema,checkOut:storefrontDateSchema}).nullable(),maxGuests:zod.z.number().int().nullable()});
6
6
 
7
7
  exports.STOREFRONT_MAX_GUESTS = STOREFRONT_MAX_GUESTS;
8
8
  exports.openEnum = openEnum;
@@ -10,4 +10,5 @@ exports.storefrontAvailabilitySchema = storefrontAvailabilitySchema;
10
10
  exports.storefrontCalendarSchema = storefrontCalendarSchema;
11
11
  exports.storefrontDateSchema = storefrontDateSchema;
12
12
  exports.storefrontGuestsSchema = storefrontGuestsSchema;
13
+ exports.storefrontUnitAvailabilitySchema = storefrontUnitAvailabilitySchema;
13
14
  exports.withStayRules = withStayRules;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
2
 
3
- function openEnum(values){return z.union([z.enum(values),z.string()])}var STOREFRONT_MAX_GUESTS=50;var STOREFRONT_MAX_STAY_NIGHTS=365;var STOREFRONT_CALENDAR_MAX_DAYS=366;var storefrontDateSchema=z.iso.date({message:"validation.storefront.date_invalid"});var storefrontGuestsSchema=z.number({message:"validation.storefront.guests_min"}).int({message:"validation.storefront.guests_min"}).min(1,{message:"validation.storefront.guests_min"}).max(STOREFRONT_MAX_GUESTS,{message:"validation.storefront.guests_max"});function daysBetween(from,to){return Math.round((Date.parse(`${to}T00:00:00Z`)-Date.parse(`${from}T00:00:00Z`))/864e5)}var STOREFRONT_MAX_ADVANCE_YEARS=2;function utcDate(days,years=0){const date=new Date;date.setUTCFullYear(date.getUTCFullYear()+years,date.getUTCMonth(),date.getUTCDate()+days);return date.toISOString().slice(0,10)}function withStayRules(schema){return schema.refine(stay=>stay.checkIn>=utcDate(-1),{path:["checkIn"],message:"validation.storefront.check_in_past"}).refine(stay=>stay.checkIn<=utcDate(0,STOREFRONT_MAX_ADVANCE_YEARS),{path:["checkIn"],message:"validation.storefront.check_in_too_far"}).refine(stay=>daysBetween(stay.checkIn,stay.checkOut)>=1,{path:["checkOut"],message:"validation.storefront.check_out_after_check_in"}).refine(stay=>daysBetween(stay.checkIn,stay.checkOut)<=STOREFRONT_MAX_STAY_NIGHTS,{path:["checkOut"],message:"validation.storefront.stay_too_long"})}withStayRules(z.object({checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:storefrontGuestsSchema}));withStayRules(z.object({checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:z.coerce.number({message:"validation.storefront.guests_min"}).pipe(storefrontGuestsSchema)}));z.object({from:storefrontDateSchema,to:storefrontDateSchema}).refine(range=>daysBetween(range.from,range.to)>=0,{path:["to"],message:"validation.storefront.calendar_range_order"}).refine(range=>daysBetween(range.from,range.to)<STOREFRONT_CALENDAR_MAX_DAYS,{path:["to"],message:"validation.storefront.calendar_range_too_long"});var CALENDAR_DAY_STATUSES=["available","blocked","booked"];var storefrontCalendarDayKnownSchema=z.object({date:storefrontDateSchema,status:z.enum(CALENDAR_DAY_STATUSES),priceMinor:z.number().int().nullable(),currency:z.string().nullable(),minNights:z.number().int().nullable(),closedToArrival:z.boolean().optional(),closedToDeparture:z.boolean().optional()});var storefrontCalendarDaySchema=storefrontCalendarDayKnownSchema.extend({status:openEnum(CALENDAR_DAY_STATUSES)});var storefrontCalendarSchema=z.object({listingId:z.uuid(),bookable:z.boolean(),days:z.array(storefrontCalendarDaySchema)});var STOREFRONT_UNAVAILABLE_REASONS=["not_bookable","dates_unavailable","min_nights","max_guests","closed_to_arrival","closed_to_departure"];z.enum(STOREFRONT_UNAVAILABLE_REASONS);var storefrontAvailabilitySchema=z.object({listingId:z.uuid(),checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:z.number().int(),bookable:z.boolean(),available:z.boolean(),reason:openEnum(STOREFRONT_UNAVAILABLE_REASONS).nullable(),minNights:z.number().int().nullable(),maxGuests:z.number().int().nullable()});
3
+ function openEnum(values){return z.union([z.enum(values),z.string()])}var STOREFRONT_MAX_GUESTS=50;var STOREFRONT_MAX_STAY_NIGHTS=365;var STOREFRONT_CALENDAR_MAX_DAYS=366;var storefrontDateSchema=z.iso.date({message:"validation.storefront.date_invalid"});var storefrontGuestsSchema=z.number({message:"validation.storefront.guests_min"}).int({message:"validation.storefront.guests_min"}).min(1,{message:"validation.storefront.guests_min"}).max(STOREFRONT_MAX_GUESTS,{message:"validation.storefront.guests_max"});function daysBetween(from,to){return Math.round((Date.parse(`${to}T00:00:00Z`)-Date.parse(`${from}T00:00:00Z`))/864e5)}var STOREFRONT_MAX_ADVANCE_YEARS=2;function utcDate(days,years=0){const date=new Date;date.setUTCFullYear(date.getUTCFullYear()+years,date.getUTCMonth(),date.getUTCDate()+days);return date.toISOString().slice(0,10)}function withStayRules(schema){return schema.refine(stay=>stay.checkIn>=utcDate(-1),{path:["checkIn"],message:"validation.storefront.check_in_past"}).refine(stay=>stay.checkIn<=utcDate(0,STOREFRONT_MAX_ADVANCE_YEARS),{path:["checkIn"],message:"validation.storefront.check_in_too_far"}).refine(stay=>daysBetween(stay.checkIn,stay.checkOut)>=1,{path:["checkOut"],message:"validation.storefront.check_out_after_check_in"}).refine(stay=>daysBetween(stay.checkIn,stay.checkOut)<=STOREFRONT_MAX_STAY_NIGHTS,{path:["checkOut"],message:"validation.storefront.stay_too_long"})}withStayRules(z.object({checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:storefrontGuestsSchema}));withStayRules(z.object({checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:z.coerce.number({message:"validation.storefront.guests_min"}).pipe(storefrontGuestsSchema)}));z.object({from:storefrontDateSchema,to:storefrontDateSchema}).refine(range=>daysBetween(range.from,range.to)>=0,{path:["to"],message:"validation.storefront.calendar_range_order"}).refine(range=>daysBetween(range.from,range.to)<STOREFRONT_CALENDAR_MAX_DAYS,{path:["to"],message:"validation.storefront.calendar_range_too_long"});var CALENDAR_DAY_STATUSES=["available","blocked","booked"];var storefrontCalendarDayKnownSchema=z.object({date:storefrontDateSchema,status:z.enum(CALENDAR_DAY_STATUSES),priceMinor:z.number().int().nullable(),currency:z.string().nullable(),minNights:z.number().int().nullable(),closedToArrival:z.boolean().optional(),closedToDeparture:z.boolean().optional()});var storefrontCalendarDaySchema=storefrontCalendarDayKnownSchema.extend({status:openEnum(CALENDAR_DAY_STATUSES)});var storefrontCalendarSchema=z.object({listingId:z.uuid(),bookable:z.boolean(),days:z.array(storefrontCalendarDaySchema)});var STOREFRONT_UNAVAILABLE_REASONS=["not_bookable","dates_unavailable","min_nights","max_guests","closed_to_arrival","closed_to_departure"];z.enum(STOREFRONT_UNAVAILABLE_REASONS);var storefrontAvailabilitySchema=z.object({listingId:z.uuid(),checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:z.number().int(),bookable:z.boolean(),available:z.boolean(),reason:openEnum(STOREFRONT_UNAVAILABLE_REASONS).nullable(),minNights:z.number().int().nullable(),maxGuests:z.number().int().nullable()});var STOREFRONT_BUILDING_AVAILABILITY_MAX_UNITS=100;withStayRules(z.object({checkIn:storefrontDateSchema,checkOut:storefrontDateSchema,guests:z.coerce.number({message:"validation.storefront.guests_min"}).pipe(storefrontGuestsSchema),limit:z.coerce.number().int().min(1).max(STOREFRONT_BUILDING_AVAILABILITY_MAX_UNITS).default(50),offset:z.coerce.number().int().min(0).max(1e4).default(0)}));var STOREFRONT_UNIT_UNAVAILABLE_REASONS=[...STOREFRONT_UNAVAILABLE_REASONS,"calendar_unavailable"];var storefrontUnitAvailabilitySchema=z.object({listingId:z.uuid(),available:z.boolean(),reason:openEnum(STOREFRONT_UNIT_UNAVAILABLE_REASONS).nullable(),totalMinor:z.number().int().nonnegative().nullable(),currency:z.string().nullable(),nights:z.number().int(),nextAvailable:z.object({checkIn:storefrontDateSchema,checkOut:storefrontDateSchema}).nullable(),maxGuests:z.number().int().nullable()});
4
4
 
5
- export { STOREFRONT_MAX_GUESTS, openEnum, storefrontAvailabilitySchema, storefrontCalendarSchema, storefrontDateSchema, storefrontGuestsSchema, withStayRules };
5
+ export { STOREFRONT_MAX_GUESTS, openEnum, storefrontAvailabilitySchema, storefrontCalendarSchema, storefrontDateSchema, storefrontGuestsSchema, storefrontUnitAvailabilitySchema, withStayRules };
@@ -1,5 +1,5 @@
1
- import { storefrontContentRefSchema, storefrontImageSchema } from './chunk-TRXDDUEL.js';
2
- import { StorefrontError } from './chunk-ZI2PG7LS.js';
1
+ import { storefrontContentRefSchema, storefrontImageSchema } from './chunk-5TUJX6GY.js';
2
+ import { StorefrontError } from './chunk-W5K7IDYN.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  var CONTENT_FIELD_TYPES=["text","rich_text","image","gallery","number","boolean","date","option","link","reference","references"];var CONTENT_TYPE_KINDS=["collection","section","fields"];var CONTENT_SUBJECT_KINDS=["building","area"];var CONTENT_REFERENCE_KINDS=["listing","building","area"];var MAX_CONTENT_TYPES=40;var MAX_CONTENT_FIELDS=40;var contentKeySchema=z.string().regex(/^[a-z][a-z0-9_]{0,39}$/,"validation.invalid_format");var contentLocalizedSchema=z.union([z.string().min(1).max(120),z.record(z.string().min(2).max(35),z.string().min(1).max(120))]);var COLLECTION_TARGET=/^collection:[a-z][a-z0-9_]{0,39}$/;var contentReferenceTargetSchema=z.union([z.enum(CONTENT_REFERENCE_KINDS),z.string().regex(COLLECTION_TARGET,"validation.invalid_format")]);var TEXT_TYPES=new Set(["text","rich_text"]);var LIST_TYPES=new Set(["gallery","references"]);var REFERENCE_TYPES=new Set(["reference","references"]);var contentFieldSchema=z.object({key:contentKeySchema,type:z.enum(CONTENT_FIELD_TYPES),label:contentLocalizedSchema,help:contentLocalizedSchema.optional(),required:z.boolean().default(false),translatable:z.boolean().optional(),maxLength:z.number().int().min(1).max(6e4).optional(),options:z.array(z.object({value:contentKeySchema,label:contentLocalizedSchema})).min(1).max(50).optional(),to:contentReferenceTargetSchema.optional(),max:z.number().int().min(1).max(100).optional(),removed:z.boolean().optional()}).superRefine((field2,ctx)=>{if(field2.type==="option"&&!field2.options?.length){ctx.addIssue({code:"custom",path:["options"],message:"validation.required"});}if(field2.options&&new Set(field2.options.map(o=>o.value)).size!==field2.options.length){ctx.addIssue({code:"custom",path:["options"],message:"validation.invalid"});}if(REFERENCE_TYPES.has(field2.type)&&!field2.to){ctx.addIssue({code:"custom",path:["to"],message:"validation.required"});}if(field2.maxLength!==void 0&&!TEXT_TYPES.has(field2.type)){ctx.addIssue({code:"custom",path:["maxLength"],message:"validation.invalid"});}if(field2.max!==void 0&&!LIST_TYPES.has(field2.type)){ctx.addIssue({code:"custom",path:["max"],message:"validation.invalid"});}});var contentTypeSchema=z.object({key:contentKeySchema,kind:z.enum(CONTENT_TYPE_KINDS),label:contentLocalizedSchema,description:contentLocalizedSchema.optional(),attachesTo:z.enum(CONTENT_SUBJECT_KINDS).optional(),titleField:contentKeySchema.optional(),routable:z.boolean().default(false),drafts:z.boolean().default(false),order:z.enum(["manual","newest"]).default("manual"),fields:z.array(contentFieldSchema).min(1).max(MAX_CONTENT_FIELDS)}).superRefine((type,ctx)=>{const keys=type.fields.map(f=>f.key);keys.forEach((key,i)=>{if(keys.indexOf(key)!==i){ctx.addIssue({code:"custom",path:["fields",i,"key"],message:"validation.invalid"});}});if(type.kind==="fields"!==(type.attachesTo!==void 0)){ctx.addIssue({code:"custom",path:["attachesTo"],message:"validation.invalid"});}if(type.kind==="collection"){const title=type.fields.find(f=>f.key===type.titleField);if(!title||title.type!=="text"){ctx.addIssue({code:"custom",path:["titleField"],message:"validation.invalid"});}}else if(type.titleField!==void 0){ctx.addIssue({code:"custom",path:["titleField"],message:"validation.invalid"});}});var contentModelSchema=z.object({version:z.literal(1),types:z.array(contentTypeSchema).max(MAX_CONTENT_TYPES)}).superRefine((model,ctx)=>{const keys=model.types.map(t=>t.key);const collections=new Set(model.types.filter(t=>t.kind==="collection").map(t=>t.key));model.types.forEach((type,i)=>{if(keys.indexOf(type.key)!==i){ctx.addIssue({code:"custom",path:["types",i,"key"],message:"validation.invalid"});}type.fields.forEach((field2,j)=>{const target=field2.to?.startsWith("collection:")?field2.to.slice(11):null;if(target!==null&&!collections.has(target)){ctx.addIssue({code:"custom",path:["types",i,"fields",j,"to"],message:"validation.invalid"});}});});});function defineContent(definition){return definition}var field={text:o=>({...o,type:"text"}),richText:o=>({...o,type:"rich_text"}),image:o=>({...o,type:"image"}),gallery:o=>({...o,type:"gallery"}),number:o=>({...o,type:"number"}),boolean:o=>({...o,type:"boolean"}),date:o=>({...o,type:"date"}),option:o=>({...o,type:"option"}),link:o=>({...o,type:"link"}),reference:o=>({...o,type:"reference"}),references:o=>({...o,type:"references"})};var optionOf=choice=>typeof choice==="string"?{value:choice,label:choice}:choice;function toContentModel(definition){return {version:1,types:Object.entries(definition).map(([key,type])=>({...type,key,fields:Object.entries(type.fields).map(([fieldKey,f])=>f.type==="option"?{...f,key:fieldKey,options:f.options.map(optionOf)}:{...f,key:fieldKey})}))}}function parseContentModel(definition){const parsed=contentModelSchema.safeParse(toContentModel(definition));if(parsed.success)return parsed.data;const problems=parsed.error.issues.map(i=>`${i.path.join(".")}: ${i.message}`);throw new Error(`Invalid SuiteOp content model:
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkLVFRVNT3_cjs = require('./chunk-LVFRVNT3.cjs');
3
+ var chunkEHQFWSP6_cjs = require('./chunk-EHQFWSP6.cjs');
4
4
  var zod = require('zod');
5
5
 
6
- var storefrontRatePlanQuoteSchema=zod.z.object({ratePlanId:zod.z.string(),name:zod.z.string(),accommodationMinor:zod.z.number().int(),feesMinor:zod.z.number().int(),taxesMinor:zod.z.number().int(),totalMinor:zod.z.number().int().positive(),currency:zod.z.string().regex(/^[a-z]{3}$/),cancellationPolicy:zod.z.string().nullable(),cancellationFee:zod.z.unknown().optional(),quoteRef:zod.z.string()});chunkLVFRVNT3_cjs.withStayRules(zod.z.object({listingId:zod.z.uuid({message:"validation.storefront.listing_invalid"}),checkIn:chunkLVFRVNT3_cjs.storefrontDateSchema,checkOut:chunkLVFRVNT3_cjs.storefrontDateSchema,guests:chunkLVFRVNT3_cjs.storefrontGuestsSchema}));var storefrontQuoteSchema=zod.z.object({quoteRef:zod.z.string(),propertyId:zod.z.uuid(),checkIn:chunkLVFRVNT3_cjs.storefrontDateSchema,checkOut:chunkLVFRVNT3_cjs.storefrontDateSchema,guests:zod.z.number().int().positive(),ratePlans:zod.z.array(storefrontRatePlanQuoteSchema).min(1),expiresAt:zod.z.iso.datetime()});var STOREFRONT_ERROR_CODES=["wrong_region","origin_not_allowed","origin_required","site_archived","not_bookable","quote_invalid","quote_expired","price_changed","currency_unsupported","payment_declined","session_expired","rate_limited","contact_not_configured","payment_account_unavailable","idempotency_key_required","idempotency_key_reused","payment_mode_unsupported","payment_not_authorized","payment_method_required","site_not_published","preview_read_only","bookings_closed","extras_invalid","UNAUTHORIZED","VALIDATION_ERROR","NOT_FOUND","site_not_found","upstream_timeout","timeout","network","invalid_response","internal_error","checkout_unavailable"];var StorefrontError=class extends Error{name="StorefrontError";status;type;code;requestId;details;constructor(init){super(init.message,init.cause===void 0?void 0:{cause:init.cause});this.status=init.status;this.code=init.code;this.type=init.type??init.code;this.requestId=init.requestId??null;this.details=init.details??{};}};var PriceChangedError=class extends StorefrontError{name="PriceChangedError";quote;requiresNewSession;constructor(init){super(init);const raw=this.details["quote"];const parsed=storefrontQuoteSchema.safeParse(raw);this.quote=parsed.success?parsed.data:null;this.requiresNewSession=this.details["requiresNewSession"]===true||raw!=null&&!parsed.success;}};var WrongRegionError=class extends StorefrontError{name="WrongRegionError";region;baseUrl;constructor(init){super(init);const{region,baseUrl}=this.details;this.region=region==="us"||region==="eu"||region==="apac"?region:null;this.baseUrl=typeof baseUrl==="string"?baseUrl:null;}};var RateLimitedError=class extends StorefrontError{name="RateLimitedError";retryAfterSec;scope;constructor(init){super(init);this.retryAfterSec=init.retryAfterSec;const{scope}=this.details;this.scope=scope==="key"||scope==="ip"||scope==="pms"?scope:null;}};var StorefrontTimeoutError=class extends StorefrontError{name="StorefrontTimeoutError";constructor(timeoutMs,requestId=null){super({status:0,code:"timeout",message:`No response within ${timeoutMs} ms`,requestId});}};var StorefrontNetworkError=class extends StorefrontError{name="StorefrontNetworkError";constructor(cause){super({status:0,code:"network",message:"The Storefront API could not be reached",cause});}};var StorefrontConfigError=class extends Error{name="StorefrontConfigError"};function isRecord(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)}function parseRetryAfter(header){if(header===null)return null;const seconds=Number(header);if(Number.isFinite(seconds)&&seconds>=0)return Math.ceil(seconds);const at=Date.parse(header);return Number.isNaN(at)?null:Math.max(0,Math.ceil((at-Date.now())/1e3))}function errorFromResponse(response,body){const headerRequestId=response.headers.get("x-request-id");const wire=isRecord(body)&&isRecord(body["error"])?body["error"]:null;const meta=isRecord(body)&&isRecord(body["meta"])?body["meta"]:null;const requestId=typeof meta?.["requestId"]==="string"?meta["requestId"]:headerRequestId;if(!wire||typeof wire["code"]!=="string"){return new StorefrontError({status:response.status,code:"internal_error",message:`The Storefront API answered ${response.status}`,requestId})}const init={status:response.status,code:wire["code"],type:typeof wire["type"]==="string"?wire["type"]:wire["code"],message:typeof wire["message"]==="string"?wire["message"]:wire["code"],requestId,details:isRecord(wire["details"])?wire["details"]:{}};switch(init.code){case "price_changed":return new PriceChangedError(init);case "wrong_region":return new WrongRegionError(init);case "rate_limited":return new RateLimitedError({...init,retryAfterSec:parseRetryAfter(response.headers.get("retry-after"))??parseRetryAfter(typeof init.details?.["retryAfterSeconds"]==="number"?String(init.details["retryAfterSeconds"]):null)});default:return new StorefrontError(init)}}
6
+ var storefrontRatePlanQuoteSchema=zod.z.object({ratePlanId:zod.z.string(),name:zod.z.string(),accommodationMinor:zod.z.number().int(),feesMinor:zod.z.number().int(),taxesMinor:zod.z.number().int(),totalMinor:zod.z.number().int().positive(),currency:zod.z.string().regex(/^[a-z]{3}$/),cancellationPolicy:zod.z.string().nullable(),cancellationFee:zod.z.unknown().optional(),quoteRef:zod.z.string()});chunkEHQFWSP6_cjs.withStayRules(zod.z.object({listingId:zod.z.uuid({message:"validation.storefront.listing_invalid"}),checkIn:chunkEHQFWSP6_cjs.storefrontDateSchema,checkOut:chunkEHQFWSP6_cjs.storefrontDateSchema,guests:chunkEHQFWSP6_cjs.storefrontGuestsSchema}));var storefrontQuoteSchema=zod.z.object({quoteRef:zod.z.string(),propertyId:zod.z.uuid(),checkIn:chunkEHQFWSP6_cjs.storefrontDateSchema,checkOut:chunkEHQFWSP6_cjs.storefrontDateSchema,guests:zod.z.number().int().positive(),ratePlans:zod.z.array(storefrontRatePlanQuoteSchema).min(1),expiresAt:zod.z.iso.datetime()});var STOREFRONT_ERROR_CODES=["wrong_region","origin_not_allowed","origin_required","site_archived","not_bookable","quote_invalid","quote_expired","price_changed","currency_unsupported","payment_declined","session_expired","rate_limited","contact_not_configured","payment_account_unavailable","idempotency_key_required","idempotency_key_reused","payment_mode_unsupported","payment_not_authorized","payment_method_required","site_not_published","preview_read_only","bookings_closed","extras_invalid","UNAUTHORIZED","VALIDATION_ERROR","NOT_FOUND","site_not_found","upstream_timeout","timeout","network","invalid_response","internal_error","checkout_unavailable"];var StorefrontError=class extends Error{name="StorefrontError";status;type;code;requestId;details;constructor(init){super(init.message,init.cause===void 0?void 0:{cause:init.cause});this.status=init.status;this.code=init.code;this.type=init.type??init.code;this.requestId=init.requestId??null;this.details=init.details??{};}};var PriceChangedError=class extends StorefrontError{name="PriceChangedError";quote;requiresNewSession;constructor(init){super(init);const raw=this.details["quote"];const parsed=storefrontQuoteSchema.safeParse(raw);this.quote=parsed.success?parsed.data:null;this.requiresNewSession=this.details["requiresNewSession"]===true||raw!=null&&!parsed.success;}};var WrongRegionError=class extends StorefrontError{name="WrongRegionError";region;baseUrl;constructor(init){super(init);const{region,baseUrl}=this.details;this.region=region==="us"||region==="eu"||region==="apac"?region:null;this.baseUrl=typeof baseUrl==="string"?baseUrl:null;}};var RateLimitedError=class extends StorefrontError{name="RateLimitedError";retryAfterSec;scope;constructor(init){super(init);this.retryAfterSec=init.retryAfterSec;const{scope}=this.details;this.scope=scope==="key"||scope==="ip"||scope==="pms"?scope:null;}};var StorefrontTimeoutError=class extends StorefrontError{name="StorefrontTimeoutError";constructor(timeoutMs,requestId=null){super({status:0,code:"timeout",message:`No response within ${timeoutMs} ms`,requestId});}};var StorefrontNetworkError=class extends StorefrontError{name="StorefrontNetworkError";constructor(cause){super({status:0,code:"network",message:"The Storefront API could not be reached",cause});}};var StorefrontConfigError=class extends Error{name="StorefrontConfigError"};function isRecord(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)}function parseRetryAfter(header){if(header===null)return null;const seconds=Number(header);if(Number.isFinite(seconds)&&seconds>=0)return Math.ceil(seconds);const at=Date.parse(header);return Number.isNaN(at)?null:Math.max(0,Math.ceil((at-Date.now())/1e3))}function errorFromResponse(response,body){const headerRequestId=response.headers.get("x-request-id");const wire=isRecord(body)&&isRecord(body["error"])?body["error"]:null;const meta=isRecord(body)&&isRecord(body["meta"])?body["meta"]:null;const requestId=typeof meta?.["requestId"]==="string"?meta["requestId"]:headerRequestId;if(!wire||typeof wire["code"]!=="string"){return new StorefrontError({status:response.status,code:"internal_error",message:`The Storefront API answered ${response.status}`,requestId})}const init={status:response.status,code:wire["code"],type:typeof wire["type"]==="string"?wire["type"]:wire["code"],message:typeof wire["message"]==="string"?wire["message"]:wire["code"],requestId,details:isRecord(wire["details"])?wire["details"]:{}};switch(init.code){case "price_changed":return new PriceChangedError(init);case "wrong_region":return new WrongRegionError(init);case "rate_limited":return new RateLimitedError({...init,retryAfterSec:parseRetryAfter(response.headers.get("retry-after"))??parseRetryAfter(typeof init.details?.["retryAfterSeconds"]==="number"?String(init.details["retryAfterSeconds"]):null)});default:return new StorefrontError(init)}}
7
7
 
8
8
  exports.PriceChangedError = PriceChangedError;
9
9
  exports.RateLimitedError = RateLimitedError;
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+
5
+ var emailField=zod.z.string().trim().toLowerCase().pipe(zod.z.email("validation.email_invalid"));zod.z.string().trim().min(1,"validation.email_required").pipe(emailField);var trimmedEmailField=zod.z.string().trim().pipe(zod.z.email("validation.email_invalid"));var requiredTrimmedEmailField=zod.z.string().trim().min(1,"validation.email_required").pipe(trimmedEmailField);zod.z.string().nullish().transform((raw,ctx)=>{if(raw===void 0)return void 0;const trimmed=(raw??"").trim().toLowerCase();if(!trimmed)return null;if(!zod.z.email().safeParse(trimmed).success){ctx.addIssue({code:"custom",message:"validation.email_invalid"});return zod.z.NEVER}return trimmed});var storefrontIdSchema=zod.z.uuid();var storefrontSiteSchema=zod.z.object({id:zod.z.uuid(),name:zod.z.string(),slug:zod.z.string(),isActive:zod.z.boolean(),enableWebChat:zod.z.boolean(),mapEmbedHost:zod.z.string().nullable(),countryCode:zod.z.string().nullish(),bookingsOpen:zod.z.boolean().optional()});var storefrontListingSummarySchema=zod.z.object({id:zod.z.uuid(),buildingId:zod.z.uuid(),sortOrder:zod.z.number().int(),name:zod.z.string(),coverImageUrl:zod.z.string().nullable(),city:zod.z.string().nullable(),state:zod.z.string().nullable(),bedroomCount:zod.z.number().int().nullable(),bathroomCount:zod.z.number().nullable(),maxGuests:zod.z.number().int().nullable(),averageRating:zod.z.number().nullable(),latitude:zod.z.number().nullable(),longitude:zod.z.number().nullable(),bookable:zod.z.boolean(),fromPriceMinor:zod.z.number().int().nonnegative().nullish(),currency:zod.z.string().nullish()});var storefrontImageSchema=zod.z.object({url:zod.z.string(),alt:zod.z.string().nullable(),width:zod.z.number().int().nullable(),height:zod.z.number().int().nullable()});var storefrontListingSchema=storefrontListingSummarySchema.extend({buildingSlug:zod.z.string(),buildingAddress:zod.z.unknown(),description:zod.z.string().nullable(),amenities:zod.z.array(zod.z.string()),pictures:zod.z.unknown(),images:zod.z.array(storefrontImageSchema).optional(),rooms:zod.z.unknown(),houseRules:zod.z.string().nullable(),checkInTime:zod.z.string().nullable(),checkOutTime:zod.z.string().nullable(),beds:zod.z.number().nullable(),countryCode:zod.z.string().nullish()});var STOREFRONT_LISTING_SORTS=["recommended","price_asc","price_desc","rating"];var asList=value=>value===void 0?void 0:Array.isArray(value)?value:[value];var boundsSchema=zod.z.string().transform(value=>value.split(",").map(part=>part.trim()===""?NaN:Number(part))).pipe(zod.z.tuple([zod.z.number().min(-90).max(90),zod.z.number().min(-180).max(180),zod.z.number().min(-90).max(90),zod.z.number().min(-180).max(180)]).refine(([swLat,,neLat])=>swLat<=neLat)).transform(([swLat,swLng,neLat,neLng])=>({swLat,swLng,neLat,neLng}));zod.z.object({location:zod.z.preprocess(value=>asList(value)?.flatMap(v=>typeof v==="string"?v.split(","):[v]),zod.z.array(zod.z.string().trim().min(1).max(200)).min(1).max(50).optional()).optional(),building:zod.z.uuid().optional(),guests:zod.z.coerce.number().int().min(1).max(100).optional(),bedrooms:zod.z.coerce.number().int().min(0).max(50).optional(),currency:zod.z.string().trim().regex(/^[A-Za-z]{3}$/).transform(value=>value.toLowerCase()).optional(),priceMin:zod.z.coerce.number().int().min(0).optional(),priceMax:zod.z.coerce.number().int().min(0).optional(),amenities:zod.z.preprocess(asList,zod.z.array(zod.z.string().trim().min(1).max(200)).min(1).max(30).optional()).optional(),bounds:boundsSchema.optional(),sort:zod.z.enum(STOREFRONT_LISTING_SORTS).optional(),facets:zod.z.enum(["0","1","true","false"]).transform(value=>value==="1"||value==="true").optional(),limit:zod.z.coerce.number().int().min(1).max(100).default(50),offset:zod.z.coerce.number().int().min(0).max(1e4).default(0)}).refine(q=>q.currency!==void 0||q.priceMin===void 0&&q.priceMax===void 0,{path:["currency"],message:"validation.required"}).refine(q=>q.priceMin===void 0||q.priceMax===void 0||q.priceMin<=q.priceMax,{path:["priceMax"],message:"validation.invalid"});var storefrontListingFacetsSchema=zod.z.object({total:zod.z.number().int(),areas:zod.z.array(zod.z.object({id:zod.z.uuid(),slug:zod.z.string().nullable(),count:zod.z.number().int()})),bedrooms:zod.z.array(zod.z.object({bedrooms:zod.z.number().int(),count:zod.z.number().int()})),price:zod.z.object({min:zod.z.number().int(),max:zod.z.number().int(),currency:zod.z.string().nullable(),buckets:zod.z.array(zod.z.number().int()).length(24)}).nullable()});var storefrontBuildingSchema=zod.z.object({id:zod.z.uuid(),locationId:zod.z.uuid().nullable(),nameId:zod.z.uuid().nullable(),descriptionId:zod.z.uuid().nullable(),slug:zod.z.string(),imageId:zod.z.uuid().nullable(),latitude:zod.z.number().nullable(),longitude:zod.z.number().nullable(),address:zod.z.unknown(),name:zod.z.string().nullish(),description:zod.z.string().nullish(),imageUrl:zod.z.string().nullish(),images:zod.z.array(storefrontImageSchema).nullish(),sortOrder:zod.z.number().int().nullish(),listingCount:zod.z.number().int().nullish(),fields:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),zod.z.unknown())).nullish()});var storefrontLocationSchema=zod.z.object({id:zod.z.uuid(),type:zod.z.string(),parentId:zod.z.uuid().nullable(),nameId:zod.z.uuid().nullable(),slug:zod.z.string().nullable(),imageId:zod.z.uuid().nullable(),latitude:zod.z.number().nullable(),longitude:zod.z.number().nullable(),address:zod.z.unknown(),sortOrder:zod.z.number().int(),name:zod.z.string().nullish(),description:zod.z.string().nullish(),imageUrl:zod.z.string().nullish(),images:zod.z.array(storefrontImageSchema).nullish(),buildingCount:zod.z.number().int().nullish(),fields:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),zod.z.unknown())).nullish()});zod.z.object({locale:zod.z.string().max(35).optional().catch(void 0)});var storefrontReviewSchema=zod.z.object({id:zod.z.uuid(),listingId:zod.z.uuid().nullable(),reviewedAt:zod.z.string().nullable(),rating:zod.z.number().nullable(),publicReview:zod.z.string(),source:zod.z.string().nullable()});zod.z.object({listingId:zod.z.uuid().optional(),limit:zod.z.coerce.number().int().min(1).max(100).default(20),offset:zod.z.coerce.number().int().min(0).max(1e4).default(0)});zod.z.object({name:zod.z.string().trim().min(1,"validation.name_required").max(200,"validation.name_max_length"),email:requiredTrimmedEmailField,subject:zod.z.string().trim().min(1,"validation.title_required").max(300,"validation.title_max_length"),message:zod.z.string().trim().min(10,"validation.message_min_length").max(1e4,"validation.message_max_length")});var storefrontContactResultSchema=zod.z.object({sent:zod.z.literal(true)});var storefrontContentRefSchema=zod.z.object({kind:zod.z.string(),id:zod.z.uuid(),slug:zod.z.string().nullable()});var storefrontContentItemSchema=zod.z.object({id:zod.z.uuid(),type:zod.z.string(),slug:zod.z.string().nullable(),publishedAt:zod.z.string().nullable(),updatedAt:zod.z.string(),sortOrder:zod.z.number().int(),fields:zod.z.record(zod.z.string(),zod.z.unknown())});var storefrontContentFieldDefSchema=zod.z.object({key:zod.z.string(),type:zod.z.string()}).catchall(zod.z.unknown());var storefrontContentModelSchema=zod.z.object({version:zod.z.number().int(),types:zod.z.array(zod.z.object({key:zod.z.string(),kind:zod.z.string(),fields:zod.z.array(storefrontContentFieldDefSchema)}).catchall(zod.z.unknown()))});zod.z.object({limit:zod.z.coerce.number().int().min(1).max(100).default(20),offset:zod.z.coerce.number().int().min(0).max(1e4).default(0),locale:zod.z.string().max(35).optional().catch(void 0)});zod.z.string().regex(/^[a-z][a-z0-9_]{0,39}$/);zod.z.string().min(1).max(120).regex(/^[a-z0-9-]+$/);
6
+
7
+ exports.requiredTrimmedEmailField = requiredTrimmedEmailField;
8
+ exports.storefrontBuildingSchema = storefrontBuildingSchema;
9
+ exports.storefrontContactResultSchema = storefrontContactResultSchema;
10
+ exports.storefrontContentItemSchema = storefrontContentItemSchema;
11
+ exports.storefrontContentModelSchema = storefrontContentModelSchema;
12
+ exports.storefrontContentRefSchema = storefrontContentRefSchema;
13
+ exports.storefrontIdSchema = storefrontIdSchema;
14
+ exports.storefrontImageSchema = storefrontImageSchema;
15
+ exports.storefrontListingFacetsSchema = storefrontListingFacetsSchema;
16
+ exports.storefrontListingSchema = storefrontListingSchema;
17
+ exports.storefrontListingSummarySchema = storefrontListingSummarySchema;
18
+ exports.storefrontLocationSchema = storefrontLocationSchema;
19
+ exports.storefrontReviewSchema = storefrontReviewSchema;
20
+ exports.storefrontSiteSchema = storefrontSiteSchema;
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkE5CGGMCO_cjs = require('./chunk-E5CGGMCO.cjs');
4
- var chunkUSOISC2R_cjs = require('./chunk-USOISC2R.cjs');
3
+ var chunkLY73ZYN5_cjs = require('./chunk-LY73ZYN5.cjs');
4
+ var chunkJ5FZ4WDQ_cjs = require('./chunk-J5FZ4WDQ.cjs');
5
5
  var zod = require('zod');
6
6
 
7
7
  var CONTENT_FIELD_TYPES=["text","rich_text","image","gallery","number","boolean","date","option","link","reference","references"];var CONTENT_TYPE_KINDS=["collection","section","fields"];var CONTENT_SUBJECT_KINDS=["building","area"];var CONTENT_REFERENCE_KINDS=["listing","building","area"];var MAX_CONTENT_TYPES=40;var MAX_CONTENT_FIELDS=40;var contentKeySchema=zod.z.string().regex(/^[a-z][a-z0-9_]{0,39}$/,"validation.invalid_format");var contentLocalizedSchema=zod.z.union([zod.z.string().min(1).max(120),zod.z.record(zod.z.string().min(2).max(35),zod.z.string().min(1).max(120))]);var COLLECTION_TARGET=/^collection:[a-z][a-z0-9_]{0,39}$/;var contentReferenceTargetSchema=zod.z.union([zod.z.enum(CONTENT_REFERENCE_KINDS),zod.z.string().regex(COLLECTION_TARGET,"validation.invalid_format")]);var TEXT_TYPES=new Set(["text","rich_text"]);var LIST_TYPES=new Set(["gallery","references"]);var REFERENCE_TYPES=new Set(["reference","references"]);var contentFieldSchema=zod.z.object({key:contentKeySchema,type:zod.z.enum(CONTENT_FIELD_TYPES),label:contentLocalizedSchema,help:contentLocalizedSchema.optional(),required:zod.z.boolean().default(false),translatable:zod.z.boolean().optional(),maxLength:zod.z.number().int().min(1).max(6e4).optional(),options:zod.z.array(zod.z.object({value:contentKeySchema,label:contentLocalizedSchema})).min(1).max(50).optional(),to:contentReferenceTargetSchema.optional(),max:zod.z.number().int().min(1).max(100).optional(),removed:zod.z.boolean().optional()}).superRefine((field2,ctx)=>{if(field2.type==="option"&&!field2.options?.length){ctx.addIssue({code:"custom",path:["options"],message:"validation.required"});}if(field2.options&&new Set(field2.options.map(o=>o.value)).size!==field2.options.length){ctx.addIssue({code:"custom",path:["options"],message:"validation.invalid"});}if(REFERENCE_TYPES.has(field2.type)&&!field2.to){ctx.addIssue({code:"custom",path:["to"],message:"validation.required"});}if(field2.maxLength!==void 0&&!TEXT_TYPES.has(field2.type)){ctx.addIssue({code:"custom",path:["maxLength"],message:"validation.invalid"});}if(field2.max!==void 0&&!LIST_TYPES.has(field2.type)){ctx.addIssue({code:"custom",path:["max"],message:"validation.invalid"});}});var contentTypeSchema=zod.z.object({key:contentKeySchema,kind:zod.z.enum(CONTENT_TYPE_KINDS),label:contentLocalizedSchema,description:contentLocalizedSchema.optional(),attachesTo:zod.z.enum(CONTENT_SUBJECT_KINDS).optional(),titleField:contentKeySchema.optional(),routable:zod.z.boolean().default(false),drafts:zod.z.boolean().default(false),order:zod.z.enum(["manual","newest"]).default("manual"),fields:zod.z.array(contentFieldSchema).min(1).max(MAX_CONTENT_FIELDS)}).superRefine((type,ctx)=>{const keys=type.fields.map(f=>f.key);keys.forEach((key,i)=>{if(keys.indexOf(key)!==i){ctx.addIssue({code:"custom",path:["fields",i,"key"],message:"validation.invalid"});}});if(type.kind==="fields"!==(type.attachesTo!==void 0)){ctx.addIssue({code:"custom",path:["attachesTo"],message:"validation.invalid"});}if(type.kind==="collection"){const title=type.fields.find(f=>f.key===type.titleField);if(!title||title.type!=="text"){ctx.addIssue({code:"custom",path:["titleField"],message:"validation.invalid"});}}else if(type.titleField!==void 0){ctx.addIssue({code:"custom",path:["titleField"],message:"validation.invalid"});}});var contentModelSchema=zod.z.object({version:zod.z.literal(1),types:zod.z.array(contentTypeSchema).max(MAX_CONTENT_TYPES)}).superRefine((model,ctx)=>{const keys=model.types.map(t=>t.key);const collections=new Set(model.types.filter(t=>t.kind==="collection").map(t=>t.key));model.types.forEach((type,i)=>{if(keys.indexOf(type.key)!==i){ctx.addIssue({code:"custom",path:["types",i,"key"],message:"validation.invalid"});}type.fields.forEach((field2,j)=>{const target=field2.to?.startsWith("collection:")?field2.to.slice(11):null;if(target!==null&&!collections.has(target)){ctx.addIssue({code:"custom",path:["types",i,"fields",j,"to"],message:"validation.invalid"});}});});});function defineContent(definition){return definition}var field={text:o=>({...o,type:"text"}),richText:o=>({...o,type:"rich_text"}),image:o=>({...o,type:"image"}),gallery:o=>({...o,type:"gallery"}),number:o=>({...o,type:"number"}),boolean:o=>({...o,type:"boolean"}),date:o=>({...o,type:"date"}),option:o=>({...o,type:"option"}),link:o=>({...o,type:"link"}),reference:o=>({...o,type:"reference"}),references:o=>({...o,type:"references"})};var optionOf=choice=>typeof choice==="string"?{value:choice,label:choice}:choice;function toContentModel(definition){return {version:1,types:Object.entries(definition).map(([key,type])=>({...type,key,fields:Object.entries(type.fields).map(([fieldKey,f])=>f.type==="option"?{...f,key:fieldKey,options:f.options.map(optionOf)}:{...f,key:fieldKey})}))}}function parseContentModel(definition){const parsed=contentModelSchema.safeParse(toContentModel(definition));if(parsed.success)return parsed.data;const problems=parsed.error.issues.map(i=>`${i.path.join(".")}: ${i.message}`);throw new Error(`Invalid SuiteOp content model:
8
- ${problems.join("\n ")}`)}var DAY=/^\d{4}-\d{2}-\d{2}$/;var linkSchema=zod.z.object({url:zod.z.string(),label:zod.z.string().optional()});function valueSchema(f){switch(f.type){case "text":case "rich_text":return zod.z.string();case "date":return zod.z.string().regex(DAY);case "image":return zod.z.union([chunkE5CGGMCO_cjs.storefrontImageSchema,zod.z.array(chunkE5CGGMCO_cjs.storefrontImageSchema).min(1).transform(photos=>photos[0])]);case "gallery":return zod.z.array(chunkE5CGGMCO_cjs.storefrontImageSchema);case "number":return zod.z.number();case "boolean":return zod.z.boolean();case "option":{const values=new Set(f.options.map(o=>optionOf(o).value));return zod.z.string().refine(v=>values.has(v))}case "link":return linkSchema;case "reference":return chunkE5CGGMCO_cjs.storefrontContentRefSchema;case "references":return zod.z.array(chunkE5CGGMCO_cjs.storefrontContentRefSchema)}}var isList=f=>f.type==="gallery"||f.type==="references";function readFields(type,values){const out={};for(const[key,f]of Object.entries(type.fields)){const raw=values?.[key];const parsed=raw===void 0||raw===null?null:valueSchema(f).safeParse(raw);out[key]=parsed?.success?parsed.data:isList(f)?[]:null;}return out}function toItem(type,item){return {id:item.id,slug:item.slug,publishedAt:item.publishedAt,updatedAt:item.updatedAt,sortOrder:item.sortOrder,fields:readFields(type,item.fields)}}async function orEmpty(read,empty){try{return await read}catch(err){if(err instanceof chunkUSOISC2R_cjs.StorefrontError&&err.status===404)return empty();throw err}}function createContentReader(client,definition){return {collection:key=>({async list(query,opts){const page=await orEmpty(client.collections.list(key,query,opts),()=>({items:[],total:0,limit:query?.limit??20,offset:query?.offset??0}));return {...page,items:page.items.map(item=>toItem(definition[key],item))}},async get(slugOrId,opts){const item=await client.collections.get(key,slugOrId,opts);return item?toItem(definition[key],item):null}}),section:key=>({get:async opts=>toItem(definition[key],await orEmpty(client.sections.get(key,opts),()=>({id:"",type:key,slug:null,publishedAt:null,updatedAt:new Date(0).toISOString(),sortOrder:0,fields:{}})))}),fieldsOf:(key,record)=>readFields(definition[key],record.fields?.[key])}}
8
+ ${problems.join("\n ")}`)}var DAY=/^\d{4}-\d{2}-\d{2}$/;var linkSchema=zod.z.object({url:zod.z.string(),label:zod.z.string().optional()});function valueSchema(f){switch(f.type){case "text":case "rich_text":return zod.z.string();case "date":return zod.z.string().regex(DAY);case "image":return zod.z.union([chunkLY73ZYN5_cjs.storefrontImageSchema,zod.z.array(chunkLY73ZYN5_cjs.storefrontImageSchema).min(1).transform(photos=>photos[0])]);case "gallery":return zod.z.array(chunkLY73ZYN5_cjs.storefrontImageSchema);case "number":return zod.z.number();case "boolean":return zod.z.boolean();case "option":{const values=new Set(f.options.map(o=>optionOf(o).value));return zod.z.string().refine(v=>values.has(v))}case "link":return linkSchema;case "reference":return chunkLY73ZYN5_cjs.storefrontContentRefSchema;case "references":return zod.z.array(chunkLY73ZYN5_cjs.storefrontContentRefSchema)}}var isList=f=>f.type==="gallery"||f.type==="references";function readFields(type,values){const out={};for(const[key,f]of Object.entries(type.fields)){const raw=values?.[key];const parsed=raw===void 0||raw===null?null:valueSchema(f).safeParse(raw);out[key]=parsed?.success?parsed.data:isList(f)?[]:null;}return out}function toItem(type,item){return {id:item.id,slug:item.slug,publishedAt:item.publishedAt,updatedAt:item.updatedAt,sortOrder:item.sortOrder,fields:readFields(type,item.fields)}}async function orEmpty(read,empty){try{return await read}catch(err){if(err instanceof chunkJ5FZ4WDQ_cjs.StorefrontError&&err.status===404)return empty();throw err}}function createContentReader(client,definition){return {collection:key=>({async list(query,opts){const page=await orEmpty(client.collections.list(key,query,opts),()=>({items:[],total:0,limit:query?.limit??20,offset:query?.offset??0}));return {...page,items:page.items.map(item=>toItem(definition[key],item))}},async get(slugOrId,opts){const item=await client.collections.get(key,slugOrId,opts);return item?toItem(definition[key],item):null}}),section:key=>({get:async opts=>toItem(definition[key],await orEmpty(client.sections.get(key,opts),()=>({id:"",type:key,slug:null,publishedAt:null,updatedAt:new Date(0).toISOString(),sortOrder:0,fields:{}})))}),fieldsOf:(key,record)=>readFields(definition[key],record.fields?.[key])}}
9
9
 
10
10
  exports.contentModelSchema = contentModelSchema;
11
11
  exports.createContentReader = createContentReader;