YiAi/YiAiQuickDeploy/dist/modules/draw/draw.service.js
2024-02-05 23:18:50 +08:00

1 line
5.8 KiB
JavaScript

'use strict';function _0x3fd3(){const _0x50885c=['decorate','response','base64','metadata','artifacts','length','drawTextToImage','design:paramtypes','push','4611292BwbStw','function','3905403LVRcnP','.png','STABILITY_API_KEY','API_HOST','https://api.stability.ai','334746EYINHs','Authorization','400jTGdFd','defineProperty','apiHost','__metadata','UploadService','from','8985516jyFMrP','2lwMtHq','795153OAizJC','apiKey','@nestjs/common','__esModule','env','data','/text-to-image','uploadService','HttpStatus','HttpException','获取列表失败','Injectable','stable-diffusion-768-v2-1','slice','BAD_REQUEST','default','application/json','*********','uploadFile','Bearer\x20','9701432yxVeId','getOwnPropertyDescriptor','DrawService','all','message','object','uuid','log','5DWoWIf','7zQKVhl','绘制失败','21183668oNLcWC'];_0x3fd3=function(){return _0x50885c;};return _0x3fd3();}const _0x7960fb=_0x19fe;(function(_0x516ec1,_0x26859a){const _0x1cd756=_0x19fe,_0x282451=_0x516ec1();while(!![]){try{const _0x31e368=-parseInt(_0x1cd756(0x145))/0x1*(parseInt(_0x1cd756(0x144))/0x2)+parseInt(_0x1cd756(0x170))/0x3+-parseInt(_0x1cd756(0x16e))/0x4*(-parseInt(_0x1cd756(0x161))/0x5)+-parseInt(_0x1cd756(0x143))/0x6+-parseInt(_0x1cd756(0x162))/0x7*(-parseInt(_0x1cd756(0x159))/0x8)+parseInt(_0x1cd756(0x175))/0x9*(parseInt(_0x1cd756(0x177))/0xa)+-parseInt(_0x1cd756(0x164))/0xb;if(_0x31e368===_0x26859a)break;else _0x282451['push'](_0x282451['shift']());}catch(_0x87298e){_0x282451['push'](_0x282451['shift']());}}}(_0x3fd3,0xe4a58));function _0x19fe(_0x4a79ed,_0x3721f7){const _0x3fd316=_0x3fd3();return _0x19fe=function(_0x19fed9,_0x192094){_0x19fed9=_0x19fed9-0x141;let _0x467711=_0x3fd316[_0x19fed9];return _0x467711;},_0x19fe(_0x4a79ed,_0x3721f7);}var __decorate=this&&this['__decorate']||function(_0x5afdb2,_0x654ce8,_0x35e917,_0x29ec38){const _0x5682fc=_0x19fe;var _0x4477af=arguments[_0x5682fc(0x16a)],_0x4b0b0a=_0x4477af<0x3?_0x654ce8:_0x29ec38===null?_0x29ec38=Object[_0x5682fc(0x15a)](_0x654ce8,_0x35e917):_0x29ec38,_0xcaf85a;if(typeof Reflect===_0x5682fc(0x15e)&&typeof Reflect[_0x5682fc(0x165)]===_0x5682fc(0x16f))_0x4b0b0a=Reflect[_0x5682fc(0x165)](_0x5afdb2,_0x654ce8,_0x35e917,_0x29ec38);else{for(var _0x242a19=_0x5afdb2[_0x5682fc(0x16a)]-0x1;_0x242a19>=0x0;_0x242a19--)if(_0xcaf85a=_0x5afdb2[_0x242a19])_0x4b0b0a=(_0x4477af<0x3?_0xcaf85a(_0x4b0b0a):_0x4477af>0x3?_0xcaf85a(_0x654ce8,_0x35e917,_0x4b0b0a):_0xcaf85a(_0x654ce8,_0x35e917))||_0x4b0b0a;}return _0x4477af>0x3&&_0x4b0b0a&&Object[_0x5682fc(0x178)](_0x654ce8,_0x35e917,_0x4b0b0a),_0x4b0b0a;},__metadata=this&&this[_0x7960fb(0x17a)]||function(_0x3aa76b,_0x315e73){const _0x44c04a=_0x7960fb;if(typeof Reflect===_0x44c04a(0x15e)&&typeof Reflect[_0x44c04a(0x168)]===_0x44c04a(0x16f))return Reflect['metadata'](_0x3aa76b,_0x315e73);};Object[_0x7960fb(0x178)](exports,_0x7960fb(0x148),{'value':!![]}),exports[_0x7960fb(0x15b)]=void 0x0;const common_1=require(_0x7960fb(0x147)),axios_1=require('axios'),uuid=require(_0x7960fb(0x15f)),upload_service_1=require('../upload/upload.service');let DrawService=class DrawService{constructor(_0xd82297){const _0x1c2e75=_0x7960fb;this[_0x1c2e75(0x14c)]=_0xd82297;}async['onModuleInit'](){const _0x40c98b=_0x7960fb;var _0x249cda;this[_0x40c98b(0x179)]=(_0x249cda=process[_0x40c98b(0x149)][_0x40c98b(0x173)])!==null&&_0x249cda!==void 0x0?_0x249cda:_0x40c98b(0x174),this['apiKey']=process['env'][_0x40c98b(0x172)],!this[_0x40c98b(0x146)]&&(this['apiKey']=_0x40c98b(0x156)),this[_0x40c98b(0x176)]=_0x40c98b(0x158)+this[_0x40c98b(0x146)];}async['getEngines'](){const _0x342399=_0x7960fb;var _0x5a1ce9,_0x3e5dd3;const _0x44bf94=this[_0x342399(0x179)]+'/v1/engines/list',_0x1b6db8=await(0x0,axios_1[_0x342399(0x154)])(_0x44bf94,{'method':'GET','headers':{'Authorization':this[_0x342399(0x176)]}});_0x1b6db8['status']===0x191&&console[_0x342399(0x160)]('stability\x20api\x20key\x20is\x20invalid,\x20'+((_0x5a1ce9=_0x1b6db8===null||_0x1b6db8===void 0x0?void 0x0:_0x1b6db8['data'])===null||_0x5a1ce9===void 0x0?void 0x0:_0x5a1ce9[_0x342399(0x15d)]));if(_0x1b6db8['status']!==0xc8){console[_0x342399(0x160)](_0x1b6db8['status']+'\x20'+((_0x3e5dd3=_0x1b6db8===null||_0x1b6db8===void 0x0?void 0x0:_0x1b6db8[_0x342399(0x14a)])===null||_0x3e5dd3===void 0x0?void 0x0:_0x3e5dd3['message'])+'}');throw new common_1[(_0x342399(0x14e))](_0x342399(0x14f),common_1[_0x342399(0x14d)][_0x342399(0x153)]);}return _0x1b6db8[_0x342399(0x14a)];}async[_0x7960fb(0x16b)](_0x427a26){const _0x357320=_0x7960fb,{engineId:engineId=_0x357320(0x151)}=_0x427a26,_0x272a24={'Content-Type':_0x357320(0x155),'Accept':_0x357320(0x155),'Authorization':this[_0x357320(0x176)]},_0x2c19b5=this[_0x357320(0x179)]+'/v1/generation/'+engineId+_0x357320(0x14b);try{const _0xf2043f=await axios_1['default']['post'](_0x2c19b5,_0x427a26,{'headers':_0x272a24});if(_0xf2043f['status']!==0xc8)throw new common_1['HttpException'](_0x357320(0x163),common_1[_0x357320(0x14d)][_0x357320(0x153)]);const _0x188c04=[];for(const _0x1ca28e of _0xf2043f[_0x357320(0x14a)][_0x357320(0x169)]){const _0x35286d=uuid['v4']()[_0x357320(0x152)](0x0,0xa)+_0x357320(0x171),_0x481d9d=Buffer[_0x357320(0x142)](_0x1ca28e[_0x357320(0x167)],_0x357320(0x167));_0x188c04[_0x357320(0x16d)](this[_0x357320(0x14c)][_0x357320(0x157)]({'filename':_0x35286d,'buffer':_0x481d9d}));}const _0x3a919d=await Promise[_0x357320(0x15c)](_0x188c04);return _0x3a919d;}catch(_0xbbbaec){if(!(_0xbbbaec===null||_0xbbbaec===void 0x0?void 0x0:_0xbbbaec[_0x357320(0x166)]))throw new common_1[(_0x357320(0x14e))](_0x357320(0x163),common_1[_0x357320(0x14d)][_0x357320(0x153)]);const {status:_0x59badc,data:_0x56a1b2}=_0xbbbaec[_0x357320(0x166)];throw new common_1[(_0x357320(0x14e))](_0x56a1b2[_0x357320(0x15d)],_0x59badc);}}};DrawService=__decorate([(0x0,common_1[_0x7960fb(0x150)])(),__metadata(_0x7960fb(0x16c),[upload_service_1[_0x7960fb(0x141)]])],DrawService),exports[_0x7960fb(0x15b)]=DrawService;