@m1212e/rumble 0.11.1 → 0.11.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/index.cjs CHANGED
@@ -93,7 +93,7 @@ spurious results.`)}}return false};function pt(e,t){let[n,r]=t?[e,t]:[void 0,e]
93
93
  }`}function Hn(e,t){let n=false,r=false;for(let l=0;l<3;l++)e instanceof M&&(r=true,e=e.ofType),e instanceof U&&(n=true,e=e.ofType);let o=e.name;r&&(o+="[]"),n||(o+=" | null");let i=e instanceof J,s=new Map;for(let l of t??[])s.set(l.name,Zn(l.type));if(i){let l=s.entries().every(([,p])=>p.includes("| undefined"));return `(${(t??[]).length>0?`p${l?"?":""}: {
94
94
  ${s.entries().map(([p,a])=>` ${p}${a.includes("| undefined")?"?":""}: ${a}`).toArray().join(`,
95
95
  `)}
96
- }`:""}) => ${o}`}else return o}function Xn(e){let t=false,n=false;for(let o=0;o<3;o++)e instanceof M&&(n=true,e=e.ofType),e instanceof U&&(t=true,e=e.ofType);let r=e.name;return n&&(r+="[]"),t?n&&(r+=" | undefined"):r+=" | null | undefined",r}function Zn(e){let t="unknown",n=true;return e instanceof U&&(n=false,e=e.ofType),(e instanceof K||e instanceof W)&&(t=e.name),n&&(t+=" | null | undefined"),t}function er(e){switch(e.name){case "ID":return "string";case "String":return "string";case "Boolean":return "boolean";case "Int":return "number";case "Float":return "number";case "Date":return "Date";case "DateTime":return "Date";case "JSON":return "any";default:return "unknown"}}function tr(e){return e.getValues().map(t=>`"${t.name}"`).join(" | ")}async function Me({outputPath:e,schema:t,rumbleImportPath:n="@m1212e/rumble",apiUrl:r,useExternalUrqlClient:o=false}){await promises.exists(e)&&await promises.rm(e,{recursive:true,force:true}),await promises.mkdir(e,{recursive:true}),e.endsWith("/")||(e+="/");let i=[],s="",l=new Map;for(let[p,a]of Object.entries(t.getTypeMap()))p.startsWith("__")||l.set(p,a);for(let[p,a]of l.entries())Ve(a)!==p&&(s+=`
96
+ }`:""}) => ${o}`}else return o}function Xn(e){let t=false,n=false;for(let o=0;o<3;o++)e instanceof M&&(n=true,e=e.ofType),e instanceof U&&(t=true,e=e.ofType);let r=e.name;return n&&(r+="[]"),t?n&&(r+=" | undefined"):r+=" | null | undefined",r}function Zn(e){let t="unknown",n=true;return e instanceof U&&(n=false,e=e.ofType),(e instanceof K||e instanceof W)&&(t=e.name),n&&(t+=" | null | undefined"),t}function er(e){switch(e.name){case "ID":return "string";case "String":return "string";case "Boolean":return "boolean";case "Int":return "number";case "Float":return "number";case "Date":return "Date";case "DateTime":return "Date";case "JSON":return "any";default:return "unknown"}}function tr(e){return e.getValues().map(t=>`"${t.name}"`).join(" | ")}async function Me({outputPath:e,schema:t,rumbleImportPath:n="@m1212e/rumble",apiUrl:r,useExternalUrqlClient:o=false}){try{await promises.access(e),await promises.rm(e,{recursive:!0,force:!0});}catch{}await promises.mkdir(e,{recursive:true}),e.endsWith("/")||(e+="/");let i=[],s="",l=new Map;for(let[p,a]of Object.entries(t.getTypeMap()))p.startsWith("__")||l.set(p,a);for(let[p,a]of l.entries())Ve(a)!==p&&(s+=`
97
97
  export type ${p} = ${Ve(a)};
98
98
  `);let u=et({apiUrl:r,useExternalUrqlClient:o,rumbleImportPath:n,availableSubscriptions:new Set(Object.keys(t.getSubscriptionType()?.getFields()||{}))});i.push(...u.imports),s+=u.code,await promises.writeFile(path.join(e,"client.ts"),`${i.join(`
99
99
  `)}