@weatherboard/cms 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/dist/next.cjs +4 -2
- package/dist/next.cjs.map +4 -4
- package/dist/next.d.cts +2 -0
- package/dist/next.d.mts +2 -0
- package/dist/next.d.ts +2 -0
- package/dist/next.mjs +4 -2
- package/dist/next.mjs.map +4 -4
- package/dist/runtime/site-readers.d.cts +170 -0
- package/dist/runtime/site-readers.d.mts +170 -0
- package/dist/runtime/site-readers.d.ts +170 -0
- package/dist/runtime/test-fixtures/saved-documents.d.cts +85 -0
- package/dist/runtime/test-fixtures/saved-documents.d.mts +85 -0
- package/dist/runtime/test-fixtures/saved-documents.d.ts +85 -0
- package/dist/server.cjs +4 -2
- package/dist/server.cjs.map +4 -4
- package/dist/server.d.cts +2 -0
- package/dist/server.d.mts +2 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.mjs +4 -2
- package/dist/server.mjs.map +4 -4
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -6,6 +6,51 @@ hero types without a provider SDK or environment access. Server reads use
|
|
|
6
6
|
`@weatherboard/cms/server` or `/next`, with the `/sanity` adapter; `/webhook`
|
|
7
7
|
provides portable signature verification. `/testing` and `/guard` are tooling.
|
|
8
8
|
|
|
9
|
+
## Server site readers (0.8.0)
|
|
10
|
+
|
|
11
|
+
Import `openVacanciesQuery`, `locationsQuery`, `scheduleQuery`, their parsers and
|
|
12
|
+
tag helpers from `@weatherboard/cms/next` in a Next server component, or from
|
|
13
|
+
`@weatherboard/cms/server` in another server runtime. Supply a configured
|
|
14
|
+
`createNextCmsReader` reader and repository data to `resolveWithFallback`:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { createNextCmsReader, openVacanciesQuery, resolveWithFallback } from '@weatherboard/cms/next';
|
|
18
|
+
|
|
19
|
+
const reader = createNextCmsReader({ adapter });
|
|
20
|
+
const validateVacancy = (entry: Record<string, unknown>): string | null =>
|
|
21
|
+
typeof entry.title === 'string' && entry.title.trim() ? null : 'missing title';
|
|
22
|
+
const result = await resolveWithFallback(reader, openVacanciesQuery('2026-10-19', validateVacancy), []);
|
|
23
|
+
// result.source is 'sanity', 'mixed' or 'fallback'.
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The client supplies the validator; the package supplies the pipeline. All list
|
|
27
|
+
readers require a client validator with no default: `openVacanciesQuery` takes
|
|
28
|
+
one that returns a refusal reason or `null`, while `locationsQuery` and
|
|
29
|
+
`businessLocationsQuery` take one that returns a validated location or throws.
|
|
30
|
+
The package checks document types and shapes, then runs identity validation,
|
|
31
|
+
duplicate detection, full parsing with per-field fallback, repository merging
|
|
32
|
+
and source reporting in that order. The client decides business validity on
|
|
33
|
+
the merged result, including cross-field rules such as required contact details.
|
|
34
|
+
|
|
35
|
+
The existing Sanity adapter supplies the request timeout and forwards hourly
|
|
36
|
+
cache and scoped revalidation tags. `locationsQuery` merges each matching
|
|
37
|
+
published document into the supplied `LocationFields[]` fallback by slug and
|
|
38
|
+
records fallback fields. For a nested business-location shape,
|
|
39
|
+
`businessLocationsQuery` and `parseBusinessLocation` preserve repository-only
|
|
40
|
+
fields and require the host's validator for cross-field rules. `scheduleQuery` preserves repository-only stop fields
|
|
41
|
+
when names match. The host keeps its repository data and chooses how to display
|
|
42
|
+
the source. `menuQuery`, `parseMenuDocument` and `menuTags` remain the menu API.
|
|
43
|
+
|
|
44
|
+
`openVacanciesQuery`, `parseVacancies` and `parseVacancyDocument` require the
|
|
45
|
+
consumer's validator, which receives each raw projected entry before display
|
|
46
|
+
fields are derived. The query resolves `workLocation` to `{ _id, name }` and
|
|
47
|
+
depends on both vacancy and location tags. The display label uses the resolved
|
|
48
|
+
name, then a non-`Other` legacy `location`, then `locationNote`; a dangling
|
|
49
|
+
reference falls through to the legacy fields. `locationId` is the resolved
|
|
50
|
+
location's ID or `null`. An entry with no display label is structurally dropped.
|
|
51
|
+
Legacy documents remain readable. Consumers whose validators require the legacy
|
|
52
|
+
string must update them before migrating documents to references.
|
|
53
|
+
|
|
9
54
|
## Site hero
|
|
10
55
|
|
|
11
56
|
The singleton `siteHero` keeps its existing heading (1–80 characters, single
|
package/dist/next.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var P=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var _e=(e,n)=>{for(var t in n)P(e,t,{get:n[t],enumerable:!0})},Ce=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of $e(n))!we.call(e,r)&&r!==t&&P(e,r,{get:()=>n[r],enumerable:!(o=Se(n,r))||o.enumerable});return e};var Te=e=>Ce(P({},"__esModule",{value:!0}),e);var Ke={};_e(Ke,{MENU_DECORATIONS:()=>M,MENU_LAYOUTS:()=>D,MENU_LAYOUT_DEFAULTS:()=>v,businessLocationsQuery:()=>ge,createNextCmsReader:()=>te,createRevalidateRoute:()=>le,locationTags:()=>pe,locationsQuery:()=>me,menuQuery:()=>X,menuTags:()=>V,openVacanciesQuery:()=>de,parseBusinessLocation:()=>B,parseLocationDocument:()=>H,parseMenuDocument:()=>I,parseScheduleDocument:()=>z,parseVacancies:()=>F,parseVacancyDocument:()=>U,resolveWithFallback:()=>ue,scheduleQuery:()=>be,scheduleTags:()=>he,vacancyTags:()=>ce});module.exports=Te(Ke);var An=require("server-only");function Q(e){if(!Array.isArray(e))return!1;for(let n=0;n<e.length;n+=1)if(!Object.hasOwn(e,n))return!1;return!0}var D=["stacked","columns"],M=["none","playful"],v={layout:"stacked",decoration:"none"},L=`_type, _id, _rev, _updatedAt, title, locationKeys, note, signOff,
|
|
2
2
|
variants[]{_key, label, note, sections[]{_key, title, service, items[]{
|
|
3
3
|
_key, name, description, priceNote, dietary, allergenNote, availability,
|
|
4
4
|
prices[]{_key, label, amount{minor, currency}}, extras[]{_key, name, amount{minor, currency}}
|
|
5
|
-
}}}`;function P(e,n){return w(e,{types:["menu"],...n===void 0?{}:{ids:[n]}})}function d(e,n){throw new T("menu",[`${e} ${n}`])}function U(e,n,t=new Set,o){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="object"||e===null)return d(n,"is not plain JSON data");try{if(t.has(e))return d(n,"is not acyclic JSON data");let r=Array.isArray(e),i=Object.getPrototypeOf(e);if(r?i!==Array.prototype:i!==Object.prototype&&i!==null)return d(n,"is not an ordinary saved object");t.add(e);let l=Reflect.ownKeys(e),c=r?[]:{},u=0,m=0;for(let s of l){if(typeof s!="string")return d(n,"has a symbol key");let a=r&&s!=="length"?`${n}[${s}]`:`${n}.${s}`,p;try{p=s==="_id"&&o!==void 0?o:Object.getOwnPropertyDescriptor(e,s)}catch{return d(a,"could not be snapshotted as plain JSON data")}if(!p||!Object.hasOwn(p,"value"))return d(a,"is not a saved data property");if(r&&s==="length"){let k=p.value;if(typeof k!="number"||!Number.isSafeInteger(k)||k<0)return d(a,"is not a saved list length");u=k;continue}if(!p.enumerable||r&&!/^(0|[1-9]\d*)$/.test(s))return d(a,"is not a JSON data property");let f=p.value,g=U(f,a,t);Object.defineProperty(c,s,{value:g,enumerable:!0,writable:!0,configurable:!0}),m++}return r&&(m!==u||c.length!==u)?d(n,"is not a complete saved list"):c}catch(r){if(r instanceof T)throw r;return d(n,"could not be snapshotted as plain JSON data")}finally{t.delete(e)}}function C(e,n){return e===null||typeof e!="object"||Array.isArray(e)||Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null?d(n,"is not an ordinary saved object"):e}function y(e,n,t=!0){return typeof e!="string"||t&&e.trim()===""?d(n,"is not saved text"):e}function S(e,n,t){return e[n]===void 0||e[n]===null?{}:{[n]:y(e[n],`${t}.${n}`,!1)}}function _(e,n,t){return e==null?[]:N(e)?e.map((o,r)=>t(o,`${n}[${String(r)}]`)):d(n,"is not a complete saved list")}function L(e,n){let t=C(e,n);if(typeof t.minor!="number"||!Number.isSafeInteger(t.minor)||t.minor<0)return d(`${n}.minor`,"is not a whole non-negative safe amount");let o=y(t.currency,`${n}.currency`);return/^[A-Z]{3}$/.test(o)?{minor:t.minor,currency:o}:d(`${n}.currency`,"is not a three-letter currency code")}function se(e,n){let t=C(e,n);return{_key:y(t._key,`${n}._key`),amount:L(t.amount,`${n}.amount`),...S(t,"label",n)}}function ae(e,n){let t=C(e,n);return{_key:y(t._key,`${n}._key`),name:y(t.name,`${n}.name`),amount:L(t.amount,`${n}.amount`)}}function le(e,n){let t=C(e,n),o=t.availability??"available";return o!=="available"&&o!=="sold-out"&&o!=="hidden"?d(`${n}.availability`,"is not an availability choice"):{_key:y(t._key,`${n}._key`),name:y(t.name,`${n}.name`),...S(t,"description",n),...S(t,"priceNote",n),...S(t,"allergenNote",n),prices:_(t.prices,`${n}.prices`,se),extras:_(t.extras,`${n}.extras`,ae),dietary:_(t.dietary,`${n}.dietary`,y),availability:o}}function ce(e,n){let t=C(e,n);return{_key:y(t._key,`${n}._key`),title:y(t.title,`${n}.title`),...S(t,"service",n),items:_(t.items,`${n}.items`,le)}}function ue(e,n){let t=C(e,n);return{_key:y(t._key,`${n}._key`),label:y(t.label,`${n}.label`),...S(t,"note",n),sections:_(t.sections,`${n}.sections`,ce)}}function de(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let n=e._id;return typeof n=="string"&&n.trim()!==""&&!/^(drafts|versions)\./.test(n)}function A(e,n="menu"){return ye(U(e,n),n)}function ye(e,n){let t=C(e,n);if(t._type!=="menu")return d(`${n}._type`,"is not menu");if(!de(t))return d(`${n}._id`,"is not a published menu identity");let o=y(t._updatedAt,`${n}._updatedAt`);if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(o)||!Number.isFinite(Date.parse(o)))return d(`${n}._updatedAt`,"is not an update date");let r=_(t.variants,`${n}.variants`,ue);return r.length===0?d(`${n}.variants`,"has no menu choices"):{_type:"menu",_id:y(t._id,`${n}._id`),_rev:y(t._rev,`${n}._rev`),_updatedAt:o,title:y(t.title,`${n}.title`),locationKeys:_(t.locationKeys,`${n}.locationKeys`,y),variants:r,...S(t,"note",n),...Object.hasOwn(t,"signOff")?{signOff:t.signOff}:{}}}function q(e){if(e===null)return!0;try{return A(e),!0}catch{return!1}}var H="malformed-content",T=class extends Error{code=H;documentId;problems;constructor(n,t){super(`${H}: ${n}: ${t.join("; ")}`),this.name="MalformedContentError",this.documentId=n,this.problems=t}};var B=`{..., "sections": coalesce(sections[]{..., _type == "menuBlock" => {menu->{${x}}}, _type == "linkListBlock" => {links[]{..., "page": page->{title, "slug": slug.current}}}}, sections)}`,je=`*[_type == "page" && defined(slug.current)]|order(slug.current asc)${B}`,ve=`*[_type == "page" && slug.current == $slug][0]${B}`;var pe=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,fe=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,me=/^[a-z0-9]{6,12}\.[a-z][a-z0-9_-]{0,63}$/;function z(e){if(!e||!Array.isArray(e.types)||e.types.length===0)throw new TypeError("CMS dependencies require document types");let n=[...e.types];for(let o of n)if(typeof o!="string"||!pe.test(o))throw new TypeError("Invalid CMS document type");if(e.ids!==void 0&&!Array.isArray(e.ids))throw new TypeError("Invalid CMS document IDs");let t=e.ids===void 0?void 0:[...e.ids];for(let o of t??[])if(typeof o!="string"||!fe.test(o)||/^(drafts|versions)\./.test(o))throw new TypeError("Invalid CMS document ID");if(new Set(n).size+new Set(t).size>128)throw new TypeError("Too many CMS tags");return Object.freeze({types:Object.freeze(n),...t===void 0?{}:{ids:Object.freeze(t)}})}function j(e){if(!e||typeof e.name!="string"||!/^[A-Za-z][A-Za-z0-9_.-]{0,127}$/.test(e.name)||typeof e.query!="string"||e.query.trim()===""||typeof e.resolve!="function")throw new TypeError("Invalid CMS query configuration");let n=e.params;if(!n||typeof n!="object"||Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw new TypeError("CMS params must be plain JSON scalars");let t={};for(let o of Reflect.ownKeys(n)){let r=Object.getOwnPropertyDescriptor(n,o);if(typeof o!="string"||!r||!Object.hasOwn(r,"value")||!r.enumerable)throw new TypeError("CMS params must be plain JSON scalars");let i=r.value;if(!(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"&&Number.isFinite(i)))throw new TypeError("CMS params must be plain JSON scalars");Object.defineProperty(t,o,{value:i,enumerable:!0})}return Object.freeze({name:e.name,query:e.query,params:Object.freeze(t),dependencies:z(e.dependencies),resolve:e.resolve})}function w(e,n){if(typeof e!="string"||e.length>77||!me.test(e))throw new TypeError("Invalid CMS scope");let t=z(n),o=[...[...new Set(t.types)].sort().map(r=>`cms:${e}:type:${r}`),...[...new Set(t.ids??[])].sort().map(r=>`cms:${e}:id:${r}`)];return Object.freeze(o)}function F(e){return j({name:"menu.v1",query:`*[_type == "menu" && _id == $id && !(_id in path("drafts.**")) && !(_id in path("versions.**"))][0]{${x}}`,params:{id:e},dependencies:{types:["menu"],ids:[e]},resolve:(n,t)=>{if(!q(t)||t!==null&&t._id!==e)throw new TypeError("Invalid CMS menu fallback");if(n==null)return{data:t,fallbackFields:["$"]};let o=A(n);if(o._id!==e)throw new T("menu",["menu._id does not match the requested document"]);return{data:o,fallbackFields:[]}}})}function J(e){if(!e||!Object.hasOwn(e,"data")||!Array.isArray(e.fallbackFields)||![...e.fallbackFields].every(n=>typeof n=="string"&&(n==="$"||/^[A-Za-z][A-Za-z0-9_.[\]-]{0,127}$/.test(n))))throw new TypeError("Invalid CMS resolution");if(e.warnings!==void 0&&(!Array.isArray(e.warnings)||![...e.warnings].every(n=>n==="siteHero.layout.defaulted"||n==="siteHero.tagline.dropped"||n==="siteHero.taglines.defaulted")))throw new TypeError("Invalid CMS resolution warnings");return{data:e.data,fallbackFields:Object.freeze([...new Set(e.fallbackFields)]),...e.warnings?.length?{warnings:Object.freeze([...new Set(e.warnings)])}:{}}}function Y(e){let n=e?.revalidateSeconds??3600;if(!Number.isSafeInteger(n)||n<3600||!e?.adapter||typeof e.adapter.read!="function"||e.onDiagnostic!==void 0&&typeof e.onDiagnostic!="function")throw new TypeError("Invalid CMS reader configuration");let t=e.adapter;w(t.scope,{types:["ScopeValidation"]});let o=r=>{try{e.onDiagnostic?e.onDiagnostic(r):console.warn(JSON.stringify(r))}catch{}};return{async read(r,i){let l,c,u;try{if(l=j(r),u=w(t.scope,l.dependencies),!i||!Object.hasOwn(i,"fallback"))throw new TypeError;c=J(l.resolve(null,i.fallback))}catch{throw new TypeError("Invalid CMS query or fallback configuration")}let m=(p,f,g)=>(o({event:"cms.fallback",query:l.name,reason:p,fields:["$"],...f===void 0?{}:{status:f},...g?{warnings:g}:{}}),{data:c.data,source:"fallback",fallbackFields:["$"],reason:p,...g?{warnings:g}:{}}),s;try{s=await t.read({name:l.name,query:l.query,params:l.params},{tags:u,revalidateSeconds:n})}catch{return m("network")}if(!s.ok){let f=["configuration","network","timeout","rate-limit","upstream","plan-limit","permission","malformed"].includes(s.reason)?s.reason:"malformed",g=Number.isInteger(s.status)&&(s.status??0)>=100&&(s.status??0)<=599?s.status:void 0;return m(f,g)}if(s.value===null||s.value===void 0)return m("missing");let a;try{a=J(l.resolve(s.value,i.fallback))}catch{return m("malformed")}return a.fallbackFields.includes("$")?{...m("invalid-field",void 0,a.warnings),data:a.data}:a.fallbackFields.length>0?(o({event:"cms.partial-fallback",query:l.name,reason:"invalid-field",fields:a.fallbackFields,...a.warnings?{warnings:a.warnings}:{}}),{...a,source:"mixed",reason:"invalid-field"}):{...a,source:"cms"}}}}var Q=Y;var V=require("next/cache.js");var v="sanity-webhook-signature",ge=/^t=(\d+)[, ]+v1=([^, ]+)$/;var W=new TextEncoder;function he(e){return crypto.subtle.importKey("raw",W.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}function be(e){if(!/^[A-Za-z0-9_-]+={0,2}$/.test(e))return null;let n=e.replace(/-/g,"+").replace(/_/g,"/");try{let t=atob(n),o=new Uint8Array(t.length);for(let r=0;r<t.length;r+=1)o[r]=t.charCodeAt(r);return o}catch{return null}}async function G(e){let{secret:n,rawBody:t,headers:o}=e,r=e.now??Date.now(),i=e.toleranceMs??3e5;if(!n||n.length===0)return{ok:!1,reason:"no-secret"};let l=o.get(v);if(!l)return{ok:!1,reason:"no-signature"};let c=ge.exec(l.trim());if(c===null)return{ok:!1,reason:"malformed-signature"};let u=Number(c[1]),m=c[2]??"";if(!Number.isSafeInteger(u))return{ok:!1,reason:"malformed-signature"};if(u<16094592e5)return{ok:!1,reason:"stale-timestamp"};if(Math.abs(r-u)>i)return{ok:!1,reason:"stale-timestamp"};let s=be(m);if(s===null)return{ok:!1,reason:"malformed-signature"};let a=await he(n);return await crypto.subtle.verify("HMAC",a,s,W.encode(`${u}.${t}`))?{ok:!0}:{ok:!1,reason:"bad-signature"}}var ke=16*1024,we=1500,$e=new TextEncoder;function h(e,n,t={},o=!1){return new Response(o?null:JSON.stringify(n),{status:e,headers:{"Content-Type":"application/json","Cache-Control":"no-store",...t}})}function Se(e,n){if(!n||typeof n!="object"||Array.isArray(n)||Object.keys(n).length===0)throw new TypeError("Invalid CMS invalidation mapping");let t=Object.create(null);for(let o of Reflect.ownKeys(n)){let r=Object.getOwnPropertyDescriptor(n,o);if(typeof o!="string"||!r?.enumerable||!Object.hasOwn(r,"value"))throw new TypeError("Invalid CMS invalidation mapping");let i=r.value;if(!Array.isArray(i)||!i.includes(o))throw new TypeError("Invalid CMS invalidation mapping");w(e,{types:i,ids:["validation"]}),t[o]=Object.freeze([...i])}for(let o of Object.values(t))if(o.some(r=>!Object.hasOwn(t,r)))throw new TypeError("Invalid CMS invalidation mapping");return Object.freeze(t)}function Z(e){return typeof e=="string"&&e.trim()!==""&&$e.encode(e).byteLength>=32}var R=class extends Error{constructor(t){super("Invalid CMS webhook body");this.status=t}status};async function _e(e){let n=e.body?.getReader();if(!n)return"";let t=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),o,r=new Promise((i,l)=>{o=setTimeout(()=>l(new R(400)),we)});try{let i=0,l="";for(;;){let{done:c,value:u}=await Promise.race([n.read(),r]);if(c)return l+t.decode();if(i+=u.byteLength,i>ke)throw new R(413);l+=t.decode(u,{stream:!0})}}catch(i){throw n.cancel().catch(()=>{}),i}finally{clearTimeout(o),n.releaseLock()}}function K(e){let n=e.scope,t=Se(n,e.typeToTags),o=e.secretEnv??"SANITY_REVALIDATE_SECRET",r=e.previousSecretEnv??"SANITY_REVALIDATE_SECRET_PREVIOUS",i=e.env??(()=>process.env),l=e.now??Date.now,c=async u=>{if(u.method!=="POST")return h(405,{error:"Method not allowed"},{Allow:"POST"},u.method==="HEAD");let m,s;try{let b=i(),M=b[o],$=b[r];if(!Z(M)||$!==void 0&&!Z($))throw new Error;m=M,s=$}catch{return h(503,{error:"COULD NOT ANSWER: revalidation configuration unavailable"})}let a=u.headers.get(v);if(!a||a.length>512||!/^t=\d+[, ]+v1=[A-Za-z0-9_-]+={0,2}$/.test(a.trim()))return h(401,{error:"Unauthorized"});let p;try{p=await _e(u)}catch(b){return b instanceof R&&b.status===413?h(413,{error:"Payload too large"}):h(400,{error:"Invalid body"})}try{let b=l();if(!Number.isFinite(b))throw new Error;if(!(await Promise.all([m,...s===void 0?[]:[s]].map($=>G({secret:$,rawBody:p,headers:u.headers,now:b})))).some($=>$.ok))return h(401,{error:"Unauthorized"})}catch{return h(401,{error:"Unauthorized"})}let f;try{f=JSON.parse(p)}catch{return h(400,{error:"Invalid payload"})}if(!f||typeof f!="object"||Array.isArray(f)||Object.keys(f).length!==2||!Object.hasOwn(f,"_type")||!Object.hasOwn(f,"_id"))return h(400,{error:"Invalid payload"});let{_type:g,_id:k}=f;if(typeof g!="string"||!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(g)||typeof k!="string"||!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(k))return h(400,{error:"Invalid payload"});if(!Object.hasOwn(t,g)||/^(drafts|versions)\./.test(k))return h(400,{error:"Unsupported document"});let X=w(n,{types:t[g],ids:[k]});try{for(let b of X)(0,V.revalidateTag)(b,{expire:0})}catch{return h(500,{error:"Could not revalidate"})}return h(200,{revalidated:!0})};return Object.freeze({POST:c,GET:c,HEAD:c,PUT:c,PATCH:c,DELETE:c,OPTIONS:c})}0&&(module.exports={MENU_DECORATIONS,MENU_LAYOUTS,MENU_LAYOUT_DEFAULTS,createNextCmsReader,createRevalidateRoute,menuQuery,menuTags,parseMenuDocument});
|
|
5
|
+
}}}`;function V(e,n){return S(e,{types:["menu"],...n===void 0?{}:{ids:[n]}})}function f(e,n){throw new R("menu",[`${e} ${n}`])}function Z(e,n,t=new Set,o){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="object"||e===null)return f(n,"is not plain JSON data");try{if(t.has(e))return f(n,"is not acyclic JSON data");let r=Array.isArray(e),s=Object.getPrototypeOf(e);if(r?s!==Array.prototype:s!==Object.prototype&&s!==null)return f(n,"is not an ordinary saved object");t.add(e);let u=Reflect.ownKeys(e),d=r?[]:{},i=0,p=0;for(let l of u){if(typeof l!="string")return f(n,"has a symbol key");let c=r&&l!=="length"?`${n}[${l}]`:`${n}.${l}`,y;try{y=l==="_id"&&o!==void 0?o:Object.getOwnPropertyDescriptor(e,l)}catch{return f(c,"could not be snapshotted as plain JSON data")}if(!y||!Object.hasOwn(y,"value"))return f(c,"is not a saved data property");if(r&&l==="length"){let k=y.value;if(typeof k!="number"||!Number.isSafeInteger(k)||k<0)return f(c,"is not a saved list length");i=k;continue}if(!y.enumerable||r&&!/^(0|[1-9]\d*)$/.test(l))return f(c,"is not a JSON data property");let a=y.value,m=Z(a,c,t);Object.defineProperty(d,l,{value:m,enumerable:!0,writable:!0,configurable:!0}),p++}return r&&(p!==i||d.length!==i)?f(n,"is not a complete saved list"):d}catch(r){if(r instanceof R)throw r;return f(n,"could not be snapshotted as plain JSON data")}finally{t.delete(e)}}function A(e,n){return e===null||typeof e!="object"||Array.isArray(e)||Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null?f(n,"is not an ordinary saved object"):e}function g(e,n,t=!0){return typeof e!="string"||t&&e.trim()===""?f(n,"is not saved text"):e}function C(e,n,t){return e[n]===void 0||e[n]===null?{}:{[n]:g(e[n],`${t}.${n}`,!1)}}function T(e,n,t){return e==null?[]:Q(e)?e.map((o,r)=>t(o,`${n}[${String(r)}]`)):f(n,"is not a complete saved list")}function J(e,n){let t=A(e,n);if(typeof t.minor!="number"||!Number.isSafeInteger(t.minor)||t.minor<0)return f(`${n}.minor`,"is not a whole non-negative safe amount");let o=g(t.currency,`${n}.currency`);return/^[A-Z]{3}$/.test(o)?{minor:t.minor,currency:o}:f(`${n}.currency`,"is not a three-letter currency code")}function Ae(e,n){let t=A(e,n);return{_key:g(t._key,`${n}._key`),amount:J(t.amount,`${n}.amount`),...C(t,"label",n)}}function Re(e,n){let t=A(e,n);return{_key:g(t._key,`${n}._key`),name:g(t.name,`${n}.name`),amount:J(t.amount,`${n}.amount`)}}function Ee(e,n){let t=A(e,n),o=t.availability??"available";return o!=="available"&&o!=="sold-out"&&o!=="hidden"?f(`${n}.availability`,"is not an availability choice"):{_key:g(t._key,`${n}._key`),name:g(t.name,`${n}.name`),...C(t,"description",n),...C(t,"priceNote",n),...C(t,"allergenNote",n),prices:T(t.prices,`${n}.prices`,Ae),extras:T(t.extras,`${n}.extras`,Re),dietary:T(t.dietary,`${n}.dietary`,g),availability:o}}function xe(e,n){let t=A(e,n);return{_key:g(t._key,`${n}._key`),title:g(t.title,`${n}.title`),...C(t,"service",n),items:T(t.items,`${n}.items`,Ee)}}function Ie(e,n){let t=A(e,n);return{_key:g(t._key,`${n}._key`),label:g(t.label,`${n}.label`),...C(t,"note",n),sections:T(t.sections,`${n}.sections`,xe)}}function Oe(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let n=e._id;return typeof n=="string"&&n.trim()!==""&&!/^(drafts|versions)\./.test(n)}function I(e,n="menu"){return De(Z(e,n),n)}function De(e,n){let t=A(e,n);if(t._type!=="menu")return f(`${n}._type`,"is not menu");if(!Oe(t))return f(`${n}._id`,"is not a published menu identity");let o=g(t._updatedAt,`${n}._updatedAt`);if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(o)||!Number.isFinite(Date.parse(o)))return f(`${n}._updatedAt`,"is not an update date");let r=T(t.variants,`${n}.variants`,Ie);return r.length===0?f(`${n}.variants`,"has no menu choices"):{_type:"menu",_id:g(t._id,`${n}._id`),_rev:g(t._rev,`${n}._rev`),_updatedAt:o,title:g(t.title,`${n}.title`),locationKeys:T(t.locationKeys,`${n}.locationKeys`,g),variants:r,...C(t,"note",n),...Object.hasOwn(t,"signOff")?{signOff:t.signOff}:{}}}function W(e){if(e===null)return!0;try{return I(e),!0}catch{return!1}}var Y="malformed-content",R=class extends Error{code=Y;documentId;problems;constructor(n,t){super(`${Y}: ${n}: ${t.join("; ")}`),this.name="MalformedContentError",this.documentId=n,this.problems=t}};var G=`{..., "sections": coalesce(sections[]{..., _type == "menuBlock" => {menu->{${L}}}, _type == "linkListBlock" => {links[]{..., "page": page->{title, "slug": slug.current}}}}, sections)}`,un=`*[_type == "page" && defined(slug.current)]|order(slug.current asc)${G}`,cn=`*[_type == "page" && slug.current == $slug][0]${G}`;var Me=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,ve=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,Le=/^[a-z0-9]{6,12}\.[a-z][a-z0-9_-]{0,63}$/;function K(e){if(!e||!Array.isArray(e.types)||e.types.length===0)throw new TypeError("CMS dependencies require document types");let n=[...e.types];for(let o of n)if(typeof o!="string"||!Me.test(o))throw new TypeError("Invalid CMS document type");if(e.ids!==void 0&&!Array.isArray(e.ids))throw new TypeError("Invalid CMS document IDs");let t=e.ids===void 0?void 0:[...e.ids];for(let o of t??[])if(typeof o!="string"||!ve.test(o)||/^(drafts|versions)\./.test(o))throw new TypeError("Invalid CMS document ID");if(new Set(n).size+new Set(t).size>128)throw new TypeError("Too many CMS tags");return Object.freeze({types:Object.freeze(n),...t===void 0?{}:{ids:Object.freeze(t)}})}function E(e){if(!e||typeof e.name!="string"||!/^[A-Za-z][A-Za-z0-9_.-]{0,127}$/.test(e.name)||typeof e.query!="string"||e.query.trim()===""||typeof e.resolve!="function")throw new TypeError("Invalid CMS query configuration");let n=e.params;if(!n||typeof n!="object"||Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw new TypeError("CMS params must be plain JSON scalars");let t={};for(let o of Reflect.ownKeys(n)){let r=Object.getOwnPropertyDescriptor(n,o);if(typeof o!="string"||!r||!Object.hasOwn(r,"value")||!r.enumerable)throw new TypeError("CMS params must be plain JSON scalars");let s=r.value;if(!(s===null||typeof s=="string"||typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s)))throw new TypeError("CMS params must be plain JSON scalars");Object.defineProperty(t,o,{value:s,enumerable:!0})}return Object.freeze({name:e.name,query:e.query,params:Object.freeze(t),dependencies:K(e.dependencies),resolve:e.resolve})}function S(e,n){if(typeof e!="string"||e.length>77||!Le.test(e))throw new TypeError("Invalid CMS scope");let t=K(n),o=[...[...new Set(t.types)].sort().map(r=>`cms:${e}:type:${r}`),...[...new Set(t.ids??[])].sort().map(r=>`cms:${e}:id:${r}`)];return Object.freeze(o)}function X(e){return E({name:"menu.v1",query:`*[_type == "menu" && _id == $id && !(_id in path("drafts.**")) && !(_id in path("versions.**"))][0]{${L}}`,params:{id:e},dependencies:{types:["menu"],ids:[e]},resolve:(n,t)=>{if(!W(t)||t!==null&&t._id!==e)throw new TypeError("Invalid CMS menu fallback");if(n==null)return{data:t,fallbackFields:["$"]};let o=I(n);if(o._id!==e)throw new R("menu",["menu._id does not match the requested document"]);return{data:o,fallbackFields:[]}}})}function ee(e){if(!e||!Object.hasOwn(e,"data")||!Array.isArray(e.fallbackFields)||![...e.fallbackFields].every(n=>typeof n=="string"&&(n==="$"||/^[A-Za-z][A-Za-z0-9_.[\]-]{0,127}$/.test(n))))throw new TypeError("Invalid CMS resolution");if(e.warnings!==void 0&&(!Array.isArray(e.warnings)||![...e.warnings].every(n=>n==="siteHero.layout.defaulted"||n==="siteHero.tagline.dropped"||n==="siteHero.taglines.defaulted")))throw new TypeError("Invalid CMS resolution warnings");return{data:e.data,fallbackFields:Object.freeze([...new Set(e.fallbackFields)]),...e.warnings?.length?{warnings:Object.freeze([...new Set(e.warnings)])}:{}}}function ne(e){let n=e?.revalidateSeconds??3600;if(!Number.isSafeInteger(n)||n<3600||!e?.adapter||typeof e.adapter.read!="function"||e.onDiagnostic!==void 0&&typeof e.onDiagnostic!="function")throw new TypeError("Invalid CMS reader configuration");let t=e.adapter;S(t.scope,{types:["ScopeValidation"]});let o=r=>{try{e.onDiagnostic?e.onDiagnostic(r):console.warn(JSON.stringify(r))}catch{}};return{async read(r,s){let u,d,i;try{if(u=E(r),i=S(t.scope,u.dependencies),!s||!Object.hasOwn(s,"fallback"))throw new TypeError;d=ee(u.resolve(null,s.fallback))}catch{throw new TypeError("Invalid CMS query or fallback configuration")}let p=(y,a,m)=>(o({event:"cms.fallback",query:u.name,reason:y,fields:["$"],...a===void 0?{}:{status:a},...m?{warnings:m}:{}}),{data:d.data,source:"fallback",fallbackFields:["$"],reason:y,...m?{warnings:m}:{}}),l;try{l=await t.read({name:u.name,query:u.query,params:u.params},{tags:i,revalidateSeconds:n})}catch{return p("network")}if(!l.ok){let a=["configuration","network","timeout","rate-limit","upstream","plan-limit","permission","malformed"].includes(l.reason)?l.reason:"malformed",m=Number.isInteger(l.status)&&(l.status??0)>=100&&(l.status??0)<=599?l.status:void 0;return p(a,m)}if(l.value===null||l.value===void 0)return p("missing");let c;try{c=ee(u.resolve(l.value,s.fallback))}catch{return p("malformed")}return c.fallbackFields.includes("$")?{...p("invalid-field",void 0,c.warnings),data:c.data}:c.fallbackFields.length>0?(o({event:"cms.partial-fallback",query:u.name,reason:"invalid-field",fields:c.fallbackFields,...c.warnings?{warnings:c.warnings}:{}}),{...c,source:"mixed",reason:"invalid-field"}):{...c,source:"cms"}}}}var te=ne;var ie=require("next/cache.js");var N="sanity-webhook-signature",je=/^t=(\d+)[, ]+v1=([^, ]+)$/;var oe=new TextEncoder;function Pe(e){return crypto.subtle.importKey("raw",oe.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}function Ne(e){if(!/^[A-Za-z0-9_-]+={0,2}$/.test(e))return null;let n=e.replace(/-/g,"+").replace(/_/g,"/");try{let t=atob(n),o=new Uint8Array(t.length);for(let r=0;r<t.length;r+=1)o[r]=t.charCodeAt(r);return o}catch{return null}}async function re(e){let{secret:n,rawBody:t,headers:o}=e,r=e.now??Date.now(),s=e.toleranceMs??3e5;if(!n||n.length===0)return{ok:!1,reason:"no-secret"};let u=o.get(N);if(!u)return{ok:!1,reason:"no-signature"};let d=je.exec(u.trim());if(d===null)return{ok:!1,reason:"malformed-signature"};let i=Number(d[1]),p=d[2]??"";if(!Number.isSafeInteger(i))return{ok:!1,reason:"malformed-signature"};if(i<16094592e5)return{ok:!1,reason:"stale-timestamp"};if(Math.abs(r-i)>s)return{ok:!1,reason:"stale-timestamp"};let l=Ne(p);if(l===null)return{ok:!1,reason:"malformed-signature"};let c=await Pe(n);return await crypto.subtle.verify("HMAC",c,l,oe.encode(`${i}.${t}`))?{ok:!0}:{ok:!1,reason:"bad-signature"}}var Ue=16*1024,Fe=1500,qe=new TextEncoder;function b(e,n,t={},o=!1){return new Response(o?null:JSON.stringify(n),{status:e,headers:{"Content-Type":"application/json","Cache-Control":"no-store",...t}})}function He(e,n){if(!n||typeof n!="object"||Array.isArray(n)||Object.keys(n).length===0)throw new TypeError("Invalid CMS invalidation mapping");let t=Object.create(null);for(let o of Reflect.ownKeys(n)){let r=Object.getOwnPropertyDescriptor(n,o);if(typeof o!="string"||!r?.enumerable||!Object.hasOwn(r,"value"))throw new TypeError("Invalid CMS invalidation mapping");let s=r.value;if(!Array.isArray(s)||!s.includes(o))throw new TypeError("Invalid CMS invalidation mapping");S(e,{types:s,ids:["validation"]}),t[o]=Object.freeze([...s])}for(let o of Object.values(t))if(o.some(r=>!Object.hasOwn(t,r)))throw new TypeError("Invalid CMS invalidation mapping");return Object.freeze(t)}function se(e){return typeof e=="string"&&e.trim()!==""&&qe.encode(e).byteLength>=32}var O=class extends Error{constructor(t){super("Invalid CMS webhook body");this.status=t}status};async function Be(e){let n=e.body?.getReader();if(!n)return"";let t=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),o,r=new Promise((s,u)=>{o=setTimeout(()=>u(new O(400)),Fe)});try{let s=0,u="";for(;;){let{done:d,value:i}=await Promise.race([n.read(),r]);if(d)return u+t.decode();if(s+=i.byteLength,s>Ue)throw new O(413);u+=t.decode(i,{stream:!0})}}catch(s){throw n.cancel().catch(()=>{}),s}finally{clearTimeout(o),n.releaseLock()}}function le(e){let n=e.scope,t=He(n,e.typeToTags),o=e.secretEnv??"SANITY_REVALIDATE_SECRET",r=e.previousSecretEnv??"SANITY_REVALIDATE_SECRET_PREVIOUS",s=e.env??(()=>process.env),u=e.now??Date.now,d=async i=>{if(i.method!=="POST")return b(405,{error:"Method not allowed"},{Allow:"POST"},i.method==="HEAD");let p,l;try{let w=s(),j=w[o],_=w[r];if(!se(j)||_!==void 0&&!se(_))throw new Error;p=j,l=_}catch{return b(503,{error:"COULD NOT ANSWER: revalidation configuration unavailable"})}let c=i.headers.get(N);if(!c||c.length>512||!/^t=\d+[, ]+v1=[A-Za-z0-9_-]+={0,2}$/.test(c.trim()))return b(401,{error:"Unauthorized"});let y;try{y=await Be(i)}catch(w){return w instanceof O&&w.status===413?b(413,{error:"Payload too large"}):b(400,{error:"Invalid body"})}try{let w=u();if(!Number.isFinite(w))throw new Error;if(!(await Promise.all([p,...l===void 0?[]:[l]].map(_=>re({secret:_,rawBody:y,headers:i.headers,now:w})))).some(_=>_.ok))return b(401,{error:"Unauthorized"})}catch{return b(401,{error:"Unauthorized"})}let a;try{a=JSON.parse(y)}catch{return b(400,{error:"Invalid payload"})}if(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).length!==2||!Object.hasOwn(a,"_type")||!Object.hasOwn(a,"_id"))return b(400,{error:"Invalid payload"});let{_type:m,_id:k}=a;if(typeof m!="string"||!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(m)||typeof k!="string"||!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(k))return b(400,{error:"Invalid payload"});if(!Object.hasOwn(t,m)||/^(drafts|versions)\./.test(k))return b(400,{error:"Unsupported document"});let ke=S(n,{types:t[m],ids:[k]});try{for(let w of ke)(0,ie.revalidateTag)(w,{expire:0})}catch{return b(500,{error:"Could not revalidate"})}return b(200,{revalidated:!0})};return Object.freeze({POST:d,GET:d,HEAD:d,PUT:d,PATCH:d,DELETE:d,OPTIONS:d})}var $=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),h=e=>typeof e=="string"&&e.trim()?e.trim():null,ze=(e,n)=>e._type===n&&typeof e._id=="string"&&e._id.length>0&&!/^(drafts|versions)\./.test(e._id),Qe=/^\d{4}-\d{2}-\d{2}$/,ae=/^([01]\d|2[0-3]):[0-5]\d$/,Ve=["mon","tue","wed","thu","fri","sat","sun"];async function ue(e,n,t){try{let o=await e.read(n,{fallback:t});return{...o,source:o.source==="cms"?"sanity":o.source}}catch{return{data:t,source:"fallback",fallbackFields:["$"],reason:"configuration"}}}var Ze=/^[A-Za-z0-9._+-]{1,64}@[A-Za-z0-9-]{1,63}(?:\.[A-Za-z0-9-]{1,63})*\.[A-Za-z]{2,63}$/;function Je(e){let n=h(e);if(!n)return null;try{let t=new URL(n);return t.protocol==="http:"||t.protocol==="https:"?t.href:null}catch{return null}}function x(e){if(typeof e!="function")throw new TypeError("A client validator is required")}function U(e,n,t){if(x(t),!$(e)||e.status!=="open")return null;let o=h(e.closingDate);if(o!==null&&o<n||t(e)!==null)return null;let r=h(e.title),s=$(e.workLocation)?e.workLocation:null,u=h(e.location),d=h(s?.name)??(u==="Other"?null:u)??h(e.locationNote);if(!r||!d)return null;let i=h(e.pdfUrl);return{id:String(h(e._id)),title:r,location:d,locationId:s===null?null:h(s._id),summary:h(e.summary),pdfUrl:i?.startsWith("https://cdn.sanity.io/files/")?i:null,applyUrl:Je(e.applyUrl),applyEmail:typeof e.applyEmail=="string"&&e.applyEmail.length<=254&&Ze.test(e.applyEmail)?e.applyEmail:null}}function F(e,n,t){if(x(t),!Array.isArray(e))throw new TypeError("Sanity returned vacancies that are not a list");return e.map(o=>({value:U(o,n,t),order:$(o)&&typeof o.order=="number"&&Number.isFinite(o.order)?o.order:1e6})).filter(o=>o.value!==null).sort((o,r)=>o.order-r.order||o.value.title.toLowerCase().localeCompare(r.value.title.toLowerCase())).map(o=>o.value)}function ce(e){return S(e,{types:["vacancy","location"]})}function de(e,n){if(!Qe.test(e))throw new TypeError("Invalid calendar date");return x(n),E({name:"vacancy.open.v2",query:'*[_type == "vacancy" && status == "open" && !(_id in path("drafts.**")) && !(_id in path("versions.**")) && (!defined(closingDate) || closingDate >= $today)]|order(coalesce(order, 1000000) asc, lower(title) asc){_id, _type, title, "workLocation": workLocation->{_id, name}, location, locationNote, summary, "pdfUrl": jobDescriptionPdf.asset->url, applyUrl, applyEmail, status, closingDate, order}',params:{today:e},dependencies:{types:["vacancy","location"]},resolve:(t,o)=>({data:t==null?o:F(t,e,n),fallbackFields:t==null?["$"]:[]})})}var We=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Ye=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function q(e){return!$(e)||typeof e._id!="string"||!$(e.slug)||typeof e.slug.current!="string"||!Ye.test(e.slug.current)||h(e.name)===null||e.addressLines!==void 0&&e.addressLines!==null&&(!Array.isArray(e.addressLines)||Array.from(e.addressLines).some(n=>h(n)===null))||e.postcode!==void 0&&e.postcode!==null&&h(e.postcode)===null||e.coordinates!==void 0&&e.coordinates!==null&&(!$(e.coordinates)||typeof e.coordinates.lat!="number"||!Number.isFinite(e.coordinates.lat)||typeof e.coordinates.lng!="number"||!Number.isFinite(e.coordinates.lng))||e.phone!==void 0&&e.phone!==null&&typeof e.phone!="string"||e.email!==void 0&&e.email!==null&&typeof e.email!="string"?null:{name:h(e.name),slug:e.slug.current,addressLines:e.addressLines==null?e.addressLines:e.addressLines.map(n=>n.trim()),postcode:e.postcode==null?e.postcode:String(e.postcode).trim(),coordinates:e.coordinates==null?e.coordinates:{lat:e.coordinates.lat,lng:e.coordinates.lng},phone:e.phone,email:e.email,hours:e.hours}}function ye(e){if(!$(e))return null;let n={};for(let t of We){let o=e[t];if(!Array.isArray(o)||!Array.from(o).every(r=>$(r)&&typeof r.opens=="string"&&typeof r.closes=="string"))return null;n[t]=o.map(r=>({opens:r.opens,closes:r.closes}))}return n}function H(e,n,t){x(t);let o=q(e);if(o===null||o.slug!==n.id)return{data:n,fallbackFields:["$"]};let r=ye(o.hours),s={id:n.id,label:o.name,addressLines:o.addressLines??n.addressLines,postcode:o.postcode??n.postcode,geo:o.coordinates==null?n.geo:{latitude:o.coordinates.lat,longitude:o.coordinates.lng},telephone:o.phone===void 0?n.telephone:o.phone,email:o.email===void 0?n.email:o.email,hours:r??n.hours};try{return{data:t(s),fallbackFields:r===null?["hours"]:[]}}catch{if(r!==null)try{return{data:t({...s,hours:n.hours}),fallbackFields:["hours"]}}catch{}return{data:n,fallbackFields:["$"]}}}function B(e,n,t){x(t);let o=q(e);if(o===null||o.slug!==n.id)return{data:n,fallbackFields:["$"]};let r=ye(o.hours),s={...n,label:o.name,address:n.address===null?null:{...n.address,streetAddress:o.addressLines??n.address.streetAddress,postalCode:o.postcode??n.address.postalCode},telephone:o.phone===void 0?n.telephone:o.phone,email:o.email===void 0?n.email:o.email,geo:o.coordinates==null?n.geo:{latitude:o.coordinates.lat,longitude:o.coordinates.lng},hours:r??n.hours};try{return{data:t(s),fallbackFields:r===null?["hours"]:[]}}catch{if(r!==null)try{return{data:t({...s,hours:n.hours}),fallbackFields:["hours"]}}catch{}return{data:n,fallbackFields:["$"]}}}function pe(e){return S(e,{types:["location"]})}function fe(e,n){return E({name:e,query:'*[_type == "location" && defined(slug.current) && !(_id in path("drafts.**")) && !(_id in path("versions.**"))]{_id, _type, name, slug, addressLines, postcode, coordinates, phone, email, hours}',params:{},dependencies:{types:["location"]},resolve:(t,o)=>{if(!Array.isArray(t))return{data:o,fallbackFields:["$"]};let r=new Map,s=new Set;for(let i of t){let p=q(i);p!==null&&(r.has(p.slug)?s.add(p.slug):r.set(p.slug,i))}let u=[];return{data:o.map((i,p)=>{let l=r.get(i.id),c=l===void 0||s.has(i.id)?{data:i,fallbackFields:["$"]}:n(l,i);return u.push(...c.fallbackFields.map(y=>y==="$"?`locations[${p}]`:`locations[${p}].${y}`)),c.data}),fallbackFields:o.length>0&&u.length===o.length&&u.every(i=>/^locations\[\d+\]$/.test(i))?["$"]:u}}})}function me(e){return x(e),fe("locations.v1",(n,t)=>H(n,t,e))}function ge(e){return x(e),fe("locations.business.v1",(n,t)=>B(n,t,e))}function Ge(e,n,t){let o=`${e}-${n.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"stop"}`,r=o;for(let s=2;t.has(r);s++)r=`${o}-${s}`;return t.add(r),r}function z(e,n){if(!$(e)||!ze(e,"schedule")||e._id!=="schedule"||e.timeZone!==n.timeZone||!Array.isArray(e.days)||e.days.length!==7)throw new TypeError("Invalid schedule document");let t=e.days.map((o,r)=>{if(!$(o)||o.day!==Ve[r]||typeof o.rest!="boolean"||!Array.isArray(o.stops))throw new TypeError("Invalid schedule day");let s=o.day,u=o.rest,d=o.stops,i=n.days.find(y=>y.day===s),p=new Set(i?.stops.map(y=>y.id)??[]),l=new Set,c=d.map(y=>{if(!$(y))throw new TypeError("Invalid schedule stop");let a=y;if(!h(a.name)||!ae.test(String(a.from??""))||!ae.test(String(a.to??""))||!h(a.address))throw new TypeError("Invalid schedule stop");let m=i?.stops.find(k=>k.name===a.name&&!l.has(k.id));return m?(l.add(m.id),{...m,name:String(a.name),from:String(a.from),to:String(a.to),address:String(a.address)}):{id:Ge(s,String(a.name),p),name:String(a.name),from:String(a.from),to:String(a.to),address:String(a.address),place:null,postcode:null,notes:null,lat:null,lng:null,coordinateSource:null,approximate:!1,needsConfirmation:null,captured:`${a.name}
|
|
6
|
+
${a.from}-${a.to}
|
|
7
|
+
${a.address}`}});return{day:s,rest:u,stops:u?[]:c}});return{timeZone:n.timeZone,days:t}}function he(e){return S(e,{types:["schedule"],ids:["schedule"]})}function be(){return E({name:"schedule.v1",query:'*[_type == "schedule" && _id == "schedule" && !(_id in path("drafts.**")) && !(_id in path("versions.**"))][0]{_id, _type, timeZone, days}',params:{},dependencies:{types:["schedule"],ids:["schedule"]},resolve:(e,n)=>({data:e==null?n:z(e,n),fallbackFields:e==null?["$"]:[]})})}0&&(module.exports={MENU_DECORATIONS,MENU_LAYOUTS,MENU_LAYOUT_DEFAULTS,businessLocationsQuery,createNextCmsReader,createRevalidateRoute,locationTags,locationsQuery,menuQuery,menuTags,openVacanciesQuery,parseBusinessLocation,parseLocationDocument,parseMenuDocument,parseScheduleDocument,parseVacancies,parseVacancyDocument,resolveWithFallback,scheduleQuery,scheduleTags,vacancyTags});
|
|
6
8
|
//# sourceMappingURL=next.cjs.map
|