UNPKG

techveda-lib-dynamodb

Version:

A clean DynamoDB abstraction library with schema and model for Node.js and TypeScript

1 lines 28.9 kB
'use strict';function a0_0x1547(){const _0x540dc8=['hLsJE','WAGkh','from','OHvjW','create','GZfzz','#PK','MLBzc',':sk','5tRaTlv','enum','\x27\x20meets\x20condition\x20\x27','Error\x20in\x20allQueryByParams','aYtQq','entity','yHTSt','#SK','\x20AND\x20#SK\x20=\x20:sk','Invalid\x20config\x20for\x20field\x20\x27','find','jpQgi','hasOwnProperty','required','ALL_NEW','__esModule','\x20=\x20','\x20=\x20:','vHEtQ','18znEhZn','getOwnPropertyDescriptor','167796lpglRj','RUN\x20QUERY','includes','join','created_at','conditionType','parse','rFlUn','@aws-sdk/client-dynamodb','maxLength','WicyP','ljGJT','BWgjf','true','PnjcF','qkSTh','PKPrefix','WjeYg','BCzFt','fromEntries','minLength','9474374wsLxUz','FilterExpression','XPQeT','IHnWS','keys','trim','RnjjN','AWS_ACCESS_KEY','call','object','68OjJNqA','type','rsQDB','AkfGz','http://localhost:8000','YpcFU','143AfbkHh','FQudI','isValuePresent','FXThk','ScanCommand','validate','Limit',':pkPrefix','XQsIe','76727SaKpxN','joi','keykey','HFIIM','\x27.\x20Must\x20be\x20an\x20object.','nvGfY','map','55444CaDaid','JlSZZ','vVocs','toUpperCase','save','Error\x20in\x20callUpdateByParams:','kSPKw','ExpressionAttributeValues','isArray','DoOTf','function','fields','prototype','aYZYz','DATABASE_TABLE','Error\x20in\x20putDataCommand:','conditionKey','@aws-sdk/lib-dynamodb','10607kaqcoo','compareValue','KeyConditionExpression','UpdateCommand','dotenv/config','toISOString','haTay','yzpeN','\x27\x20is\x20required\x20when\x20\x27','findAndUpdate','error','exports','uvQAL','111iblkMY','buildJoiSchema','\x27\x20validation\x20failed:\x20','length','Schema\x20instance\x20must\x20be\x20provided\x20and\x20return\x20an\x20array.','scan','entries','SKPrefix','isConditionalRequired','cotjH','yPqLE','cBugB','string','XPvEZ',':pk','key','ExclusiveStartKey','Error\x20in\x20getDataInScanCommand:','GzfKb','updated_at','krwBE','modelName','email','assign','start_key','deleted_at','params','equalTo','IOgtj','EeFFo','ref','lpNCV','SFjCE','SET\x20','DynamoDBDocumentClient','begins_with(#PK,\x20:pkPrefix)','272CMXUpL','NODE_ENV','\x20AND\x20','Field\x20\x27','number','TcdaH','fakeSecretAccessKey','constructor','2691966acEaMh','pYMda','qhqUs','WgzIX','hEJKp','contains(','getPrototypeOf','ap-south-1','getOwnPropertyNames','parseType',':skPrefix','Cannot\x20save:\x20PK/SK\x20missing.\x20Call\x20create()\x20or\x20find()\x20first.','message','boolean','hOFMt','send','details','3413050paepjx','\x27\x20is\x20required.','schema','filter','Error\x20in\x20allQueryByParams:','Items','Zzatx','TableName','PryyO','CDoCp','log','OAglO','skId','env','ziFis','EGEVa','zjOoh','push','AWS_SECRET_ACCESS_KEY','USE_LOCAL_DYNAMO','default','short-uuid','\x20|\x20','ExpressionAttributeNames','AWS_REGION','development','QueryCommand','getSchema','HUDKR','ShSEI','nFGzy','Error\x20in\x20getDataInScanCommand','NCJXn','Error\x20in\x20callUpdateByParams','MrXoY','fakeMyKeyId','array'];a0_0x1547=function(){return _0x540dc8;};return a0_0x1547();}const a0_0xb88410=a0_0x45ea;(function(_0x3c9314,_0x232b99){const _0x11b9a3=a0_0x45ea,_0x585b66=_0x3c9314();while(!![]){try{const _0x36f0bb=parseInt(_0x11b9a3(0x198))/0x1*(-parseInt(_0x11b9a3(0x170))/0x2)+-parseInt(_0x11b9a3(0x1a5))/0x3*(-parseInt(_0x11b9a3(0x186))/0x4)+-parseInt(_0x11b9a3(0x13c))/0x5*(-parseInt(_0x11b9a3(0x1d1))/0x6)+-parseInt(_0x11b9a3(0x17f))/0x7*(parseInt(_0x11b9a3(0x1c9))/0x8)+-parseInt(_0x11b9a3(0x14f))/0x9*(parseInt(_0x11b9a3(0x10e))/0xa)+parseInt(_0x11b9a3(0x176))/0xb*(parseInt(_0x11b9a3(0x151))/0xc)+parseInt(_0x11b9a3(0x166))/0xd;if(_0x36f0bb===_0x232b99)break;else _0x585b66['push'](_0x585b66['shift']());}catch(_0x54e583){_0x585b66['push'](_0x585b66['shift']());}}}(a0_0x1547,0x6f5ed));var __create=Object[a0_0xb88410(0x137)],__defProp=Object['defineProperty'],__getOwnPropDesc=Object[a0_0xb88410(0x150)],__getOwnPropNames=Object[a0_0xb88410(0x105)],__getProtoOf=Object[a0_0xb88410(0x103)],__hasOwnProp=Object[a0_0xb88410(0x192)][a0_0xb88410(0x148)],__export=(_0x32f342,_0x2269af)=>{const _0x150159=a0_0xb88410,_0x4ace04={'qkSTh':function(_0x56c9ad,_0x4459e5,_0x19f880,_0x3394f2){return _0x56c9ad(_0x4459e5,_0x19f880,_0x3394f2);}};for(var _0x599e9f in _0x2269af)_0x4ace04[_0x150159(0x160)](__defProp,_0x32f342,_0x599e9f,{'get':_0x2269af[_0x599e9f],'enumerable':!![]});},__copyProps=(_0x2617c1,_0x314fe3,_0x571607,_0x3fed4e)=>{const _0x546eff=a0_0xb88410,_0x3e1521={'PryyO':function(_0x4c3e20,_0x56bb53){return _0x4c3e20===_0x56bb53;},'ljGJT':_0x546eff(0x190),'WjeYg':function(_0x14ee27,_0x5a7fb8){return _0x14ee27(_0x5a7fb8);},'BCzFt':function(_0x26f725,_0xa4a478){return _0x26f725!==_0xa4a478;},'XPvEZ':function(_0x30ca3e,_0x5ed81c,_0x538294){return _0x30ca3e(_0x5ed81c,_0x538294);}};if(_0x314fe3&&_0x3e1521[_0x546eff(0x116)](typeof _0x314fe3,_0x546eff(0x16f))||typeof _0x314fe3===_0x3e1521[_0x546eff(0x15c)]){for(let _0x292d2e of _0x3e1521[_0x546eff(0x162)](__getOwnPropNames,_0x314fe3))if(!__hasOwnProp[_0x546eff(0x16e)](_0x2617c1,_0x292d2e)&&_0x3e1521[_0x546eff(0x163)](_0x292d2e,_0x571607))__defProp(_0x2617c1,_0x292d2e,{'get':()=>_0x314fe3[_0x292d2e],'enumerable':!(_0x3fed4e=_0x3e1521[_0x546eff(0x1b2)](__getOwnPropDesc,_0x314fe3,_0x292d2e))||_0x3fed4e['enumerable']});}return _0x2617c1;},__toESM=(_0x7cd3ec,_0x34508d,_0x90a3d2)=>(_0x90a3d2=_0x7cd3ec!=null?__create(__getProtoOf(_0x7cd3ec)):{},__copyProps(_0x34508d||!_0x7cd3ec||!_0x7cd3ec[a0_0xb88410(0x14b)]?__defProp(_0x90a3d2,'default',{'value':_0x7cd3ec,'enumerable':!![]}):_0x90a3d2,_0x7cd3ec)),__toCommonJS=_0x244214=>__copyProps(__defProp({},a0_0xb88410(0x14b),{'value':!![]}),_0x244214),index_exports={};__export(index_exports,{'Model':()=>Model,'Schema':()=>Schema,'allQueryByParams':()=>allQueryByParams,'callUpdateByParams':()=>callUpdateByParams,'docClient':()=>docClient,'generateKeys':()=>generateKeys,'getDataInScanCommand':()=>getDataInScanCommand,'initDynamoDB':()=>initDynamoDB,'putDataCommand':()=>putDataCommand,'removeExtraFields':()=>removeExtraFields}),module[a0_0xb88410(0x1a3)]=__toCommonJS(index_exports);function a0_0x45ea(_0x321f13,_0x28314a){const _0x15474b=a0_0x1547();return a0_0x45ea=function(_0x45ea69,_0x451779){_0x45ea69=_0x45ea69-0xfe;let _0x3b0dee=_0x15474b[_0x45ea69];return _0x3b0dee;},a0_0x45ea(_0x321f13,_0x28314a);}var import_joi=__toESM(require('joi')),buildJoiSchema=_0x547c50=>{const _0x7f6ce9=a0_0xb88410,_0xae1ae2={'haTay':function(_0x4fb661,_0x557bcb){return _0x4fb661===_0x557bcb;},'FXThk':_0x7f6ce9(0x10a),'hEJKp':_0x7f6ce9(0x132),'MLBzc':_0x7f6ce9(0x1bb),'hOFMt':function(_0x763637,_0x43ff13){return _0x763637!==_0x43ff13;},'QZTWN':function(_0x570c93,_0x379201){return _0x570c93!==_0x379201;}},_0x2cf543={};for(const _0x2e9b2b of _0x547c50[_0x7f6ce9(0x110)]){const _0xa10b0=_0x2e9b2b[_0x7f6ce9(0x1b4)];let _0x2e294d=import_joi[_0x7f6ce9(0x122)]['any']();if(_0x2e9b2b['type']===_0x7f6ce9(0x1b1))_0x2e294d=import_joi[_0x7f6ce9(0x122)][_0x7f6ce9(0x1b1)]();if(_0xae1ae2[_0x7f6ce9(0x19e)](_0x2e9b2b[_0x7f6ce9(0x171)],'number'))_0x2e294d=import_joi['default'][_0x7f6ce9(0x1cd)]();if(_0x2e9b2b[_0x7f6ce9(0x171)]===_0xae1ae2[_0x7f6ce9(0x179)])_0x2e294d=import_joi[_0x7f6ce9(0x122)][_0x7f6ce9(0x10a)]();if(_0xae1ae2[_0x7f6ce9(0x19e)](_0x2e9b2b[_0x7f6ce9(0x171)],_0xae1ae2[_0x7f6ce9(0x101)]))_0x2e294d=import_joi[_0x7f6ce9(0x122)][_0x7f6ce9(0x132)]();if(_0x2e9b2b['type']==='object')_0x2e294d=import_joi[_0x7f6ce9(0x122)][_0x7f6ce9(0x16f)]();if(_0x2e9b2b['type']===_0xae1ae2[_0x7f6ce9(0x13a)])_0x2e294d=import_joi[_0x7f6ce9(0x122)]['string']()[_0x7f6ce9(0x1bb)]();if(_0x2e9b2b[_0x7f6ce9(0x149)])_0x2e294d=_0x2e294d['required']();if(_0xae1ae2[_0x7f6ce9(0x10b)](_0x2e9b2b['default'],void 0x0))_0x2e294d=_0x2e294d[_0x7f6ce9(0x122)](_0x2e9b2b[_0x7f6ce9(0x122)]);_0xae1ae2[_0x7f6ce9(0x19e)](_0xa10b0,_0x7f6ce9(0x141))&&console['log'](_0x2e294d,_0x7f6ce9(0x181));if(_0xae1ae2['QZTWN'](_0x2e9b2b[_0x7f6ce9(0x13d)],void 0x0))_0x2e294d=_0x2e294d['valid'](..._0x2e9b2b[_0x7f6ce9(0x13d)]);_0x2cf543[_0xa10b0]=_0x2e294d;}return import_joi[_0x7f6ce9(0x122)][_0x7f6ce9(0x16f)](_0x2cf543);},import_joi2=__toESM(require(a0_0xb88410(0x180))),typeMap={'string':_0x36bdab=>import_joi2[a0_0xb88410(0x122)][a0_0xb88410(0x1b1)]()[a0_0xb88410(0x149)]()[a0_0xb88410(0x17b)](_0x36bdab),'email':_0x18bb34=>import_joi2[a0_0xb88410(0x122)][a0_0xb88410(0x1b1)]()[a0_0xb88410(0x1bb)]()['required']()[a0_0xb88410(0x17b)](_0x18bb34),'number':_0x305902=>import_joi2['default'][a0_0xb88410(0x1cd)]()[a0_0xb88410(0x149)]()[a0_0xb88410(0x17b)](_0x305902),'boolean':_0x52dfea=>import_joi2[a0_0xb88410(0x122)][a0_0xb88410(0x10a)]()[a0_0xb88410(0x149)]()[a0_0xb88410(0x17b)](_0x52dfea),'array':_0xbd6ea4=>import_joi2[a0_0xb88410(0x122)]['array']()[a0_0xb88410(0x149)]()[a0_0xb88410(0x17b)](_0xbd6ea4),'object':_0x119886=>import_joi2[a0_0xb88410(0x122)]['object']()[a0_0xb88410(0x149)]()[a0_0xb88410(0x17b)](_0x119886)},isValuePresent=_0x59a695=>_0x59a695!==null&&_0x59a695!==void 0x0&&_0x59a695!==''&&_0x59a695!==![]&&!(Array[a0_0xb88410(0x18e)](_0x59a695)&&_0x59a695[a0_0xb88410(0x1a8)]===0x0)&&!(typeof _0x59a695===a0_0xb88410(0x16f)&&Object[a0_0xb88410(0x16a)](_0x59a695)[a0_0xb88410(0x1a8)]===0x0),validate=(_0x2006bc,_0x2de082)=>{const _0x57a85e=a0_0xb88410,_0x41b088={'OAglO':function(_0x3968d0,_0x368859){return _0x3968d0===_0x368859;},'nFGzy':function(_0x6ba6f2,_0x56ca6b){return _0x6ba6f2===_0x56ca6b;},'TcdaH':function(_0x56d9f8,_0x531fcb){return _0x56d9f8!==_0x531fcb;},'EaVir':function(_0x2eadda,_0x454b97){return _0x2eadda===_0x454b97;},'HFIIM':function(_0x272176,_0x512eb1){return _0x272176 in _0x512eb1;},'qhqUs':'contains','JlSZZ':_0x57a85e(0x1c0),'WAGkh':function(_0x52a5bb,_0x9bb9d2){return _0x52a5bb===_0x9bb9d2;},'HUDKR':_0x57a85e(0x178),'cBugB':function(_0xe369ce,_0x1dbb69){return _0xe369ce(_0x1dbb69);},'EGEVa':function(_0x5d3030,_0x50887c){return _0x5d3030===_0x50887c;},'XQsIe':function(_0x338a09,_0x4322ae){return _0x338a09===_0x4322ae;},'KLgKB':function(_0x57e968,_0xb95898){return _0x57e968>_0xb95898;}},_0x434d37=[];for(const _0x3219f9 of _0x2006bc[_0x57a85e(0x110)]){const {key:_0xec9c53,type:_0x14d457,required:_0x1e4ca3,enum:_0x4d85ea,default:_0x2a4e92,isConditionalRequired:_0x58d285,conditionKey:_0x3c12ca,compareValue:_0x2ca1f9,conditionType:_0x10d73a}=_0x3219f9;let _0x513e9b=_0x2de082[_0xec9c53];_0x41b088[_0x57a85e(0x119)](typeof _0x513e9b,'string')&&(_0x513e9b=_0x513e9b[_0x57a85e(0x16b)](),_0x2de082[_0xec9c53]=_0x513e9b);(_0x41b088[_0x57a85e(0x119)](_0x513e9b,void 0x0)||_0x41b088['nFGzy'](_0x513e9b,null))&&_0x41b088[_0x57a85e(0x1ce)](_0x2a4e92,void 0x0)&&(_0x2de082[_0xec9c53]=_0x2a4e92,_0x513e9b=_0x2a4e92);if(_0x1e4ca3&&(_0x41b088['EaVir'](_0x513e9b,void 0x0)||_0x513e9b===null||_0x513e9b==='')){_0x434d37['push']('Field\x20\x27'+_0xec9c53+_0x57a85e(0x10f));continue;}if(_0x41b088[_0x57a85e(0x1ce)](_0x513e9b,void 0x0)&&_0x14d457&&_0x41b088[_0x57a85e(0x12c)](typeof _0x14d457,'string')&&_0x41b088[_0x57a85e(0x182)](_0x14d457,typeMap)){const {error:_0x37be70}=typeMap[_0x14d457](_0x513e9b);if(_0x37be70){_0x434d37[_0x57a85e(0x11f)](_0x57a85e(0x1cc)+_0xec9c53+_0x57a85e(0x1a7)+_0x37be70[_0x57a85e(0x109)]);continue;}}if(_0x4d85ea&&_0x513e9b!==void 0x0&&!_0x4d85ea[_0x57a85e(0x153)](_0x513e9b)){_0x434d37[_0x57a85e(0x11f)](_0x57a85e(0x1cc)+_0xec9c53+'\x27\x20should\x20be\x20one\x20of\x20['+_0x4d85ea[_0x57a85e(0x154)](',\x20')+'].');continue;}if(_0x58d285){const _0x3f6986=_0x2de082[_0x3c12ca];let _0x541054=![];if(_0x41b088[_0x57a85e(0x12c)](_0x10d73a,_0x41b088[_0x57a85e(0xff)])&&Array[_0x57a85e(0x18e)](_0x2ca1f9))_0x541054=_0x2ca1f9[_0x57a85e(0x153)](_0x3f6986);else{if(_0x10d73a===_0x41b088[_0x57a85e(0x187)])_0x541054=_0x41b088[_0x57a85e(0x134)](_0x3f6986,_0x2ca1f9);else _0x10d73a===_0x41b088[_0x57a85e(0x12a)]&&(_0x541054=_0x41b088[_0x57a85e(0x1b0)](isValuePresent,_0x3f6986));}_0x541054&&(_0x41b088[_0x57a85e(0x11d)](_0x513e9b,void 0x0)||_0x41b088[_0x57a85e(0x17e)](_0x513e9b,null)||_0x513e9b==='')&&_0x434d37[_0x57a85e(0x11f)](_0x57a85e(0x1cc)+_0xec9c53+_0x57a85e(0x1a0)+_0x3c12ca+_0x57a85e(0x13e)+_0x10d73a+'\x27.');}}if(_0x41b088['KLgKB'](_0x434d37[_0x57a85e(0x1a8)],0x0))throw new Error(_0x434d37[_0x57a85e(0x154)](_0x57a85e(0x124)));return _0x2de082;},import_dayjs=__toESM(require('dayjs')),dateNow=()=>(0x0,import_dayjs[a0_0xb88410(0x122)])()[a0_0xb88410(0x19d)](),DEFAULT_SK_TYPE=a0_0xb88410(0x10d),generateKeys=(_0xb78ea9,_0x387982,_0x404521=DEFAULT_SK_TYPE,_0x45d709='')=>{const _0x53bcd0=a0_0xb88410,_0x2bef82=_0xb78ea9['toUpperCase'](),_0xe4952a=_0x404521[_0x53bcd0(0x189)]();return{'PK':_0x2bef82+'#'+_0x387982,'SK':_0xe4952a+'#'+_0x45d709};},removeExtraFields=(_0x4f8439={},_0x4b066b=[])=>{const _0x350941=a0_0xb88410,_0x284c95={'nUjOk':_0x350941(0x155),'GZfzz':_0x350941(0x1b8),'uvQAL':_0x350941(0x1be)},_0x12f8fe=[..._0x4b066b,'id','PK','SK',_0x284c95['nUjOk'],_0x284c95[_0x350941(0x138)],_0x284c95[_0x350941(0x1a4)]];return Object[_0x350941(0x164)](Object[_0x350941(0x1ab)](_0x4f8439)[_0x350941(0x111)](([_0x29837b])=>_0x12f8fe[_0x350941(0x153)](_0x29837b)));},import_short_uuid=__toESM(require(a0_0xb88410(0x123))),import_lib_dynamodb2=require('@aws-sdk/lib-dynamodb'),import_client_dynamodb=require(a0_0xb88410(0x159)),import_lib_dynamodb=require(a0_0xb88410(0x197)),import_config=require(a0_0xb88410(0x19c)),docClient,initDynamoDB=()=>{const _0x27f3dc=a0_0xb88410,_0x43c011={'zjOoh':function(_0x431444,_0x5c8da8){return _0x431444===_0x5c8da8;},'WgzIX':_0x27f3dc(0x127),'cotjH':_0x27f3dc(0x104),'CDoCp':_0x27f3dc(0x1cf)},_0x3ea6de=_0x43c011[_0x27f3dc(0x11e)](process['env'][_0x27f3dc(0x1ca)],_0x43c011[_0x27f3dc(0x100)])||process[_0x27f3dc(0x11b)][_0x27f3dc(0x121)]===_0x27f3dc(0x15e),_0xaa5ced=new import_client_dynamodb['DynamoDBClient']({'region':process[_0x27f3dc(0x11b)][_0x27f3dc(0x126)]||_0x43c011[_0x27f3dc(0x1ae)],'endpoint':_0x3ea6de?_0x27f3dc(0x174):void 0x0,'credentials':_0x3ea6de?{'accessKeyId':_0x27f3dc(0x131),'secretAccessKey':_0x43c011[_0x27f3dc(0x117)]}:{'accessKeyId':process[_0x27f3dc(0x11b)][_0x27f3dc(0x16d)]||'','secretAccessKey':process[_0x27f3dc(0x11b)][_0x27f3dc(0x120)]||''}});return docClient=import_lib_dynamodb[_0x27f3dc(0x1c7)][_0x27f3dc(0x135)](_0xaa5ced),docClient;},putDataCommand=async _0xc36766=>{const _0x1e1d79=a0_0xb88410,_0x41da71={'xNJzQ':_0x1e1d79(0x195),'XPQeT':'Error\x20in\x20putDataCommand'};try{const _0x288e78={'TableName':process['env'][_0x1e1d79(0x194)],'Item':_0xc36766};return await docClient[_0x1e1d79(0x10c)](new import_lib_dynamodb2['PutCommand'](_0x288e78)),_0xc36766;}catch(_0x1e0e25){console[_0x1e1d79(0x1a2)](_0x41da71['xNJzQ'],_0x1e0e25);throw new Error(_0x1e0e25['message']||_0x41da71[_0x1e1d79(0x168)]);}},create=async(_0x4fc0fe,_0x18953a)=>{const _0x5ccf6b=a0_0xb88410,_0x1a31be={'YpcFU':function(_0x512dc9,_0x44812f,_0x45e303){return _0x512dc9(_0x44812f,_0x45e303);}};try{const _0x4a6e7d=_0x1a31be[_0x5ccf6b(0x175)](validate,_0x4fc0fe,_0x18953a),_0x441312=_0x1a31be['YpcFU'](removeExtraFields,_0x4a6e7d,_0x4fc0fe[_0x5ccf6b(0x110)]['map'](_0x2bae51=>_0x2bae51['key']));if(!_0x441312['id'])_0x441312['id']=(0x0,import_short_uuid[_0x5ccf6b(0x122)])()['new']();const {PK:_0x4169c7,SK:_0x49b787}=_0x1a31be[_0x5ccf6b(0x175)](generateKeys,_0x4fc0fe[_0x5ccf6b(0x161)],_0x441312['id']);_0x441312['PK']=_0x4169c7,_0x441312['SK']=_0x49b787,_0x441312[_0x5ccf6b(0x155)]=dateNow(),_0x441312['updated_at']=dateNow(),Object[_0x5ccf6b(0x1bc)](_0x4fc0fe,_0x441312);const _0x3718a6=new _0x4fc0fe[(_0x5ccf6b(0x1d0))](_0x4fc0fe[_0x5ccf6b(0x1ba)],{'getSchema':()=>_0x4fc0fe['schema']},_0x4fc0fe[_0x5ccf6b(0x161)],_0x4fc0fe[_0x5ccf6b(0x1ac)]),_0x3306b9=await putDataCommand(_0x441312);return Object[_0x5ccf6b(0x1bc)](_0x3718a6,_0x3306b9);;}catch(_0x2bcde8){throw new Error(_0x2bcde8);}},import_lib_dynamodb3=require(a0_0xb88410(0x197)),callUpdateByParams=async _0x19f1b1=>{const _0x1c06fe=a0_0xb88410,_0x5b4250={'lzfwV':_0x1c06fe(0x18b)};try{!_0x19f1b1[_0x1c06fe(0x115)]&&(_0x19f1b1[_0x1c06fe(0x115)]=process[_0x1c06fe(0x11b)]['DATABASE_TABLE']);const _0x5ef32d=await docClient['send'](new import_lib_dynamodb3[(_0x1c06fe(0x19b))](_0x19f1b1));return _0x5ef32d['Attributes'];}catch(_0x4668cc){console['error'](_0x5b4250['lzfwV'],_0x4668cc);throw new Error(_0x4668cc[_0x1c06fe(0x109)]||_0x1c06fe(0x12f));}},save=async _0x2b9a75=>{const _0x212b1b=a0_0xb88410,_0x2ae10d={'vVocs':function(_0x3f349b){return _0x3f349b();},'uQztu':function(_0x14b8ae,_0x5ac7bb){return _0x14b8ae!==_0x5ac7bb;},'gIyqC':'function','aYZYz':function(_0x439eb4,_0x42e656,_0x13b08c){return _0x439eb4(_0x42e656,_0x13b08c);},'BWgjf':function(_0x4e74b2,_0x159e0c){return _0x4e74b2+_0x159e0c;},'SFjCE':_0x212b1b(0x14a),'myBmI':function(_0x15ad42,_0x10d55e){return _0x15ad42(_0x10d55e);}};if(!_0x2b9a75['PK']||!_0x2b9a75['SK'])throw new Error(_0x212b1b(0x108));_0x2b9a75[_0x212b1b(0x1b8)]=_0x2ae10d[_0x212b1b(0x188)](dateNow);const _0x387a50={};for(const _0x591980 of Object[_0x212b1b(0x16a)](_0x2b9a75)){_0x2ae10d['uQztu'](typeof _0x2b9a75[_0x591980],_0x2ae10d['gIyqC'])&&(_0x387a50[_0x591980]=_0x2b9a75[_0x591980]);}const _0x2cc77b=_0x2ae10d[_0x212b1b(0x193)](removeExtraFields,_0x387a50,_0x2b9a75[_0x212b1b(0x110)]['map'](_0x3f4f0a=>_0x3f4f0a['key']));_0x2b9a75[_0x212b1b(0x17b)](_0x2cc77b);const _0x15b55f=_0x2ae10d[_0x212b1b(0x15d)](_0x212b1b(0x1c6),Object[_0x212b1b(0x16a)](_0x2cc77b)[_0x212b1b(0x111)](_0x2b4a76=>!['PK','SK'][_0x212b1b(0x153)](_0x2b4a76))[_0x212b1b(0x185)](_0x374953=>'#'+_0x374953+_0x212b1b(0x14d)+_0x374953)[_0x212b1b(0x154)](',\x20')),_0x5ebea8=Object[_0x212b1b(0x164)](Object[_0x212b1b(0x16a)](_0x2cc77b)[_0x212b1b(0x111)](_0x3583c6=>!['PK','SK']['includes'](_0x3583c6))[_0x212b1b(0x185)](_0x23d558=>['#'+_0x23d558,_0x23d558])),_0x193d90=Object[_0x212b1b(0x164)](Object[_0x212b1b(0x1ab)](_0x2cc77b)[_0x212b1b(0x111)](([_0x2ff38f])=>!['PK','SK'][_0x212b1b(0x153)](_0x2ff38f))[_0x212b1b(0x185)](([_0x436bcb,_0x315a61])=>[':'+_0x436bcb,_0x315a61])),_0x1de665={'TableName':process[_0x212b1b(0x11b)][_0x212b1b(0x194)],'Key':{'PK':_0x2b9a75['PK'],'SK':_0x2b9a75['SK']},'UpdateExpression':_0x15b55f,'ExpressionAttributeNames':_0x5ebea8,'ExpressionAttributeValues':_0x193d90,'ReturnValues':_0x2ae10d[_0x212b1b(0x1c5)]};return console['log'](_0x1de665,_0x212b1b(0x1bf)),await _0x2ae10d['myBmI'](callUpdateByParams,_0x1de665),_0x2b9a75;},import_lib_dynamodb4=require(a0_0xb88410(0x197)),allQueryByParams=async _0x239aa2=>{const _0x5704f3=a0_0xb88410,_0x22dd62={'XqFwu':_0x5704f3(0x112)};try{return!_0x239aa2['TableName']&&(_0x239aa2[_0x5704f3(0x115)]=process[_0x5704f3(0x11b)][_0x5704f3(0x194)]),await docClient[_0x5704f3(0x10c)](new import_lib_dynamodb4[(_0x5704f3(0x128))](_0x239aa2));}catch(_0x138f05){console[_0x5704f3(0x1a2)](_0x22dd62['XqFwu'],_0x138f05);throw new Error(_0x138f05[_0x5704f3(0x109)]||_0x5704f3(0x13f));}},import_lib_dynamodb5=require(a0_0xb88410(0x197)),getDataInScanCommand=async _0x1e495f=>{const _0x4025d0=a0_0xb88410,_0x4b5039={'rFlUn':_0x4025d0(0x1b6),'AkfGz':_0x4025d0(0x12d)};try{const _0x12055c={'TableName':process[_0x4025d0(0x11b)]['DATABASE_TABLE'],..._0x1e495f};return docClient[_0x4025d0(0x10c)](new import_lib_dynamodb5[(_0x4025d0(0x17a))](_0x12055c));}catch(_0x33e847){console[_0x4025d0(0x1a2)](_0x4b5039[_0x4025d0(0x158)],_0x33e847);throw new Error(_0x33e847[_0x4025d0(0x109)]||_0x4b5039[_0x4025d0(0x173)]);}},scan=async(_0x4388e2,_0x1da25b={},_0x2fd05c)=>{const _0x554c0f=a0_0xb88410,_0x4e39fa={'WTyNG':_0x554c0f(0x139),'KarAK':_0x554c0f(0x143),'IOgtj':function(_0x1e5ea9,_0x4c3d37){return _0x1e5ea9===_0x4c3d37;},'nvGfY':_0x554c0f(0x1b1),'jpQgi':_0x554c0f(0x1cb),'RnjjN':function(_0x16a869,_0x35d5e6){return _0x16a869(_0x35d5e6);},'Zzatx':function(_0x346a36,_0x5b94f7){return _0x346a36(_0x5b94f7);}},_0x4a65b1={'TableName':process[_0x554c0f(0x11b)][_0x554c0f(0x194)],'ExpressionAttributeNames':{},'ExpressionAttributeValues':{}},_0x2c445=[];_0x2c445[_0x554c0f(0x11f)](_0x554c0f(0x1c8)),_0x4a65b1[_0x554c0f(0x125)][_0x4e39fa['WTyNG']]='PK',_0x4a65b1[_0x554c0f(0x18d)][_0x554c0f(0x17d)]=_0x4388e2[_0x554c0f(0x161)]+'#';_0x4388e2[_0x554c0f(0x1ac)]&&(_0x2c445['push']('begins_with(#SK,\x20:skPrefix)'),_0x4a65b1[_0x554c0f(0x125)][_0x4e39fa['KarAK']]='SK',_0x4a65b1[_0x554c0f(0x18d)][_0x554c0f(0x107)]=_0x4388e2[_0x554c0f(0x1ac)]+'#');for(const [_0x396b03,_0x277b67]of Object[_0x554c0f(0x1ab)](_0x1da25b)){const _0x57103b='#'+_0x396b03,_0x297422=':'+_0x396b03;_0x4a65b1[_0x554c0f(0x125)][_0x57103b]=_0x396b03,_0x4a65b1[_0x554c0f(0x18d)][_0x297422]=_0x277b67,_0x4e39fa[_0x554c0f(0x1c1)](typeof _0x277b67,_0x4e39fa[_0x554c0f(0x184)])?_0x2c445[_0x554c0f(0x11f)](_0x554c0f(0x102)+_0x57103b+',\x20'+_0x297422+')'):_0x2c445['push'](_0x57103b+'\x20=\x20'+_0x297422);}_0x4a65b1[_0x554c0f(0x167)]=_0x2c445[_0x554c0f(0x154)](_0x4e39fa[_0x554c0f(0x147)]);if(_0x1da25b[_0x554c0f(0x1bd)])_0x4a65b1['ExclusiveStartKey']=JSON[_0x554c0f(0x157)](_0x4e39fa[_0x554c0f(0x16c)](decodeURIComponent,_0x1da25b[_0x554c0f(0x1bd)]));return _0x4a65b1[_0x554c0f(0x17c)]=_0x2fd05c,await _0x4e39fa[_0x554c0f(0x114)](getDataInScanCommand,_0x4a65b1);},find=async(_0x3abd84,_0x213a40={},_0x2411ef=0x1)=>{const _0x411b03=a0_0xb88410,_0x25f557={'pYMda':function(_0xfc1e7f,_0x3bb0f7,_0x458b53,_0x128bdb){return _0xfc1e7f(_0x3bb0f7,_0x458b53,_0x128bdb);}},_0x3bec20=!!_0x213a40['id']||!!_0x213a40['PK'],_0x2c5782=_0x3bec20?await _0x25f557[_0x411b03(0xfe)](runQuery,_0x3abd84,_0x213a40,_0x2411ef):await _0x25f557['pYMda'](scan,_0x3abd84,_0x213a40,_0x2411ef),_0x152384=[];let _0x5a6579;if(_0x2c5782&&_0x2c5782['Items']&&_0x2c5782[_0x411b03(0x113)][_0x411b03(0x1a8)]>0x0){_0x5a6579=_0x2c5782['LastEvaluatedKey'];for(const _0x91764f of _0x2c5782[_0x411b03(0x113)]){const _0x2e3563=new _0x3abd84['constructor'](_0x3abd84[_0x411b03(0x1ba)],{'getSchema':()=>_0x3abd84[_0x411b03(0x110)]},_0x3abd84[_0x411b03(0x161)],_0x3abd84[_0x411b03(0x1ac)]);Object['assign'](_0x2e3563,_0x91764f),_0x152384[_0x411b03(0x11f)](_0x2e3563);}}return{'data':_0x152384,'LastEvaluatedKey':_0x5a6579};},runQuery=async(_0x114c4a,_0x403528,_0x41bdb6)=>{const _0xde5943=a0_0xb88410,_0x4c71b1={'PtQck':_0xde5943(0x152),'rvokt':function(_0x38ba19,_0x436643,_0x5a6c24,_0x363621,_0x1790a4){return _0x38ba19(_0x436643,_0x5a6c24,_0x363621,_0x1790a4);},'yzpeN':'#PK\x20=\x20:pk','PnjcF':_0xde5943(0x139),'vHEtQ':_0xde5943(0x1b3),'GzfKb':_0xde5943(0x143),'tgbFC':function(_0x4dc5c9,_0x2a32c9){return _0x4dc5c9>_0x2a32c9;},'NCJXn':function(_0x6d6ff9,_0x132663){return _0x6d6ff9(_0x132663);}};try{console[_0xde5943(0x118)](_0x4c71b1['PtQck']);const _0x277ff4={'TableName':process[_0xde5943(0x11b)]['DATABASE_TABLE'],'ExpressionAttributeNames':{},'ExpressionAttributeValues':{}},_0x1c018e=[],{PK:_0x42d6b4,SK:_0x382438}=_0x403528['PK']?_0x403528:_0x4c71b1['rvokt'](generateKeys,_0x114c4a[_0xde5943(0x161)],_0x403528['id'],_0x403528['sktype'],_0x403528['skId']);_0x277ff4[_0xde5943(0x19a)]=_0x4c71b1[_0xde5943(0x19f)],_0x277ff4[_0xde5943(0x125)][_0x4c71b1[_0xde5943(0x15f)]]='PK',_0x277ff4['ExpressionAttributeValues'][_0x4c71b1[_0xde5943(0x14e)]]=_0x42d6b4;(_0x403528[_0xde5943(0x11a)]||_0x382438)&&(_0x277ff4['KeyConditionExpression']+=_0xde5943(0x144),_0x277ff4['ExpressionAttributeNames'][_0x4c71b1[_0xde5943(0x1b7)]]='SK',_0x277ff4[_0xde5943(0x18d)][_0xde5943(0x13b)]=_0x382438);for(const [_0x16e25b,_0x5101fc]of Object[_0xde5943(0x1ab)](_0x403528)){if(['id',_0xde5943(0x11a),'PK']['includes'](_0x16e25b))continue;const _0x3b96d1='#'+_0x16e25b,_0x14bf97=':'+_0x16e25b;_0x277ff4[_0xde5943(0x125)][_0x3b96d1]=_0x16e25b,_0x277ff4[_0xde5943(0x18d)][_0x14bf97]=_0x5101fc,_0x1c018e[_0xde5943(0x11f)](_0x3b96d1+_0xde5943(0x14c)+_0x14bf97);}_0x4c71b1['tgbFC'](_0x1c018e[_0xde5943(0x1a8)],0x0)&&(_0x277ff4[_0xde5943(0x167)]=_0x1c018e['join'](_0xde5943(0x1cb)));if(_0x403528[_0xde5943(0x1bd)])_0x277ff4[_0xde5943(0x1b5)]=JSON[_0xde5943(0x157)](_0x4c71b1[_0xde5943(0x12e)](decodeURIComponent,_0x403528['start_key']));return _0x277ff4[_0xde5943(0x17c)]=_0x41bdb6,await _0x4c71b1[_0xde5943(0x12e)](allQueryByParams,_0x277ff4);}catch(_0x146f2b){}},list=async(_0x4528db,_0x1e7091={},_0x871b4c=0x64)=>{return await find(_0x4528db,_0x1e7091,_0x871b4c);},findAndUpdate=async(_0x654695,_0x5c9c71)=>{const _0x14a54b=a0_0xb88410,_0x18958d={'MrXoY':'Call\x20find()\x20or\x20create()\x20before\x20updating.','NLgMt':function(_0x572a29){return _0x572a29();}};if(!_0x654695['PK']||!_0x654695['SK'])throw new Error(_0x18958d[_0x14a54b(0x130)]);return Object[_0x14a54b(0x1bc)](_0x654695,_0x5c9c71,{'updated_at':_0x18958d['NLgMt'](dateNow)}),await save(_0x654695);},Model=class{constructor(_0x5f0e68,_0x5742d5,_0x5abf82,_0x2db600){const _0x4692f7=a0_0xb88410;this[_0x4692f7(0x1a6)]=()=>buildJoiSchema(this),this[_0x4692f7(0x17b)]=_0x521689=>validate(this,_0x521689),this['create']=_0x147d59=>create(this,_0x147d59),this[_0x4692f7(0x18a)]=()=>save(this),this[_0x4692f7(0x146)]=(_0x23f965={},_0x1a0244=0x1)=>find(this,_0x23f965,_0x1a0244),this['list']=(_0xfd757b={},_0x38b406=0x64)=>list(this,_0xfd757b,_0x38b406),this[_0x4692f7(0x1a1)]=_0x1e40f9=>findAndUpdate(this,_0x1e40f9),this[_0x4692f7(0x1aa)]=(_0x5118cc={},_0x4a2e43=0x64)=>scan(this,_0x5118cc,_0x4a2e43);const _0x19de6b=_0x5742d5[_0x4692f7(0x129)]();if(!_0x19de6b||!Array['isArray'](_0x19de6b))throw new Error(_0x4692f7(0x1a9));this['modelName']=_0x5f0e68,this[_0x4692f7(0x110)]=_0x19de6b,this[_0x4692f7(0x161)]=_0x5abf82,this['SKPrefix']=_0x2db600;}},Schema=class{constructor(_0x2faef5={}){const _0x51b2c8=a0_0xb88410,_0x38dca5={'rsQDB':function(_0x650f6e,_0x5bbefa){return _0x650f6e!==_0x5bbefa;},'WicyP':'Schema\x20definition\x20must\x20be\x20an\x20object.','ShSEI':'object','yHTSt':function(_0x2dc0b7,_0x51949a){return _0x2dc0b7!==_0x51949a;},'ENDov':function(_0x5bce3a,_0x20d788){return _0x5bce3a!==_0x20d788;},'krwBE':function(_0xac53f0,_0x363922){return _0xac53f0!==_0x363922;},'kSPKw':function(_0xf5b76b,_0x805a2e){return _0xf5b76b!==_0x805a2e;},'ziFis':function(_0x1470d5,_0x212f66){return _0x1470d5!==_0x212f66;},'lpNCV':function(_0x535aac,_0x1aa614){return _0x535aac!==_0x1aa614;}};if(_0x38dca5[_0x51b2c8(0x172)](typeof _0x2faef5,_0x51b2c8(0x16f))||Array[_0x51b2c8(0x18e)](_0x2faef5))throw new Error(_0x38dca5[_0x51b2c8(0x15b)]);this['fields']=[];for(const _0x5af8cd in _0x2faef5){const _0x1bbfe4=_0x2faef5[_0x5af8cd];if(_0x38dca5[_0x51b2c8(0x172)](typeof _0x1bbfe4,_0x38dca5[_0x51b2c8(0x12b)])||_0x1bbfe4===null)throw new Error(_0x51b2c8(0x145)+_0x5af8cd+_0x51b2c8(0x183));const _0xf398e7={'key':_0x5af8cd},_0x2cfbba=this['parseType'](_0x1bbfe4[_0x51b2c8(0x171)]);if(_0x2cfbba!==void 0x0)_0xf398e7[_0x51b2c8(0x171)]=_0x2cfbba;if(_0x38dca5[_0x51b2c8(0x142)](_0x1bbfe4[_0x51b2c8(0x149)],void 0x0))_0xf398e7[_0x51b2c8(0x149)]=_0x1bbfe4['required'];if(_0x1bbfe4['enum']!==void 0x0)_0xf398e7[_0x51b2c8(0x13d)]=_0x1bbfe4['enum'];if(_0x1bbfe4[_0x51b2c8(0x122)]!==void 0x0)_0xf398e7[_0x51b2c8(0x122)]=_0x1bbfe4[_0x51b2c8(0x122)];if(_0x1bbfe4[_0x51b2c8(0x165)]!==void 0x0)_0xf398e7[_0x51b2c8(0x165)]=_0x1bbfe4[_0x51b2c8(0x165)];if(_0x38dca5['ENDov'](_0x1bbfe4['maxLength'],void 0x0))_0xf398e7['maxLength']=_0x1bbfe4[_0x51b2c8(0x15a)];if(_0x38dca5[_0x51b2c8(0x1b9)](_0x1bbfe4[_0x51b2c8(0x1ad)],void 0x0))_0xf398e7[_0x51b2c8(0x1ad)]=_0x1bbfe4['isConditionalRequired'];if(_0x38dca5[_0x51b2c8(0x18c)](_0x1bbfe4['conditionKey'],void 0x0))_0xf398e7[_0x51b2c8(0x196)]=_0x1bbfe4[_0x51b2c8(0x196)];if(_0x38dca5['ziFis'](_0x1bbfe4[_0x51b2c8(0x199)],void 0x0))_0xf398e7[_0x51b2c8(0x199)]=_0x1bbfe4['compareValue'];if(_0x38dca5[_0x51b2c8(0x11c)](_0x1bbfe4[_0x51b2c8(0x156)],void 0x0))_0xf398e7[_0x51b2c8(0x156)]=_0x1bbfe4[_0x51b2c8(0x156)];if(_0x38dca5[_0x51b2c8(0x1c4)](_0x1bbfe4[_0x51b2c8(0x1c3)],void 0x0))_0xf398e7[_0x51b2c8(0x1c3)]=_0x1bbfe4['ref'];this[_0x51b2c8(0x191)]['push'](_0xf398e7);}}[a0_0xb88410(0x106)](_0x1eedce){const _0x59cedf=a0_0xb88410,_0x2f8637={'DoOTf':function(_0x541727,_0xc532f3){return _0x541727===_0xc532f3;},'pUugr':function(_0x4f46d9,_0x5b3fe5){return _0x4f46d9===_0x5b3fe5;},'OHvjW':_0x59cedf(0x1cd),'FQudI':function(_0x54c2cf,_0x19e9af){return _0x54c2cf===_0x19e9af;},'IHnWS':'boolean','aYtQq':function(_0x3c279b,_0x8dcbcd){return _0x3c279b===_0x8dcbcd;},'hLsJE':_0x59cedf(0x132),'yPqLE':function(_0x2221db,_0x380efd){return _0x2221db===_0x380efd;},'EeFFo':_0x59cedf(0x1bb)};if(_0x2f8637[_0x59cedf(0x18f)](_0x1eedce,String))return'string';if(_0x2f8637['pUugr'](_0x1eedce,Number))return _0x2f8637[_0x59cedf(0x136)];if(_0x2f8637[_0x59cedf(0x177)](_0x1eedce,Boolean))return _0x2f8637[_0x59cedf(0x169)];if(_0x2f8637[_0x59cedf(0x140)](_0x1eedce,Array))return _0x2f8637[_0x59cedf(0x133)];if(_0x2f8637[_0x59cedf(0x1af)](_0x1eedce,Object))return _0x59cedf(0x16f);if(_0x2f8637[_0x59cedf(0x1af)](_0x1eedce,_0x2f8637[_0x59cedf(0x1c2)]))return _0x2f8637[_0x59cedf(0x1c2)];if(_0x2f8637['aYtQq'](_0x1eedce,void 0x0))return void 0x0;throw new Error('Unsupported\x20type:\x20'+_0x1eedce);}[a0_0xb88410(0x129)](){const _0x1200a9=a0_0xb88410;return this[_0x1200a9(0x191)];}};0x0&&(module[a0_0xb88410(0x1a3)]={'Model':Model,'Schema':Schema,'allQueryByParams':allQueryByParams,'callUpdateByParams':callUpdateByParams,'docClient':docClient,'generateKeys':generateKeys,'getDataInScanCommand':getDataInScanCommand,'initDynamoDB':initDynamoDB,'putDataCommand':putDataCommand,'removeExtraFields':removeExtraFields});