@samarium.sdk/new 0.17.0 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/bin/samarium +24 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -18,13 +18,13 @@ It's done in 10s and you'll never bother with GraphQL or clumsy OpenAPI fetch wr
|
|
|
18
18
|
<span> · </span>
|
|
19
19
|
<a href="https://github.com/liontariai/samarium">GitHub</a>
|
|
20
20
|
<span> · </span>
|
|
21
|
-
<a href="https://npmjs.com/package/@
|
|
21
|
+
<a href="https://npmjs.com/package/@samarium.sdk/new">NPM</a>
|
|
22
22
|
<br />
|
|
23
23
|
<br />
|
|
24
24
|
|
|
25
25
|
[](https://github.com/liontariai/samarium/commits/main/)
|
|
26
|
-
[](https://www.npmjs.com/package/@samarium.sdk/new)
|
|
27
|
+
[](https://www.npmjs.com/package/@samarium.sdk/new)
|
|
28
28
|
|
|
29
29
|
<hr/>
|
|
30
30
|
</div>
|
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.17.
|
|
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.2",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 = {};
|
|
@@ -1827,10 +1827,10 @@ export class SelectionWrapper<
|
|
|
1827
1827
|
field: Exclude<
|
|
1828
1828
|
typeof operation extends "${q[0]}"
|
|
1829
1829
|
? keyof ReturnTypeFrom${q[0]}Selection
|
|
1830
|
-
${q.length>2?`
|
|
1830
|
+
: ${q.length>2?`
|
|
1831
1831
|
typeof operation extends "${q[1]}"
|
|
1832
1832
|
? keyof ReturnTypeFrom${q[1]}Selection
|
|
1833
|
-
: keyof ReturnTypeFrom${q[2]}Selection
|
|
1833
|
+
: keyof ReturnTypeFrom${q[2]}Selection,`:`keyof ReturnTypeFrom${q[1]}Selection,`}
|
|
1834
1834
|
"$fragment" | "$scalars"
|
|
1835
1835
|
>,
|
|
1836
1836
|
) => {
|
|
@@ -1855,7 +1855,7 @@ export class SelectionWrapper<
|
|
|
1855
1855
|
"$fragment" | "$scalars"
|
|
1856
1856
|
>
|
|
1857
1857
|
];
|
|
1858
|
-
} else ${q.length>2?`if (operation === "${q[1]})
|
|
1858
|
+
} else ${q.length>2?`if (operation === "${q[1]}")`:""}{
|
|
1859
1859
|
fieldFn =
|
|
1860
1860
|
make${q[1]}SelectionInput.bind(rootRef)()[
|
|
1861
1861
|
field as Exclude<
|
|
@@ -1893,7 +1893,7 @@ export class SelectionWrapper<
|
|
|
1893
1893
|
)(opFnArgs);
|
|
1894
1894
|
|
|
1895
1895
|
const fieldSlw = fieldSLFN(
|
|
1896
|
-
opFnSelectionCb,
|
|
1896
|
+
opFnSelectionCb as any,
|
|
1897
1897
|
) as unknown as SelectionWrapperImpl<
|
|
1898
1898
|
typeof field,
|
|
1899
1899
|
string,
|
|
@@ -2078,6 +2078,25 @@ export class SelectionWrapper<
|
|
|
2078
2078
|
args: infer A,
|
|
2079
2079
|
) => (selection: any) => any
|
|
2080
2080
|
? (args: A) => ReturnTypeFrom${Y}SelectionRetTypes<1>[field]
|
|
2081
|
+
: ReturnType<typeof make${Y}SelectionInput>[field] extends (
|
|
2082
|
+
args: infer _A,
|
|
2083
|
+
) => SelectionWrapperImpl<
|
|
2084
|
+
infer _FN,
|
|
2085
|
+
infer _TTNP,
|
|
2086
|
+
infer _TTAD,
|
|
2087
|
+
infer _VT,
|
|
2088
|
+
infer _AT
|
|
2089
|
+
>
|
|
2090
|
+
? (args: _A) => ToTArrayWithDepth<
|
|
2091
|
+
SLW_TPN_ToType<_TTNP>,
|
|
2092
|
+
_TTAD
|
|
2093
|
+
> & {
|
|
2094
|
+
$lazy: (
|
|
2095
|
+
args: _A,
|
|
2096
|
+
) => Promise<
|
|
2097
|
+
ToTArrayWithDepth<SLW_TPN_ToType<_TTNP>, _TTAD>
|
|
2098
|
+
>;
|
|
2099
|
+
}
|
|
2081
2100
|
: ReturnTypeFrom${Y}SelectionRetTypes<1>[field];
|
|
2082
2101
|
};`).join(`
|
|
2083
2102
|
`)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samarium.sdk/new",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"main": "bin/samarium",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"bun-types": "^1.1.29",
|
|
47
|
-
"@samarium.sdk/make": "0.
|
|
47
|
+
"@samarium.sdk/make": "0.17.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"typescript": "^5.0.0"
|