@samarium.sdk/new 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/samarium +299 -27
  2. package/package.json +2 -2
package/bin/samarium CHANGED
@@ -354,7 +354,7 @@ ${F.comment}`:F.comment}this.doc.range[2]=F.offset;break}default:this.errors.pus
354
354
  `)+1;while(F!==0)this.onNewLine(this.offset+F),F=this.source.indexOf(`
355
355
  `,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 q=[];for(let X=0;X<F.sep.length;++X){let J=F.sep[X];switch(J.type){case"newline":q.push(X);break;case"space":break;case"comment":if(J.indent>D.indent)q.length=0;break;default:q.length=0}}if(q.length>=2)Z=F.sep.splice(q[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(D8(F.start,"newline"))Object.assign(F,{key:null,sep:[this.sourceToken]});else{let q=m8(F.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,key:null,sep:[this.sourceToken]}]})}else if(F.value)D.items.push({start:[],key:null,sep:[this.sourceToken]});else if(D8(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(lQ(F.key)&&!D8(F.sep,"newline")){let q=m8(F.start),X=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:q,key:X,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(D8(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 q=this.flowScalar(this.type);if(B||F.value)D.items.push({start:Z,key:q,sep:[]}),this.onKeyLine=!0;else if(F.sep)this.stack.push(q);else Object.assign(F,{key:q,sep:[]}),this.onKeyLine=!0;return}default:{let q=this.startBlockValue(D);if(q){if(P&&q.type!=="block-seq")D.items.push({start:Z});this.stack.push(q);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||D8(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=p5(P),Z=m8(B);mQ(D);let q=D.end.splice(1,D.end.length);q.push(this.sourceToken);let X={type:"block-map",offset:D.offset,indent:D.indent,items:[{start:Z,key:D,sep:q}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=X}else yield*this.lineEnd(D)}}flowScalar(D){if(this.onNewLine){let F=this.source.indexOf(`
356
356
  `)+1;while(F!==0)this.onNewLine(this.offset+F),F=this.source.indexOf(`
357
- `,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=p5(D),P=m8(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=p5(D),P=m8(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()}}}ng.Parser=cQ});var sQ=Q((Zy)=>{var dQ=CP(),og=H6(),G6=U6(),tg=_F(),eg=i(),Dy=_P(),pQ=kP();function rQ(D){let F=D.prettyErrors!==!1;return{lineCounter:D.lineCounter||F&&new Dy.LineCounter||null,prettyErrors:F}}function Fy(D,F={}){let{lineCounter:P,prettyErrors:B}=rQ(F),Z=new pQ.Parser(P?.addNewLine),q=new dQ.Composer(F),X=Array.from(q.compose(Z.parse(D)));if(B&&P)for(let J of X)J.errors.forEach(G6.prettifyError(D,P)),J.warnings.forEach(G6.prettifyError(D,P));if(X.length>0)return X;return Object.assign([],{empty:!0},q.streamInfo())}function aQ(D,F={}){let{lineCounter:P,prettyErrors:B}=rQ(F),Z=new pQ.Parser(P?.addNewLine),q=new dQ.Composer(F),X=null;for(let J of q.compose(Z.parse(D),!0,D.length))if(!X)X=J;else if(X.options.logLevel!=="silent"){X.errors.push(new G6.YAMLParseError(J.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(B&&P)X.errors.forEach(G6.prettifyError(D,P)),X.warnings.forEach(G6.prettifyError(D,P));return X}function Py(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=aQ(D,P);if(!Z)return null;if(Z.warnings.forEach((q)=>tg.warn(Z.options.logLevel,q)),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 By(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(eg.isDocument(D)&&!B)return D.toString(P);return new og.Document(D,B,P).toString(P)}Zy.parse=Py;Zy.parseAllDocuments=Fy;Zy.parseDocument=aQ;Zy.stringify=By});var iQ=Q((Ey)=>{var Hy=CP(),Uy=H6(),Wy=JP(),xP=U6(),Oy=n1(),K2=i(),zy=R2(),Qy=ED(),Gy=$2(),Ry=M2(),Iy=c5(),$y=uP(),My=_P(),Ky=kP(),r5=sQ(),nQ=a1();Ey.Composer=Hy.Composer;Ey.Document=Uy.Document;Ey.Schema=Wy.Schema;Ey.YAMLError=xP.YAMLError;Ey.YAMLParseError=xP.YAMLParseError;Ey.YAMLWarning=xP.YAMLWarning;Ey.Alias=Oy.Alias;Ey.isAlias=K2.isAlias;Ey.isCollection=K2.isCollection;Ey.isDocument=K2.isDocument;Ey.isMap=K2.isMap;Ey.isNode=K2.isNode;Ey.isPair=K2.isPair;Ey.isScalar=K2.isScalar;Ey.isSeq=K2.isSeq;Ey.Pair=zy.Pair;Ey.Scalar=Qy.Scalar;Ey.YAMLMap=Gy.YAMLMap;Ey.YAMLSeq=Ry.YAMLSeq;Ey.CST=Iy;Ey.Lexer=$y.Lexer;Ey.LineCounter=My.LineCounter;Ey.Parser=Ky.Parser;Ey.parse=r5.parse;Ey.parseAllDocuments=r5.parseAllDocuments;Ey.parseDocument=r5.parseDocument;Ey.stringify=r5.stringify;Ey.visit=nQ.visit;Ey.visitAsync=nQ.visitAsync});var $6={name:"@samarium.sdk/new",version:"0.16.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://github.com/liontariai/samarium",bin:{samarium:"bin/samarium"},publishConfig:{access:"public"},files:["bin/**/*","README.md","package.json"],scripts:{prettier:"prettier --write .",bundle:"bun bundle.js",prepublishOnly:"bun run bundle",test:"bun test"},prettier:{tabWidth:4},devDependencies:{"bun-types":"^1.1.29","@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 XB=UD(qB(),1),{program:Hm,createCommand:Um,createArgument:Wm,createOption:Om,CommanderError:zm,InvalidArgumentError:Qm,InvalidOptionArgumentError:Gm,Command:JB,Argument:Rm,Option:Im,Help:$m}=XB.default;var RU=UD(u0(),1);var A3=UD(u0(),1);class Z2 extends Error{response;request;constructor(D,F){let P=`${Z2.extractMessage(D)}: ${JSON.stringify({response:D,request:F})}`;super(P);if(Object.setPrototypeOf(this,Z2.prototype),this.response=D,this.request=F,typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,Z2)}static extractMessage(D){return D.errors?.[0]?.message??`GraphQL Error (Code: ${String(D.status)})`}}var C7=(D)=>D.toUpperCase(),R3=(D)=>{return typeof D==="function"?D():D},L7=(D,F)=>D.map((P,B)=>[P,F[B]]),v2=(D)=>{let F={};if(D instanceof Headers)F=oS(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},oS=(D)=>{let F={};return D.forEach((P,B)=>{F[B]=P}),F},BU=(D)=>{try{let F=D();if(tS(F))return F.catch((P)=>{return PU(P)});return F}catch(F){return PU(F)}},PU=(D)=>{if(D instanceof Error)return D;return new Error(String(D))},tS=(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"},I3=(D)=>{throw new Error(`Unhandled case: ${String(D)}`)},T1=(D)=>{return typeof D==="object"&&D!==null&&!Array.isArray(D)};var ZU=(D,F)=>{return D.documents?D:{documents:D,requestHeaders:F,signal:void 0}};var qU=(D,F,P)=>{return D.query?D:{query:D,variables:F,requestHeaders:P,signal:void 0}};var YU=UD(u0(),1);var w7="Accept",$3="Content-Type",N1="application/json",M3="application/graphql-response+json";var V7=(D)=>D.replace(/([\s,]|#[^\n\r]+)+/g," ").trim(),HU=(D)=>{let F=D.toLowerCase();return F.includes(M3)||F.includes(N1)},j7=(D)=>{try{if(Array.isArray(D))return{_tag:"Batch",executionResults:D.map(XU)};else if(T1(D))return{_tag:"Single",executionResult:XU(D)};else throw new Error(`Invalid execution result: result is not object or array.
357
+ `,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=p5(D),P=m8(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=p5(D),P=m8(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()}}}ng.Parser=cQ});var sQ=Q((Zy)=>{var dQ=CP(),og=H6(),G6=U6(),tg=_F(),eg=i(),Dy=_P(),pQ=kP();function rQ(D){let F=D.prettyErrors!==!1;return{lineCounter:D.lineCounter||F&&new Dy.LineCounter||null,prettyErrors:F}}function Fy(D,F={}){let{lineCounter:P,prettyErrors:B}=rQ(F),Z=new pQ.Parser(P?.addNewLine),q=new dQ.Composer(F),X=Array.from(q.compose(Z.parse(D)));if(B&&P)for(let J of X)J.errors.forEach(G6.prettifyError(D,P)),J.warnings.forEach(G6.prettifyError(D,P));if(X.length>0)return X;return Object.assign([],{empty:!0},q.streamInfo())}function aQ(D,F={}){let{lineCounter:P,prettyErrors:B}=rQ(F),Z=new pQ.Parser(P?.addNewLine),q=new dQ.Composer(F),X=null;for(let J of q.compose(Z.parse(D),!0,D.length))if(!X)X=J;else if(X.options.logLevel!=="silent"){X.errors.push(new G6.YAMLParseError(J.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(B&&P)X.errors.forEach(G6.prettifyError(D,P)),X.warnings.forEach(G6.prettifyError(D,P));return X}function Py(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=aQ(D,P);if(!Z)return null;if(Z.warnings.forEach((q)=>tg.warn(Z.options.logLevel,q)),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 By(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(eg.isDocument(D)&&!B)return D.toString(P);return new og.Document(D,B,P).toString(P)}Zy.parse=Py;Zy.parseAllDocuments=Fy;Zy.parseDocument=aQ;Zy.stringify=By});var iQ=Q((Ey)=>{var Hy=CP(),Uy=H6(),Wy=JP(),xP=U6(),Oy=n1(),K2=i(),zy=R2(),Qy=ED(),Gy=$2(),Ry=M2(),Iy=c5(),$y=uP(),My=_P(),Ky=kP(),r5=sQ(),nQ=a1();Ey.Composer=Hy.Composer;Ey.Document=Uy.Document;Ey.Schema=Wy.Schema;Ey.YAMLError=xP.YAMLError;Ey.YAMLParseError=xP.YAMLParseError;Ey.YAMLWarning=xP.YAMLWarning;Ey.Alias=Oy.Alias;Ey.isAlias=K2.isAlias;Ey.isCollection=K2.isCollection;Ey.isDocument=K2.isDocument;Ey.isMap=K2.isMap;Ey.isNode=K2.isNode;Ey.isPair=K2.isPair;Ey.isScalar=K2.isScalar;Ey.isSeq=K2.isSeq;Ey.Pair=zy.Pair;Ey.Scalar=Qy.Scalar;Ey.YAMLMap=Gy.YAMLMap;Ey.YAMLSeq=Ry.YAMLSeq;Ey.CST=Iy;Ey.Lexer=$y.Lexer;Ey.LineCounter=My.LineCounter;Ey.Parser=Ky.Parser;Ey.parse=r5.parse;Ey.parseAllDocuments=r5.parseAllDocuments;Ey.parseDocument=r5.parseDocument;Ey.stringify=r5.stringify;Ey.visit=nQ.visit;Ey.visitAsync=nQ.visitAsync});var $6={name:"@samarium.sdk/new",version:"0.17.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.js",prepublishOnly:"bun run bundle",test:"bun test"},prettier:{tabWidth:4},devDependencies:{"bun-types":"^1.1.29","@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 XB=UD(qB(),1),{program:Hm,createCommand:Um,createArgument:Wm,createOption:Om,CommanderError:zm,InvalidArgumentError:Qm,InvalidOptionArgumentError:Gm,Command:JB,Argument:Rm,Option:Im,Help:$m}=XB.default;var RU=UD(u0(),1);var A3=UD(u0(),1);class Z2 extends Error{response;request;constructor(D,F){let P=`${Z2.extractMessage(D)}: ${JSON.stringify({response:D,request:F})}`;super(P);if(Object.setPrototypeOf(this,Z2.prototype),this.response=D,this.request=F,typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,Z2)}static extractMessage(D){return D.errors?.[0]?.message??`GraphQL Error (Code: ${String(D.status)})`}}var C7=(D)=>D.toUpperCase(),R3=(D)=>{return typeof D==="function"?D():D},L7=(D,F)=>D.map((P,B)=>[P,F[B]]),v2=(D)=>{let F={};if(D instanceof Headers)F=oS(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},oS=(D)=>{let F={};return D.forEach((P,B)=>{F[B]=P}),F},BU=(D)=>{try{let F=D();if(tS(F))return F.catch((P)=>{return PU(P)});return F}catch(F){return PU(F)}},PU=(D)=>{if(D instanceof Error)return D;return new Error(String(D))},tS=(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"},I3=(D)=>{throw new Error(`Unhandled case: ${String(D)}`)},T1=(D)=>{return typeof D==="object"&&D!==null&&!Array.isArray(D)};var ZU=(D,F)=>{return D.documents?D:{documents:D,requestHeaders:F,signal:void 0}};var qU=(D,F,P)=>{return D.query?D:{query:D,variables:F,requestHeaders:P,signal:void 0}};var YU=UD(u0(),1);var w7="Accept",$3="Content-Type",N1="application/json",M3="application/graphql-response+json";var V7=(D)=>D.replace(/([\s,]|#[^\n\r]+)+/g," ").trim(),HU=(D)=>{let F=D.toLowerCase();return F.includes(M3)||F.includes(N1)},j7=(D)=>{try{if(Array.isArray(D))return{_tag:"Batch",executionResults:D.map(XU)};else if(T1(D))return{_tag:"Single",executionResult:XU(D)};else throw new Error(`Invalid execution result: result is not object or array.
358
358
  Got:
359
359
  ${String(D)}`)}catch(F){return F}},XU=(D)=>{if(typeof D!=="object"||D===null)throw new Error("Invalid execution result: result is not object");let F=void 0,P=void 0,B=void 0;if("errors"in D){if(!T1(D.errors)&&!Array.isArray(D.errors))throw new Error("Invalid execution result: errors is not plain object OR array");F=D.errors}if("data"in D){if(!T1(D.data)&&D.data!==null)throw new Error("Invalid execution result: data is not plain object");P=D.data}if("extensions"in D){if(!T1(D.extensions))throw new Error("Invalid execution result: extensions is not plain object");B=D.extensions}return{data:P,errors:F,extensions:B}},UU=(D)=>D._tag==="Batch"?D.executionResults.some(JU):JU(D.executionResult),JU=(D)=>Array.isArray(D.errors)?D.errors.length>0:Boolean(D.errors),b7=(D)=>{return typeof D==="object"&&D!==null&&"kind"in D&&D.kind===YU.Kind.OPERATION_DEFINITION};var WU=UD(u0(),1),OU=UD(u0(),1),zU=UD(u0(),1),eS=(D)=>{let F=void 0,P=D.definitions.filter(b7);if(P.length===1)F=P[0].name?.value;return F},DT=(D)=>{let F=!1,P=D.definitions.filter(b7);if(P.length===1)F=P[0].operation===WU.OperationTypeNode.MUTATION;return F},u1=(D,F)=>{let P=typeof D==="string"?D:zU.print(D),B=!1,Z=void 0;if(F)return{expression:P,isMutation:B,operationName:Z};let q=BU(()=>typeof D==="string"?OU.parse(D):D);if(q instanceof Error)return{expression:P,isMutation:B,operationName:Z};return Z=eS(q),B=DT(q),{expression:P,operationName:Z,isMutation:B}};var K3=JSON;var E3=async(D)=>{let F={...D,method:D.request._tag==="Single"?D.request.document.isMutation?"POST":C7(D.method??"post"):D.request.hasMutations?"POST":C7(D.method??"post"),fetchOptions:{...D.fetchOptions,errorPolicy:D.fetchOptions.errorPolicy??"none"}},B=await PT(F.method)(F);if(!B.ok)return new Z2({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 FT(B,D.fetchOptions.jsonSerializer??K3);if(Z instanceof Error)throw Z;let q={status:B.status,headers:B.headers};if(UU(Z)&&F.fetchOptions.errorPolicy==="none"){let X=Z._tag==="Batch"?{...Z.executionResults,...q}:{...Z.executionResult,...q};return new Z2(X,{query:D.request._tag==="Single"?D.request.document.expression:D.request.query,variables:D.request.variables})}switch(Z._tag){case"Single":return{...q,...QU(F)(Z.executionResult)};case"Batch":return{...q,data:Z.executionResults.map(QU(F))};default:I3(Z)}},QU=(D)=>(F)=>{return{extensions:F.extensions,data:F.data,errors:D.fetchOptions.errorPolicy==="all"?F.errors:void 0}},FT=async(D,F)=>{let P=D.headers.get($3),B=await D.text();if(P&&HU(P))return j7(F.parse(B));else return j7(B)},PT=(D)=>async(F)=>{let P=new Headers(F.headers),B=null,Z=void 0;if(!P.has(w7))P.set(w7,[M3,N1].join(", "));if(D==="POST"){if(Z=(F.fetchOptions.jsonSerializer??K3).stringify(BT(F)),typeof Z==="string"&&!P.has($3))P.set($3,N1)}else B=ZT(F);let q={method:D,headers:P,body:Z,...F.fetchOptions},X=new URL(F.url),J=q;if(F.middleware){let H=await Promise.resolve(F.middleware({...q,url:F.url,operationName:F.request._tag==="Single"?F.request.document.operationName:void 0,variables:F.request.variables})),{url:W,...U}=H;X=new URL(W),J=U}if(B)B.forEach((H,W)=>{X.searchParams.append(W,H)});return await(F.fetch??fetch)(X,J)},BT=(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 L7(D.request.query,D.request.variables??[]).map(([F,P])=>({query:F,variables:P}));default:throw I3(D.request)}},ZT=(D)=>{let F=D.fetchOptions.jsonSerializer??K3,P=new URLSearchParams;switch(D.request._tag){case"Single":{if(P.append("query",V7(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((X)=>F.stringify(X))??[],Z=D.request.query.map(V7),q=L7(Z,B).map(([X,J])=>({query:X,variables:J}));return P.append("query",F.stringify(q)),P}default:throw I3(D.request)}};class g2{url;requestConfig;constructor(D,F={}){this.url=D,this.requestConfig=F}rawRequest=async(...D)=>{let[F,P,B]=D,Z=qU(F,P,B),{headers:q,fetch:X=globalThis.fetch,method:J="POST",requestMiddleware:Y,responseMiddleware:H,excludeOperationName:W,...U}=this.requestConfig,{url:O}=this;if(Z.signal!==void 0)U.signal=Z.signal;let z=u1(Z.query,W),I=await E3({url:O,request:{_tag:"Single",document:z,variables:Z.variables},headers:{...v2(R3(q)),...v2(Z.requestHeaders)},fetch:X,method:J,fetchOptions:U,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=GU(D,P,B),{headers:q,fetch:X=globalThis.fetch,method:J="POST",requestMiddleware:Y,responseMiddleware:H,excludeOperationName:W,...U}=this.requestConfig,{url:O}=this;if(Z.signal!==void 0)U.signal=Z.signal;let z=u1(Z.document,W),I=await E3({url:O,request:{_tag:"Single",document:z,variables:Z.variables},headers:{...v2(R3(q)),...v2(Z.requestHeaders)},fetch:X,method:J,fetchOptions:U,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=ZU(D,F),{headers:B,excludeOperationName:Z,...q}=this.requestConfig;if(P.signal!==void 0)q.signal=P.signal;let X=P.documents.map(({document:U})=>u1(U,Z)),J=X.map(({expression:U})=>U),Y=X.some(({isMutation:U})=>U),H=P.documents.map(({variables:U})=>U),W=await E3({url:this.url,request:{_tag:"Batch",operationName:void 0,query:J,hasMutations:Y,variables:H},headers:{...v2(R3(B)),...v2(P.requestHeaders)},fetch:this.requestConfig.fetch??globalThis.fetch,method:this.requestConfig.method||"POST",fetchOptions:q,middleware:this.requestConfig.requestMiddleware});if(this.requestConfig.responseMiddleware)await this.requestConfig.responseMiddleware(W,{operationName:void 0,variables:H,url:this.url});if(W instanceof Error)throw W;return W.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 GU=(D,F,P)=>{return D.document?D:{document:D,variables:F,requestHeaders:P,signal:void 0}};async function y2(D,F){try{let B=await new g2(D).request(A3.getIntrospectionQuery(),void 0,new Headers(F?.map((q)=>q.split("="))));return A3.buildClientSchema(B)}catch(P){throw P}}import qT from"fs";var S7=async(D,F)=>{let P=await y2(D.url,D.headers),B=RU.printSchema(P);qT.writeFileSync(F,B)};var C3=UD(u0(),1),L3=UD(u0(),1),MD=UD(u0(),1),XT=Object.defineProperty,$U=(D,F)=>{for(var P in F)XT(D,P,{get:F[P],enumerable:!0,configurable:!0,set:(B)=>F[P]=()=>B})};class MU{collector;options;static FieldValueWrapperType;static EnumTypesMapped;static HelperTypes;static HelperFunctions;typeMeta;typeName;originalFullTypeName;constructor(D,F,P){this.collector=F,this.options=P,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 new Error("Method not implemented.")}}var JT=`const Proxy = global.Proxy;
360
360
  Proxy.prototype = {};
@@ -802,7 +802,7 @@ export class SelectionWrapperImpl<
802
802
 
803
803
  readonly [SLW_UID] = this.generateUniqueId();
804
804
  [ROOT_OP_COLLECTOR]?: OperationSelectionCollectorRef;
805
- readonly [SLW_PARENT_COLLECTOR]?: OperationSelectionCollector;
805
+ [SLW_PARENT_COLLECTOR]?: OperationSelectionCollector;
806
806
  readonly [SLW_COLLECTOR]?: OperationSelectionCollector;
807
807
 
808
808
  [SLW_FIELD_NAME]?: fieldName;
@@ -1042,7 +1042,7 @@ export class SelectionWrapper<
1042
1042
  const r =
1043
1043
  that[SLW_RECREATE_VALUE_CALLBACK]?.bind(
1044
1044
  newThisCollector,
1045
- )();
1045
+ )?.() ?? {};
1046
1046
 
1047
1047
  const newThat = new SelectionWrapper(
1048
1048
  that[SLW_FIELD_NAME],
@@ -1050,7 +1050,12 @@ export class SelectionWrapper<
1050
1050
  that[SLW_FIELD_ARR_DEPTH],
1051
1051
  r,
1052
1052
  newThisCollector,
1053
- newRootOpCollectorRef,
1053
+ // only set parent collector, if 'that' had one,
1054
+ // the absence indicates, that 'that' is a scalar field
1055
+ // without a subselection!
1056
+ that[SLW_PARENT_COLLECTOR]
1057
+ ? newRootOpCollectorRef
1058
+ : undefined,
1054
1059
  that[SLW_ARGS],
1055
1060
  that[SLW_ARGS_META],
1056
1061
  );
@@ -1346,6 +1351,7 @@ export class SelectionWrapper<
1346
1351
  type ToTArrayWithDepth<T, D extends number> = D extends 0
1347
1352
  ? T
1348
1353
  : ToTArrayWithDepth<T[], Prev[D]>;
1354
+ type ConvertToPromise<T, skip = 1> = skip extends 0 ? T : Promise<T>;
1349
1355
 
1350
1356
  export type SLFN<
1351
1357
  T extends object,
@@ -1355,6 +1361,7 @@ export class SelectionWrapper<
1355
1361
  TAD extends number,
1356
1362
  E extends { [key: string | number | symbol]: any } = {},
1357
1363
  REP extends string | number | symbol = never,
1364
+ AS_PROMISE = 0,
1358
1365
  > = (
1359
1366
  makeSLFNInput: () => F,
1360
1367
  SLFN_name: N,
@@ -1363,19 +1370,22 @@ export class SelectionWrapper<
1363
1370
  ) => <TT = T, FF = F, EE = E>(
1364
1371
  this: any,
1365
1372
  s: (selection: FF) => TT,
1366
- ) => ToTArrayWithDepth<
1367
- {
1368
- [K in keyof TT]: TT[K] extends SelectionWrapperImpl<
1369
- infer FN,
1370
- infer TTNP,
1371
- infer TTAD,
1372
- infer VT,
1373
- infer AT
1374
- >
1375
- ? ToTArrayWithDepth<SLW_TPN_ToType<TTNP>, TTAD>
1376
- : TT[K];
1377
- },
1378
- TAD
1373
+ ) => ConvertToPromise<
1374
+ ToTArrayWithDepth<
1375
+ {
1376
+ [K in keyof TT]: TT[K] extends SelectionWrapperImpl<
1377
+ infer FN,
1378
+ infer TTNP,
1379
+ infer TTAD,
1380
+ infer VT,
1381
+ infer AT
1382
+ >
1383
+ ? ToTArrayWithDepth<SLW_TPN_ToType<TTNP>, TTAD>
1384
+ : TT[K];
1385
+ },
1386
+ TAD
1387
+ >,
1388
+ AS_PROMISE
1379
1389
  > & {
1380
1390
  [k in keyof EE]: k extends REP
1381
1391
  ? EE[k] extends (...args: any) => any
@@ -1550,9 +1560,9 @@ export class SelectionWrapper<
1550
1560
  `:""}`;let Z=new Map,q=`
1551
1561
  export function make${D}Input(this: any) ${this.typeMeta.isUnion?"":`: ReturnTypeFrom${D}`} {
1552
1562
  return {
1553
- ${this.typeMeta.fields.map((J)=>[J,this.makeSelectionFunctionInputObjectValueForField(J,this.typeMeta.isInput?[]:[this.typeName])]).map(([J,Y])=>{return Z.set(J.name,`${J.hasArgs?`(
1563
+ ${this.typeMeta.fields.map((J)=>[J,this.makeSelectionFunctionInputObjectValueForField(J,this.typeMeta.isInput?[]:[this.typeName])]).map(([J,Y])=>{return Z.set(J.name,[`${J.hasArgs?`(
1554
1564
  args: ${this.typeName}${J.name.slice(0,1).toUpperCase()}${J.name.slice(1)}Args
1555
- ) =>`:""} ${J.type.isScalar||J.type.isEnum?`SelectionWrapperImpl<"${J.name}", "${J.type.name.replaceAll("[","").replaceAll("]","").replaceAll("!","")}", ${J.type.isList}, {}, ${J.hasArgs?`${this.typeName}${J.name.slice(0,1).toUpperCase()}${J.name.slice(1)}Args`:"undefined"}>`:`ReturnType<
1565
+ ) =>`:""}`,`${J.type.isScalar||J.type.isEnum?`SelectionWrapperImpl<"${J.name}", "${J.type.name.replaceAll("[","").replaceAll("]","").replaceAll("!","")}", ${J.type.isList}, {}, ${J.hasArgs?`${this.typeName}${J.name.slice(0,1).toUpperCase()}${J.name.slice(1)}Args`:"undefined"}>`:`ReturnType<
1556
1566
  SLFN<
1557
1567
  {},
1558
1568
  ReturnType<typeof make${super.originalTypeNameToTypescriptFriendlyName(J.type.name)}SelectionInput>,
@@ -1565,10 +1575,11 @@ export class SelectionWrapper<
1565
1575
  ${J.hasArgs?`args: ${this.typeName}${J.name.slice(0,1).toUpperCase()}${J.name.slice(1)}Args`:""}
1566
1576
  ) => Promise<"T">
1567
1577
  },
1568
- "$lazy"
1578
+ "$lazy",
1579
+ AS_PROMISE
1569
1580
  `:""}
1570
1581
  >
1571
- >`}`),`${Y},`}).join(`
1582
+ >`}`]),`${Y},`}).join(`
1572
1583
  `)}
1573
1584
 
1574
1585
  ${B}
@@ -1581,8 +1592,12 @@ export class SelectionWrapper<
1581
1592
  ${this.typeMeta.isList??0}
1582
1593
  );
1583
1594
  `,X=this.typeMeta.isUnion?"":`
1595
+ type ReturnTypeFrom${D}RetTypes<AS_PROMISE = 0> = {
1596
+ ${Array.from(Z).map(([J,[Y,H]])=>`${J}: ${H}`).join(`
1597
+ `)}
1598
+ }
1584
1599
  type ReturnTypeFrom${D} = {
1585
- ${Array.from(Z).map(([J,Y])=>`${J}: ${Y}`).join(`
1600
+ ${Array.from(Z).map(([J,[Y,H]])=>`${J}: ${Y} ReturnTypeFrom${D}RetTypes["${J}"]`).join(`
1586
1601
  `)}
1587
1602
  } & {
1588
1603
  $fragment: <F extends (this: any, ...args: any[]) => any>(
@@ -1595,9 +1610,9 @@ export class SelectionWrapper<
1595
1610
  `:""}
1596
1611
  };`;return this.collector.addSelectionFunction(this.typeMeta,`${X}
1597
1612
  ${q}
1598
- `),D}static makeRootOperationFunction(D,F){let{QueryTypeName:P,MutationTypeName:B,SubscriptionTypeName:Z}=D,q=[...D.types.values()].filter((J)=>J.isDirective?.locations.some((Y)=>[C3.DirectiveLocation.FIELD,C3.DirectiveLocation.FRAGMENT_SPREAD,C3.DirectiveLocation.INLINE_FRAGMENT].includes(Y))).map((J)=>{return`"${J.isDirective.name}": ${new m2(J.name,D,{}).makeDirective()}`});return`
1599
- ${q?.length?`export const $directives = {
1600
- ${q.join(`,
1613
+ `),D}static makeRootOperationFunction(D,F){let{QueryTypeName:P,MutationTypeName:B,SubscriptionTypeName:Z}=D,q=[P,B,Z].filter(Boolean),X=[...D.types.values()].filter((Y)=>Y.isDirective?.locations.some((H)=>[C3.DirectiveLocation.FIELD,C3.DirectiveLocation.FRAGMENT_SPREAD,C3.DirectiveLocation.INLINE_FRAGMENT].includes(H))).map((Y)=>{return`"${Y.isDirective.name}": ${new m2(Y.name,D,{}).makeDirective()}`});return`
1614
+ ${X?.length?`export const $directives = {
1615
+ ${X.join(`,
1601
1616
  `)}
1602
1617
  } as const;`:""}
1603
1618
  export function _makeRootOperationInput(this: any) {
@@ -1615,7 +1630,7 @@ export class SelectionWrapper<
1615
1630
  isRootType: "Subscription",
1616
1631
  }),`:""}
1617
1632
 
1618
- ${q?.length?`
1633
+ ${X?.length?`
1619
1634
  $directives,`:""}
1620
1635
  } as const;
1621
1636
  };
@@ -1807,9 +1822,266 @@ export class SelectionWrapper<
1807
1822
  value: __init__,
1808
1823
  });
1809
1824
 
1825
+ const _makeOperationShortcut = <O extends ${q.map((Y)=>`"${Y}"`).join(" | ")}>(
1826
+ operation: O,
1827
+ field: Exclude<
1828
+ typeof operation extends "${q[0]}"
1829
+ ? keyof ReturnTypeFrom${q[0]}Selection
1830
+ ${q.length>2?`
1831
+ typeof operation extends "${q[1]}"
1832
+ ? keyof ReturnTypeFrom${q[1]}Selection
1833
+ : keyof ReturnTypeFrom${q[2]}Selection`:`: keyof ReturnTypeFrom${q[1]}Selection,`}
1834
+ "$fragment" | "$scalars"
1835
+ >,
1836
+ ) => {
1837
+ const root = new OperationSelectionCollector(
1838
+ undefined,
1839
+ undefined,
1840
+ new RootOperation(),
1841
+ );
1842
+ const rootRef = { ref: root };
1843
+
1844
+ let fieldFn: ${q.map((Y)=>`
1845
+ ReturnTypeFrom${Y}Selection[Exclude<
1846
+ keyof ReturnTypeFrom${Y}Selection,
1847
+ "$fragment" | "$scalars"
1848
+ >]`).join(" | ")};
1849
+
1850
+ if (operation === "${q[0]}") {
1851
+ fieldFn =
1852
+ make${q[0]}SelectionInput.bind(rootRef)()[
1853
+ field as Exclude<
1854
+ keyof ReturnTypeFrom${q[0]}Selection,
1855
+ "$fragment" | "$scalars"
1856
+ >
1857
+ ];
1858
+ } else ${q.length>2?`if (operation === "${q[1]})"`:""}{
1859
+ fieldFn =
1860
+ make${q[1]}SelectionInput.bind(rootRef)()[
1861
+ field as Exclude<
1862
+ keyof ReturnTypeFrom${q[1]}Selection,
1863
+ "$fragment" | "$scalars"
1864
+ >
1865
+ ];
1866
+ }
1867
+ ${q.length>2?`else {
1868
+ fieldFn =
1869
+ make${q[2]}SelectionInput.bind(rootRef)()[
1870
+ field as Exclude<
1871
+ keyof ReturnTypeFrom${q[2]}Selection,
1872
+ "$fragment" | "$scalars"
1873
+ >
1874
+ ];
1875
+ }`:""}
1876
+
1877
+ if (typeof fieldFn === "function") {
1878
+ const makeSubSelectionFn =
1879
+ (
1880
+ opFnArgs?: Exclude<
1881
+ Parameters<typeof fieldFn>[0],
1882
+ (args: any) => any
1883
+ >,
1884
+ ) =>
1885
+ (opFnSelectionCb: (selection: unknown) => unknown) => {
1886
+ const fieldSLFN =
1887
+ opFnArgs === undefined
1888
+ ? fieldFn
1889
+ : (
1890
+ fieldFn as (
1891
+ args: typeof opFnArgs,
1892
+ ) => (s: typeof opFnSelectionCb) => unknown
1893
+ )(opFnArgs);
1894
+
1895
+ const fieldSlw = fieldSLFN(
1896
+ opFnSelectionCb,
1897
+ ) as unknown as SelectionWrapperImpl<
1898
+ typeof field,
1899
+ string,
1900
+ number,
1901
+ any,
1902
+ typeof opFnArgs
1903
+ >;
1904
+ const opSlw = new SelectionWrapper(
1905
+ undefined,
1906
+ undefined,
1907
+ undefined,
1908
+ { [field]: fieldSlw },
1909
+ new OperationSelectionCollector(
1910
+ operation + "Selection",
1911
+ root,
1912
+ ),
1913
+ root,
1914
+ );
1915
+ fieldSlw[SLW_PARENT_SLW] = opSlw;
1916
+ opSlw[SLW_IS_ROOT_TYPE] = operation;
1917
+ opSlw[SLW_PARENT_COLLECTOR] = opSlw[SLW_COLLECTOR];
1918
+ // access the keys of the proxy object, to register operations
1919
+ (opSlw as any)[field as any];
1920
+ const rootSlw = new SelectionWrapper(
1921
+ undefined,
1922
+ undefined,
1923
+ undefined,
1924
+ opSlw,
1925
+ root,
1926
+ );
1927
+ opSlw[ROOT_OP_COLLECTOR] = rootRef;
1928
+ // access the keys of the proxy object, to register operations
1929
+ (rootSlw as any)[field as any];
1930
+
1931
+ return new Proxy(
1932
+ {},
1933
+ {
1934
+ get(_t, _prop) {
1935
+ if (String(_prop) === "$lazy") {
1936
+ return (fieldSlw as any)[_prop].bind({
1937
+ parentSlw: opSlw,
1938
+ key: field,
1939
+ });
1940
+ } else {
1941
+ const result = new Promise(
1942
+ (resolve, reject) => {
1943
+ root.execute({})
1944
+ .then(() => {
1945
+ resolve(
1946
+ (rootSlw as any)[field],
1947
+ );
1948
+ })
1949
+ .catch(reject);
1950
+ },
1951
+ );
1952
+ if (String(_prop) === "then") {
1953
+ return result.then.bind(result);
1954
+ }
1955
+ return result;
1956
+ }
1957
+ },
1958
+ },
1959
+ );
1960
+ };
1961
+
1962
+ // if the fieldFn is the SLFN subselection function without an (args) => .. wrapper
1963
+ if (fieldFn.name === "bound _SLFN") {
1964
+ return makeSubSelectionFn();
1965
+ }
1966
+ return (
1967
+ opFnArgs: Exclude<
1968
+ Parameters<typeof fieldFn>[0],
1969
+ (args: any) => any
1970
+ >,
1971
+ ) => {
1972
+ return makeSubSelectionFn(opFnArgs);
1973
+ };
1974
+ } else {
1975
+ const fieldSlw = fieldFn as SelectionWrapperImpl<any, any, any>;
1976
+ const opSlw = new SelectionWrapper(
1977
+ undefined,
1978
+ undefined,
1979
+ undefined,
1980
+ { [field]: fieldSlw },
1981
+ new OperationSelectionCollector(operation + "Selection", root),
1982
+ root,
1983
+ );
1984
+ fieldSlw[ROOT_OP_COLLECTOR] = rootRef;
1985
+ opSlw[SLW_IS_ROOT_TYPE] = operation;
1986
+ opSlw[SLW_PARENT_COLLECTOR] = opSlw[SLW_COLLECTOR];
1987
+ opSlw[SLW_PARENT_SLW] = opSlw;
1988
+ // access the keys of the proxy object, to register operations
1989
+ (opSlw as any)[field as any];
1990
+ const rootSlw = new SelectionWrapper(
1991
+ undefined,
1992
+ undefined,
1993
+ undefined,
1994
+ opSlw,
1995
+ root,
1996
+ );
1997
+ opSlw[ROOT_OP_COLLECTOR] = rootRef;
1998
+ // access the keys of the proxy object, to register operations
1999
+ (rootSlw as any)[field as any];
2000
+
2001
+ return new Proxy(
2002
+ {},
2003
+ {
2004
+ get(_t, _prop) {
2005
+ if (String(_prop) === "$lazy") {
2006
+ return (fieldSlw as any)[_prop].bind({
2007
+ parentSlw: opSlw,
2008
+ key: field,
2009
+ });
2010
+ } else {
2011
+ const result = new Promise(
2012
+ (resolve, reject) => {
2013
+ root.execute({})
2014
+ .then(() => {
2015
+ resolve(
2016
+ (rootSlw as any)[field],
2017
+ );
2018
+ })
2019
+ .catch(reject);
2020
+ },
2021
+ );
2022
+ if (String(_prop) === "then") {
2023
+ return result.then.bind(result);
2024
+ }
2025
+ return result;
2026
+ }
2027
+ },
2028
+ },
2029
+ );
2030
+ }
2031
+ };
2032
+
2033
+ ${q.map((Y)=>`
2034
+ Object.defineProperty(__client__, "${Y.toLowerCase()}", {
2035
+ enumerable: false,
2036
+ get() {
2037
+ return new Proxy(
2038
+ {},
2039
+ {
2040
+ get(
2041
+ target,
2042
+ op: Exclude<
2043
+ keyof ReturnTypeFrom${Y}Selection,
2044
+ "$fragment" | "$scalars"
2045
+ >,
2046
+ ) {
2047
+ return _makeOperationShortcut("${Y}", op);
2048
+ },
2049
+ },
2050
+ );
2051
+ },
2052
+ });
2053
+ `).join(`
2054
+ `)}
2055
+
1810
2056
  export default __client__ as typeof __client__ & {
1811
2057
  init: typeof __init__;
1812
- };
2058
+ } & {
2059
+ ${q.map((Y)=>`${Y?.toLowerCase()}: {
2060
+ [field in Exclude<
2061
+ keyof ReturnType<typeof make${Y}SelectionInput>,
2062
+ "$fragment" | "$scalars"
2063
+ >]: ReturnType<
2064
+ typeof make${Y}SelectionInput
2065
+ >[field] extends SelectionWrapperImpl<
2066
+ infer FN,
2067
+ infer TTNP,
2068
+ infer TTAD,
2069
+ infer VT,
2070
+ infer AT
2071
+ >
2072
+ ? ToTArrayWithDepth<SLW_TPN_ToType<TTNP>, TTAD> & {
2073
+ $lazy: () => Promise<
2074
+ ToTArrayWithDepth<SLW_TPN_ToType<TTNP>, TTAD>
2075
+ >;
2076
+ }
2077
+ : ReturnType<typeof make${Y}SelectionInput>[field]extends (
2078
+ args: infer A,
2079
+ ) => (selection: any) => any
2080
+ ? (args: A) => ReturnTypeFrom${Y}SelectionRetTypes<1>[field]
2081
+ : ReturnTypeFrom${Y}SelectionRetTypes<1>[field];
2082
+ };`).join(`
2083
+ `)}
2084
+ }
1813
2085
  `}}class _1{collector;options;static FieldValueWrapperType;static EnumTypesMapped;static HelperTypes;static HelperFunctions;typeMeta;typeName;originalFullTypeName;constructor(D,F,P){this.collector=F,this.options=P,this.typeMeta=F.getType(D),this.originalFullTypeName=D,this.typeName=this.originalTypeNameToTypescriptFriendlyName(D)}static originalTypeNameToTypescriptFriendlyName(D){return D.replaceAll("[","").replaceAll("]","Array").replaceAll("!","")}originalTypeNameToTypescriptFriendlyName(D){return _1.originalTypeNameToTypescriptFriendlyName(D)}static originalTypeNameToTypescriptTypeNameWithoutModifiers(D,F=""){return`${D.replaceAll("[","").replaceAll("]","").replaceAll("!","")}${F}`}originalTypeNameToTypescriptTypeNameWithoutModifiers(D,F=""){return _1.originalTypeNameToTypescriptTypeNameWithoutModifiers(D,F)}static originalTypeNameToTypescriptTypeName(D,F=""){return`${this.originalTypeNameToTypescriptTypeNameWithoutModifiers(D,F)}${Array.from({length:D.split("[").length-1}).fill("[]").join("")}`}originalTypeNameToTypescriptTypeName(D,F=""){return _1.originalTypeNameToTypescriptTypeName(D,F)}static makeRootOperationFunction(D,F,P,B){throw new Error("Method not implemented.")}}var YT=`const Proxy = global.Proxy;
1814
2086
  Proxy.prototype = {};
1815
2087
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samarium.sdk/new",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "main": "bin/samarium",
5
5
  "type": "module",
6
6
  "repository": {
@@ -21,7 +21,7 @@
21
21
  "graphql-sdk",
22
22
  "graphql-codegen"
23
23
  ],
24
- "homepage": "https://github.com/liontariai/samarium",
24
+ "homepage": "https://liontari.ai",
25
25
  "bin": {
26
26
  "samarium": "bin/samarium"
27
27
  },