nx-mesh
Version:
GraphQL Mesh support for Nx
7 lines (6 loc) • 39.5 kB
JavaScript
var Dt=Object.create;var X=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var Gt=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty;var M=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Yt=(t,e)=>{for(var i in e)X(t,i,{get:e[i],enumerable:!0})},Re=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $t(e))!zt.call(t,n)&&n!==i&&X(t,n,{get:()=>e[n],enumerable:!(r=Lt(e,n))||r.enumerable});return t};var Kt=(t,e,i)=>(i=t!=null?Dt(Gt(t)):{},Re(e||!t||!t.__esModule?X(i,"default",{value:t,enumerable:!0}):i,t)),Ut=t=>Re(X({},"__esModule",{value:!0}),t);var Ke=M((zr,Ye)=>{var j=require("constants"),Zt=process.cwd,ee=null,er=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return ee||(ee=Zt.call(process)),ee};try{process.cwd()}catch{}typeof process.chdir=="function"&&(ge=process.chdir,process.chdir=function(t){ee=null,ge.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,ge));var ge;Ye.exports=tr;function tr(t){j.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(t),t.lutimes||i(t),t.chown=s(t.chown),t.fchown=s(t.fchown),t.lchown=s(t.lchown),t.chmod=r(t.chmod),t.fchmod=r(t.fchmod),t.lchmod=r(t.lchmod),t.chownSync=o(t.chownSync),t.fchownSync=o(t.fchownSync),t.lchownSync=o(t.lchownSync),t.chmodSync=n(t.chmodSync),t.fchmodSync=n(t.fchmodSync),t.lchmodSync=n(t.lchmodSync),t.stat=a(t.stat),t.fstat=a(t.fstat),t.lstat=a(t.lstat),t.statSync=h(t.statSync),t.fstatSync=h(t.fstatSync),t.lstatSync=h(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(c,f,p){p&&process.nextTick(p)},t.lchmodSync=function(){}),t.chown&&!t.lchown&&(t.lchown=function(c,f,p,d){d&&process.nextTick(d)},t.lchownSync=function(){}),er==="win32"&&(t.rename=typeof t.rename!="function"?t.rename:function(c){function f(p,d,m){var E=Date.now(),u=0;c(p,d,function g(y){if(y&&(y.code==="EACCES"||y.code==="EPERM")&&Date.now()-E<6e4){setTimeout(function(){t.stat(d,function(W,K){W&&W.code==="ENOENT"?c(p,d,g):m(y)})},u),u<100&&(u+=10);return}m&&m(y)})}return Object.setPrototypeOf&&Object.setPrototypeOf(f,c),f}(t.rename)),t.read=typeof t.read!="function"?t.read:function(c){function f(p,d,m,E,u,g){var y;if(g&&typeof g=="function"){var W=0;y=function(K,qe,Me){if(K&&K.code==="EAGAIN"&&W<10)return W++,c.call(t,p,d,m,E,u,y);g.apply(this,arguments)}}return c.call(t,p,d,m,E,u,y)}return Object.setPrototypeOf&&Object.setPrototypeOf(f,c),f}(t.read),t.readSync=typeof t.readSync!="function"?t.readSync:function(c){return function(f,p,d,m,E){for(var u=0;;)try{return c.call(t,f,p,d,m,E)}catch(g){if(g.code==="EAGAIN"&&u<10){u++;continue}throw g}}}(t.readSync);function e(c){c.lchmod=function(f,p,d){c.open(f,j.O_WRONLY|j.O_SYMLINK,p,function(m,E){if(m){d&&d(m);return}c.fchmod(E,p,function(u){c.close(E,function(g){d&&d(u||g)})})})},c.lchmodSync=function(f,p){var d=c.openSync(f,j.O_WRONLY|j.O_SYMLINK,p),m=!0,E;try{E=c.fchmodSync(d,p),m=!1}finally{if(m)try{c.closeSync(d)}catch{}else c.closeSync(d)}return E}}function i(c){j.hasOwnProperty("O_SYMLINK")&&c.futimes?(c.lutimes=function(f,p,d,m){c.open(f,j.O_SYMLINK,function(E,u){if(E){m&&m(E);return}c.futimes(u,p,d,function(g){c.close(u,function(y){m&&m(g||y)})})})},c.lutimesSync=function(f,p,d){var m=c.openSync(f,j.O_SYMLINK),E,u=!0;try{E=c.futimesSync(m,p,d),u=!1}finally{if(u)try{c.closeSync(m)}catch{}else c.closeSync(m)}return E}):c.futimes&&(c.lutimes=function(f,p,d,m){m&&process.nextTick(m)},c.lutimesSync=function(){})}function r(c){return c&&function(f,p,d){return c.call(t,f,p,function(m){l(m)&&(m=null),d&&d.apply(this,arguments)})}}function n(c){return c&&function(f,p){try{return c.call(t,f,p)}catch(d){if(!l(d))throw d}}}function s(c){return c&&function(f,p,d,m){return c.call(t,f,p,d,function(E){l(E)&&(E=null),m&&m.apply(this,arguments)})}}function o(c){return c&&function(f,p,d){try{return c.call(t,f,p,d)}catch(m){if(!l(m))throw m}}}function a(c){return c&&function(f,p,d){typeof p=="function"&&(d=p,p=null);function m(E,u){u&&(u.uid<0&&(u.uid+=4294967296),u.gid<0&&(u.gid+=4294967296)),d&&d.apply(this,arguments)}return p?c.call(t,f,p,m):c.call(t,f,m)}}function h(c){return c&&function(f,p){var d=p?c.call(t,f,p):c.call(t,f);return d&&(d.uid<0&&(d.uid+=4294967296),d.gid<0&&(d.gid+=4294967296)),d}}function l(c){if(!c||c.code==="ENOSYS")return!0;var f=!process.getuid||process.getuid()!==0;return!!(f&&(c.code==="EINVAL"||c.code==="EPERM"))}}});var Ve=M((Yr,Be)=>{var Ue=require("stream").Stream;Be.exports=rr;function rr(t){return{ReadStream:e,WriteStream:i};function e(r,n){if(!(this instanceof e))return new e(r,n);Ue.call(this);var s=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,n=n||{};for(var o=Object.keys(n),a=0,h=o.length;a<h;a++){var l=o[a];this[l]=n[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){s._read()});return}t.open(this.path,this.flags,this.mode,function(c,f){if(c){s.emit("error",c),s.readable=!1;return}s.fd=f,s.emit("open",f),s._read()})}function i(r,n){if(!(this instanceof i))return new i(r,n);Ue.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,n=n||{};for(var s=Object.keys(n),o=0,a=s.length;o<a;o++){var h=s[o];this[h]=n[h]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=t.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Je=M((Kr,He)=>{"use strict";He.exports=sr;var ir=Object.getPrototypeOf||function(t){return t.__proto__};function sr(t){if(t===null||typeof t!="object")return t;if(t instanceof Object)var e={__proto__:ir(t)};else var e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}});var et=M((Ur,ye)=>{var C=require("fs"),nr=Ke(),or=Ve(),ar=Je(),te=require("util"),_,ie;typeof Symbol=="function"&&typeof Symbol.for=="function"?(_=Symbol.for("graceful-fs.queue"),ie=Symbol.for("graceful-fs.previous")):(_="___graceful-fs.queue",ie="___graceful-fs.previous");function cr(){}function Ze(t,e){Object.defineProperty(t,_,{get:function(){return e}})}var I=cr;te.debuglog?I=te.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(I=function(){var t=te.format.apply(te,arguments);t="GFS4: "+t.split(/\n/).join(`
GFS4: `),console.error(t)});C[_]||(Qe=global[_]||[],Ze(C,Qe),C.close=function(t){function e(i,r){return t.call(C,i,function(n){n||Xe(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(e,ie,{value:t}),e}(C.close),C.closeSync=function(t){function e(i){t.apply(C,arguments),Xe()}return Object.defineProperty(e,ie,{value:t}),e}(C.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){I(C[_]),require("assert").equal(C[_].length,0)}));var Qe;global[_]||Ze(global,C[_]);ye.exports=me(ar(C));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!C.__patched&&(ye.exports=me(C),C.__patched=!0);function me(t){nr(t),t.gracefulify=me,t.createReadStream=qe,t.createWriteStream=Me;var e=t.readFile;t.readFile=i;function i(w,S,v){return typeof S=="function"&&(v=S,S=null),k(w,S,v);function k(P,b,O,A){return e(P,b,function(T){T&&(T.code==="EMFILE"||T.code==="ENFILE")?$([k,[P,b,O],T,A||Date.now(),Date.now()]):typeof O=="function"&&O.apply(this,arguments)})}}var r=t.writeFile;t.writeFile=n;function n(w,S,v,k){return typeof v=="function"&&(k=v,v=null),P(w,S,v,k);function P(b,O,A,T,F){return r(b,O,A,function(x){x&&(x.code==="EMFILE"||x.code==="ENFILE")?$([P,[b,O,A,T],x,F||Date.now(),Date.now()]):typeof T=="function"&&T.apply(this,arguments)})}}var s=t.appendFile;s&&(t.appendFile=o);function o(w,S,v,k){return typeof v=="function"&&(k=v,v=null),P(w,S,v,k);function P(b,O,A,T,F){return s(b,O,A,function(x){x&&(x.code==="EMFILE"||x.code==="ENFILE")?$([P,[b,O,A,T],x,F||Date.now(),Date.now()]):typeof T=="function"&&T.apply(this,arguments)})}}var a=t.copyFile;a&&(t.copyFile=h);function h(w,S,v,k){return typeof v=="function"&&(k=v,v=0),P(w,S,v,k);function P(b,O,A,T,F){return a(b,O,A,function(x){x&&(x.code==="EMFILE"||x.code==="ENFILE")?$([P,[b,O,A,T],x,F||Date.now(),Date.now()]):typeof T=="function"&&T.apply(this,arguments)})}}var l=t.readdir;t.readdir=f;var c=/^v[0-5]\./;function f(w,S,v){typeof S=="function"&&(v=S,S=null);var k=c.test(process.version)?function(O,A,T,F){return l(O,P(O,A,T,F))}:function(O,A,T,F){return l(O,A,P(O,A,T,F))};return k(w,S,v);function P(b,O,A,T){return function(F,x){F&&(F.code==="EMFILE"||F.code==="ENFILE")?$([k,[b,O,A],F,T||Date.now(),Date.now()]):(x&&x.sort&&x.sort(),typeof A=="function"&&A.call(this,F,x))}}}if(process.version.substr(0,4)==="v0.8"){var p=or(t);g=p.ReadStream,W=p.WriteStream}var d=t.ReadStream;d&&(g.prototype=Object.create(d.prototype),g.prototype.open=y);var m=t.WriteStream;m&&(W.prototype=Object.create(m.prototype),W.prototype.open=K),Object.defineProperty(t,"ReadStream",{get:function(){return g},set:function(w){g=w},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return W},set:function(w){W=w},enumerable:!0,configurable:!0});var E=g;Object.defineProperty(t,"FileReadStream",{get:function(){return E},set:function(w){E=w},enumerable:!0,configurable:!0});var u=W;Object.defineProperty(t,"FileWriteStream",{get:function(){return u},set:function(w){u=w},enumerable:!0,configurable:!0});function g(w,S){return this instanceof g?(d.apply(this,arguments),this):g.apply(Object.create(g.prototype),arguments)}function y(){var w=this;pe(w.path,w.flags,w.mode,function(S,v){S?(w.autoClose&&w.destroy(),w.emit("error",S)):(w.fd=v,w.emit("open",v),w.read())})}function W(w,S){return this instanceof W?(m.apply(this,arguments),this):W.apply(Object.create(W.prototype),arguments)}function K(){var w=this;pe(w.path,w.flags,w.mode,function(S,v){S?(w.destroy(),w.emit("error",S)):(w.fd=v,w.emit("open",v))})}function qe(w,S){return new t.ReadStream(w,S)}function Me(w,S){return new t.WriteStream(w,S)}var It=t.open;t.open=pe;function pe(w,S,v,k){return typeof v=="function"&&(k=v,v=null),P(w,S,v,k);function P(b,O,A,T,F){return It(b,O,A,function(x,Pr){x&&(x.code==="EMFILE"||x.code==="ENFILE")?$([P,[b,O,A,T],x,F||Date.now(),Date.now()]):typeof T=="function"&&T.apply(this,arguments)})}}return t}function $(t){I("ENQUEUE",t[0].name,t[1]),C[_].push(t),we()}var re;function Xe(){for(var t=Date.now(),e=0;e<C[_].length;++e)C[_][e].length>2&&(C[_][e][3]=t,C[_][e][4]=t);we()}function we(){if(clearTimeout(re),re=void 0,C[_].length!==0){var t=C[_].shift(),e=t[0],i=t[1],r=t[2],n=t[3],s=t[4];if(n===void 0)I("RETRY",e.name,i),e.apply(null,i);else if(Date.now()-n>=6e4){I("TIMEOUT",e.name,i);var o=i.pop();typeof o=="function"&&o.call(null,r)}else{var a=Date.now()-s,h=Math.max(s-n,1),l=Math.min(h*1.2,100);a>=l?(I("RETRY",e.name,i),e.apply(null,i.concat([n]))):C[_].push(t)}re===void 0&&(re=setTimeout(we,0))}}});var rt=M((Br,tt)=>{"use strict";var hr=require("path");tt.exports=(t,e)=>{let i=new Map;for(let[s,o]of t)i.set(s,{filePath:s,parent:void 0,children:void 0,entries:1,active:!0,value:o});let r=i.size;for(let s of i.values()){let o=hr.dirname(s.filePath);if(o!==s.filePath){let a=i.get(o);if(a===void 0)a={filePath:o,parent:void 0,children:[s],entries:s.entries,active:!1,value:void 0},i.set(o,a),s.parent=a;else{s.parent=a,a.children===void 0?a.children=[s]:a.children.push(s);do a.entries+=s.entries,a=a.parent;while(a)}}}for(;r>e;){let s=r-e,o,a=1/0;for(let f of i.values()){if(f.entries<=1||!f.children||!f.parent||f.children.length===0||f.children.length===1&&!f.value)continue;let p=f.entries-1>=s?f.entries-1-s:s-f.entries+1+e*.3;p<a&&(o=f,a=p)}if(!o)break;let h=o.entries-1;o.active=!0,o.entries=1,r-=h;let l=o.parent;for(;l;)l.entries-=h,l=l.parent;let c=new Set(o.children);for(let f of c)if(f.active=!1,f.entries=0,f.children)for(let p of f.children)c.add(p)}let n=new Map;for(let s of i.values()){if(!s.active)continue;let o=new Map,a=new Set([s]);for(let h of a)if(!(h.active&&h!==s)){if(h.value)if(Array.isArray(h.value))for(let l of h.value)o.set(l,h.filePath);else o.set(h.value,h.filePath);if(h.children)for(let l of h.children)a.add(l)}n.set(s.filePath,o)}return n}});var We=M(oe=>{"use strict";var st=require("fs"),ne=require("path"),{EventEmitter:fr}=require("events"),lr=rt(),nt=require("os").platform()==="darwin",ur=require("os").platform()==="win32",dr=nt||ur,it=+process.env.WATCHPACK_WATCHER_LIMIT||(nt?2e3:1e4),se=!!process.env.WATCHPACK_RECURSIVE_WATCHER_LOGGING,Ee=!1,G=0,U=new Map,B=new Map,V=new Map,D=new Map,Se=class{constructor(e){this.filePath=e,this.watchers=new Set,this.watcher=void 0;try{let i=st.watch(e);this.watcher=i,i.on("change",(r,n)=>{for(let s of this.watchers)s.emit("change",r,n)}),i.on("error",r=>{for(let n of this.watchers)n.emit("error",r)})}catch(i){process.nextTick(()=>{for(let r of this.watchers)r.emit("error",i)})}G++}add(e){D.set(e,this),this.watchers.add(e)}remove(e){this.watchers.delete(e),this.watchers.size===0&&(V.delete(this.filePath),G--,this.watcher&&this.watcher.close())}getWatchers(){return this.watchers}},Te=class{constructor(e){this.rootPath=e,this.mapWatcherToPath=new Map,this.mapPathToWatchers=new Map,this.watcher=void 0;try{let i=st.watch(e,{recursive:!0});this.watcher=i,i.on("change",(r,n)=>{if(n){let s=ne.dirname(n),o=this.mapPathToWatchers.get(s);if(se&&process.stderr.write(`[watchpack] dispatch ${r} event in recursive watcher (${this.rootPath}) for '${n}' to ${o?o.size:0} watchers
`),o===void 0)return;for(let a of o)a.emit("change",r,ne.basename(n))}else{se&&process.stderr.write(`[watchpack] dispatch ${r} event in recursive watcher (${this.rootPath}) to all watchers
`);for(let s of this.mapWatcherToPath.keys())s.emit("change",r)}}),i.on("error",r=>{for(let n of this.mapWatcherToPath.keys())n.emit("error",r)})}catch(i){process.nextTick(()=>{for(let r of this.mapWatcherToPath.keys())r.emit("error",i)})}G++,se&&process.stderr.write(`[watchpack] created recursive watcher at ${e}
`)}add(e,i){D.set(i,this);let r=e.slice(this.rootPath.length+1)||".";this.mapWatcherToPath.set(i,r);let n=this.mapPathToWatchers.get(r);if(n===void 0){let s=new Set;s.add(i),this.mapPathToWatchers.set(r,s)}else n.add(i)}remove(e){let i=this.mapWatcherToPath.get(e);if(!i)return;this.mapWatcherToPath.delete(e);let r=this.mapPathToWatchers.get(i);r.delete(e),r.size===0&&this.mapPathToWatchers.delete(i),this.mapWatcherToPath.size===0&&(B.delete(this.rootPath),G--,this.watcher&&this.watcher.close(),se&&process.stderr.write(`[watchpack] closed recursive watcher at ${this.rootPath}
`))}getWatchers(){return this.mapWatcherToPath}},xe=class extends fr{close(){if(U.has(this)){U.delete(this);return}D.get(this).remove(this),D.delete(this)}},ve=t=>{let e=V.get(t);if(e!==void 0)return e;let i=new Se(t);return V.set(t,i),i},pr=t=>{let e=B.get(t);if(e!==void 0)return e;let i=new Te(t);return B.set(t,i),i},ot=()=>{let t=new Map,e=(r,n)=>{let s=t.get(n);s===void 0?t.set(n,r):Array.isArray(s)?s.push(r):t.set(n,[s,r])};for(let[r,n]of U)e(r,n);if(U.clear(),!dr||it-G>=t.size){for(let[r,n]of t){let s=ve(r);if(Array.isArray(n))for(let o of n)s.add(o);else s.add(n)}return}for(let r of B.values())for(let[n,s]of r.getWatchers())e(n,ne.join(r.rootPath,s));for(let r of V.values())for(let n of r.getWatchers())e(n,r.filePath);let i=lr(t,it*.9);for(let[r,n]of i)if(n.size===1)for(let[s,o]of n){let a=ve(o),h=D.get(s);h!==a&&(a.add(s),h!==void 0&&h.remove(s))}else{let s=new Set(n.values());if(s.size>1){let o=pr(r);for(let[a,h]of n){let l=D.get(a);l!==o&&(o.add(h,a),l!==void 0&&l.remove(a))}}else for(let o of s){let a=ve(o);for(let h of n.keys()){let l=D.get(h);l!==a&&(a.add(h),l!==void 0&&l.remove(h))}}}};oe.watch=t=>{let e=new xe,i=V.get(t);if(i!==void 0)return i.add(e),e;let r=t;for(;;){let n=B.get(r);if(n!==void 0)return n.add(t,e),e;let s=ne.dirname(r);if(s===r)break;r=s}return U.set(e,t),Ee||ot(),e};oe.batch=t=>{Ee=!0;try{t()}finally{Ee=!1,ot()}};oe.getNumberOfWatchers=()=>G});var lt=M((Hr,Ae)=>{"use strict";var ft=require("events").EventEmitter,ae=et(),H=require("path"),gr=We(),Y=Object.freeze({}),q=2e3,at=require("os").platform()==="darwin",J=process.env.WATCHPACK_POLLING,ct=`${+J}`===J?+J:!!J&&J!=="false";function z(t){return t.toLowerCase()}function mr(t,e){return function(){if(--t===0)return e()}}var Oe=class extends ft{constructor(e,i,r){super(),this.directoryWatcher=e,this.path=i,this.startTime=r&&+r}checkStartTime(e,i){let r=this.startTime;return typeof r!="number"?!i:r<=e}close(){this.emit("closed")}},Ce=class extends ft{constructor(e,i,r){super(),ct&&(r.poll=ct),this.watcherManager=e,this.options=r,this.path=i,this.files=new Map,this.filesWithoutCase=new Map,this.directories=new Map,this.lastWatchEvent=0,this.initialScan=!0,this.ignored=r.ignored||(()=>!1),this.nestedWatching=!1,this.polledWatching=typeof r.poll=="number"?r.poll:r.poll?5007:!1,this.timeout=void 0,this.initialScanRemoved=new Set,this.initialScanFinished=void 0,this.watchers=new Map,this.parentWatcher=null,this.refs=0,this._activeEvents=new Map,this.closed=!1,this.scanning=!1,this.scanAgain=!1,this.scanAgainInitial=!1,this.createWatcher(),this.doScan(!0)}createWatcher(){try{this.polledWatching?this.watcher={close:()=>{this.timeout&&(clearTimeout(this.timeout),this.timeout=void 0)}}:(at&&this.watchInParentDirectory(),this.watcher=gr.watch(this.path),this.watcher.on("change",this.onWatchEvent.bind(this)),this.watcher.on("error",this.onWatcherError.bind(this)))}catch(e){this.onWatcherError(e)}}forEachWatcher(e,i){let r=this.watchers.get(z(e));if(r!==void 0)for(let n of r)i(n)}setMissing(e,i,r){this.initialScan&&this.initialScanRemoved.add(e);let n=this.directories.get(e);if(n&&(this.nestedWatching&&n.close(),this.directories.delete(e),this.forEachWatcher(e,o=>o.emit("remove",r)),i||this.forEachWatcher(this.path,o=>o.emit("change",e,null,r,i))),this.files.get(e)){this.files.delete(e);let o=z(e),a=this.filesWithoutCase.get(o)-1;a<=0?(this.filesWithoutCase.delete(o),this.forEachWatcher(e,h=>h.emit("remove",r))):this.filesWithoutCase.set(o,a),i||this.forEachWatcher(this.path,h=>h.emit("change",e,null,r,i))}}setFileTime(e,i,r,n,s){let o=Date.now();if(this.ignored(e))return;let a=this.files.get(e),h,l;if(r)h=Math.min(o,i)+q,l=q;else if(h=o,l=0,a&&a.timestamp===i&&i+q<o)return;if(!(n&&a&&a.timestamp===i)){if(this.files.set(e,{safeTime:h,accuracy:l,timestamp:i}),a)r||this.forEachWatcher(e,c=>c.emit("change",i,s));else{let c=z(e),f=this.filesWithoutCase.get(c);this.filesWithoutCase.set(c,(f||0)+1),f!==void 0&&this.doScan(!1),this.forEachWatcher(e,p=>{(!r||p.checkStartTime(h,r))&&p.emit("change",i,s)})}this.forEachWatcher(this.path,c=>{(!r||c.checkStartTime(h,r))&&c.emit("change",e,h,s,r)})}}setDirectory(e,i,r,n){if(!this.ignored(e)){if(e===this.path)r||this.forEachWatcher(this.path,s=>s.emit("change",e,i,n,r));else if(!this.directories.get(e)){let o=Date.now();this.nestedWatching?this.createNestedWatcher(e):this.directories.set(e,!0);let a;r?a=Math.min(o,i)+q:a=o,this.forEachWatcher(e,h=>{(!r||h.checkStartTime(a,!1))&&h.emit("change",i,n)}),this.forEachWatcher(this.path,h=>{(!r||h.checkStartTime(a,r))&&h.emit("change",e,a,n,r)})}}}createNestedWatcher(e){let i=this.watcherManager.watchDirectory(e,1);i.on("change",(r,n,s,o)=>{this.forEachWatcher(this.path,a=>{(!o||a.checkStartTime(n,o))&&a.emit("change",r,n,s,o)})}),this.directories.set(e,i)}setNestedWatching(e){if(this.nestedWatching!==!!e)if(this.nestedWatching=!!e,this.nestedWatching)for(let i of this.directories.keys())this.createNestedWatcher(i);else for(let[i,r]of this.directories)r.close(),this.directories.set(i,!0)}watch(e,i){let r=z(e),n=this.watchers.get(r);n===void 0&&(n=new Set,this.watchers.set(r,n)),this.refs++;let s=new Oe(this,e,i);s.on("closed",()=>{if(--this.refs<=0){this.close();return}n.delete(s),n.size===0&&(this.watchers.delete(r),this.path===e&&this.setNestedWatching(!1))}),n.add(s);let o;if(e===this.path){this.setNestedWatching(!0),o=this.lastWatchEvent;for(let a of this.files.values())ce(a),o=Math.max(o,a.safeTime)}else{let a=this.files.get(e);a?(ce(a),o=a.safeTime):o=0}return o?o>=i&&process.nextTick(()=>{this.closed||(e===this.path?s.emit("change",e,o,"watch (outdated on attach)",!0):s.emit("change",o,"watch (outdated on attach)",!0))}):this.initialScan?this.initialScanRemoved.has(e)&&process.nextTick(()=>{this.closed||s.emit("remove")}):!this.directories.has(e)&&s.checkStartTime(this.initialScanFinished,!1)&&process.nextTick(()=>{this.closed||s.emit("initial-missing","watch (missing on attach)")}),s}onWatchEvent(e,i){if(this.closed)return;if(!i){this.doScan(!1);return}let r=H.join(this.path,i);if(!this.ignored(r))if(this._activeEvents.get(i)===void 0){this._activeEvents.set(i,!1);let n=()=>{this.closed||(this._activeEvents.set(i,!1),ae.lstat(r,(s,o)=>{if(!this.closed){if(this._activeEvents.get(i)===!0){process.nextTick(n);return}this._activeEvents.delete(i),s&&(s.code!=="ENOENT"&&s.code!=="EPERM"&&s.code!=="EBUSY"?this.onStatsError(s):i===H.basename(this.path)&&(ae.existsSync(this.path)||this.onDirectoryRemoved("stat failed"))),this.lastWatchEvent=Date.now(),o?o.isDirectory()?this.setDirectory(r,+o.birthtime||1,!1,e):(o.isFile()||o.isSymbolicLink())&&(o.mtime&&ht(o.mtime),this.setFileTime(r,+o.mtime||+o.ctime||1,!1,!1,e)):this.setMissing(r,!1,e)}}))};process.nextTick(n)}else this._activeEvents.set(i,!0)}onWatcherError(e){this.closed||e&&(e.code!=="EPERM"&&e.code!=="ENOENT"&&console.error("Watchpack Error (watcher): "+e),this.onDirectoryRemoved("watch error"))}onStatsError(e){e&&console.error("Watchpack Error (stats): "+e)}onScanError(e){e&&console.error("Watchpack Error (initial scan): "+e),this.onScanFinished()}onScanFinished(){this.polledWatching&&(this.timeout=setTimeout(()=>{this.closed||this.doScan(!1)},this.polledWatching))}onDirectoryRemoved(e){this.watcher&&(this.watcher.close(),this.watcher=null),this.watchInParentDirectory();let i=`directory-removed (${e})`;for(let r of this.directories.keys())this.setMissing(r,null,i);for(let r of this.files.keys())this.setMissing(r,null,i)}watchInParentDirectory(){if(!this.parentWatcher){let e=H.dirname(this.path);if(H.dirname(e)===e)return;this.parentWatcher=this.watcherManager.watchFile(this.path,1),this.parentWatcher.on("change",(i,r)=>{this.closed||((!at||this.polledWatching)&&this.parentWatcher&&(this.parentWatcher.close(),this.parentWatcher=null),this.watcher||(this.createWatcher(),this.doScan(!1),this.forEachWatcher(this.path,n=>n.emit("change",this.path,i,r,!1))))}),this.parentWatcher.on("remove",()=>{this.onDirectoryRemoved("parent directory removed")})}}doScan(e){if(this.scanning){this.scanAgain?e||(this.scanAgainInitial=!1):(this.scanAgain=!0,this.scanAgainInitial=e);return}this.scanning=!0,this.timeout&&(clearTimeout(this.timeout),this.timeout=void 0),process.nextTick(()=>{this.closed||ae.readdir(this.path,(i,r)=>{if(this.closed)return;if(i){if(i.code==="ENOENT"||i.code==="EPERM"?this.onDirectoryRemoved("scan readdir failed"):this.onScanError(i),this.initialScan=!1,this.initialScanFinished=Date.now(),e)for(let o of this.watchers.values())for(let a of o)a.checkStartTime(this.initialScanFinished,!1)&&a.emit("initial-missing","scan (parent directory missing in initial scan)");this.scanAgain?(this.scanAgain=!1,this.doScan(this.scanAgainInitial)):this.scanning=!1;return}let n=new Set(r.map(o=>H.join(this.path,o.normalize("NFC"))));for(let o of this.files.keys())n.has(o)||this.setMissing(o,e,"scan (missing)");for(let o of this.directories.keys())n.has(o)||this.setMissing(o,e,"scan (missing)");if(this.scanAgain){this.scanAgain=!1,this.doScan(e);return}let s=mr(n.size+1,()=>{if(!this.closed){if(this.initialScan=!1,this.initialScanRemoved=null,this.initialScanFinished=Date.now(),e){let o=new Map(this.watchers);o.delete(z(this.path));for(let a of n)o.delete(z(a));for(let a of o.values())for(let h of a)h.checkStartTime(this.initialScanFinished,!1)&&h.emit("initial-missing","scan (missing in initial scan)")}this.scanAgain?(this.scanAgain=!1,this.doScan(this.scanAgainInitial)):(this.scanning=!1,this.onScanFinished())}});for(let o of n)ae.lstat(o,(a,h)=>{if(!this.closed){if(a){a.code==="ENOENT"||a.code==="EPERM"||a.code==="EACCES"||a.code==="EBUSY"?this.setMissing(o,e,"scan ("+a.code+")"):this.onScanError(a),s();return}h.isFile()||h.isSymbolicLink()?(h.mtime&&ht(h.mtime),this.setFileTime(o,+h.mtime||+h.ctime||1,e,!0,"scan (file)")):h.isDirectory()&&(!e||!this.directories.has(o))&&this.setDirectory(o,+h.birthtime||1,e,"scan (dir)"),s()}});s()})})}getTimes(){let e=Object.create(null),i=this.lastWatchEvent;for(let[r,n]of this.files)ce(n),i=Math.max(i,n.safeTime),e[r]=Math.max(n.safeTime,n.timestamp);if(this.nestedWatching){for(let r of this.directories.values()){let n=r.directoryWatcher.getTimes();for(let s of Object.keys(n)){let o=n[s];i=Math.max(i,o),e[s]=o}}e[this.path]=i}if(!this.initialScan)for(let r of this.watchers.values())for(let n of r){let s=n.path;Object.prototype.hasOwnProperty.call(e,s)||(e[s]=null)}return e}collectTimeInfoEntries(e,i){let r=this.lastWatchEvent;for(let[n,s]of this.files)ce(s),r=Math.max(r,s.safeTime),e.set(n,s);if(this.nestedWatching){for(let n of this.directories.values())r=Math.max(r,n.directoryWatcher.collectTimeInfoEntries(e,i));e.set(this.path,Y),i.set(this.path,{safeTime:r})}else{for(let n of this.directories.keys())e.set(n,Y),i.has(n)||i.set(n,Y);e.set(this.path,Y),i.set(this.path,Y)}if(!this.initialScan)for(let n of this.watchers.values())for(let s of n){let o=s.path;e.has(o)||e.set(o,null)}return r}close(){if(this.closed=!0,this.initialScan=!1,this.watcher&&(this.watcher.close(),this.watcher=null),this.nestedWatching){for(let e of this.directories.values())e.close();this.directories.clear()}this.parentWatcher&&(this.parentWatcher.close(),this.parentWatcher=null),this.emit("closed")}};Ae.exports=Ce;Ae.exports.EXISTANCE_ONLY_TIME_ENTRY=Y;function ce(t){t.accuracy>q&&(t.safeTime=t.safeTime-t.accuracy+q,t.accuracy=q)}function ht(t){t&&(q>1&&t%1!==0?q=1:q>10&&t%10!==0?q=10:q>100&&t%100!==0?q=100:q>1e3&&t%1e3!==0&&(q=1e3))}});var dt=M((Jr,be)=>{"use strict";var wr=require("path"),yr=lt(),he=class{constructor(e){this.options=e,this.directoryWatchers=new Map}getDirectoryWatcher(e){let i=this.directoryWatchers.get(e);if(i===void 0){let r=new yr(this,e,this.options);return this.directoryWatchers.set(e,r),r.on("closed",()=>{this.directoryWatchers.delete(e)}),r}return i}watchFile(e,i){let r=wr.dirname(e);return r===e?null:this.getDirectoryWatcher(r).watch(e,i)}watchDirectory(e,i){return this.getDirectoryWatcher(e).watch(e,i)}},ut=new WeakMap;be.exports=t=>{let e=ut.get(t);if(e!==void 0)return e;let i=new he(t);return ut.set(t,i),i};be.exports.WatcherManager=he});var mt=M((Qr,gt)=>{"use strict";var vr=require("fs"),fe=require("path"),pt=new Set(["EINVAL","ENOENT"]);process.platform==="win32"&&pt.add("UNKNOWN");var ke=class{constructor(){this.cache=new Map}resolve(e){let i=this.cache.get(e);if(i!==void 0)return i;let r=fe.dirname(e);if(r===e){let o=Object.freeze([e]);return this.cache.set(e,o),o}let n=this.resolve(r),s=e;if(n[0]!==r){let o=fe.basename(e);s=fe.resolve(n[0],o)}try{let o=vr.readlinkSync(s),a=fe.resolve(n[0],o),h=this.resolve(a),l;if(h.length>1&&n.length>1){let c=new Set(h);c.add(s);for(let f=1;f<n.length;f++)c.add(n[f]);l=Object.freeze(Array.from(c))}else n.length>1?(l=n.slice(),l[0]=h[0],l.push(s),Object.freeze(l)):h.length>1?(l=h.slice(),l.push(s),Object.freeze(l)):l=Object.freeze([h[0],s]);return this.cache.set(e,l),l}catch(o){if(!pt.has(o.code))throw o;let a=n.slice();return a[0]=s,Object.freeze(a),this.cache.set(e,a),a}}};gt.exports=ke});var yt=M((Xr,wt)=>{wt.exports=function(t,e){if(typeof t!="string")throw new TypeError("Expected a string");for(var i=String(t),r="",n=e?!!e.extended:!1,s=e?!!e.globstar:!1,o=!1,a=e&&typeof e.flags=="string"?e.flags:"",h,l=0,c=i.length;l<c;l++)switch(h=i[l],h){case"/":case"$":case"^":case"+":case".":case"(":case")":case"=":case"!":case"|":r+="\\"+h;break;case"?":if(n){r+=".";break}case"[":case"]":if(n){r+=h;break}case"{":if(n){o=!0,r+="(";break}case"}":if(n){o=!1,r+=")";break}case",":if(o){r+="|";break}r+="\\"+h;break;case"*":for(var f=i[l-1],p=1;i[l+1]==="*";)p++,l++;var d=i[l+1];if(!s)r+=".*";else{var m=p>1&&(f==="/"||f===void 0)&&(d==="/"||d===void 0);m?(r+="((?:[^/]*(?:/|$))*)",l++):r+="([^/]*)"}break;default:r+=h}return(!a||!~a.indexOf("g"))&&(r="^"+r+"$"),new RegExp(r,a)}});var Tt=M((Zr,St)=>{"use strict";var Er=dt(),Sr=mt(),Tr=require("events").EventEmitter,xr=yt(),Wr=We(),le=[],Or={};function ue(t,e){for(let i of t){let r=i.watcher;e.has(r.directoryWatcher)||e.add(r.directoryWatcher)}}var vt=t=>{let e=xr(t,{globstar:!0,extended:!0}).source;return e.slice(0,e.length-1)+"(?:$|\\/)"},Cr=t=>{if(Array.isArray(t)){let e=new RegExp(t.map(i=>vt(i)).join("|"));return i=>e.test(i.replace(/\\/g,"/"))}else if(typeof t=="string"){let e=new RegExp(vt(t));return i=>e.test(i.replace(/\\/g,"/"))}else{if(t instanceof RegExp)return e=>t.test(e.replace(/\\/g,"/"));if(t instanceof Function)return t;if(t)throw new Error(`Invalid option for 'ignored': ${t}`);return()=>!1}},Ar=t=>({followSymlinks:!!t.followSymlinks,ignored:Cr(t.ignored),poll:t.poll}),Et=new WeakMap,br=t=>{let e=Et.get(t);if(e!==void 0)return e;let i=Ar(t);return Et.set(t,i),i},Pe=class{constructor(e,i,r){this.files=Array.isArray(r)?r:[r],this.watcher=i,i.on("initial-missing",n=>{for(let s of this.files)e._missing.has(s)||e._onRemove(s,s,n)}),i.on("change",(n,s)=>{for(let o of this.files)e._onChange(o,n,o,s)}),i.on("remove",n=>{for(let s of this.files)e._onRemove(s,s,n)})}update(e){Array.isArray(e)?this.files=e:this.files.length!==1?this.files=[e]:this.files[0]!==e&&(this.files[0]=e)}close(){this.watcher.close()}},Fe=class{constructor(e,i,r){this.directories=Array.isArray(r)?r:[r],this.watcher=i,i.on("initial-missing",n=>{for(let s of this.directories)e._onRemove(s,s,n)}),i.on("change",(n,s,o)=>{for(let a of this.directories)e._onChange(a,s,n,o)}),i.on("remove",n=>{for(let s of this.directories)e._onRemove(s,s,n)})}update(e){Array.isArray(e)?this.directories=e:this.directories.length!==1?this.directories=[e]:this.directories[0]!==e&&(this.directories[0]=e)}close(){this.watcher.close()}},_e=class extends Tr{constructor(e){super(),e||(e=Or),this.options=e,this.aggregateTimeout=typeof e.aggregateTimeout=="number"?e.aggregateTimeout:200,this.watcherOptions=br(e),this.watcherManager=Er(this.watcherOptions),this.fileWatchers=new Map,this.directoryWatchers=new Map,this._missing=new Set,this.startTime=void 0,this.paused=!1,this.aggregatedChanges=new Set,this.aggregatedRemovals=new Set,this.aggregateTimer=void 0,this._onTimeout=this._onTimeout.bind(this)}watch(e,i,r){let n,s,o,a;i?(n=e,s=i,o=le,a=r):{files:n=le,directories:s=le,missing:o=le,startTime:a}=e,this.paused=!1;let h=this.fileWatchers,l=this.directoryWatchers,c=this.watcherOptions.ignored,f=u=>!c(u),p=(u,g,y)=>{let W=u.get(g);W===void 0?u.set(g,y):Array.isArray(W)?W.push(y):u.set(g,[W,y])},d=new Map,m=new Map,E=new Set;if(this.watcherOptions.followSymlinks){let u=new Sr;for(let g of n)if(f(g))for(let y of u.resolve(g))(g===y||f(y))&&p(d,y,g);for(let g of o)if(f(g))for(let y of u.resolve(g))(g===y||f(y))&&(E.add(g),p(d,y,g));for(let g of s)if(f(g)){let y=!0;for(let W of u.resolve(g))f(W)&&p(y?m:d,W,g),y=!1}}else{for(let u of n)f(u)&&p(d,u,u);for(let u of o)f(u)&&(E.add(u),p(d,u,u));for(let u of s)f(u)&&p(m,u,u)}for(let[u,g]of h){let y=d.get(u);y===void 0?(g.close(),h.delete(u)):(g.update(y),d.delete(u))}for(let[u,g]of l){let y=m.get(u);y===void 0?(g.close(),l.delete(u)):(g.update(y),m.delete(u))}Wr.batch(()=>{for(let[u,g]of d){let y=this.watcherManager.watchFile(u,a);y&&h.set(u,new Pe(this,y,g))}for(let[u,g]of m){let y=this.watcherManager.watchDirectory(u,a);y&&l.set(u,new Fe(this,y,g))}}),this._missing=E,this.startTime=a}close(){this.paused=!0,this.aggregateTimer&&clearTimeout(this.aggregateTimer);for(let e of this.fileWatchers.values())e.close();for(let e of this.directoryWatchers.values())e.close();this.fileWatchers.clear(),this.directoryWatchers.clear()}pause(){this.paused=!0,this.aggregateTimer&&clearTimeout(this.aggregateTimer)}getTimes(){let e=new Set;ue(this.fileWatchers.values(),e),ue(this.directoryWatchers.values(),e);let i=Object.create(null);for(let r of e){let n=r.getTimes();for(let s of Object.keys(n))i[s]=n[s]}return i}getTimeInfoEntries(){let e=new Map;return this.collectTimeInfoEntries(e,e),e}collectTimeInfoEntries(e,i){let r=new Set;ue(this.fileWatchers.values(),r),ue(this.directoryWatchers.values(),r);let n={value:0};for(let s of r)s.collectTimeInfoEntries(e,i,n)}getAggregated(){this.aggregateTimer&&(clearTimeout(this.aggregateTimer),this.aggregateTimer=void 0);let e=this.aggregatedChanges,i=this.aggregatedRemovals;return this.aggregatedChanges=new Set,this.aggregatedRemovals=new Set,{changes:e,removals:i}}_onChange(e,i,r,n){r=r||e,this.paused||(this.emit("change",r,i,n),this.aggregateTimer&&clearTimeout(this.aggregateTimer),this.aggregateTimer=setTimeout(this._onTimeout,this.aggregateTimeout)),this.aggregatedRemovals.delete(e),this.aggregatedChanges.add(e)}_onRemove(e,i,r){i=i||e,this.paused||(this.emit("remove",i,r),this.aggregateTimer&&clearTimeout(this.aggregateTimer),this.aggregateTimer=setTimeout(this._onTimeout,this.aggregateTimeout)),this.aggregatedChanges.delete(e),this.aggregatedRemovals.add(e)}_onTimeout(){this.aggregateTimer=void 0;let e=this.aggregatedChanges,i=this.aggregatedRemovals;this.aggregatedChanges=new Set,this.aggregatedRemovals=new Set,this.emit("aggregated",e,i)}};St.exports=_e});var kr={};Yt(kr,{default:()=>jt});module.exports=Ut(kr);var N=require("@nrwl/devkit"),Rt=require("@nrwl/js/src/executors/tsc/tsc.impl"),Nt=require("node:path");var L=require("@nrwl/devkit"),Ge=require("node:path");var Bt=["@graphql-mesh/cli","@graphql-mesh/cross-helpers","@graphql-mesh/merger-bare","@graphql-mesh/runtime","@graphql-mesh/store","@graphql-mesh/types","@graphql-mesh/utils"],Vt=["@graphql-mesh/graphql","@graphql-mesh/grpc","@graphql-mesh/json-schema","@graphql-mesh/mongoose","@graphql-mesh/mysql","@graphql-mesh/neo4j","@graphql-mesh/new-openapi","@graphql-mesh/odata","@graphql-mesh/openapi","@graphql-mesh/postgraphile","@graphql-mesh/soap","@graphql-mesh/thrift","@graphql-mesh/tuql"],Ht=["@graphql-mesh/transform-cache","@graphql-mesh/transform-encapsulate","@graphql-mesh/transform-federation","@graphql-mesh/transform-filter-schema","@graphql-mesh/transform-hoist-field","@graphql-mesh/transform-mock","@graphql-mesh/transform-naming-convention","@graphql-mesh/transform-prefix","@graphql-mesh/transform-prune","@graphql-mesh/transform-rename","@graphql-mesh/transform-replace-field","@graphql-mesh/transform-resolvers-composition","@graphql-mesh/transform-snapshot"],Jt=["@graphql-mesh/cache-file","@graphql-mesh/cache-localforage","@graphql-mesh/cache-redis"],Qt=["@graphql-mesh/plugin-mock","@graphql-mesh/plugin-snapshot"],Xt=["@graphql-codegen/cli","@graphql-codegen/client-preset"],Ne=[...Jt,...Xt,...Qt,...Vt,...Ht,...Bt];var je=(t,e)=>{let i=[];return e.forEach(r=>{t.indexOf(r)>-1&&i.push(r)}),i};var Ie=(t,e)=>{if(e===void 0)return{};let i={};return t.forEach(r=>{let n=e[`npm:${r}`];n&&(i[r]=n.data.version)}),i};var De=require("node:fs/promises"),Z=require("node:path"),Le=async t=>{let{root:e,dir:i,sourcePath:r}=Object.assign({sourcePath:".mesh/index.ts"},t),n=(0,Z.resolve)(e,i),s=(0,Z.join)(n,r);return await(0,De.readFile)(s,"utf8")};var $e=t=>Object.keys(t).filter(e=>t[e]==="*");async function ze(t,e){if(e.projectName===void 0)throw new Error("project name is undefined");let i=(0,L.readCachedProjectGraph)(),r=(0,L.createPackageJson)(e.projectName,i,{root:e.root});r.name||(r.name=e.projectName),r.scripts||(r.scripts={}),r.scripts.start="graphql-mesh start",r.devDependencies||(r.devDependencies={});let n=await Le({dir:t.dir,root:e.root}),s=["@graphql-mesh/cli","graphql",...je(n,Ne)];r.dependencies&&(s=[...s,...$e(r.dependencies)]),r.dependencies={...r.dependencies,...Ie(s,i.externalNodes)};let o=(0,Ge.join)(t.outputPath,"package.json");return(0,L.writeJsonFile)(o,r),{outputFile:o,packageJson:r}}var de=require("@nrwl/devkit"),xt=Kt(Tt());async function Wt(t,e){let{dir:i,watch:r,...n}=e;if(r===!0){let s=new xt.default({...n,ignored:[".eslintrc.json",".swcrc","**/.codegen","**/.git","**/.mesh","**/node_modules","jest.config.ts","project.json"]});s.watch({directories:[i],startTime:0}),s.on("aggregated",async()=>{await t(),de.logger.info(""),de.logger.info(""),de.logger.info("Watching for changes...")}),await new Promise(()=>{})}else await t()}var Ot=t=>{let e={};return Object.entries(t).forEach(([i,r])=>{let n=`--${i}`,s;Array.isArray(r)?s=r.join(" "):s=r,s!==void 0&&s!==""&&(e[n]=`${s}`)}),e},Ct=t=>Object.entries(t).flat();var At=require("node:child_process");var Q;async function bt(t,e,i){let r=Ot(t),n=Ct(r);return new Promise((s,o)=>{Q=(0,At.spawn)("npx",["graphql-codegen",...n],{stdio:i?.stdio??[0,1,2],cwd:e.root,env:{...process.env,FORCE_COLOR:"true"}}),process.on("exit",()=>Q.kill()),process.on("SIGTERM",()=>Q.kill()),Q.on("error",a=>{o(a)}),Q.on("exit",a=>{a===0?s(a):o(a)})})}var kt=t=>{let e={};return Object.entries(t).forEach(([i,r])=>{let n=`--${i}`,s;Array.isArray(r)?s=r.join(" "):s=r,s!==void 0&&s!==""&&(e[n]=`${s}`)}),e},Pt=t=>Object.entries(t).flat();var qt=require("node:child_process");var Ft=t=>{let e={};return Object.keys(t).forEach(i=>{let r=t[i],n=i.toUpperCase();i==="debug"&&r!==void 0&&(e[n]=(+r).toString())}),e};var _t=t=>{let e=kt(t.args),i=Ft(t.env);return{args:e,env:i}};var R;async function Mt(t,e,i,r){let{args:n,env:s}=_t(e),o=Pt(n);return new Promise((a,h)=>{R=(0,qt.spawn)("npx",["graphql-mesh",t,...o],{stdio:r?.stdio??[0,1,2],cwd:i.root,env:{...process.env,...s,FORCE_COLOR:"true"}}),process.on("exit",()=>R.kill()),process.on("SIGTERM",()=>R.kill()),R.on("error",l=>{h(l)}),R.on("exit",l=>{l===0?a(l):h(l)})})}async function*jt(t,e){if(t.dir===void 0)throw new Error("Please define the 'dir' value");let i=(0,Nt.resolve)(e.root,t.dir),r=!1;N.logger.log("Building GraphQL Mesh..."),await Wt(async()=>{Mt("build",{args:{dir:i,require:t.require},env:{debug:t.debug}},e,{stdio:"pipe"}),R?.stdout?.on("data",s=>{t.debug&&process.stdout.write(s)}),R?.stderr?.on("data",s=>{(s.toString().indexOf("Transformed schema is not set yet")<=-1||t.debug)&&process.stderr.write(s)}),await new Promise((s,o)=>{R?.stdout?.on("data",a=>{a.toString().indexOf("Done!")>-1&&s(),a.toString().indexOf("\u{1F4A5}")>-1&&o()})}),t.codegen?.config&&(t.debug&&(N.logger.debug(""),N.logger.debug("Running GraphQL Codegen...")),await bt({...t.codegen,debug:t.debug,verbose:t.debug,watch:!1},e)),t.debug&&(N.logger.debug(""),N.logger.debug("Running Typescript compiler..."));let n=(0,Rt.tscExecutor)({assets:[...t.assets],main:t.main,outputPath:t.outputPath,transformers:[],tsConfig:t.tsConfig,watch:!1},e);for await(let s of n)r=s.success;r&&(t.debug&&(N.logger.debug(""),N.logger.debug("Creating package.json...")),await ze({dir:i,outputPath:t.outputPath,projectRoot:t.outputPath},e),N.logger.log("Done."))},{dir:i,watch:t.watch}),yield{success:r}}