From 6c25df3bc9ec089f52d7152bdd362a76f40f5ff2 Mon Sep 17 00:00:00 2001 From: POPPIN-FUMI Date: Tue, 12 Sep 2023 09:41:28 +0200 Subject: [PATCH] update: release v1.8.2 --- dist/index.js | 4 ++-- package.json | 2 +- src/lib/version.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index e41a89bd..a009e21f 100755 --- a/dist/index.js +++ b/dist/index.js @@ -984,7 +984,7 @@ You must use <@skeet-framework/firestore> to retrieve data from Firestore. catch (error) { throw new Error(\`findLargest: \${error}\`) } -}`}]}},sQ=async(c,g,d,p,h,s,a,f)=>{try{let b=uQ(d,p,h,s,a,f);return await fi(b,c,g.ai,g.aiInstance)}catch(b){throw new Error(`skeetNaming: ${b}`)}};dQ.config();var tl,kh=(tl=class{ai;model;maxTokens;temperature;_initOptions;aiInstance;functionConfigPaths=g=>({packageJson:`${tl.FUNCTION_ROOT}/${g}/package.json`,tsconfigJson:`${tl.FUNCTION_ROOT}/${g}/tsconfig.json`});constructor(g={}){this.ai=g.ai||"VertexAI",this.model=g.model||(this.ai==="VertexAI"?"chat-bison@001":"gpt-4"),this.maxTokens=g.maxTokens||1e3,this.temperature=g.temperature||0,this.ai==="VertexAI"?this.aiInstance=new Sd({model:this.model,maxOutputTokens:this.maxTokens}):this.aiInstance=new Od({model:this.model,maxTokens:this.maxTokens,apiKey:process.env.CHAT_GPT_KEY||"",organizationKey:process.env.CHAT_GPT_ORG||""}),this._initOptions=g}get initOptions(){return this._initOptions}async prisma(g){try{return await NH(g,this)}catch(d){this.handleError(d)}}async skeet(g){try{return await IH(g,this)}catch(d){throw new Error(`skeet: ${d}`)}}async uploadFile(g){try{return await xH(g,this.ai,this.aiInstance)}catch(d){this.handleError(d)}}async createFineTuningJob(g,d="gpt-3.5-turbo-0613"){try{return await EH(g,d,this.ai,this.aiInstance)}catch(p){this.handleError(p)}}async showFineTuningJob(g){try{return await MH(g,this.ai,this.aiInstance)}catch(d){this.handleError(d)}}async typedoc(g){try{return await UH(g,this)}catch(d){this.handleError(d)}}async naming(g,d="function"){try{return await zH(g,this,d)}catch(p){this.handleError(p)}}async translates(g,d="ja",p="en"){try{return await $H(g,d,p,this)}catch(h){this.handleError(h)}}async firestore(g){try{return await tQ(g,this)}catch(d){this.handleError(d)}}async function(g,d,p,h,s,a,f){try{return await sQ(g,this,d,p,h,s,a,f)}catch(b){this.handleError(b)}}async method(g,d,p,h,s,a){try{return await nQ(g,this,d,p,h,s,a)}catch(f){this.handleError(f)}}async run(g,d){try{let p=Ia(g.context,g.examples,d,this.ai);return this.ai==="VertexAI"?await this.aiInstance.prompt(p):await this.aiInstance.prompt(p)}catch(p){throw new Error(`run: ${p}`)}}handleError(g){console.error("Error:",g)}},k0(tl,"PRISMA_SCHEMA_PATH","./graphql/prisma/schema.prisma"),k0(tl,"MODEL_PATH","./functions/skeet/src/models"),k0(tl,"FUNCTION_ROOT","./functions"),tl),Cp=kh;});var Ozt={};ake(Ozt,{DEFAULT_FUNCTION_NAME:()=>Hr,FIREBASERC_PATH:()=>O5,GRAPHQL_ENV_BUILD_PATH:()=>WI,GRAPHQL_ENV_PRODUCTION_PATH:()=>ei,GRAPHQL_PATH:()=>ea,GRAPHQL_ROOT:()=>Xo,PRISMA_SCHEMA_PATH:()=>Ps,SKEET_CONFIG_PATH:()=>hp,TRANSLATE_PATH:()=>p$,program:()=>qt});module.exports=nke(Ozt);var o_e=st(lA());var AY=st(DY(),1),{program:Fzt,createCommand:_zt,createArgument:kzt,createOption:Mzt,CommanderError:Rzt,InvalidArgumentError:Nzt,InvalidOptionArgumentError:Bzt,Command:FY,Argument:Izt,Option:Lzt,Help:qzt}=AY.default;var _Y="1.8.1";var kY=(c=0)=>g=>`\x1B[${g+c}m`,MY=(c=0)=>g=>`\x1B[${38+c};5;${g}m`,RY=(c=0)=>(g,d,p)=>`\x1B[${38+c};2;${g};${d};${p}m`,Ao={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Vzt=Object.keys(Ao.modifier),_ke=Object.keys(Ao.color),kke=Object.keys(Ao.bgColor),Gzt=[..._ke,...kke];function Mke(){let c=new Map;for(let[g,d]of Object.entries(Ao)){for(let[p,h]of Object.entries(d))Ao[p]={open:`\x1B[${h[0]}m`,close:`\x1B[${h[1]}m`},d[p]=Ao[p],c.set(h[0],h[1]);Object.defineProperty(Ao,g,{value:d,enumerable:!1})}return Object.defineProperty(Ao,"codes",{value:c,enumerable:!1}),Ao.color.close="\x1B[39m",Ao.bgColor.close="\x1B[49m",Ao.color.ansi=kY(),Ao.color.ansi256=MY(),Ao.color.ansi16m=RY(),Ao.bgColor.ansi=kY(10),Ao.bgColor.ansi256=MY(10),Ao.bgColor.ansi16m=RY(10),Object.defineProperties(Ao,{rgbToAnsi256:{value(g,d,p){return g===d&&d===p?g<8?16:g>248?231:Math.round((g-8)/247*24)+232:16+36*Math.round(g/255*5)+6*Math.round(d/255*5)+Math.round(p/255*5)},enumerable:!1},hexToRgb:{value(g){let d=/[a-f\d]{6}|[a-f\d]{3}/i.exec(g.toString(16));if(!d)return[0,0,0];let[p]=d;p.length===3&&(p=[...p].map(s=>s+s).join(""));let h=Number.parseInt(p,16);return[h>>16&255,h>>8&255,h&255]},enumerable:!1},hexToAnsi256:{value:g=>Ao.rgbToAnsi256(...Ao.hexToRgb(g)),enumerable:!1},ansi256ToAnsi:{value(g){if(g<8)return 30+g;if(g<16)return 90+(g-8);let d,p,h;if(g>=232)d=((g-232)*10+8)/255,p=d,h=d;else{g-=16;let f=g%36;d=Math.floor(g/36)/5,p=Math.floor(f/6)/5,h=f%6/5}let s=Math.max(d,p,h)*2;if(s===0)return 30;let a=30+(Math.round(h)<<2|Math.round(p)<<1|Math.round(d));return s===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(g,d,p)=>Ao.ansi256ToAnsi(Ao.rgbToAnsi256(g,d,p)),enumerable:!1},hexToAnsi:{value:g=>Ao.ansi256ToAnsi(Ao.hexToAnsi256(g)),enumerable:!1}}),Ao}var Rke=Mke(),Gn=Rke;var U0=st(require("node:process"),1),BY=st(require("node:os"),1),SA=st(require("node:tty"),1);function gn(c,g=globalThis.Deno?globalThis.Deno.args:U0.default.argv){let d=c.startsWith("-")?"":c.length===1?"-":"--",p=g.indexOf(d+c),h=g.indexOf("--");return p!==-1&&(h===-1||p=2,has16m:c>=3}}function Ike(c,{streamIsTTY:g,sniffFlags:d=!0}={}){let p=Nke();p!==void 0&&(J0=p);let h=d?J0:p;if(h===0)return 0;if(d){if(gn("color=16m")||gn("color=full")||gn("color=truecolor"))return 3;if(gn("color=256"))return 2}if("TF_BUILD"in Lo&&"AGENT_NAME"in Lo)return 1;if(c&&!g&&h===void 0)return 0;let s=h||0;if(Lo.TERM==="dumb")return s;if(U0.default.platform==="win32"){let a=BY.default.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in Lo)return"GITHUB_ACTIONS"in Lo||"GITEA_ACTIONS"in Lo?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(a=>a in Lo)||Lo.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in Lo)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Lo.TEAMCITY_VERSION)?1:0;if(Lo.COLORTERM==="truecolor"||Lo.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in Lo){let a=Number.parseInt((Lo.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Lo.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Lo.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Lo.TERM)||"COLORTERM"in Lo?1:s}function NY(c,g={}){let d=Ike(c,{streamIsTTY:c&&c.isTTY,...g});return Bke(d)}var Lke={stdout:NY({isTTY:SA.default.isatty(1)}),stderr:NY({isTTY:SA.default.isatty(2)})},IY=Lke;function LY(c,g,d){let p=c.indexOf(g);if(p===-1)return c;let h=g.length,s=0,a="";do a+=c.slice(s,p)+g+d,s=p+h,p=c.indexOf(g,s);while(p!==-1);return a+=c.slice(s),a}function qY(c,g,d,p){let h=0,s="";do{let a=c[p-1]==="\r";s+=c.slice(h,a?p-1:p)+g+(a?`\r +}`}]}},sQ=async(c,g,d,p,h,s,a,f)=>{try{let b=uQ(d,p,h,s,a,f);return await fi(b,c,g.ai,g.aiInstance)}catch(b){throw new Error(`skeetNaming: ${b}`)}};dQ.config();var tl,kh=(tl=class{ai;model;maxTokens;temperature;_initOptions;aiInstance;functionConfigPaths=g=>({packageJson:`${tl.FUNCTION_ROOT}/${g}/package.json`,tsconfigJson:`${tl.FUNCTION_ROOT}/${g}/tsconfig.json`});constructor(g={}){this.ai=g.ai||"VertexAI",this.model=g.model||(this.ai==="VertexAI"?"chat-bison@001":"gpt-4"),this.maxTokens=g.maxTokens||1e3,this.temperature=g.temperature||0,this.ai==="VertexAI"?this.aiInstance=new Sd({model:this.model,maxOutputTokens:this.maxTokens}):this.aiInstance=new Od({model:this.model,maxTokens:this.maxTokens,apiKey:process.env.CHAT_GPT_KEY||"",organizationKey:process.env.CHAT_GPT_ORG||""}),this._initOptions=g}get initOptions(){return this._initOptions}async prisma(g){try{return await NH(g,this)}catch(d){this.handleError(d)}}async skeet(g){try{return await IH(g,this)}catch(d){throw new Error(`skeet: ${d}`)}}async uploadFile(g){try{return await xH(g,this.ai,this.aiInstance)}catch(d){this.handleError(d)}}async createFineTuningJob(g,d="gpt-3.5-turbo-0613"){try{return await EH(g,d,this.ai,this.aiInstance)}catch(p){this.handleError(p)}}async showFineTuningJob(g){try{return await MH(g,this.ai,this.aiInstance)}catch(d){this.handleError(d)}}async typedoc(g){try{return await UH(g,this)}catch(d){this.handleError(d)}}async naming(g,d="function"){try{return await zH(g,this,d)}catch(p){this.handleError(p)}}async translates(g,d="ja",p="en"){try{return await $H(g,d,p,this)}catch(h){this.handleError(h)}}async firestore(g){try{return await tQ(g,this)}catch(d){this.handleError(d)}}async function(g,d,p,h,s,a,f){try{return await sQ(g,this,d,p,h,s,a,f)}catch(b){this.handleError(b)}}async method(g,d,p,h,s,a){try{return await nQ(g,this,d,p,h,s,a)}catch(f){this.handleError(f)}}async run(g,d){try{let p=Ia(g.context,g.examples,d,this.ai);return this.ai==="VertexAI"?await this.aiInstance.prompt(p):await this.aiInstance.prompt(p)}catch(p){throw new Error(`run: ${p}`)}}handleError(g){console.error("Error:",g)}},k0(tl,"PRISMA_SCHEMA_PATH","./graphql/prisma/schema.prisma"),k0(tl,"MODEL_PATH","./functions/skeet/src/models"),k0(tl,"FUNCTION_ROOT","./functions"),tl),Cp=kh;});var Ozt={};ake(Ozt,{DEFAULT_FUNCTION_NAME:()=>Hr,FIREBASERC_PATH:()=>O5,GRAPHQL_ENV_BUILD_PATH:()=>WI,GRAPHQL_ENV_PRODUCTION_PATH:()=>ei,GRAPHQL_PATH:()=>ea,GRAPHQL_ROOT:()=>Xo,PRISMA_SCHEMA_PATH:()=>Ps,SKEET_CONFIG_PATH:()=>hp,TRANSLATE_PATH:()=>p$,program:()=>qt});module.exports=nke(Ozt);var o_e=st(lA());var AY=st(DY(),1),{program:Fzt,createCommand:_zt,createArgument:kzt,createOption:Mzt,CommanderError:Rzt,InvalidArgumentError:Nzt,InvalidOptionArgumentError:Bzt,Command:FY,Argument:Izt,Option:Lzt,Help:qzt}=AY.default;var _Y="1.8.2";var kY=(c=0)=>g=>`\x1B[${g+c}m`,MY=(c=0)=>g=>`\x1B[${38+c};5;${g}m`,RY=(c=0)=>(g,d,p)=>`\x1B[${38+c};2;${g};${d};${p}m`,Ao={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Vzt=Object.keys(Ao.modifier),_ke=Object.keys(Ao.color),kke=Object.keys(Ao.bgColor),Gzt=[..._ke,...kke];function Mke(){let c=new Map;for(let[g,d]of Object.entries(Ao)){for(let[p,h]of Object.entries(d))Ao[p]={open:`\x1B[${h[0]}m`,close:`\x1B[${h[1]}m`},d[p]=Ao[p],c.set(h[0],h[1]);Object.defineProperty(Ao,g,{value:d,enumerable:!1})}return Object.defineProperty(Ao,"codes",{value:c,enumerable:!1}),Ao.color.close="\x1B[39m",Ao.bgColor.close="\x1B[49m",Ao.color.ansi=kY(),Ao.color.ansi256=MY(),Ao.color.ansi16m=RY(),Ao.bgColor.ansi=kY(10),Ao.bgColor.ansi256=MY(10),Ao.bgColor.ansi16m=RY(10),Object.defineProperties(Ao,{rgbToAnsi256:{value(g,d,p){return g===d&&d===p?g<8?16:g>248?231:Math.round((g-8)/247*24)+232:16+36*Math.round(g/255*5)+6*Math.round(d/255*5)+Math.round(p/255*5)},enumerable:!1},hexToRgb:{value(g){let d=/[a-f\d]{6}|[a-f\d]{3}/i.exec(g.toString(16));if(!d)return[0,0,0];let[p]=d;p.length===3&&(p=[...p].map(s=>s+s).join(""));let h=Number.parseInt(p,16);return[h>>16&255,h>>8&255,h&255]},enumerable:!1},hexToAnsi256:{value:g=>Ao.rgbToAnsi256(...Ao.hexToRgb(g)),enumerable:!1},ansi256ToAnsi:{value(g){if(g<8)return 30+g;if(g<16)return 90+(g-8);let d,p,h;if(g>=232)d=((g-232)*10+8)/255,p=d,h=d;else{g-=16;let f=g%36;d=Math.floor(g/36)/5,p=Math.floor(f/6)/5,h=f%6/5}let s=Math.max(d,p,h)*2;if(s===0)return 30;let a=30+(Math.round(h)<<2|Math.round(p)<<1|Math.round(d));return s===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(g,d,p)=>Ao.ansi256ToAnsi(Ao.rgbToAnsi256(g,d,p)),enumerable:!1},hexToAnsi:{value:g=>Ao.ansi256ToAnsi(Ao.hexToAnsi256(g)),enumerable:!1}}),Ao}var Rke=Mke(),Gn=Rke;var U0=st(require("node:process"),1),BY=st(require("node:os"),1),SA=st(require("node:tty"),1);function gn(c,g=globalThis.Deno?globalThis.Deno.args:U0.default.argv){let d=c.startsWith("-")?"":c.length===1?"-":"--",p=g.indexOf(d+c),h=g.indexOf("--");return p!==-1&&(h===-1||p=2,has16m:c>=3}}function Ike(c,{streamIsTTY:g,sniffFlags:d=!0}={}){let p=Nke();p!==void 0&&(J0=p);let h=d?J0:p;if(h===0)return 0;if(d){if(gn("color=16m")||gn("color=full")||gn("color=truecolor"))return 3;if(gn("color=256"))return 2}if("TF_BUILD"in Lo&&"AGENT_NAME"in Lo)return 1;if(c&&!g&&h===void 0)return 0;let s=h||0;if(Lo.TERM==="dumb")return s;if(U0.default.platform==="win32"){let a=BY.default.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in Lo)return"GITHUB_ACTIONS"in Lo||"GITEA_ACTIONS"in Lo?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(a=>a in Lo)||Lo.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in Lo)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Lo.TEAMCITY_VERSION)?1:0;if(Lo.COLORTERM==="truecolor"||Lo.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in Lo){let a=Number.parseInt((Lo.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Lo.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Lo.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Lo.TERM)||"COLORTERM"in Lo?1:s}function NY(c,g={}){let d=Ike(c,{streamIsTTY:c&&c.isTTY,...g});return Bke(d)}var Lke={stdout:NY({isTTY:SA.default.isatty(1)}),stderr:NY({isTTY:SA.default.isatty(2)})},IY=Lke;function LY(c,g,d){let p=c.indexOf(g);if(p===-1)return c;let h=g.length,s=0,a="";do a+=c.slice(s,p)+g+d,s=p+h,p=c.indexOf(g,s);while(p!==-1);return a+=c.slice(s),a}function qY(c,g,d,p){let h=0,s="";do{let a=c[p-1]==="\r";s+=c.slice(h,a?p-1:p)+g+(a?`\r `:` `)+d,h=p+1,p=c.indexOf(` `,h)}while(p!==-1);return s+=c.slice(h),s}var{stdout:JY,stderr:UY}=IY,PA=Symbol("GENERATOR"),Rc=Symbol("STYLER"),Yf=Symbol("IS_EMPTY"),VY=["ansi","ansi","ansi256","ansi16m"],Nc=Object.create(null),qke=(c,g={})=>{if(g.level&&!(Number.isInteger(g.level)&&g.level>=0&&g.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let d=JY?JY.level:0;c.level=g.level===void 0?d:g.level};var Jke=c=>{let g=(...d)=>d.join(" ");return qke(g,c),Object.setPrototypeOf(g,Wf.prototype),g};function Wf(c){return Jke(c)}Object.setPrototypeOf(Wf.prototype,Function.prototype);for(let[c,g]of Object.entries(Gn))Nc[c]={get(){let d=V0(this,xA(g.open,g.close,this[Rc]),this[Yf]);return Object.defineProperty(this,c,{value:d}),d}};Nc.visible={get(){let c=V0(this,this[Rc],!0);return Object.defineProperty(this,"visible",{value:c}),c}};var jA=(c,g,d,...p)=>c==="rgb"?g==="ansi16m"?Gn[d].ansi16m(...p):g==="ansi256"?Gn[d].ansi256(Gn.rgbToAnsi256(...p)):Gn[d].ansi(Gn.rgbToAnsi(...p)):c==="hex"?jA("rgb",g,d,...Gn.hexToRgb(...p)):Gn[d][c](...p),Uke=["rgb","hex","ansi256"];for(let c of Uke){Nc[c]={get(){let{level:d}=this;return function(...p){let h=xA(jA(c,VY[d],"color",...p),Gn.color.close,this[Rc]);return V0(this,h,this[Yf])}}};let g="bg"+c[0].toUpperCase()+c.slice(1);Nc[g]={get(){let{level:d}=this;return function(...p){let h=xA(jA(c,VY[d],"bgColor",...p),Gn.bgColor.close,this[Rc]);return V0(this,h,this[Yf])}}}}var Vke=Object.defineProperties(()=>{},{...Nc,level:{enumerable:!0,get(){return this[PA].level},set(c){this[PA].level=c}}}),xA=(c,g,d)=>{let p,h;return d===void 0?(p=c,h=g):(p=d.openAll+c,h=g+d.closeAll),{open:c,close:g,openAll:p,closeAll:h,parent:d}},V0=(c,g,d)=>{let p=(...h)=>Gke(p,h.length===1?""+h[0]:h.join(" "));return Object.setPrototypeOf(p,Vke),p[PA]=c,p[Rc]=g,p[Yf]=d,p},Gke=(c,g)=>{if(c.level<=0||!g)return c[Yf]?"":g;let d=c[Rc];if(d===void 0)return g;let{openAll:p,closeAll:h}=d;if(g.includes("\x1B"))for(;d!==void 0;)g=LY(g,d.close,d.open),d=d.parent;let s=g.indexOf(` @@ -1757,7 +1757,7 @@ export * from './mutation' `);return{filePath:g,body:d}},Abt=async(c,g)=>{let d=[];for await(let s of g)d.push(`${await ys(s)}`);let p=d.join(", ");return["import { objectType } from 'nexus'",`import { ${c} } from 'nexus-prisma'`,`import { ${p} } from '../../enums' `]},Fbt=async c=>["import { objectType } from 'nexus'",`import { ${c} } from 'nexus-prisma' `],_bt=async c=>{let g=await ug(c),d=await Ybe(g),p=[],h=[`export const ${c}Object = objectType({`,` name: ${c}.$name,`,` description: ${c}.$description,`," definition(t) {"," t.relayGlobalId('id', {})"];if(d.length===0){p=await Fbt(c);for await(let a of p.reverse())h.unshift(a)}else{let a=[];for await(let b of d)b.type.match("Enum$")&&a.push(b.type);let f=Array.from(new Set(a));p=await Abt(c,f);for await(let b of p.reverse())h.unshift(b)}let s=[];for await(let a of g)if(a.type.match("Enum$")){let f=` t.field(${c}.${a.name}.name, { type: ${await ys(a.type)} })`;h.push(f),s.push(a.name)}else{let f=` t.field(${c}.${a.name})`;h.push(f)}return h.push(" },","})"),h};var P0e=async c=>{let g=ea+"/modelManager/"+c+"/mutation.ts",d=await kbt(c),p=await Mbt(c),h=await Rbt(c),a=d.concat(p,h).join(` -`);return{filePath:g,body:a}},kbt=async c=>{let g=await Nm(c),d=await ys(c),p=["import { extendType, stringArg, intArg, floatArg, BooleanArg } from 'nexus'","import { toPrismaId } from '@/lib/toPrismaId'",`import { ${g} } from 'nexus-prisma'`,`import { GraphQLError } from 'graphql' +`);return{filePath:g,body:a}},kbt=async c=>{let g=await Nm(c),d=await ys(c),p=["import { extendType, stringArg, intArg, floatArg, booleanArg } from 'nexus'","import { toPrismaId } from '@/lib/toPrismaId'",`import { ${g} } from 'nexus-prisma'`,`import { GraphQLError } from 'graphql' `,`export const ${g}Mutation = extendType({`," type: 'Mutation',"," definition(t) {",` t.field('create${g}', {`,` type: ${g}.$name,`," args: {"],h=await j0e(c);return p=p.concat(h),p.push(" },"),p.push(" async resolve(_, args, ctx) {"),p.push(" try {",` return await ctx.prisma.${d}.create({`," data: args,"," })"," } catch (error) {"," console.log(error)"," throw new GraphQLError(`error: ${error}`)"," }"," },"," })"),p},Mbt=async c=>{let g=await Nm(c),d=await ys(c),p=[` t.field('update${g}', {`,` type: ${g}.$name,`," args: {"," id: stringArg(),"],h=await j0e(c+"?",!0,!0);return h.shift(),p=p.concat(h),p.push(" },"," async resolve(_, args, ctx) {",` if (!args.id) throw new GraphQLError('id is required') `," const id = toPrismaId(args.id)"," const data = JSON.parse(JSON.stringify(args))"," delete data.id"," try {",` return await ctx.prisma.${d}.update({`," where: {"," id"," },"," data"," })"," } catch (error) {"," console.log(error)"," throw new GraphQLError(`error: ${error}`)"," }"," },"," })"),p},Rbt=async c=>{let g=await Nm(c),d=await ys(c);return[` t.field('delete${g}', {`,` type: ${g}.$name,`," args: {"," id: stringArg(),"," },"," async resolve(_, { id }, ctx) {"," try {",` if (!id) throw new GraphQLError('id is required') `,` return await ctx.prisma.${d}.delete({`," where: {"," id: toPrismaId(id),"," },"," })"," } catch (error) {"," throw new GraphQLError(`error: ${error}`)"," }"," },"," })"," },","})"]},j0e=async(c,g=!1,d=!1)=>{let p=await ug(c),h=[];for await(let s of p){let a=await XI(s.type);if(s.type.includes("[]")||s.name.includes("atedAt")||a===1)continue;let f=d?Bbt(s.type):Nbt(s.type);if(s.name==="id"&&g)continue;let b=` ${s.name}: ${f},`;h.push(b)}return h};var Nbt=c=>{switch(c){case"String":return"stringArg()";case"String?":return"stringArg()";case"Int":return"intArg()";case"Int?":return"intArg()";case"DateTime":return"stringArg()";case"Float":return"floatArg()";case"Float?":return"floatArg()";case"Boolean":return"booleanArg()";case"Boolean?":return"booleanArg()";default:return"stringArg()"}},Bbt=c=>{switch(c){case"String":return"stringArg()";case"String?":return"stringArg()";case"Int":return"intArg()";case"Int?":return"intArg()";case"DateTime":return"stringArg()";case"Float":return"floatArg()";case"Float?":return"floatArg()";case"Boolean":return"booleanArg()";case"Boolean?":return"booleanArg()";default:return"stringArg()"}};var x0e=async c=>{let g=ea+"/modelManager/"+c+"/query.ts",d=(await Ibt(c)).join(` diff --git a/package.json b/package.json index e94da381..0a4fae73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@skeet-framework/cli", - "version": "1.8.1", + "version": "1.8.2", "description": "Skeet CLI", "main": "dist/index.js", "repository": "https://github.com/elsoul/skeet-cli", diff --git a/src/lib/version.ts b/src/lib/version.ts index 701a39e4..1aa29803 100644 --- a/src/lib/version.ts +++ b/src/lib/version.ts @@ -1 +1 @@ -export const VERSION = '1.8.1' \ No newline at end of file +export const VERSION = '1.8.2' \ No newline at end of file