nuxt-graphql-middleware 5.1.1 → 5.2.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/client/200.html +6 -6
- package/dist/client/404.html +6 -6
- package/dist/client/_nuxt/4Fsya3Lb.js +1 -0
- package/dist/client/_nuxt/{CyxO-88q.js → BKIQXJNq.js} +1 -1
- package/dist/client/_nuxt/BMPkTe12.js +25 -0
- package/dist/client/_nuxt/CghSORGW.js +2 -0
- package/dist/client/_nuxt/{CFKT0oF2.js → CyXF4zpN.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/85b9c065-c702-4b67-9fa8-2d27fbcda8e3.json +1 -0
- package/dist/client/index.html +6 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -4
- package/dist/runtime/composables/nuxtApp.d.ts +5 -1
- package/dist/runtime/composables/nuxtApp.js +5 -9
- package/dist/runtime/composables/useAsyncGraphqlQuery.js +10 -2
- package/dist/runtime/helpers/ClientCache.d.ts +3 -1
- package/dist/runtime/helpers/ClientCache.js +23 -5
- package/dist/runtime/helpers/composables.d.ts +0 -4
- package/dist/runtime/helpers/composables.js +0 -8
- package/dist/runtime/helpers/queryEncoding.d.ts +5 -1
- package/dist/runtime/helpers/queryEncoding.js +10 -2
- package/package.json +4 -4
- package/dist/client/_nuxt/B-BZSpkz.js +0 -25
- package/dist/client/_nuxt/C6_BMIRJ.js +0 -1
- package/dist/client/_nuxt/CrwW1KlQ.js +0 -2
- package/dist/client/_nuxt/builds/meta/bab648bf-3b57-4a37-bfa7-d3789fe7395f.json +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as L,x as w,y as g,J as I,K as ze,r as W,L as ie,k as O,M as ae,N as T,O as he,P as Ie,Q as x,z as v,R as fe,S as me,T as P,U as F,A as V,s as Fe,V as Ve,W as B,X as ne,B as N,C as Y,D as re,Y as Te,_ as Me}from"./BMPkTe12.js";const pe=L({__name:"NIcon",props:{icon:{}},setup(o){return(e,t)=>(g(),w("div",{class:I(["n-icon",e.icon])},null,2))}});typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Oe=o=>typeof o<"u";function Le(o){return JSON.parse(JSON.stringify(o))}function _e(o,e,t,n={}){var s,i,r;const{clone:c=!1,passive:l=!1,eventName:d,deep:u=!1,defaultValue:a,shouldEmit:f}=n,m=ze(),p=t||(m==null?void 0:m.emit)||((s=m==null?void 0:m.$emit)==null?void 0:s.bind(m))||((r=(i=m==null?void 0:m.proxy)==null?void 0:i.$emit)==null?void 0:r.bind(m==null?void 0:m.proxy));let h=d;e||(e="modelValue"),h=h||`update:${e.toString()}`;const _=S=>c?typeof c=="function"?c(S):Le(S):S,k=()=>Oe(o[e])?_(o[e]):a,b=S=>{f?f(S)&&p(h,S):p(h,S)};if(l){const S=k(),$=W(S);let z=!1;return ie(()=>o[e],C=>{z||(z=!0,$.value=_(C),ae(()=>z=!1))}),ie($,C=>{!z&&(C!==o[e]||u)&&b(C)},{deep:u}),$}else return O({get(){return k()},set(S){b(S)}})}const $e={class:"n-text-input flex flex items-center border n-border-base rounded py-1 pl-1 pr-2 focus-within:n-focus-base focus-within:border-context n-bg-base"},Ee=L({__name:"NTextInput",props:{modelValue:{default:""},icon:{},placeholder:{},disabled:{type:Boolean},autofocus:{type:Boolean},autocomplete:{},readonly:{type:Boolean},type:{default:"text"}},emits:["keydown","keyup","change"],setup(o,{emit:e}){const s=_e(o,"modelValue",e,{passive:!0});return(i,r)=>{const c=pe;return g(),w("div",$e,[T(i.$slots,"icon",{},()=>[i.icon?(g(),P(c,{key:0,icon:i.icon,class:"ml-0.3em mr-0.1em text-1.1em op50"},null,8,["icon"])):F("",!0)]),he(v("input",fe({"onUpdate:modelValue":r[0]||(r[0]=l=>me(s)?s.value=l:null)},i.$props,{class:"ml-0.4em w-full flex-auto n-bg-base !outline-none"}),null,16),[[Ie,x(s)]])])}}}),ge=L({__name:"Tag",props:{green:{type:Boolean},orange:{type:Boolean},text:{}},setup(o){const e=o,t=O(()=>e.green?"bg-green-400:10 text-green-400":e.orange?"bg-orange-400:10 text-orange-400":"bg-gray-400:10 text-gray");return(n,s)=>(g(),w("span",{class:I(["mx-0.5 select-none whitespace-nowrap rounded px-1.5 py-0.5 text-xs inline-block",x(t)])},V(n.text),3))}});let E;const j=[];function ve(o){if(j.push(o),!(typeof window>"u"))return window.__NUXT_DEVTOOLS__&&j.forEach(e=>e(window.__NUXT_DEVTOOLS__)),Object.defineProperty(window,"__NUXT_DEVTOOLS__",{set(e){e&&j.forEach(t=>t(e))},get(){return E.value},configurable:!0}),()=>{j.splice(j.indexOf(o),1)}}function De(){E||(E=Fe(),ve(e));function o(){E&&Ve(E)}function e(t){E.value=t,t.host&&t.host.hooks.hook("host:update:reactivity",o)}return E}const Ne=De(),Ae=["innerHTML"],Pe=["textContent"],Be=L({__name:"NCodeBlock",props:{code:{},lang:{},lines:{type:Boolean,default:!0},inline:{type:Boolean},grammarContextCode:{},transformRendered:{}},emits:["loaded"],setup(o,{emit:e}){const t=o,n=e,s=O(()=>{var c;const r=t.lang==="text"?{code:t.code,supported:!1}:((c=Ne.value)==null?void 0:c.devtools.renderCodeHighlight(t.code,t.lang,{grammarContextCode:t.grammarContextCode}))||{code:t.code,supported:!1};return r.supported&&t.transformRendered&&(r.code=t.transformRendered(r.code)),r.supported&&ae(()=>n("loaded")),r}),i=O(()=>["n-code-block shiki",t.lines&&!t.inline?"n-code-block-lines":""]);return(r,c)=>r.lang&&s.value.supported?(g(),w("pre",{key:0,class:I(i.value)},[v("code",{innerHTML:s.value.code},null,8,Ae)],2)):(g(),w("pre",{key:1,class:I(i.value)},[v("code",null,[(g(!0),w(B,null,ne(r.code.split(`
|
|
2
|
+
`),(l,d)=>(g(),w(B,{key:d},[v("span",{class:"line",textContent:V(l)},null,8,Pe),c[0]||(c[0]=v("br",null,null,-1))],64))),128))])],2))}}),Re={flex:"~ gap-3","items-center":""},je=L({__name:"NIconTitle",props:{icon:{},text:{}},setup(o){return(e,t)=>(g(),w("div",Re,[e.icon?(g(),w("div",{key:0,class:I(e.icon)},null,2)):F("",!0),T(e.$slots,"default",{},()=>[v("div",null,V(e.text),1)])]))}}),We=["open"],Ue={"text-base":""},Je={key:0,"text-sm":"",op50:""},Qe=L({__name:"NSectionBlock",props:{icon:{},text:{},description:{},containerClass:{default:""},headerClass:{},collapse:{type:Boolean,default:!0},open:{type:Boolean,default:!0},padding:{type:[Boolean,String],default:!0}},setup(o){const t=_e(o,"open",void 0,{passive:!0});function n(s){t.value=s.target.open}return(s,i)=>{const r=pe,c=je;return g(),w(B,null,[v("details",{open:x(t),onToggle:i[0]||(i[0]=(...l)=>n&&n(...l))},[v("summary",{class:I(["cursor-pointer select-none hover:bg-active p4",s.collapse?"":"pointer-events-none"])},[N(c,{icon:s.icon,text:s.text,"text-xl":"",transition:"",class:I([x(t)?"op100":"op60",s.headerClass])},{default:Y(()=>[v("div",null,[v("div",Ue,[T(s.$slots,"text",{},()=>[re(V(s.text),1)],!0)]),s.description||s.$slots.description?(g(),w("div",Je,[T(s.$slots,"description",{},()=>[re(V(s.description),1)],!0)])):F("",!0)]),i[1]||(i[1]=v("div",{class:"flex-auto"},null,-1)),T(s.$slots,"actions",{},void 0,!0),s.collapse?(g(),P(r,{key:0,icon:"carbon-chevron-down",class:"chevron","cursor-pointer":"","place-self-start":"","text-base":"",op75:"",transition:"","duration-500":""})):F("",!0)]),_:3,__:[1]},8,["icon","text","class"])],2),i._lazyshow1||x(t)?(i._lazyshow1=!0,g(),w(B,null,[he(v("div",{class:I(["flex flex-col flex-gap2 pb6 pt2",typeof s.padding=="string"?s.padding:s.padding?"px4":""])},[T(s.$slots,"details",{},void 0,!0),v("div",{class:I([s.containerClass,"mt1"])},[T(s.$slots,"default",{},void 0,!0)],2),T(s.$slots,"footer",{},void 0,!0)],2),[[Te,x(t)]])],64)):F("v-show-if",!0)],40,We),i[2]||(i[2]=v("div",{class:"x-divider"},null,-1))],64)}}}),qe=Me(Qe,[["__scopeId","data-v-f3591bcd"]]),Ge={class:"h-full of-auto p2"},Ke={class:"p5"},Xe={class:"font-mono mb4 font-bold text-3xl"},He={key:0,class:"mb3"},Ye=["href"],Ze={key:0,class:"font-mono bg-red-900 text-red-100 p2"},et=L({__name:"DocumentDetail",props:{id:{},timestamp:{},source:{},name:{},identifier:{},filePath:{},serverApiPrefix:{}},setup(o){const e=o,t=O(()=>[]),n=O(()=>e.identifier!=="fragment"?`${e.serverApiPrefix}/${e.identifier}/${e.name}`:null);return(s,i)=>{const r=ge,c=Be,l=qe;return g(),w("div",Ge,[v("div",Ke,[v("h2",Xe,V(s.name),1),x(n)?(g(),w("div",He,[s.identifier==="query"?(g(),P(r,{key:0,green:"",text:"GET"})):(g(),P(r,{key:1,orange:"",text:"POST"})),v("a",{class:"n-transition n-link n-link-base hover:n-link-hover ml2",target:"_blank",href:x(n)},V(x(n)),9,Ye)])):F("",!0)]),N(l,{text:"Document",description:s.filePath,padding:"px4"},{default:Y(()=>[N(c,{code:s.source,lang:"graphql"},null,8,["code"])]),_:1},8,["description"]),N(l,{text:"Errors",description:x(t).length+" errors",padding:"px4"},{default:Y(()=>[x(t).length?(g(),w("div",Ze,[(g(!0),w(B,null,ne(x(t),(d,u)=>(g(),w("div",{key:u},V(d),1))),128))])):F("",!0)]),_:1},8,["description"])])}}}),tt="ENTRIES",we="KEYS",ye="VALUES",y="";class q{constructor(e,t){const n=e._tree,s=Array.from(n.keys());this.set=e,this._type=t,this._path=s.length>0?[{node:n,keys:s}]:[]}next(){const e=this.dive();return this.backtrack(),e}dive(){if(this._path.length===0)return{done:!0,value:void 0};const{node:e,keys:t}=D(this._path);if(D(t)===y)return{done:!1,value:this.result()};const n=e.get(D(t));return this._path.push({node:n,keys:Array.from(n.keys())}),this.dive()}backtrack(){if(this._path.length===0)return;const e=D(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}key(){return this.set._prefix+this._path.map(({keys:e})=>D(e)).filter(e=>e!==y).join("")}value(){return D(this._path).node.get(y)}result(){switch(this._type){case ye:return this.value();case we:return this.key();default:return[this.key(),this.value()]}}[Symbol.iterator](){return this}}const D=o=>o[o.length-1],nt=(o,e,t)=>{const n=new Map;if(e===void 0)return n;const s=e.length+1,i=s+t,r=new Uint8Array(i*s).fill(t+1);for(let c=0;c<s;++c)r[c]=c;for(let c=1;c<i;++c)r[c*s]=c;return xe(o,e,t,n,r,1,s,""),n},xe=(o,e,t,n,s,i,r,c)=>{const l=i*r;e:for(const d of o.keys())if(d===y){const u=s[l-1];u<=t&&n.set(c,[o.get(d),u])}else{let u=i;for(let a=0;a<d.length;++a,++u){const f=d[a],m=r*u,p=m-r;let h=s[m];const _=Math.max(0,u-t-1),k=Math.min(r-1,u+t);for(let b=_;b<k;++b){const S=f!==e[b],$=s[p+b]+ +S,z=s[p+b+1]+1,C=s[m+b]+1,R=s[m+b+1]=Math.min($,z,C);R<h&&(h=R)}if(h>t)continue e}xe(o.get(d),e,t,n,s,u,r,c+d)}};class M{constructor(e=new Map,t=""){this._size=void 0,this._tree=e,this._prefix=t}atPrefix(e){if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");const[t,n]=Q(this._tree,e.slice(this._prefix.length));if(t===void 0){const[s,i]=se(n);for(const r of s.keys())if(r!==y&&r.startsWith(i)){const c=new Map;return c.set(r.slice(i.length),s.get(r)),new M(c,e)}}return new M(t,e)}clear(){this._size=void 0,this._tree.clear()}delete(e){return this._size=void 0,st(this._tree,e)}entries(){return new q(this,tt)}forEach(e){for(const[t,n]of this)e(t,n,this)}fuzzyGet(e,t){return nt(this._tree,e,t)}get(e){const t=Z(this._tree,e);return t!==void 0?t.get(y):void 0}has(e){const t=Z(this._tree,e);return t!==void 0&&t.has(y)}keys(){return new q(this,we)}set(e,t){if(typeof e!="string")throw new Error("key must be a string");return this._size=void 0,G(this._tree,e).set(y,t),this}get size(){if(this._size)return this._size;this._size=0;const e=this.entries();for(;!e.next().done;)this._size+=1;return this._size}update(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;const n=G(this._tree,e);return n.set(y,t(n.get(y))),this}fetch(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;const n=G(this._tree,e);let s=n.get(y);return s===void 0&&n.set(y,s=t()),s}values(){return new q(this,ye)}[Symbol.iterator](){return this.entries()}static from(e){const t=new M;for(const[n,s]of e)t.set(n,s);return t}static fromObject(e){return M.from(Object.entries(e))}}const Q=(o,e,t=[])=>{if(e.length===0||o==null)return[o,t];for(const n of o.keys())if(n!==y&&e.startsWith(n))return t.push([o,n]),Q(o.get(n),e.slice(n.length),t);return t.push([o,e]),Q(void 0,"",t)},Z=(o,e)=>{if(e.length===0||o==null)return o;for(const t of o.keys())if(t!==y&&e.startsWith(t))return Z(o.get(t),e.slice(t.length))},G=(o,e)=>{const t=e.length;e:for(let n=0;o&&n<t;){for(const i of o.keys())if(i!==y&&e[n]===i[0]){const r=Math.min(t-n,i.length);let c=1;for(;c<r&&e[n+c]===i[c];)++c;const l=o.get(i);if(c===i.length)o=l;else{const d=new Map;d.set(i.slice(c),l),o.set(e.slice(n,n+c),d),o.delete(i),o=d}n+=c;continue e}const s=new Map;return o.set(e.slice(n),s),s}return o},st=(o,e)=>{const[t,n]=Q(o,e);if(t!==void 0){if(t.delete(y),t.size===0)be(n);else if(t.size===1){const[s,i]=t.entries().next().value;Se(n,s,i)}}},be=o=>{if(o.length===0)return;const[e,t]=se(o);if(e.delete(t),e.size===0)be(o.slice(0,-1));else if(e.size===1){const[n,s]=e.entries().next().value;n!==y&&Se(o.slice(0,-1),n,s)}},Se=(o,e,t)=>{if(o.length===0)return;const[n,s]=se(o);n.set(s+e,t),n.delete(s)},se=o=>o[o.length-1],oe="or",ke="and",ot="and_not";class A{constructor(e){if((e==null?void 0:e.fields)==null)throw new Error('MiniSearch: option "fields" must be provided');const t=e.autoVacuum==null||e.autoVacuum===!0?H:e.autoVacuum;this._options={...X,...e,autoVacuum:t,searchOptions:{...ce,...e.searchOptions||{}},autoSuggestOptions:{...dt,...e.autoSuggestOptions||{}}},this._index=new M,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=te,this.addFields(this._options.fields)}add(e){const{extractField:t,tokenize:n,processTerm:s,fields:i,idField:r}=this._options,c=t(e,r);if(c==null)throw new Error(`MiniSearch: document does not have ID field "${r}"`);if(this._idToShortId.has(c))throw new Error(`MiniSearch: duplicate ID ${c}`);const l=this.addDocumentId(c);this.saveStoredFields(l,e);for(const d of i){const u=t(e,d);if(u==null)continue;const a=n(u.toString(),d),f=this._fieldIds[d],m=new Set(a).size;this.addFieldLength(l,f,this._documentCount-1,m);for(const p of a){const h=s(p,d);if(Array.isArray(h))for(const _ of h)this.addTerm(f,l,_);else h&&this.addTerm(f,l,h)}}}addAll(e){for(const t of e)this.add(t)}addAllAsync(e,t={}){const{chunkSize:n=10}=t,s={chunk:[],promise:Promise.resolve()},{chunk:i,promise:r}=e.reduce(({chunk:c,promise:l},d,u)=>(c.push(d),(u+1)%n===0?{chunk:[],promise:l.then(()=>new Promise(a=>setTimeout(a,0))).then(()=>this.addAll(c))}:{chunk:c,promise:l}),s);return r.then(()=>this.addAll(i))}remove(e){const{tokenize:t,processTerm:n,extractField:s,fields:i,idField:r}=this._options,c=s(e,r);if(c==null)throw new Error(`MiniSearch: document does not have ID field "${r}"`);const l=this._idToShortId.get(c);if(l==null)throw new Error(`MiniSearch: cannot remove document with ID ${c}: it is not in the index`);for(const d of i){const u=s(e,d);if(u==null)continue;const a=t(u.toString(),d),f=this._fieldIds[d],m=new Set(a).size;this.removeFieldLength(l,f,this._documentCount,m);for(const p of a){const h=n(p,d);if(Array.isArray(h))for(const _ of h)this.removeTerm(f,l,_);else h&&this.removeTerm(f,l,h)}}this._storedFields.delete(l),this._documentIds.delete(l),this._idToShortId.delete(c),this._fieldLength.delete(l),this._documentCount-=1}removeAll(e){if(e)for(const t of e)this.remove(t);else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new M,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}}discard(e){const t=this._idToShortId.get(e);if(t==null)throw new Error(`MiniSearch: cannot discard document with ID ${e}: it is not in the index`);this._idToShortId.delete(e),this._documentIds.delete(t),this._storedFields.delete(t),(this._fieldLength.get(t)||[]).forEach((n,s)=>{this.removeFieldLength(t,s,this._documentCount,n)}),this._fieldLength.delete(t),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()}maybeAutoVacuum(){if(this._options.autoVacuum===!1)return;const{minDirtFactor:e,minDirtCount:t,batchSize:n,batchWait:s}=this._options.autoVacuum;this.conditionalVacuum({batchSize:n,batchWait:s},{minDirtCount:t,minDirtFactor:e})}discardAll(e){const t=this._options.autoVacuum;try{this._options.autoVacuum=!1;for(const n of e)this.discard(n)}finally{this._options.autoVacuum=t}this.maybeAutoVacuum()}replace(e){const{idField:t,extractField:n}=this._options,s=n(e,t);this.discard(s),this.add(e)}vacuum(e={}){return this.conditionalVacuum(e)}conditionalVacuum(e,t){return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&t,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(()=>{const n=this._enqueuedVacuumConditions;return this._enqueuedVacuumConditions=te,this.performVacuuming(e,n)}),this._enqueuedVacuum)):this.vacuumConditionsMet(t)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)}async performVacuuming(e,t){const n=this._dirtCount;if(this.vacuumConditionsMet(t)){const s=e.batchSize||ee.batchSize,i=e.batchWait||ee.batchWait;let r=1;for(const[c,l]of this._index){for(const[d,u]of l)for(const[a]of u)this._documentIds.has(a)||(u.size<=1?l.delete(d):u.delete(a));this._index.get(c).size===0&&this._index.delete(c),r%s===0&&await new Promise(d=>setTimeout(d,i)),r+=1}this._dirtCount-=n}await null,this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null}vacuumConditionsMet(e){if(e==null)return!0;let{minDirtCount:t,minDirtFactor:n}=e;return t=t||H.minDirtCount,n=n||H.minDirtFactor,this.dirtCount>=t&&this.dirtFactor>=n}get isVacuuming(){return this._currentVacuum!=null}get dirtCount(){return this._dirtCount}get dirtFactor(){return this._dirtCount/(1+this._documentCount+this._dirtCount)}has(e){return this._idToShortId.has(e)}getStoredFields(e){const t=this._idToShortId.get(e);if(t!=null)return this._storedFields.get(t)}search(e,t={}){const{searchOptions:n}=this._options,s={...n,...t},i=this.executeQuery(e,t),r=[];for(const[c,{score:l,terms:d,match:u}]of i){const a=d.length||1,f={id:this._documentIds.get(c),score:l*a,terms:Object.keys(u),queryTerms:d,match:u};Object.assign(f,this._storedFields.get(c)),(s.filter==null||s.filter(f))&&r.push(f)}return e===A.wildcard&&s.boostDocument==null||r.sort(de),r}autoSuggest(e,t={}){t={...this._options.autoSuggestOptions,...t};const n=new Map;for(const{score:i,terms:r}of this.search(e,t)){const c=r.join(" "),l=n.get(c);l!=null?(l.score+=i,l.count+=1):n.set(c,{score:i,terms:r,count:1})}const s=[];for(const[i,{score:r,terms:c,count:l}]of n)s.push({suggestion:i,terms:c,score:r/l});return s.sort(de),s}get documentCount(){return this._documentCount}get termCount(){return this._index.size}static loadJSON(e,t){if(t==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(e),t)}static async loadJSONAsync(e,t){if(t==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJSAsync(JSON.parse(e),t)}static getDefault(e){if(X.hasOwnProperty(e))return K(X,e);throw new Error(`MiniSearch: unknown option "${e}"`)}static loadJS(e,t){const{index:n,documentIds:s,fieldLength:i,storedFields:r,serializationVersion:c}=e,l=this.instantiateMiniSearch(e,t);l._documentIds=U(s),l._fieldLength=U(i),l._storedFields=U(r);for(const[d,u]of l._documentIds)l._idToShortId.set(u,d);for(const[d,u]of n){const a=new Map;for(const f of Object.keys(u)){let m=u[f];c===1&&(m=m.ds),a.set(parseInt(f,10),U(m))}l._index.set(d,a)}return l}static async loadJSAsync(e,t){const{index:n,documentIds:s,fieldLength:i,storedFields:r,serializationVersion:c}=e,l=this.instantiateMiniSearch(e,t);l._documentIds=await J(s),l._fieldLength=await J(i),l._storedFields=await J(r);for(const[u,a]of l._documentIds)l._idToShortId.set(a,u);let d=0;for(const[u,a]of n){const f=new Map;for(const m of Object.keys(a)){let p=a[m];c===1&&(p=p.ds),f.set(parseInt(m,10),await J(p))}++d%1e3===0&&await Ce(0),l._index.set(u,f)}return l}static instantiateMiniSearch(e,t){const{documentCount:n,nextId:s,fieldIds:i,averageFieldLength:r,dirtCount:c,serializationVersion:l}=e;if(l!==1&&l!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");const d=new A(t);return d._documentCount=n,d._nextId=s,d._idToShortId=new Map,d._fieldIds=i,d._avgFieldLength=r,d._dirtCount=c||0,d._index=new M,d}executeQuery(e,t={}){if(e===A.wildcard)return this.executeWildcardQuery(t);if(typeof e!="string"){const f={...t,...e,queries:void 0},m=e.queries.map(p=>this.executeQuery(p,f));return this.combineResults(m,f.combineWith)}const{tokenize:n,processTerm:s,searchOptions:i}=this._options,r={tokenize:n,processTerm:s,...i,...t},{tokenize:c,processTerm:l}=r,a=c(e).flatMap(f=>l(f)).filter(f=>!!f).map(lt(r)).map(f=>this.executeQuerySpec(f,r));return this.combineResults(a,r.combineWith)}executeQuerySpec(e,t){const n={...this._options.searchOptions,...t},s=(n.fields||this._options.fields).reduce((h,_)=>({...h,[_]:K(n.boost,_)||1}),{}),{boostDocument:i,weights:r,maxFuzzy:c,bm25:l}=n,{fuzzy:d,prefix:u}={...ce.weights,...r},a=this._index.get(e.term),f=this.termResults(e.term,e.term,1,e.termBoost,a,s,i,l);let m,p;if(e.prefix&&(m=this._index.atPrefix(e.term)),e.fuzzy){const h=e.fuzzy===!0?.2:e.fuzzy,_=h<1?Math.min(c,Math.round(e.term.length*h)):h;_&&(p=this._index.fuzzyGet(e.term,_))}if(m)for(const[h,_]of m){const k=h.length-e.term.length;if(!k)continue;p==null||p.delete(h);const b=u*h.length/(h.length+.3*k);this.termResults(e.term,h,b,e.termBoost,_,s,i,l,f)}if(p)for(const h of p.keys()){const[_,k]=p.get(h);if(!k)continue;const b=d*h.length/(h.length+k);this.termResults(e.term,h,b,e.termBoost,_,s,i,l,f)}return f}executeWildcardQuery(e){const t=new Map,n={...this._options.searchOptions,...e};for(const[s,i]of this._documentIds){const r=n.boostDocument?n.boostDocument(i,"",this._storedFields.get(s)):1;t.set(s,{score:r,terms:[],match:{}})}return t}combineResults(e,t=oe){if(e.length===0)return new Map;const n=t.toLowerCase(),s=it[n];if(!s)throw new Error(`Invalid combination operator: ${t}`);return e.reduce(s)||new Map}toJSON(){const e=[];for(const[t,n]of this._index){const s={};for(const[i,r]of n)s[i]=Object.fromEntries(r);e.push([t,s])}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:e,serializationVersion:2}}termResults(e,t,n,s,i,r,c,l,d=new Map){if(i==null)return d;for(const u of Object.keys(r)){const a=r[u],f=this._fieldIds[u],m=i.get(f);if(m==null)continue;let p=m.size;const h=this._avgFieldLength[f];for(const _ of m.keys()){if(!this._documentIds.has(_)){this.removeTerm(f,_,t),p-=1;continue}const k=c?c(this._documentIds.get(_),t,this._storedFields.get(_)):1;if(!k)continue;const b=m.get(_),S=this._fieldLength.get(_)[f],$=ct(b,p,this._documentCount,S,h,l),z=n*s*a*k*$,C=d.get(_);if(C){C.score+=z,ut(C.terms,e);const R=K(C.match,t);R?R.push(u):C.match[t]=[u]}else d.set(_,{score:z,terms:[e],match:{[t]:[u]}})}}return d}addTerm(e,t,n){const s=this._index.fetch(n,ue);let i=s.get(e);if(i==null)i=new Map,i.set(t,1),s.set(e,i);else{const r=i.get(t);i.set(t,(r||0)+1)}}removeTerm(e,t,n){if(!this._index.has(n)){this.warnDocumentChanged(t,e,n);return}const s=this._index.fetch(n,ue),i=s.get(e);i==null||i.get(t)==null?this.warnDocumentChanged(t,e,n):i.get(t)<=1?i.size<=1?s.delete(e):i.delete(t):i.set(t,i.get(t)-1),this._index.get(n).size===0&&this._index.delete(n)}warnDocumentChanged(e,t,n){for(const s of Object.keys(this._fieldIds))if(this._fieldIds[s]===t){this._options.logger("warn",`MiniSearch: document with ID ${this._documentIds.get(e)} has changed before removal: term "${n}" was not present in field "${s}". Removing a document after it has changed can corrupt the index!`,"version_conflict");return}}addDocumentId(e){const t=this._nextId;return this._idToShortId.set(e,t),this._documentIds.set(t,e),this._documentCount+=1,this._nextId+=1,t}addFields(e){for(let t=0;t<e.length;t++)this._fieldIds[e[t]]=t}addFieldLength(e,t,n,s){let i=this._fieldLength.get(e);i==null&&this._fieldLength.set(e,i=[]),i[t]=s;const c=(this._avgFieldLength[t]||0)*n+s;this._avgFieldLength[t]=c/(n+1)}removeFieldLength(e,t,n,s){if(n===1){this._avgFieldLength[t]=0;return}const i=this._avgFieldLength[t]*n-s;this._avgFieldLength[t]=i/(n-1)}saveStoredFields(e,t){const{storeFields:n,extractField:s}=this._options;if(n==null||n.length===0)return;let i=this._storedFields.get(e);i==null&&this._storedFields.set(e,i={});for(const r of n){const c=s(t,r);c!==void 0&&(i[r]=c)}}}A.wildcard=Symbol("*");const K=(o,e)=>Object.prototype.hasOwnProperty.call(o,e)?o[e]:void 0,it={[oe]:(o,e)=>{for(const t of e.keys()){const n=o.get(t);if(n==null)o.set(t,e.get(t));else{const{score:s,terms:i,match:r}=e.get(t);n.score=n.score+s,n.match=Object.assign(n.match,r),le(n.terms,i)}}return o},[ke]:(o,e)=>{const t=new Map;for(const n of e.keys()){const s=o.get(n);if(s==null)continue;const{score:i,terms:r,match:c}=e.get(n);le(s.terms,r),t.set(n,{score:s.score+i,terms:s.terms,match:Object.assign(s.match,c)})}return t},[ot]:(o,e)=>{for(const t of e.keys())o.delete(t);return o}},rt={k:1.2,b:.7,d:.5},ct=(o,e,t,n,s,i)=>{const{k:r,b:c,d:l}=i;return Math.log(1+(t-e+.5)/(e+.5))*(l+o*(r+1)/(o+r*(1-c+c*n/s)))},lt=o=>(e,t,n)=>{const s=typeof o.fuzzy=="function"?o.fuzzy(e,t,n):o.fuzzy||!1,i=typeof o.prefix=="function"?o.prefix(e,t,n):o.prefix===!0,r=typeof o.boostTerm=="function"?o.boostTerm(e,t,n):1;return{term:e,fuzzy:s,prefix:i,termBoost:r}},X={idField:"id",extractField:(o,e)=>o[e],tokenize:o=>o.split(at),processTerm:o=>o.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(o,e)=>{typeof(console==null?void 0:console[o])=="function"&&console[o](e)},autoVacuum:!0},ce={combineWith:oe,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:rt},dt={combineWith:ke,prefix:(o,e,t)=>e===t.length-1},ee={batchSize:1e3,batchWait:10},te={minDirtFactor:.1,minDirtCount:20},H={...ee,...te},ut=(o,e)=>{o.includes(e)||o.push(e)},le=(o,e)=>{for(const t of e)o.includes(t)||o.push(t)},de=({score:o},{score:e})=>e-o,ue=()=>new Map,U=o=>{const e=new Map;for(const t of Object.keys(o))e.set(parseInt(t,10),o[t]);return e},J=async o=>{const e=new Map;let t=0;for(const n of Object.keys(o))e.set(parseInt(n,10),o[n]),++t%1e3===0&&await Ce(0);return e},Ce=o=>new Promise(e=>setTimeout(e,o)),at=/[\n\r\p{Z}\p{P}]+/u,ht={class:"relative",style:{height:"100vh"}},ft={class:"flex h-full"},mt={class:"h-full border-r border-r-gray-800 of-auto","h-full":"",style:{width:"22rem","min-width":"0",flex:"0 0 auto"}},pt={flex:"~ col gap2",border:"b base",class:"border-b-gray-800 p3 flex-1"},_t=["onClick"],gt={style:{width:"6rem"},class:"text-left"},vt=["onClick"],wt={key:0,class:"h-full relative w-full of-auto"},yt="nuxt-graphql-middleware",bt=L({__name:"index",setup(o){const e=new A({fields:["id","source","name","filePath","identifier"],storeFields:["id","source","name","identifier","filePath"],searchOptions:{fuzzy:.7}}),t=W(""),n=W([]),s=W(""),i=W(""),r=O(()=>{if(t.value)return n.value.find(u=>u.id===t.value)});async function c(u){e.removeAll(),n.value=u,e.addAll(u)}ve(async u=>{const a=u.devtools.extendClientRpc(yt,{showNotification(){},documentsUpdated(p){c(p)}}),f=await a.getDocuments();c(f);const m=await a.getModuleOptions();i.value=m.serverApiPrefix});function l(u){const a=document.createElement("textarea");a.value=u.source,a.style.top="0",a.style.left="0",a.style.position="fixed",document.body.appendChild(a),a.focus(),a.select();try{document.execCommand("copy")}catch{}document.body.removeChild(a)}const d=O(()=>s.value?e.search(s.value):n.value);return(u,a)=>{const f=Ee,m=ge,p=et;return g(),w("div",ht,[v("div",ft,[v("div",mt,[v("div",pt,[N(f,{modelValue:x(s),"onUpdate:modelValue":a[0]||(a[0]=h=>me(s)?s.value=h:null),placeholder:"Search documents...",icon:"carbon-search",class:"w-full"},null,8,["modelValue"])]),(g(!0),w(B,null,ne(x(d),h=>(g(),w("div",{key:h.id,class:"relative group"},[v("button",{class:"text-secondary hover:n-bg-hover flex select-none truncate px2 py2 font-mono text-sm w-full",onClick:_=>t.value=h.id},[v("div",gt,[h.identifier==="query"?(g(),P(m,{key:0,green:"",text:"Query"})):h.identifier==="mutation"?(g(),P(m,{key:1,orange:"",text:"Mutation"})):F("",!0)]),v("div",null,V(h.name),1)],8,_t),v("button",{class:"absolute right-0 top-0 text-sm h-full flex items-center opacity-0 group-hover:opacity-100 pr2",onClick:_=>l(h)},a[1]||(a[1]=[v("span",null,"Copy",-1)]),8,vt)]))),128))]),a[2]||(a[2]=v("div",{class:"splitpanes__splitter"},null,-1)),x(r)?(g(),w("div",wt,[N(p,fe(x(r),{"server-api-prefix":x(i)}),null,16,["server-api-prefix"])])):F("",!0)])])}}});export{bt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{E as a,F as s,G as r,H as o,I as i}from"./BMPkTe12.js";function u(n){var t;const e=n||s();return((t=e==null?void 0:e.ssrContext)==null?void 0:t.head)||(e==null?void 0:e.runWithContext(()=>{if(r())return o(i)}))}function d(n,e={}){const t=u(e.nuxt);if(t)return a(n,{head:t,...e})}export{d as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"85b9c065-c702-4b67-9fa8-2d27fbcda8e3","timestamp":1751274166516}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"85b9c065-c702-4b67-9fa8-2d27fbcda8e3","timestamp":1751274166516,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<!DOCTYPE html><html><head><meta charset="utf-8">
|
|
2
2
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3
3
|
<link rel="stylesheet" href="/__nuxt-graphql-middleware/_nuxt/entry.BBgLZ1Jk.css" crossorigin>
|
|
4
|
-
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/
|
|
4
|
+
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/BMPkTe12.js">
|
|
5
5
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-graphql-middleware/_nuxt/error-404.Bbd2eCoc.css">
|
|
6
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/
|
|
7
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/
|
|
6
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/4Fsya3Lb.js">
|
|
7
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/CyXF4zpN.js">
|
|
8
8
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-graphql-middleware/_nuxt/error-500.Cd2cwFc3.css">
|
|
9
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/
|
|
10
|
-
<script type="module" src="/__nuxt-graphql-middleware/_nuxt/
|
|
11
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"
|
|
9
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/BKIQXJNq.js">
|
|
10
|
+
<script type="module" src="/__nuxt-graphql-middleware/_nuxt/BMPkTe12.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1751274168721,false]</script>
|
|
11
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"85b9c065-c702-4b67-9fa8-2d27fbcda8e3",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import { existsSync as existsSync$1 } from 'fs';
|
|
|
20
20
|
import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
|
|
21
21
|
|
|
22
22
|
const name = "nuxt-graphql-middleware";
|
|
23
|
-
const version = "5.
|
|
23
|
+
const version = "5.2.0";
|
|
24
24
|
|
|
25
25
|
const logger = useLogger("nuxt-graphql-middleware");
|
|
26
26
|
const defaultOptions = {
|
|
@@ -1347,9 +1347,7 @@ const OperationVariables = defineGeneratorTemplate(
|
|
|
1347
1347
|
const operations = output.getCollectedOperations().reduce((acc, collectedOperation) => {
|
|
1348
1348
|
const node = collectedOperation.node;
|
|
1349
1349
|
const operationName = collectedOperation.graphqlName;
|
|
1350
|
-
const variables = (node.variableDefinitions || []).map(
|
|
1351
|
-
(v) => v.variable.name.value
|
|
1352
|
-
);
|
|
1350
|
+
const variables = (node.variableDefinitions || []).map((v) => v.variable.name.value).sort();
|
|
1353
1351
|
acc[operationName] = variables;
|
|
1354
1352
|
return acc;
|
|
1355
1353
|
}, {});
|
|
@@ -30,7 +30,11 @@ overrideClientContext: Record<string, any>,
|
|
|
30
30
|
/**
|
|
31
31
|
* The cache options set on the composable.
|
|
32
32
|
*/
|
|
33
|
-
cacheOptions: RequestCacheOptions
|
|
33
|
+
cacheOptions: RequestCacheOptions,
|
|
34
|
+
/**
|
|
35
|
+
* The async data key.
|
|
36
|
+
*/
|
|
37
|
+
asyncDataKey?: string): Promise<GraphqlResponse<T>>;
|
|
34
38
|
declare module '#app' {
|
|
35
39
|
interface NuxtApp {
|
|
36
40
|
$graphqlCache?: GraphqlMiddlewareCache;
|
|
@@ -7,14 +7,10 @@ import {
|
|
|
7
7
|
clientCacheEnabledAtBuild,
|
|
8
8
|
importMetaClient
|
|
9
9
|
} from "#nuxt-graphql-middleware/config";
|
|
10
|
-
import { encodeVariables } from "../helpers/queryEncoding.js";
|
|
11
|
-
import {
|
|
12
|
-
encodeContext,
|
|
13
|
-
getOrCreateClientCache,
|
|
14
|
-
sortQueryParams
|
|
15
|
-
} from "../helpers/composables.js";
|
|
10
|
+
import { encodeVariables, sortQueryParams } from "../helpers/queryEncoding.js";
|
|
11
|
+
import { encodeContext, getOrCreateClientCache } from "../helpers/composables.js";
|
|
16
12
|
import { OPERATION_HASH_PREFIX } from "../settings/index.js";
|
|
17
|
-
export function performRequest(operation, operationName, variablesOrBody, overrideFetchOptions, globalClientContext, overrideClientContext, cacheOptions) {
|
|
13
|
+
export function performRequest(operation, operationName, variablesOrBody, overrideFetchOptions, globalClientContext, overrideClientContext, cacheOptions, asyncDataKey) {
|
|
18
14
|
const state = useGraphqlState();
|
|
19
15
|
const app = useNuxtApp();
|
|
20
16
|
const config = useAppConfig();
|
|
@@ -89,7 +85,7 @@ export function performRequest(operation, operationName, variablesOrBody, overri
|
|
|
89
85
|
}
|
|
90
86
|
)
|
|
91
87
|
).then((v) => {
|
|
92
|
-
if (import.meta.dev && v
|
|
88
|
+
if (import.meta.dev && v?.errors?.length) {
|
|
93
89
|
app.callHook("nuxt-graphql-middleware:errors", {
|
|
94
90
|
operation,
|
|
95
91
|
operationName,
|
|
@@ -103,7 +99,7 @@ export function performRequest(operation, operationName, variablesOrBody, overri
|
|
|
103
99
|
});
|
|
104
100
|
});
|
|
105
101
|
if (importMetaClient && cacheKey && app.$graphqlCache && clientCacheEnabledAtBuild) {
|
|
106
|
-
app.$graphqlCache.set(cacheKey, promise);
|
|
102
|
+
app.$graphqlCache.set(cacheKey, promise, asyncDataKey);
|
|
107
103
|
}
|
|
108
104
|
return promise;
|
|
109
105
|
}
|
|
@@ -16,6 +16,7 @@ export function useAsyncGraphqlQuery(name, ...args) {
|
|
|
16
16
|
const vars = isRef(variables) ? variables.value : variables;
|
|
17
17
|
return `useAsyncGraphqlQuery:${name}:${hash(vars)}`;
|
|
18
18
|
});
|
|
19
|
+
let prevKey = "";
|
|
19
20
|
const config = useAppConfig();
|
|
20
21
|
const app = useNuxtApp();
|
|
21
22
|
if (importMetaClient) {
|
|
@@ -39,13 +40,19 @@ export function useAsyncGraphqlQuery(name, ...args) {
|
|
|
39
40
|
asyncDataOptions.getCachedData = function(key, app2, ctx) {
|
|
40
41
|
if (ctx.cause === "initial") {
|
|
41
42
|
return app2.payload.data[key] ?? app2.$graphqlCache?.get(key);
|
|
43
|
+
} else if (ctx.cause === "refresh:manual" || ctx.cause === "refresh:hook") {
|
|
44
|
+
if (app2.$graphqlCache) {
|
|
45
|
+
app2.$graphqlCache.purgeAsyncDataKey(key);
|
|
46
|
+
app2.$graphqlCache.purgeAsyncDataKey(prevKey);
|
|
47
|
+
}
|
|
42
48
|
}
|
|
43
49
|
};
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
const result = useAsyncData(
|
|
47
|
-
asyncDataKey,
|
|
53
|
+
asyncDataKey.value,
|
|
48
54
|
() => {
|
|
55
|
+
prevKey = asyncDataKey.value;
|
|
49
56
|
const globalClientContext = clientOptions && clientOptions.buildClientContext ? clientOptions.buildClientContext() : {};
|
|
50
57
|
return performRequest(
|
|
51
58
|
"query",
|
|
@@ -54,7 +61,8 @@ export function useAsyncGraphqlQuery(name, ...args) {
|
|
|
54
61
|
asyncDataOptions.fetchOptions || {},
|
|
55
62
|
globalClientContext,
|
|
56
63
|
asyncDataOptions.clientContext || {},
|
|
57
|
-
asyncDataOptions.graphqlCaching || {}
|
|
64
|
+
asyncDataOptions.graphqlCaching || {},
|
|
65
|
+
asyncDataKey.value
|
|
58
66
|
);
|
|
59
67
|
},
|
|
60
68
|
asyncDataOptions
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class GraphqlMiddlewareCache {
|
|
8
8
|
cache: Record<string, unknown>;
|
|
9
|
+
asyncDataKeyMap: Record<string, string[]>;
|
|
9
10
|
keys: string[];
|
|
10
11
|
maxSize: number;
|
|
11
12
|
constructor(maxSize?: number);
|
|
12
|
-
set(key: string, value: unknown): void;
|
|
13
|
+
set(key: string, value: unknown, asyncDataKey?: string): void;
|
|
13
14
|
get<T>(key: string): T | undefined;
|
|
14
15
|
purge(): void;
|
|
16
|
+
purgeAsyncDataKey(asyncDataKey: string): void;
|
|
15
17
|
remove(key: string): boolean;
|
|
16
18
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
export class GraphqlMiddlewareCache {
|
|
2
|
-
cache;
|
|
3
|
-
|
|
2
|
+
cache = {};
|
|
3
|
+
asyncDataKeyMap = {};
|
|
4
|
+
keys = [];
|
|
4
5
|
maxSize;
|
|
5
6
|
constructor(maxSize = 100) {
|
|
6
|
-
this.cache = {};
|
|
7
|
-
this.keys = [];
|
|
8
7
|
this.maxSize = maxSize;
|
|
9
8
|
}
|
|
10
|
-
set(key, value) {
|
|
9
|
+
set(key, value, asyncDataKey) {
|
|
11
10
|
if (Object.prototype.hasOwnProperty.call(this.cache, key)) {
|
|
12
11
|
const index = this.keys.indexOf(key);
|
|
13
12
|
if (index > -1) {
|
|
@@ -17,10 +16,20 @@ export class GraphqlMiddlewareCache {
|
|
|
17
16
|
const oldestKey = this.keys.shift();
|
|
18
17
|
if (oldestKey !== void 0) {
|
|
19
18
|
delete this.cache[oldestKey];
|
|
19
|
+
delete this.asyncDataKeyMap[oldestKey];
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
this.cache[key] = value;
|
|
23
23
|
this.keys.push(key);
|
|
24
|
+
if (asyncDataKey) {
|
|
25
|
+
if (!Object.prototype.hasOwnProperty.call(
|
|
26
|
+
this.asyncDataKeyMap,
|
|
27
|
+
asyncDataKey
|
|
28
|
+
)) {
|
|
29
|
+
this.asyncDataKeyMap[asyncDataKey] = [];
|
|
30
|
+
}
|
|
31
|
+
this.asyncDataKeyMap[asyncDataKey].push(key);
|
|
32
|
+
}
|
|
24
33
|
}
|
|
25
34
|
get(key) {
|
|
26
35
|
const value = this.cache[key];
|
|
@@ -37,6 +46,15 @@ export class GraphqlMiddlewareCache {
|
|
|
37
46
|
purge() {
|
|
38
47
|
this.cache = {};
|
|
39
48
|
this.keys = [];
|
|
49
|
+
this.asyncDataKeyMap = {};
|
|
50
|
+
}
|
|
51
|
+
purgeAsyncDataKey(asyncDataKey) {
|
|
52
|
+
const keys = this.asyncDataKeyMap[asyncDataKey];
|
|
53
|
+
if (keys && keys.length) {
|
|
54
|
+
keys.forEach((key) => {
|
|
55
|
+
this.remove(key);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
40
58
|
}
|
|
41
59
|
remove(key) {
|
|
42
60
|
if (Object.prototype.hasOwnProperty.call(this.cache, key)) {
|
|
@@ -41,8 +41,4 @@ export type MutationObjectArgs<K extends keyof Mutation, M extends Mutation[K] =
|
|
|
41
41
|
export type PickFrom<T, K extends Array<string>> = T extends Array<any> ? T : T extends Record<string, any> ? keyof T extends K[number] ? T : K[number] extends never ? T : Pick<T, K[number]> : T;
|
|
42
42
|
export type KeysOf<T> = Array<T extends T ? (keyof T extends string ? keyof T : never) : never>;
|
|
43
43
|
export declare function encodeContext(context: Record<string, string | null | undefined>): Record<string, string>;
|
|
44
|
-
/**
|
|
45
|
-
* Sort an object defining query params alphabetically.
|
|
46
|
-
*/
|
|
47
|
-
export declare function sortQueryParams(obj: Record<string, string>): Record<string, string>;
|
|
48
44
|
export declare function getOrCreateClientCache(app: NuxtApp, config: AppConfig): GraphqlMiddlewareCache | undefined;
|
|
@@ -15,14 +15,6 @@ export function encodeContext(context) {
|
|
|
15
15
|
{}
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
|
-
export function sortQueryParams(obj) {
|
|
19
|
-
const sortedKeys = Object.keys(obj).sort();
|
|
20
|
-
const sortedObj = {};
|
|
21
|
-
for (const key of sortedKeys) {
|
|
22
|
-
sortedObj[key] = obj[key];
|
|
23
|
-
}
|
|
24
|
-
return sortedObj;
|
|
25
|
-
}
|
|
26
18
|
export function getOrCreateClientCache(app, config) {
|
|
27
19
|
if (importMetaServer || !clientCacheEnabledAtBuild) {
|
|
28
20
|
return;
|
|
@@ -8,4 +8,8 @@ export declare function encodeVariables(variables?: Record<string, any> | null):
|
|
|
8
8
|
* In complex cases, the entire variables are sent as a JSON encoded string:
|
|
9
9
|
* ?__variables=%7B%22foobar%22:%7B%22path%22:%22%22%7D%7D
|
|
10
10
|
*/
|
|
11
|
-
export declare function decodeVariables(query: Record<string, any>, validKeys?: string[]): any
|
|
11
|
+
export declare function decodeVariables(query: Record<string, any>, validKeys?: string[]): Record<string, any>;
|
|
12
|
+
/**
|
|
13
|
+
* Sort an object defining query params alphabetically.
|
|
14
|
+
*/
|
|
15
|
+
export declare function sortQueryParams(obj: Record<string, string>): Record<string, string>;
|
|
@@ -49,7 +49,7 @@ function filterValidKeys(validKeys, obj) {
|
|
|
49
49
|
export function decodeVariables(query, validKeys) {
|
|
50
50
|
try {
|
|
51
51
|
if (query.__variables && typeof query.__variables === "string") {
|
|
52
|
-
return JSON.parse(query.__variables);
|
|
52
|
+
return sortQueryParams(JSON.parse(query.__variables));
|
|
53
53
|
}
|
|
54
54
|
} catch {
|
|
55
55
|
}
|
|
@@ -85,5 +85,13 @@ export function decodeVariables(query, validKeys) {
|
|
|
85
85
|
result[key] = query[key];
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
return result;
|
|
88
|
+
return sortQueryParams(result);
|
|
89
|
+
}
|
|
90
|
+
export function sortQueryParams(obj) {
|
|
91
|
+
const sortedKeys = Object.keys(obj).sort();
|
|
92
|
+
const sortedObj = {};
|
|
93
|
+
for (const key of sortedKeys) {
|
|
94
|
+
sortedObj[key] = obj[key];
|
|
95
|
+
}
|
|
96
|
+
return sortedObj;
|
|
89
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-graphql-middleware",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Module to perform GraphQL requests as a server middleware.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -82,16 +82,16 @@
|
|
|
82
82
|
"@nuxt/devtools": "^2.4.0",
|
|
83
83
|
"@nuxt/devtools-ui-kit": "^2.4.0",
|
|
84
84
|
"@nuxt/eslint": "^1.2.0",
|
|
85
|
-
"@nuxt/kit": "^3.17.
|
|
85
|
+
"@nuxt/kit": "^3.17.5",
|
|
86
86
|
"@nuxt/module-builder": "^1.0.1",
|
|
87
|
-
"@nuxt/schema": "^3.17.
|
|
87
|
+
"@nuxt/schema": "^3.17.5",
|
|
88
88
|
"@types/micromatch": "^4.0.9",
|
|
89
89
|
"cypress": "^13.12.0",
|
|
90
90
|
"eslint": "^9.23.0",
|
|
91
91
|
"eslint-config-prettier": "^10.1.1",
|
|
92
92
|
"eslint-plugin-prettier": "^5.2.3",
|
|
93
93
|
"mermaid": "^11.5.0",
|
|
94
|
-
"nuxt": "^3.17.
|
|
94
|
+
"nuxt": "^3.17.5",
|
|
95
95
|
"postcss": "^8.5.3",
|
|
96
96
|
"postcss-cli": "^11.0.1",
|
|
97
97
|
"postcss-import": "^16.1.0",
|