nuxt-graphql-middleware 4.0.0-beta.5 → 4.0.0-beta.7

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.
Files changed (44) hide show
  1. package/dist/client/200.html +12 -2
  2. package/dist/client/404.html +12 -2
  3. package/dist/client/_nuxt/entry.1bc811cf.css +1 -0
  4. package/dist/client/_nuxt/entry.ea5ff097.js +7 -0
  5. package/dist/client/_nuxt/error-404.0c27f143.js +1 -0
  6. package/dist/client/_nuxt/error-404.a6f724cc.css +1 -0
  7. package/dist/client/_nuxt/error-500.0ea30584.js +1 -0
  8. package/dist/client/_nuxt/error-500.d92554dd.css +1 -0
  9. package/dist/client/_nuxt/index.3f9296a3.css +1 -0
  10. package/dist/client/_nuxt/index.e982558e.js +2 -0
  11. package/dist/client/_nuxt/vue.f36acd1f.b03bdbb5.js +1 -0
  12. package/dist/client/index.html +12 -2
  13. package/dist/module.d.mts +256 -0
  14. package/dist/module.d.ts +1 -1
  15. package/dist/module.json +1 -1
  16. package/dist/module.mjs +113 -12
  17. package/dist/runtime/composables/nuxtApp.d.ts +5 -0
  18. package/dist/runtime/composables/nuxtApp.mjs +15 -0
  19. package/dist/runtime/composables/server.d.ts +10 -0
  20. package/dist/runtime/composables/{index.mjs → server.mjs} +3 -17
  21. package/dist/runtime/composables/shared.d.ts +31 -0
  22. package/dist/runtime/composables/shared.mjs +5 -0
  23. package/dist/runtime/composables/useGraphqlMutation.d.ts +6 -0
  24. package/dist/runtime/composables/useGraphqlMutation.mjs +8 -0
  25. package/dist/runtime/composables/useGraphqlQuery.d.ts +6 -0
  26. package/dist/runtime/composables/useGraphqlQuery.mjs +9 -0
  27. package/dist/runtime/composables/useGraphqlState.d.ts +2 -0
  28. package/dist/runtime/composables/useGraphqlState.mjs +11 -0
  29. package/dist/runtime/plugins/provideState.d.ts +1 -1
  30. package/dist/runtime/serverHandler/debug.d.ts +1 -1
  31. package/dist/runtime/serverHandler/index.d.ts +1 -1
  32. package/dist/types.d.mts +17 -0
  33. package/dist/types.d.ts +6 -0
  34. package/package.json +34 -32
  35. package/dist/client/_nuxt/entry.0bb826e1.js +0 -5
  36. package/dist/client/_nuxt/entry.0dd29d47.css +0 -1
  37. package/dist/client/_nuxt/error-404.0cd4f3dd.css +0 -1
  38. package/dist/client/_nuxt/error-404.ffea5d7c.js +0 -1
  39. package/dist/client/_nuxt/error-500.748cb764.css +0 -1
  40. package/dist/client/_nuxt/error-500.d39ec227.js +0 -1
  41. package/dist/client/_nuxt/error-component.3d690bfd.js +0 -3
  42. package/dist/client/_nuxt/index.86b21181.js +0 -2
  43. package/dist/client/_nuxt/index.dc8fb7ec.css +0 -1
  44. package/dist/runtime/composables/index.d.ts +0 -41
@@ -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};
@@ -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"><link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/entry.0bb826e1.js"><link rel="preload" as="style" href="/__nuxt-graphql-middleware/_nuxt/entry.0dd29d47.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/error-component.3d690bfd.js"><link rel="stylesheet" href="/__nuxt-graphql-middleware/_nuxt/entry.0dd29d47.css"><script>"use strict";const w=window,de=document.documentElement,knownColorSchemes=["dark","light"],preference=window.localStorage.getItem("nuxt-color-mode")||"system";let value=preference==="system"?getColorScheme():preference;const forcedColorMode=de.getAttribute("data-color-mode-forced");forcedColorMode&&(value=forcedColorMode),addColorScheme(value),w["__NUXT_COLOR_MODE__"]={preference,value,getColorScheme,addColorScheme,removeColorScheme};function addColorScheme(e){const o=""+e+"",t="";de.classList?de.classList.add(o):de.className+=" "+o,t&&de.setAttribute("data-"+t,e)}function removeColorScheme(e){const o=""+e+"",t="";de.classList?de.classList.remove(o):de.className=de.className.replace(new RegExp(o,"g"),""),t&&de.removeAttribute("data-"+t)}function prefersColorScheme(e){return w.matchMedia("(prefers-color-scheme"+e+")")}function getColorScheme(){if(w.matchMedia&&prefersColorScheme("").media!=="not all"){for(const e of knownColorSchemes)if(prefersColorScheme(":"+e).matches)return e}return"light"}
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>window.__NUXT__={_errors:{},serverRendered:false,data:{},state:{},config:{public:{},app:{baseURL:"\u002F__nuxt-graphql-middleware",buildAssetsDir:"\u002F_nuxt\u002F",cdnURL:""}}}</script><script type="module" src="/__nuxt-graphql-middleware/_nuxt/entry.0bb826e1.js" crossorigin></script></body>
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,256 @@
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
+ /**
13
+ * Configuration options during runtime.
14
+ */
15
+ type GraphqlMiddlewareServerOptions = {
16
+ /**
17
+ * Custom callback to return the GraphQL endpoint per request.
18
+ *
19
+ * @default undefined
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * function graphqlEndpoint(event, operation, operationName) {
24
+ * const language = getLanguageFromRequest(event)
25
+ * return `https://api.example.com/${language}/graphql`
26
+ * }
27
+ * ```
28
+ */
29
+ graphqlEndpoint?: GraphqlMiddlewareGraphqlEndpointMethod;
30
+ /**
31
+ * Provide the options for the ofetch request to the GraphQL server.
32
+ *
33
+ * @default undefined
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { getHeader } from 'h3'
38
+ *
39
+ * // Pass the cookie from the client request to the GraphQL request.
40
+ * function serverFetchOptions(event, operation, operationName) {
41
+ * return {
42
+ * headers: {
43
+ * Cookie: getHeader(event, 'cookie')
44
+ * }
45
+ * }
46
+ * }
47
+ * ```
48
+ */
49
+ serverFetchOptions?: GraphqlMiddlewareServerFetchOptionsMethod;
50
+ /**
51
+ * Handle the response from the GraphQL server.
52
+ *
53
+ * You can alter the response, add additional properties to the data, get
54
+ * and set headers, etc.
55
+ *
56
+ * ```ts
57
+ * import type { H3Event } from 'h3'
58
+ * import type { FetchResponse } from 'ofetch'
59
+ *
60
+ * function onServerResponse(event: H3Event, graphqlResponse: FetchResponse) {
61
+ * // Set a static header.
62
+ * event.node.res.setHeader('x-nuxt-custom-header', 'A custom header value')
63
+ *
64
+ * // Pass the set-cookie header from the GraphQL response to the client.
65
+ * const setCookie = graphqlResponse.headers.get('set-cookie')
66
+ * if (setCookie) {
67
+ * event.node.res.setHeader('set-cookie', setCookie)
68
+ * }
69
+ *
70
+ * // Add additional properties to the response.
71
+ * graphqlResponse._data.__customProperty = ['My', 'values']
72
+ *
73
+ * // Return the GraphQL response.
74
+ * return graphqlResponse._data
75
+ * }
76
+ * ```
77
+ */
78
+ onServerResponse?: GraphqlMiddlewareOnServerResponseMethod;
79
+ /**
80
+ * Handle a fetch error from the GraphQL request.
81
+ *
82
+ * Note that errors are only thrown for responses that are not status
83
+ * 200-299. See https://github.com/unjs/ofetch#%EF%B8%8F-handling-errors for
84
+ * more information.
85
+ *
86
+ * ```ts
87
+ * import { createError } from 'h3'
88
+ * import type { H3Event } from 'h3'
89
+ * import type { FetchError } from 'ofetch'
90
+ *
91
+ * function onServerError(
92
+ * event: H3Event,
93
+ * error: FetchError,
94
+ * operation: string,
95
+ * operationName: string,
96
+ * ) {
97
+ * // Throw a h3 error.
98
+ * throw createError({
99
+ * statusCode: 500,
100
+ * statusMessage: `Couldn't execute GraphQL ${operation} "${operationName}".`,
101
+ * data: error.message
102
+ * })
103
+ * }
104
+ * ```
105
+ */
106
+ onServerError?: GraphqlMiddlewareOnServerErrorMethod;
107
+ };
108
+
109
+ interface ModuleOptions {
110
+ /**
111
+ * File glob patterns for the auto import feature.
112
+ *
113
+ * If left empty, no documents are auto imported.
114
+ *
115
+ * @default
116
+ * ```json
117
+ * ["**\/.{gql,graphql}", "!node_modules"]
118
+ * ```
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * // Load .graphql files from pages folder and from a node_modules dependency.
123
+ * const autoImportPatterns = [
124
+ * './pages/**\/*.graphql',
125
+ * 'node_modules/my_library/dist/**\/*.graphql'
126
+ * ]
127
+ * ```
128
+ */
129
+ autoImportPatterns?: string[];
130
+ /**
131
+ * Additional raw documents to include.
132
+ *
133
+ * Useful if for example you need to generate queries during build time.
134
+ *
135
+ * @default []
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * const documents = [`
140
+ * query myQuery {
141
+ * articles {
142
+ * title
143
+ * id
144
+ * }
145
+ * }`,
146
+ * ...getGeneratedDocuments()
147
+ * ]
148
+ * ```
149
+ */
150
+ documents?: string[];
151
+ /**
152
+ * Wether the useGraphqlQuery, useGraphqlMutation and useGraphqlState
153
+ * composables should be included.
154
+ *
155
+ * @default ```ts
156
+ * true
157
+ * ```
158
+ */
159
+ includeComposables?: boolean;
160
+ /**
161
+ * Enable detailled debugging messages.
162
+ *
163
+ * @default false
164
+ */
165
+ debug?: boolean;
166
+ /**
167
+ * The URL of the GraphQL server.
168
+ *
169
+ * For the runtime execution you can provide a method that determines the endpoint
170
+ * during runtime. See the app/graphqlMiddleware.serverOptions.ts documentation
171
+ * for more information.
172
+ */
173
+ graphqlEndpoint: string;
174
+ /**
175
+ * Download the GraphQL schema and store it on disk.
176
+ *
177
+ * @default true
178
+ */
179
+ downloadSchema?: boolean;
180
+ /**
181
+ * The prefix for the server route.
182
+ *
183
+ * @default ```ts
184
+ * "/api/graphql_middleware"
185
+ * ```
186
+ */
187
+ serverApiPrefix?: string;
188
+ /**
189
+ * Path to the GraphQL schema file.
190
+ *
191
+ * If `downloadSchema` is `true`, the downloaded schema is written to this specified path.
192
+ * If `downloadSchema` is `false`, this file must be present in order to generate types.
193
+ *
194
+ * @default './schema.graphql'
195
+ */
196
+ schemaPath?: string;
197
+ /**
198
+ * These options are passed to the graphql-codegen method when generating the
199
+ * TypeScript operations types.
200
+ *
201
+ * {@link https://www.the-guild.dev/graphql/codegen/plugins/typescript/typescript-operations}
202
+ * @default
203
+ * ```ts
204
+ * const codegenConfig = {
205
+ * exportFragmentSpreadSubTypes: true,
206
+ * preResolveTypes: true,
207
+ * skipTypeNameForRoot: true,
208
+ * skipTypename: true,
209
+ * useTypeImports: true,
210
+ * onlyOperationTypes: true,
211
+ * namingConvention: {
212
+ * enumValues: 'change-case-all#upperCaseFirst',
213
+ * },
214
+ * }
215
+ * ```
216
+ */
217
+ codegenConfig?: TypeScriptDocumentsPluginConfig;
218
+ /**
219
+ * Configuration for graphql-codegen when downloading the schema.
220
+ */
221
+ codegenSchemaConfig?: {
222
+ /**
223
+ * Configure how the schema.graphql file should be generated.
224
+ */
225
+ schemaAstConfig?: SchemaASTConfig;
226
+ /**
227
+ * Configure how the schema-ast introspection request should be made.
228
+ *
229
+ * Usually this is where you can provide a custom authentication header:
230
+ *
231
+ * ```typescript
232
+ * const codegenSchemaConfig = {
233
+ * urlSchemaOptions: {
234
+ * headers: {
235
+ * authentication: 'foobar',
236
+ * }
237
+ * }
238
+ * }
239
+ * ```
240
+ */
241
+ urlSchemaOptions?: Types.UrlSchemaOptions;
242
+ };
243
+ /**
244
+ * Set to true if you want to output each compiled query and mutation in the
245
+ * .nuxt folder.
246
+ */
247
+ outputDocuments?: boolean;
248
+ /**
249
+ * Enable Nuxt DevTools integration.
250
+ */
251
+ devtools?: boolean;
252
+ }
253
+ type ModuleHooks = {};
254
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
255
+
256
+ export { type GraphqlMiddlewareServerOptions, type ModuleHooks, type ModuleOptions, _default as default };
package/dist/module.d.ts CHANGED
@@ -253,4 +253,4 @@ interface ModuleOptions {
253
253
  type ModuleHooks = {};
254
254
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
255
255
 
256
- export { GraphqlMiddlewareServerOptions, ModuleHooks, ModuleOptions, _default as default };
256
+ export { type GraphqlMiddlewareServerOptions, type ModuleHooks, type ModuleOptions, _default as default };
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-graphql-middleware",
3
3
  "configKey": "graphqlMiddleware",
4
- "version": "4.0.0-beta.5",
4
+ "version": "4.0.0-beta.7",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.1.0"
7
7
  }
package/dist/module.mjs CHANGED
@@ -1,26 +1,26 @@
1
1
  import { fileURLToPath } from 'url';
2
2
  import { resolve } from 'pathe';
3
3
  import { defu } from 'defu';
4
- import { useLogger, resolveAlias, resolveFiles, defineNuxtModule, createResolver, addImportsDir, addTemplate, addServerHandler, addPlugin, updateTemplates } from '@nuxt/kit';
4
+ import { useLogger, resolveAlias, resolveFiles, defineNuxtModule, createResolver, addImports, addTemplate, addServerHandler, addPlugin, updateTemplates } from '@nuxt/kit';
5
5
  import inquirer from 'inquirer';
6
6
  import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
7
7
  import { existsSync } from 'fs';
8
8
  import { promises, existsSync as existsSync$1 } from 'node:fs';
9
+ import { oldVisit } from '@graphql-codegen/plugin-helpers';
9
10
  import fragmentImport from '@graphql-fragment-import/lib/inline-imports.js';
10
11
  import { validateGraphQlDocuments } from '@graphql-tools/utils';
11
12
  import { loadSchema } from '@graphql-tools/load';
12
13
  import Table from 'cli-table';
13
14
  import chalk from 'chalk';
14
- import { concatAST, print, Source, parse } from 'graphql';
15
+ import { concatAST, parse, print, visit, Kind, Source } from 'graphql';
15
16
  import { generate as generate$1, executeCodegen } from '@graphql-codegen/cli';
16
17
  import * as PluginTypescript from '@graphql-codegen/typescript';
17
18
  import * as PluginTypescriptOperations from '@graphql-codegen/typescript-operations';
18
19
  import * as PluginSchemaAst from '@graphql-codegen/schema-ast';
19
- import { oldVisit } from '@graphql-codegen/plugin-helpers';
20
20
  import { pascalCase } from 'change-case-all';
21
21
 
22
22
  const name = "nuxt-graphql-middleware";
23
- const version = "4.0.0-beta.5";
23
+ const version = "4.0.0-beta.7";
24
24
 
25
25
  const DEVTOOLS_UI_ROUTE = "/__nuxt-graphql-middleware";
26
26
  const DEVTOOLS_UI_LOCAL_PORT = 3300;
@@ -461,8 +461,9 @@ function parseDocument(document, srcDir) {
461
461
  return parse(source);
462
462
  }
463
463
  function validateDocuments(schema, documents, srcDir) {
464
+ const validated = [];
464
465
  for (let i = 0; i < documents.length; i++) {
465
- const document = documents[i];
466
+ const document = { ...documents[i] };
466
467
  if (document.filename) {
467
468
  document.relativePath = document.filename.replace(srcDir + "/", "");
468
469
  }
@@ -490,8 +491,59 @@ function validateDocuments(schema, documents, srcDir) {
490
491
  document.isValid = false;
491
492
  }
492
493
  document.id = [document.operation, document.name, document.filename].filter(Boolean).join("_");
494
+ validated.push(document);
495
+ if (!document.isValid) {
496
+ break;
497
+ }
498
+ }
499
+ return validated;
500
+ }
501
+ function cleanGraphqlDocument(graphqlContent, operationName) {
502
+ const document = parse(graphqlContent);
503
+ let selectedOperation = null;
504
+ const fragments = {};
505
+ const usedFragments = /* @__PURE__ */ new Set();
506
+ visit(document, {
507
+ OperationDefinition(node) {
508
+ if (node.name?.value === operationName) {
509
+ selectedOperation = node;
510
+ }
511
+ },
512
+ FragmentDefinition(node) {
513
+ fragments[node.name.value] = node;
514
+ }
515
+ });
516
+ if (!selectedOperation) {
517
+ throw new Error(`Operation named "${operationName}" not found`);
518
+ }
519
+ visit(selectedOperation, {
520
+ FragmentSpread(node) {
521
+ usedFragments.add(node.name.value);
522
+ }
523
+ });
524
+ let hasNewFragments = true;
525
+ while (hasNewFragments) {
526
+ hasNewFragments = false;
527
+ for (const fragmentName of usedFragments) {
528
+ visit(fragments[fragmentName], {
529
+ FragmentSpread(node) {
530
+ if (!usedFragments.has(node.name.value)) {
531
+ usedFragments.add(node.name.value);
532
+ hasNewFragments = true;
533
+ }
534
+ }
535
+ });
536
+ }
493
537
  }
494
- return documents;
538
+ return {
539
+ kind: Kind.DOCUMENT,
540
+ definitions: [
541
+ selectedOperation,
542
+ ...Array.from(usedFragments).map(
543
+ (fragmentName) => fragments[fragmentName]
544
+ )
545
+ ]
546
+ };
495
547
  }
496
548
  async function generate(options, schemaPath, resolver, srcDir, logEverything = false) {
497
549
  const schemaContent = await promises.readFile(schemaPath).then((v) => v.toString());
@@ -502,17 +554,55 @@ async function generate(options, schemaPath, resolver, srcDir, logEverything = f
502
554
  resolver
503
555
  );
504
556
  const validated = validateDocuments(schema, documents, srcDir);
557
+ const extracted = validated.filter(
558
+ (v) => !v.operation
559
+ );
560
+ validated.forEach((v) => {
561
+ if (v.isValid) {
562
+ try {
563
+ const node = parse(v.content);
564
+ oldVisit(node, {
565
+ enter: {
566
+ OperationDefinition: (node2) => {
567
+ if (node2.name?.value && node2.loc?.source && (node2.operation === "query" || node2.operation === "mutation")) {
568
+ const document = { ...v };
569
+ const cleaned = cleanGraphqlDocument(
570
+ node2.loc.source.body,
571
+ node2.name.value
572
+ );
573
+ const errors = validateGraphQlDocuments(schema, [cleaned]);
574
+ document.errors = document.errors || [];
575
+ document.errors.push(...errors);
576
+ document.isValid = !document.errors.length;
577
+ document.name = node2.name.value;
578
+ document.operation = node2.operation;
579
+ document.content = print(cleaned);
580
+ document.id = [
581
+ document.operation,
582
+ document.name,
583
+ document.filename
584
+ ].filter(Boolean).join("_");
585
+ extracted.push(document);
586
+ }
587
+ }
588
+ }
589
+ });
590
+ } catch (e) {
591
+ logger.error(e);
592
+ }
593
+ }
594
+ });
505
595
  const templates = await generateTemplates(
506
- validated.filter((v) => v.isValid).map((v) => v.content),
596
+ extracted.filter((v) => v.isValid).map((v) => v.content),
507
597
  schemaPath,
508
598
  options
509
599
  );
510
- const hasErrors = validated.some((v) => !v.isValid);
600
+ const hasErrors = extracted.some((v) => !v.isValid);
511
601
  if (hasErrors || logEverything) {
512
602
  const table = new Table({
513
603
  head: ["Operation", "Name", "File", "Errors"].map((v) => chalk.white(v))
514
604
  });
515
- validated.forEach((document) => {
605
+ extracted.forEach((document) => {
516
606
  if (logEverything || !document.isValid) {
517
607
  table.push(
518
608
  [
@@ -539,7 +629,7 @@ async function generate(options, schemaPath, resolver, srcDir, logEverything = f
539
629
  return a.filename.localeCompare(b.filename);
540
630
  }),
541
631
  hasErrors,
542
- documents: validated.sort((a, b) => {
632
+ documents: extracted.sort((a, b) => {
543
633
  const nameA = a.name || "";
544
634
  const nameB = b.name || "";
545
635
  return nameA.localeCompare(nameB);
@@ -687,9 +777,20 @@ const module = defineNuxtModule({
687
777
  graphqlEndpoint: options.graphqlEndpoint || ""
688
778
  };
689
779
  if (options.includeComposables) {
690
- addImportsDir(moduleResolver("runtime/composables"));
780
+ addImports({
781
+ from: moduleResolver("./runtime/composables/useGraphqlQuery"),
782
+ name: "useGraphqlQuery"
783
+ });
784
+ addImports({
785
+ from: moduleResolver("./runtime/composables/useGraphqlMutation"),
786
+ name: "useGraphqlMutation"
787
+ });
788
+ addImports({
789
+ from: moduleResolver("./runtime/composables/useGraphqlState"),
790
+ name: "useGraphqlState"
791
+ });
691
792
  nuxt.options.alias["#graphql-composable"] = moduleResolver(
692
- "runtime/composables"
793
+ "runtime/composables/server"
693
794
  );
694
795
  }
695
796
  Object.values(GraphqlMiddlewareTemplate).forEach((filename) => {
@@ -0,0 +1,5 @@
1
+ import type { FetchOptions } from 'ofetch';
2
+ export declare function performRequest(operation: string, operationName: string, method: 'get' | 'post', options: FetchOptions): Promise<{
3
+ data: any;
4
+ errors: any[];
5
+ }>;
@@ -0,0 +1,15 @@
1
+ import { useGraphqlState } from "./useGraphqlState.mjs";
2
+ import { getEndpoint } from "./shared.mjs";
3
+ export function performRequest(operation, operationName, method, options) {
4
+ const state = useGraphqlState();
5
+ return $fetch(getEndpoint(operation, operationName), {
6
+ ...state && state.fetchOptions ? state.fetchOptions : {},
7
+ ...options,
8
+ method
9
+ }).then((v) => {
10
+ return {
11
+ data: v.data,
12
+ errors: v.errors || []
13
+ };
14
+ });
15
+ }
@@ -0,0 +1,10 @@
1
+ import { GraphqlMiddlewareQueryName, GetQueryArgs, QueryObjectArgs, GetQueryResult, GraphqlMiddlewareMutationName, GetMutationArgs, MutationObjectArgs, GetMutationResult } from './shared';
2
+ import type { GraphqlMiddlewareQuery, GraphqlMiddlewareMutation } from '#build/nuxt-graphql-middleware';
3
+ /**
4
+ * Performs a GraphQL query.
5
+ */
6
+ export declare function useGraphqlQuery<T extends GraphqlMiddlewareQueryName>(...args: GetQueryArgs<T, GraphqlMiddlewareQuery> | [QueryObjectArgs<T, GraphqlMiddlewareQuery>]): Promise<GetQueryResult<T, GraphqlMiddlewareQuery>>;
7
+ /**
8
+ * Performs a GraphQL mutation.
9
+ */
10
+ export declare function useGraphqlMutation<T extends GraphqlMiddlewareMutationName>(...args: GetMutationArgs<T, GraphqlMiddlewareMutation> | [MutationObjectArgs<T, GraphqlMiddlewareMutation>]): Promise<GetMutationResult<T, GraphqlMiddlewareMutation>>;
@@ -1,23 +1,9 @@
1
+ import {
2
+ getEndpoint
3
+ } from "./shared.mjs";
1
4
  import { buildRequestParams } from "./../helpers/index.mjs";
2
- import { useRuntimeConfig } from "#imports";
3
- function getEndpoint(operation, operationName) {
4
- const config = useRuntimeConfig();
5
- return `${config?.public?.["nuxt-graphql-middleware"]?.serverApiPrefix}/${operation}/${operationName}`;
6
- }
7
- export const useGraphqlState = function(providedApp) {
8
- try {
9
- const app = providedApp || useNuxtApp();
10
- if (app.$graphqlState) {
11
- return app.$graphqlState;
12
- }
13
- } catch (_e) {
14
- }
15
- return null;
16
- };
17
5
  function performRequest(operation, operationName, method, options) {
18
- const state = useGraphqlState();
19
6
  return $fetch(getEndpoint(operation, operationName), {
20
- ...state && state.fetchOptions ? state.fetchOptions : {},
21
7
  ...options,
22
8
  method
23
9
  }).then((v) => {