@sanity/client 6.24.0 → 6.24.2-canary.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/dist/_chunks-cjs/resolveEditInfo.cjs +1 -2
- package/dist/_chunks-cjs/resolveEditInfo.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaClean.cjs +1 -2
- package/dist/_chunks-cjs/stegaClean.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +1 -2
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
- package/dist/_chunks-es/resolveEditInfo.js +1 -2
- package/dist/_chunks-es/resolveEditInfo.js.map +1 -1
- package/dist/_chunks-es/stegaClean.js +1 -2
- package/dist/_chunks-es/stegaClean.js.map +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +1 -2
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
- package/dist/csm.cjs +1 -2
- package/dist/csm.cjs.map +1 -1
- package/dist/csm.d.cts +99 -34
- package/dist/csm.d.ts +99 -34
- package/dist/csm.js +1 -2
- package/dist/csm.js.map +1 -1
- package/dist/index.browser.cjs +4 -4
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +6 -5
- package/dist/index.browser.d.ts +6 -5
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +3312 -98
- package/dist/stega.browser.d.ts +3312 -98
- package/dist/stega.d.cts +3312 -98
- package/dist/stega.d.ts +3312 -98
- package/package.json +16 -16
- package/src/config.ts +3 -1
- package/src/csm/types.ts +1 -1
- package/src/http/request.ts +1 -1
- package/src/index.browser.ts +1 -1
- package/src/index.ts +1 -1
- package/src/stega/stegaEncodeSourceMap.ts +5 -1
- package/src/util/pick.ts +1 -1
- package/src/warnings.ts +1 -1
- package/umd/sanityClient.js +102 -117
- package/umd/sanityClient.min.js +2 -2
package/umd/sanityClient.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SanityClient = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
const e=!(typeof navigator>"u")&&"ReactNative"===navigator.product,t={timeout:e?6e4:12e4},r=function(r){const a={...t,..."string"==typeof r?{url:r}:r};if(a.timeout=n$1(a.timeout),a.query){const{url:t,searchParams:r}=function(t){const r=t.indexOf("?");if(-1===r)return {url:t,searchParams:new URLSearchParams};const n=t.slice(0,r),a=t.slice(r+1);if(!e)return {url:n,searchParams:new URLSearchParams(a)};if("function"!=typeof decodeURIComponent)throw new Error("Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined");const s=new URLSearchParams;for(const e of a.split("&")){const[t,r]=e.split("=");t&&s.append(o$1(t),o$1(r||""));}return {url:n,searchParams:s}}(a.url);for(const[e,o]of Object.entries(a.query)){if(
|
|
7
|
+
const e=!(typeof navigator>"u")&&"ReactNative"===navigator.product,t={timeout:e?6e4:12e4},r=function(r){const a={...t,..."string"==typeof r?{url:r}:r};if(a.timeout=n$1(a.timeout),a.query){const{url:t,searchParams:r}=function(t){const r=t.indexOf("?");if(-1===r)return {url:t,searchParams:new URLSearchParams};const n=t.slice(0,r),a=t.slice(r+1);if(!e)return {url:n,searchParams:new URLSearchParams(a)};if("function"!=typeof decodeURIComponent)throw new Error("Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined");const s=new URLSearchParams;for(const e of a.split("&")){const[t,r]=e.split("=");t&&s.append(o$1(t),o$1(r||""));}return {url:n,searchParams:s}}(a.url);for(const[e,o]of Object.entries(a.query)){if(undefined!==o)if(Array.isArray(o))for(const t of o)r.append(e,t);else r.append(e,o);const n=r.toString();n&&(a.url=`${t}?${n}`);}}return a.method=a.body&&!a.method?"POST":(a.method||"GET").toUpperCase(),a};function o$1(e){return decodeURIComponent(e.replace(/\+/g," "))}function n$1(e){if(false===e||0===e)return false;if(e.connect||e.socket)return e;const r=Number(e);return isNaN(r)?n$1(t.timeout):{connect:r,socket:r}}const a$2=/^https?:\/\//i,s$2=function(e){if(!a$2.test(e.url))throw new Error(`"${e.url}" is not a valid URL`)};function c$3(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}
|
|
8
8
|
|
|
9
|
-
const o=["request","response","progress","error","abort"],s$1=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function n(r$1,a){const i=[],u=s$1.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[r],validateOptions:[s$2]});function l(e){const t=o.reduce(((e,t)=>(e[t]=function(){const e=Object.create(null);let t=0;return {publish:function(t){for(const r in e)e[r](t);},subscribe:function(r){const o=t++;return e[o]=r,function(){delete e[o];}}}}(),e)),{}),r=(e=>function(t,r,...o){const s="onError"===t;let n=r;for(let r=0;r<e[t].length&&(n=(0, e[t][r])(n,...o),!s||n);r++);return n})(u),s=r("processOptions",e);r("validateOptions",s);const n={options:s,channels:t,applyMiddleware:r};let i;const l=t.request.subscribe((e=>{i=a(e,((o,s)=>((e,o,s)=>{let n=e,a=o;if(!n)try{a=r("onResponse",o,s);}catch(e){a=null,n=e;}n=n&&r("onError",n,s),n?t.error.publish(n):a&&t.response.publish(a);})(o,s,e)));}));t.abort.subscribe((()=>{l(),i&&i.abort();}));const c=r("onReturn",t,n);return c===t&&t.request.publish(n),c}return l.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&u.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return s$1.forEach((t=>{e[t]&&u[t].push(e[t]);})),i.push(e),l},l.clone=()=>n(i,a),r$1.forEach(l.use),l}var a$1=function(e){return e.replace(/^\s+|\s+$/g,"")},i=c$3((function(e){if(!e)return {};for(var t={},r=a$1(e).split("\n"),o=0;o<r.length;o++){var s=r[o],n=s.indexOf(":"),i=a$1(s.slice(0,n)).toLowerCase(),u=a$1(s.slice(n+1));typeof t[i]>"u"?t[i]=u:(l=t[i],"[object Array]"===Object.prototype.toString.call(l)?t[i].push(u):t[i]=[t[i],u]);}var l;return t}));let u$2 = class u{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#o={};#s;#n={};#a;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#s=
|
|
9
|
+
const o=["request","response","progress","error","abort"],s$1=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function n(r$1,a){const i=[],u=s$1.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[r],validateOptions:[s$2]});function l(e){const t=o.reduce(((e,t)=>(e[t]=function(){const e=Object.create(null);let t=0;return {publish:function(t){for(const r in e)e[r](t);},subscribe:function(r){const o=t++;return e[o]=r,function(){delete e[o];}}}}(),e)),{}),r=(e=>function(t,r,...o){const s="onError"===t;let n=r;for(let r=0;r<e[t].length&&(n=(0, e[t][r])(n,...o),!s||n);r++);return n})(u),s=r("processOptions",e);r("validateOptions",s);const n={options:s,channels:t,applyMiddleware:r};let i;const l=t.request.subscribe((e=>{i=a(e,((o,s)=>((e,o,s)=>{let n=e,a=o;if(!n)try{a=r("onResponse",o,s);}catch(e){a=null,n=e;}n=n&&r("onError",n,s),n?t.error.publish(n):a&&t.response.publish(a);})(o,s,e)));}));t.abort.subscribe((()=>{l(),i&&i.abort();}));const c=r("onReturn",t,n);return c===t&&t.request.publish(n),c}return l.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&u.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return s$1.forEach((t=>{e[t]&&u[t].push(e[t]);})),i.push(e),l},l.clone=()=>n(i,a),r$1.forEach(l.use),l}var a$1=function(e){return e.replace(/^\s+|\s+$/g,"")},i=c$3((function(e){if(!e)return {};for(var t={},r=a$1(e).split("\n"),o=0;o<r.length;o++){var s=r[o],n=s.indexOf(":"),i=a$1(s.slice(0,n)).toLowerCase(),u=a$1(s.slice(n+1));typeof t[i]>"u"?t[i]=u:(l=t[i],"[object Array]"===Object.prototype.toString.call(l)?t[i].push(u):t[i]=[t[i],u]);}var l;return t}));let u$2 = class u{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#o={};#s;#n={};#a;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#s=undefined;}abort(){this.#s&&this.#s.abort();}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#o[e]=t;}setInit(e,t=true){this.#n=e,this.#a=t;}send(e){const t="arraybuffer"!==this.responseType,r={...this.#n,method:this.#e,headers:this.#o,body:e};"function"==typeof AbortController&&this.#a&&(this.#s=new AbortController,typeof EventTarget<"u"&&this.#s.signal instanceof EventTarget&&(r.signal=this.#s.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`;})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.();})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.();}));}};const l$1="function"==typeof XMLHttpRequest?"xhr":"fetch",c$2="xhr"===l$1?XMLHttpRequest:u$2,h=(e,t)=>{const r=e.options,o=e.applyMiddleware("finalizeOptions",r),s={},n=e.applyMiddleware("interceptRequest",undefined,{adapter:l$1,context:e});if(n){const e=setTimeout(t,0,null,n);return {abort:()=>clearTimeout(e)}}let a=new c$2;a instanceof u$2&&"object"==typeof o.fetch&&a.setInit(o.fetch,o.useAbortSignal??true);const h=o.headers,d=o.timeout;let p=false,f=false,b=false;if(a.onerror=e=>{m(a instanceof u$2?e instanceof Error?e:new Error(`Request error while attempting to reach is ${o.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`));},a.ontimeout=e=>{m(new Error(`Request timeout while attempting to reach ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`));},a.onabort=()=>{w(true),p=true;},a.onreadystatechange=()=>{d&&(w(),s.socket=setTimeout((()=>y("ESOCKETTIMEDOUT")),d.socket)),!p&&4===a.readyState&&0!==a.status&&function(){if(!(p||f||b)){if(0===a.status)return void m(new Error("Unknown XHR error"));w(),f=true,t(null,{body:a.response||(""===a.responseType||"text"===a.responseType?a.responseText:""),url:o.url,method:o.method,headers:i(a.getAllResponseHeaders()),statusCode:a.status,statusMessage:a.statusText});}}();},a.open(o.method,o.url,true),a.withCredentials=!!o.withCredentials,h&&a.setRequestHeader)for(const e in h)h.hasOwnProperty(e)&&a.setRequestHeader(e,h[e]);return o.rawBody&&(a.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:o,adapter:l$1,request:a,context:e}),a.send(o.body||null),d&&(s.connect=setTimeout((()=>y("ETIMEDOUT")),d.connect)),{abort:function(){p=true,a&&a.abort();}};function y(t){b=true,a.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${o.url}`:`Connection timed out on request to ${o.url}`);r.code=t,e.channels.error.publish(r);}function w(e){(e||p||a.readyState>=2&&s.connect)&&clearTimeout(s.connect),s.socket&&clearTimeout(s.socket);}function m(e){if(f)return;w(true),f=true,a=null;const r=e||new Error(`Network error while attempting to reach ${o.url}`);r.isNetworkError=true,r.request=o,t(r);}},d=(e=[],t=h)=>n(e,t),p$1="browser";
|
|
10
10
|
|
|
11
|
-
var a,c$1,u$1={exports:{}};function l(){if(c$1)return a;c$1=1;var e=1e3,t=60*e,s=60*t,n=24*s,r=7*n,o=365.25*n;function i(e,t,s,n){var r=t>=1.5*s;return Math.round(e/s)+" "+n+(r?"s":"")}return a=function(a,c){c=c||{};var u,l,p=typeof a;if("string"===p&&a.length>0)return function(i){if(!((i=String(i)).length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(a){var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*r;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*s;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}}}(a);if("number"===p&&isFinite(a))return c.long?(u=a,(l=Math.abs(u))>=n?i(u,l,n,"day"):l>=s?i(u,l,s,"hour"):l>=t?i(u,l,t,"minute"):l>=e?i(u,l,e,"second"):u+" ms"):function(r){var o=Math.abs(r);return o>=n?Math.round(r/n)+"d":o>=s?Math.round(r/s)+"h":o>=t?Math.round(r/t)+"m":o>=e?Math.round(r/e)+"s":r+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var p=function(e){function t(e){let n,r,o,i=null;function a(...e){if(!a.enabled)return;const s=a,r=Number(new Date),o=r-(n||r);s.diff=o,s.prev=n,s.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,r)=>{if("%%"===n)return "%";i++;const o=t.formatters[r];if("function"==typeof o){const t=e[i];n=o.call(s,t),e.splice(i,1),i--;}return n})),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e);}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=s,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable
|
|
11
|
+
var a,c$1,u$1={exports:{}};function l(){if(c$1)return a;c$1=1;var e=1e3,t=60*e,s=60*t,n=24*s,r=7*n,o=365.25*n;function i(e,t,s,n){var r=t>=1.5*s;return Math.round(e/s)+" "+n+(r?"s":"")}return a=function(a,c){c=c||{};var u,l,p=typeof a;if("string"===p&&a.length>0)return function(i){if(!((i=String(i)).length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(a){var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case "years":case "year":case "yrs":case "yr":case "y":return c*o;case "weeks":case "week":case "w":return c*r;case "days":case "day":case "d":return c*n;case "hours":case "hour":case "hrs":case "hr":case "h":return c*s;case "minutes":case "minute":case "mins":case "min":case "m":return c*t;case "seconds":case "second":case "secs":case "sec":case "s":return c*e;case "milliseconds":case "millisecond":case "msecs":case "msec":case "ms":return c;default:return}}}}(a);if("number"===p&&isFinite(a))return c.long?(u=a,(l=Math.abs(u))>=n?i(u,l,n,"day"):l>=s?i(u,l,s,"hour"):l>=t?i(u,l,t,"minute"):l>=e?i(u,l,e,"second"):u+" ms"):function(r){var o=Math.abs(r);return o>=n?Math.round(r/n)+"d":o>=s?Math.round(r/s)+"h":o>=t?Math.round(r/t)+"m":o>=e?Math.round(r/e)+"s":r+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var p=function(e){function t(e){let n,r,o,i=null;function a(...e){if(!a.enabled)return;const s=a,r=Number(new Date),o=r-(n||r);s.diff=o,s.prev=n,s.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,r)=>{if("%%"===n)return "%";i++;const o=t.formatters[r];if("function"==typeof o){const t=e[i];n=o.call(s,t),e.splice(i,1),i--;}return n})),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e);}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=s,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:true,configurable:false,get:()=>null!==i?i:(r!==t.namespaces&&(r=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e;}}),"function"==typeof t.init&&t.init(a),a}function s(e,s){const n=t(this.namespace+(typeof s>"u"?":":s)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let s;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),r=n.length;for(s=0;s<r;s++)n[s]&&("-"===(e=n[s].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")));},t.enabled=function(e){if("*"===e[e.length-1])return true;let s,n;for(s=0,n=t.skips.length;s<n;s++)if(t.skips[s].test(e))return false;for(s=0,n=t.names.length;s<n;s++)if(t.names[s].test(e))return true;return false},t.humanize=l(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");},Object.keys(e).forEach((s=>{t[s]=e[s];})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t),s|=0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;t.splice(1,0,s,"color: inherit");let n=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(r=n));})),t.splice(r,0,s);},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug");}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug");}catch{}return !e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return !(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=(()=>{let e=false;return ()=>{e||(e=true,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=p(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return "[UnexpectedJSONParseError]: "+e.message}};}(u$1,u$1.exports);c$3(u$1.exports);const w=typeof Buffer>"u"?()=>false:e=>Buffer.isBuffer(e);function F(e){return "[object Object]"===Object.prototype.toString.call(e)}function O$1(e){if(false===F(e))return false;const t=e.constructor;if(undefined===t)return true;const s=t.prototype;return !(false===F(s)||false===s.hasOwnProperty("isPrototypeOf"))}const j=["boolean","string","number"];function v(){return {processOptions:e=>{const t=e.body;return !t||"function"==typeof t.pipe||w(t)||-1===j.indexOf(typeof t)&&!Array.isArray(t)&&!O$1(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function x(e){return {onResponse:s=>{const n=s.headers["content-type"]||"",r=e&&e.force||-1!==n.indexOf("application/json");return s.body&&n&&r?Object.assign({},s,{body:t(s.body)}):s},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message=`Failed to parsed response body as JSON: ${e.message}`,e}}}let R={};typeof globalThis<"u"?R=globalThis:typeof window<"u"?R=window:typeof global<"u"?R=global:typeof self<"u"&&(R=self);var k=R;function q(e={}){const t=e.implementation||k.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return {onReturn:(e,s)=>new t((t=>(e.error.subscribe((e=>t.error(e))),e.progress.subscribe((e=>t.next(Object.assign({type:"progress"},e)))),e.response.subscribe((e=>{t.next(Object.assign({type:"response"},e)),t.complete();})),e.request.publish(s),()=>e.abort.publish())))}}function A(){return {onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,s=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;s.channels.progress.publish({stage:e,percent:n,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable});}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=n("upload")),"onprogress"in t&&(t.onprogress=n("download"));}}}var I$1=(e,t,s)=>("GET"===s.method||"HEAD"===s.method)&&(e.isNetworkError||false);function M(e){return 100*Math.pow(2,e)+100*Math.random()}const _$1=(e={})=>(e=>{const t=e.maxRetries||5,s=e.retryDelay||M,n=e.shouldRetry;return {onError:(e,r)=>{const o=r.options,i=o.maxRetries||t,a=o.retryDelay||s,c=o.shouldRetry||n,u=o.attemptNumber||0;if(null!==(l=o.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,o)||u>=i)return e;var l;const p=Object.assign({},r,{options:Object.assign({},o,{attemptNumber:u+1})});return setTimeout((()=>r.channels.request.publish(p)),a(u)),null}}})({shouldRetry:I$1,...e});_$1.shouldRetry=I$1;
|
|
12
12
|
|
|
13
13
|
/******************************************************************************
|
|
14
14
|
Copyright (c) Microsoft Corporation.
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
25
25
|
PERFORMANCE OF THIS SOFTWARE.
|
|
26
26
|
***************************************************************************** */
|
|
27
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
27
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
28
28
|
|
|
29
29
|
var extendStatics = function(d, b) {
|
|
30
30
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function __generator(thisArg, body) {
|
|
55
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
56
|
-
return g =
|
|
55
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
56
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
57
57
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
58
58
|
function step(op) {
|
|
59
59
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
}
|
|
76
76
|
op = body.call(thisArg, _);
|
|
77
77
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
78
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] :
|
|
78
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : undefined, done: true };
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
if (m) return m.call(o);
|
|
85
85
|
if (o && typeof o.length === "number") return {
|
|
86
86
|
next: function () {
|
|
87
|
-
if (o && i >= o.length) o =
|
|
87
|
+
if (o && i >= o.length) o = undefined;
|
|
88
88
|
return { value: o && o[i++], done: !o };
|
|
89
89
|
}
|
|
90
90
|
};
|
|
@@ -125,8 +125,9 @@
|
|
|
125
125
|
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
126
126
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
127
127
|
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
128
|
-
return i =
|
|
129
|
-
function
|
|
128
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
129
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
130
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
130
131
|
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
131
132
|
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
132
133
|
function fulfill(value) { resume("next", value); }
|
|
@@ -269,7 +270,7 @@
|
|
|
269
270
|
}
|
|
270
271
|
teardown._addParent(this);
|
|
271
272
|
}
|
|
272
|
-
(this._finalizers = (_a = this._finalizers) !== null && _a !==
|
|
273
|
+
(this._finalizers = (_a = this._finalizers) !== null && _a !== undefined ? _a : []).push(teardown);
|
|
273
274
|
}
|
|
274
275
|
}
|
|
275
276
|
};
|
|
@@ -332,11 +333,11 @@
|
|
|
332
333
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
333
334
|
args[_i - 2] = arguments[_i];
|
|
334
335
|
}
|
|
335
|
-
return setTimeout.apply(
|
|
336
|
+
return setTimeout.apply(undefined, __spreadArray([handler, timeout], __read(args)));
|
|
336
337
|
},
|
|
337
338
|
clearTimeout: function (handle) {
|
|
338
339
|
var delegate = timeoutProvider.delegate;
|
|
339
|
-
return ((delegate === null || delegate ===
|
|
340
|
+
return ((delegate === null || delegate === undefined ? undefined : delegate.clearTimeout) || clearTimeout)(handle);
|
|
340
341
|
},
|
|
341
342
|
delegate: undefined,
|
|
342
343
|
};
|
|
@@ -424,10 +425,6 @@
|
|
|
424
425
|
};
|
|
425
426
|
return Subscriber;
|
|
426
427
|
}(Subscription));
|
|
427
|
-
var _bind = Function.prototype.bind;
|
|
428
|
-
function bind(fn, thisArg) {
|
|
429
|
-
return _bind.call(fn, thisArg);
|
|
430
|
-
}
|
|
431
428
|
var ConsumerObserver = (function () {
|
|
432
429
|
function ConsumerObserver(partialObserver) {
|
|
433
430
|
this.partialObserver = partialObserver;
|
|
@@ -477,23 +474,13 @@
|
|
|
477
474
|
var partialObserver;
|
|
478
475
|
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
479
476
|
partialObserver = {
|
|
480
|
-
next: (observerOrNext !== null && observerOrNext !==
|
|
481
|
-
error: error !== null && error !==
|
|
482
|
-
complete: complete !== null && complete !==
|
|
477
|
+
next: (observerOrNext !== null && observerOrNext !== undefined ? observerOrNext : undefined),
|
|
478
|
+
error: error !== null && error !== undefined ? error : undefined,
|
|
479
|
+
complete: complete !== null && complete !== undefined ? complete : undefined,
|
|
483
480
|
};
|
|
484
481
|
}
|
|
485
482
|
else {
|
|
486
|
-
|
|
487
|
-
if (_this && config.useDeprecatedNextContext) {
|
|
488
|
-
context_1 = Object.create(observerOrNext);
|
|
489
|
-
context_1.unsubscribe = function () { return _this.unsubscribe(); };
|
|
490
|
-
partialObserver = {
|
|
491
|
-
next: observerOrNext.next && bind(observerOrNext.next, context_1),
|
|
492
|
-
error: observerOrNext.error && bind(observerOrNext.error, context_1),
|
|
493
|
-
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
483
|
+
{
|
|
497
484
|
partialObserver = observerOrNext;
|
|
498
485
|
}
|
|
499
486
|
}
|
|
@@ -600,7 +587,7 @@
|
|
|
600
587
|
};
|
|
601
588
|
Observable.prototype._subscribe = function (subscriber) {
|
|
602
589
|
var _a;
|
|
603
|
-
return (_a = this.source) === null || _a ===
|
|
590
|
+
return (_a = this.source) === null || _a === undefined ? undefined : _a.subscribe(subscriber);
|
|
604
591
|
};
|
|
605
592
|
Observable.prototype[observable] = function () {
|
|
606
593
|
return this;
|
|
@@ -627,7 +614,7 @@
|
|
|
627
614
|
}());
|
|
628
615
|
function getPromiseCtor(promiseCtor) {
|
|
629
616
|
var _a;
|
|
630
|
-
return (_a = promiseCtor !== null && promiseCtor !==
|
|
617
|
+
return (_a = promiseCtor !== null && promiseCtor !== undefined ? promiseCtor : config.Promise) !== null && _a !== undefined ? _a : Promise;
|
|
631
618
|
}
|
|
632
619
|
function isObserver(value) {
|
|
633
620
|
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
|
|
@@ -637,7 +624,7 @@
|
|
|
637
624
|
}
|
|
638
625
|
|
|
639
626
|
function hasLift(source) {
|
|
640
|
-
return isFunction(source === null || source ===
|
|
627
|
+
return isFunction(source === null || source === undefined ? undefined : source.lift);
|
|
641
628
|
}
|
|
642
629
|
function operate(init) {
|
|
643
630
|
return function (source) {
|
|
@@ -707,7 +694,7 @@
|
|
|
707
694
|
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
|
|
708
695
|
var closed_1 = this.closed;
|
|
709
696
|
_super.prototype.unsubscribe.call(this);
|
|
710
|
-
!closed_1 && ((_a = this.onFinalize) === null || _a ===
|
|
697
|
+
!closed_1 && ((_a = this.onFinalize) === null || _a === undefined ? undefined : _a.call(this));
|
|
711
698
|
}
|
|
712
699
|
};
|
|
713
700
|
return OperatorSubscriber;
|
|
@@ -723,7 +710,7 @@
|
|
|
723
710
|
var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
|
|
724
711
|
|
|
725
712
|
function isPromise(value) {
|
|
726
|
-
return isFunction(value === null || value ===
|
|
713
|
+
return isFunction(value === null || value === undefined ? undefined : value.then);
|
|
727
714
|
}
|
|
728
715
|
|
|
729
716
|
function isInteropObservable(input) {
|
|
@@ -731,7 +718,7 @@
|
|
|
731
718
|
}
|
|
732
719
|
|
|
733
720
|
function isAsyncIterable(obj) {
|
|
734
|
-
return Symbol.asyncIterator && isFunction(obj === null || obj ===
|
|
721
|
+
return Symbol.asyncIterator && isFunction(obj === null || obj === undefined ? undefined : obj[Symbol.asyncIterator]);
|
|
735
722
|
}
|
|
736
723
|
|
|
737
724
|
function createInvalidObservableTypeError(input) {
|
|
@@ -747,7 +734,7 @@
|
|
|
747
734
|
var iterator = getSymbolIterator();
|
|
748
735
|
|
|
749
736
|
function isIterable(input) {
|
|
750
|
-
return isFunction(input === null || input ===
|
|
737
|
+
return isFunction(input === null || input === undefined ? undefined : input[iterator]);
|
|
751
738
|
}
|
|
752
739
|
|
|
753
740
|
function readableStreamLikeToAsyncGenerator(readableStream) {
|
|
@@ -766,7 +753,7 @@
|
|
|
766
753
|
case 3:
|
|
767
754
|
_a = _b.sent(), value = _a.value, done = _a.done;
|
|
768
755
|
if (!done) return [3, 5];
|
|
769
|
-
return [4, __await(
|
|
756
|
+
return [4, __await(undefined)];
|
|
770
757
|
case 4: return [2, _b.sent()];
|
|
771
758
|
case 5: return [4, __await(value)];
|
|
772
759
|
case 6: return [4, _b.sent()];
|
|
@@ -783,7 +770,7 @@
|
|
|
783
770
|
});
|
|
784
771
|
}
|
|
785
772
|
function isReadableStreamLike(obj) {
|
|
786
|
-
return isFunction(obj === null || obj ===
|
|
773
|
+
return isFunction(obj === null || obj === undefined ? undefined : obj.getReader);
|
|
787
774
|
}
|
|
788
775
|
|
|
789
776
|
function innerFrom(input) {
|
|
@@ -874,7 +861,7 @@
|
|
|
874
861
|
function process$1(asyncIterable, subscriber) {
|
|
875
862
|
var asyncIterable_1, asyncIterable_1_1;
|
|
876
863
|
var e_2, _a;
|
|
877
|
-
return __awaiter(this,
|
|
864
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
878
865
|
var value, e_2_1;
|
|
879
866
|
return __generator(this, function (_b) {
|
|
880
867
|
switch (_b.label) {
|
|
@@ -960,14 +947,14 @@
|
|
|
960
947
|
|
|
961
948
|
var isArray$2 = Array.isArray;
|
|
962
949
|
function callOrApply(fn, args) {
|
|
963
|
-
return isArray$2(args) ? fn.apply(
|
|
950
|
+
return isArray$2(args) ? fn.apply(undefined, __spreadArray([], __read(args))) : fn(args);
|
|
964
951
|
}
|
|
965
952
|
function mapOneOrManyArgs(fn) {
|
|
966
953
|
return map(function (args) { return callOrApply(fn, args); });
|
|
967
954
|
}
|
|
968
955
|
|
|
969
956
|
function combineLatestInit(observables, scheduler, valueTransform) {
|
|
970
|
-
if (valueTransform ===
|
|
957
|
+
if (valueTransform === undefined) { valueTransform = identity; }
|
|
971
958
|
return function (subscriber) {
|
|
972
959
|
maybeSchedule(scheduler, function () {
|
|
973
960
|
var length = observables.length;
|
|
@@ -1025,7 +1012,7 @@
|
|
|
1025
1012
|
}
|
|
1026
1013
|
var resultSelector = popResultSelector(args);
|
|
1027
1014
|
return resultSelector
|
|
1028
|
-
? pipe(combineLatest.apply(
|
|
1015
|
+
? pipe(combineLatest.apply(undefined, __spreadArray([], __read(args))), mapOneOrManyArgs(resultSelector))
|
|
1029
1016
|
: operate(function (source, subscriber) {
|
|
1030
1017
|
combineLatestInit(__spreadArray([source], __read(argsOrArgArray(args))))(subscriber);
|
|
1031
1018
|
});
|
|
@@ -1036,7 +1023,7 @@
|
|
|
1036
1023
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1037
1024
|
otherSources[_i] = arguments[_i];
|
|
1038
1025
|
}
|
|
1039
|
-
return combineLatest.apply(
|
|
1026
|
+
return combineLatest.apply(undefined, __spreadArray([], __read(otherSources)));
|
|
1040
1027
|
}
|
|
1041
1028
|
|
|
1042
1029
|
var s = { 0: 8203, 1: 8204, 2: 8205, 3: 8290, 4: 8291, 5: 8288, 6: 65279, 7: 8289, 8: 119155, 9: 119156, a: 119157, b: 119158, c: 119159, d: 119160, e: 119161, f: 119162 }, c = { 0: 8203, 1: 8204, 2: 8205, 3: 65279 }, u = new Array(4).fill(String.fromCodePoint(c[0])).join("");
|
|
@@ -1044,31 +1031,30 @@
|
|
|
1044
1031
|
let e = JSON.stringify(t);
|
|
1045
1032
|
return `${u}${Array.from(e).map((r) => {
|
|
1046
1033
|
let n = r.charCodeAt(0);
|
|
1047
|
-
if (n > 255)
|
|
1048
|
-
throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);
|
|
1034
|
+
if (n > 255) throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);
|
|
1049
1035
|
return Array.from(n.toString(4).padStart(4, "0")).map((o) => String.fromCodePoint(c[o])).join("");
|
|
1050
1036
|
}).join("")}`;
|
|
1051
1037
|
}
|
|
1052
1038
|
function I(t) {
|
|
1053
|
-
return !Number.isNaN(Number(t)) || /[a-z]/i.test(t) && !/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(t) ?
|
|
1039
|
+
return !Number.isNaN(Number(t)) || /[a-z]/i.test(t) && !/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(t) ? false : !!Date.parse(t);
|
|
1054
1040
|
}
|
|
1055
1041
|
function T(t) {
|
|
1056
1042
|
try {
|
|
1057
1043
|
new URL(t, t.startsWith("/") ? "https://acme.com" : void 0);
|
|
1058
1044
|
} catch {
|
|
1059
|
-
return
|
|
1045
|
+
return false;
|
|
1060
1046
|
}
|
|
1061
|
-
return
|
|
1047
|
+
return true;
|
|
1062
1048
|
}
|
|
1063
1049
|
function C(t, e, r = "auto") {
|
|
1064
|
-
return r ===
|
|
1050
|
+
return r === true || r === "auto" && (I(t) || T(t)) ? t : `${t}${E(e)}`;
|
|
1065
1051
|
}
|
|
1066
1052
|
Object.fromEntries(Object.entries(c).map((t) => t.reverse()));
|
|
1067
1053
|
Object.fromEntries(Object.entries(s).map((t) => t.reverse()));
|
|
1068
1054
|
var S = `${Object.values(s).map((t) => `\\u{${t.toString(16)}}`).join("")}`, f = new RegExp(`[${S}]{4,}`, "gu");
|
|
1069
1055
|
function _(t) {
|
|
1070
1056
|
var e;
|
|
1071
|
-
return { cleaned: t.replace(f, ""), encoded: ((e = t.match(f)) == null ?
|
|
1057
|
+
return { cleaned: t.replace(f, ""), encoded: ((e = t.match(f)) == null ? undefined : e[0]) || "" };
|
|
1072
1058
|
}
|
|
1073
1059
|
function O(t) {
|
|
1074
1060
|
return t && JSON.parse(_(JSON.stringify(t)).cleaned);
|
|
@@ -1103,7 +1089,7 @@
|
|
|
1103
1089
|
statusCode: res.statusCode,
|
|
1104
1090
|
responseBody: stringifyBody(body, res),
|
|
1105
1091
|
message: "",
|
|
1106
|
-
details:
|
|
1092
|
+
details: undefined
|
|
1107
1093
|
};
|
|
1108
1094
|
if (body.error && body.message)
|
|
1109
1095
|
return props.message = `${body.error} - ${body.message}`, props;
|
|
@@ -1173,10 +1159,9 @@
|
|
|
1173
1159
|
]);
|
|
1174
1160
|
}
|
|
1175
1161
|
function shouldRetry(err, attempt, options) {
|
|
1176
|
-
if (options.maxRetries === 0)
|
|
1177
|
-
return !1;
|
|
1162
|
+
if (options.maxRetries === 0) return false;
|
|
1178
1163
|
const isSafe = options.method === "GET" || options.method === "HEAD", isQuery = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
|
|
1179
|
-
return (isSafe || isQuery) && isRetriableResponse ?
|
|
1164
|
+
return (isSafe || isQuery) && isRetriableResponse ? true : _$1.shouldRetry(err, attempt, options);
|
|
1180
1165
|
}
|
|
1181
1166
|
const BASE_URL = "https://www.sanity.io/help/";
|
|
1182
1167
|
function generateHelpUrl(slug) {
|
|
@@ -1225,8 +1210,8 @@
|
|
|
1225
1210
|
return tag;
|
|
1226
1211
|
};
|
|
1227
1212
|
function once(fn) {
|
|
1228
|
-
let didCall =
|
|
1229
|
-
return (...args) => (didCall || (returnValue = fn(...args), didCall =
|
|
1213
|
+
let didCall = false, returnValue;
|
|
1214
|
+
return (...args) => (didCall || (returnValue = fn(...args), didCall = true), returnValue);
|
|
1230
1215
|
}
|
|
1231
1216
|
const createWarningPrinter = (message) => (
|
|
1232
1217
|
// eslint-disable-next-line no-console
|
|
@@ -1254,8 +1239,8 @@
|
|
|
1254
1239
|
]), defaultCdnHost = "apicdn.sanity.io", defaultConfig = {
|
|
1255
1240
|
apiHost: "https://api.sanity.io",
|
|
1256
1241
|
apiVersion: "1",
|
|
1257
|
-
useProjectHostname:
|
|
1258
|
-
stega: { enabled:
|
|
1242
|
+
useProjectHostname: true,
|
|
1243
|
+
stega: { enabled: false }
|
|
1259
1244
|
}, LOCALHOSTS = ["localhost", "127.0.0.1", "0.0.0.0"], isLocal = (host) => LOCALHOSTS.indexOf(host) !== -1;
|
|
1260
1245
|
function validateApiVersion(apiVersion) {
|
|
1261
1246
|
if (apiVersion === "1" || apiVersion === "X")
|
|
@@ -1264,7 +1249,7 @@
|
|
|
1264
1249
|
if (!(/^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0))
|
|
1265
1250
|
throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
|
|
1266
1251
|
}
|
|
1267
|
-
|
|
1252
|
+
function validateApiPerspective(perspective) {
|
|
1268
1253
|
if (Array.isArray(perspective)) {
|
|
1269
1254
|
for (const perspectiveValue of perspective)
|
|
1270
1255
|
if (perspectiveValue !== "published" && perspectiveValue !== "drafts" && !(typeof perspectiveValue == "string" && perspectiveValue.startsWith("r") && perspectiveValue !== "raw"))
|
|
@@ -1284,7 +1269,8 @@
|
|
|
1284
1269
|
"Invalid API perspective string, expected `published`, `previewDrafts` or `raw`"
|
|
1285
1270
|
);
|
|
1286
1271
|
}
|
|
1287
|
-
}
|
|
1272
|
+
}
|
|
1273
|
+
const initConfig = (config, prevConfig) => {
|
|
1288
1274
|
const specifiedConfig = {
|
|
1289
1275
|
...prevConfig,
|
|
1290
1276
|
...config,
|
|
@@ -1314,14 +1300,14 @@
|
|
|
1314
1300
|
);
|
|
1315
1301
|
if (typeof newConfig.stega.enabled != "boolean")
|
|
1316
1302
|
throw new Error(`stega.enabled must be a boolean, received ${newConfig.stega.enabled}`);
|
|
1317
|
-
if (newConfig.stega.enabled && newConfig.stega.studioUrl ===
|
|
1303
|
+
if (newConfig.stega.enabled && newConfig.stega.studioUrl === undefined)
|
|
1318
1304
|
throw new Error("stega.studioUrl must be defined when stega.enabled is true");
|
|
1319
1305
|
if (newConfig.stega.enabled && typeof newConfig.stega.studioUrl != "string" && typeof newConfig.stega.studioUrl != "function")
|
|
1320
1306
|
throw new Error(
|
|
1321
1307
|
`stega.studioUrl must be a string or a function, received ${newConfig.stega.studioUrl}`
|
|
1322
1308
|
);
|
|
1323
1309
|
const isBrowser = typeof window < "u" && window.location && window.location.hostname, isLocalhost = isBrowser && isLocal(window.location.hostname);
|
|
1324
|
-
isBrowser && isLocalhost && newConfig.token && newConfig.ignoreBrowserTokenWarning !==
|
|
1310
|
+
isBrowser && isLocalhost && newConfig.token && newConfig.ignoreBrowserTokenWarning !== true ? printBrowserTokenWarning() : typeof newConfig.useCdn > "u" && printCdnWarning(), projectBased && projectId(newConfig.projectId), newConfig.dataset && dataset(newConfig.dataset), "requestTagPrefix" in newConfig && (newConfig.requestTagPrefix = newConfig.requestTagPrefix ? requestTag(newConfig.requestTagPrefix).replace(/\.+$/, "") : undefined), newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, ""), newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost, newConfig.useCdn === true && newConfig.withCredentials && printCdnAndWithCredentialsWarning(), newConfig.useCdn = newConfig.useCdn !== false && !newConfig.withCredentials, validateApiVersion(newConfig.apiVersion);
|
|
1325
1311
|
const hostParts = newConfig.apiHost.split("://", 2), protocol = hostParts[0], host = hostParts[1], cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host;
|
|
1326
1312
|
return newConfig.useProjectHostname ? (newConfig.url = `${protocol}://${newConfig.projectId}.${host}/v${newConfig.apiVersion}`, newConfig.cdnUrl = `${protocol}://${newConfig.projectId}.${cdnHost}/v${newConfig.apiVersion}`) : (newConfig.url = `${newConfig.apiHost}/v${newConfig.apiVersion}`, newConfig.cdnUrl = newConfig.url), newConfig;
|
|
1327
1313
|
};
|
|
@@ -1468,13 +1454,13 @@ ${selectionOpts}`);
|
|
|
1468
1454
|
reset() {
|
|
1469
1455
|
return this.operations = {}, this;
|
|
1470
1456
|
}
|
|
1471
|
-
_assign(op, props, merge =
|
|
1457
|
+
_assign(op, props, merge = true) {
|
|
1472
1458
|
return validateObject(op, props), this.operations = Object.assign({}, this.operations, {
|
|
1473
1459
|
[op]: Object.assign({}, merge && this.operations[op] || {}, props)
|
|
1474
1460
|
}), this;
|
|
1475
1461
|
}
|
|
1476
1462
|
_set(op, props) {
|
|
1477
|
-
return this._assign(op, props,
|
|
1463
|
+
return this._assign(op, props, false);
|
|
1478
1464
|
}
|
|
1479
1465
|
}
|
|
1480
1466
|
class ObservablePatch extends BasePatch {
|
|
@@ -1493,7 +1479,7 @@ ${selectionOpts}`);
|
|
|
1493
1479
|
throw new Error(
|
|
1494
1480
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
1495
1481
|
);
|
|
1496
|
-
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments:
|
|
1482
|
+
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: true }, options);
|
|
1497
1483
|
return this.#client.mutate({ patch: this.serialize() }, opts);
|
|
1498
1484
|
}
|
|
1499
1485
|
}
|
|
@@ -1513,11 +1499,11 @@ ${selectionOpts}`);
|
|
|
1513
1499
|
throw new Error(
|
|
1514
1500
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
1515
1501
|
);
|
|
1516
|
-
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments:
|
|
1502
|
+
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: true }, options);
|
|
1517
1503
|
return this.#client.mutate({ patch: this.serialize() }, opts);
|
|
1518
1504
|
}
|
|
1519
1505
|
}
|
|
1520
|
-
const defaultMutateOptions = { returnDocuments:
|
|
1506
|
+
const defaultMutateOptions = { returnDocuments: false };
|
|
1521
1507
|
class BaseTransaction {
|
|
1522
1508
|
operations;
|
|
1523
1509
|
trxId;
|
|
@@ -1664,7 +1650,7 @@ ${selectionOpts}`);
|
|
|
1664
1650
|
headers: Object.assign({}, headers, overrides.headers || {}),
|
|
1665
1651
|
timeout: typeof timeout > "u" ? 5 * 60 * 1e3 : timeout,
|
|
1666
1652
|
proxy: overrides.proxy || config.proxy,
|
|
1667
|
-
json:
|
|
1653
|
+
json: true,
|
|
1668
1654
|
withCredentials,
|
|
1669
1655
|
fetch: typeof overrides.fetch == "object" && typeof config.fetch == "object" ? { ...config.fetch, ...overrides.fetch } : overrides.fetch || config.fetch
|
|
1670
1656
|
});
|
|
@@ -1680,11 +1666,11 @@ ${selectionOpts}`);
|
|
|
1680
1666
|
searchParams.append(`$${key}`, JSON.stringify(value));
|
|
1681
1667
|
for (const [key, value] of Object.entries(opts))
|
|
1682
1668
|
value && searchParams.append(key, `${value}`);
|
|
1683
|
-
return returnQuery ===
|
|
1684
|
-
}, excludeFalsey = (param, defValue) => param ===
|
|
1669
|
+
return returnQuery === false && searchParams.append("returnQuery", "false"), includeMutations === false && searchParams.append("includeMutations", "false"), `?${searchParams}`;
|
|
1670
|
+
}, excludeFalsey = (param, defValue) => param === false ? undefined : typeof param > "u" ? defValue : param, getMutationQuery = (options = {}) => ({
|
|
1685
1671
|
dryRun: options.dryRun,
|
|
1686
|
-
returnIds:
|
|
1687
|
-
returnDocuments: excludeFalsey(options.returnDocuments,
|
|
1672
|
+
returnIds: true,
|
|
1673
|
+
returnDocuments: excludeFalsey(options.returnDocuments, true),
|
|
1688
1674
|
visibility: options.visibility || "sync",
|
|
1689
1675
|
autoGenerateArrayKeys: options.autoGenerateArrayKeys,
|
|
1690
1676
|
skipCrossDatasetReferenceValidation: options.skipCrossDatasetReferenceValidation
|
|
@@ -1693,7 +1679,7 @@ ${selectionOpts}`);
|
|
|
1693
1679
|
const stega = "stega" in options ? {
|
|
1694
1680
|
..._stega || {},
|
|
1695
1681
|
...typeof options.stega == "boolean" ? { enabled: options.stega } : options.stega || {}
|
|
1696
|
-
} : _stega, params = stega.enabled ? stegaClean(_params) : _params, mapResponse = options.filterResponse ===
|
|
1682
|
+
} : _stega, params = stega.enabled ? stegaClean(_params) : _params, mapResponse = options.filterResponse === false ? (res) => res : (res) => res.result, { cache, next, ...opts } = {
|
|
1697
1683
|
// Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
|
|
1698
1684
|
// This is necessary in React Server Components to avoid opting out of Request Memoization.
|
|
1699
1685
|
useAbortSignal: typeof options.signal < "u",
|
|
@@ -1702,7 +1688,7 @@ ${selectionOpts}`);
|
|
|
1702
1688
|
...options,
|
|
1703
1689
|
// Default to not returning the query, unless `filterResponse` is `false`,
|
|
1704
1690
|
// or `returnQuery` is explicitly set. `true` is the default in Content Lake, so skip if truthy
|
|
1705
|
-
returnQuery: options.filterResponse ===
|
|
1691
|
+
returnQuery: options.filterResponse === false && options.returnQuery !== false
|
|
1706
1692
|
}, reqOpts = typeof cache < "u" || typeof next < "u" ? { ...opts, fetch: { cache, next } } : opts, $request = _dataRequest(client, httpRequest, "query", { query, params }, reqOpts);
|
|
1707
1693
|
return stega.enabled ? $request.pipe(
|
|
1708
1694
|
combineLatestWith(
|
|
@@ -1725,7 +1711,7 @@ ${selectionOpts}`);
|
|
|
1725
1711
|
function _getDocument(client, httpRequest, id, opts = {}) {
|
|
1726
1712
|
const options = {
|
|
1727
1713
|
uri: _getDataUrl(client, "doc", id),
|
|
1728
|
-
json:
|
|
1714
|
+
json: true,
|
|
1729
1715
|
tag: opts.tag,
|
|
1730
1716
|
signal: opts.signal
|
|
1731
1717
|
};
|
|
@@ -1737,7 +1723,7 @@ ${selectionOpts}`);
|
|
|
1737
1723
|
function _getDocuments(client, httpRequest, ids, opts = {}) {
|
|
1738
1724
|
const options = {
|
|
1739
1725
|
uri: _getDataUrl(client, "doc", ids.join(",")),
|
|
1740
|
-
json:
|
|
1726
|
+
json: true,
|
|
1741
1727
|
tag: opts.tag,
|
|
1742
1728
|
signal: opts.signal
|
|
1743
1729
|
};
|
|
@@ -1767,11 +1753,11 @@ ${selectionOpts}`);
|
|
|
1767
1753
|
function _mutate(client, httpRequest, mutations, options) {
|
|
1768
1754
|
let mut;
|
|
1769
1755
|
mutations instanceof Patch || mutations instanceof ObservablePatch ? mut = { patch: mutations.serialize() } : mutations instanceof Transaction || mutations instanceof ObservableTransaction ? mut = mutations.serialize() : mut = mutations;
|
|
1770
|
-
const muts = Array.isArray(mut) ? mut : [mut], transactionId = options && options.transactionId ||
|
|
1756
|
+
const muts = Array.isArray(mut) ? mut : [mut], transactionId = options && options.transactionId || undefined;
|
|
1771
1757
|
return _dataRequest(client, httpRequest, "mutate", { mutations: muts, transactionId }, options);
|
|
1772
1758
|
}
|
|
1773
1759
|
function _action(client, httpRequest, actions, options) {
|
|
1774
|
-
const acts = Array.isArray(actions) ? actions : [actions], transactionId = options && options.transactionId ||
|
|
1760
|
+
const acts = Array.isArray(actions) ? actions : [actions], transactionId = options && options.transactionId || undefined, skipCrossDatasetReferenceValidation = options && options.skipCrossDatasetReferenceValidation || undefined, dryRun = options && options.dryRun || undefined;
|
|
1775
1761
|
return _dataRequest(
|
|
1776
1762
|
client,
|
|
1777
1763
|
httpRequest,
|
|
@@ -1784,8 +1770,8 @@ ${selectionOpts}`);
|
|
|
1784
1770
|
const isMutation = endpoint === "mutate", isAction = endpoint === "actions", isQuery = endpoint === "query", strQuery = isMutation || isAction ? "" : encodeQueryString(body), useGet = !isMutation && !isAction && strQuery.length < getQuerySizeLimit, stringQuery = useGet ? strQuery : "", returnFirst = options.returnFirst, { timeout, token, tag, headers, returnQuery, lastLiveEventId, cacheMode } = options, uri = _getDataUrl(client, endpoint, stringQuery), reqOptions = {
|
|
1785
1771
|
method: useGet ? "GET" : "POST",
|
|
1786
1772
|
uri,
|
|
1787
|
-
json:
|
|
1788
|
-
body: useGet ?
|
|
1773
|
+
json: true,
|
|
1774
|
+
body: useGet ? undefined : body,
|
|
1789
1775
|
query: isMutation && getMutationQuery(options),
|
|
1790
1776
|
timeout,
|
|
1791
1777
|
headers,
|
|
@@ -1821,7 +1807,7 @@ ${selectionOpts}`);
|
|
|
1821
1807
|
);
|
|
1822
1808
|
}
|
|
1823
1809
|
function _create(client, httpRequest, doc, op, options = {}) {
|
|
1824
|
-
const mutation = { [op]: doc }, opts = Object.assign({ returnFirst:
|
|
1810
|
+
const mutation = { [op]: doc }, opts = Object.assign({ returnFirst: true, returnDocuments: true }, options);
|
|
1825
1811
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
|
|
1826
1812
|
}
|
|
1827
1813
|
function _requestObservable(client, httpRequest, options) {
|
|
@@ -1830,12 +1816,12 @@ ${selectionOpts}`);
|
|
|
1830
1816
|
const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
|
|
1831
1817
|
if (tag && options.tag !== null && (options.query = { tag: requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
|
|
1832
1818
|
const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap;
|
|
1833
|
-
resultSourceMap !==
|
|
1819
|
+
resultSourceMap !== undefined && resultSourceMap !== false && (options.query = { resultSourceMap, ...options.query });
|
|
1834
1820
|
const perspectiveOption = options.perspective || config.perspective;
|
|
1835
1821
|
typeof perspectiveOption < "u" && (validateApiPerspective(perspectiveOption), options.query = {
|
|
1836
1822
|
perspective: Array.isArray(perspectiveOption) ? perspectiveOption.join(",") : perspectiveOption,
|
|
1837
1823
|
...options.query
|
|
1838
|
-
}, perspectiveOption === "previewDrafts" && useCdn && (useCdn =
|
|
1824
|
+
}, perspectiveOption === "previewDrafts" && useCdn && (useCdn = false, printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === false && (options.query = { returnQuery: "false", ...options.query }), useCdn && options.cacheMode == "noStale" && (options.query = { cacheMode: "noStale", ...options.query });
|
|
1839
1825
|
}
|
|
1840
1826
|
const reqOptions = requestOptions(
|
|
1841
1827
|
config,
|
|
@@ -1857,7 +1843,7 @@ ${selectionOpts}`);
|
|
|
1857
1843
|
const config = client.config(), catalog = hasDataset(config), baseUri = `/${operation}/${catalog}`;
|
|
1858
1844
|
return `/data${path ? `${baseUri}/${path}` : baseUri}`.replace(/\/($|\?)/, "$1");
|
|
1859
1845
|
}
|
|
1860
|
-
function _getUrl(client, uri, canUseCdn =
|
|
1846
|
+
function _getUrl(client, uri, canUseCdn = false) {
|
|
1861
1847
|
const { url, cdnUrl } = client.config();
|
|
1862
1848
|
return `${canUseCdn ? cdnUrl : url}/${uri.replace(/^\//, "")}`;
|
|
1863
1849
|
}
|
|
@@ -1911,7 +1897,7 @@ ${selectionOpts}`);
|
|
|
1911
1897
|
}
|
|
1912
1898
|
function _upload(client, httpRequest, assetType, body, opts = {}) {
|
|
1913
1899
|
validateAssetType(assetType);
|
|
1914
|
-
let meta = opts.extract ||
|
|
1900
|
+
let meta = opts.extract || undefined;
|
|
1915
1901
|
meta && !meta.length && (meta = ["none"]);
|
|
1916
1902
|
const dataset2 = hasDataset(client.config()), assetEndpoint = assetType === "image" ? "images" : "files", options = optionsFromFile(opts, body), { tag, label, title, description, creditLine, filename, source } = options, query = {
|
|
1917
1903
|
label,
|
|
@@ -1934,7 +1920,7 @@ ${selectionOpts}`);
|
|
|
1934
1920
|
function optionsFromFile(opts, file) {
|
|
1935
1921
|
return typeof File > "u" || !(file instanceof File) ? opts : Object.assign(
|
|
1936
1922
|
{
|
|
1937
|
-
filename: opts.preserveFilename ===
|
|
1923
|
+
filename: opts.preserveFilename === false ? undefined : file.name,
|
|
1938
1924
|
contentType: file.type
|
|
1939
1925
|
},
|
|
1940
1926
|
opts
|
|
@@ -1949,17 +1935,17 @@ ${selectionOpts}`);
|
|
|
1949
1935
|
"effectFormat",
|
|
1950
1936
|
"tag"
|
|
1951
1937
|
], defaultOptions = {
|
|
1952
|
-
includeResult:
|
|
1938
|
+
includeResult: true
|
|
1953
1939
|
};
|
|
1954
1940
|
function _listen(query, params, opts = {}) {
|
|
1955
1941
|
const { url, token, withCredentials, requestTagPrefix } = this.config(), tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag, options = { ...defaults(opts, defaultOptions), tag }, listenOpts = pick(options, possibleOptions), qs = encodeQueryString({ query, params, options: { tag, ...listenOpts } }), uri = `${url}${_getDataUrl(this, "listen", qs)}`;
|
|
1956
1942
|
if (uri.length > MAX_URL_LENGTH)
|
|
1957
1943
|
return new Observable((observer) => observer.error(new Error("Query too large for listener")));
|
|
1958
1944
|
const listenFor = options.events ? options.events : ["mutation"], shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1, esOptions = {};
|
|
1959
|
-
return (token || withCredentials) && (esOptions.withCredentials =
|
|
1945
|
+
return (token || withCredentials) && (esOptions.withCredentials = true), token && (esOptions.headers = {
|
|
1960
1946
|
Authorization: `Bearer ${token}`
|
|
1961
1947
|
}), new Observable((observer) => {
|
|
1962
|
-
let es, reconnectTimer, stopped =
|
|
1948
|
+
let es, reconnectTimer, stopped = false, unsubscribed = false;
|
|
1963
1949
|
open();
|
|
1964
1950
|
function onError() {
|
|
1965
1951
|
stopped || (emitReconnect(), !stopped && es.readyState === es.CLOSED && (unsubscribe(), clearTimeout(reconnectTimer), reconnectTimer = setTimeout(open, 100)));
|
|
@@ -1972,7 +1958,7 @@ ${selectionOpts}`);
|
|
|
1972
1958
|
return event instanceof Error ? observer.error(event) : observer.next(event);
|
|
1973
1959
|
}
|
|
1974
1960
|
function onDisconnect() {
|
|
1975
|
-
stopped =
|
|
1961
|
+
stopped = true, unsubscribe(), observer.complete();
|
|
1976
1962
|
}
|
|
1977
1963
|
function unsubscribe() {
|
|
1978
1964
|
es && (es.removeEventListener("error", onError), es.removeEventListener("channelError", onChannelError), es.removeEventListener("disconnect", onDisconnect), listenFor.forEach((type) => es.removeEventListener(type, onMessage)), es.close());
|
|
@@ -1995,7 +1981,7 @@ ${selectionOpts}`);
|
|
|
1995
1981
|
});
|
|
1996
1982
|
}
|
|
1997
1983
|
function stop() {
|
|
1998
|
-
stopped =
|
|
1984
|
+
stopped = true, unsubscribe(), unsubscribed = true;
|
|
1999
1985
|
}
|
|
2000
1986
|
return stop;
|
|
2001
1987
|
});
|
|
@@ -2027,7 +2013,7 @@ ${selectionOpts}`);
|
|
|
2027
2013
|
* Requires `apiVersion` to be `2021-03-26` or later.
|
|
2028
2014
|
*/
|
|
2029
2015
|
events({
|
|
2030
|
-
includeDrafts =
|
|
2016
|
+
includeDrafts = false,
|
|
2031
2017
|
tag: _tag
|
|
2032
2018
|
} = {}) {
|
|
2033
2019
|
const {
|
|
@@ -2049,13 +2035,13 @@ ${selectionOpts}`);
|
|
|
2049
2035
|
throw new Error(
|
|
2050
2036
|
"The live events API requires API version X when 'includeDrafts: true'. This API is experimental and may change or even be removed."
|
|
2051
2037
|
);
|
|
2052
|
-
const path = _getDataUrl(this.#client, "live/events"), url = new URL(this.#client.getUrl(path,
|
|
2038
|
+
const path = _getDataUrl(this.#client, "live/events"), url = new URL(this.#client.getUrl(path, false)), tag = _tag && requestTagPrefix ? [requestTagPrefix, _tag].join(".") : _tag;
|
|
2053
2039
|
tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true");
|
|
2054
2040
|
const listenFor = ["restart", "message", "welcome", "reconnect"], esOptions = {};
|
|
2055
2041
|
return includeDrafts && token && (esOptions.headers = {
|
|
2056
2042
|
Authorization: `Bearer ${token}`
|
|
2057
|
-
}), includeDrafts && withCredentials && (esOptions.withCredentials =
|
|
2058
|
-
let es, reconnectTimer, stopped =
|
|
2043
|
+
}), includeDrafts && withCredentials && (esOptions.withCredentials = true), new Observable((observer) => {
|
|
2044
|
+
let es, reconnectTimer, stopped = false, unsubscribed = false;
|
|
2059
2045
|
open();
|
|
2060
2046
|
function onError(evt) {
|
|
2061
2047
|
if (!stopped) {
|
|
@@ -2107,7 +2093,7 @@ ${selectionOpts}`);
|
|
|
2107
2093
|
});
|
|
2108
2094
|
}
|
|
2109
2095
|
function stop() {
|
|
2110
|
-
stopped =
|
|
2096
|
+
stopped = true, unsubscribe(), unsubscribed = true;
|
|
2111
2097
|
}
|
|
2112
2098
|
return stop;
|
|
2113
2099
|
});
|
|
@@ -2223,7 +2209,7 @@ ${selectionOpts}`);
|
|
|
2223
2209
|
this.#client = client, this.#httpRequest = httpRequest;
|
|
2224
2210
|
}
|
|
2225
2211
|
list(options) {
|
|
2226
|
-
const uri = options?.includeMembers ===
|
|
2212
|
+
const uri = options?.includeMembers === false ? "/projects?includeMembers=false" : "/projects";
|
|
2227
2213
|
return _request(this.#client, this.#httpRequest, { uri });
|
|
2228
2214
|
}
|
|
2229
2215
|
/**
|
|
@@ -2242,7 +2228,7 @@ ${selectionOpts}`);
|
|
|
2242
2228
|
this.#client = client, this.#httpRequest = httpRequest;
|
|
2243
2229
|
}
|
|
2244
2230
|
list(options) {
|
|
2245
|
-
const uri = options?.includeMembers ===
|
|
2231
|
+
const uri = options?.includeMembers === false ? "/projects?includeMembers=false" : "/projects";
|
|
2246
2232
|
return lastValueFrom(_request(this.#client, this.#httpRequest, { uri }));
|
|
2247
2233
|
}
|
|
2248
2234
|
/**
|
|
@@ -2319,9 +2305,9 @@ ${selectionOpts}`);
|
|
|
2319
2305
|
return new ObservableSanityClient(this.#httpRequest, this.config());
|
|
2320
2306
|
}
|
|
2321
2307
|
config(newConfig) {
|
|
2322
|
-
if (newConfig ===
|
|
2308
|
+
if (newConfig === undefined)
|
|
2323
2309
|
return { ...this.#clientConfig };
|
|
2324
|
-
if (this.#clientConfig && this.#clientConfig.allowReconfigure ===
|
|
2310
|
+
if (this.#clientConfig && this.#clientConfig.allowReconfigure === false)
|
|
2325
2311
|
throw new Error(
|
|
2326
2312
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
2327
2313
|
);
|
|
@@ -2472,9 +2458,9 @@ ${selectionOpts}`);
|
|
|
2472
2458
|
return new SanityClient(this.#httpRequest, this.config());
|
|
2473
2459
|
}
|
|
2474
2460
|
config(newConfig) {
|
|
2475
|
-
if (newConfig ===
|
|
2461
|
+
if (newConfig === undefined)
|
|
2476
2462
|
return { ...this.#clientConfig };
|
|
2477
|
-
if (this.#clientConfig && this.#clientConfig.allowReconfigure ===
|
|
2463
|
+
if (this.#clientConfig && this.#clientConfig.allowReconfigure === false)
|
|
2478
2464
|
throw new Error(
|
|
2479
2465
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
2480
2466
|
);
|
|
@@ -2685,16 +2671,16 @@ ${selectionOpts}`);
|
|
|
2685
2671
|
const parsed = [], parseRe = /\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g;
|
|
2686
2672
|
let match;
|
|
2687
2673
|
for (; (match = parseRe.exec(path)) !== null; ) {
|
|
2688
|
-
if (match[1] !==
|
|
2674
|
+
if (match[1] !== undefined) {
|
|
2689
2675
|
const key = match[1].replace(/\\(\\|f|n|r|t|')/g, (m) => UNESCAPE[m]);
|
|
2690
2676
|
parsed.push(key);
|
|
2691
2677
|
continue;
|
|
2692
2678
|
}
|
|
2693
|
-
if (match[2] !==
|
|
2679
|
+
if (match[2] !== undefined) {
|
|
2694
2680
|
parsed.push(parseInt(match[2], 10));
|
|
2695
2681
|
continue;
|
|
2696
2682
|
}
|
|
2697
|
-
if (match[3] !==
|
|
2683
|
+
if (match[3] !== undefined) {
|
|
2698
2684
|
const _key = match[3].replace(/\\(\\')/g, (m) => UNESCAPE[m]);
|
|
2699
2685
|
parsed.push({
|
|
2700
2686
|
_key,
|
|
@@ -2729,7 +2715,7 @@ ${selectionOpts}`);
|
|
|
2729
2715
|
if (!csm?.mappings)
|
|
2730
2716
|
return;
|
|
2731
2717
|
const resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath));
|
|
2732
|
-
if (csm.mappings[resultMappingPath] !==
|
|
2718
|
+
if (csm.mappings[resultMappingPath] !== undefined)
|
|
2733
2719
|
return {
|
|
2734
2720
|
mapping: csm.mappings[resultMappingPath],
|
|
2735
2721
|
matchedPath: resultMappingPath,
|
|
@@ -2810,7 +2796,7 @@ ${selectionOpts}`);
|
|
|
2810
2796
|
throw new Error("id is required");
|
|
2811
2797
|
if (baseUrl !== "/" && baseUrl.endsWith("/"))
|
|
2812
2798
|
throw new Error("baseUrl must not end with a slash");
|
|
2813
|
-
const workspace = _workspace === "default" ?
|
|
2799
|
+
const workspace = _workspace === "default" ? undefined : _workspace, tool = _tool === "default" ? undefined : _tool, id = getPublishedId(_id), stringifiedPath = Array.isArray(path) ? toString(jsonPathToStudioPath(path)) : path, searchParams = new URLSearchParams({
|
|
2814
2800
|
baseUrl,
|
|
2815
2801
|
id,
|
|
2816
2802
|
type,
|
|
@@ -2833,7 +2819,7 @@ ${selectionOpts}`);
|
|
|
2833
2819
|
}
|
|
2834
2820
|
const filterDefault = ({ sourcePath, resultPath, value }) => {
|
|
2835
2821
|
if (isValidDate(value) || isValidURL(value))
|
|
2836
|
-
return
|
|
2822
|
+
return false;
|
|
2837
2823
|
const endPath = sourcePath.at(-1);
|
|
2838
2824
|
return !(sourcePath.at(-2) === "slug" && endPath === "current" || typeof endPath == "string" && (endPath.startsWith("_") || endPath.endsWith("Id")) || sourcePath.some(
|
|
2839
2825
|
(path) => path === "meta" || path === "metadata" || path === "openGraph" || path === "seo"
|
|
@@ -2880,15 +2866,15 @@ ${selectionOpts}`);
|
|
|
2880
2866
|
"website"
|
|
2881
2867
|
]);
|
|
2882
2868
|
function isValidDate(dateString) {
|
|
2883
|
-
return /^\d{4}-\d{2}-\d{2}/.test(dateString) ? !!Date.parse(dateString) :
|
|
2869
|
+
return /^\d{4}-\d{2}-\d{2}/.test(dateString) ? !!Date.parse(dateString) : false;
|
|
2884
2870
|
}
|
|
2885
2871
|
function isValidURL(url) {
|
|
2886
2872
|
try {
|
|
2887
2873
|
new URL(url, url.startsWith("/") ? "https://acme.com" : void 0);
|
|
2888
2874
|
} catch {
|
|
2889
|
-
return
|
|
2875
|
+
return false;
|
|
2890
2876
|
}
|
|
2891
|
-
return
|
|
2877
|
+
return true;
|
|
2892
2878
|
}
|
|
2893
2879
|
function hasTypeLike(path) {
|
|
2894
2880
|
return path.some((segment) => typeof segment == "string" && segment.match(/type/i) !== null);
|
|
@@ -2917,7 +2903,7 @@ ${selectionOpts}`);
|
|
|
2917
2903
|
result,
|
|
2918
2904
|
resultSourceMap,
|
|
2919
2905
|
({ sourcePath, sourceDocument, resultPath, value }) => {
|
|
2920
|
-
if ((typeof filter == "function" ? filter({ sourcePath, resultPath, filterDefault, sourceDocument, value }) : filterDefault({ sourcePath, resultPath, filterDefault, sourceDocument, value })) ===
|
|
2906
|
+
if ((typeof filter == "function" ? filter({ sourcePath, resultPath, filterDefault, sourceDocument, value }) : filterDefault({ sourcePath, resultPath, filterDefault, sourceDocument, value })) === false)
|
|
2921
2907
|
return logger && report.skipped.push({
|
|
2922
2908
|
path: prettyPathForLogging(sourcePath),
|
|
2923
2909
|
value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? "..." : ""}`,
|
|
@@ -2931,8 +2917,7 @@ ${selectionOpts}`);
|
|
|
2931
2917
|
const { baseUrl, workspace, tool } = resolveStudioBaseRoute(
|
|
2932
2918
|
typeof config.studioUrl == "function" ? config.studioUrl(sourceDocument) : config.studioUrl
|
|
2933
2919
|
);
|
|
2934
|
-
if (!baseUrl)
|
|
2935
|
-
return value;
|
|
2920
|
+
if (!baseUrl) return value;
|
|
2936
2921
|
const { _id: id, _type: type, _projectId: projectId, _dataset: dataset } = sourceDocument;
|
|
2937
2922
|
return C(
|
|
2938
2923
|
value,
|
|
@@ -2949,7 +2934,7 @@ ${selectionOpts}`);
|
|
|
2949
2934
|
})
|
|
2950
2935
|
},
|
|
2951
2936
|
// We use custom logic to determine if we should skip encoding
|
|
2952
|
-
|
|
2937
|
+
false
|
|
2953
2938
|
);
|
|
2954
2939
|
}
|
|
2955
2940
|
);
|