@weatherboard/cms 0.7.0 → 0.8.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 +41 -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 +164 -0
- package/dist/runtime/site-readers.d.mts +164 -0
- package/dist/runtime/site-readers.d.ts +164 -0
- package/dist/runtime/test-fixtures/saved-documents.d.cts +81 -0
- package/dist/runtime/test-fixtures/saved-documents.d.mts +81 -0
- package/dist/runtime/test-fixtures/saved-documents.d.ts +81 -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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export declare const savedVacancy: {
|
|
2
|
+
readonly _id: "vacancy_7e57";
|
|
3
|
+
readonly _type: "vacancy";
|
|
4
|
+
readonly title: "Assistant";
|
|
5
|
+
readonly location: "Other";
|
|
6
|
+
readonly locationNote: "Depot";
|
|
7
|
+
readonly summary: "Day shift";
|
|
8
|
+
readonly description: readonly [];
|
|
9
|
+
readonly jobDescriptionPdf: {
|
|
10
|
+
readonly _type: "file";
|
|
11
|
+
readonly asset: {
|
|
12
|
+
readonly _type: "reference";
|
|
13
|
+
readonly _ref: "file-neutral-pdf";
|
|
14
|
+
};
|
|
15
|
+
readonly media: null;
|
|
16
|
+
};
|
|
17
|
+
readonly applyUrl: "https://example.test/apply";
|
|
18
|
+
readonly applyEmail: "apply@example.test";
|
|
19
|
+
readonly status: "open";
|
|
20
|
+
readonly closingDate: "2026-10-20";
|
|
21
|
+
readonly order: 1;
|
|
22
|
+
readonly _createdAt: string;
|
|
23
|
+
readonly _updatedAt: string;
|
|
24
|
+
readonly _rev: string;
|
|
25
|
+
};
|
|
26
|
+
export declare const savedLocation: {
|
|
27
|
+
readonly _id: "location_7e57";
|
|
28
|
+
readonly _type: "location";
|
|
29
|
+
readonly name: "Depot";
|
|
30
|
+
readonly slug: {
|
|
31
|
+
readonly _type: "slug";
|
|
32
|
+
readonly current: "depot";
|
|
33
|
+
};
|
|
34
|
+
readonly addressLines: readonly ["1 Example Road"];
|
|
35
|
+
readonly postcode: "AB1 2CD";
|
|
36
|
+
readonly mapLink: "https://example.test/map";
|
|
37
|
+
readonly coordinates: {
|
|
38
|
+
readonly _type: "geopoint";
|
|
39
|
+
readonly lat: 51.5;
|
|
40
|
+
readonly lng: -0.1;
|
|
41
|
+
readonly alt: 0;
|
|
42
|
+
};
|
|
43
|
+
readonly hours: {
|
|
44
|
+
readonly _type: "openingHours";
|
|
45
|
+
readonly monday: readonly [];
|
|
46
|
+
readonly tuesday: readonly [];
|
|
47
|
+
readonly wednesday: readonly [];
|
|
48
|
+
readonly thursday: readonly [];
|
|
49
|
+
readonly friday: readonly [];
|
|
50
|
+
readonly saturday: readonly [];
|
|
51
|
+
readonly sunday: readonly [];
|
|
52
|
+
};
|
|
53
|
+
readonly phone: "+44 20 7000 0000";
|
|
54
|
+
readonly email: "hello@example.test";
|
|
55
|
+
readonly _createdAt: string;
|
|
56
|
+
readonly _updatedAt: string;
|
|
57
|
+
readonly _rev: string;
|
|
58
|
+
};
|
|
59
|
+
export declare const savedSchedule: {
|
|
60
|
+
readonly _id: "schedule";
|
|
61
|
+
readonly _type: "schedule";
|
|
62
|
+
readonly timeZone: "Europe/London";
|
|
63
|
+
readonly days: {
|
|
64
|
+
_key: string;
|
|
65
|
+
_type: "scheduleDay";
|
|
66
|
+
day: "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun";
|
|
67
|
+
rest: false;
|
|
68
|
+
stops: {
|
|
69
|
+
_key: string;
|
|
70
|
+
_type: "scheduleStop";
|
|
71
|
+
name: string;
|
|
72
|
+
from: string;
|
|
73
|
+
to: string;
|
|
74
|
+
address: string;
|
|
75
|
+
mapLink: string;
|
|
76
|
+
}[];
|
|
77
|
+
}[];
|
|
78
|
+
readonly _createdAt: string;
|
|
79
|
+
readonly _updatedAt: string;
|
|
80
|
+
readonly _rev: string;
|
|
81
|
+
};
|
package/dist/server.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var D=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var ce=(e,n)=>{for(var t in n)D(e,t,{get:n[t],enumerable:!0})},de=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of ae(n))!ue.call(e,r)&&r!==t&&D(e,r,{get:()=>n[r],enumerable:!(o=le(n,r))||o.enumerable});return e};var ye=e=>de(D({},"__esModule",{value:!0}),e);var Oe={};ce(Oe,{MENU_DECORATIONS:()=>I,MENU_LAYOUTS:()=>x,MENU_LAYOUT_DEFAULTS:()=>E,businessLocationsQuery:()=>re,createCmsReader:()=>W,locationTags:()=>ne,locationsQuery:()=>oe,menuQuery:()=>J,menuTags:()=>q,openVacanciesQuery:()=>X,parseBusinessLocation:()=>N,parseLocationDocument:()=>P,parseMenuDocument:()=>R,parseScheduleDocument:()=>v,parseVacancies:()=>j,parseVacancyDocument:()=>M,resolveWithFallback:()=>G,scheduleQuery:()=>ie,scheduleTags:()=>se,vacancyTags:()=>K});module.exports=ye(Oe);var Ke=require("server-only");function F(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 x=["stacked","columns"],I=["none","playful"],E={layout:"stacked",decoration:"none"},O=`_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 E(e,n){return S(e,{types:["menu"],...n===void 0?{}:{ids:[n]}})}function s(e,n){throw new h("menu",[`${e} ${n}`])}function M(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 s(n,"is not plain JSON data");try{if(t.has(e))return s(n,"is not acyclic JSON data");let r=Array.isArray(e),u=Object.getPrototypeOf(e);if(r?u!==Array.prototype:u!==Object.prototype&&u!==null)return s(n,"is not an ordinary saved object");t.add(e);let c=Reflect.ownKeys(e),k=r?[]:{},b=0,y=0;for(let i of c){if(typeof i!="string")return s(n,"has a symbol key");let a=r&&i!=="length"?`${n}[${i}]`:`${n}.${i}`,d;try{d=i==="_id"&&o!==void 0?o:Object.getOwnPropertyDescriptor(e,i)}catch{return s(a,"could not be snapshotted as plain JSON data")}if(!d||!Object.hasOwn(d,"value"))return s(a,"is not a saved data property");if(r&&i==="length"){let C=d.value;if(typeof C!="number"||!Number.isSafeInteger(C)||C<0)return s(a,"is not a saved list length");b=C;continue}if(!d.enumerable||r&&!/^(0|[1-9]\d*)$/.test(i))return s(a,"is not a JSON data property");let $=d.value,p=M($,a,t);Object.defineProperty(k,i,{value:p,enumerable:!0,writable:!0,configurable:!0}),y++}return r&&(y!==b||k.length!==b)?s(n,"is not a complete saved list"):k}catch(r){if(r instanceof h)throw r;return s(n,"could not be snapshotted as plain JSON data")}finally{t.delete(e)}}function g(e,n){return e===null||typeof e!="object"||Array.isArray(e)||Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null?s(n,"is not an ordinary saved object"):e}function l(e,n,t=!0){return typeof e!="string"||t&&e.trim()===""?s(n,"is not saved text"):e}function f(e,n,t){return e[n]===void 0||e[n]===null?{}:{[n]:l(e[n],`${t}.${n}`,!1)}}function m(e,n,t){return e==null?[]:x(e)?e.map((o,r)=>t(o,`${n}[${String(r)}]`)):s(n,"is not a complete saved list")}function D(e,n){let t=g(e,n);if(typeof t.minor!="number"||!Number.isSafeInteger(t.minor)||t.minor<0)return s(`${n}.minor`,"is not a whole non-negative safe amount");let o=l(t.currency,`${n}.currency`);return/^[A-Z]{3}$/.test(o)?{minor:t.minor,currency:o}:s(`${n}.currency`,"is not a three-letter currency code")}function Y(e,n){let t=g(e,n);return{_key:l(t._key,`${n}._key`),amount:D(t.amount,`${n}.amount`),...f(t,"label",n)}}function G(e,n){let t=g(e,n);return{_key:l(t._key,`${n}._key`),name:l(t.name,`${n}.name`),amount:D(t.amount,`${n}.amount`)}}function W(e,n){let t=g(e,n),o=t.availability??"available";return o!=="available"&&o!=="sold-out"&&o!=="hidden"?s(`${n}.availability`,"is not an availability choice"):{_key:l(t._key,`${n}._key`),name:l(t.name,`${n}.name`),...f(t,"description",n),...f(t,"priceNote",n),...f(t,"allergenNote",n),prices:m(t.prices,`${n}.prices`,Y),extras:m(t.extras,`${n}.extras`,G),dietary:m(t.dietary,`${n}.dietary`,l),availability:o}}function Z(e,n){let t=g(e,n);return{_key:l(t._key,`${n}._key`),title:l(t.title,`${n}.title`),...f(t,"service",n),items:m(t.items,`${n}.items`,W)}}function K(e,n){let t=g(e,n);return{_key:l(t._key,`${n}._key`),label:l(t.label,`${n}.label`),...f(t,"note",n),sections:m(t.sections,`${n}.sections`,Z)}}function V(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 w(e,n="menu"){return X(M(e,n),n)}function X(e,n){let t=g(e,n);if(t._type!=="menu")return s(`${n}._type`,"is not menu");if(!V(t))return s(`${n}._id`,"is not a published menu identity");let o=l(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 s(`${n}._updatedAt`,"is not an update date");let r=m(t.variants,`${n}.variants`,K);return r.length===0?s(`${n}.variants`,"has no menu choices"):{_type:"menu",_id:l(t._id,`${n}._id`),_rev:l(t._rev,`${n}._rev`),_updatedAt:o,title:l(t.title,`${n}.title`),locationKeys:m(t.locationKeys,`${n}.locationKeys`,l),variants:r,...f(t,"note",n),...Object.hasOwn(t,"signOff")?{signOff:t.signOff}:{}}}function j(e){if(e===null)return!0;try{return w(e),!0}catch{return!1}}var P="malformed-content",h=class extends Error{code=P;documentId;problems;constructor(n,t){super(`${P}: ${n}: ${t.join("; ")}`),this.name="MalformedContentError",this.documentId=n,this.problems=t}};var N=`{..., "sections": coalesce(sections[]{..., _type == "menuBlock" => {menu->{${T}}}, _type == "linkListBlock" => {links[]{..., "page": page->{title, "slug": slug.current}}}}, sections)}`,pe=`*[_type == "page" && defined(slug.current)]|order(slug.current asc)${N}`,fe=`*[_type == "page" && slug.current == $slug][0]${N}`;var ee=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,ne=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,te=/^[a-z0-9]{6,12}\.[a-z][a-z0-9_-]{0,63}$/;function q(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"||!ee.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"||!ne.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 I(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 u=r.value;if(!(u===null||typeof u=="string"||typeof u=="boolean"||typeof u=="number"&&Number.isFinite(u)))throw new TypeError("CMS params must be plain JSON scalars");Object.defineProperty(t,o,{value:u,enumerable:!0})}return Object.freeze({name:e.name,query:e.query,params:Object.freeze(t),dependencies:q(e.dependencies),resolve:e.resolve})}function S(e,n){if(typeof e!="string"||e.length>77||!te.test(e))throw new TypeError("Invalid CMS scope");let t=q(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 U(e){return I({name:"menu.v1",query:`*[_type == "menu" && _id == $id && !(_id in path("drafts.**")) && !(_id in path("versions.**"))][0]{${T}}`,params:{id:e},dependencies:{types:["menu"],ids:[e]},resolve:(n,t)=>{if(!j(t)||t!==null&&t._id!==e)throw new TypeError("Invalid CMS menu fallback");if(n==null)return{data:t,fallbackFields:["$"]};let o=w(n);if(o._id!==e)throw new h("menu",["menu._id does not match the requested document"]);return{data:o,fallbackFields:[]}}})}function v(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 L(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,u){let c,k,b;try{if(c=I(r),b=S(t.scope,c.dependencies),!u||!Object.hasOwn(u,"fallback"))throw new TypeError;k=v(c.resolve(null,u.fallback))}catch{throw new TypeError("Invalid CMS query or fallback configuration")}let y=(d,$,p)=>(o({event:"cms.fallback",query:c.name,reason:d,fields:["$"],...$===void 0?{}:{status:$},...p?{warnings:p}:{}}),{data:k.data,source:"fallback",fallbackFields:["$"],reason:d,...p?{warnings:p}:{}}),i;try{i=await t.read({name:c.name,query:c.query,params:c.params},{tags:b,revalidateSeconds:n})}catch{return y("network")}if(!i.ok){let $=["configuration","network","timeout","rate-limit","upstream","plan-limit","permission","malformed"].includes(i.reason)?i.reason:"malformed",p=Number.isInteger(i.status)&&(i.status??0)>=100&&(i.status??0)<=599?i.status:void 0;return y($,p)}if(i.value===null||i.value===void 0)return y("missing");let a;try{a=v(c.resolve(i.value,u.fallback))}catch{return y("malformed")}return a.fallbackFields.includes("$")?{...y("invalid-field",void 0,a.warnings),data:a.data}:a.fallbackFields.length>0?(o({event:"cms.partial-fallback",query:c.name,reason:"invalid-field",fields:a.fallbackFields,...a.warnings?{warnings:a.warnings}:{}}),{...a,source:"mixed",reason:"invalid-field"}):{...a,source:"cms"}}}}0&&(module.exports={MENU_DECORATIONS,MENU_LAYOUTS,MENU_LAYOUT_DEFAULTS,createCmsReader,menuQuery,menuTags,parseMenuDocument});
|
|
5
|
+
}}}`;function q(e,n){return b(e,{types:["menu"],...n===void 0?{}:{ids:[n]}})}function d(e,n){throw new w("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),s=Object.getPrototypeOf(e);if(r?s!==Array.prototype:s!==Object.prototype&&s!==null)return d(n,"is not an ordinary saved object");t.add(e);let a=Reflect.ownKeys(e),k=r?[]:{},y=0,p=0;for(let i of a){if(typeof i!="string")return d(n,"has a symbol key");let u=r&&i!=="length"?`${n}[${i}]`:`${n}.${i}`,c;try{c=i==="_id"&&o!==void 0?o:Object.getOwnPropertyDescriptor(e,i)}catch{return d(u,"could not be snapshotted as plain JSON data")}if(!c||!Object.hasOwn(c,"value"))return d(u,"is not a saved data property");if(r&&i==="length"){let $=c.value;if(typeof $!="number"||!Number.isSafeInteger($)||$<0)return d(u,"is not a saved list length");y=$;continue}if(!c.enumerable||r&&!/^(0|[1-9]\d*)$/.test(i))return d(u,"is not a JSON data property");let l=c.value,g=U(l,u,t);Object.defineProperty(k,i,{value:g,enumerable:!0,writable:!0,configurable:!0}),p++}return r&&(p!==y||k.length!==y)?d(n,"is not a complete saved list"):k}catch(r){if(r instanceof w)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 f(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]:f(e[n],`${t}.${n}`,!1)}}function _(e,n,t){return e==null?[]:F(e)?e.map((o,r)=>t(o,`${n}[${String(r)}]`)):d(n,"is not a complete saved list")}function B(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=f(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 pe(e,n){let t=C(e,n);return{_key:f(t._key,`${n}._key`),amount:B(t.amount,`${n}.amount`),...S(t,"label",n)}}function fe(e,n){let t=C(e,n);return{_key:f(t._key,`${n}._key`),name:f(t.name,`${n}.name`),amount:B(t.amount,`${n}.amount`)}}function me(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:f(t._key,`${n}._key`),name:f(t.name,`${n}.name`),...S(t,"description",n),...S(t,"priceNote",n),...S(t,"allergenNote",n),prices:_(t.prices,`${n}.prices`,pe),extras:_(t.extras,`${n}.extras`,fe),dietary:_(t.dietary,`${n}.dietary`,f),availability:o}}function ge(e,n){let t=C(e,n);return{_key:f(t._key,`${n}._key`),title:f(t.title,`${n}.title`),...S(t,"service",n),items:_(t.items,`${n}.items`,me)}}function he(e,n){let t=C(e,n);return{_key:f(t._key,`${n}._key`),label:f(t.label,`${n}.label`),...S(t,"note",n),sections:_(t.sections,`${n}.sections`,ge)}}function ke(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 R(e,n="menu"){return be(U(e,n),n)}function be(e,n){let t=C(e,n);if(t._type!=="menu")return d(`${n}._type`,"is not menu");if(!ke(t))return d(`${n}._id`,"is not a published menu identity");let o=f(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`,he);return r.length===0?d(`${n}.variants`,"has no menu choices"):{_type:"menu",_id:f(t._id,`${n}._id`),_rev:f(t._rev,`${n}._rev`),_updatedAt:o,title:f(t.title,`${n}.title`),locationKeys:_(t.locationKeys,`${n}.locationKeys`,f),variants:r,...S(t,"note",n),...Object.hasOwn(t,"signOff")?{signOff:t.signOff}:{}}}function H(e){if(e===null)return!0;try{return R(e),!0}catch{return!1}}var Q="malformed-content",w=class extends Error{code=Q;documentId;problems;constructor(n,t){super(`${Q}: ${n}: ${t.join("; ")}`),this.name="MalformedContentError",this.documentId=n,this.problems=t}};var z=`{..., "sections": coalesce(sections[]{..., _type == "menuBlock" => {menu->{${O}}}, _type == "linkListBlock" => {links[]{..., "page": page->{title, "slug": slug.current}}}}, sections)}`,Ue=`*[_type == "page" && defined(slug.current)]|order(slug.current asc)${z}`,Be=`*[_type == "page" && slug.current == $slug][0]${z}`;var $e=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,Se=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,_e=/^[a-z0-9]{6,12}\.[a-z][a-z0-9_-]{0,63}$/;function V(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"||!$e.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"||!Se.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 A(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:V(e.dependencies),resolve:e.resolve})}function b(e,n){if(typeof e!="string"||e.length>77||!_e.test(e))throw new TypeError("Invalid CMS scope");let t=V(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 J(e){return A({name:"menu.v1",query:`*[_type == "menu" && _id == $id && !(_id in path("drafts.**")) && !(_id in path("versions.**"))][0]{${O}}`,params:{id:e},dependencies:{types:["menu"],ids:[e]},resolve:(n,t)=>{if(!H(t)||t!==null&&t._id!==e)throw new TypeError("Invalid CMS menu fallback");if(n==null)return{data:t,fallbackFields:["$"]};let o=R(n);if(o._id!==e)throw new w("menu",["menu._id does not match the requested document"]);return{data:o,fallbackFields:[]}}})}function Z(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 W(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;b(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 a,k,y;try{if(a=A(r),y=b(t.scope,a.dependencies),!s||!Object.hasOwn(s,"fallback"))throw new TypeError;k=Z(a.resolve(null,s.fallback))}catch{throw new TypeError("Invalid CMS query or fallback configuration")}let p=(c,l,g)=>(o({event:"cms.fallback",query:a.name,reason:c,fields:["$"],...l===void 0?{}:{status:l},...g?{warnings:g}:{}}),{data:k.data,source:"fallback",fallbackFields:["$"],reason:c,...g?{warnings:g}:{}}),i;try{i=await t.read({name:a.name,query:a.query,params:a.params},{tags:y,revalidateSeconds:n})}catch{return p("network")}if(!i.ok){let l=["configuration","network","timeout","rate-limit","upstream","plan-limit","permission","malformed"].includes(i.reason)?i.reason:"malformed",g=Number.isInteger(i.status)&&(i.status??0)>=100&&(i.status??0)<=599?i.status:void 0;return p(l,g)}if(i.value===null||i.value===void 0)return p("missing");let u;try{u=Z(a.resolve(i.value,s.fallback))}catch{return p("malformed")}return u.fallbackFields.includes("$")?{...p("invalid-field",void 0,u.warnings),data:u.data}:u.fallbackFields.length>0?(o({event:"cms.partial-fallback",query:a.name,reason:"invalid-field",fields:u.fallbackFields,...u.warnings?{warnings:u.warnings}:{}}),{...u,source:"mixed",reason:"invalid-field"}):{...u,source:"cms"}}}}var h=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),m=e=>typeof e=="string"&&e.trim()?e.trim():null,Ce=(e,n)=>e._type===n&&typeof e._id=="string"&&e._id.length>0&&!/^(drafts|versions)\./.test(e._id),we=/^\d{4}-\d{2}-\d{2}$/,Y=/^([01]\d|2[0-3]):[0-5]\d$/,Ae=["mon","tue","wed","thu","fri","sat","sun"];async function G(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 Te=/^[A-Za-z0-9._+-]{1,64}@[A-Za-z0-9-]{1,63}(?:\.[A-Za-z0-9-]{1,63})*\.[A-Za-z]{2,63}$/;function Re(e){let n=m(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 T(e){if(typeof e!="function")throw new TypeError("A client validator is required")}function M(e,n,t){if(T(t),!h(e)||e.status!=="open")return null;let o=m(e.closingDate);if(o!==null&&o<n||t(e)!==null)return null;let r=m(e.title),s=e.location==="Other"?m(e.locationNote):m(e.location);if(!r||!s)return null;let a=m(e.pdfUrl);return{id:String(m(e._id)),title:r,location:s,summary:m(e.summary),pdfUrl:a?.startsWith("https://cdn.sanity.io/files/")?a:null,applyUrl:Re(e.applyUrl),applyEmail:typeof e.applyEmail=="string"&&e.applyEmail.length<=254&&Te.test(e.applyEmail)?e.applyEmail:null}}function j(e,n,t){if(T(t),!Array.isArray(e))throw new TypeError("Sanity returned vacancies that are not a list");return e.map(o=>({value:M(o,n,t),order:h(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 K(e){return b(e,{types:["vacancy"]})}function X(e,n){if(!we.test(e))throw new TypeError("Invalid calendar date");return T(n),A({name:"vacancy.open.v1",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, location, locationNote, summary, "pdfUrl": jobDescriptionPdf.asset->url, applyUrl, applyEmail, status, closingDate, order}',params:{today:e},dependencies:{types:["vacancy"]},resolve:(t,o)=>({data:t==null?o:j(t,e,n),fallbackFields:t==null?["$"]:[]})})}var xe=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Ie=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function L(e){return!h(e)||typeof e._id!="string"||!h(e.slug)||typeof e.slug.current!="string"||!Ie.test(e.slug.current)||m(e.name)===null||e.addressLines!==void 0&&e.addressLines!==null&&(!Array.isArray(e.addressLines)||Array.from(e.addressLines).some(n=>m(n)===null))||e.postcode!==void 0&&e.postcode!==null&&m(e.postcode)===null||e.coordinates!==void 0&&e.coordinates!==null&&(!h(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:m(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 ee(e){if(!h(e))return null;let n={};for(let t of xe){let o=e[t];if(!Array.isArray(o)||!Array.from(o).every(r=>h(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 P(e,n,t){T(t);let o=L(e);if(o===null||o.slug!==n.id)return{data:n,fallbackFields:["$"]};let r=ee(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 N(e,n,t){T(t);let o=L(e);if(o===null||o.slug!==n.id)return{data:n,fallbackFields:["$"]};let r=ee(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 ne(e){return b(e,{types:["location"]})}function te(e,n){return A({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 y of t){let p=L(y);p!==null&&(r.has(p.slug)?s.add(p.slug):r.set(p.slug,y))}let a=[];return{data:o.map((y,p)=>{let i=r.get(y.id),u=i===void 0||s.has(y.id)?{data:y,fallbackFields:["$"]}:n(i,y);return a.push(...u.fallbackFields.map(c=>c==="$"?`locations[${p}]`:`locations[${p}].${c}`)),u.data}),fallbackFields:o.length>0&&a.length===o.length&&a.every(y=>/^locations\[\d+\]$/.test(y))?["$"]:a}}})}function oe(e){return T(e),te("locations.v1",(n,t)=>P(n,t,e))}function re(e){return T(e),te("locations.business.v1",(n,t)=>N(n,t,e))}function Ee(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 v(e,n){if(!h(e)||!Ce(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(!h(o)||o.day!==Ae[r]||typeof o.rest!="boolean"||!Array.isArray(o.stops))throw new TypeError("Invalid schedule day");let s=o.day,a=o.rest,k=o.stops,y=n.days.find(c=>c.day===s),p=new Set(y?.stops.map(c=>c.id)??[]),i=new Set,u=k.map(c=>{if(!h(c))throw new TypeError("Invalid schedule stop");let l=c;if(!m(l.name)||!Y.test(String(l.from??""))||!Y.test(String(l.to??""))||!m(l.address))throw new TypeError("Invalid schedule stop");let g=y?.stops.find($=>$.name===l.name&&!i.has($.id));return g?(i.add(g.id),{...g,name:String(l.name),from:String(l.from),to:String(l.to),address:String(l.address)}):{id:Ee(s,String(l.name),p),name:String(l.name),from:String(l.from),to:String(l.to),address:String(l.address),place:null,postcode:null,notes:null,lat:null,lng:null,coordinateSource:null,approximate:!1,needsConfirmation:null,captured:`${l.name}
|
|
6
|
+
${l.from}-${l.to}
|
|
7
|
+
${l.address}`}});return{day:s,rest:a,stops:a?[]:u}});return{timeZone:n.timeZone,days:t}}function se(e){return b(e,{types:["schedule"],ids:["schedule"]})}function ie(){return A({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:v(e,n),fallbackFields:e==null?["$"]:[]})})}0&&(module.exports={MENU_DECORATIONS,MENU_LAYOUTS,MENU_LAYOUT_DEFAULTS,businessLocationsQuery,createCmsReader,locationTags,locationsQuery,menuQuery,menuTags,openVacanciesQuery,parseBusinessLocation,parseLocationDocument,parseMenuDocument,parseScheduleDocument,parseVacancies,parseVacancyDocument,resolveWithFallback,scheduleQuery,scheduleTags,vacancyTags});
|
|
6
8
|
//# sourceMappingURL=server.cjs.map
|