New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

storyblok-js-client

Package Overview
Dependencies
Maintainers
7
Versions
201
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

storyblok-js-client - npm Package Compare versions

Comparing version 6.4.0 to 6.4.1

4

dist/index.umd.js

@@ -1,2 +0,2 @@

(function(p,h){typeof exports=="object"&&typeof module<"u"?module.exports=h():typeof define=="function"&&define.amd?define(h):(p=typeof globalThis<"u"?globalThis:p||self,p.StoryblokJSClient=h())})(this,function(){"use strict";var z=Object.defineProperty;var P=(p,h,m)=>h in p?z(p,h,{enumerable:!0,configurable:!0,writable:!0,value:m}):p[h]=m;var u=(p,h,m)=>(P(p,typeof h!="symbol"?h+"":h,m),m);function p(i){return!(i!==i||i===1/0||i===-1/0)}function h(i,e,t){if(!p(e))throw new TypeError("Expected `limit` to be a finite number");if(!p(t))throw new TypeError("Expected `interval` to be a finite number");const s=[];let o=[],n=0;const r=function(){n++;const a=setTimeout(function(){n--,s.length>0&&r(),o=o.filter(function(d){return d!==a})},t);o.indexOf(a)<0&&o.push(a);const c=s.shift();c.resolve(i.apply(c.self,c.args))},l=function(...a){const c=this;return new Promise(function(d,b){s.push({resolve:d,reject:b,args:a,self:c}),n<e&&r()})};return l.abort=function(){o.forEach(clearTimeout),o=[],s.forEach(function(a){a.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),s.length=0},l}class m{constructor(){u(this,"isCDNUrl",(e="")=>e.indexOf("/cdn/")>-1);u(this,"getOptionsPage",(e,t=25,s=1)=>({...e,per_page:t,page:s}));u(this,"delay",e=>new Promise(t=>setTimeout(t,e)));u(this,"arrayFrom",(e=0,t)=>[...Array(e)].map(t));u(this,"range",(e=0,t=e)=>{const s=Math.abs(t-e)||0,o=e<t?1:-1;return this.arrayFrom(s,(n,r)=>r*o+e)});u(this,"asyncMap",async(e,t)=>Promise.all(e.map(t)));u(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,o)=>[...s,...o],[]));u(this,"escapeHTML",function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s=/[&<>"']/g,o=RegExp(s.source);return e&&o.test(e)?e.replace(s,n=>t[n]):e})}stringify(e,t,s){const o=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const r=e[n],l=s?"":encodeURIComponent(n);let a;typeof r=="object"?a=this.stringify(r,t?t+encodeURIComponent("["+l+"]"):l,Array.isArray(r)):a=(t?t+encodeURIComponent("["+l+"]"):l)+"="+encodeURIComponent(r),o.push(a)}return o.join("&")}getRegionURL(e){const t="api.storyblok.com",s="api-us.storyblok.com",o="app.storyblokchina.cn",n="api-ap.storyblok.com",r="api-ca.storyblok.com";switch(e){case"us":return s;case"cn":return o;case"ap":return n;case"ca":return r;default:return t}}}const U=Object.freeze(Object.defineProperty({__proto__:null,SbHelpers:m},Symbol.toStringTag,{value:"Module"})),N=function(i,e){const t={};for(const s in i){const o=i[s];e.indexOf(s)>-1&&o!==null&&(t[s]=o)}return t},L=i=>i==="email",I={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:i=>({tag:["pre",{tag:"code",attrs:i.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:i=>({tag:`h${i.attrs.level}`}),image:i=>({singleTag:[{tag:"img",attrs:N(i.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"}),emoji:i=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":i.attrs.name,emoji:i.attrs.emoji}}]})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"s"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link:i=>{if(!i.attrs)return{tag:""};const e=new m().escapeHTML,t={...i.attrs},{linktype:s="url"}=i.attrs;if(delete t.linktype,t.href&&(t.href=e(i.attrs.href||"")),L(s)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const o in t.custom)t[o]=t.custom[o];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},styled:i=>({tag:[{tag:"span",attrs:i.attrs}]}),subscript:()=>({tag:"sub"}),superscript:()=>({tag:"sup"}),anchor:i=>({tag:[{tag:"span",attrs:i.attrs}]}),highlight:i=>{var t;return(t=i.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`background-color:${i.attrs.color};`}}]}:{tag:""}},textStyle:i=>{var t;return(t=i.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`color:${i.attrs.color}`}}]}:{tag:""}}}},S=function(i){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,s=RegExp(t.source);return i&&s.test(i)?i.replace(t,o=>e[o]):i};class k{constructor(e){u(this,"marks");u(this,"nodes");e||(e=I),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1}){if(e&&e.content&&Array.isArray(e.content)){let s="";return e.content.forEach(o=>{s+=this.renderNode(o)}),t.optimizeImages?this.optimizeImages(s,t.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
(function(f,d){typeof exports=="object"&&typeof module<"u"?module.exports=d():typeof define=="function"&&define.amd?define(d):(f=typeof globalThis<"u"?globalThis:f||self,f.StoryblokJSClient=d())})(this,function(){"use strict";var N=Object.defineProperty;var I=(f,d,g)=>d in f?N(f,d,{enumerable:!0,configurable:!0,writable:!0,value:g}):f[d]=g;var h=(f,d,g)=>(I(f,typeof d!="symbol"?d+"":d,g),g);function f(o){return!(o!==o||o===1/0||o===-1/0)}function d(o,e,t){if(!f(e))throw new TypeError("Expected `limit` to be a finite number");if(!f(t))throw new TypeError("Expected `interval` to be a finite number");const s=[];let r=[],i=0;const n=function(){i++;const l=setTimeout(function(){i--,s.length>0&&n(),r=r.filter(function(u){return u!==l})},t);r.indexOf(l)<0&&r.push(l);const a=s.shift();a.resolve(o.apply(a.self,a.args))},c=function(...l){const a=this;return new Promise(function(u,m){s.push({resolve:u,reject:m,args:l,self:a}),i<e&&n()})};return c.abort=function(){r.forEach(clearTimeout),r=[],s.forEach(function(l){l.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),s.length=0},c}class g{constructor(){h(this,"isCDNUrl",(e="")=>e.indexOf("/cdn/")>-1);h(this,"getOptionsPage",(e,t=25,s=1)=>({...e,per_page:t,page:s}));h(this,"delay",e=>new Promise(t=>setTimeout(t,e)));h(this,"arrayFrom",(e=0,t)=>[...Array(e)].map(t));h(this,"range",(e=0,t=e)=>{const s=Math.abs(t-e)||0,r=e<t?1:-1;return this.arrayFrom(s,(i,n)=>n*r+e)});h(this,"asyncMap",async(e,t)=>Promise.all(e.map(t)));h(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[]));h(this,"escapeHTML",function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s=/[&<>"']/g,r=RegExp(s.source);return e&&r.test(e)?e.replace(s,i=>t[i]):e})}stringify(e,t,s){const r=[];for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const n=e[i],c=s?"":encodeURIComponent(i);let l;typeof n=="object"?l=this.stringify(n,t?t+encodeURIComponent("["+c+"]"):c,Array.isArray(n)):l=(t?t+encodeURIComponent("["+c+"]"):c)+"="+encodeURIComponent(n),r.push(l)}return r.join("&")}getRegionURL(e){const t="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn",i="api-ap.storyblok.com",n="api-ca.storyblok.com";switch(e){case"us":return s;case"cn":return r;case"ap":return i;case"ca":return n;default:return t}}}const O=Object.freeze(Object.defineProperty({__proto__:null,SbHelpers:g},Symbol.toStringTag,{value:"Module"})),w=function(o,e){const t={};for(const s in o){const r=o[s];e.indexOf(s)>-1&&r!==null&&(t[s]=r)}return t},A=o=>o==="email",C={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:o=>({tag:`h${o.attrs.level}`}),image:o=>({singleTag:[{tag:"img",attrs:w(o.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"}),emoji:o=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":o.attrs.name,emoji:o.attrs.emoji}}]})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"s"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link:o=>{if(!o.attrs)return{tag:""};const e=new g().escapeHTML,t={...o.attrs},{linktype:s="url"}=o.attrs;if(delete t.linktype,t.href&&(t.href=e(o.attrs.href||"")),A(s)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const r in t.custom)t[r]=t.custom[r];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},styled:o=>({tag:[{tag:"span",attrs:o.attrs}]}),subscript:()=>({tag:"sub"}),superscript:()=>({tag:"sup"}),anchor:o=>({tag:[{tag:"span",attrs:o.attrs}]}),highlight:o=>{var t;return(t=o.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},textStyle:o=>{var t;return(t=o.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}}}},L=function(o){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,s=RegExp(t.source);return o&&s.test(o)?o.replace(t,r=>e[r]):o};class k{constructor(e){h(this,"marks");h(this,"nodes");e||(e=C),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1}){if(e&&e.content&&Array.isArray(e.content)){let s="";return e.content.forEach(r=>{s+=this.renderNode(r)}),t.optimizeImages?this.optimizeImages(s,t.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
The "content" field must be an array of nodes as the type ISbRichtext.

@@ -24,2 +24,2 @@ ISbRichtext:

type: 'doc'
}`),""}optimizeImages(e,t){let s=0,o=0,n="",r="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(n+=`width="${t.width}" `,s=t.width),typeof t.height=="number"&&t.height>0&&(n+=`height="${t.height}" `,o=t.height),(t.loading==="lazy"||t.loading==="eager")&&(n+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(n+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(r+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(r+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-Fa-f]{6}/g)||t.filters.fill==="transparent")&&(r+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(r+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(r+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(r+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(r+=`:rotate(${t.filters.rotate})`),r.length>0&&(r="/filters"+r))),n.length>0&&(e=e.replace(/<img/g,`<img ${n.trim()}`));const l=s>0||o>0||r.length>0?`${s}x${o}${r}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var d,b;const c=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(c&&c.length>0){const _={srcset:(d=t.srcset)==null?void 0:d.map(f=>{if(typeof f=="number")return`//${c}/m/${f}x0${r} ${f}w`;if(typeof f=="object"&&f.length===2){let O=0,C=0;return typeof f[0]=="number"&&(O=f[0]),typeof f[1]=="number"&&(C=f[1]),`//${c}/m/${O}x${C}${r} ${O}w`}}).join(", "),sizes:(b=t.sizes)==null?void 0:b.map(f=>f).join(", ")};let R="";return _.srcset&&(R+=`srcset="${_.srcset}" `),_.sizes&&(R+=`sizes="${_.sizes}" `),a.replace(/<img/g,`<img ${R.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(o=>{const n=this.getMatchingMark(o);n&&n.tag!==""&&t.push(this.renderOpeningTag(n.tag))});const s=this.getMatchingNode(e);return s&&s.tag&&t.push(this.renderOpeningTag(s.tag)),e.content?e.content.forEach(o=>{t.push(this.renderNode(o))}):e.text?t.push(S(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html?t.push(s.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(o=>{const n=this.getMatchingMark(o);n&&n.tag!==""&&t.push(this.renderClosingTag(n.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(o=>{if(o.constructor===String)return`<${o}${t}>`;{let n=`<${o.tag}`;if(o.attrs)for(const r in o.attrs){const l=o.attrs[r];l!==null&&(n+=` ${r}="${l}"`)}return`${n}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(s=>s.constructor===String?`</${s}>`:`</${s.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}class w{constructor(e){u(this,"baseURL");u(this,"timeout");u(this,"headers");u(this,"responseInterceptor");u(this,"fetch");u(this,"ejectInterceptor");u(this,"url");u(this,"parameters");this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=e.fetch||fetch,this.ejectInterceptor=!1,this.ejectInterceptor=!1,this.url="",this.parameters={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t,this._methodHandler("delete")}async _responseHandler(e){const t=[],s={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(o=>{s.data=o});for(const o of e.headers.entries())t[o[0]]=o[1];return s.headers={...t},s.status=e.status,s.statusText=e.statusText,s}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,s=null;if(e==="get"){const a=new m;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const o=new URL(t),n=new AbortController,{signal:r}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${o}`,{method:e,headers:this.headers,body:s,signal:r});this.timeout&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return{message:a}}}eject(){this.ejectInterceptor=!0}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,o)=>{if(t.test(`${e.status}`))return s(e);const n={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};o(n)})}}var D={MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",CODEBUILD_LAST_EXIT:"0",GIT_COMMITTER_NAME:"semantic-release-bot",CODEBUILD_START_TIME:"1702044355455",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",npm_config_user_agent:"npm/10.2.5 node/v18.19.0 linux x64 workspaces/false ci/aws-codebuild",GIT_AUTHOR_EMAIL:"semantic-release-bot@martynus.net",CODEBUILD_SOURCE_VERSION:"arn:aws:s3:::codepipeline-us-east-1-627980213760/storyblok-js-client/SourceArti/SBdIxak",GOLANG_18_VERSION:"1.18.10",JDK_17_HOME:"/usr/lib/jvm/java-17-amazon-corretto",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",HOSTNAME:"4ed8e0d59ae4",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:us-east-1:211471875135:alias/aws/s3",CODEBUILD_BUILD_ID:"storyblok-js-client-node16:99807f7d-c7a4-40b4-9761-87e56df4b430",GH_TOKEN:"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",npm_node_execpath:"/usr/local/bin/node",GIT_ASKPASS:"echo",npm_package_resolved:"/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/storyblok-js-client",npm_config_noproxy:"",NODE_16_VERSION:"16.20.2",HOME:"/root",OLDPWD:"/codebuild/readonly",JRE_HOME:"/usr/lib/jvm/java-17-amazon-corretto",CODEBUILD_GOPATH:"/codebuild/output/src2498269880",npm_package_json:"/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/storyblok-js-client/package.json",CODEBUILD_CI:"true",GOENV_DISABLE_GOPATH:"1",CODEBUILD_RESOLVED_SOURCE_VERSION:"d50d92e44ea1be2197ce30b5a33ba794e3848ebc",CODEBUILD_BUILD_NUMBER:"258",CODEBUILD_BUILD_SUCCEEDING:"1",GIT_AUTHOR_NAME:"semantic-release-bot",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:us-east-1:211471875135:build/storyblok-js-client-node16:99807f7d-c7a4-40b4-9761-87e56df4b430",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/50ba70fa-e6c7-4435-80e9-a698790c9e44",LC_CTYPE:"C.UTF-8",npm_config_userconfig:"/tmp/b75770a362da713df71ccbf471502a85/.npmrc",npm_config_local_prefix:"/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/storyblok-js-client",npm_package_integrity:"null",AWS_EXECUTION_ENV:"AWS_ECS_EC2",JRE_17_HOME:"/usr/lib/jvm/java-17-amazon-corretto",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-us-east-1-prod-default-build-agent-executor.s3.us-east-1.amazonaws.com/cawsrunner.zip",RUBY_BUILD_SRC_DIR:"/usr/local/rbenv/plugins/ruby-build",COLOR:"0",CODEBUILD_INITIATOR:"codepipeline/storyblok-js-client",DOTNET_6_SDK_VERSION:"6.0.410",NPM_TOKEN:"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",AWS_DEFAULT_REGION:"us-east-1",npm_config_prefix:"/usr/local",npm_config_npm_version:"10.2.5",RUBY_31_VERSION:"3.1.4",PHP_81_VERSION:"8.1.20",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/c4443833-4ac1-4aac-b884-6aa48465ee1f",npm_config_cache:"/root/.npm",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/c4443833-4ac1-4aac-b884-6aa48465ee1f",DOTNET_ROOT:"/root/.dotnet",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_config_node_gyp:"/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",PATH:"/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/storyblok-js-client/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/node_modules/.bin:/codebuild/output/src2498269880/src/node_modules/.bin:/codebuild/output/src2498269880/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/usr/local/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/storyblok-js-client/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/node_modules/.bin:/codebuild/output/src2498269880/src/node_modules/.bin:/codebuild/output/src2498269880/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/usr/local/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/storyblok-js-client/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/node_modules/.bin:/codebuild/output/src2498269880/src/node_modules/.bin:/codebuild/output/src2498269880/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/usr/local/bin:/root/.npm/_npx/cdf31b77322f1d44/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/storyblok-js-client/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/node_modules/.bin:/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/node_modules/.bin:/codebuild/output/src2498269880/src/node_modules/.bin:/codebuild/output/src2498269880/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/usr/local/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/usr/local/bin/sbt/bin:/root/.goenv/shims:/root/.goenv/bin:/go/bin:/root/.phpenv/shims:/root/.phpenv/bin:/root/.pyenv/shims:/root/.pyenv/bin:/root/.rbenv/shims:/usr/local/rbenv/bin:/usr/local/rbenv/shims:/root/.dotnet/:/root/.dotnet/tools/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/tools:/codebuild/user/bin",NODE:"/usr/local/bin/node",npm_package_name:"storyblok-js-client",CODEBUILD_LOG_PATH:"99807f7d-c7a4-40b4-9761-87e56df4b430",PYYAML_VERSION:"5.4.1",CODEBUILD_BUILD_IMAGE:"aws/codebuild/standard:6.0",npm_lifecycle_script:"node vite.build.mjs && tsc",GOPATH:"/go:/codebuild/output/src2498269880",npm_package_version:"6.4.0",npm_lifecycle_event:"build",GIT_TERMINAL_PROMPT:"0",CODEBUILD_BUILD_URL:"https://us-east-1.console.aws.amazon.com/codebuild/home?region=us-east-1#/builds/storyblok-js-client-node16:99807f7d-c7a4-40b4-9761-87e56df4b430/view/new",AWS_REGION:"us-east-1",CODEBUILD_SRC_DIR:"/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/storyblok-js-client",CODEBUILD_PROJECT_UUID:"32cade05-a75b-4c83-a9ee-1b765b71d873",CODEBUILD_AUTH_TOKEN:"fd8fd95c-9244-48c9-89c8-f4ba3ce1b690",CODEBUILD_CONTAINER_NAME:"default",npm_config_globalconfig:"/usr/local/etc/npmrc",npm_config_init_module:"/root/.npm-init.js",GIT_COMMITTER_EMAIL:"semantic-release-bot@martynus.net",LOG4J_UNSAFE_VERSIONS:"2.11.1 1.2.8",JAVA_HOME:"/usr/lib/jvm/java-17-amazon-corretto",PWD:"/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/storyblok-js-client",npm_execpath:"/usr/local/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.us-east-1.amazonaws.com/",npm_config_global_prefix:"/usr/local",npm_command:"run-script",PYTHON_310_VERSION:"3.10.12",JAVA_17_HOME:"/usr/lib/jvm/java-17-amazon-corretto",NUGET_XMLDOC_MODE:"skip",JDK_HOME:"/usr/lib/jvm/java-17-amazon-corretto",INIT_CWD:"/codebuild/output/src2498269880/src/codestar-connections.us-east-1.amazonaws.com/git-http/211471875135/eu-central-1/7d060832-ad20-4152-b085-4826ef8a8eed/storyblok/storyblok-js-client",EDITOR:"vi",NODE_ENV:"production"};const v="SB-Agent",E={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:D.npm_package_version};let y={};const g={};class T{constructor(e,t){u(this,"client");u(this,"maxRetries");u(this,"throttle");u(this,"accessToken");u(this,"cache");u(this,"helpers");u(this,"resolveCounter");u(this,"relations");u(this,"links");u(this,"richTextResolver");u(this,"resolveNestedRelations");let s=e.endpoint||t;if(!s){const r=new m().getRegionURL,l=e.https===!1?"http":"https";e.oauthToken?s=`${l}://${r(e.region)}/v1`:s=`${l}://${r(e.region)}/v2`}const o=new Headers;if(o.set("Content-Type","application/json"),o.set("Accept","application/json"),e.headers)for(const r in e.headers)o.set(r,e.headers[r]);o.has(v)||(o.set(v,E.defaultAgentName),o.set(E.defaultAgentVersion,E.packageVersion));let n=5;e.oauthToken&&(o.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),e.richTextSchema?this.richTextResolver=new k(e.richTextSchema):this.richTextResolver=new k,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=h(this.throttledRequest,n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new m,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.client=new w({baseURL:s,timeout:e.timeout||0,headers:o,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body&&t.attrs.body.forEach(o=>{s+=e(o.component,o)}),{html:s}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=g[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,s,o){const n=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,o));return this.cacheResponse(e,n)}get(e,t){t||(t={});const s=`/${e}`,o=this.factoryParamOptions(s,t);return this.cacheResponse(s,o)}async getAll(e,t,s){const o=(t==null?void 0:t.per_page)||25,n=`/${e}`,r=n.split("/"),l=s||r[r.length-1],a=1,c=await this.makeRequest(n,t,o,a),d=c.total?Math.ceil(c.total/o):1,b=await this.helpers.asyncMap(this.helpers.range(a,d),_=>this.makeRequest(n,t,o,_+1));return this.helpers.flatMap([c,...b],_=>Object.values(_.data[l]))}post(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("post",s,t))}put(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("put",s,t))}delete(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("delete",s,t))}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get(`cdn/stories/${e}`,t)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,s){const o=e[t];o&&o.fieldtype=="multilink"&&o.linktype=="story"&&typeof o.id=="string"&&this.links[s][o.id]?o.story=this._cleanCopy(this.links[s][o.id]):o&&o.linktype==="story"&&typeof o.uuid=="string"&&this.links[s][o.uuid]&&(o.story=this._cleanCopy(this.links[s][o.uuid]))}_insertRelations(e,t,s,o){if(s.indexOf(`${e.component}.${t}`)>-1){if(typeof e[t]=="string")this.relations[o][e[t]]&&(e[t]=this._cleanCopy(this.relations[o][e[t]]));else if(e[t]&&e[t].constructor===Array){const n=[];e[t].forEach(r=>{this.relations[o][r]&&n.push(this._cleanCopy(this.relations[o][r]))}),e[t]=n}}}iterateTree(e,t,s){const o=n=>{if(n!=null){if(n.constructor===Array)for(let r=0;r<n.length;r++)o(n[r]);else if(n.constructor===Object){if(n._stopResolving)return;for(const r in n)(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,r,t,s),this._insertLinks(n,r,s)),o(n[r])}}};o(e.content)}async resolveLinks(e,t,s){let o=[];if(e.link_uuids){const n=e.link_uuids.length,r=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);r.push(e.link_uuids.slice(a,c))}for(let a=0;a<r.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:r[a].join(",")})).data.stories.forEach(d=>{o.push(d)})}else o=e.links;o.forEach(n=>{this.links[s][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,s){let o=[];if(e.rel_uuids){const n=e.rel_uuids.length,r=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);r.push(e.rel_uuids.slice(a,c))}for(let a=0;a<r.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:r[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(d=>{o.push(d)})}else o=e.rels;o&&o.length>0&&o.forEach(n=>{this.relations[s][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,s){var n,r;let o=[];if(this.links[s]={},this.relations[s]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(o=t.resolve_relations.split(",")),await this.resolveRelations(e,t,s)),t.resolve_links&&["1","story","url","link"].indexOf(t.resolve_links)>-1&&((n=e.links)!=null&&n.length||(r=e.link_uuids)!=null&&r.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const l in this.relations[s])this.iterateTree(this.relations[s][l],o,s);e.story?this.iterateTree(e.story,o,s):e.stories.forEach(l=>{this.iterateTree(l,o,s)}),delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s){(typeof s>"u"||!s)&&(s=0);const o=this.helpers.stringify({url:e,params:t}),n=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const r=await n.get(o);if(r)return Promise.resolve(r)}return new Promise(async(r,l)=>{var a;try{const c=await this.throttle("get",e,t);if(c.status!==200)return l(c);let d={data:c.data,headers:c.headers};if((a=c.headers)!=null&&a["per-page"]&&(d=Object.assign({},d,{perPage:c.headers["per-page"]?parseInt(c.headers["per-page"]):0,total:c.headers["per-page"]?parseInt(c.headers.total):0})),d.data.story||d.data.stories){const b=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(d.data,t,`${b}`)}return t.version==="published"&&e!="/cdn/spaces/me"&&await n.set(o,d),d.data.cv&&t.token&&(t.version==="draft"&&g[t.token]!=d.data.cv&&await this.flushCache(),g[t.token]=t.cv?t.cv:d.data.cv),r(d)}catch(c){if(c.response&&c.response.status===429&&(s=s?s+1:0,s<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${s} seconds.`),await this.helpers.delay(1e3*s),this.cacheResponse(e,t,s).then(r).catch(l);l(c)}})}throttledRequest(e,t,s){return this.client[e](t,s)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(y[e])},getAll(){return Promise.resolve(y)},set(e,t){return y[e]=t,Promise.resolve(void 0)},flush(){return y={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this}}const A=(i,e)=>{for(const t in e)i[t]=e[t]};return A(T,{RichtextResolver:k,SbFetch:w,RichTextSchema:I}),A(T,U),T});
}`),""}optimizeImages(e,t){let s=0,r=0,i="",n="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(i+=`width="${t.width}" `,s=t.width),typeof t.height=="number"&&t.height>0&&(i+=`height="${t.height}" `,r=t.height),(t.loading==="lazy"||t.loading==="eager")&&(i+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(i+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(n+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(n+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-Fa-f]{6}/g)||t.filters.fill==="transparent")&&(n+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(n+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(n+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(n+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(n+=`:rotate(${t.filters.rotate})`),n.length>0&&(n="/filters"+n))),i.length>0&&(e=e.replace(/<img/g,`<img ${i.trim()}`));const c=s>0||r>0||n.length>0?`${s}x${r}${n}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${c}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,l=>{var u,m;const a=l.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(a&&a.length>0){const _={srcset:(u=t.srcset)==null?void 0:u.map(p=>{if(typeof p=="number")return`//${a}/m/${p}x0${n} ${p}w`;if(typeof p=="object"&&p.length===2){let S=0,$=0;return typeof p[0]=="number"&&(S=p[0]),typeof p[1]=="number"&&($=p[1]),`//${a}/m/${S}x${$}${n} ${S}w`}}).join(", "),sizes:(m=t.sizes)==null?void 0:m.map(p=>p).join(", ")};let T="";return _.srcset&&(T+=`srcset="${_.srcset}" `),_.sizes&&(T+=`sizes="${_.sizes}" `),l.replace(/<img/g,`<img ${T.trim()}`)}return l})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&t.push(this.renderOpeningTag(i.tag))});const s=this.getMatchingNode(e);return s&&s.tag&&t.push(this.renderOpeningTag(s.tag)),e.content?e.content.forEach(r=>{t.push(this.renderNode(r))}):e.text?t.push(L(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html?t.push(s.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(r=>{const i=this.getMatchingMark(r);i&&i.tag!==""&&t.push(this.renderClosingTag(i.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(r=>{if(r.constructor===String)return`<${r}${t}>`;{let i=`<${r.tag}`;if(r.attrs)for(const n in r.attrs){const c=r.attrs[n];c!==null&&(i+=` ${n}="${c}"`)}return`${i}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(s=>s.constructor===String?`</${s}>`:`</${s.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}class x{constructor(e){h(this,"baseURL");h(this,"timeout");h(this,"headers");h(this,"responseInterceptor");h(this,"fetch");h(this,"ejectInterceptor");h(this,"url");h(this,"parameters");this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t,this._methodHandler("delete")}async _responseHandler(e){const t=[],s={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(r=>{s.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return s.headers={...t},s.status=e.status,s.statusText=e.statusText,s}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,s=null;if(e==="get"){const l=new g;t=`${this.baseURL}${this.url}?${l.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(t),i=new AbortController,{signal:n}=i;let c;this.timeout&&(c=setTimeout(()=>i.abort(),this.timeout));try{const l=await fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:n});this.timeout&&clearTimeout(c);const a=await this._responseHandler(l);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(a)):this._statusHandler(a)}catch(l){return{message:l}}}eject(){this.ejectInterceptor=!0}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,r)=>{if(t.test(`${e.status}`))return s(e);const i={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};r(i)})}}var P={NVM_INC:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/include/node",TERM_PROGRAM:"iTerm.app",NODE:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node",NVM_CD_FLAGS:"-q",INIT_CWD:"/Users/lisilinhart/Code/storyblok-js-client",SHELL:"/bin/zsh",TERM:"xterm-256color",TMPDIR:"/var/folders/9v/t3hq3s9n2rj6_x9jlsjjq95w0000gn/T/",npm_config_metrics_registry:"https://registry.npmjs.org/",npm_config_global_prefix:"/Users/lisilinhart/.nvm/versions/node/v18.16.0",TERM_PROGRAM_VERSION:"3.4.20",TERM_SESSION_ID:"w0t0p1:12B7CE01-010D-40B5-B6DA-DFE3CF20B8FF",COLOR:"0",npm_config_noproxy:"",ZSH:"/Users/lisilinhart/.oh-my-zsh",npm_config_local_prefix:"/Users/lisilinhart/Code/storyblok-js-client",USER:"lisilinhart",NVM_DIR:"/Users/lisilinhart/.nvm",COMMAND_MODE:"unix2003",npm_config_globalconfig:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/etc/npmrc",SSH_AUTH_SOCK:"/private/tmp/com.apple.launchd.oUounWp9qr/Listeners",__CF_USER_TEXT_ENCODING:"0x1F5:0x0:0x5C",npm_execpath:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/bin/npm-cli.js",PAGER:"less",npm_package_integrity:"null",LSCOLORS:"Gxfxcxdxbxegedabagacad",PATH:"/Users/lisilinhart/Code/storyblok-js-client/node_modules/.bin:/Users/lisilinhart/Code/node_modules/.bin:/Users/lisilinhart/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/Users/lisilinhart/Code/storyblok-js-client/node_modules/.bin:/Users/lisilinhart/Code/node_modules/.bin:/Users/lisilinhart/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/usr/local/sbin:/Users/lisilinhart/.rbenv/shims:/Users/lisilinhart/.yarn/bin:/Users/lisilinhart/.config/yarn/global/node_modules/.bin:/Users/lisilinhart/.rbenv/shims:/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin:/Users/lisilinhart/bin:/usr/local/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/lisilinhart/.cargo/bin",RUBY_CONFIGURE_OPTS:"--with-openssl-dir=/usr/local/opt/openssl@1.1",LaunchInstanceID:"9D2A03D3-35CC-4CDD-810D-0D5C25991BBB",_:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node",npm_package_json:"/Users/lisilinhart/Code/storyblok-js-client/package.json",__CFBundleIdentifier:"com.googlecode.iterm2",npm_config_init_module:"/Users/lisilinhart/.npm-init.js",npm_config_userconfig:"/Users/lisilinhart/.npmrc",PWD:"/Users/lisilinhart/Code/storyblok-js-client",npm_command:"run-script",P9K_SSH:"0",EDITOR:"vi",npm_lifecycle_event:"build",LANG:"de_AT.UTF-8",P9K_TTY:"old",npm_package_name:"storyblok-js-client",ITERM_PROFILE:"Default",XPC_FLAGS:"0x0",RBENV_SHELL:"zsh",npm_config_node_gyp:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",XPC_SERVICE_NAME:"0",npm_package_version:"6.4.1",COLORFGBG:"7;0",HOME:"/Users/lisilinhart",SHLVL:"3",npm_package_resolved:"/Users/lisilinhart/Code/storyblok-js-client",LC_TERMINAL_VERSION:"3.4.20",ITERM_SESSION_ID:"w0t0p1:12B7CE01-010D-40B5-B6DA-DFE3CF20B8FF",LOGNAME:"lisilinhart",LESS:"-R",npm_config_cache:"/Users/lisilinhart/.npm",npm_lifecycle_script:"node vite.build.mjs && tsc",NVM_BIN:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin",npm_config_user_agent:"npm/9.5.1 node/v18.16.0 darwin x64 workspaces/false",LC_TERMINAL:"iTerm2",SECURITYSESSIONID:"186a1",COLORTERM:"truecolor",npm_config_prefix:"/Users/lisilinhart/.nvm/versions/node/v18.16.0",npm_node_execpath:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node",NODE_ENV:"production"};const U="SB-Agent",v={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:P.npm_package_version};let b={};const y={};class R{constructor(e,t){h(this,"client");h(this,"maxRetries");h(this,"throttle");h(this,"accessToken");h(this,"cache");h(this,"helpers");h(this,"resolveCounter");h(this,"relations");h(this,"links");h(this,"richTextResolver");h(this,"resolveNestedRelations");h(this,"stringifiedStoriesCache");let s=e.endpoint||t;if(!s){const n=new g().getRegionURL,c=e.https===!1?"http":"https";e.oauthToken?s=`${c}://${n(e.region)}/v1`:s=`${c}://${n(e.region)}/v2`}const r=new Headers;if(r.set("Content-Type","application/json"),r.set("Accept","application/json"),e.headers)for(const n in e.headers)r.set(n,e.headers[n]);r.has(U)||(r.set(U,v.defaultAgentName),r.set(v.defaultAgentVersion,v.packageVersion));let i=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),i=3),e.rateLimit&&(i=e.rateLimit),e.richTextSchema?this.richTextResolver=new k(e.richTextSchema):this.richTextResolver=new k,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=d(this.throttledRequest,i,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new g,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new x({baseURL:s,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body&&t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=y[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,s,r){const i=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,r));return this.cacheResponse(e,i)}get(e,t){t||(t={});const s=`/${e}`,r=this.factoryParamOptions(s,t);return this.cacheResponse(s,r)}async getAll(e,t,s){const r=(t==null?void 0:t.per_page)||25,i=`/${e}`,n=i.split("/"),c=s||n[n.length-1],l=1,a=await this.makeRequest(i,t,r,l),u=a.total?Math.ceil(a.total/r):1,m=await this.helpers.asyncMap(this.helpers.range(l,u),_=>this.makeRequest(i,t,r,_+1));return this.helpers.flatMap([a,...m],_=>Object.values(_.data[c]))}post(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("post",s,t))}put(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("put",s,t))}delete(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("delete",s,t))}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get(`cdn/stories/${e}`,t)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,s){const r=e[t];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}getStoryReference(e,t){return this.relations[e][t]?(this.stringifiedStoriesCache[t]||(this.stringifiedStoriesCache[t]=JSON.stringify(this.relations[e][t])),JSON.parse(this.stringifiedStoriesCache[t])):t}_insertRelations(e,t,s,r){s.indexOf(`${e.component}.${t}`)>-1&&(typeof e[t]=="string"?e[t]=this.getStoryReference(r,e[t]):Array.isArray(e[t])&&(e[t]=e[t].map(i=>this.getStoryReference(r,i)).filter(Boolean)))}iterateTree(e,t,s){const r=i=>{if(i!=null){if(i.constructor===Array)for(let n=0;n<i.length;n++)r(i[n]);else if(i.constructor===Object){if(i._stopResolving)return;for(const n in i)(i.component&&i._uid||i.type==="link")&&(this._insertRelations(i,n,t,s),this._insertLinks(i,n,s)),r(i[n])}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const i=e.link_uuids.length,n=[],c=50;for(let l=0;l<i;l+=c){const a=Math.min(i,l+c);n.push(e.link_uuids.slice(l,a))}for(let l=0;l<n.length;l++)(await this.getStories({per_page:c,language:t.language,version:t.version,by_uuids:n[l].join(",")})).data.stories.forEach(u=>{r.push(u)})}else r=e.links;r.forEach(i=>{this.links[s][i.uuid]={...i,_stopResolving:!0}})}async resolveRelations(e,t,s){let r=[];if(e.rel_uuids){const i=e.rel_uuids.length,n=[],c=50;for(let l=0;l<i;l+=c){const a=Math.min(i,l+c);n.push(e.rel_uuids.slice(l,a))}for(let l=0;l<n.length;l++)(await this.getStories({per_page:c,language:t.language,version:t.version,by_uuids:n[l].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(u=>{r.push(u)})}else r=e.rels;r&&r.length>0&&r.forEach(i=>{this.relations[s][i.uuid]={...i,_stopResolving:!0}})}async resolveStories(e,t,s){var i,n;let r=[];if(this.links[s]={},this.relations[s]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(r=t.resolve_relations.split(",")),await this.resolveRelations(e,t,s)),t.resolve_links&&["1","story","url","link"].indexOf(t.resolve_links)>-1&&((i=e.links)!=null&&i.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const c in this.relations[s])this.iterateTree(this.relations[s][c],r,s);e.story?this.iterateTree(e.story,r,s):e.stories.forEach(c=>{this.iterateTree(c,r,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s){(typeof s>"u"||!s)&&(s=0);const r=this.helpers.stringify({url:e,params:t}),i=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const n=await i.get(r);if(n)return Promise.resolve(n)}return new Promise(async(n,c)=>{var l;try{const a=await this.throttle("get",e,t);if(a.status!==200)return c(a);let u={data:a.data,headers:a.headers};if((l=a.headers)!=null&&l["per-page"]&&(u=Object.assign({},u,{perPage:a.headers["per-page"]?parseInt(a.headers["per-page"]):0,total:a.headers["per-page"]?parseInt(a.headers.total):0})),u.data.story||u.data.stories){const m=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(u.data,t,`${m}`)}return t.version==="published"&&e!="/cdn/spaces/me"&&await i.set(r,u),u.data.cv&&t.token&&(t.version==="draft"&&y[t.token]!=u.data.cv&&await this.flushCache(),y[t.token]=t.cv?t.cv:u.data.cv),n(u)}catch(a){if(a.response&&a.response.status===429&&(s=s?s+1:0,s<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${s} seconds.`),await this.helpers.delay(1e3*s),this.cacheResponse(e,t,s).then(n).catch(c);c(a)}})}throttledRequest(e,t,s){return this.client[e](t,s)}cacheVersions(){return y}cacheVersion(){return y[this.accessToken]}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(b[e])},getAll(){return Promise.resolve(b)},set(e,t){return b[e]=t,Promise.resolve(void 0)},flush(){return b={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this}}const E=(o,e)=>{for(const t in e)o[t]=e[t]};return E(R,{RichtextResolver:k,SbFetch:x,RichTextSchema:C}),E(R,O),R});

@@ -34,2 +34,3 @@ import { ISbStoriesParams, ISbConfig, ISbResult, ISbStories, ISbStory, ISbStoryData, ISbStoryParams, ISbContentMangmntAPI } from './interfaces';

resolveNestedRelations: boolean;
private stringifiedStoriesCache;
/**

@@ -56,2 +57,9 @@ *

private _insertLinks;
/**
*
* @param resolveId A counter number as a string
* @param uuid The uuid of the story
* @returns string | object
*/
private getStoryReference;
private _insertRelations;

@@ -58,0 +66,0 @@ private iterateTree;

{
"name": "storyblok-js-client",
"version": "6.4.0",
"version": "6.4.1",
"description": "Universal JavaScript SDK for Storyblok's API",

@@ -67,3 +67,3 @@ "license": "MIT",

"vite": "^5.0.2",
"vitest": "^0.34.6"
"vitest": "^1.0.4"
},

@@ -130,2 +130,2 @@ "release": {

}
}
}

@@ -78,2 +78,3 @@ import throttledQueue from './throttlePromise'

public resolveNestedRelations: boolean
private stringifiedStoriesCache: Record<string, string>

@@ -152,2 +153,3 @@ /**

this.resolveNestedRelations = config.resolveNestedRelations || true
this.stringifiedStoriesCache = {} as Record<string, string>

@@ -323,2 +325,17 @@ this.client = new SbFetch({

/**
*
* @param resolveId A counter number as a string
* @param uuid The uuid of the story
* @returns string | object
*/
private getStoryReference(resolveId: string, uuid: string): string | JSON {
if (!this.relations[resolveId][uuid]) return uuid
if (!this.stringifiedStoriesCache[uuid])
this.stringifiedStoriesCache[uuid] = JSON.stringify(
this.relations[resolveId][uuid]
)
return JSON.parse(this.stringifiedStoriesCache[uuid])
}
private _insertRelations(

@@ -332,15 +349,7 @@ jtree: ISbStoriesParams,

if (typeof jtree[treeItem] === 'string') {
if (this.relations[resolveId][jtree[treeItem]]) {
jtree[treeItem] = this._cleanCopy(
this.relations[resolveId][jtree[treeItem]]
)
}
} else if (jtree[treeItem] && jtree[treeItem].constructor === Array) {
const stories: JSON[] = []
jtree[treeItem].forEach((uuid: string) => {
if (this.relations[resolveId][uuid]) {
stories.push(this._cleanCopy(this.relations[resolveId][uuid]))
}
})
jtree[treeItem] = stories
jtree[treeItem] = this.getStoryReference(resolveId, jtree[treeItem])
} else if (Array.isArray(jtree[treeItem])) {
jtree[treeItem] = jtree[treeItem]
.map((uuid: string) => this.getStoryReference(resolveId, uuid))
.filter(Boolean)
}

@@ -522,2 +531,4 @@ }

this.stringifiedStoriesCache = {}
delete this.links[resolveId]

@@ -524,0 +535,0 @@ delete this.relations[resolveId]

@@ -33,5 +33,5 @@ import { SbHelpers } from './sbHelpers'

this.responseInterceptor = $c.responseInterceptor
this.fetch = $c.fetch || fetch
this.fetch = (...args: [any]) =>
$c.fetch ? $c.fetch(...args) : fetch(...args)
this.ejectInterceptor = false
this.ejectInterceptor = false
this.url = ''

@@ -125,3 +125,3 @@ this.parameters = {} as ISbStoriesParams

try {
const response = await this.fetch(`${url}`, {
const response = await fetch(`${url}`, {
method,

@@ -128,0 +128,0 @@ headers: this.headers,

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc