picosanity
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -42,15 +42,5 @@ "use strict"; | ||
} : undefined; | ||
var headers = Object.assign({}, auth, type); // Some environments (like CloudFlare Workers) don't support credentials | ||
// in fetch() RequestInitDict, and there doesn't seem to be any easy way | ||
// to check of it, so for now we'll make do with a window check :/ | ||
var credentials; | ||
if (typeof window !== 'undefined') { | ||
credentials = cfg.withCredentials ? 'include' : 'omit'; | ||
} | ||
var headers = Object.assign({}, auth, type); | ||
var host = !cfg.useCdn || cfg.token || usePost ? apiHost : cdnHost; | ||
var opts = { | ||
credentials: credentials, | ||
headers: headers, | ||
@@ -62,3 +52,10 @@ method: usePost ? 'POST' : 'GET', | ||
}) : undefined | ||
}; | ||
}; // Some environments (like CloudFlare Workers) don't support credentials | ||
// in fetch() RequestInitDict, and there doesn't seem to be any easy way | ||
// to check of it, so for now we'll make do with a window check :/ | ||
if (typeof window !== 'undefined') { | ||
opts.credentials = cfg.withCredentials ? 'include' : 'omit'; | ||
} | ||
var url = "https://".concat(cfg.projectId, ".").concat(host, "/").concat(version, "/data/query/").concat(cfg.dataset); | ||
@@ -65,0 +62,0 @@ return this.fetcher("".concat(url).concat(usePost ? '' : qs), opts).then(parse); |
{ | ||
"name": "picosanity", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "Tiny Sanity client alternative should you only need to do queries", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -47,13 +47,4 @@ const enc = encodeURIComponent | ||
// Some environments (like CloudFlare Workers) don't support credentials | ||
// in fetch() RequestInitDict, and there doesn't seem to be any easy way | ||
// to check of it, so for now we'll make do with a window check :/ | ||
let credentials | ||
if (typeof window !== 'undefined') { | ||
credentials = cfg.withCredentials ? 'include' : 'omit' | ||
} | ||
const host = !cfg.useCdn || cfg.token || usePost ? apiHost : cdnHost | ||
const opts = { | ||
credentials, | ||
headers, | ||
@@ -64,2 +55,9 @@ method: usePost ? 'POST' : 'GET', | ||
// Some environments (like CloudFlare Workers) don't support credentials | ||
// in fetch() RequestInitDict, and there doesn't seem to be any easy way | ||
// to check of it, so for now we'll make do with a window check :/ | ||
if (typeof window !== 'undefined') { | ||
opts.credentials = cfg.withCredentials ? 'include' : 'omit' | ||
} | ||
const url = `https://${cfg.projectId}.${host}/${version}/data/query/${cfg.dataset}` | ||
@@ -66,0 +64,0 @@ return this.fetcher(`${url}${usePost ? '' : qs}`, opts).then(parse) |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.PicoSanity=e():t.PicoSanity=e()}(self,(function(){return(()=>{"use strict";var t={693:(t,e,n)=>{var o=n(26);t.exports=function(t){return new o(t,(function(t,e){return fetch(t,e)}))}},26:t=>{var e=encodeURIComponent,n={}.hasOwnProperty;function o(t,e){if(!(this instanceof o))return new o(t);this.clientConfig=t,this.fetcher=e}function r(t){if(!(t.headers.get("content-type")||"").includes("json"))throw i(t);return t.json().then((function(e){if(t.status<400)return e.result;throw i(t,e)}))}function i(t,e){var n=t.url,o=t.statusText;return e&&e.error&&e.error.description&&(n=e.error.description,o=e.error.type||o),new Error("HTTP ".concat(t.status," ").concat(o,": ").concat(n))}["clone","create","createIfNotExists","createOrReplace","delete","listen","mutate","patch","transaction"].forEach((function(t){o.prototype[t]=function(t){return function(){throw new Error('Method "'.concat(t,'" not implemented, use @sanity/client'))}}(t)})),o.prototype.config=function(t){return t?(this.clientConfig=Object.assign({},this.clientConfig,t),this):this.clientConfig},o.prototype.fetch=function(t,o){var i,c=this.clientConfig,a=c.apiVersion?"v".concat(c.apiVersion.replace(/^v/,"")):"v1",s=function(t,o){var r="?query=".concat(e(t));if(!o)return r;for(var i in o)n.call(o,i)&&(r+="&".concat(e("$".concat(i)),"=").concat(e(JSON.stringify(o[i]))));return r}(t,o),u=s.length>11264,f=c.token?{Authorization:"Bearer ".concat(c.token)}:void 0,p=u?{"content-type":"application/json"}:void 0,d=Object.assign({},f,p);"undefined"!=typeof window&&(i=c.withCredentials?"include":"omit");var h=!c.useCdn||c.token||u?"api.sanity.io":"apicdn.sanity.io",l={credentials:i,headers:d,method:u?"POST":"GET",body:u?JSON.stringify({query:t,params:o}):void 0},y="https://".concat(c.projectId,".").concat(h,"/").concat(a,"/data/query/").concat(c.dataset);return this.fetcher("".concat(y).concat(u?"":s),l).then(r)},t.exports=o}},e={};return function n(o){var r=e[o];if(void 0!==r)return r.exports;var i=e[o]={exports:{}};return t[o](i,i.exports,n),i.exports}(693)})()})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.PicoSanity=e():t.PicoSanity=e()}(self,(function(){return(()=>{"use strict";var t={693:(t,e,n)=>{var o=n(26);t.exports=function(t){return new o(t,(function(t,e){return fetch(t,e)}))}},26:t=>{var e=encodeURIComponent,n={}.hasOwnProperty;function o(t,e){if(!(this instanceof o))return new o(t);this.clientConfig=t,this.fetcher=e}function r(t){if(!(t.headers.get("content-type")||"").includes("json"))throw i(t);return t.json().then((function(e){if(t.status<400)return e.result;throw i(t,e)}))}function i(t,e){var n=t.url,o=t.statusText;return e&&e.error&&e.error.description&&(n=e.error.description,o=e.error.type||o),new Error("HTTP ".concat(t.status," ").concat(o,": ").concat(n))}["clone","create","createIfNotExists","createOrReplace","delete","listen","mutate","patch","transaction"].forEach((function(t){o.prototype[t]=function(t){return function(){throw new Error('Method "'.concat(t,'" not implemented, use @sanity/client'))}}(t)})),o.prototype.config=function(t){return t?(this.clientConfig=Object.assign({},this.clientConfig,t),this):this.clientConfig},o.prototype.fetch=function(t,o){var i=this.clientConfig,c=i.apiVersion?"v".concat(i.apiVersion.replace(/^v/,"")):"v1",a=function(t,o){var r="?query=".concat(e(t));if(!o)return r;for(var i in o)n.call(o,i)&&(r+="&".concat(e("$".concat(i)),"=").concat(e(JSON.stringify(o[i]))));return r}(t,o),s=a.length>11264,u=i.token?{Authorization:"Bearer ".concat(i.token)}:void 0,f=s?{"content-type":"application/json"}:void 0,p=Object.assign({},u,f),d=!i.useCdn||i.token||s?"api.sanity.io":"apicdn.sanity.io",h={headers:p,method:s?"POST":"GET",body:s?JSON.stringify({query:t,params:o}):void 0};"undefined"!=typeof window&&(h.credentials=i.withCredentials?"include":"omit");var l="https://".concat(i.projectId,".").concat(d,"/").concat(c,"/data/query/").concat(i.dataset);return this.fetcher("".concat(l).concat(s?"":a),h).then(r)},t.exports=o}},e={};return function n(o){var r=e[o];if(void 0!==r)return r.exports;var i=e[o]={exports:{}};return t[o](i,i.exports,n),i.exports}(693)})()})); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14735
258