UNPKG

lambdaorm

Version:
1 lines 13.9 kB
'use strict';const a62o=a62y;function a62y(s,y){const O=a62s();return a62y=function(D,g){D=D-0xbf;let M=O[D];return M;},a62y(s,y);}(function(s,y){const i=a62y,g=s();while(!![]){try{const x=-parseInt(i(0xc9))/0x1*(parseInt(i(0x10c))/0x2)+parseInt(i(0xe7))/0x3+-parseInt(i(0xe4))/0x4+-parseInt(i(0xd3))/0x5+parseInt(i(0x10b))/0x6*(parseInt(i(0xc7))/0x7)+parseInt(i(0xc8))/0x8*(-parseInt(i(0x12b))/0x9)+parseInt(i(0xfc))/0xa;if(x===y)break;else g['push'](g['shift']());}catch(m){g['push'](g['shift']());}}}(a62s,0xa8f6f));Object[a62o(0xd9)](exports,'__esModule',{'value':!![]}),exports[a62o(0x104)]=void 0x0;const lambdaorm_base_1=require(a62o(0x121));function a62s(){const sR=['name','dependents','addQuery','helper','entities','evalDataSource','198ngelAb','2676vXfTAo','primaryKey','changeRelation','dropPk','_syncRemoveFkForChanges','length','_syncCreatePkForChangesInEntity','dml','changed','view','builder','createSequence','sync','dropFk','addUk','query','truncateEntity','indexes','remove','setNull','SchemaError','lambdaorm-base','\x20not\x20found\x20in\x20mapping\x20for\x20truncate\x20action','relations','push','_truncate','mappings','children','truncate','_syncCreateUkForChangesInEntity','composite','120969bnjapc','schema','properties','map','_syncCreateIndexesForNewEntity','alterPropertyType','SentenceAction','domain','get','_syncModifyPropertyForEntitiesChanges','entity','sortByDependencies','property\x20','property','119749PXMkpE','248jUTfBE','916HmVvqP','_syncCreateIndexesForChangesInEntity','type','getInfo','drop','from','_syncRemoveIndexForChanges','find','weak','dialect','6078505OKgHSG','addFk','entity\x20','_dropRelation','_dropRelations','old','defineProperty','_syncRemovePrimaryKey','_drop','languages','source','_syncRemovePropertyForEntityChanges','relation','_syncCreateFksForNewEntity','_syncCreateForEntitiesChanges','_syncRemoveForEntitiesChanges','new','4389788raZpif','mapping','stage','1511841sYIeMg','dropUk','dropIndex','equalName','solveComposite','sequence','addProperty','_syncRemoveUniqueKey','schemaState','alterProperty','obj','addPk','evalSourceRule','_dropIndexes','_syncRemoveForRemovedEntities','delta','_dropEntity','\x20not\x20found\x20in\x20mapping\x20for\x20drop\x20indexes\x20action','dropEntity','sources','_syncCreateEntities','35790280phjiFu','equal','required','createIndex','_syncCreateSequencesForChangesInEntity','getDialect','_sync','uniqueKey','DDLBuilderService'];a62s=function(){return sR;};return a62s();}class DDLBuilderService{constructor(s,y,g,x){const p=a62o;this[p(0xef)]=s,this[p(0xdc)]=y,this['stage']=g,this['helper']=x,this['domain']=s[p(0xc0)];}[a62o(0xcd)](s){const f=a62o,y=[],g=this[f(0xef)][f(0xe6)]['get'](this[f(0xe6)]);for(const x of g[f(0xfa)]){const m=this[f(0xef)][f(0xdd)][f(0xc1)](x[f(0x105)]),w=s[f(0xd0)](t=>this[f(0xfd)](t[f(0x105)],m[f(0xe5)]));w!==undefined&&w[f(0x109)]!==undefined&&this[f(0xdb)](m,x,w['entities'],y);}return y;}[a62o(0x128)](s){const q=a62o,y=[],g=this['schemaState'][q(0xe6)][q(0xc1)](this[q(0xe6)]);for(const x of g[q(0xfa)]){const m=this['schemaState'][q(0xdd)][q(0xc1)](x[q(0x105)]),w=s[q(0xd0)](t=>this[q(0xfd)](t['name'],m['mapping']));w!==undefined&&w['entities']!==undefined&&this[q(0x125)](m,x,w['entities'],y);}return y;}[a62o(0x118)](s){const j=a62o,y=[],g=this[j(0xef)][j(0xe6)][j(0xc1)](this[j(0xe6)]);for(const x of g[j(0xfa)]){const m=this['schemaState'][j(0xdd)][j(0xc1)](x[j(0x105)]),w=s[j(0xd0)](k=>this[j(0xfd)](k[j(0x105)],m['mapping'])),t=w!==undefined&&w['entities']!==undefined?w[j(0x109)]:null,v=this[j(0xef)][j(0xe5)][j(0x126)][j(0xd0)](k=>this['equal'](k['name'],m[j(0xe5)])),a=v!==undefined&&v['entities']!==undefined?v[j(0x109)]:null,c=this[j(0x108)][j(0xf1)][j(0xf6)](a,t,{'ignore':[j(0x106)]});if(c[j(0x127)]&&c['children']['length']>0x0)for(const k of c[j(0x127)]){if(!k['change'])continue;this[j(0x102)](m,x,a||[],t||[],k[j(0xf6)],y);}else this['_sync'](m,x,a||[],t||[],c,y);}return y;}['_sync'](s,y,g,x,m,w){const b=a62o;this[b(0xe2)](s,y,x||[],m,w),this[b(0xf5)](s,y,m,w),this[b(0xfb)](s,y,m,w),this['_syncCreateForEntitiesChanges'](s,y,m,w),this['_syncCreateForNewEntities'](s,y,g||[],m,w);}['_drop'](s,y,g,x){const l=a62o,m=this[l(0xdc)][l(0x101)](s[l(0xd2)]),w=g[l(0x12e)](v=>v[l(0x105)]),t=this['domain']['sortByDependencies'](w);for(const v of t){if(this['evalDataSource'](y,v)){const a=g[l(0xd0)](c=>this[l(0xfd)](c[l(0x105)],v));if(a===undefined)throw new lambdaorm_base_1[(l(0x120))]('entity\x20'+v+'\x20not\x20found\x20in\x20mapping\x20for\x20drop\x20constraint\x20action');this[l(0xd7)](s,y,a,g,m,x);}}for(const c of t){if(this['evalDataSource'](y,c)){const k=g[l(0xd0)](r=>this['equal'](r[l(0x105)],c));if(k===undefined)throw new lambdaorm_base_1['SchemaError'](l(0xd5)+c+l(0xf8));this[l(0xf7)](s,k,m,x);}}}[a62o(0xd7)](s,y,g,x,m,w){const u=a62o;if(g[u(0x123)]&&!g[u(0x115)]&&(!g[u(0x12a)]||!m[u(0xeb)]))for(const t of g['relations']){const v=x[u(0xd0)](a=>this[u(0xfd)](a['name'],t[u(0xc3)]));v&&!v['view']&&(!v[u(0x12a)]||!m[u(0xeb)])&&this[u(0x10a)](y,t[u(0xc3)])&&this[u(0xd6)](s,g,t,w);}}[a62o(0xd6)](s,y,g,x){const e=a62o;var m;if(!g['weak']){const w=(m=y['properties'])===null||m===void 0x0?void 0x0:m[e(0xd0)](v=>this[e(0xfd)](v['name'],g[e(0xce)]));if(w===undefined)throw new lambdaorm_base_1[(e(0x120))](e(0xc5)+g['from']+'\x20not\x20found\x20in\x20'+y[e(0x105)]+'\x20');const t=!w[e(0xfe)];t&&this[e(0x107)](x,this[e(0x116)](s)[e(0x11f)](y,g)),this[e(0x107)](x,this[e(0x116)](s)['dropFk'](y,g));}}[a62o(0xf7)](s,y,g,x){const n=a62o;!y[n(0x115)]&&(!y['composite']||!g[n(0xeb)])&&(this[n(0xf4)](s,y,x),y['sequence']&&this[n(0x107)](x,this[n(0x116)](s)['dropSequence'](y)),this[n(0x107)](x,this[n(0x116)](s)['dropEntity'](y)));}[a62o(0xf4)](s,y,g){const h=a62o;if(y[h(0x11d)])for(const x of y[h(0x11d)]){this[h(0x107)](g,this[h(0x116)](s)[h(0xe9)](y,x));}}[a62o(0x125)](s,y,g,x){const s0=a62o,m=this[s0(0xdc)]['getDialect'](s[s0(0xd2)]),w=g['map'](v=>v[s0(0x105)]),t=this[s0(0xc0)][s0(0xc4)](w);for(const v of t){if(this[s0(0x10a)](y,v)){const a=g[s0(0xd0)](c=>this[s0(0xfd)](c[s0(0x105)],v));if(a===undefined)throw new lambdaorm_base_1[(s0(0x120))]('entity\x20'+v+s0(0x122));!a[s0(0x115)]&&(!a['composite']||!m[s0(0xeb)])&&this['addQuery'](x,this[s0(0x116)](s)[s0(0x11c)](a));}}}[a62o(0xe2)](s,y,g,x,m){const s1=a62o;if(x['changed']===undefined)return;for(const w of x['changed']){if(!w[s1(0xf6)]||!w[s1(0xf6)][s1(0x114)]||w[s1(0xd8)][s1(0x115)]||!this[s1(0x10a)](y,w['name']))continue;for(const t of w[s1(0xf6)][s1(0x114)]){if(!t['delta'])continue;switch(t[s1(0x105)]){case s1(0x10d):this[s1(0xda)](s,w,t['delta'],m);break;case s1(0x103):this[s1(0xee)](s,w,t[s1(0xf6)],m);break;case'index':this[s1(0xcf)](s,w,t['delta'],m);break;case s1(0xdf):this[s1(0x110)](s,y,g,w,t[s1(0xf6)],m);break;}}}}[a62o(0xda)](s,y,g,x){const s2=a62o;g[s2(0x11e)]&&g[s2(0x11e)]['length']>0x0&&this['addQuery'](x,this[s2(0x116)](s)[s2(0x10f)](y[s2(0xd8)])),g[s2(0x114)]&&g[s2(0x114)][s2(0x111)]>0x0&&this[s2(0x107)](x,this[s2(0x116)](s)[s2(0x10f)](y[s2(0xd8)]));}[a62o(0xee)](s,y,g,x){const s3=a62o;g[s3(0x11e)]&&g[s3(0x11e)][s3(0x111)]>0x0&&this['addQuery'](x,this['builder'](s)[s3(0xe8)](y[s3(0xd8)])),g[s3(0x114)]&&g[s3(0x114)]['length']>0x0&&this[s3(0x107)](x,this[s3(0x116)](s)['dropUk'](y[s3(0xd8)]));}[a62o(0xcf)](s,y,g,x){const s4=a62o;if(g[s4(0x114)])for(const m of g['changed']){this[s4(0x107)](x,this[s4(0x116)](s)[s4(0xe9)](y['new'],m['old']));}if(g[s4(0x11e)])for(const w of g[s4(0x11e)]){this[s4(0x107)](x,this[s4(0x116)](s)[s4(0xe9)](y[s4(0xe3)],w[s4(0xd8)]));}}[a62o(0x110)](s,y,g,x,m,w){const s5=a62o;if(m[s5(0x114)])for(const t of m[s5(0x114)]){const v=t[s5(0xe3)],a=t['old'],c=g[s5(0xd0)](k=>this[s5(0xfd)](k[s5(0x105)],a[s5(0xc3)]));c&&!c['view']&&this[s5(0x10a)](y,v['entity'])&&this['changeRelation'](a,v)&&!a['weak']&&this[s5(0x107)](w,this[s5(0x116)](s)[s5(0x119)](x['new'],a));}if(m[s5(0x11e)])for(const k of m[s5(0x11e)]){const r=k[s5(0xd8)],z=g[s5(0xd0)](d=>this[s5(0xfd)](d[s5(0x105)],r[s5(0xc3)]));z&&!z[s5(0x115)]&&this['evalDataSource'](y,r[s5(0xc3)])&&this['addQuery'](w,this[s5(0x116)](s)[s5(0x119)](x['new'],r));}}[a62o(0xf5)](s,y,g,x){const s6=a62o;if(!g[s6(0x11e)])return;for(const m of g[s6(0x11e)]){const w=m[s6(0xd8)];if(w['view'])continue;if(this[s6(0x10a)](y,w[s6(0x105)])){if(w[s6(0x11d)])for(const t of w['indexes']){this[s6(0x107)](x,this['builder'](s)[s6(0xe9)](w,t));}w[s6(0xec)]&&this[s6(0x107)](x,this['builder'](s)[s6(0x117)](w)),this[s6(0x107)](x,this[s6(0x116)](s)[s6(0xf9)](w));}}}['_syncCreateEntities'](s,y,g,x){const s7=a62o;if(!g['new'])return;const m=this['languages'][s7(0x101)](s[s7(0xd2)]);for(const w of g['new']){const t=w[s7(0xe3)];!t[s7(0x115)]&&(!t[s7(0x12a)]||!m['solveComposite'])&&this['evalDataSource'](y,t[s7(0x105)])&&(t[s7(0xec)]&&this['addQuery'](x,this[s7(0x116)](s)['createSequence'](t)),this[s7(0x107)](x,this['builder'](s)['createEntity'](t)),t[s7(0x103)]&&t['uniqueKey']['length']>0x0&&this[s7(0x107)](x,this[s7(0x116)](s)['addUk'](t,t[s7(0x103)])));}}[a62o(0xe1)](s,y,g,x){const s8=a62o;if(g[s8(0x114)]===undefined)return;for(const m of g[s8(0x114)]){if(m[s8(0xe3)]['view']||!this[s8(0x10a)](y,m[s8(0x105)]))continue;if(m['delta']&&m[s8(0xf6)][s8(0x127)]&&m[s8(0xf6)]['children'][s8(0x111)]>0x0)for(const w of m[s8(0xf6)][s8(0x127)]){if(!w['change']||!w['delta']||!w[s8(0xf6)]['changed'])continue;for(const t of w[s8(0xf6)][s8(0x114)]){if(!t[s8(0xf6)])continue;const v=t[s8(0xe3)];switch(t[s8(0x105)]){case s8(0x12d):this[s8(0xc2)](s,m,v,t['delta'],x);break;}}}else{if(m[s8(0xf6)]&&m[s8(0xf6)][s8(0x114)])for(const a of m[s8(0xf6)][s8(0x114)]){if(!a['delta'])continue;switch(a[s8(0x105)]){case s8(0xc6):this['_syncAddPropertyForEntitiesChanges'](s,m,a['delta'],x),this[s8(0xde)](s,m,a[s8(0xf6)],x);break;case'primaryKey':this[s8(0x112)](s,m,a[s8(0xf6)],x);break;case'uniqueKey':this['_syncCreateUkForChangesInEntity'](s,m,a[s8(0xf6)],x);break;case'index':this[s8(0xca)](s,m,a['delta'],x);break;case s8(0xdf):this['_syncCreateFksForChangesInEntity'](s,y,m,a['delta'],x);break;case s8(0xec):this[s8(0x100)](s,m,x);break;}}}}}['_syncAddPropertyForEntitiesChanges'](s,y,g,x){const s9=a62o;if(g[s9(0xe3)])for(const m in g['new']){const w=g[s9(0xe3)][m][s9(0xe3)];this['addQuery'](x,this['builder'](s)[s9(0xed)](y[s9(0xe3)],w));}if(g[s9(0x114)])for(const t of g[s9(0x114)]){const v=t[s9(0xe3)],a=t['old'];this[s9(0xfd)](v[s9(0xe5)],a[s9(0xe5)])&&!v[s9(0x115)]&&this[s9(0x107)](x,this[s9(0x116)](s)[s9(0xf0)](y['new'],v));}}['_syncModifyPropertyForEntitiesChanges'](s,y,g,x,m){const ss=a62o;if(!x['changed'])return;for(const w of x[ss(0x114)]){switch(w[ss(0x105)]){case ss(0x111):case'type':this['addQuery'](m,this[ss(0x116)](s)[ss(0x130)](y[ss(0xe3)],g));break;case ss(0xfe):this[ss(0x107)](m,this[ss(0x116)](s)['alterPropertyRequired'](y['new'],g));break;}}}['_syncRemovePropertyForEntityChanges'](s,y,g,x){const sy=a62o;if(g['remove'])for(const m of g[sy(0x11e)]){const w=m[sy(0xd8)];!w[sy(0x115)]&&this['addQuery'](x,this[sy(0x116)](s)['dropProperty'](y[sy(0xd8)],w));}}[a62o(0x112)](s,y,g,x){const sO=a62o;if(g[sO(0xe3)])for(const m of g[sO(0xe3)]){const w=m[sO(0xe3)];this[sO(0x107)](x,this[sO(0x116)](s)[sO(0xf2)](y[sO(0xe3)],w));}if(g[sO(0x114)])for(const t of g[sO(0x114)]){const v=t['new'];this[sO(0x107)](x,this[sO(0x116)](s)[sO(0xf2)](y['new'],v));}}[a62o(0x129)](s,y,g,x){const sD=a62o;if(g[sD(0xe3)])for(const m of g[sD(0xe3)]){const w=m[sD(0xe3)];this[sD(0x107)](x,this[sD(0x116)](s)['addUk'](y[sD(0xe3)],w));}if(g[sD(0x114)])for(const t of g[sD(0x114)]){const v=t[sD(0xe3)];this[sD(0x107)](x,this[sD(0x116)](s)[sD(0x11a)](y['new'],v));}}[a62o(0xca)](s,y,g,x){const sg=a62o;if(g[sg(0xe3)])for(const m of g[sg(0xe3)]){const w=m[sg(0xe3)];this[sg(0x107)](x,this['builder'](s)[sg(0xff)](y[sg(0xe3)],w));}if(g['changed'])for(const t of g[sg(0x114)]){const v=t[sg(0xe3)];this[sg(0x107)](x,this['builder'](s)[sg(0xff)](y[sg(0xe3)],v));}}['_syncCreateFksForChangesInEntity'](s,y,g,x,m){const sM=a62o;if(x[sM(0xe3)])for(const w of x[sM(0xe3)]){const t=w['new'];this[sM(0x10a)](y,t[sM(0xc3)])&&!t[sM(0xd1)]&&this['addQuery'](m,this[sM(0x116)](s)[sM(0xd4)](g[sM(0xe3)],t));}if(x[sM(0x114)])for(const v of x[sM(0x114)]){const a=v['new'],c=v['old'];this[sM(0x10a)](y,a[sM(0xc3)])&&this[sM(0x10e)](c,a)&&!a['weak']&&this[sM(0x107)](m,this[sM(0x116)](s)[sM(0xd4)](g[sM(0xe3)],a));}}['_syncCreateSequencesForChangesInEntity'](s,y,g){const sE=a62o;this[sE(0x107)](g,this[sE(0x116)](s)[sE(0x117)](y[sE(0xe3)]));}['_syncCreateForNewEntities'](s,y,g,x,m){const sx=a62o;if(x[sx(0xe3)])for(const w of x['new']){const t=w[sx(0xe3)];if(t[sx(0x115)]||!this[sx(0x10a)](y,t[sx(0x105)]))continue;this[sx(0x12f)](s,t,m),this[sx(0xe0)](s,y,g,t,m);}}[a62o(0xe0)](s,y,g,x,m){const sm=a62o;if(x[sm(0x123)])for(const w of x['relations']){const t=g['find'](v=>this[sm(0xfd)](v[sm(0x105)],w[sm(0xc3)]));if(t&&t[sm(0x115)]||!this['evalDataSource'](y,w[sm(0xc3)])||w[sm(0xd1)])continue;this['addQuery'](m,this[sm(0x116)](s)['addFk'](x,w));}}['_syncCreateIndexesForNewEntity'](s,y,g){const sH=a62o;if(y[sH(0x11d)])for(const x of y[sH(0x11d)]){this[sH(0x107)](g,this[sH(0x116)](s)['createIndex'](y,x));}}[a62o(0x10a)](s,y){const sw=a62o;return this[sw(0xef)][sw(0xf3)](s,this[sw(0x108)][sw(0x11b)][sw(0xcc)](lambdaorm_base_1[sw(0xbf)]['undefined'],y,lambdaorm_base_1['SentenceType'][sw(0x113)]));}['builder'](s){const sI=a62o,y=this[sI(0xdc)]['getByDialect'](s[sI(0xd2)]),g=this[sI(0xef)][sI(0xe5)]['getInstance'](s['mapping']);return y['ddlBuilder'](s,g);}['addQuery'](s,y){const sF=a62o;if(y)s[sF(0x124)](y);}[a62o(0x10e)](s,y){const st=a62o;return!this[st(0xfd)](s[st(0xc3)],y[st(0xc3)])||!this['equal'](s[st(0xce)],y['from'])||!this['equal'](s[st(0x105)],y['name'])||!this[st(0xfd)](s['to'],y['to'])||!this[st(0xfd)](s['type'],y[st(0xcb)]);}[a62o(0xfd)](s,y){const sv=a62o;return this[sv(0x108)][sv(0x12c)][sv(0xea)](s,y);}}exports[a62o(0x104)]=DDLBuilderService;