@samarium.sdk/new 0.25.0 → 0.25.1

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 (2) hide show
  1. package/bin/samarium +240 -655
  2. package/package.json +2 -2
package/bin/samarium CHANGED
@@ -344,7 +344,7 @@ ${F.comment}`:F.comment}this.doc.range[2]=F.offset;break}default:this.errors.pus
344
344
  `)+1;while(F!==0)this.onNewLine(this.offset+F),F=this.source.indexOf(`
345
345
  `,F)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(D){let F=D.items[D.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,F.value){let P="end"in F.value?F.value.end:void 0;if((Array.isArray(P)?P[P.length-1]:void 0)?.type==="comment")P?.push(this.sourceToken);else D.items.push({start:[this.sourceToken]})}else if(F.sep)F.sep.push(this.sourceToken);else F.start.push(this.sourceToken);return;case"space":case"comment":if(F.value)D.items.push({start:[this.sourceToken]});else if(F.sep)F.sep.push(this.sourceToken);else{if(this.atIndentedComment(F.start,D.indent)){let B=D.items[D.items.length-2]?.value?.end;if(Array.isArray(B)){Array.prototype.push.apply(B,F.start),B.push(this.sourceToken),D.items.pop();return}}F.start.push(this.sourceToken)}return}if(this.indent>=D.indent){let P=!this.onKeyLine&&this.indent===D.indent,B=P&&(F.sep||F.explicitKey)&&this.type!=="seq-item-ind",Z=[];if(B&&F.sep&&!F.value){let X=[];for(let q=0;q<F.sep.length;++q){let J=F.sep[q];switch(J.type){case"newline":X.push(q);break;case"space":break;case"comment":if(J.indent>D.indent)X.length=0;break;default:X.length=0}}if(X.length>=2)Z=F.sep.splice(X[1])}switch(this.type){case"anchor":case"tag":if(B||F.value)Z.push(this.sourceToken),D.items.push({start:Z}),this.onKeyLine=!0;else if(F.sep)F.sep.push(this.sourceToken);else F.start.push(this.sourceToken);return;case"explicit-key-ind":if(!F.sep&&!F.explicitKey)F.start.push(this.sourceToken),F.explicitKey=!0;else if(B||F.value)Z.push(this.sourceToken),D.items.push({start:Z,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(F.explicitKey)if(!F.sep)if(R0(F.start,"newline"))Object.assign(F,{key:null,sep:[this.sourceToken]});else{let X=y8(F.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:X,key:null,sep:[this.sourceToken]}]})}else if(F.value)D.items.push({start:[],key:null,sep:[this.sourceToken]});else if(R0(F.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:Z,key:null,sep:[this.sourceToken]}]});else if(Vz(F.key)&&!R0(F.sep,"newline")){let X=y8(F.start),q=F.key,J=F.sep;J.push(this.sourceToken),delete F.key,delete F.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:X,key:q,sep:J}]})}else if(Z.length>0)F.sep=F.sep.concat(Z,this.sourceToken);else F.sep.push(this.sourceToken);else if(!F.sep)Object.assign(F,{key:null,sep:[this.sourceToken]});else if(F.value||B)D.items.push({start:Z,key:null,sep:[this.sourceToken]});else if(R0(F.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else F.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let X=this.flowScalar(this.type);if(B||F.value)D.items.push({start:Z,key:X,sep:[]}),this.onKeyLine=!0;else if(F.sep)this.stack.push(X);else Object.assign(F,{key:X,sep:[]}),this.onKeyLine=!0;return}default:{let X=this.startBlockValue(D);if(X){if(X.type==="block-seq"){if(!F.explicitKey&&F.sep&&!R0(F.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(P)D.items.push({start:Z});this.stack.push(X);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(D){let F=D.items[D.items.length-1];switch(this.type){case"newline":if(F.value){let P="end"in F.value?F.value.end:void 0;if((Array.isArray(P)?P[P.length-1]:void 0)?.type==="comment")P?.push(this.sourceToken);else D.items.push({start:[this.sourceToken]})}else F.start.push(this.sourceToken);return;case"space":case"comment":if(F.value)D.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(F.start,D.indent)){let B=D.items[D.items.length-2]?.value?.end;if(Array.isArray(B)){Array.prototype.push.apply(B,F.start),B.push(this.sourceToken),D.items.pop();return}}F.start.push(this.sourceToken)}return;case"anchor":case"tag":if(F.value||this.indent<=D.indent)break;F.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==D.indent)break;if(F.value||R0(F.start,"seq-item-ind"))D.items.push({start:[this.sourceToken]});else F.start.push(this.sourceToken);return}if(this.indent>D.indent){let P=this.startBlockValue(D);if(P){this.stack.push(P);return}}yield*this.pop(),yield*this.step()}*flowCollection(D){let F=D.items[D.items.length-1];if(this.type==="flow-error-end"){let P;do yield*this.pop(),P=this.peek(1);while(P&&P.type==="flow-collection")}else if(D.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!F||F.sep)D.items.push({start:[this.sourceToken]});else F.start.push(this.sourceToken);return;case"map-value-ind":if(!F||F.value)D.items.push({start:[],key:null,sep:[this.sourceToken]});else if(F.sep)F.sep.push(this.sourceToken);else Object.assign(F,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!F||F.value)D.items.push({start:[this.sourceToken]});else if(F.sep)F.sep.push(this.sourceToken);else F.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let B=this.flowScalar(this.type);if(!F||F.value)D.items.push({start:[],key:B,sep:[]});else if(F.sep)this.stack.push(B);else Object.assign(F,{key:B,sep:[]});return}case"flow-map-end":case"flow-seq-end":D.end.push(this.sourceToken);return}let P=this.startBlockValue(D);if(P)this.stack.push(P);else yield*this.pop(),yield*this.step()}else{let P=this.peek(2);if(P.type==="block-map"&&(this.type==="map-value-ind"&&P.indent===D.indent||this.type==="newline"&&!P.items[P.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&P.type!=="flow-collection"){let B=T5(P),Z=y8(B);Lz(D);let X=D.end.splice(1,D.end.length);X.push(this.sourceToken);let q={type:"block-map",offset:D.offset,indent:D.indent,items:[{start:Z,key:D,sep:X}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=q}else yield*this.lineEnd(D)}}flowScalar(D){if(this.onNewLine){let F=this.source.indexOf(`
346
346
  `)+1;while(F!==0)this.onNewLine(this.offset+F),F=this.source.indexOf(`
347
- `,F)+1}return{type:D,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(D){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let F=T5(D),P=y8(F);return P.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:P,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let F=T5(D),P=y8(F);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:P,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(D,F){if(this.type!=="comment")return!1;if(this.indent<=F)return!1;return D.every((P)=>P.type==="newline"||P.type==="space")}*documentEnd(D){if(this.type!=="doc-mode"){if(D.end)D.end.push(this.sourceToken);else D.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(D){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(D.end)D.end.push(this.sourceToken);else D.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}qg.Parser=wz});var uz=Q((Gg)=>{var jz=DP(),Yg=q1(),O1=J1(),Hg=UF(),Ug=t(),Wg=UP(),bz=WP();function Sz(D){let F=D.prettyErrors!==!1;return{lineCounter:D.lineCounter||F&&new Wg.LineCounter||null,prettyErrors:F}}function Og(D,F={}){let{lineCounter:P,prettyErrors:B}=Sz(F),Z=new bz.Parser(P?.addNewLine),X=new jz.Composer(F),q=Array.from(X.compose(Z.parse(D)));if(B&&P)for(let J of q)J.errors.forEach(O1.prettifyError(D,P)),J.warnings.forEach(O1.prettifyError(D,P));if(q.length>0)return q;return Object.assign([],{empty:!0},X.streamInfo())}function Tz(D,F={}){let{lineCounter:P,prettyErrors:B}=Sz(F),Z=new bz.Parser(P?.addNewLine),X=new jz.Composer(F),q=null;for(let J of X.compose(Z.parse(D),!0,D.length))if(!q)q=J;else if(q.options.logLevel!=="silent"){q.errors.push(new O1.YAMLParseError(J.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(B&&P)q.errors.forEach(O1.prettifyError(D,P)),q.warnings.forEach(O1.prettifyError(D,P));return q}function zg(D,F,P){let B=void 0;if(typeof F==="function")B=F;else if(P===void 0&&F&&typeof F==="object")P=F;let Z=Tz(D,P);if(!Z)return null;if(Z.warnings.forEach((X)=>Hg.warn(Z.options.logLevel,X)),Z.errors.length>0)if(Z.options.logLevel!=="silent")throw Z.errors[0];else Z.errors=[];return Z.toJS(Object.assign({reviver:B},P))}function Qg(D,F,P){let B=null;if(typeof F==="function"||Array.isArray(F))B=F;else if(P===void 0&&F)P=F;if(typeof P==="string")P=P.length;if(typeof P==="number"){let Z=Math.round(P);P=Z<1?void 0:Z>8?{indent:8}:{indent:Z}}if(D===void 0){let{keepUndefined:Z}=P??F??{};if(!Z)return}if(Ug.isDocument(D)&&!B)return D.toString(P);return new Yg.Document(D,B,P).toString(P)}Gg.parse=zg;Gg.parseAllDocuments=Og;Gg.parseDocument=Tz;Gg.stringify=Qg});var _z=Q((Ng)=>{var Eg=DP(),Kg=q1(),Ag=gF(),OP=J1(),Cg=p6(),I0=t(),Lg=O0(),Vg=CD(),wg=Q0(),jg=G0(),bg=b5(),Sg=HP(),Tg=UP(),ug=WP(),u5=uz(),Nz=c6();Ng.Composer=Eg.Composer;Ng.Document=Kg.Document;Ng.Schema=Ag.Schema;Ng.YAMLError=OP.YAMLError;Ng.YAMLParseError=OP.YAMLParseError;Ng.YAMLWarning=OP.YAMLWarning;Ng.Alias=Cg.Alias;Ng.isAlias=I0.isAlias;Ng.isCollection=I0.isCollection;Ng.isDocument=I0.isDocument;Ng.isMap=I0.isMap;Ng.isNode=I0.isNode;Ng.isPair=I0.isPair;Ng.isScalar=I0.isScalar;Ng.isSeq=I0.isSeq;Ng.Pair=Lg.Pair;Ng.Scalar=Vg.Scalar;Ng.YAMLMap=wg.YAMLMap;Ng.YAMLSeq=jg.YAMLSeq;Ng.CST=bg;Ng.Lexer=Sg.Lexer;Ng.LineCounter=Tg.LineCounter;Ng.Parser=ug.Parser;Ng.parse=u5.parse;Ng.parseAllDocuments=u5.parseAllDocuments;Ng.parseDocument=u5.parseDocument;Ng.stringify=u5.stringify;Ng.visit=Nz.visit;Ng.visitAsync=Nz.visitAsync});var G1={name:"@samarium.sdk/new",version:"0.25.0",main:"bin/samarium",type:"module",repository:{type:"git",url:"https://github.com/liontariai/samarium",directory:"packages/new"},keywords:["graphql","typescript","compiler","api","sdk","openapi","oas3","oas3.1","swagger","graphql-sdk","graphql-codegen"],homepage:"https://liontari.ai",bin:{samarium:"bin/samarium"},publishConfig:{access:"public"},files:["bin/**/*","README.md","package.json"],scripts:{prettier:"prettier --write .",bundle:"bun bundle.ts",prepublishOnly:"bun run bundle",test:"bun test"},prettier:{tabWidth:4},devDependencies:{"bun-types":"^1.2.19","@samarium.sdk/make":"workspace:*"},peerDependencies:{typescript:"^5.0.0"},dependencies:{"@inquirer/prompts":"^5.0.5",commander:"^11.1.0","detect-indent":"^7.0.1",prettier:"^3.2.5",yaml:"^2.6.0"}};var hP=RD(fP(),1),{program:Ev,createCommand:Kv,createArgument:Av,createOption:Cv,CommanderError:Lv,InvalidArgumentError:Vv,InvalidOptionArgumentError:wv,Command:gP,Argument:jv,Option:bv,Help:Sv}=hP.default;var dH=RD(l2(),1);var E3=RD(l2(),1);class P0 extends Error{response;request;constructor(D,F){let P=`${P0.extractMessage(D)}: ${JSON.stringify({response:D,request:F})}`;super(P);if(Object.setPrototypeOf(this,P0.prototype),this.response=D,this.request=F,typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,P0)}static extractMessage(D){return D.errors?.[0]?.message??`GraphQL Error (Code: ${String(D.status)})`}}var W7=(D)=>D.toUpperCase(),Q3=(D)=>{return typeof D==="function"?D():D},O7=(D,F)=>D.map((P,B)=>[P,F[B]]),x0=(D)=>{let F={};if(D instanceof Headers)F=_b(D);else if(Array.isArray(D))D.forEach(([P,B])=>{if(P&&B!==void 0)F[P]=B});else if(D)F=D;return F},_b=(D)=>{let F={};return D.forEach((P,B)=>{F[B]=P}),F},NH=(D)=>{try{let F=D();if(kb(F))return F.catch((P)=>{return uH(P)});return F}catch(F){return uH(F)}},uH=(D)=>{if(D instanceof Error)return D;return Error(String(D))},kb=(D)=>{return typeof D==="object"&&D!==null&&"then"in D&&typeof D.then==="function"&&"catch"in D&&typeof D.catch==="function"&&"finally"in D&&typeof D.finally==="function"},G3=(D)=>{throw Error(`Unhandled case: ${String(D)}`)},S6=(D)=>{return typeof D==="object"&&D!==null&&!Array.isArray(D)};var _H=(D,F)=>{return D.documents?D:{documents:D,requestHeaders:F,signal:void 0}};var kH=(D,F,P)=>{return D.query?D:{query:D,variables:F,requestHeaders:P,signal:void 0}};var hH=RD(l2(),1);var z7="Accept",R3="Content-Type",T6="application/json",I3="application/graphql-response+json";var Q7=(D)=>D.replace(/([\s,]|#[^\n\r]+)+/g," ").trim(),gH=(D)=>{let F=D.toLowerCase();return F.includes(I3)||F.includes(T6)},G7=(D)=>{try{if(Array.isArray(D))return{_tag:"Batch",executionResults:D.map(xH)};else if(S6(D))return{_tag:"Single",executionResult:xH(D)};else throw Error(`Invalid execution result: result is not object or array.
347
+ `,F)+1}return{type:D,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(D){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let F=T5(D),P=y8(F);return P.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:P,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let F=T5(D),P=y8(F);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:P,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(D,F){if(this.type!=="comment")return!1;if(this.indent<=F)return!1;return D.every((P)=>P.type==="newline"||P.type==="space")}*documentEnd(D){if(this.type!=="doc-mode"){if(D.end)D.end.push(this.sourceToken);else D.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(D){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(D.end)D.end.push(this.sourceToken);else D.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}qg.Parser=wz});var uz=Q((Gg)=>{var jz=DP(),Yg=q1(),O1=J1(),Hg=UF(),Ug=t(),Wg=UP(),bz=WP();function Sz(D){let F=D.prettyErrors!==!1;return{lineCounter:D.lineCounter||F&&new Wg.LineCounter||null,prettyErrors:F}}function Og(D,F={}){let{lineCounter:P,prettyErrors:B}=Sz(F),Z=new bz.Parser(P?.addNewLine),X=new jz.Composer(F),q=Array.from(X.compose(Z.parse(D)));if(B&&P)for(let J of q)J.errors.forEach(O1.prettifyError(D,P)),J.warnings.forEach(O1.prettifyError(D,P));if(q.length>0)return q;return Object.assign([],{empty:!0},X.streamInfo())}function Tz(D,F={}){let{lineCounter:P,prettyErrors:B}=Sz(F),Z=new bz.Parser(P?.addNewLine),X=new jz.Composer(F),q=null;for(let J of X.compose(Z.parse(D),!0,D.length))if(!q)q=J;else if(q.options.logLevel!=="silent"){q.errors.push(new O1.YAMLParseError(J.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(B&&P)q.errors.forEach(O1.prettifyError(D,P)),q.warnings.forEach(O1.prettifyError(D,P));return q}function zg(D,F,P){let B=void 0;if(typeof F==="function")B=F;else if(P===void 0&&F&&typeof F==="object")P=F;let Z=Tz(D,P);if(!Z)return null;if(Z.warnings.forEach((X)=>Hg.warn(Z.options.logLevel,X)),Z.errors.length>0)if(Z.options.logLevel!=="silent")throw Z.errors[0];else Z.errors=[];return Z.toJS(Object.assign({reviver:B},P))}function Qg(D,F,P){let B=null;if(typeof F==="function"||Array.isArray(F))B=F;else if(P===void 0&&F)P=F;if(typeof P==="string")P=P.length;if(typeof P==="number"){let Z=Math.round(P);P=Z<1?void 0:Z>8?{indent:8}:{indent:Z}}if(D===void 0){let{keepUndefined:Z}=P??F??{};if(!Z)return}if(Ug.isDocument(D)&&!B)return D.toString(P);return new Yg.Document(D,B,P).toString(P)}Gg.parse=zg;Gg.parseAllDocuments=Og;Gg.parseDocument=Tz;Gg.stringify=Qg});var _z=Q((Ng)=>{var Eg=DP(),Kg=q1(),Ag=gF(),OP=J1(),Cg=p6(),I0=t(),Lg=O0(),Vg=CD(),wg=Q0(),jg=G0(),bg=b5(),Sg=HP(),Tg=UP(),ug=WP(),u5=uz(),Nz=c6();Ng.Composer=Eg.Composer;Ng.Document=Kg.Document;Ng.Schema=Ag.Schema;Ng.YAMLError=OP.YAMLError;Ng.YAMLParseError=OP.YAMLParseError;Ng.YAMLWarning=OP.YAMLWarning;Ng.Alias=Cg.Alias;Ng.isAlias=I0.isAlias;Ng.isCollection=I0.isCollection;Ng.isDocument=I0.isDocument;Ng.isMap=I0.isMap;Ng.isNode=I0.isNode;Ng.isPair=I0.isPair;Ng.isScalar=I0.isScalar;Ng.isSeq=I0.isSeq;Ng.Pair=Lg.Pair;Ng.Scalar=Vg.Scalar;Ng.YAMLMap=wg.YAMLMap;Ng.YAMLSeq=jg.YAMLSeq;Ng.CST=bg;Ng.Lexer=Sg.Lexer;Ng.LineCounter=Tg.LineCounter;Ng.Parser=ug.Parser;Ng.parse=u5.parse;Ng.parseAllDocuments=u5.parseAllDocuments;Ng.parseDocument=u5.parseDocument;Ng.stringify=u5.stringify;Ng.visit=Nz.visit;Ng.visitAsync=Nz.visitAsync});var G1={name:"@samarium.sdk/new",version:"0.25.1",main:"bin/samarium",type:"module",repository:{type:"git",url:"https://github.com/liontariai/samarium",directory:"packages/new"},keywords:["graphql","typescript","compiler","api","sdk","openapi","oas3","oas3.1","swagger","graphql-sdk","graphql-codegen"],homepage:"https://liontari.ai",bin:{samarium:"bin/samarium"},publishConfig:{access:"public"},files:["bin/**/*","README.md","package.json"],scripts:{prettier:"prettier --write .",bundle:"bun bundle.ts",prepublishOnly:"bun run bundle",test:"bun test"},prettier:{tabWidth:4},devDependencies:{"bun-types":"^1.2.19","@samarium.sdk/make":"workspace:*"},peerDependencies:{typescript:"^5.0.0"},dependencies:{"@inquirer/prompts":"^5.0.5",commander:"^11.1.0","detect-indent":"^7.0.1",prettier:"^3.2.5",yaml:"^2.6.0"}};var hP=RD(fP(),1),{program:Ev,createCommand:Kv,createArgument:Av,createOption:Cv,CommanderError:Lv,InvalidArgumentError:Vv,InvalidOptionArgumentError:wv,Command:gP,Argument:jv,Option:bv,Help:Sv}=hP.default;var dH=RD(l2(),1);var E3=RD(l2(),1);class P0 extends Error{response;request;constructor(D,F){let P=`${P0.extractMessage(D)}: ${JSON.stringify({response:D,request:F})}`;super(P);if(Object.setPrototypeOf(this,P0.prototype),this.response=D,this.request=F,typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,P0)}static extractMessage(D){return D.errors?.[0]?.message??`GraphQL Error (Code: ${String(D.status)})`}}var W7=(D)=>D.toUpperCase(),Q3=(D)=>{return typeof D==="function"?D():D},O7=(D,F)=>D.map((P,B)=>[P,F[B]]),x0=(D)=>{let F={};if(D instanceof Headers)F=_b(D);else if(Array.isArray(D))D.forEach(([P,B])=>{if(P&&B!==void 0)F[P]=B});else if(D)F=D;return F},_b=(D)=>{let F={};return D.forEach((P,B)=>{F[B]=P}),F},NH=(D)=>{try{let F=D();if(kb(F))return F.catch((P)=>{return uH(P)});return F}catch(F){return uH(F)}},uH=(D)=>{if(D instanceof Error)return D;return Error(String(D))},kb=(D)=>{return typeof D==="object"&&D!==null&&"then"in D&&typeof D.then==="function"&&"catch"in D&&typeof D.catch==="function"&&"finally"in D&&typeof D.finally==="function"},G3=(D)=>{throw Error(`Unhandled case: ${String(D)}`)},S6=(D)=>{return typeof D==="object"&&D!==null&&!Array.isArray(D)};var _H=(D,F)=>{return D.documents?D:{documents:D,requestHeaders:F,signal:void 0}};var kH=(D,F,P)=>{return D.query?D:{query:D,variables:F,requestHeaders:P,signal:void 0}};var hH=RD(l2(),1);var z7="Accept",R3="Content-Type",T6="application/json",I3="application/graphql-response+json";var Q7=(D)=>D.replace(/([\s,]|#[^\n\r]+)+/g," ").trim(),gH=(D)=>{let F=D.toLowerCase();return F.includes(I3)||F.includes(T6)},G7=(D)=>{try{if(Array.isArray(D))return{_tag:"Batch",executionResults:D.map(xH)};else if(S6(D))return{_tag:"Single",executionResult:xH(D)};else throw Error(`Invalid execution result: result is not object or array.
348
348
  Got:
349
349
  ${String(D)}`)}catch(F){return F}},xH=(D)=>{if(typeof D!=="object"||D===null)throw Error("Invalid execution result: result is not object");let F=void 0,P=void 0,B=void 0;if("errors"in D){if(!S6(D.errors)&&!Array.isArray(D.errors))throw Error("Invalid execution result: errors is not plain object OR array");F=D.errors}if("data"in D){if(!S6(D.data)&&D.data!==null)throw Error("Invalid execution result: data is not plain object");P=D.data}if("extensions"in D){if(!S6(D.extensions))throw Error("Invalid execution result: extensions is not plain object");B=D.extensions}return{data:P,errors:F,extensions:B}},vH=(D)=>D._tag==="Batch"?D.executionResults.some(fH):fH(D.executionResult),fH=(D)=>Array.isArray(D.errors)?D.errors.length>0:Boolean(D.errors),R7=(D)=>{return typeof D==="object"&&D!==null&&"kind"in D&&D.kind===hH.Kind.OPERATION_DEFINITION};var yH=RD(l2(),1),mH=RD(l2(),1),xb=(D)=>{let F=void 0,P=D.definitions.filter(R7);if(P.length===1)F=P[0].name?.value;return F},fb=(D)=>{let F=!1,P=D.definitions.filter(R7);if(P.length===1)F=P[0].operation==="mutation";return F},u6=(D,F)=>{let P=typeof D==="string"?D:mH.print(D),B=!1,Z=void 0;if(F)return{expression:P,isMutation:B,operationName:Z};let X=NH(()=>typeof D==="string"?yH.parse(D):D);if(X instanceof Error)return{expression:P,isMutation:B,operationName:Z};return Z=xb(X),B=fb(X),{expression:P,operationName:Z,isMutation:B}};var $3=JSON;var M3=async(D)=>{let F={...D,method:D.request._tag==="Single"?D.request.document.isMutation?"POST":W7(D.method??"post"):D.request.hasMutations?"POST":W7(D.method??"post"),fetchOptions:{...D.fetchOptions,errorPolicy:D.fetchOptions.errorPolicy??"none"}},B=await gb(F.method)(F);if(!B.ok)return new P0({status:B.status,headers:B.headers},{query:D.request._tag==="Single"?D.request.document.expression:D.request.query,variables:D.request.variables});let Z=await hb(B,D.fetchOptions.jsonSerializer??$3);if(Z instanceof Error)throw Z;let X={status:B.status,headers:B.headers};if(vH(Z)&&F.fetchOptions.errorPolicy==="none"){let q=Z._tag==="Batch"?{...Z.executionResults,...X}:{...Z.executionResult,...X};return new P0(q,{query:D.request._tag==="Single"?D.request.document.expression:D.request.query,variables:D.request.variables})}switch(Z._tag){case"Single":return{...X,...lH(F)(Z.executionResult)};case"Batch":return{...X,data:Z.executionResults.map(lH(F))};default:G3(Z)}},lH=(D)=>(F)=>{return{extensions:F.extensions,data:F.data,errors:D.fetchOptions.errorPolicy==="all"?F.errors:void 0}},hb=async(D,F)=>{let P=D.headers.get(R3),B=await D.text();if(P&&gH(P))return G7(F.parse(B));else return G7(B)},gb=(D)=>async(F)=>{let P=new Headers(F.headers),B=null,Z=void 0;if(!P.has(z7))P.set(z7,[I3,T6].join(", "));if(D==="POST"){if(Z=(F.fetchOptions.jsonSerializer??$3).stringify(vb(F)),typeof Z==="string"&&!P.has(R3))P.set(R3,T6)}else B=yb(F);let X={method:D,headers:P,body:Z,...F.fetchOptions},q=new URL(F.url),J=X;if(F.middleware){let H=await Promise.resolve(F.middleware({...X,url:F.url,operationName:F.request._tag==="Single"?F.request.document.operationName:void 0,variables:F.request.variables})),{url:U,...W}=H;q=new URL(U),J=W}if(B)B.forEach((H,U)=>{q.searchParams.append(U,H)});return await(F.fetch??fetch)(q,J)},vb=(D)=>{switch(D.request._tag){case"Single":return{query:D.request.document.expression,variables:D.request.variables,operationName:D.request.document.operationName};case"Batch":return O7(D.request.query,D.request.variables??[]).map(([F,P])=>({query:F,variables:P}));default:throw G3(D.request)}},yb=(D)=>{let F=D.fetchOptions.jsonSerializer??$3,P=new URLSearchParams;switch(D.request._tag){case"Single":{if(P.append("query",Q7(D.request.document.expression)),D.request.variables)P.append("variables",F.stringify(D.request.variables));if(D.request.document.operationName)P.append("operationName",D.request.document.operationName);return P}case"Batch":{let B=D.request.variables?.map((q)=>F.stringify(q))??[],Z=D.request.query.map(Q7),X=O7(Z,B).map(([q,J])=>({query:q,variables:J}));return P.append("query",F.stringify(X)),P}default:throw G3(D.request)}};class f0{url;requestConfig;constructor(D,F={}){this.url=D,this.requestConfig=F}rawRequest=async(...D)=>{let[F,P,B]=D,Z=kH(F,P,B),{headers:X,fetch:q=globalThis.fetch,method:J="POST",requestMiddleware:Y,responseMiddleware:H,excludeOperationName:U,...W}=this.requestConfig,{url:O}=this;if(Z.signal!==void 0)W.signal=Z.signal;let z=u6(Z.query,U),I=await M3({url:O,request:{_tag:"Single",document:z,variables:Z.variables},headers:{...x0(Q3(X)),...x0(Z.requestHeaders)},fetch:q,method:J,fetchOptions:W,middleware:Y});if(H)await H(I,{operationName:z.operationName,variables:P,url:this.url});if(I instanceof Error)throw I;return I};async request(D,...F){let[P,B]=F,Z=cH(D,P,B),{headers:X,fetch:q=globalThis.fetch,method:J="POST",requestMiddleware:Y,responseMiddleware:H,excludeOperationName:U,...W}=this.requestConfig,{url:O}=this;if(Z.signal!==void 0)W.signal=Z.signal;let z=u6(Z.document,U),I=await M3({url:O,request:{_tag:"Single",document:z,variables:Z.variables},headers:{...x0(Q3(X)),...x0(Z.requestHeaders)},fetch:q,method:J,fetchOptions:W,middleware:Y});if(H)await H(I,{operationName:z.operationName,variables:Z.variables,url:this.url});if(I instanceof Error)throw I;return I.data}async batchRequests(D,F){let P=_H(D,F),{headers:B,excludeOperationName:Z,...X}=this.requestConfig;if(P.signal!==void 0)X.signal=P.signal;let q=P.documents.map(({document:W})=>u6(W,Z)),J=q.map(({expression:W})=>W),Y=q.some(({isMutation:W})=>W),H=P.documents.map(({variables:W})=>W),U=await M3({url:this.url,request:{_tag:"Batch",operationName:void 0,query:J,hasMutations:Y,variables:H},headers:{...x0(Q3(B)),...x0(P.requestHeaders)},fetch:this.requestConfig.fetch??globalThis.fetch,method:this.requestConfig.method||"POST",fetchOptions:X,middleware:this.requestConfig.requestMiddleware});if(this.requestConfig.responseMiddleware)await this.requestConfig.responseMiddleware(U,{operationName:void 0,variables:H,url:this.url});if(U instanceof Error)throw U;return U.data}setHeaders(D){return this.requestConfig.headers=D,this}setHeader(D,F){let{headers:P}=this.requestConfig;if(P)P[D]=F;else this.requestConfig.headers={[D]:F};return this}setEndpoint(D){return this.url=D,this}}var cH=(D,F,P)=>{return D.document?D:{document:D,variables:F,requestHeaders:P,signal:void 0}};async function h0(D,F){try{let B=await new f0(D).request(E3.getIntrospectionQuery(),void 0,new Headers(F?.map((X)=>X.split("="))));return E3.buildClientSchema(B)}catch(P){throw P}}import mb from"fs";var I7=async(D,F)=>{let P=await h0(D.url,D.headers),B=dH.printSchema(P);mb.writeFileSync(F,B)};var K3=RD(l2(),1),A3=RD(l2(),1),KD=RD(l2(),1),lb=Object.defineProperty,rH=(D,F)=>{for(var P in F)lb(D,P,{get:F[P],enumerable:!0,configurable:!0,set:(B)=>F[P]=()=>B})};class aH{collector;options;authConfig;static FieldValueWrapperType;static EnumTypesMapped;static HelperTypes;static HelperFunctions;typeMeta;typeName;originalFullTypeName;constructor(D,F,P,B){this.collector=F,this.options=P,this.authConfig=B,this.typeMeta=F.getType(D),this.originalFullTypeName=D,this.typeName=this.originalTypeNameToTypescriptFriendlyName(D)}originalTypeNameToTypescriptFriendlyName(D){return D.replaceAll("[","").replaceAll("]","Array").replaceAll("!","NotNull")}originalTypeNameToTypescriptTypeNameWithoutModifiers(D,F=""){return`${D.replaceAll("[","").replaceAll("]","").replaceAll("!","")}${F}`}originalTypeNameToTypescriptTypeName(D,F=""){return`${this.originalTypeNameToTypescriptTypeNameWithoutModifiers(D,F)}${Array.from({length:D.split("[").length-1}).fill("[]").join("")}`}static makeRootOperationFunction(D){throw Error("Method not implemented.")}}var cb=`const Proxy = globalThis.Proxy;
350
350
  Proxy.prototype = {};
@@ -355,12 +355,7 @@ function proxify(data: any, slw: any): any & ArrayLike<any> {
355
355
  get(target: any[], prop: PropertyKey, receiver: any): any {
356
356
  return Reflect.get(slw, prop, receiver);
357
357
  },
358
- set(
359
- target: any[],
360
- prop: PropertyKey,
361
- value: any,
362
- receiver: any,
363
- ): boolean {
358
+ set(target: any[], prop: PropertyKey, value: any, receiver: any): boolean {
364
359
  return Reflect.set(slw, prop, value, receiver);
365
360
  },
366
361
  has(target: any[], prop: PropertyKey): boolean {
@@ -372,10 +367,7 @@ function proxify(data: any, slw: any): any & ArrayLike<any> {
372
367
  ownKeys(target: any[]): ArrayLike<string | symbol> {
373
368
  return Reflect.ownKeys(slw);
374
369
  },
375
- getOwnPropertyDescriptor(
376
- target: any[],
377
- prop: PropertyKey,
378
- ): PropertyDescriptor | undefined {
370
+ getOwnPropertyDescriptor(target: any[], prop: PropertyKey): PropertyDescriptor | undefined {
379
371
  return Reflect.getOwnPropertyDescriptor(slw, prop);
380
372
  },
381
373
  getPrototypeOf(target: any[]): object | null {
@@ -398,9 +390,7 @@ export const _ = Symbol("_") as any;
398
390
  export const OPTIONS = Symbol("OPTIONS");
399
391
  export class RootOperation {
400
392
  public static authHeaderName = "[AUTH_HEADER_NAME]";
401
- private resolveFnOrPromisOrPrimitiveHeaders = (
402
- arg?: FnOrPromisOrPrimitive,
403
- ) => {
393
+ private resolveFnOrPromisOrPrimitiveHeaders = (arg?: FnOrPromisOrPrimitive) => {
404
394
  if (!arg) return undefined;
405
395
  let headers: Record<string, string> | undefined = undefined;
406
396
  if (typeof arg === "string") {
@@ -409,8 +399,7 @@ export class RootOperation {
409
399
  const tokenOrPromise = arg();
410
400
  if (tokenOrPromise instanceof Promise) {
411
401
  return tokenOrPromise.then((t) => {
412
- if (typeof t === "string")
413
- headers = { [RootOperation.authHeaderName]: t };
402
+ if (typeof t === "string") headers = { [RootOperation.authHeaderName]: t };
414
403
  else headers = t;
415
404
 
416
405
  return headers;
@@ -450,9 +439,7 @@ export class RootOperation {
450
439
  sseFetchTransform: undefined as unknown as (
451
440
  input: string | URL | globalThis.Request,
452
441
  init?: RequestInit,
453
- ) => Promise<
454
- [string | URL | globalThis.Request, RequestInit | undefined]
455
- >,
442
+ ) => Promise<[string | URL | globalThis.Request, RequestInit | undefined]>,
456
443
 
457
444
  _auth_fn: undefined as
458
445
  | (() => string | { [key: string]: string } | undefined)
@@ -468,10 +455,7 @@ export class RootOperation {
468
455
  };
469
456
 
470
457
  private utilSet = (obj: Record<string, any>, path: string[], value: any) =>
471
- path.reduce(
472
- (o, p, i, a) => (o[p] = a.length - 1 === i ? value : o[p] || {}),
473
- obj,
474
- );
458
+ path.reduce((o, p, i, a) => (o[p] = a.length - 1 === i ? value : o[p] || {}), obj);
475
459
 
476
460
  private rootCollector: OperationSelectionCollector | undefined = undefined;
477
461
  public registerRootCollector(collector: OperationSelectionCollector) {
@@ -482,16 +466,12 @@ export class RootOperation {
482
466
  throw new Error("RootOperation has no registered collector");
483
467
  }
484
468
 
485
- const authHeaders =
486
- await this.rootCollector.op!.resolveFnOrPromisOrPrimitiveHeaders(
487
- this.rootCollector.op!.authArg ??
488
- RootOperation[OPTIONS]._auth_fn,
489
- );
490
- const headersHeaders =
491
- await this.rootCollector.op!.resolveFnOrPromisOrPrimitiveHeaders(
492
- this.rootCollector.op!.headers ??
493
- RootOperation[OPTIONS].headers,
494
- );
469
+ const authHeaders = await this.rootCollector.op!.resolveFnOrPromisOrPrimitiveHeaders(
470
+ this.rootCollector.op!.authArg ?? RootOperation[OPTIONS]._auth_fn,
471
+ );
472
+ const headersHeaders = await this.rootCollector.op!.resolveFnOrPromisOrPrimitiveHeaders(
473
+ this.rootCollector.op!.headers ?? RootOperation[OPTIONS].headers,
474
+ );
495
475
 
496
476
  headers = {
497
477
  ...authHeaders,
@@ -499,19 +479,14 @@ export class RootOperation {
499
479
  ...headers,
500
480
  };
501
481
 
502
- type selection = ReturnType<
503
- typeof OperationSelectionCollector.prototype.renderSelections
504
- >;
482
+ type selection = ReturnType<typeof OperationSelectionCollector.prototype.renderSelections>;
505
483
  const operations: {
506
484
  [key: string]: {
507
485
  selection: selection;
508
486
  rootSlw: SelectionWrapperImpl<string, string, number, any>;
509
487
  };
510
488
  } = {};
511
- for (const [
512
- opName,
513
- opSelection,
514
- ] of this.rootCollector?.selections.entries()) {
489
+ for (const [opName, opSelection] of this.rootCollector?.selections.entries()) {
515
490
  if (opSelection[SLW_LAZY_FLAG]) continue;
516
491
 
517
492
  let rootSlw = opSelection;
@@ -537,14 +512,9 @@ export class RootOperation {
537
512
  (acc, [opName, { selection, rootSlw }]) => ({
538
513
  ...acc,
539
514
  [opName]: {
540
- opType: rootSlw[SLW_IS_ROOT_TYPE]?.toLowerCase() as
541
- | "subscription"
542
- | "query"
543
- | "mutation",
515
+ opType: rootSlw[SLW_IS_ROOT_TYPE]?.toLowerCase() as "subscription" | "query" | "mutation",
544
516
  query: \`\${rootSlw[SLW_IS_ROOT_TYPE]?.toLowerCase()} \${opName} \${
545
- selection.variableDefinitions.length
546
- ? \`(\${selection.variableDefinitions.join(", ")}) \`
547
- : ""
517
+ selection.variableDefinitions.length ? \`(\${selection.variableDefinitions.join(", ")}) \` : ""
548
518
  }\${selection.selection}\`,
549
519
  variables: selection.variables,
550
520
  fragments: selection.usedFragments,
@@ -590,8 +560,7 @@ export class RootOperation {
590
560
  const that = this;
591
561
  const generator = (async function* () {
592
562
  const [url, options] = (await (
593
- RootOperation[OPTIONS].sseFetchTransform ??
594
- ((url: string, options?: RequestInit) => [url, options])
563
+ RootOperation[OPTIONS].sseFetchTransform ?? ((url: string, options?: RequestInit) => [url, options])
595
564
  )("http://localhost:4000/graphql", {
596
565
  method: "POST",
597
566
  headers: {
@@ -630,8 +599,7 @@ export class RootOperation {
630
599
  const eventName = event.match(/^event: (.*)$/m)?.[1];
631
600
  const rawdata = event.match(/^data: (.*)$/m)?.[1];
632
601
 
633
- if ((eventName === null && rawdata === "") || !rawdata)
634
- continue;
602
+ if ((eventName === null && rawdata === "") || !rawdata) continue;
635
603
  if (eventName === "complete" || done) break;
636
604
 
637
605
  const parsed = JSON.parse(rawdata) as {
@@ -673,20 +641,17 @@ export class RootOperation {
673
641
  },
674
642
  headers: Record<string, string> = {},
675
643
  ) {
676
- const res = await (RootOperation[OPTIONS].fetcher ?? globalThis.fetch)(
677
- "[ENDPOINT]",
678
- {
679
- method: "POST",
680
- headers: {
681
- "Content-Type": "application/json",
682
- ...headers,
683
- },
684
- body: JSON.stringify({
685
- query: \`\${[...query.fragments.values()].join("\\n")}\\n \${query.query}\`.trim(),
686
- variables: query.variables,
687
- }),
644
+ const res = await (RootOperation[OPTIONS].fetcher ?? globalThis.fetch)("[ENDPOINT]", {
645
+ method: "POST",
646
+ headers: {
647
+ "Content-Type": "application/json",
648
+ ...headers,
688
649
  },
689
- );
650
+ body: JSON.stringify({
651
+ query: \`\${[...query.fragments.values()].join("\\n")}\\n \${query.query}\`.trim(),
652
+ variables: query.variables,
653
+ }),
654
+ });
690
655
  const result = (await res.json()) as { data: any; errors: any[] };
691
656
 
692
657
  const { data, errors } = result ?? {};
@@ -713,9 +678,7 @@ export type OperationSelectionCollectorRef = {
713
678
  export class OperationSelectionCollector {
714
679
  constructor(
715
680
  public readonly name?: string,
716
- public readonly parent?:
717
- | OperationSelectionCollector
718
- | OperationSelectionCollectorRef,
681
+ public readonly parent?: OperationSelectionCollector | OperationSelectionCollectorRef,
719
682
  public readonly op?: RootOperation,
720
683
  ) {
721
684
  if (op) op.registerRootCollector(this);
@@ -734,9 +697,7 @@ export class OperationSelectionCollector {
734
697
 
735
698
  public async execute(headers?: Record<string, string>) {
736
699
  if (!this.op) {
737
- throw new Error(
738
- "OperationSelectionCollector is not registered to a root operation",
739
- );
700
+ throw new Error("OperationSelectionCollector is not registered to a root operation");
740
701
  }
741
702
  this.operationResult = await this.op.execute(headers);
742
703
  this.executed = true;
@@ -746,14 +707,8 @@ export class OperationSelectionCollector {
746
707
  return this.executed;
747
708
  }
748
709
 
749
- public readonly selections = new Map<
750
- string,
751
- SelectionWrapperImpl<string, string, number, any>
752
- >();
753
- public registerSelection(
754
- id: string,
755
- selection: SelectionWrapperImpl<string, string, number, any, any>,
756
- ) {
710
+ public readonly selections = new Map<string, SelectionWrapperImpl<string, string, number, any>>();
711
+ public registerSelection(id: string, selection: SelectionWrapperImpl<string, string, number, any, any>) {
757
712
  this.selections.set(id, selection);
758
713
  }
759
714
 
@@ -761,12 +716,7 @@ export class OperationSelectionCollector {
761
716
  path: string[] = [],
762
717
  opVars: Record<string, any> = {},
763
718
  usedFragments: Map<string, string> = new Map(),
764
- renderOnlyTheseSelections: SelectionWrapperImpl<
765
- string,
766
- string,
767
- number,
768
- any
769
- >[] = [],
719
+ renderOnlyTheseSelections: SelectionWrapperImpl<string, string, number, any>[] = [],
770
720
  ) {
771
721
  const result: Record<string, string | undefined> = {};
772
722
  const varDefs: string[] = [];
@@ -775,9 +725,7 @@ export class OperationSelectionCollector {
775
725
  for (const [key, value] of [...this.selections.entries()].filter(
776
726
  ([k, v]) =>
777
727
  renderOnlyTheseSelections.length === 0 ||
778
- renderOnlyTheseSelections.find(
779
- (r) => r[SLW_UID] === v[SLW_UID],
780
- ),
728
+ renderOnlyTheseSelections.find((r) => r[SLW_UID] === v[SLW_UID]),
781
729
  )) {
782
730
  const subPath = [...path, key];
783
731
  const {
@@ -793,10 +741,7 @@ export class OperationSelectionCollector {
793
741
  varDefs.push(...fieldVarDefs);
794
742
 
795
743
  if (directiveRendered) {
796
- const {
797
- variableDefinitions: directiveVarDefs,
798
- variables: directiveVars,
799
- } = directiveRendered;
744
+ const { variableDefinitions: directiveVarDefs, variables: directiveVars } = directiveRendered;
800
745
 
801
746
  varDefs.push(...directiveVarDefs);
802
747
  Object.assign(variables, directiveVars);
@@ -807,38 +752,29 @@ export class OperationSelectionCollector {
807
752
 
808
753
  if (value[SLW_PARENT_COLLECTOR] === undefined) {
809
754
  if (directiveRendered) {
810
- result[key] =
811
- \`\${fieldSelection} \${directiveRendered.rendered}\`;
755
+ result[key] = \`\${fieldSelection} \${directiveRendered.rendered}\`;
812
756
  } else {
813
757
  result[key] = fieldSelection;
814
758
  }
815
- } else if (
816
- value[SLW_COLLECTOR] instanceof OperationSelectionCollector
817
- ) {
759
+ } else if (value[SLW_COLLECTOR] instanceof OperationSelectionCollector) {
818
760
  const {
819
761
  selection: subSelection,
820
762
  variableDefinitions: subVarDefs,
821
763
  variables: subVars,
822
- } = value[SLW_COLLECTOR].renderSelections(
823
- subPath,
824
- opVars,
825
- usedFragments,
826
- );
764
+ } = value[SLW_COLLECTOR].renderSelections(subPath, opVars, usedFragments);
827
765
 
828
766
  if (value[SLW_IS_ON_TYPE_FRAGMENT]) {
829
767
  if (directiveRendered) {
830
768
  result[key] =
831
769
  \`... on \${value[SLW_IS_ON_TYPE_FRAGMENT]} \${directiveRendered.rendered} \${subSelection}\`;
832
770
  } else {
833
- result[key] =
834
- \`... on \${value[SLW_IS_ON_TYPE_FRAGMENT]} \${subSelection}\`;
771
+ result[key] = \`... on \${value[SLW_IS_ON_TYPE_FRAGMENT]} \${subSelection}\`;
835
772
  }
836
773
  } else if (value[SLW_IS_FRAGMENT]) {
837
774
  const fragmentName = \`\${key}_\${subVarDefs.map((v) => v.split(":")[0].slice(1)).join("_")}\`;
838
775
 
839
776
  if (directiveRendered) {
840
- result[key] =
841
- \`...\${fragmentName} \${directiveRendered.rendered}\`;
777
+ result[key] = \`...\${fragmentName} \${directiveRendered.rendered}\`;
842
778
  } else {
843
779
  result[key] = \`...\${fragmentName}\`;
844
780
  }
@@ -847,14 +783,11 @@ export class OperationSelectionCollector {
847
783
  if (!usedFragments.has(fragmentName)) {
848
784
  usedFragments.set(fragmentName, fragment);
849
785
  } else if (usedFragments.get(fragmentName) !== fragment) {
850
- console.warn(
851
- \`Fragment \${fragmentName} is already defined with a different selection\`,
852
- );
786
+ console.warn(\`Fragment \${fragmentName} is already defined with a different selection\`);
853
787
  }
854
788
  } else {
855
789
  if (directiveRendered) {
856
- result[key] =
857
- \`\${fieldSelection} \${directiveRendered.rendered} \${subSelection}\`;
790
+ result[key] = \`\${fieldSelection} \${directiveRendered.rendered} \${subSelection}\`;
858
791
  } else {
859
792
  result[key] = \`\${fieldSelection} \${subSelection}\`;
860
793
  }
@@ -866,11 +799,8 @@ export class OperationSelectionCollector {
866
799
  }
867
800
  }
868
801
  let rendered = "{ ";
869
- for (const [key, value] of Object.entries(result).filter(
870
- ([k, v]) => v !== undefined,
871
- ) as [string, string][]) {
872
- const keyIsFieldName =
873
- value.startsWith(\`\${key} {\`) || value.startsWith(\`\${key} (\`);
802
+ for (const [key, value] of Object.entries(result).filter(([k, v]) => v !== undefined) as [string, string][]) {
803
+ const keyIsFieldName = value.startsWith(\`\${key} {\`) || value.startsWith(\`\${key} (\`);
874
804
  const isSubSelection = value.startsWith("{");
875
805
  const isOnType = value.startsWith("... on");
876
806
  const isFragment = value.startsWith("...");
@@ -891,17 +821,10 @@ export class OperationSelectionCollector {
891
821
  };
892
822
  }
893
823
 
894
- private utilGet = (obj: Record<string, any>, path: (string | number)[]) =>
895
- path.reduce((o, p) => o?.[p], obj);
896
- public getOperationResultPath<T>(
897
- path: (string | number)[] = [],
898
- _type?: string,
899
- opResultDataOverride?: any,
900
- ): T {
824
+ private utilGet = (obj: Record<string, any>, path: (string | number)[]) => path.reduce((o, p) => o?.[p], obj);
825
+ public getOperationResultPath<T>(path: (string | number)[] = [], _type?: string, opResultDataOverride?: any): T {
901
826
  if (!this.op) {
902
- throw new Error(
903
- "OperationSelectionCollector is not registered to a root operation",
904
- );
827
+ throw new Error("OperationSelectionCollector is not registered to a root operation");
905
828
  }
906
829
 
907
830
  let result = opResultDataOverride ?? this.operationResult;
@@ -920,25 +843,18 @@ export class OperationSelectionCollector {
920
843
  depth++;
921
844
  }
922
845
 
923
- const deepParse = (
924
- res: any | any[],
925
- depth: number,
926
- parse: (v: string) => any,
927
- ) => {
846
+ const deepParse = (res: any | any[], depth: number, parse: (v: string) => any) => {
928
847
  if (depth === 0) {
929
848
  return parse(res);
930
849
  }
931
- return res.map((rarr: any) =>
932
- deepParse(rarr, depth - 1, parse),
933
- );
850
+ return res.map((rarr: any) => deepParse(rarr, depth - 1, parse));
934
851
  };
935
852
 
936
853
  return deepParse(
937
854
  finalResult,
938
855
  depth,
939
- RootOperation[OPTIONS].scalars[
940
- type as keyof (typeof RootOperation)[typeof OPTIONS]["scalars"]
941
- ] ?? ((value: string) => JSON.parse(value)),
856
+ RootOperation[OPTIONS].scalars[type as keyof (typeof RootOperation)[typeof OPTIONS]["scalars"]] ??
857
+ ((value: string) => JSON.parse(value)),
942
858
  ) as T;
943
859
  }
944
860
 
@@ -970,13 +886,9 @@ export const SLW_OP_PATH = Symbol("SLW_OP_PATH");
970
886
  export const SLW_REGISTER_PATH = Symbol("SLW_REGISTER_PATH");
971
887
  export const SLW_RENDER_WITH_ARGS = Symbol("SLW_RENDER_WITH_ARGS");
972
888
 
973
- export const SLW_OP_RESULT_DATA_OVERRIDE = Symbol(
974
- "SLW_OP_RESULT_DATA_OVERRIDE",
975
- );
889
+ export const SLW_OP_RESULT_DATA_OVERRIDE = Symbol("SLW_OP_RESULT_DATA_OVERRIDE");
976
890
 
977
- export const SLW_RECREATE_VALUE_CALLBACK = Symbol(
978
- "SLW_RECREATE_VALUE_CALLBACK",
979
- );
891
+ export const SLW_RECREATE_VALUE_CALLBACK = Symbol("SLW_RECREATE_VALUE_CALLBACK");
980
892
  export const SLW_SETTER_DATA_OVERRIDE = Symbol("SLW_SETTER_DATA_OVERRIDE");
981
893
  export const SLW_NEEDS_CLONE = Symbol("SLW_NEEDS_CLONE");
982
894
 
@@ -990,10 +902,7 @@ export class SelectionWrapperImpl<
990
902
  argsT extends Record<string, any> | undefined = undefined,
991
903
  > {
992
904
  private generateUniqueId(): string {
993
- return (
994
- performance.now().toString(36) +
995
- Math.random().toString(36).substring(2)
996
- );
905
+ return performance.now().toString(36) + Math.random().toString(36).substring(2);
997
906
  }
998
907
  [SLW_CLONE](
999
908
  overrides: {
@@ -1019,15 +928,9 @@ export class SelectionWrapperImpl<
1019
928
  slw[SLW_IS_FRAGMENT] = this[SLW_IS_FRAGMENT];
1020
929
  slw[SLW_PARENT_SLW] = this[SLW_PARENT_SLW];
1021
930
  slw[SLW_OP_PATH] = overrides.SLW_OP_PATH ?? this[SLW_OP_PATH];
1022
- slw[SLW_SETTER_DATA_OVERRIDE] =
1023
- overrides.SLW_SETTER_DATA_OVERRIDE ??
1024
- this[SLW_SETTER_DATA_OVERRIDE];
931
+ slw[SLW_SETTER_DATA_OVERRIDE] = overrides.SLW_SETTER_DATA_OVERRIDE ?? this[SLW_SETTER_DATA_OVERRIDE];
1025
932
 
1026
- slw[SLW_NEEDS_CLONE] = overrides.SLW_NEEDS_CLONE
1027
- ? true
1028
- : this[SLW_NEEDS_CLONE]
1029
- ? false
1030
- : true;
933
+ slw[SLW_NEEDS_CLONE] = overrides.SLW_NEEDS_CLONE ? true : this[SLW_NEEDS_CLONE] ? false : true;
1031
934
 
1032
935
  if (overrides.OP_RESULT_DATA) {
1033
936
  slw[SLW_OP_RESULT_DATA_OVERRIDE] = overrides.OP_RESULT_DATA;
@@ -1093,9 +996,7 @@ export class SelectionWrapperImpl<
1093
996
  this[SLW_COLLECTOR] = collector;
1094
997
 
1095
998
  let rootCollector = collector;
1096
- while (
1097
- rootCollector?.parent instanceof OperationSelectionCollector
1098
- ) {
999
+ while (rootCollector?.parent instanceof OperationSelectionCollector) {
1099
1000
  rootCollector = rootCollector.parent;
1100
1001
  }
1101
1002
  if (rootCollector.parent && "ref" in rootCollector.parent) {
@@ -1113,20 +1014,14 @@ export class SelectionWrapperImpl<
1113
1014
  if (!this[SLW_OP_PATH]) this[SLW_OP_PATH] = path.join(".");
1114
1015
  }
1115
1016
  [SLW_RENDER_WITH_ARGS](opVars: Record<string, any> = {}) {
1116
- const renderArgsString = (
1117
- args: Record<string, any>,
1118
- argsMeta: Record<string, string>,
1119
- ) => {
1017
+ const renderArgsString = (args: Record<string, any>, argsMeta: Record<string, string>) => {
1120
1018
  const argToVarMap: Record<string, string> = {};
1121
1019
  let argsString = "(";
1122
1020
  const argsStringParts: string[] = [];
1123
1021
  for (const key of Object.keys(args)) {
1124
1022
  let varName = key;
1125
1023
  if (opVars[key] !== undefined) {
1126
- varName = \`\${key}_\${
1127
- Object.keys(opVars).filter((k) => k.startsWith(key))
1128
- .length
1129
- }\`;
1024
+ varName = \`\${key}_\${Object.keys(opVars).filter((k) => k.startsWith(key)).length}\`;
1130
1025
  argToVarMap[varName] = varName;
1131
1026
  args[varName] = args[key];
1132
1027
  argsMeta[varName] = argsMeta[key];
@@ -1150,19 +1045,14 @@ export class SelectionWrapperImpl<
1150
1045
  const args = this[SLW_DIRECTIVE_ARGS];
1151
1046
  const argsMeta = this[SLW_DIRECTIVE_ARGS_META]!;
1152
1047
 
1153
- const { argsString, argToVarMap } = renderArgsString(
1154
- args,
1155
- argsMeta,
1156
- );
1048
+ const { argsString, argToVarMap } = renderArgsString(args, argsMeta);
1157
1049
 
1158
1050
  directiveRender.rendered = \`@\${directive}\${Object.keys(args).length ? argsString : ""}\`;
1159
1051
  directiveRender.variables = args;
1160
- directiveRender.variableDefinitions = Object.keys(args).map(
1161
- (key) => {
1162
- const varName = argToVarMap[key] ?? key;
1163
- return \`$\${varName}: \${argsMeta[key]}\`;
1164
- },
1165
- );
1052
+ directiveRender.variableDefinitions = Object.keys(args).map((key) => {
1053
+ const varName = argToVarMap[key] ?? key;
1054
+ return \`$\${varName}: \${argsMeta[key]}\`;
1055
+ });
1166
1056
  } else {
1167
1057
  directiveRender.rendered = \`@\${directive}\`;
1168
1058
  }
@@ -1172,10 +1062,7 @@ export class SelectionWrapperImpl<
1172
1062
  const args = this[SLW_ARGS];
1173
1063
  const argsMeta = this[SLW_ARGS_META]!;
1174
1064
 
1175
- const { argsString, argToVarMap } = renderArgsString(
1176
- args,
1177
- argsMeta,
1178
- );
1065
+ const { argsString, argToVarMap } = renderArgsString(args, argsMeta);
1179
1066
  return {
1180
1067
  selection: \`\${this[SLW_FIELD_NAME]}\${Object.keys(args).length ? argsString : ""}\`,
1181
1068
  variables: args,
@@ -1184,9 +1071,7 @@ export class SelectionWrapperImpl<
1184
1071
  return \`$\${varName}: \${argsMeta[key]}\`;
1185
1072
  }),
1186
1073
 
1187
- directive: directiveRender.rendered
1188
- ? directiveRender
1189
- : undefined,
1074
+ directive: directiveRender.rendered ? directiveRender : undefined,
1190
1075
  };
1191
1076
  }
1192
1077
  return {
@@ -1204,9 +1089,7 @@ export class SelectionWrapper<
1204
1089
  typeArrDepth extends number,
1205
1090
  valueT extends any = any,
1206
1091
  argsT extends Record<string, any> | undefined = undefined,
1207
- > extends Proxy<
1208
- SelectionWrapperImpl<fieldName, typeNamePure, typeArrDepth, valueT, argsT>
1209
- > {
1092
+ > extends Proxy<SelectionWrapperImpl<fieldName, typeNamePure, typeArrDepth, valueT, argsT>> {
1210
1093
  constructor(
1211
1094
  fieldName?: fieldName,
1212
1095
  typeNamePure?: typeNamePure,
@@ -1219,13 +1102,7 @@ export class SelectionWrapper<
1219
1102
  reCreateValueCallback?: () => valueT,
1220
1103
  ) {
1221
1104
  super(
1222
- new SelectionWrapperImpl<
1223
- fieldName,
1224
- typeNamePure,
1225
- typeArrDepth,
1226
- valueT,
1227
- argsT
1228
- >(
1105
+ new SelectionWrapperImpl<fieldName, typeNamePure, typeArrDepth, valueT, argsT>(
1229
1106
  fieldName,
1230
1107
  typeNamePure,
1231
1108
  typeArrDepth,
@@ -1237,43 +1114,27 @@ export class SelectionWrapper<
1237
1114
  reCreateValueCallback,
1238
1115
  ),
1239
1116
  (() => {
1240
- const getCache = (
1241
- t: SelectionWrapperImpl<
1242
- fieldName,
1243
- typeNamePure,
1244
- typeArrDepth,
1245
- valueT,
1246
- argsT
1247
- >,
1248
- ) => t[ROOT_OP_COLLECTOR]!.ref.cache;
1117
+ const getCache = (t: SelectionWrapperImpl<fieldName, typeNamePure, typeArrDepth, valueT, argsT>) =>
1118
+ t[SLW_OP_RESULT_DATA_OVERRIDE]
1119
+ ? { data: new Map(), proxiedArray: new Map() }
1120
+ : t[ROOT_OP_COLLECTOR]!.ref.cache;
1249
1121
 
1250
1122
  const getResultDataForTarget = (
1251
- t: SelectionWrapperImpl<
1252
- fieldName,
1253
- typeNamePure,
1254
- typeArrDepth,
1255
- valueT,
1256
- argsT
1257
- >,
1123
+ t: SelectionWrapperImpl<fieldName, typeNamePure, typeArrDepth, valueT, argsT>,
1258
1124
  overrideOpPath?: string,
1259
1125
  ): valueT | undefined => {
1260
1126
  const cache = getCache(t);
1261
1127
 
1262
- const path = overrideOpPath ?? t[SLW_OP_PATH] ?? "";
1263
- if (cache.data.has(path) && !t[SLW_NEEDS_CLONE])
1264
- return cache.data.get(path);
1128
+ const path = overrideOpPath ?? t[SLW_OP_PATH] ?? undefined;
1129
+ if (path && cache.data.has(path) && !t[SLW_NEEDS_CLONE]) return cache.data.get(path);
1265
1130
 
1266
- const data = t[
1267
- ROOT_OP_COLLECTOR
1268
- ]!.ref.getOperationResultPath<valueT>(
1269
- (path?.split(".") ?? []).map((p) =>
1270
- !isNaN(+p) ? +p : p,
1271
- ),
1131
+ const data = t[ROOT_OP_COLLECTOR]!.ref.getOperationResultPath<valueT>(
1132
+ (path?.split(".") ?? []).map((p) => (!isNaN(+p) ? +p : p)),
1272
1133
  t[SLW_FIELD_TYPENAME],
1273
1134
  t[SLW_OP_RESULT_DATA_OVERRIDE],
1274
1135
  );
1275
1136
 
1276
- cache.data.set(path, data);
1137
+ if (path) cache.data.set(path, data);
1277
1138
  return data;
1278
1139
  };
1279
1140
 
@@ -1283,19 +1144,14 @@ export class SelectionWrapper<
1283
1144
  return Reflect.ownKeys(value ?? {});
1284
1145
  },
1285
1146
  getOwnPropertyDescriptor(target, prop) {
1286
- return Reflect.getOwnPropertyDescriptor(
1287
- value ?? {},
1288
- prop,
1289
- );
1147
+ return Reflect.getOwnPropertyDescriptor(value ?? {}, prop);
1290
1148
  },
1291
1149
  has(target, prop) {
1292
- if (prop === Symbol.for("nodejs.util.inspect.custom"))
1293
- return true;
1150
+ if (prop === Symbol.for("nodejs.util.inspect.custom")) return true;
1294
1151
  if (prop === Symbol.iterator && typeArrDepth) {
1295
1152
  const dataArr = getResultDataForTarget(target);
1296
1153
  if (Array.isArray(dataArr)) return true;
1297
- if (dataArr === undefined || dataArr === null)
1298
- return false;
1154
+ if (dataArr === undefined || dataArr === null) return false;
1299
1155
  }
1300
1156
 
1301
1157
  return Reflect.has(value ?? {}, prop);
@@ -1304,8 +1160,7 @@ export class SelectionWrapper<
1304
1160
  const pstr = String(p);
1305
1161
  if (
1306
1162
  typeof p === "symbol" &&
1307
- (pstr.startsWith("Symbol(SLW_") ||
1308
- pstr == "Symbol(ROOT_OP_COLLECTOR)")
1163
+ (pstr.startsWith("Symbol(SLW_") || pstr == "Symbol(ROOT_OP_COLLECTOR)")
1309
1164
  ) {
1310
1165
  return Reflect.set(target, p, newValue, receiver);
1311
1166
  }
@@ -1320,10 +1175,7 @@ export class SelectionWrapper<
1320
1175
  );
1321
1176
  },
1322
1177
  get: (target, prop) => {
1323
- if (
1324
- target[SLW_SETTER_DATA_OVERRIDE] &&
1325
- target[SLW_SETTER_DATA_OVERRIDE][prop]
1326
- ) {
1178
+ if (target[SLW_SETTER_DATA_OVERRIDE] && target[SLW_SETTER_DATA_OVERRIDE][prop]) {
1327
1179
  return target[SLW_SETTER_DATA_OVERRIDE][prop];
1328
1180
  }
1329
1181
  if (prop === "$lazy") {
@@ -1347,25 +1199,17 @@ export class SelectionWrapper<
1347
1199
  undefined,
1348
1200
  undefined,
1349
1201
  new RootOperation(
1350
- that[
1351
- ROOT_OP_COLLECTOR
1352
- ]!.ref.op!.authArg,
1353
- that[
1354
- ROOT_OP_COLLECTOR
1355
- ]!.ref.op!.headers,
1202
+ that[ROOT_OP_COLLECTOR]!.ref.op!.authArg,
1203
+ that[ROOT_OP_COLLECTOR]!.ref.op!.headers,
1356
1204
  ),
1357
1205
  ),
1358
1206
  };
1359
1207
 
1360
- const newThisCollector =
1361
- new OperationSelectionCollector(
1362
- undefined,
1363
- newRootOpCollectorRef,
1364
- );
1365
- const r =
1366
- that[SLW_RECREATE_VALUE_CALLBACK]?.bind(
1367
- newThisCollector,
1368
- )?.() ?? {};
1208
+ const newThisCollector = new OperationSelectionCollector(
1209
+ undefined,
1210
+ newRootOpCollectorRef,
1211
+ );
1212
+ const r = that[SLW_RECREATE_VALUE_CALLBACK]?.bind(newThisCollector)?.() ?? {};
1369
1213
 
1370
1214
  const newThat = new SelectionWrapper(
1371
1215
  that[SLW_FIELD_NAME],
@@ -1376,33 +1220,20 @@ export class SelectionWrapper<
1376
1220
  // only set parent collector, if 'that' had one,
1377
1221
  // the absence indicates, that 'that' is a scalar field
1378
1222
  // without a subselection!
1379
- that[SLW_PARENT_COLLECTOR]
1380
- ? newRootOpCollectorRef
1381
- : undefined,
1223
+ that[SLW_PARENT_COLLECTOR] ? newRootOpCollectorRef : undefined,
1382
1224
  that[SLW_ARGS],
1383
1225
  that[SLW_ARGS_META],
1384
1226
  );
1385
1227
  newThat[SLW_UID] = that[SLW_UID];
1386
1228
 
1387
- Object.keys(r!).forEach(
1388
- (key) =>
1389
- (newThat as valueT)[
1390
- key as keyof valueT
1391
- ],
1392
- );
1229
+ Object.keys(r!).forEach((key) => (newThat as valueT)[key as keyof valueT]);
1393
1230
 
1394
- newThat[SLW_IS_ROOT_TYPE] =
1395
- that[SLW_IS_ROOT_TYPE];
1396
- newThat[SLW_IS_ON_TYPE_FRAGMENT] =
1397
- that[SLW_IS_ON_TYPE_FRAGMENT];
1398
- newThat[SLW_IS_FRAGMENT] =
1399
- that[SLW_IS_FRAGMENT];
1231
+ newThat[SLW_IS_ROOT_TYPE] = that[SLW_IS_ROOT_TYPE];
1232
+ newThat[SLW_IS_ON_TYPE_FRAGMENT] = that[SLW_IS_ON_TYPE_FRAGMENT];
1233
+ newThat[SLW_IS_FRAGMENT] = that[SLW_IS_FRAGMENT];
1400
1234
 
1401
1235
  newThat[SLW_PARENT_SLW] = parentSlw;
1402
- parentSlw[SLW_COLLECTOR]?.registerSelection(
1403
- key,
1404
- newThat,
1405
- );
1236
+ parentSlw[SLW_COLLECTOR]?.registerSelection(key, newThat);
1406
1237
  newThat[SLW_ARGS] = {
1407
1238
  ...(that[SLW_ARGS] ?? {}),
1408
1239
  ...args,
@@ -1410,41 +1241,30 @@ export class SelectionWrapper<
1410
1241
 
1411
1242
  newThat[SLW_OP_PATH] = that[SLW_OP_PATH];
1412
1243
 
1413
- newRootOpCollectorRef.ref.registerSelection(
1414
- newThat[SLW_FIELD_NAME]!,
1415
- newThat,
1416
- );
1244
+ newRootOpCollectorRef.ref.registerSelection(newThat[SLW_FIELD_NAME]!, newThat);
1417
1245
 
1418
1246
  const resultProxy = new Proxy(
1419
1247
  {},
1420
1248
  {
1421
1249
  get(_t, _prop) {
1422
- const result = new Promise(
1423
- (resolve, reject) => {
1424
- newRootOpCollectorRef.ref
1425
- .execute()
1426
- .catch(reject)
1427
- .then((_data) => {
1428
- const data =
1429
- _data[
1430
- newThat[
1431
- SLW_FIELD_NAME
1432
- ]
1433
- ][
1434
- newThat[
1435
- SLW_FIELD_NAME
1436
- ]
1437
- ];
1438
-
1439
- resolve(
1440
- proxify(
1441
- data,
1442
- newThat as any,
1443
- ),
1444
- );
1445
- });
1446
- },
1447
- );
1250
+ const result = new Promise((resolve, reject) => {
1251
+ newRootOpCollectorRef.ref
1252
+ .execute()
1253
+ .catch(reject)
1254
+ .then((_data) => {
1255
+ const fieldName = newThat[SLW_FIELD_NAME]!;
1256
+ const d = _data[fieldName];
1257
+
1258
+ if (Symbol.asyncIterator in d) {
1259
+ return resolve(newThat);
1260
+ }
1261
+ if (typeof d === "object" && d && fieldName in d) {
1262
+ return resolve(proxify(d[fieldName], newThat as any));
1263
+ }
1264
+
1265
+ return resolve(proxify(d, newThat as any));
1266
+ });
1267
+ });
1448
1268
  if (String(_prop) === "then") {
1449
1269
  return result.then.bind(result);
1450
1270
  }
@@ -1458,12 +1278,8 @@ export class SelectionWrapper<
1458
1278
  {
1459
1279
  get(_t, _prop) {
1460
1280
  if (String(_prop) === "auth") {
1461
- return (
1462
- auth: FnOrPromisOrPrimitive,
1463
- ) => {
1464
- newRootOpCollectorRef.ref.op!.setAuth(
1465
- auth,
1466
- );
1281
+ return (auth: FnOrPromisOrPrimitive) => {
1282
+ newRootOpCollectorRef.ref.op!.setAuth(auth);
1467
1283
  return resultProxy;
1468
1284
  };
1469
1285
  }
@@ -1505,12 +1321,7 @@ export class SelectionWrapper<
1505
1321
  prop === SLW_NEEDS_CLONE
1506
1322
  ) {
1507
1323
  return target[
1508
- prop as keyof SelectionWrapperImpl<
1509
- fieldName,
1510
- typeNamePure,
1511
- typeArrDepth,
1512
- valueT
1513
- >
1324
+ prop as keyof SelectionWrapperImpl<fieldName, typeNamePure, typeArrDepth, valueT>
1514
1325
  ];
1515
1326
  }
1516
1327
  if (prop === SLW_VALUE) {
@@ -1520,41 +1331,35 @@ export class SelectionWrapper<
1520
1331
  return this;
1521
1332
  }
1522
1333
 
1523
- let slw_value = target[SLW_VALUE] as
1524
- | Record<string, any>
1525
- | undefined;
1334
+ let slw_value = target[SLW_VALUE] as Record<string, any> | undefined;
1526
1335
 
1527
1336
  if (target[ROOT_OP_COLLECTOR]?.ref.isExecuted) {
1528
1337
  if (prop === Symbol.asyncIterator) {
1529
- const asyncGenRootPath =
1530
- target[SLW_OP_PATH]?.split(".")?.[0];
1531
- const asyncGen = getResultDataForTarget(
1532
- target,
1533
- asyncGenRootPath,
1534
- ) as AsyncGenerator<valueT, any, any>;
1338
+ const asyncGenRootPath = target[SLW_OP_PATH]?.split(".")?.[0];
1339
+ const asyncGen = getResultDataForTarget(target, asyncGenRootPath) as AsyncGenerator<
1340
+ valueT,
1341
+ any,
1342
+ any
1343
+ >;
1535
1344
 
1536
1345
  return function () {
1537
1346
  return {
1538
1347
  next() {
1539
- return asyncGen
1540
- .next()
1541
- .then((val) => {
1542
- return {
1543
- done: val.done,
1544
- value: proxify(
1545
- val.value,
1546
- target[SLW_CLONE]({
1547
- SLW_OP_PATH:
1548
- asyncGenRootPath,
1549
- OP_RESULT_DATA:
1550
- val.value,
1551
-
1552
- // this is only for subscriptions
1553
- SLW_NEEDS_CLONE: true,
1554
- }),
1555
- ),
1556
- };
1557
- });
1348
+ return asyncGen.next().then((val) => {
1349
+ return {
1350
+ done: val.done,
1351
+ value: proxify(
1352
+ val.value,
1353
+ target[SLW_CLONE]({
1354
+ SLW_OP_PATH: asyncGenRootPath,
1355
+ OP_RESULT_DATA: val.value,
1356
+
1357
+ // this is only for subscriptions
1358
+ SLW_NEEDS_CLONE: true,
1359
+ }),
1360
+ ),
1361
+ };
1362
+ });
1558
1363
  },
1559
1364
  };
1560
1365
  };
@@ -1568,17 +1373,10 @@ export class SelectionWrapper<
1568
1373
  if (typeArrDepth && Array.isArray(_data)) {
1569
1374
  if (!isNaN(+String(prop))) {
1570
1375
  const elm = target[SLW_CLONE]({
1571
- SLW_OP_PATH:
1572
- path + "." + String(prop),
1573
- OP_RESULT_DATA:
1574
- target[
1575
- SLW_OP_RESULT_DATA_OVERRIDE
1576
- ],
1376
+ SLW_OP_PATH: path + "." + String(prop),
1377
+ OP_RESULT_DATA: target[SLW_OP_RESULT_DATA_OVERRIDE],
1577
1378
  });
1578
- return proxify(
1579
- _data[Number(prop)],
1580
- elm,
1581
- );
1379
+ return proxify(_data[Number(prop)], elm);
1582
1380
  }
1583
1381
 
1584
1382
  const data = _data as valueT[] | undefined;
@@ -1587,42 +1385,30 @@ export class SelectionWrapper<
1587
1385
  const cache = getCache(target);
1588
1386
 
1589
1387
  const proxiedData =
1590
- cache.proxiedArray.get(
1591
- target[SLW_OP_PATH]!,
1592
- ) ??
1593
- Array.from(
1594
- { length: data.length },
1595
- (_, i) =>
1596
- proxify(
1597
- data[i],
1598
- target[SLW_CLONE]({
1599
- SLW_OP_PATH:
1600
- target[
1601
- SLW_OP_PATH
1602
- ] +
1603
- "." +
1604
- String(i),
1605
- OP_RESULT_DATA:
1606
- target[
1607
- SLW_OP_RESULT_DATA_OVERRIDE
1608
- ],
1609
- }),
1610
- ),
1388
+ cache.proxiedArray.get(target[SLW_OP_PATH]!) ??
1389
+ Array.from({ length: data.length }, (_, i) =>
1390
+ typeof data[i] === "object"
1391
+ ? proxify(
1392
+ data[i],
1393
+ target[SLW_CLONE]({
1394
+ SLW_OP_PATH: target[SLW_OP_PATH] + "." + String(i),
1395
+ OP_RESULT_DATA: target[SLW_OP_RESULT_DATA_OVERRIDE],
1396
+ }),
1397
+ )
1398
+ : target[SLW_CLONE]({
1399
+ SLW_OP_PATH: target[SLW_OP_PATH] + "." + String(i),
1400
+ OP_RESULT_DATA: target[SLW_OP_RESULT_DATA_OVERRIDE],
1401
+ }),
1611
1402
  );
1612
1403
 
1613
1404
  if (!cache.proxiedArray.has(path)) {
1614
- cache.proxiedArray.set(
1615
- path,
1616
- proxiedData,
1617
- );
1405
+ cache.proxiedArray.set(path, proxiedData);
1618
1406
  }
1619
1407
 
1620
- const proto =
1621
- Object.getPrototypeOf(proxiedData);
1408
+ const proto = Object.getPrototypeOf(proxiedData);
1622
1409
  if (Object.hasOwn(proto, prop)) {
1623
1410
  const v = (proxiedData as any)[prop];
1624
- if (typeof v === "function")
1625
- return v.bind(proxiedData);
1411
+ if (typeof v === "function") return v.bind(proxiedData);
1626
1412
  return v;
1627
1413
  }
1628
1414
 
@@ -1639,8 +1425,7 @@ export class SelectionWrapper<
1639
1425
  const proto = Object.getPrototypeOf(data);
1640
1426
  if (Object.hasOwn(proto, prop)) {
1641
1427
  const v = (data as any)[prop];
1642
- if (typeof v === "function")
1643
- return v.bind(data);
1428
+ if (typeof v === "function") return v.bind(data);
1644
1429
  return v;
1645
1430
  }
1646
1431
 
@@ -1649,8 +1434,7 @@ export class SelectionWrapper<
1649
1434
 
1650
1435
  let slw = slw_value?.[String(prop)];
1651
1436
  let slwOpPathIsIndexAccessOrInArray = false;
1652
- let targetOpPathArr =
1653
- target[SLW_OP_PATH]?.split(".") ?? [];
1437
+ let targetOpPathArr = target[SLW_OP_PATH]?.split(".") ?? [];
1654
1438
  while (targetOpPathArr.length) {
1655
1439
  if (!isNaN(+targetOpPathArr.pop()!)) {
1656
1440
  slwOpPathIsIndexAccessOrInArray = true;
@@ -1660,8 +1444,7 @@ export class SelectionWrapper<
1660
1444
 
1661
1445
  if (
1662
1446
  slwOpPathIsIndexAccessOrInArray ||
1663
- (target[SLW_OP_RESULT_DATA_OVERRIDE] &&
1664
- !slw[SLW_OP_RESULT_DATA_OVERRIDE])
1447
+ (target[SLW_OP_RESULT_DATA_OVERRIDE] && !slw[SLW_OP_RESULT_DATA_OVERRIDE])
1665
1448
  ) {
1666
1449
  if (target[SLW_NEEDS_CLONE]) {
1667
1450
  // if the slw is flagged it needs to be cloned
@@ -1671,34 +1454,20 @@ export class SelectionWrapper<
1671
1454
  // we need a new object that doesn't reference
1672
1455
  // the other objects
1673
1456
  slw = slw[SLW_CLONE]({
1674
- SLW_OP_PATH:
1675
- target[SLW_OP_PATH] +
1676
- "." +
1677
- String(prop),
1678
- OP_RESULT_DATA:
1679
- target[SLW_OP_RESULT_DATA_OVERRIDE],
1457
+ SLW_OP_PATH: target[SLW_OP_PATH] + "." + String(prop),
1458
+ OP_RESULT_DATA: target[SLW_OP_RESULT_DATA_OVERRIDE],
1680
1459
  });
1681
1460
  } else {
1682
1461
  // index access detected, setting the op path
1683
1462
  // with the index (coming from the slw's parent (target))
1684
1463
  // it's in the parent because the parent was cloned before
1685
- slw[SLW_OP_PATH] =
1686
- target[SLW_OP_PATH] +
1687
- "." +
1688
- String(prop);
1689
- slw[SLW_OP_RESULT_DATA_OVERRIDE] =
1690
- target[SLW_OP_RESULT_DATA_OVERRIDE];
1464
+ slw[SLW_OP_PATH] = target[SLW_OP_PATH] + "." + String(prop);
1465
+ slw[SLW_OP_RESULT_DATA_OVERRIDE] = target[SLW_OP_RESULT_DATA_OVERRIDE];
1691
1466
  }
1692
1467
  }
1693
1468
 
1694
- if (
1695
- slw instanceof SelectionWrapperImpl &&
1696
- slw[SLW_FIELD_ARR_DEPTH]
1697
- ) {
1698
- const dataArr = getResultDataForTarget(slw) as
1699
- | unknown[]
1700
- | undefined
1701
- | null;
1469
+ if (slw instanceof SelectionWrapperImpl && slw[SLW_FIELD_ARR_DEPTH]) {
1470
+ const dataArr = getResultDataForTarget(slw) as unknown[] | undefined | null;
1702
1471
  if (dataArr === undefined) return undefined;
1703
1472
  if (dataArr === null) return null;
1704
1473
  if (!dataArr?.length) {
@@ -1709,10 +1478,7 @@ export class SelectionWrapper<
1709
1478
  return proxify(dataArr, slw);
1710
1479
  }
1711
1480
  } else if (slw instanceof SelectionWrapperImpl) {
1712
- const data = getResultDataForTarget(slw) as
1713
- | unknown
1714
- | undefined
1715
- | null;
1481
+ const data = getResultDataForTarget(slw) as unknown | undefined | null;
1716
1482
  if (data === undefined) return undefined;
1717
1483
  if (data === null) return null;
1718
1484
 
@@ -1732,18 +1498,13 @@ export class SelectionWrapper<
1732
1498
 
1733
1499
  if (
1734
1500
  Object.hasOwn(slw_value ?? {}, String(prop)) &&
1735
- slw_value?.[String(prop)] instanceof
1736
- SelectionWrapperImpl
1501
+ slw_value?.[String(prop)] instanceof SelectionWrapperImpl
1737
1502
  ) {
1738
1503
  if (target[SLW_COLLECTOR]) {
1739
- target[SLW_COLLECTOR].registerSelection(
1740
- String(prop),
1741
- slw_value[String(prop)],
1742
- );
1504
+ target[SLW_COLLECTOR].registerSelection(String(prop), slw_value[String(prop)]);
1743
1505
  }
1744
1506
  if (!slw_value[String(prop)][SLW_PARENT_SLW]) {
1745
- slw_value[String(prop)][SLW_PARENT_SLW] =
1746
- target;
1507
+ slw_value[String(prop)][SLW_PARENT_SLW] = target;
1747
1508
  }
1748
1509
  }
1749
1510
  if (slw_value?.[String(prop)]?.[SLW_LAZY_FLAG]) {
@@ -1753,8 +1514,7 @@ export class SelectionWrapper<
1753
1514
  parentSlw: target,
1754
1515
  key: String(prop),
1755
1516
  });
1756
- slw_value[String(prop)][SLW_PARENT_SLW] =
1757
- target;
1517
+ slw_value[String(prop)][SLW_PARENT_SLW] = target;
1758
1518
  slw_value[String(prop)][SLW_LAZY_FLAG] = true;
1759
1519
  }
1760
1520
  }
@@ -2930,10 +2690,7 @@ export class RootOperation {
2930
2690
  };
2931
2691
 
2932
2692
  private utilSet = (obj: Record<string, any>, path: string[], value: any) =>
2933
- path.reduce(
2934
- (o, p, i, a) => (o[p] = a.length - 1 === i ? value : o[p] || {}),
2935
- obj,
2936
- );
2693
+ path.reduce((o, p, i, a) => (o[p] = a.length - 1 === i ? value : o[p] || {}), obj);
2937
2694
 
2938
2695
  private rootCollector: OperationSelectionCollector | undefined = undefined;
2939
2696
  public registerRootCollector(collector: OperationSelectionCollector) {
@@ -2944,26 +2701,18 @@ export class RootOperation {
2944
2701
  throw new Error("RootOperation has no registered collector");
2945
2702
  }
2946
2703
 
2947
- type selection = ReturnType<
2948
- typeof OperationSelectionCollector.prototype.renderSelections
2949
- >;
2704
+ type selection = ReturnType<typeof OperationSelectionCollector.prototype.renderSelections>;
2950
2705
  const operations: {
2951
2706
  [key: string]: {
2952
2707
  selection: selection;
2953
2708
  rootSlw: SelectionWrapperImpl<string, string, number, any>;
2954
2709
  };
2955
2710
  } = {};
2956
- for (const [
2957
- opName,
2958
- opSelection,
2959
- ] of this.rootCollector?.selections.entries()) {
2711
+ for (const [opName, opSelection] of this.rootCollector?.selections.entries()) {
2960
2712
  if (opSelection[SLW_LAZY_FLAG]) continue;
2961
2713
 
2962
2714
  const rootSlw = opSelection;
2963
- const selection = rootSlw[SLW_PARENT_COLLECTOR]!.renderSelections(
2964
- [],
2965
- [rootSlw],
2966
- );
2715
+ const selection = rootSlw[SLW_PARENT_COLLECTOR]!.renderSelections([], [rootSlw]);
2967
2716
 
2968
2717
  operations[opName] = {
2969
2718
  selection,
@@ -2973,15 +2722,13 @@ export class RootOperation {
2973
2722
 
2974
2723
  const ops = Object.entries(operations).reduce(
2975
2724
  (acc, [opName, { selection, rootSlw }]) => {
2976
- const bodyVarDefCount = Object.entries(
2977
- selection.variableDefinitions,
2978
- ).filter(([_, v]) => v.location === "body").length;
2725
+ const bodyVarDefCount = Object.entries(selection.variableDefinitions).filter(
2726
+ ([_, v]) => v.location === "body",
2727
+ ).length;
2979
2728
  const body =
2980
2729
  bodyVarDefCount === 0
2981
2730
  ? undefined
2982
- : bodyVarDefCount === 1 &&
2983
- Object.keys(selection.variableDefinitions)
2984
- .length === 1
2731
+ : bodyVarDefCount === 1 && Object.keys(selection.variableDefinitions).length === 1
2985
2732
  ? selection.variables
2986
2733
  : bodyVarDefCount === 1 &&
2987
2734
  "$body" in selection.variableDefinitions &&
@@ -2990,10 +2737,7 @@ export class RootOperation {
2990
2737
  : Object.fromEntries(
2991
2738
  Object.entries(selection.variableDefinitions)
2992
2739
  .filter(([_, v]) => v.location === "body")
2993
- .map(([k, _]) => [
2994
- k,
2995
- selection.variables[k],
2996
- ]),
2740
+ .map(([k, _]) => [k, selection.variables[k]]),
2997
2741
  );
2998
2742
 
2999
2743
  return {
@@ -3010,18 +2754,12 @@ export class RootOperation {
3010
2754
  path: Object.fromEntries(
3011
2755
  Object.entries(selection.variableDefinitions)
3012
2756
  .filter(([_, v]) => v.location === "path")
3013
- .map(([k, v]) => [
3014
- k,
3015
- selection.variables[k],
3016
- ]),
2757
+ .map(([k, v]) => [k, selection.variables[k]]),
3017
2758
  ),
3018
2759
  query: Object.fromEntries(
3019
2760
  Object.entries(selection.variableDefinitions)
3020
2761
  .filter(([_, v]) => v.location === "query")
3021
- .map(([k, v]) => [
3022
- k,
3023
- selection.variables[k],
3024
- ]),
2762
+ .map(([k, v]) => [k, selection.variables[k]]),
3025
2763
  ),
3026
2764
  },
3027
2765
  body,
@@ -3037,15 +2775,7 @@ export class RootOperation {
3037
2775
  string,
3038
2776
  {
3039
2777
  path: string;
3040
- method:
3041
- | "get"
3042
- | "post"
3043
- | "put"
3044
- | "delete"
3045
- | "patch"
3046
- | "head"
3047
- | "options"
3048
- | "trace";
2778
+ method: "get" | "post" | "put" | "delete" | "patch" | "head" | "options" | "trace";
3049
2779
  header: Record<string, any>;
3050
2780
  params: {
3051
2781
  path: Record<string, any>;
@@ -3061,11 +2791,7 @@ export class RootOperation {
3061
2791
  const results = Object.fromEntries(
3062
2792
  await Promise.all([
3063
2793
  ...Object.entries(ops).map(
3064
- async ([opName, op]) =>
3065
- [
3066
- opName,
3067
- await this.executeOperation(op, headers),
3068
- ] as const,
2794
+ async ([opName, op]) => [opName, await this.executeOperation(op, headers)] as const,
3069
2795
  ),
3070
2796
  ]),
3071
2797
  );
@@ -3076,15 +2802,7 @@ export class RootOperation {
3076
2802
  private async executeOperation(
3077
2803
  request: {
3078
2804
  path: string;
3079
- method:
3080
- | "get"
3081
- | "post"
3082
- | "put"
3083
- | "delete"
3084
- | "patch"
3085
- | "head"
3086
- | "options"
3087
- | "trace";
2805
+ method: "get" | "post" | "put" | "delete" | "patch" | "head" | "options" | "trace";
3088
2806
  header: Record<string, any>;
3089
2807
  params: {
3090
2808
  path: Record<string, any>;
@@ -3100,9 +2818,7 @@ export class RootOperation {
3100
2818
  });
3101
2819
  const finalQuery = new URLSearchParams(request.params.query).toString();
3102
2820
  // remove the '{?arg1, arg2, ...}' part from the finalPath and add the finalQuery to the end
3103
- finalPath = \`\${finalPath.replace(/\\{.*?\\}$/, "")}\${
3104
- finalQuery ? \`?\${finalQuery}\` : ""
3105
- }\`;
2821
+ finalPath = \`\${finalPath.replace(/\\{.*?\\}$/, "")}\${finalQuery ? \`?\${finalQuery}\` : ""}\`;
3106
2822
  const cookies = new URLSearchParams(request.cookie).toString();
3107
2823
 
3108
2824
  const res = await fetch(\`[ENDPOINT]\${finalPath}\`, {
@@ -3132,9 +2848,7 @@ export type OperationSelectionCollectorRef = {
3132
2848
  export class OperationSelectionCollector {
3133
2849
  constructor(
3134
2850
  public readonly name?: string,
3135
- public readonly parent?:
3136
- | OperationSelectionCollector
3137
- | OperationSelectionCollectorRef,
2851
+ public readonly parent?: OperationSelectionCollector | OperationSelectionCollectorRef,
3138
2852
  public readonly op?: RootOperation,
3139
2853
  ) {
3140
2854
  if (op) op.registerRootCollector(this);
@@ -3142,13 +2856,9 @@ export class OperationSelectionCollector {
3142
2856
 
3143
2857
  private executed = false;
3144
2858
  private operationResult: any | undefined = undefined;
3145
- public async execute(
3146
- headers: Record<string, string> = RootOperation[OPTIONS].headers,
3147
- ) {
2859
+ public async execute(headers: Record<string, string> = RootOperation[OPTIONS].headers) {
3148
2860
  if (!this.op) {
3149
- throw new Error(
3150
- "OperationSelectionCollector is not registered to a root operation",
3151
- );
2861
+ throw new Error("OperationSelectionCollector is not registered to a root operation");
3152
2862
  }
3153
2863
  this.operationResult = await this.op.execute(headers);
3154
2864
  this.executed = true;
@@ -3157,25 +2867,14 @@ export class OperationSelectionCollector {
3157
2867
  return this.executed;
3158
2868
  }
3159
2869
 
3160
- public readonly selections = new Map<
3161
- string,
3162
- SelectionWrapperImpl<string, string, number, any>
3163
- >();
3164
- public registerSelection(
3165
- id: string,
3166
- selection: SelectionWrapperImpl<string, string, number, any, any>,
3167
- ) {
2870
+ public readonly selections = new Map<string, SelectionWrapperImpl<string, string, number, any>>();
2871
+ public registerSelection(id: string, selection: SelectionWrapperImpl<string, string, number, any, any>) {
3168
2872
  this.selections.set(id, selection);
3169
2873
  }
3170
2874
 
3171
2875
  public renderSelections(
3172
2876
  path: string[] = [],
3173
- renderOnlyTheseSelections: SelectionWrapperImpl<
3174
- string,
3175
- string,
3176
- number,
3177
- any
3178
- >[] = [],
2877
+ renderOnlyTheseSelections: SelectionWrapperImpl<string, string, number, any>[] = [],
3179
2878
  ) {
3180
2879
  const varDefs: Record<
3181
2880
  string,
@@ -3189,13 +2888,10 @@ export class OperationSelectionCollector {
3189
2888
  for (const [key, value] of [...this.selections.entries()].filter(
3190
2889
  ([k, v]) =>
3191
2890
  renderOnlyTheseSelections.length === 0 ||
3192
- renderOnlyTheseSelections.find(
3193
- (r) => r[SLW_UID] === v[SLW_UID],
3194
- ),
2891
+ renderOnlyTheseSelections.find((r) => r[SLW_UID] === v[SLW_UID]),
3195
2892
  )) {
3196
2893
  const subPath = [...path, key];
3197
- const { variableDefinitions: fieldVarDefs, variables: fieldVars } =
3198
- value[SLW_RENDER_WITH_ARGS]();
2894
+ const { variableDefinitions: fieldVarDefs, variables: fieldVars } = value[SLW_RENDER_WITH_ARGS]();
3199
2895
 
3200
2896
  Object.assign(variables, fieldVars);
3201
2897
  Object.assign(varDefs, fieldVarDefs);
@@ -3204,9 +2900,7 @@ export class OperationSelectionCollector {
3204
2900
 
3205
2901
  if (value[SLW_PARENT_COLLECTOR] === undefined) {
3206
2902
  // do nothing
3207
- } else if (
3208
- value[SLW_COLLECTOR] instanceof OperationSelectionCollector
3209
- ) {
2903
+ } else if (value[SLW_COLLECTOR] instanceof OperationSelectionCollector) {
3210
2904
  const { variableDefinitions: subVarDefs, variables: subVars } =
3211
2905
  value[SLW_COLLECTOR].renderSelections(subPath);
3212
2906
 
@@ -3221,16 +2915,10 @@ export class OperationSelectionCollector {
3221
2915
  };
3222
2916
  }
3223
2917
 
3224
- private utilGet = (obj: Record<string, any>, path: (string | number)[]) =>
3225
- path.reduce((o, p) => o?.[p], obj);
3226
- public getOperationResultPath<T>(
3227
- path: (string | number)[] = [],
3228
- type?: string,
3229
- ): T {
2918
+ private utilGet = (obj: Record<string, any>, path: (string | number)[]) => path.reduce((o, p) => o?.[p], obj);
2919
+ public getOperationResultPath<T>(path: (string | number)[] = [], type?: string): T {
3230
2920
  if (!this.op) {
3231
- throw new Error(
3232
- "OperationSelectionCollector is not registered to a root operation",
3233
- );
2921
+ throw new Error("OperationSelectionCollector is not registered to a root operation");
3234
2922
  }
3235
2923
 
3236
2924
  let result = this.operationResult;
@@ -3248,25 +2936,17 @@ export class OperationSelectionCollector {
3248
2936
  depth++;
3249
2937
  }
3250
2938
 
3251
- const deepParse = (
3252
- res: any | any[],
3253
- depth: number,
3254
- parse: (v: string) => any,
3255
- ) => {
2939
+ const deepParse = (res: any | any[], depth: number, parse: (v: string) => any) => {
3256
2940
  if (depth === 0) {
3257
2941
  return parse(res);
3258
2942
  }
3259
- return res.map((rarr: any) =>
3260
- deepParse(rarr, depth - 1, parse),
3261
- );
2943
+ return res.map((rarr: any) => deepParse(rarr, depth - 1, parse));
3262
2944
  };
3263
2945
 
3264
2946
  return deepParse(
3265
2947
  finalResult,
3266
2948
  depth,
3267
- RootOperation[OPTIONS].scalars[
3268
- type as keyof (typeof RootOperation)[typeof OPTIONS]["scalars"]
3269
- ],
2949
+ RootOperation[OPTIONS].scalars[type as keyof (typeof RootOperation)[typeof OPTIONS]["scalars"]],
3270
2950
  ) as T;
3271
2951
  }
3272
2952
 
@@ -3295,9 +2975,7 @@ export const SLW_OP_PATH = Symbol("SLW_OP_PATH");
3295
2975
  export const SLW_REGISTER_PATH = Symbol("SLW_REGISTER_PATH");
3296
2976
  export const SLW_RENDER_WITH_ARGS = Symbol("SLW_RENDER_WITH_ARGS");
3297
2977
 
3298
- export const SLW_RECREATE_VALUE_CALLBACK = Symbol(
3299
- "SLW_RECREATE_VALUE_CALLBACK",
3300
- );
2978
+ export const SLW_RECREATE_VALUE_CALLBACK = Symbol("SLW_RECREATE_VALUE_CALLBACK");
3301
2979
 
3302
2980
  export const SLW_CLONE = Symbol("SLW_CLONE");
3303
2981
 
@@ -3312,10 +2990,7 @@ export class SelectionWrapperImpl<
3312
2990
  argsT extends Record<string, any> | any | undefined = undefined,
3313
2991
  > {
3314
2992
  private generateUniqueId(): string {
3315
- return (
3316
- performance.now().toString(36) +
3317
- Math.random().toString(36).substring(2)
3318
- );
2993
+ return performance.now().toString(36) + Math.random().toString(36).substring(2);
3319
2994
  }
3320
2995
  [SLW_CLONE](
3321
2996
  overrides: {
@@ -3352,15 +3027,7 @@ export class SelectionWrapperImpl<
3352
3027
 
3353
3028
  [ROOT_OP_META]?: {
3354
3029
  path: string;
3355
- method:
3356
- | "get"
3357
- | "post"
3358
- | "put"
3359
- | "delete"
3360
- | "patch"
3361
- | "head"
3362
- | "options"
3363
- | "trace";
3030
+ method: "get" | "post" | "put" | "delete" | "patch" | "head" | "options" | "trace";
3364
3031
  };
3365
3032
 
3366
3033
  [SLW_ARGS]?: argsT;
@@ -3415,9 +3082,7 @@ export class SelectionWrapperImpl<
3415
3082
  this[SLW_COLLECTOR] = collector;
3416
3083
 
3417
3084
  let rootCollector = collector;
3418
- while (
3419
- rootCollector?.parent instanceof OperationSelectionCollector
3420
- ) {
3085
+ while (rootCollector?.parent instanceof OperationSelectionCollector) {
3421
3086
  rootCollector = rootCollector.parent;
3422
3087
  }
3423
3088
  if (rootCollector.parent && "ref" in rootCollector.parent) {
@@ -3452,7 +3117,7 @@ export class SelectionWrapperImpl<
3452
3117
  return {
3453
3118
  variables: args ?? {},
3454
3119
  variableDefinitions: argsMeta?.["$body"]
3455
- ? argsMeta ?? {}
3120
+ ? (argsMeta ?? {})
3456
3121
  : args
3457
3122
  ? Object.keys(args).reduce(
3458
3123
  (acc, key) => {
@@ -3463,12 +3128,7 @@ export class SelectionWrapperImpl<
3463
3128
  string,
3464
3129
  {
3465
3130
  type: string;
3466
- location:
3467
- | "path"
3468
- | "query"
3469
- | "header"
3470
- | "cookie"
3471
- | "body";
3131
+ location: "path" | "query" | "header" | "cookie" | "body";
3472
3132
  }
3473
3133
  >,
3474
3134
  )
@@ -3493,9 +3153,7 @@ export class SelectionWrapper<
3493
3153
  typeArrDepth extends number,
3494
3154
  valueT extends any = any,
3495
3155
  argsT extends Record<string, any> | any | undefined = undefined,
3496
- > extends Proxy<
3497
- SelectionWrapperImpl<fieldName, typeNamePure, typeArrDepth, valueT, argsT>
3498
- > {
3156
+ > extends Proxy<SelectionWrapperImpl<fieldName, typeNamePure, typeArrDepth, valueT, argsT>> {
3499
3157
  constructor(
3500
3158
  fieldName?: fieldName,
3501
3159
  typeNamePure?: typeNamePure,
@@ -3515,13 +3173,7 @@ export class SelectionWrapper<
3515
3173
  isScalarOp?: boolean,
3516
3174
  ) {
3517
3175
  super(
3518
- new SelectionWrapperImpl<
3519
- fieldName,
3520
- typeNamePure,
3521
- typeArrDepth,
3522
- valueT,
3523
- argsT
3524
- >(
3176
+ new SelectionWrapperImpl<fieldName, typeNamePure, typeArrDepth, valueT, argsT>(
3525
3177
  fieldName,
3526
3178
  typeNamePure,
3527
3179
  typeArrDepth,
@@ -3542,8 +3194,7 @@ export class SelectionWrapper<
3542
3194
  return Reflect.getOwnPropertyDescriptor(value ?? {}, prop);
3543
3195
  },
3544
3196
  has(target, prop) {
3545
- if (prop === Symbol.for("nodejs.util.inspect.custom"))
3546
- return true;
3197
+ if (prop === Symbol.for("nodejs.util.inspect.custom")) return true;
3547
3198
  return Reflect.has(value ?? {}, prop);
3548
3199
  },
3549
3200
  get: (target, prop) => {
@@ -3551,35 +3202,18 @@ export class SelectionWrapper<
3551
3202
  const that = this;
3552
3203
  function lazy(
3553
3204
  this: {
3554
- parentSlw: SelectionWrapperImpl<
3555
- fieldName,
3556
- typeNamePure,
3557
- typeArrDepth,
3558
- valueT,
3559
- argsT
3560
- >;
3205
+ parentSlw: SelectionWrapperImpl<fieldName, typeNamePure, typeArrDepth, valueT, argsT>;
3561
3206
  key: string;
3562
3207
  },
3563
3208
  args?: argsT,
3564
3209
  ) {
3565
3210
  const { parentSlw, key } = this;
3566
3211
  const newRootOpCollectorRef = {
3567
- ref: new OperationSelectionCollector(
3568
- undefined,
3569
- undefined,
3570
- new RootOperation(),
3571
- ),
3212
+ ref: new OperationSelectionCollector(undefined, undefined, new RootOperation()),
3572
3213
  };
3573
3214
 
3574
- const newThisCollector =
3575
- new OperationSelectionCollector(
3576
- undefined,
3577
- newRootOpCollectorRef,
3578
- );
3579
- const r =
3580
- that[SLW_RECREATE_VALUE_CALLBACK]?.bind(
3581
- newThisCollector,
3582
- )();
3215
+ const newThisCollector = new OperationSelectionCollector(undefined, newRootOpCollectorRef);
3216
+ const r = that[SLW_RECREATE_VALUE_CALLBACK]?.bind(newThisCollector)();
3583
3217
 
3584
3218
  const newThat = new SelectionWrapper(
3585
3219
  that[SLW_FIELD_NAME],
@@ -3593,18 +3227,12 @@ export class SelectionWrapper<
3593
3227
  that[SLW_RECREATE_VALUE_CALLBACK],
3594
3228
  that[SLW_IS_SCALAR_OP],
3595
3229
  );
3596
- Object.keys(r!).forEach(
3597
- (key) =>
3598
- (newThat as valueT)[key as keyof valueT],
3599
- );
3230
+ Object.keys(r!).forEach((key) => (newThat as valueT)[key as keyof valueT]);
3600
3231
 
3601
3232
  newThat[ROOT_OP_META] = that[ROOT_OP_META];
3602
3233
 
3603
3234
  newThat[SLW_PARENT_SLW] = parentSlw;
3604
- parentSlw[SLW_COLLECTOR]?.registerSelection(
3605
- key,
3606
- newThat,
3607
- );
3235
+ parentSlw[SLW_COLLECTOR]?.registerSelection(key, newThat);
3608
3236
  newThat[SLW_ARGS] = {
3609
3237
  ...(that[SLW_ARGS] ?? {}),
3610
3238
  ...(args as any), // need to fix this
@@ -3612,10 +3240,7 @@ export class SelectionWrapper<
3612
3240
 
3613
3241
  newThat[SLW_OP_PATH] = that[SLW_OP_PATH];
3614
3242
 
3615
- newRootOpCollectorRef.ref.registerSelection(
3616
- newThat[SLW_FIELD_NAME]!,
3617
- newThat,
3618
- );
3243
+ newRootOpCollectorRef.ref.registerSelection(newThat[SLW_FIELD_NAME]!, newThat);
3619
3244
 
3620
3245
  return new Promise((resolve, reject) => {
3621
3246
  newRootOpCollectorRef.ref
@@ -3655,12 +3280,7 @@ export class SelectionWrapper<
3655
3280
  prop === SLW_IS_SCALAR_OP
3656
3281
  ) {
3657
3282
  return target[
3658
- prop as keyof SelectionWrapperImpl<
3659
- fieldName,
3660
- typeNamePure,
3661
- typeArrDepth,
3662
- valueT
3663
- >
3283
+ prop as keyof SelectionWrapperImpl<fieldName, typeNamePure, typeArrDepth, valueT>
3664
3284
  ];
3665
3285
  }
3666
3286
  if (prop === SLW_VALUE) {
@@ -3670,26 +3290,14 @@ export class SelectionWrapper<
3670
3290
  return this;
3671
3291
  }
3672
3292
 
3673
- let slw_value = target[SLW_VALUE] as
3674
- | Record<string, any>
3675
- | undefined;
3293
+ let slw_value = target[SLW_VALUE] as Record<string, any> | undefined;
3676
3294
 
3677
3295
  if (target[ROOT_OP_COLLECTOR]?.ref.isExecuted) {
3678
3296
  const getResultDataForTarget = (
3679
- t: SelectionWrapperImpl<
3680
- fieldName,
3681
- typeNamePure,
3682
- typeArrDepth,
3683
- valueT,
3684
- argsT
3685
- >,
3297
+ t: SelectionWrapperImpl<fieldName, typeNamePure, typeArrDepth, valueT, argsT>,
3686
3298
  ): valueT | undefined => {
3687
- const data = t[
3688
- ROOT_OP_COLLECTOR
3689
- ]!.ref.getOperationResultPath<valueT>(
3690
- (t[SLW_OP_PATH]?.split(".") ?? []).map((p) =>
3691
- !isNaN(+p) ? +p : p,
3692
- ),
3299
+ const data = t[ROOT_OP_COLLECTOR]!.ref.getOperationResultPath<valueT>(
3300
+ (t[SLW_OP_PATH]?.split(".") ?? []).map((p) => (!isNaN(+p) ? +p : p)),
3693
3301
  t[SLW_FIELD_TYPENAME],
3694
3302
  );
3695
3303
  return data;
@@ -3700,37 +3308,25 @@ export class SelectionWrapper<
3700
3308
  if (typeArrDepth) {
3701
3309
  if (!isNaN(+String(prop))) {
3702
3310
  const elm = target[SLW_CLONE]({
3703
- SLW_OP_PATH:
3704
- target[SLW_OP_PATH] +
3705
- "." +
3706
- String(prop),
3311
+ SLW_OP_PATH: target[SLW_OP_PATH] + "." + String(prop),
3707
3312
  });
3708
3313
  return elm;
3709
3314
  }
3710
3315
 
3711
- const data = getResultDataForTarget(target) as
3712
- | valueT[]
3713
- | undefined;
3316
+ const data = getResultDataForTarget(target) as valueT[] | undefined;
3714
3317
 
3715
3318
  if (data === undefined) return undefined;
3716
3319
 
3717
- const proxiedData = Array.from(
3718
- { length: data.length },
3719
- (_, i) =>
3720
- target[SLW_CLONE]({
3721
- SLW_OP_PATH:
3722
- target[SLW_OP_PATH] +
3723
- "." +
3724
- String(i),
3725
- }),
3320
+ const proxiedData = Array.from({ length: data.length }, (_, i) =>
3321
+ target[SLW_CLONE]({
3322
+ SLW_OP_PATH: target[SLW_OP_PATH] + "." + String(i),
3323
+ }),
3726
3324
  );
3727
3325
 
3728
- const proto =
3729
- Object.getPrototypeOf(proxiedData);
3326
+ const proto = Object.getPrototypeOf(proxiedData);
3730
3327
  if (Object.hasOwn(proto, prop)) {
3731
3328
  const v = (proxiedData as any)[prop];
3732
- if (typeof v === "function")
3733
- return v.bind(proxiedData);
3329
+ if (typeof v === "function") return v.bind(proxiedData);
3734
3330
  return v;
3735
3331
  }
3736
3332
 
@@ -3742,8 +3338,7 @@ export class SelectionWrapper<
3742
3338
  const proto = Object.getPrototypeOf(data);
3743
3339
  if (Object.hasOwn(proto, prop)) {
3744
3340
  const v = (data as any)[prop];
3745
- if (typeof v === "function")
3746
- return v.bind(data);
3341
+ if (typeof v === "function") return v.bind(data);
3747
3342
  return v;
3748
3343
  }
3749
3344
 
@@ -3751,21 +3346,15 @@ export class SelectionWrapper<
3751
3346
  }
3752
3347
 
3753
3348
  let slw = slw_value?.[String(prop)];
3754
- const slwOpPathIsIndexAccess = !isNaN(
3755
- +target[SLW_OP_PATH]?.split(".").pop()!,
3756
- );
3349
+ const slwOpPathIsIndexAccess = !isNaN(+target[SLW_OP_PATH]?.split(".").pop()!);
3757
3350
  if (slwOpPathIsIndexAccess) {
3758
3351
  // index access detected, cloning
3759
3352
  slw = slw[SLW_CLONE]({
3760
- SLW_OP_PATH:
3761
- target[SLW_OP_PATH] + "." + String(prop),
3353
+ SLW_OP_PATH: target[SLW_OP_PATH] + "." + String(prop),
3762
3354
  });
3763
3355
  }
3764
3356
 
3765
- if (
3766
- slw instanceof SelectionWrapperImpl &&
3767
- slw[SLW_PARENT_COLLECTOR]
3768
- ) {
3357
+ if (slw instanceof SelectionWrapperImpl && slw[SLW_PARENT_COLLECTOR]) {
3769
3358
  return slw;
3770
3359
  } else if (slw instanceof SelectionWrapperImpl) {
3771
3360
  return getResultDataForTarget(slw);
@@ -3778,14 +3367,10 @@ export class SelectionWrapper<
3778
3367
 
3779
3368
  if (
3780
3369
  Object.hasOwn(slw_value ?? {}, String(prop)) &&
3781
- slw_value?.[String(prop)] instanceof
3782
- SelectionWrapperImpl
3370
+ slw_value?.[String(prop)] instanceof SelectionWrapperImpl
3783
3371
  ) {
3784
3372
  if (target[SLW_COLLECTOR]) {
3785
- target[SLW_COLLECTOR].registerSelection(
3786
- String(prop),
3787
- slw_value[String(prop)],
3788
- );
3373
+ target[SLW_COLLECTOR].registerSelection(String(prop), slw_value[String(prop)]);
3789
3374
  }
3790
3375
  if (!slw_value[String(prop)][SLW_PARENT_SLW]) {
3791
3376
  slw_value[String(prop)][SLW_PARENT_SLW] = target;