@samarium.sdk/new 0.24.0 → 0.24.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 +42 -10
  2. package/package.json +3 -3
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=l8(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=l8(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=l8(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=l8(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=l8(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.24.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)}`)},N1=(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",u1="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(u1)},j7=(D)=>{try{if(Array.isArray(D))return{_tag:"Batch",executionResults:D.map(XU)};else if(N1(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=l8(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=l8(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.24.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.js",prepublishOnly:"bun run bundle",test:"bun test"},prettier:{tabWidth:4},devDependencies:{"bun-types":"^1.1.29"},peerDependencies:{typescript:"^5.0.0"},dependencies:{"@samarium.sdk/make":"workspace:*","@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)}`)},N1=(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",u1="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(u1)},j7=(D)=>{try{if(Array.isArray(D))return{_tag:"Batch",executionResults:D.map(XU)};else if(N1(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(!N1(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(!N1(D.data)&&D.data!==null)throw new Error("Invalid execution result: data is not plain object");P=D.data}if("extensions"in D){if(!N1(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},_1=(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,u1].join(", "));if(D==="POST"){if(Z=(F.fetchOptions.jsonSerializer??K3).stringify(BT(F)),typeof Z==="string"&&!P.has($3))P.set($3,u1)}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=_1(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=_1(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})=>_1(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;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 new Error("Method not implemented.")}}var JT=`const Proxy = globalThis.Proxy;
360
360
  Proxy.prototype = {};
@@ -947,6 +947,7 @@ export const SLW_RECREATE_VALUE_CALLBACK = Symbol(
947
947
  "SLW_RECREATE_VALUE_CALLBACK",
948
948
  );
949
949
  export const SLW_SETTER_DATA_OVERRIDE = Symbol("SLW_SETTER_DATA_OVERRIDE");
950
+ export const SLW_NEEDS_CLONE = Symbol("SLW_NEEDS_CLONE");
950
951
 
951
952
  export const SLW_CLONE = Symbol("SLW_CLONE");
952
953
 
@@ -968,6 +969,7 @@ export class SelectionWrapperImpl<
968
969
  SLW_OP_PATH?: string;
969
970
  OP_RESULT_DATA?: any;
970
971
  SLW_SETTER_DATA_OVERRIDE?: any;
972
+ SLW_NEEDS_CLONE?: boolean;
971
973
  } = {},
972
974
  ) {
973
975
  const slw = new SelectionWrapper(
@@ -990,6 +992,12 @@ export class SelectionWrapperImpl<
990
992
  overrides.SLW_SETTER_DATA_OVERRIDE ??
991
993
  this[SLW_SETTER_DATA_OVERRIDE];
992
994
 
995
+ slw[SLW_NEEDS_CLONE] = overrides.SLW_NEEDS_CLONE
996
+ ? true
997
+ : this[SLW_NEEDS_CLONE]
998
+ ? false
999
+ : true;
1000
+
993
1001
  if (overrides.OP_RESULT_DATA) {
994
1002
  slw[SLW_OP_RESULT_DATA_OVERRIDE] = overrides.OP_RESULT_DATA;
995
1003
  }
@@ -1019,11 +1027,11 @@ export class SelectionWrapperImpl<
1019
1027
 
1020
1028
  [SLW_PARENT_SLW]?: SelectionWrapperImpl<string, string, number, any, any>;
1021
1029
  [SLW_LAZY_FLAG]?: boolean;
1022
-
1023
1030
  [SLW_RECREATE_VALUE_CALLBACK]?: () => valueT;
1024
1031
 
1025
1032
  [SLW_OP_RESULT_DATA_OVERRIDE]?: any;
1026
1033
  [SLW_SETTER_DATA_OVERRIDE]?: any;
1034
+ [SLW_NEEDS_CLONE]?: boolean;
1027
1035
 
1028
1036
  constructor(
1029
1037
  fieldName?: fieldName,
@@ -1221,7 +1229,8 @@ export class SelectionWrapper<
1221
1229
  const cache = getCache(t);
1222
1230
 
1223
1231
  const path = overrideOpPath ?? t[SLW_OP_PATH] ?? "";
1224
- if (cache.data.has(path)) return cache.data.get(path);
1232
+ if (cache.data.has(path) && !t[SLW_NEEDS_CLONE])
1233
+ return cache.data.get(path);
1225
1234
 
1226
1235
  const data = t[
1227
1236
  ROOT_OP_COLLECTOR
@@ -1489,6 +1498,10 @@ export class SelectionWrapper<
1489
1498
  asyncGenRootPath,
1490
1499
  OP_RESULT_DATA:
1491
1500
  val.value,
1501
+
1502
+ // this is only for subscriptions
1503
+ SLW_NEEDS_CLONE:
1504
+ true,
1492
1505
  }),
1493
1506
  };
1494
1507
  });
@@ -1592,13 +1605,32 @@ export class SelectionWrapper<
1592
1605
  (target[SLW_OP_RESULT_DATA_OVERRIDE] &&
1593
1606
  !slw[SLW_OP_RESULT_DATA_OVERRIDE])
1594
1607
  ) {
1595
- // index access detected, setting the op path
1596
- // with the index (coming from the slw's parent (target))
1597
- // it's in the parent because the parent was cloned before
1598
- slw[SLW_OP_PATH] =
1599
- target[SLW_OP_PATH] + "." + String(prop);
1600
- slw[SLW_OP_RESULT_DATA_OVERRIDE] =
1601
- target[SLW_OP_RESULT_DATA_OVERRIDE];
1608
+ if (target[SLW_NEEDS_CLONE]) {
1609
+ // if the slw is flagged it needs to be cloned
1610
+ // this is only for subscriptions, because
1611
+ // the original slw will continue to exist
1612
+ // and also have the same op path
1613
+ // we need a new object that doesn't reference
1614
+ // the other objects
1615
+ slw = slw[SLW_CLONE]({
1616
+ SLW_OP_PATH:
1617
+ target[SLW_OP_PATH] +
1618
+ "." +
1619
+ String(prop),
1620
+ OP_RESULT_DATA:
1621
+ target[SLW_OP_RESULT_DATA_OVERRIDE],
1622
+ });
1623
+ } else {
1624
+ // index access detected, setting the op path
1625
+ // with the index (coming from the slw's parent (target))
1626
+ // it's in the parent because the parent was cloned before
1627
+ slw[SLW_OP_PATH] =
1628
+ target[SLW_OP_PATH] +
1629
+ "." +
1630
+ String(prop);
1631
+ slw[SLW_OP_RESULT_DATA_OVERRIDE] =
1632
+ target[SLW_OP_RESULT_DATA_OVERRIDE];
1633
+ }
1602
1634
  }
1603
1635
 
1604
1636
  if (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samarium.sdk/new",
3
- "version": "0.24.0",
3
+ "version": "0.24.1",
4
4
  "main": "bin/samarium",
5
5
  "type": "module",
6
6
  "repository": {
@@ -43,13 +43,13 @@
43
43
  "tabWidth": 4
44
44
  },
45
45
  "devDependencies": {
46
- "bun-types": "^1.1.29",
47
- "@samarium.sdk/make": "0.21.2"
46
+ "bun-types": "^1.1.29"
48
47
  },
49
48
  "peerDependencies": {
50
49
  "typescript": "^5.0.0"
51
50
  },
52
51
  "dependencies": {
52
+ "@samarium.sdk/make": "0.21.2",
53
53
  "@inquirer/prompts": "^5.0.5",
54
54
  "commander": "^11.1.0",
55
55
  "detect-indent": "^7.0.1",