nuxt-graphql-middleware 4.0.0-beta.6 → 4.0.0-beta.8
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 +12 -2
- package/dist/client/404.html +12 -2
- package/dist/client/_nuxt/entry.1bc811cf.css +1 -0
- package/dist/client/_nuxt/entry.ea5ff097.js +7 -0
- package/dist/client/_nuxt/error-404.0c27f143.js +1 -0
- package/dist/client/_nuxt/error-404.a6f724cc.css +1 -0
- package/dist/client/_nuxt/error-500.0ea30584.js +1 -0
- package/dist/client/_nuxt/error-500.d92554dd.css +1 -0
- package/dist/client/_nuxt/index.3f9296a3.css +1 -0
- package/dist/client/_nuxt/index.e982558e.js +2 -0
- package/dist/client/_nuxt/vue.f36acd1f.b03bdbb5.js +1 -0
- package/dist/client/index.html +12 -2
- package/dist/module.d.mts +318 -0
- package/dist/module.d.ts +63 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +103 -16
- package/dist/runtime/composables/useGraphqlState.d.ts +1 -2
- package/dist/runtime/composables/useGraphqlState.mjs +1 -1
- package/dist/runtime/plugins/provideState.d.ts +1 -1
- package/dist/runtime/serverHandler/debug.d.ts +1 -1
- package/dist/runtime/serverHandler/index.d.ts +1 -1
- package/dist/runtime/serverHandler/index.mjs +33 -12
- package/dist/types.d.mts +17 -0
- package/dist/types.d.ts +6 -0
- package/package.json +35 -34
- package/dist/client/_nuxt/entry.0bb826e1.js +0 -5
- package/dist/client/_nuxt/entry.0dd29d47.css +0 -1
- package/dist/client/_nuxt/error-404.0cd4f3dd.css +0 -1
- package/dist/client/_nuxt/error-404.ffea5d7c.js +0 -1
- package/dist/client/_nuxt/error-500.748cb764.css +0 -1
- package/dist/client/_nuxt/error-500.d39ec227.js +0 -1
- package/dist/client/_nuxt/error-component.3d690bfd.js +0 -3
- package/dist/client/_nuxt/index.86b21181.js +0 -2
- package/dist/client/_nuxt/index.dc8fb7ec.css +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as H,m as E,q as B,I as U,r as ne,D as xe,J as Ae,c as K,H as Pe,K as G,L as Se,M as Ue,N as T,s as M,O as ze,P as Ee,Q as j,R,t as J,S as We,T as Re,U as ee,V as ye,v as Z,x as he,y as we,W as Je,z as Qe,A as Ge}from"./entry.ea5ff097.js";import{_ as He}from"./_plugin-vue_export-helper.c27b6911.js";const De=H({__name:"NIcon",props:{icon:{}},setup(i){return(e,t)=>(E(),B("div",{class:U(["n-icon",e.icon])},null,2))}}),Ke=i=>typeof i<"u";function Xe(i){return JSON.parse(JSON.stringify(i))}function Ve(i,e,t,o={}){var r,n,a;const{clone:u=!1,passive:l=!1,eventName:s,deep:c=!1,defaultValue:f,shouldEmit:d}=o,h=Pe(),y=t||(h==null?void 0:h.emit)||((r=h==null?void 0:h.$emit)==null?void 0:r.bind(h))||((a=(n=h==null?void 0:h.proxy)==null?void 0:n.$emit)==null?void 0:a.bind(h==null?void 0:h.proxy));let v=s;e||(e="modelValue"),v=v||`update:${e.toString()}`;const m=p=>u?typeof u=="function"?u(p):Xe(p):p,g=()=>Ke(i[e])?m(i[e]):f,x=p=>{d?d(p)&&y(v,p):y(v,p)};if(l){const p=g(),A=ne(p);let b=!1;return xe(()=>i[e],S=>{b||(b=!0,A.value=m(S),Ae(()=>b=!1))}),xe(A,S=>{!b&&(S!==i[e]||c)&&x(S)},{deep:c}),A}else return K({get(){return g()},set(p){x(p)}})}const Ye={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"},qe=H({__name:"NTextInput",props:{modelValue:{default:""},icon:{},placeholder:{},disabled:{type:Boolean},autofocus:{type:Boolean},type:{default:"text"}},setup(i,{emit:e}){const o=Ve(i,"modelValue",e,{passive:!0});return(r,n)=>{const a=De;return E(),B("div",Ye,[G(r.$slots,"icon",{},()=>[r.icon?(E(),j(a,{key:0,icon:r.icon,class:"ml-0.3em mr-0.1em text-1.1em op50"},null,8,["icon"])):R("",!0)]),Se(M("input",ze({"onUpdate:modelValue":n[0]||(n[0]=u=>Ee(o)?o.value=u:null)},r.$props,{class:"ml-0.4em w-full flex-auto n-bg-base !outline-none"}),null,16),[[Ue,T(o)]])])}}}),Me=H({__name:"Tag",props:{green:{type:Boolean},orange:{type:Boolean},text:{}},setup(i){const e=i,t=K(()=>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(o,r)=>(E(),B("span",{class:U(["mx-0.5 select-none whitespace-nowrap rounded px-1.5 py-0.5 text-xs inline-block",T(t)])},J(o.text),3))}});let q;const te=[];function Oe(i){if(te.push(i),!(typeof window>"u"))return window.__NUXT_DEVTOOLS__&&te.forEach(e=>e(window.__NUXT_DEVTOOLS__)),Object.defineProperty(window,"__NUXT_DEVTOOLS__",{set(e){e&&te.forEach(t=>t(e))},get(){return q.value},configurable:!0}),()=>{te.splice(te.indexOf(i),1)}}function Ze(){q||(q=We(),Oe(e));function i(){Re(q)}function e(t){q.value=t,t.host&&t.host.hooks.hook("host:update:reactivity",i)}return q}const je=Ze(),et=["innerHTML"],tt={class:"shiki"},rt=["textContent"],nt=M("br",null,null,-1),it=H({__name:"NCodeBlock",props:{code:{},lang:{},lines:{type:Boolean,default:!0},transformRendered:{}},emits:["loaded"],setup(i,{emit:e}){const t=i,o=K(()=>{var n;const r=t.lang==="text"?{code:t.code,supported:!1}:((n=je.value)==null?void 0:n.devtools.renderCodeHighlight(t.code,t.lang))||{code:t.code,supported:!1};return r.supported&&t.transformRendered&&(r.code=t.transformRendered(r.code)),r.supported&&Ae(()=>e("loaded")),r});return(r,n)=>r.lang&&o.value.supported?(E(),B("pre",{key:0,class:U(["n-code-block",r.lines?"n-code-block-lines":""]),innerHTML:o.value.code},null,10,et)):(E(),B("pre",{key:1,class:U(["n-code-block",r.lines?"n-code-block-lines":""])},[M("pre",tt,[M("code",null,[(E(!0),B(ee,null,ye(r.code.split(`
|
|
2
|
+
`),(a,u)=>(E(),B(ee,{key:u},[M("span",{class:"line",textContent:J(a)},null,8,rt),nt],64))),128))])])],2))}});const ot={flex:"~ gap-3","items-center":""},at=H({__name:"NIconTitle",props:{icon:{},text:{}},setup(i){return(e,t)=>(E(),B("div",ot,[e.icon?(E(),B("div",{key:0,class:U(e.icon)},null,2)):R("",!0),G(e.$slots,"default",{},()=>[M("div",null,J(e.text),1)])]))}}),ke=i=>(Qe("data-v-f53dd400"),i=i(),Ge(),i),ut=["open"],lt={"text-base":""},st={key:0,"text-sm":"",op50:""},ct=ke(()=>M("div",{class:"flex-auto"},null,-1)),ft=ke(()=>M("div",{class:"x-divider"},null,-1)),ht=H({__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(i){const t=Ve(i,"open",void 0,{passive:!0});function o(r){t.value=r.target.open}return(r,n)=>{const a=De,u=at;return E(),B(ee,null,[M("details",{open:T(t),onToggle:o},[M("summary",{class:U(["cursor-pointer select-none hover:bg-active p4",r.collapse?"":"pointer-events-none"])},[Z(u,{icon:r.icon,text:r.text,"text-xl":"",transition:"",class:U([T(t)?"op100":"op60",r.headerClass])},{default:he(()=>[M("div",null,[M("div",lt,[G(r.$slots,"text",{},()=>[we(J(r.text),1)],!0)]),r.description||r.$slots.description?(E(),B("div",st,[G(r.$slots,"description",{},()=>[we(J(r.description),1)],!0)])):R("",!0)]),ct,G(r.$slots,"actions",{},void 0,!0),r.collapse?(E(),j(a,{key:0,icon:"carbon-chevron-down",class:"chevron","cursor-pointer":"","place-self-start":"","text-base":"",op75:"",transition:"","duration-500":""})):R("",!0)]),_:3},8,["icon","text","class"])],2),n._lazyshow1||T(t)?(n._lazyshow1=!0,E(),B(ee,null,[Se(M("div",{class:U(["flex flex-col flex-gap2 pb6 pt2",typeof r.padding=="string"?r.padding:r.padding?"px4":""])},[G(r.$slots,"details",{},void 0,!0),M("div",{class:U([r.containerClass,"mt1"])},[G(r.$slots,"default",{},void 0,!0)],2),G(r.$slots,"footer",{},void 0,!0)],2),[[Je,T(t)]])],64)):R("v-show-if",!0)],40,ut),ft],64)}}});const dt=He(ht,[["__scopeId","data-v-f53dd400"]]),vt={class:"h-full of-auto p2"},pt={class:"p5"},yt={class:"font-mono mb4 font-bold text-3xl"},mt={key:0,class:"mb3"},gt=["href"],xt={key:0,class:"font-mono bg-red-900 text-red-100 p2"},wt=H({__name:"DocumentDetail",props:{id:{},content:{},isValid:{type:Boolean},errors:{},filename:{},relativePath:{},name:{},operation:{},serverApiPrefix:{}},setup(i){const e=i,t=K(()=>(e.errors||[]).map(r=>r.message)),o=K(()=>{if(e.operation)return`${e.serverApiPrefix}/${e.operation}/${e.name}`});return(r,n)=>{const a=Me,u=it,l=dt;return E(),B("div",vt,[M("div",pt,[M("h2",yt,J(r.name),1),T(o)?(E(),B("div",mt,[r.operation==="query"?(E(),j(a,{key:0,green:"",text:"GET"})):(E(),j(a,{key:1,orange:"",text:"POST"})),M("a",{class:"n-transition n-link n-link-base hover:n-link-hover ml2",target:"_blank",href:T(o)},J(T(o)),9,gt)])):R("",!0)]),Z(l,{text:"Document",description:r.relativePath,padding:"px4"},{default:he(()=>[Z(u,{code:r.content,lang:"graphql"},null,8,["code"])]),_:1},8,["description"]),Z(l,{text:"Errors",description:T(t).length+" errors",padding:"px4"},{default:he(()=>[T(t).length?(E(),B("div",xt,[(E(!0),B(ee,null,ye(T(t),(s,c)=>(E(),B("div",{key:c},J(s),1))),128))])):R("",!0)]),_:1},8,["description"])])}}});var k=function(){return k=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++){t=arguments[o];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},k.apply(this,arguments)};function _t(i,e,t,o){function r(n){return n instanceof t?n:new t(function(a){a(n)})}return new(t||(t=Promise))(function(n,a){function u(c){try{s(o.next(c))}catch(f){a(f)}}function l(c){try{s(o.throw(c))}catch(f){a(f)}}function s(c){c.done?n(c.value):r(c.value).then(u,l)}s((o=o.apply(i,e||[])).next())})}function Ft(i,e){var t={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},o,r,n,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(s){return function(c){return l([s,c])}}function l(s){if(o)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(t=0)),t;)try{if(o=1,r&&(n=s[0]&2?r.return:s[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,s[1])).done)return n;switch(r=0,n&&(s=[s[0]&2,n.value]),s[0]){case 0:case 1:n=s;break;case 4:return t.label++,{value:s[1],done:!1};case 5:t.label++,r=s[1],s=[0];continue;case 7:s=t.ops.pop(),t.trys.pop();continue;default:if(n=t.trys,!(n=n.length>0&&n[n.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!n||s[1]>n[0]&&s[1]<n[3])){t.label=s[1];break}if(s[0]===6&&t.label<n[1]){t.label=n[1],n=s;break}if(n&&t.label<n[2]){t.label=n[2],t.ops.push(s);break}n[2]&&t.ops.pop(),t.trys.pop();continue}s=e.call(i,t)}catch(c){s=[6,c],r=0}finally{o=n=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function w(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],o=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&o>=i.length&&(i=void 0),{value:i&&i[o++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function I(i,e){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var o=t.call(i),r,n=[],a;try{for(;(e===void 0||e-- >0)&&!(r=o.next()).done;)n.push(r.value)}catch(u){a={error:u}}finally{try{r&&!r.done&&(t=o.return)&&t.call(o)}finally{if(a)throw a.error}}return n}var bt="ENTRIES",Le="KEYS",Be="VALUES",$="",ae=function(){function i(e,t){var o=e._tree,r=Array.from(o.keys());this.set=e,this._type=t,this._path=r.length>0?[{node:o,keys:r}]:[]}return i.prototype.next=function(){var e=this.dive();return this.backtrack(),e},i.prototype.dive=function(){if(this._path.length===0)return{done:!0,value:void 0};var e=Y(this._path),t=e.node,o=e.keys;if(Y(o)===$)return{done:!1,value:this.result()};var r=t.get(Y(o));return this._path.push({node:r,keys:Array.from(r.keys())}),this.dive()},i.prototype.backtrack=function(){if(this._path.length!==0){var e=Y(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}},i.prototype.key=function(){return this.set._prefix+this._path.map(function(e){var t=e.keys;return Y(t)}).filter(function(e){return e!==$}).join("")},i.prototype.value=function(){return Y(this._path).node.get($)},i.prototype.result=function(){switch(this._type){case Be:return this.value();case Le:return this.key();default:return[this.key(),this.value()]}},i.prototype[Symbol.iterator]=function(){return this},i}(),Y=function(i){return i[i.length-1]},Ct=function(i,e,t){var o=new Map;if(e===void 0)return o;for(var r=e.length+1,n=r+t,a=new Uint8Array(n*r).fill(t+1),u=0;u<r;++u)a[u]=u;for(var l=1;l<n;++l)a[l*r]=l;return Ie(i,e,t,o,a,1,r,""),o},Ie=function(i,e,t,o,r,n,a,u){var l,s,c=n*a;try{e:for(var f=w(i.keys()),d=f.next();!d.done;d=f.next()){var h=d.value;if(h===$){var y=r[c-1];y<=t&&o.set(u,[i.get(h),y])}else{for(var v=n,m=0;m<h.length;++m,++v){for(var g=h[m],x=a*v,p=x-a,A=r[x],b=Math.max(0,v-t-1),S=Math.min(a-1,v+t),_=b;_<S;++_){var C=g!==e[_],z=r[p+_]+ +C,D=r[p+_+1]+1,O=r[x+_]+1,F=r[x+_+1]=Math.min(z,D,O);F<A&&(A=F)}if(A>t)continue e}Ie(i.get(h),e,t,o,r,v,a,u+h)}}}catch(L){l={error:L}}finally{try{d&&!d.done&&(s=f.return)&&s.call(f)}finally{if(l)throw l.error}}},ue=function(){function i(e,t){e===void 0&&(e=new Map),t===void 0&&(t=""),this._size=void 0,this._tree=e,this._prefix=t}return i.prototype.atPrefix=function(e){var t,o;if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");var r=I(oe(this._tree,e.slice(this._prefix.length)),2),n=r[0],a=r[1];if(n===void 0){var u=I(me(a),2),l=u[0],s=u[1];try{for(var c=w(l.keys()),f=c.next();!f.done;f=c.next()){var d=f.value;if(d!==$&&d.startsWith(s)){var h=new Map;return h.set(d.slice(s.length),l.get(d)),new i(h,e)}}}catch(y){t={error:y}}finally{try{f&&!f.done&&(o=c.return)&&o.call(c)}finally{if(t)throw t.error}}}return new i(n,e)},i.prototype.clear=function(){this._size=void 0,this._tree.clear()},i.prototype.delete=function(e){return this._size=void 0,At(this._tree,e)},i.prototype.entries=function(){return new ae(this,bt)},i.prototype.forEach=function(e){var t,o;try{for(var r=w(this),n=r.next();!n.done;n=r.next()){var a=I(n.value,2),u=a[0],l=a[1];e(u,l,this)}}catch(s){t={error:s}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(t)throw t.error}}},i.prototype.fuzzyGet=function(e,t){return Ct(this._tree,e,t)},i.prototype.get=function(e){var t=de(this._tree,e);return t!==void 0?t.get($):void 0},i.prototype.has=function(e){var t=de(this._tree,e);return t!==void 0&&t.has($)},i.prototype.keys=function(){return new ae(this,Le)},i.prototype.set=function(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var o=le(this._tree,e);return o.set($,t),this},Object.defineProperty(i.prototype,"size",{get:function(){if(this._size)return this._size;this._size=0;for(var e=this.entries();!e.next().done;)this._size+=1;return this._size},enumerable:!1,configurable:!0}),i.prototype.update=function(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var o=le(this._tree,e);return o.set($,t(o.get($))),this},i.prototype.fetch=function(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var o=le(this._tree,e),r=o.get($);return r===void 0&&o.set($,r=t()),r},i.prototype.values=function(){return new ae(this,Be)},i.prototype[Symbol.iterator]=function(){return this.entries()},i.from=function(e){var t,o,r=new i;try{for(var n=w(e),a=n.next();!a.done;a=n.next()){var u=I(a.value,2),l=u[0],s=u[1];r.set(l,s)}}catch(c){t={error:c}}finally{try{a&&!a.done&&(o=n.return)&&o.call(n)}finally{if(t)throw t.error}}return r},i.fromObject=function(e){return i.from(Object.entries(e))},i}(),oe=function(i,e,t){var o,r;if(t===void 0&&(t=[]),e.length===0||i==null)return[i,t];try{for(var n=w(i.keys()),a=n.next();!a.done;a=n.next()){var u=a.value;if(u!==$&&e.startsWith(u))return t.push([i,u]),oe(i.get(u),e.slice(u.length),t)}}catch(l){o={error:l}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return t.push([i,e]),oe(void 0,"",t)},de=function(i,e){var t,o;if(e.length===0||i==null)return i;try{for(var r=w(i.keys()),n=r.next();!n.done;n=r.next()){var a=n.value;if(a!==$&&e.startsWith(a))return de(i.get(a),e.slice(a.length))}}catch(u){t={error:u}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(t)throw t.error}}},le=function(i,e){var t,o,r=e.length;e:for(var n=0;i&&n<r;){try{for(var a=(t=void 0,w(i.keys())),u=a.next();!u.done;u=a.next()){var l=u.value;if(l!==$&&e[n]===l[0]){for(var s=Math.min(r-n,l.length),c=1;c<s&&e[n+c]===l[c];)++c;var f=i.get(l);if(c===l.length)i=f;else{var d=new Map;d.set(l.slice(c),f),i.set(e.slice(n,n+c),d),i.delete(l),i=d}n+=c;continue e}}}catch(y){t={error:y}}finally{try{u&&!u.done&&(o=a.return)&&o.call(a)}finally{if(t)throw t.error}}var h=new Map;return i.set(e.slice(n),h),h}return i},At=function(i,e){var t=I(oe(i,e),2),o=t[0],r=t[1];if(o!==void 0){if(o.delete($),o.size===0)$e(r);else if(o.size===1){var n=I(o.entries().next().value,2),a=n[0],u=n[1];Te(r,a,u)}}},$e=function(i){if(i.length!==0){var e=I(me(i),2),t=e[0],o=e[1];if(t.delete(o),t.size===0)$e(i.slice(0,-1));else if(t.size===1){var r=I(t.entries().next().value,2),n=r[0],a=r[1];n!==$&&Te(i.slice(0,-1),n,a)}}},Te=function(i,e,t){if(i.length!==0){var o=I(me(i),2),r=o[0],n=o[1];r.set(n+e,t),r.delete(n)}},me=function(i){return i[i.length-1]},re,ge="or",Ne="and",St="and_not",zt=function(){function i(e){if((e==null?void 0:e.fields)==null)throw new Error('MiniSearch: option "fields" must be provided');var t=e.autoVacuum==null||e.autoVacuum===!0?fe:e.autoVacuum;this._options=k(k(k({},ce),e),{autoVacuum:t,searchOptions:k(k({},_e),e.searchOptions||{}),autoSuggestOptions:k(k({},Ot),e.autoSuggestOptions||{})}),this._index=new ue,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=pe,this.addFields(this._options.fields)}return i.prototype.add=function(e){var t,o,r,n,a,u,l=this._options,s=l.extractField,c=l.tokenize,f=l.processTerm,d=l.fields,h=l.idField,y=s(e,h);if(y==null)throw new Error('MiniSearch: document does not have ID field "'.concat(h,'"'));if(this._idToShortId.has(y))throw new Error("MiniSearch: duplicate ID ".concat(y));var v=this.addDocumentId(y);this.saveStoredFields(v,e);try{for(var m=w(d),g=m.next();!g.done;g=m.next()){var x=g.value,p=s(e,x);if(p!=null){var A=c(p.toString(),x),b=this._fieldIds[x],S=new Set(A).size;this.addFieldLength(v,b,this._documentCount-1,S);try{for(var _=(r=void 0,w(A)),C=_.next();!C.done;C=_.next()){var z=C.value,D=f(z,x);if(Array.isArray(D))try{for(var O=(a=void 0,w(D)),F=O.next();!F.done;F=O.next()){var L=F.value;this.addTerm(b,v,L)}}catch(V){a={error:V}}finally{try{F&&!F.done&&(u=O.return)&&u.call(O)}finally{if(a)throw a.error}}else D&&this.addTerm(b,v,D)}}catch(V){r={error:V}}finally{try{C&&!C.done&&(n=_.return)&&n.call(_)}finally{if(r)throw r.error}}}}}catch(V){t={error:V}}finally{try{g&&!g.done&&(o=m.return)&&o.call(m)}finally{if(t)throw t.error}}},i.prototype.addAll=function(e){var t,o;try{for(var r=w(e),n=r.next();!n.done;n=r.next()){var a=n.value;this.add(a)}}catch(u){t={error:u}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(t)throw t.error}}},i.prototype.addAllAsync=function(e,t){var o=this;t===void 0&&(t={});var r=t.chunkSize,n=r===void 0?10:r,a={chunk:[],promise:Promise.resolve()},u=e.reduce(function(c,f,d){var h=c.chunk,y=c.promise;return h.push(f),(d+1)%n===0?{chunk:[],promise:y.then(function(){return new Promise(function(v){return setTimeout(v,0)})}).then(function(){return o.addAll(h)})}:{chunk:h,promise:y}},a),l=u.chunk,s=u.promise;return s.then(function(){return o.addAll(l)})},i.prototype.remove=function(e){var t,o,r,n,a,u,l=this._options,s=l.tokenize,c=l.processTerm,f=l.extractField,d=l.fields,h=l.idField,y=f(e,h);if(y==null)throw new Error('MiniSearch: document does not have ID field "'.concat(h,'"'));var v=this._idToShortId.get(y);if(v==null)throw new Error("MiniSearch: cannot remove document with ID ".concat(y,": it is not in the index"));try{for(var m=w(d),g=m.next();!g.done;g=m.next()){var x=g.value,p=f(e,x);if(p!=null){var A=s(p.toString(),x),b=this._fieldIds[x],S=new Set(A).size;this.removeFieldLength(v,b,this._documentCount,S);try{for(var _=(r=void 0,w(A)),C=_.next();!C.done;C=_.next()){var z=C.value,D=c(z,x);if(Array.isArray(D))try{for(var O=(a=void 0,w(D)),F=O.next();!F.done;F=O.next()){var L=F.value;this.removeTerm(b,v,L)}}catch(V){a={error:V}}finally{try{F&&!F.done&&(u=O.return)&&u.call(O)}finally{if(a)throw a.error}}else D&&this.removeTerm(b,v,D)}}catch(V){r={error:V}}finally{try{C&&!C.done&&(n=_.return)&&n.call(_)}finally{if(r)throw r.error}}}}}catch(V){t={error:V}}finally{try{g&&!g.done&&(o=m.return)&&o.call(m)}finally{if(t)throw t.error}}this._storedFields.delete(v),this._documentIds.delete(v),this._idToShortId.delete(y),this._fieldLength.delete(v),this._documentCount-=1},i.prototype.removeAll=function(e){var t,o;if(e)try{for(var r=w(e),n=r.next();!n.done;n=r.next()){var a=n.value;this.remove(a)}}catch(u){t={error:u}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(t)throw t.error}}else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new ue,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}},i.prototype.discard=function(e){var t=this,o=this._idToShortId.get(e);if(o==null)throw new Error("MiniSearch: cannot discard document with ID ".concat(e,": it is not in the index"));this._idToShortId.delete(e),this._documentIds.delete(o),this._storedFields.delete(o),(this._fieldLength.get(o)||[]).forEach(function(r,n){t.removeFieldLength(o,n,t._documentCount,r)}),this._fieldLength.delete(o),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()},i.prototype.maybeAutoVacuum=function(){if(this._options.autoVacuum!==!1){var e=this._options.autoVacuum,t=e.minDirtFactor,o=e.minDirtCount,r=e.batchSize,n=e.batchWait;this.conditionalVacuum({batchSize:r,batchWait:n},{minDirtCount:o,minDirtFactor:t})}},i.prototype.discardAll=function(e){var t,o,r=this._options.autoVacuum;try{this._options.autoVacuum=!1;try{for(var n=w(e),a=n.next();!a.done;a=n.next()){var u=a.value;this.discard(u)}}catch(l){t={error:l}}finally{try{a&&!a.done&&(o=n.return)&&o.call(n)}finally{if(t)throw t.error}}}finally{this._options.autoVacuum=r}this.maybeAutoVacuum()},i.prototype.replace=function(e){var t=this._options,o=t.idField,r=t.extractField,n=r(e,o);this.discard(n),this.add(e)},i.prototype.vacuum=function(e){return e===void 0&&(e={}),this.conditionalVacuum(e)},i.prototype.conditionalVacuum=function(e,t){var o=this;return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&t,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(function(){var r=o._enqueuedVacuumConditions;return o._enqueuedVacuumConditions=pe,o.performVacuuming(e,r)}),this._enqueuedVacuum)):this.vacuumConditionsMet(t)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)},i.prototype.performVacuuming=function(e,t){return _t(this,void 0,void 0,function(){var o,r,n,a,u,l,s,c,f,d,h,y,v,m,g,x,p,A,b,S,_,C,z,D,O;return Ft(this,function(F){switch(F.label){case 0:if(o=this._dirtCount,!this.vacuumConditionsMet(t))return[3,10];r=e.batchSize||ve.batchSize,n=e.batchWait||ve.batchWait,a=1,F.label=1;case 1:F.trys.push([1,7,8,9]),u=w(this._index),l=u.next(),F.label=2;case 2:if(l.done)return[3,6];s=I(l.value,2),c=s[0],f=s[1];try{for(d=(C=void 0,w(f)),h=d.next();!h.done;h=d.next()){y=I(h.value,2),v=y[0],m=y[1];try{for(g=(D=void 0,w(m)),x=g.next();!x.done;x=g.next())p=I(x.value,1),A=p[0],!this._documentIds.has(A)&&(m.size<=1?f.delete(v):m.delete(A))}catch(L){D={error:L}}finally{try{x&&!x.done&&(O=g.return)&&O.call(g)}finally{if(D)throw D.error}}}}catch(L){C={error:L}}finally{try{h&&!h.done&&(z=d.return)&&z.call(d)}finally{if(C)throw C.error}}return this._index.get(c).size===0&&this._index.delete(c),a%r!==0?[3,4]:[4,new Promise(function(L){return setTimeout(L,n)})];case 3:F.sent(),F.label=4;case 4:a+=1,F.label=5;case 5:return l=u.next(),[3,2];case 6:return[3,9];case 7:return b=F.sent(),S={error:b},[3,9];case 8:try{l&&!l.done&&(_=u.return)&&_.call(u)}finally{if(S)throw S.error}return[7];case 9:this._dirtCount-=o,F.label=10;case 10:return[4,null];case 11:return F.sent(),this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null,[2]}})})},i.prototype.vacuumConditionsMet=function(e){if(e==null)return!0;var t=e.minDirtCount,o=e.minDirtFactor;return t=t||fe.minDirtCount,o=o||fe.minDirtFactor,this.dirtCount>=t&&this.dirtFactor>=o},Object.defineProperty(i.prototype,"isVacuuming",{get:function(){return this._currentVacuum!=null},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"dirtCount",{get:function(){return this._dirtCount},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"dirtFactor",{get:function(){return this._dirtCount/(1+this._documentCount+this._dirtCount)},enumerable:!1,configurable:!0}),i.prototype.has=function(e){return this._idToShortId.has(e)},i.prototype.getStoredFields=function(e){var t=this._idToShortId.get(e);if(t!=null)return this._storedFields.get(t)},i.prototype.search=function(e,t){var o,r;t===void 0&&(t={});var n=this.executeQuery(e,t),a=[];try{for(var u=w(n),l=u.next();!l.done;l=u.next()){var s=I(l.value,2),c=s[0],f=s[1],d=f.score,h=f.terms,y=f.match,v=h.length,m={id:this._documentIds.get(c),score:d*v,terms:Object.keys(y),match:y};Object.assign(m,this._storedFields.get(c)),(t.filter==null||t.filter(m))&&a.push(m)}}catch(g){o={error:g}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(o)throw o.error}}return a.sort(be),a},i.prototype.autoSuggest=function(e,t){var o,r,n,a;t===void 0&&(t={}),t=k(k({},this._options.autoSuggestOptions),t);var u=new Map;try{for(var l=w(this.search(e,t)),s=l.next();!s.done;s=l.next()){var c=s.value,f=c.score,d=c.terms,h=d.join(" "),y=u.get(h);y!=null?(y.score+=f,y.count+=1):u.set(h,{score:f,terms:d,count:1})}}catch(b){o={error:b}}finally{try{s&&!s.done&&(r=l.return)&&r.call(l)}finally{if(o)throw o.error}}var v=[];try{for(var m=w(u),g=m.next();!g.done;g=m.next()){var x=I(g.value,2),y=x[0],p=x[1],f=p.score,d=p.terms,A=p.count;v.push({suggestion:y,terms:d,score:f/A})}}catch(b){n={error:b}}finally{try{g&&!g.done&&(a=m.return)&&a.call(m)}finally{if(n)throw n.error}}return v.sort(be),v},Object.defineProperty(i.prototype,"documentCount",{get:function(){return this._documentCount},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"termCount",{get:function(){return this._index.size},enumerable:!1,configurable:!0}),i.loadJSON=function(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)},i.getDefault=function(e){if(ce.hasOwnProperty(e))return se(ce,e);throw new Error('MiniSearch: unknown option "'.concat(e,'"'))},i.loadJS=function(e,t){var o,r,n,a,u,l,s=e.index,c=e.documentCount,f=e.nextId,d=e.documentIds,h=e.fieldIds,y=e.fieldLength,v=e.averageFieldLength,m=e.storedFields,g=e.dirtCount,x=e.serializationVersion;if(x!==1&&x!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");var p=new i(t);p._documentCount=c,p._nextId=f,p._documentIds=ie(d),p._idToShortId=new Map,p._fieldIds=h,p._fieldLength=ie(y),p._avgFieldLength=v,p._storedFields=ie(m),p._dirtCount=g||0,p._index=new ue;try{for(var A=w(p._documentIds),b=A.next();!b.done;b=A.next()){var S=I(b.value,2),_=S[0],C=S[1];p._idToShortId.set(C,_)}}catch(W){o={error:W}}finally{try{b&&!b.done&&(r=A.return)&&r.call(A)}finally{if(o)throw o.error}}try{for(var z=w(s),D=z.next();!D.done;D=z.next()){var O=I(D.value,2),F=O[0],L=O[1],V=new Map;try{for(var P=(u=void 0,w(Object.keys(L))),N=P.next();!N.done;N=P.next()){var Q=N.value,X=L[Q];x===1&&(X=X.ds),V.set(parseInt(Q,10),ie(X))}}catch(W){u={error:W}}finally{try{N&&!N.done&&(l=P.return)&&l.call(P)}finally{if(u)throw u.error}}p._index.set(F,V)}}catch(W){n={error:W}}finally{try{D&&!D.done&&(a=z.return)&&a.call(z)}finally{if(n)throw n.error}}return p},i.prototype.executeQuery=function(e,t){var o=this;if(t===void 0&&(t={}),typeof e!="string"){var r=k(k(k({},t),e),{queries:void 0}),n=e.queries.map(function(m){return o.executeQuery(m,r)});return this.combineResults(n,r.combineWith)}var a=this._options,u=a.tokenize,l=a.processTerm,s=a.searchOptions,c=k(k({tokenize:u,processTerm:l},s),t),f=c.tokenize,d=c.processTerm,h=f(e).flatMap(function(m){return d(m)}).filter(function(m){return!!m}),y=h.map(Mt(c)),v=y.map(function(m){return o.executeQuerySpec(m,c)});return this.combineResults(v,c.combineWith)},i.prototype.executeQuerySpec=function(e,t){var o,r,n,a,u=k(k({},this._options.searchOptions),t),l=(u.fields||this._options.fields).reduce(function(Q,X){var W;return k(k({},Q),(W={},W[X]=se(u.boost,X)||1,W))},{}),s=u.boostDocument,c=u.weights,f=u.maxFuzzy,d=u.bm25,h=k(k({},_e.weights),c),y=h.fuzzy,v=h.prefix,m=this._index.get(e.term),g=this.termResults(e.term,e.term,1,m,l,s,d),x,p;if(e.prefix&&(x=this._index.atPrefix(e.term)),e.fuzzy){var A=e.fuzzy===!0?.2:e.fuzzy,b=A<1?Math.min(f,Math.round(e.term.length*A)):A;b&&(p=this._index.fuzzyGet(e.term,b))}if(x)try{for(var S=w(x),_=S.next();!_.done;_=S.next()){var C=I(_.value,2),z=C[0],D=C[1],O=z.length-e.term.length;if(O){p==null||p.delete(z);var F=v*z.length/(z.length+.3*O);this.termResults(e.term,z,F,D,l,s,d,g)}}}catch(Q){o={error:Q}}finally{try{_&&!_.done&&(r=S.return)&&r.call(S)}finally{if(o)throw o.error}}if(p)try{for(var L=w(p.keys()),V=L.next();!V.done;V=L.next()){var z=V.value,P=I(p.get(z),2),N=P[0],O=P[1];if(O){var F=y*z.length/(z.length+O);this.termResults(e.term,z,F,N,l,s,d,g)}}}catch(Q){n={error:Q}}finally{try{V&&!V.done&&(a=L.return)&&a.call(L)}finally{if(n)throw n.error}}return g},i.prototype.combineResults=function(e,t){if(t===void 0&&(t=ge),e.length===0)return new Map;var o=t.toLowerCase();return e.reduce(Et[o])||new Map},i.prototype.toJSON=function(){var e,t,o,r,n=[];try{for(var a=w(this._index),u=a.next();!u.done;u=a.next()){var l=I(u.value,2),s=l[0],c=l[1],f={};try{for(var d=(o=void 0,w(c)),h=d.next();!h.done;h=d.next()){var y=I(h.value,2),v=y[0],m=y[1];f[v]=Object.fromEntries(m)}}catch(g){o={error:g}}finally{try{h&&!h.done&&(r=d.return)&&r.call(d)}finally{if(o)throw o.error}}n.push([s,f])}}catch(g){e={error:g}}finally{try{u&&!u.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}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:n,serializationVersion:2}},i.prototype.termResults=function(e,t,o,r,n,a,u,l){var s,c,f,d,h;if(l===void 0&&(l=new Map),r==null)return l;try{for(var y=w(Object.keys(n)),v=y.next();!v.done;v=y.next()){var m=v.value,g=n[m],x=this._fieldIds[m],p=r.get(x);if(p!=null){var A=p.size,b=this._avgFieldLength[x];try{for(var S=(f=void 0,w(p.keys())),_=S.next();!_.done;_=S.next()){var C=_.value;if(!this._documentIds.has(C)){this.removeTerm(x,C,t),A-=1;continue}var z=a?a(this._documentIds.get(C),t,this._storedFields.get(C)):1;if(z){var D=p.get(C),O=this._fieldLength.get(C)[x],F=Vt(D,A,this._documentCount,O,b,u),L=o*g*z*F,V=l.get(C);if(V){V.score+=L,kt(V.terms,e);var P=se(V.match,t);P?P.push(m):V.match[t]=[m]}else l.set(C,{score:L,terms:[e],match:(h={},h[t]=[m],h)})}}}catch(N){f={error:N}}finally{try{_&&!_.done&&(d=S.return)&&d.call(S)}finally{if(f)throw f.error}}}}}catch(N){s={error:N}}finally{try{v&&!v.done&&(c=y.return)&&c.call(y)}finally{if(s)throw s.error}}return l},i.prototype.addTerm=function(e,t,o){var r=this._index.fetch(o,Ce),n=r.get(e);if(n==null)n=new Map,n.set(t,1),r.set(e,n);else{var a=n.get(t);n.set(t,(a||0)+1)}},i.prototype.removeTerm=function(e,t,o){if(!this._index.has(o)){this.warnDocumentChanged(t,e,o);return}var r=this._index.fetch(o,Ce),n=r.get(e);n==null||n.get(t)==null?this.warnDocumentChanged(t,e,o):n.get(t)<=1?n.size<=1?r.delete(e):n.delete(t):n.set(t,n.get(t)-1),this._index.get(o).size===0&&this._index.delete(o)},i.prototype.warnDocumentChanged=function(e,t,o){var r,n;try{for(var a=w(Object.keys(this._fieldIds)),u=a.next();!u.done;u=a.next()){var l=u.value;if(this._fieldIds[l]===t){this._options.logger("warn","MiniSearch: document with ID ".concat(this._documentIds.get(e),' has changed before removal: term "').concat(o,'" was not present in field "').concat(l,'". Removing a document after it has changed can corrupt the index!'),"version_conflict");return}}}catch(s){r={error:s}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}},i.prototype.addDocumentId=function(e){var t=this._nextId;return this._idToShortId.set(e,t),this._documentIds.set(t,e),this._documentCount+=1,this._nextId+=1,t},i.prototype.addFields=function(e){for(var t=0;t<e.length;t++)this._fieldIds[e[t]]=t},i.prototype.addFieldLength=function(e,t,o,r){var n=this._fieldLength.get(e);n==null&&this._fieldLength.set(e,n=[]),n[t]=r;var a=this._avgFieldLength[t]||0,u=a*o+r;this._avgFieldLength[t]=u/(o+1)},i.prototype.removeFieldLength=function(e,t,o,r){if(o===1){this._avgFieldLength[t]=0;return}var n=this._avgFieldLength[t]*o-r;this._avgFieldLength[t]=n/(o-1)},i.prototype.saveStoredFields=function(e,t){var o,r,n=this._options,a=n.storeFields,u=n.extractField;if(!(a==null||a.length===0)){var l=this._storedFields.get(e);l==null&&this._storedFields.set(e,l={});try{for(var s=w(a),c=s.next();!c.done;c=s.next()){var f=c.value,d=u(t,f);d!==void 0&&(l[f]=d)}}catch(h){o={error:h}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}}},i}(),se=function(i,e){return Object.prototype.hasOwnProperty.call(i,e)?i[e]:void 0},Et=(re={},re[ge]=function(i,e){var t,o;try{for(var r=w(e.keys()),n=r.next();!n.done;n=r.next()){var a=n.value,u=i.get(a);if(u==null)i.set(a,e.get(a));else{var l=e.get(a),s=l.score,c=l.terms,f=l.match;u.score=u.score+s,u.match=Object.assign(u.match,f),Fe(u.terms,c)}}}catch(d){t={error:d}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(t)throw t.error}}return i},re[Ne]=function(i,e){var t,o,r=new Map;try{for(var n=w(e.keys()),a=n.next();!a.done;a=n.next()){var u=a.value,l=i.get(u);if(l!=null){var s=e.get(u),c=s.score,f=s.terms,d=s.match;Fe(l.terms,f),r.set(u,{score:l.score+c,terms:l.terms,match:Object.assign(l.match,d)})}}}catch(h){t={error:h}}finally{try{a&&!a.done&&(o=n.return)&&o.call(n)}finally{if(t)throw t.error}}return r},re[St]=function(i,e){var t,o;try{for(var r=w(e.keys()),n=r.next();!n.done;n=r.next()){var a=n.value;i.delete(a)}}catch(u){t={error:u}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(t)throw t.error}}return i},re),Dt={k:1.2,b:.7,d:.5},Vt=function(i,e,t,o,r,n){var a=n.k,u=n.b,l=n.d,s=Math.log(1+(t-e+.5)/(e+.5));return s*(l+i*(a+1)/(i+a*(1-u+u*o/r)))},Mt=function(i){return function(e,t,o){var r=typeof i.fuzzy=="function"?i.fuzzy(e,t,o):i.fuzzy||!1,n=typeof i.prefix=="function"?i.prefix(e,t,o):i.prefix===!0;return{term:e,fuzzy:r,prefix:n}}},ce={idField:"id",extractField:function(i,e){return i[e]},tokenize:function(i,e){return i.split(Lt)},processTerm:function(i,e){return i.toLowerCase()},fields:void 0,searchOptions:void 0,storeFields:[],logger:function(i,e,t){return console!=null&&console.warn!=null&&console[i](e)},autoVacuum:!0},_e={combineWith:ge,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:Dt},Ot={combineWith:Ne,prefix:function(i,e,t){return e===t.length-1}},ve={batchSize:1e3,batchWait:10},pe={minDirtFactor:.1,minDirtCount:20},fe=k(k({},ve),pe),kt=function(i,e){i.includes(e)||i.push(e)},Fe=function(i,e){var t,o;try{for(var r=w(e),n=r.next();!n.done;n=r.next()){var a=n.value;i.includes(a)||i.push(a)}}catch(u){t={error:u}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(t)throw t.error}}},be=function(i,e){var t=i.score,o=e.score;return o-t},Ce=function(){return new Map},ie=function(i){var e,t,o=new Map;try{for(var r=w(Object.keys(i)),n=r.next();!n.done;n=r.next()){var a=n.value;o.set(parseInt(a,10),i[a])}}catch(u){e={error:u}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return o},Lt=/[\n\r -#%-*,-/:;?@[-\]_{}\u00A0\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u1680\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2000-\u200A\u2010-\u2029\u202F-\u2043\u2045-\u2051\u2053-\u205F\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u3000-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]+/u;const Bt={class:"relative",style:{height:"100vh"}},It={class:"flex h-full"},$t={class:"h-full border-r border-r-gray-800 of-auto","h-full":"",style:{width:"22rem","min-width":"0",flex:"0 0 auto"}},Tt={flex:"~ col gap2",border:"b base",class:"border-b-gray-800 p3 flex-1"},Nt=["onClick"],Pt={style:{width:"6rem"},class:"text-left"},Ut=["onClick"],Wt=M("span",null,"Copy",-1),Rt=[Wt],Jt=M("div",{class:"splitpanes__splitter"},null,-1),Qt={key:0,class:"h-full relative w-full of-auto"},Gt="nuxt-graphql-middleware",Xt=H({__name:"index",setup(i){let e=new zt({fields:["content","name","filename"],storeFields:["id","content","isValid","errors","filename","relativePath","name","operation"],searchOptions:{fuzzy:.7}});const t=ne(""),o=ne([]),r=ne(""),n=ne(""),a=K(()=>{if(t.value)return o.value.find(c=>c.id===t.value)});async function u(c){e.removeAll(),o.value=c.filter(f=>!!f.operation),await e.addAll(c)}Oe(async c=>{const f=c.devtools.extendClientRpc(Gt,{documentsUpdated(y){u(y)}}),d=await f.getDocuments();u(d);const h=await f.getModuleOptions();n.value=h.serverApiPrefix});function l(c){const f=document.createElement("textarea");f.value=c.content,f.style.top="0",f.style.left="0",f.style.position="fixed",document.body.appendChild(f),f.focus(),f.select();try{const d=document.execCommand("copy")}catch{}document.body.removeChild(f)}const s=K(()=>r.value?e.search(r.value):o.value);return(c,f)=>{const d=qe,h=Me,y=wt;return E(),B("div",Bt,[M("div",It,[M("div",$t,[M("div",Tt,[Z(d,{modelValue:T(r),"onUpdate:modelValue":f[0]||(f[0]=v=>Ee(r)?r.value=v:null),placeholder:"Search documents...",icon:"carbon-search",class:"w-full"},null,8,["modelValue"])]),(E(!0),B(ee,null,ye(T(s),v=>(E(),B("div",{key:v.content,class:"relative group"},[M("button",{class:U(["text-secondary hover:n-bg-hover flex select-none truncate px2 py2 font-mono text-sm w-full",{"text-red-500":!v.isValid}]),onClick:m=>t.value=v.id},[M("div",Pt,[v.operation==="query"?(E(),j(h,{key:0,green:"",text:"Query"})):v.operation==="mutation"?(E(),j(h,{key:1,orange:"",text:"Mutation"})):R("",!0)]),M("div",null,J(v.name),1)],10,Nt),M("button",{class:"absolute right-0 top-0 text-sm h-full flex items-center opacity-0 group-hover:opacity-100 pr2",onClick:m=>l(v)},Rt,8,Ut)]))),128))]),Jt,T(a)?(E(),B("div",Qt,[Z(y,ze(T(a),{"server-api-prefix":T(n)}),null,16,["server-api-prefix"])])):R("",!0)])])}}});export{Xt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as o,r as u,C as f,D as d,e as v,E as l,F as i,G as h,H as m}from"./entry.ea5ff097.js";function U(t,a={}){const e=a.head||o();if(e)return e.ssr?e.push(t,a):p(e,t,a)}function p(t,a,e={}){const s=u(!1),n=u({});f(()=>{n.value=s.value?{}:h(a)});const r=t.push(n.value,e);return d(n,c=>{r.patch(c)}),m()&&(v(()=>{r.dispose()}),l(()=>{s.value=!0}),i(()=>{s.value=!1})),r}export{U as u};
|
package/dist/client/index.html
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html >
|
|
3
3
|
<head><meta charset="utf-8">
|
|
4
|
-
<meta name="viewport" content="width=device-width, initial-scale=1"
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
5
|
+
<link rel="stylesheet" href="/__nuxt-graphql-middleware/_nuxt/entry.1bc811cf.css">
|
|
6
|
+
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/entry.ea5ff097.js">
|
|
7
|
+
<link rel="prefetch" as="style" href="/__nuxt-graphql-middleware/_nuxt/error-404.a6f724cc.css">
|
|
8
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/error-404.0c27f143.js">
|
|
9
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/vue.f36acd1f.b03bdbb5.js">
|
|
10
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/_plugin-vue_export-helper.c27b6911.js">
|
|
11
|
+
<link rel="prefetch" as="style" href="/__nuxt-graphql-middleware/_nuxt/error-500.d92554dd.css">
|
|
12
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/error-500.0ea30584.js">
|
|
13
|
+
<script type="module" src="/__nuxt-graphql-middleware/_nuxt/entry.ea5ff097.js" crossorigin></script><script>"use strict";(()=>{const a=window,e=document.documentElement,m=["dark","light"],c=window.localStorage.getItem("nuxt-color-mode")||"system";let n=c==="system"?f():c;const l=e.getAttribute("data-color-mode-forced");l&&(n=l),i(n),a["__NUXT_COLOR_MODE__"]={preference:c,value:n,getColorScheme:f,addColorScheme:i,removeColorScheme:d};function i(o){const t=""+o+"",s="";e.classList?e.classList.add(t):e.className+=" "+t,s&&e.setAttribute("data-"+s,o)}function d(o){const t=""+o+"",s="";e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp(t,"g"),""),s&&e.removeAttribute("data-"+s)}function r(o){return a.matchMedia("(prefers-color-scheme"+o+")")}function f(){if(a.matchMedia&&r("").media!=="not all"){for(const o of m)if(r(":"+o).matches)return o}return"light"}})();
|
|
5
14
|
</script></head>
|
|
6
|
-
<body ><div id="__nuxt"></div><script>
|
|
15
|
+
<body ><div id="__nuxt"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"_errors":1,"serverRendered":2,"data":3,"state":4},{},false,{},{}]</script>
|
|
16
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body>
|
|
7
17
|
</html>
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
3
|
+
import { SchemaASTConfig } from '@graphql-codegen/schema-ast';
|
|
4
|
+
import { TypeScriptDocumentsPluginConfig } from '@graphql-codegen/typescript-operations';
|
|
5
|
+
import { H3Event } from 'h3';
|
|
6
|
+
import { FetchOptions, FetchResponse, FetchError } from 'ofetch';
|
|
7
|
+
|
|
8
|
+
type GraphqlMiddlewareGraphqlEndpointMethod = (event?: H3Event, operation?: string, operationName?: string) => string | Promise<string> | void;
|
|
9
|
+
type GraphqlMiddlewareServerFetchOptionsMethod = (event?: H3Event, operation?: string, operationName?: string) => FetchOptions | Promise<FetchOptions>;
|
|
10
|
+
type GraphqlMiddlewareOnServerResponseMethod = (event: H3Event, response: FetchResponse<any>, operation?: string, operationName?: string) => any | Promise<any>;
|
|
11
|
+
type GraphqlMiddlewareOnServerErrorMethod = (event: H3Event, error: FetchError, operation?: string, operationName?: string) => any | Promise<any>;
|
|
12
|
+
type GraphqlMiddlewareDoRequestMethodContext = {
|
|
13
|
+
/**
|
|
14
|
+
* The incoming request event from H3.
|
|
15
|
+
*/
|
|
16
|
+
event: H3Event;
|
|
17
|
+
/**
|
|
18
|
+
* The type of operation.
|
|
19
|
+
*/
|
|
20
|
+
operation: 'query' | 'mutation';
|
|
21
|
+
/**
|
|
22
|
+
* The name of the operation.
|
|
23
|
+
*/
|
|
24
|
+
operationName: string;
|
|
25
|
+
/**
|
|
26
|
+
* The operation document (the raw GraphQL query/mutation as a string).
|
|
27
|
+
*/
|
|
28
|
+
operationDocument: string;
|
|
29
|
+
/**
|
|
30
|
+
* Variables for the operation.
|
|
31
|
+
*/
|
|
32
|
+
variables: Record<string, any>;
|
|
33
|
+
};
|
|
34
|
+
type GraphqlMiddlewareDoRequestMethod = (context: GraphqlMiddlewareDoRequestMethodContext) => Promise<{
|
|
35
|
+
data: any;
|
|
36
|
+
errors?: any[];
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Configuration options during runtime.
|
|
40
|
+
*/
|
|
41
|
+
type GraphqlMiddlewareServerOptions = {
|
|
42
|
+
/**
|
|
43
|
+
* Custom callback to return the GraphQL endpoint per request.
|
|
44
|
+
*
|
|
45
|
+
* @default undefined
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* function graphqlEndpoint(event, operation, operationName) {
|
|
50
|
+
* const language = getLanguageFromRequest(event)
|
|
51
|
+
* return `https://api.example.com/${language}/graphql`
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
graphqlEndpoint?: GraphqlMiddlewareGraphqlEndpointMethod;
|
|
56
|
+
/**
|
|
57
|
+
* Provide the options for the ofetch request to the GraphQL server.
|
|
58
|
+
*
|
|
59
|
+
* @default undefined
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { getHeader } from 'h3'
|
|
64
|
+
*
|
|
65
|
+
* // Pass the cookie from the client request to the GraphQL request.
|
|
66
|
+
* function serverFetchOptions(event, operation, operationName) {
|
|
67
|
+
* return {
|
|
68
|
+
* headers: {
|
|
69
|
+
* Cookie: getHeader(event, 'cookie')
|
|
70
|
+
* }
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
serverFetchOptions?: GraphqlMiddlewareServerFetchOptionsMethod;
|
|
76
|
+
/**
|
|
77
|
+
* Handle the response from the GraphQL server.
|
|
78
|
+
*
|
|
79
|
+
* You can alter the response, add additional properties to the data, get
|
|
80
|
+
* and set headers, etc.
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* import type { H3Event } from 'h3'
|
|
84
|
+
* import type { FetchResponse } from 'ofetch'
|
|
85
|
+
*
|
|
86
|
+
* function onServerResponse(event: H3Event, graphqlResponse: FetchResponse) {
|
|
87
|
+
* // Set a static header.
|
|
88
|
+
* event.node.res.setHeader('x-nuxt-custom-header', 'A custom header value')
|
|
89
|
+
*
|
|
90
|
+
* // Pass the set-cookie header from the GraphQL response to the client.
|
|
91
|
+
* const setCookie = graphqlResponse.headers.get('set-cookie')
|
|
92
|
+
* if (setCookie) {
|
|
93
|
+
* event.node.res.setHeader('set-cookie', setCookie)
|
|
94
|
+
* }
|
|
95
|
+
*
|
|
96
|
+
* // Add additional properties to the response.
|
|
97
|
+
* graphqlResponse._data.__customProperty = ['My', 'values']
|
|
98
|
+
*
|
|
99
|
+
* // Return the GraphQL response.
|
|
100
|
+
* return graphqlResponse._data
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
onServerResponse?: GraphqlMiddlewareOnServerResponseMethod;
|
|
105
|
+
/**
|
|
106
|
+
* Handle a fetch error from the GraphQL request.
|
|
107
|
+
*
|
|
108
|
+
* Note that errors are only thrown for responses that are not status
|
|
109
|
+
* 200-299. See https://github.com/unjs/ofetch#%EF%B8%8F-handling-errors for
|
|
110
|
+
* more information.
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* import { createError } from 'h3'
|
|
114
|
+
* import type { H3Event } from 'h3'
|
|
115
|
+
* import type { FetchError } from 'ofetch'
|
|
116
|
+
*
|
|
117
|
+
* function onServerError(
|
|
118
|
+
* event: H3Event,
|
|
119
|
+
* error: FetchError,
|
|
120
|
+
* operation: string,
|
|
121
|
+
* operationName: string,
|
|
122
|
+
* ) {
|
|
123
|
+
* // Throw a h3 error.
|
|
124
|
+
* throw createError({
|
|
125
|
+
* statusCode: 500,
|
|
126
|
+
* statusMessage: `Couldn't execute GraphQL ${operation} "${operationName}".`,
|
|
127
|
+
* data: error.message
|
|
128
|
+
* })
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
onServerError?: GraphqlMiddlewareOnServerErrorMethod;
|
|
133
|
+
/**
|
|
134
|
+
* Provide a custom fetch method for requests to the GraphQL server.
|
|
135
|
+
*
|
|
136
|
+
* This can be used if onServerError, onServerResponse, serverFetchOptions
|
|
137
|
+
* and graphqlEndpoint are not enough to meet your requirements.
|
|
138
|
+
*
|
|
139
|
+
* The method will be called in the /api/graphql server route and should
|
|
140
|
+
* perform the GraphQL request and return the response.
|
|
141
|
+
*
|
|
142
|
+
* An example use case might be to handle expired tokens.
|
|
143
|
+
*
|
|
144
|
+
* * ```ts
|
|
145
|
+
* async function doGraphqlRequest({
|
|
146
|
+
* event,
|
|
147
|
+
* operation,
|
|
148
|
+
* operationName,
|
|
149
|
+
* operationDocument,
|
|
150
|
+
* variables,
|
|
151
|
+
* }) {
|
|
152
|
+
* const result = await $fetch.raw('https://example.com/graphql', {
|
|
153
|
+
* method: 'POST'
|
|
154
|
+
* body: {
|
|
155
|
+
* query: operationDocument,
|
|
156
|
+
* variables,
|
|
157
|
+
* operationName
|
|
158
|
+
* },
|
|
159
|
+
* headers: {
|
|
160
|
+
* 'custom-header': 'foobar'
|
|
161
|
+
* }
|
|
162
|
+
* })
|
|
163
|
+
*
|
|
164
|
+
* return result._data
|
|
165
|
+
* }
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
doGraphqlRequest?: GraphqlMiddlewareDoRequestMethod;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
interface ModuleOptions {
|
|
172
|
+
/**
|
|
173
|
+
* File glob patterns for the auto import feature.
|
|
174
|
+
*
|
|
175
|
+
* If left empty, no documents are auto imported.
|
|
176
|
+
*
|
|
177
|
+
* @default
|
|
178
|
+
* ```json
|
|
179
|
+
* ["**\/.{gql,graphql}", "!node_modules"]
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* // Load .graphql files from pages folder and from a node_modules dependency.
|
|
185
|
+
* const autoImportPatterns = [
|
|
186
|
+
* './pages/**\/*.graphql',
|
|
187
|
+
* 'node_modules/my_library/dist/**\/*.graphql'
|
|
188
|
+
* ]
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
autoImportPatterns?: string[];
|
|
192
|
+
/**
|
|
193
|
+
* Additional raw documents to include.
|
|
194
|
+
*
|
|
195
|
+
* Useful if for example you need to generate queries during build time.
|
|
196
|
+
*
|
|
197
|
+
* @default []
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const documents = [`
|
|
202
|
+
* query myQuery {
|
|
203
|
+
* articles {
|
|
204
|
+
* title
|
|
205
|
+
* id
|
|
206
|
+
* }
|
|
207
|
+
* }`,
|
|
208
|
+
* ...getGeneratedDocuments()
|
|
209
|
+
* ]
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
documents?: string[];
|
|
213
|
+
/**
|
|
214
|
+
* Wether the useGraphqlQuery, useGraphqlMutation and useGraphqlState
|
|
215
|
+
* composables should be included.
|
|
216
|
+
*
|
|
217
|
+
* @default ```ts
|
|
218
|
+
* true
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
includeComposables?: boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Enable detailled debugging messages.
|
|
224
|
+
*
|
|
225
|
+
* @default false
|
|
226
|
+
*/
|
|
227
|
+
debug?: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* The URL of the GraphQL server.
|
|
230
|
+
*
|
|
231
|
+
* For the runtime execution you can provide a method that determines the endpoint
|
|
232
|
+
* during runtime. See the app/graphqlMiddleware.serverOptions.ts documentation
|
|
233
|
+
* for more information.
|
|
234
|
+
*/
|
|
235
|
+
graphqlEndpoint: string;
|
|
236
|
+
/**
|
|
237
|
+
* Download the GraphQL schema and store it on disk.
|
|
238
|
+
*
|
|
239
|
+
* @default true
|
|
240
|
+
*/
|
|
241
|
+
downloadSchema?: boolean;
|
|
242
|
+
/**
|
|
243
|
+
* The prefix for the server route.
|
|
244
|
+
*
|
|
245
|
+
* @default ```ts
|
|
246
|
+
* "/api/graphql_middleware"
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
serverApiPrefix?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Path to the GraphQL schema file.
|
|
252
|
+
*
|
|
253
|
+
* If `downloadSchema` is `true`, the downloaded schema is written to this specified path.
|
|
254
|
+
* If `downloadSchema` is `false`, this file must be present in order to generate types.
|
|
255
|
+
*
|
|
256
|
+
* @default './schema.graphql'
|
|
257
|
+
*/
|
|
258
|
+
schemaPath?: string;
|
|
259
|
+
/**
|
|
260
|
+
* These options are passed to the graphql-codegen method when generating the
|
|
261
|
+
* TypeScript operations types.
|
|
262
|
+
*
|
|
263
|
+
* {@link https://www.the-guild.dev/graphql/codegen/plugins/typescript/typescript-operations}
|
|
264
|
+
* @default
|
|
265
|
+
* ```ts
|
|
266
|
+
* const codegenConfig = {
|
|
267
|
+
* exportFragmentSpreadSubTypes: true,
|
|
268
|
+
* preResolveTypes: true,
|
|
269
|
+
* skipTypeNameForRoot: true,
|
|
270
|
+
* skipTypename: true,
|
|
271
|
+
* useTypeImports: true,
|
|
272
|
+
* onlyOperationTypes: true,
|
|
273
|
+
* namingConvention: {
|
|
274
|
+
* enumValues: 'change-case-all#upperCaseFirst',
|
|
275
|
+
* },
|
|
276
|
+
* }
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
codegenConfig?: TypeScriptDocumentsPluginConfig;
|
|
280
|
+
/**
|
|
281
|
+
* Configuration for graphql-codegen when downloading the schema.
|
|
282
|
+
*/
|
|
283
|
+
codegenSchemaConfig?: {
|
|
284
|
+
/**
|
|
285
|
+
* Configure how the schema.graphql file should be generated.
|
|
286
|
+
*/
|
|
287
|
+
schemaAstConfig?: SchemaASTConfig;
|
|
288
|
+
/**
|
|
289
|
+
* Configure how the schema-ast introspection request should be made.
|
|
290
|
+
*
|
|
291
|
+
* Usually this is where you can provide a custom authentication header:
|
|
292
|
+
*
|
|
293
|
+
* ```typescript
|
|
294
|
+
* const codegenSchemaConfig = {
|
|
295
|
+
* urlSchemaOptions: {
|
|
296
|
+
* headers: {
|
|
297
|
+
* authentication: 'foobar',
|
|
298
|
+
* }
|
|
299
|
+
* }
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
urlSchemaOptions?: Types.UrlSchemaOptions;
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Set to true if you want to output each compiled query and mutation in the
|
|
307
|
+
* .nuxt folder.
|
|
308
|
+
*/
|
|
309
|
+
outputDocuments?: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* Enable Nuxt DevTools integration.
|
|
312
|
+
*/
|
|
313
|
+
devtools?: boolean;
|
|
314
|
+
}
|
|
315
|
+
type ModuleHooks = {};
|
|
316
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
317
|
+
|
|
318
|
+
export { type GraphqlMiddlewareServerOptions, type ModuleHooks, type ModuleOptions, _default as default };
|
package/dist/module.d.ts
CHANGED
|
@@ -9,6 +9,32 @@ type GraphqlMiddlewareGraphqlEndpointMethod = (event?: H3Event, operation?: stri
|
|
|
9
9
|
type GraphqlMiddlewareServerFetchOptionsMethod = (event?: H3Event, operation?: string, operationName?: string) => FetchOptions | Promise<FetchOptions>;
|
|
10
10
|
type GraphqlMiddlewareOnServerResponseMethod = (event: H3Event, response: FetchResponse<any>, operation?: string, operationName?: string) => any | Promise<any>;
|
|
11
11
|
type GraphqlMiddlewareOnServerErrorMethod = (event: H3Event, error: FetchError, operation?: string, operationName?: string) => any | Promise<any>;
|
|
12
|
+
type GraphqlMiddlewareDoRequestMethodContext = {
|
|
13
|
+
/**
|
|
14
|
+
* The incoming request event from H3.
|
|
15
|
+
*/
|
|
16
|
+
event: H3Event;
|
|
17
|
+
/**
|
|
18
|
+
* The type of operation.
|
|
19
|
+
*/
|
|
20
|
+
operation: 'query' | 'mutation';
|
|
21
|
+
/**
|
|
22
|
+
* The name of the operation.
|
|
23
|
+
*/
|
|
24
|
+
operationName: string;
|
|
25
|
+
/**
|
|
26
|
+
* The operation document (the raw GraphQL query/mutation as a string).
|
|
27
|
+
*/
|
|
28
|
+
operationDocument: string;
|
|
29
|
+
/**
|
|
30
|
+
* Variables for the operation.
|
|
31
|
+
*/
|
|
32
|
+
variables: Record<string, any>;
|
|
33
|
+
};
|
|
34
|
+
type GraphqlMiddlewareDoRequestMethod = (context: GraphqlMiddlewareDoRequestMethodContext) => Promise<{
|
|
35
|
+
data: any;
|
|
36
|
+
errors?: any[];
|
|
37
|
+
}>;
|
|
12
38
|
/**
|
|
13
39
|
* Configuration options during runtime.
|
|
14
40
|
*/
|
|
@@ -104,6 +130,42 @@ type GraphqlMiddlewareServerOptions = {
|
|
|
104
130
|
* ```
|
|
105
131
|
*/
|
|
106
132
|
onServerError?: GraphqlMiddlewareOnServerErrorMethod;
|
|
133
|
+
/**
|
|
134
|
+
* Provide a custom fetch method for requests to the GraphQL server.
|
|
135
|
+
*
|
|
136
|
+
* This can be used if onServerError, onServerResponse, serverFetchOptions
|
|
137
|
+
* and graphqlEndpoint are not enough to meet your requirements.
|
|
138
|
+
*
|
|
139
|
+
* The method will be called in the /api/graphql server route and should
|
|
140
|
+
* perform the GraphQL request and return the response.
|
|
141
|
+
*
|
|
142
|
+
* An example use case might be to handle expired tokens.
|
|
143
|
+
*
|
|
144
|
+
* * ```ts
|
|
145
|
+
* async function doGraphqlRequest({
|
|
146
|
+
* event,
|
|
147
|
+
* operation,
|
|
148
|
+
* operationName,
|
|
149
|
+
* operationDocument,
|
|
150
|
+
* variables,
|
|
151
|
+
* }) {
|
|
152
|
+
* const result = await $fetch.raw('https://example.com/graphql', {
|
|
153
|
+
* method: 'POST'
|
|
154
|
+
* body: {
|
|
155
|
+
* query: operationDocument,
|
|
156
|
+
* variables,
|
|
157
|
+
* operationName
|
|
158
|
+
* },
|
|
159
|
+
* headers: {
|
|
160
|
+
* 'custom-header': 'foobar'
|
|
161
|
+
* }
|
|
162
|
+
* })
|
|
163
|
+
*
|
|
164
|
+
* return result._data
|
|
165
|
+
* }
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
doGraphqlRequest?: GraphqlMiddlewareDoRequestMethod;
|
|
107
169
|
};
|
|
108
170
|
|
|
109
171
|
interface ModuleOptions {
|
|
@@ -253,4 +315,4 @@ interface ModuleOptions {
|
|
|
253
315
|
type ModuleHooks = {};
|
|
254
316
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
255
317
|
|
|
256
|
-
export { GraphqlMiddlewareServerOptions, ModuleHooks, ModuleOptions, _default as default };
|
|
318
|
+
export { type GraphqlMiddlewareServerOptions, type ModuleHooks, type ModuleOptions, _default as default };
|