@ooneex/typeorm 0.13.0 → 0.14.0

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.
Files changed (141) hide show
  1. package/dist/shared/chunk-19qhst35.js +5 -0
  2. package/dist/shared/{chunk-tqd6ek7s.js.map → chunk-19qhst35.js.map} +2 -2
  3. package/dist/shared/{chunk-trhrh4e1.js → chunk-31y260d6.js} +24 -89
  4. package/dist/shared/{chunk-trhrh4e1.js.map → chunk-31y260d6.js.map} +2 -2
  5. package/dist/shared/chunk-59vwmfpm.js +5 -0
  6. package/dist/shared/{chunk-r9hsk9fk.js.map → chunk-59vwmfpm.js.map} +1 -1
  7. package/dist/shared/chunk-5tnqjb3n.js +5 -0
  8. package/dist/shared/{chunk-2wdazj26.js.map → chunk-5tnqjb3n.js.map} +2 -2
  9. package/dist/shared/chunk-5ybg5hda.js +5 -0
  10. package/dist/shared/{chunk-m4mpkr4n.js.map → chunk-5ybg5hda.js.map} +2 -2
  11. package/dist/shared/chunk-6jnj2pfx.js +5 -0
  12. package/dist/shared/{chunk-p12g6e7b.js.map → chunk-6jnj2pfx.js.map} +2 -2
  13. package/dist/shared/chunk-6kdkyjbn.js +5 -0
  14. package/dist/shared/{chunk-mssxq87m.js.map → chunk-6kdkyjbn.js.map} +2 -2
  15. package/dist/shared/{chunk-jap9t59k.js → chunk-aj0aak90.js} +14 -52
  16. package/dist/shared/{chunk-jap9t59k.js.map → chunk-aj0aak90.js.map} +2 -2
  17. package/dist/shared/chunk-e51ktjsq.js +5 -0
  18. package/dist/shared/{chunk-efmap3y3.js.map → chunk-e51ktjsq.js.map} +2 -2
  19. package/dist/shared/{chunk-yszvxhf3.js → chunk-jr0xys18.js} +11 -41
  20. package/dist/shared/{chunk-yszvxhf3.js.map → chunk-jr0xys18.js.map} +2 -2
  21. package/dist/shared/chunk-kw4t1san.js +5 -0
  22. package/dist/shared/{chunk-m9wkjs7v.js.map → chunk-kw4t1san.js.map} +2 -2
  23. package/dist/shared/chunk-nfv9ce7v.js +5 -0
  24. package/dist/shared/{chunk-qbn9p4vj.js.map → chunk-nfv9ce7v.js.map} +2 -2
  25. package/dist/shared/chunk-p22keb3y.js +5 -0
  26. package/dist/shared/{chunk-bkdccdhn.js.map → chunk-p22keb3y.js.map} +2 -2
  27. package/dist/shared/chunk-pbns711f.js +5 -0
  28. package/dist/shared/{chunk-hkfj9j6w.js.map → chunk-pbns711f.js.map} +2 -2
  29. package/dist/shared/{chunk-6vmvyg0q.js → chunk-qrs0g3m9.js} +17 -58
  30. package/dist/shared/{chunk-6vmvyg0q.js.map → chunk-qrs0g3m9.js.map} +2 -2
  31. package/dist/shared/{chunk-eets3mef.js → chunk-qyf32qsz.js} +22 -75
  32. package/dist/shared/{chunk-eets3mef.js.map → chunk-qyf32qsz.js.map} +2 -2
  33. package/dist/shared/chunk-t1jad451.js +5 -0
  34. package/dist/shared/{chunk-cv6xa6qy.js.map → chunk-t1jad451.js.map} +2 -2
  35. package/dist/shared/chunk-t5cy307m.js +5 -0
  36. package/dist/shared/{chunk-wg7xcq50.js.map → chunk-t5cy307m.js.map} +2 -2
  37. package/dist/shared/chunk-x2d798hg.js +5 -0
  38. package/dist/shared/{chunk-sk8z5zmk.js.map → chunk-x2d798hg.js.map} +2 -2
  39. package/dist/shared/chunk-x3pmm3na.js +5 -0
  40. package/dist/shared/{chunk-cwxhwya1.js.map → chunk-x3pmm3na.js.map} +2 -2
  41. package/dist/shared/chunk-xrqhqgen.js +5 -0
  42. package/dist/shared/{chunk-chan1evn.js.map → chunk-xrqhqgen.js.map} +2 -2
  43. package/dist/shared/chunk-xwe8m6av.js +5 -0
  44. package/dist/shared/{chunk-0swb1h0m.js.map → chunk-xwe8m6av.js.map} +2 -2
  45. package/dist/shared/chunk-yrwsqc6r.js +5 -0
  46. package/dist/shared/{chunk-6m3p1ht9.js.map → chunk-yrwsqc6r.js.map} +2 -2
  47. package/dist/src/entities/book/index.js +2 -34
  48. package/dist/src/entities/book/index.js.map +1 -1
  49. package/dist/src/entities/common/index.js +2 -26
  50. package/dist/src/entities/common/index.js.map +1 -1
  51. package/dist/src/entities/country/index.js +2 -9
  52. package/dist/src/entities/country/index.js.map +1 -1
  53. package/dist/src/entities/currency/index.js +2 -9
  54. package/dist/src/entities/currency/index.js.map +1 -1
  55. package/dist/src/entities/folder/index.js +2 -394
  56. package/dist/src/entities/folder/index.js.map +2 -2
  57. package/dist/src/entities/gamification/flashcard/index.js +2 -26
  58. package/dist/src/entities/gamification/flashcard/index.js.map +1 -1
  59. package/dist/src/entities/gamification/index.js +2 -9
  60. package/dist/src/entities/gamification/index.js.map +1 -1
  61. package/dist/src/entities/gamification/mcq/index.js +2 -36
  62. package/dist/src/entities/gamification/mcq/index.js.map +1 -1
  63. package/dist/src/entities/image/index.js +2 -31
  64. package/dist/src/entities/image/index.js.map +1 -1
  65. package/dist/src/entities/medecine/index.js +2 -13
  66. package/dist/src/entities/medecine/index.js.map +1 -1
  67. package/dist/src/entities/payment/index.js +2 -23
  68. package/dist/src/entities/payment/index.js.map +1 -1
  69. package/dist/src/entities/user/index.js +2 -30
  70. package/dist/src/entities/user/index.js.map +1 -1
  71. package/dist/src/entities/video/index.js +2 -34
  72. package/dist/src/entities/video/index.js.map +1 -1
  73. package/dist/src/migrations/book/index.js +137 -541
  74. package/dist/src/migrations/book/index.js.map +2 -2
  75. package/dist/src/migrations/common/index.js +14 -63
  76. package/dist/src/migrations/common/index.js.map +2 -2
  77. package/dist/src/migrations/country/index.js +13 -48
  78. package/dist/src/migrations/country/index.js.map +2 -2
  79. package/dist/src/migrations/currency/index.js +14 -50
  80. package/dist/src/migrations/currency/index.js.map +2 -2
  81. package/dist/src/migrations/folder/index.js +104 -426
  82. package/dist/src/migrations/folder/index.js.map +2 -2
  83. package/dist/src/migrations/gamification/flashcard/index.js +96 -356
  84. package/dist/src/migrations/gamification/flashcard/index.js.map +2 -2
  85. package/dist/src/migrations/gamification/index.js +2 -8
  86. package/dist/src/migrations/gamification/index.js.map +1 -1
  87. package/dist/src/migrations/gamification/mcq/index.js +139 -553
  88. package/dist/src/migrations/gamification/mcq/index.js.map +2 -2
  89. package/dist/src/migrations/image/index.js +85 -353
  90. package/dist/src/migrations/image/index.js.map +2 -2
  91. package/dist/src/migrations/medecine/index.js +36 -132
  92. package/dist/src/migrations/medecine/index.js.map +2 -2
  93. package/dist/src/migrations/payment/index.js +94 -339
  94. package/dist/src/migrations/payment/index.js.map +2 -2
  95. package/dist/src/migrations/user/index.js +39 -331
  96. package/dist/src/migrations/user/index.js.map +2 -2
  97. package/dist/src/migrations/video/index.js +17 -345
  98. package/dist/src/migrations/video/index.js.map +2 -2
  99. package/dist/src/repositories/book/index.js +2 -997
  100. package/dist/src/repositories/book/index.js.map +2 -2
  101. package/dist/src/repositories/common/index.js +2 -439
  102. package/dist/src/repositories/common/index.js.map +2 -2
  103. package/dist/src/repositories/country/index.js +2 -89
  104. package/dist/src/repositories/country/index.js.map +2 -2
  105. package/dist/src/repositories/currency/index.js +2 -89
  106. package/dist/src/repositories/currency/index.js.map +2 -2
  107. package/dist/src/repositories/gamification/flashcard/index.js +2 -632
  108. package/dist/src/repositories/gamification/flashcard/index.js.map +2 -2
  109. package/dist/src/repositories/gamification/index.js +2 -160
  110. package/dist/src/repositories/gamification/index.js.map +2 -2
  111. package/dist/src/repositories/gamification/mcq/index.js +2 -1017
  112. package/dist/src/repositories/gamification/mcq/index.js.map +2 -2
  113. package/dist/src/repositories/image/index.js +2 -800
  114. package/dist/src/repositories/image/index.js.map +2 -2
  115. package/dist/src/repositories/medecine/index.js +2 -243
  116. package/dist/src/repositories/medecine/index.js.map +2 -2
  117. package/dist/src/repositories/payment/index.js +2 -560
  118. package/dist/src/repositories/payment/index.js.map +2 -2
  119. package/dist/src/repositories/user/index.js +2 -999
  120. package/dist/src/repositories/user/index.js.map +2 -2
  121. package/dist/src/repositories/video/index.js +2 -975
  122. package/dist/src/repositories/video/index.js.map +2 -2
  123. package/package.json +1 -1
  124. package/dist/shared/chunk-0swb1h0m.js +0 -51
  125. package/dist/shared/chunk-2wdazj26.js +0 -371
  126. package/dist/shared/chunk-6m3p1ht9.js +0 -606
  127. package/dist/shared/chunk-bkdccdhn.js +0 -105
  128. package/dist/shared/chunk-chan1evn.js +0 -72
  129. package/dist/shared/chunk-cv6xa6qy.js +0 -621
  130. package/dist/shared/chunk-cwxhwya1.js +0 -548
  131. package/dist/shared/chunk-efmap3y3.js +0 -345
  132. package/dist/shared/chunk-hkfj9j6w.js +0 -30
  133. package/dist/shared/chunk-m4mpkr4n.js +0 -34
  134. package/dist/shared/chunk-m9wkjs7v.js +0 -639
  135. package/dist/shared/chunk-mssxq87m.js +0 -195
  136. package/dist/shared/chunk-p12g6e7b.js +0 -38
  137. package/dist/shared/chunk-qbn9p4vj.js +0 -835
  138. package/dist/shared/chunk-r9hsk9fk.js +0 -20
  139. package/dist/shared/chunk-sk8z5zmk.js +0 -112
  140. package/dist/shared/chunk-tqd6ek7s.js +0 -86
  141. package/dist/shared/chunk-wg7xcq50.js +0 -38
@@ -1,1001 +1,4 @@
1
1
  // @bun
2
- import {
3
- AccountEntity,
4
- SessionEntity,
5
- UserBlockedEntity,
6
- UserEntity,
7
- UserFollowedEntity,
8
- UserProfileUpdateEntity,
9
- UserReportEntity,
10
- UserStatEntity,
11
- UserViewedEntity,
12
- VerificationEntity
13
- } from "../../../shared/chunk-m9wkjs7v.js";
14
- import"../../../shared/chunk-bkdccdhn.js";
15
- import"../../../shared/chunk-p12g6e7b.js";
16
- import"../../../shared/chunk-sk8z5zmk.js";
17
- import"../../../shared/chunk-chan1evn.js";
18
- import {
19
- __legacyDecorateClassTS,
20
- __legacyDecorateParamTS,
21
- __legacyMetadataTS
22
- } from "../../../shared/chunk-r9hsk9fk.js";
2
+ import{Aa as d,ra as y,sa as I,ta as g,ua as m,va as q,wa as U,xa as u,ya as k,za as l}from"../../../shared/chunk-kw4t1san.js";import"../../../shared/chunk-p22keb3y.js";import"../../../shared/chunk-6jnj2pfx.js";import"../../../shared/chunk-x2d798hg.js";import"../../../shared/chunk-xrqhqgen.js";import{Ha as Y,Ia as Z,Ja as _}from"../../../shared/chunk-59vwmfpm.js";import{inject as p}from"@ooneex/container";import{decorator as a}from"@ooneex/repository";import{ILike as j}from"typeorm";class W{database;constructor(x){this.database=x}async open(){return await this.database.open(I)}async close(){await this.database.close()}async find(x){let v=await this.open(),{page:G=1,limit:z=100,q:H,...J}=x,K,X=z===0?100:z;if(G&&G>0&&z&&z>0)K=(G-1)*X;let N={...J,take:X,...K!==void 0&&{skip:K}};if(H){let Q=[{provider:j(`%${H}%`)},{providerAccountId:j(`%${H}%`)},{email:j(`%${H}%`)},{name:j(`%${H}%`)}];N={...N,where:J.where?[...Q.map((M)=>({...J.where,...M}))]:Q}}let $=await v.find(N),B=J.where;if(H){let Q=[{provider:j(`%${H}%`)},{providerAccountId:j(`%${H}%`)},{email:j(`%${H}%`)},{name:j(`%${H}%`)}];B=J.where?[...Q.map((M)=>({...J.where,...M}))]:Q}let F=await this.count(B),b=Math.ceil(F/z);return{resources:$,total:F,totalPages:b,page:G,limit:z}}async findOne(x){return await(await this.open()).findOne({where:{id:x}})}async findOneBy(x){return await(await this.open()).findOne({where:x})}async create(x,v){return await(await this.open()).save(x,v)}async createMany(x,v){return await(await this.open()).save(x,v)}async update(x,v){return await this.create(x,v)}async updateMany(x,v){return await this.createMany(x,v)}async delete(x){return await(await this.open()).softDelete(x)}async count(x){return await(await this.open()).count(x?{where:x}:{})}}W=Y([a.repository(),Z(0,p("database")),_("design:paramtypes",[typeof ITypeormDatabase==="undefined"?Object:ITypeormDatabase])],W);import{inject as n}from"@ooneex/container";import{decorator as s}from"@ooneex/repository";import{ILike as T,LessThan as r}from"typeorm";class V{database;constructor(x){this.database=x}async open(){return await this.database.open(g)}async close(){await this.database.close()}async find(x){let v=await this.open(),{page:G=1,limit:z=100,q:H,...J}=x,K,X=z===0?100:z;if(G&&G>0&&z&&z>0)K=(G-1)*X;let N={...J,take:X,...K!==void 0&&{skip:K}};if(H){let Q=[{deviceName:T(`%${H}%`)},{deviceType:T(`%${H}%`)},{browser:T(`%${H}%`)},{operatingSystem:T(`%${H}%`)},{location:T(`%${H}%`)}];N={...N,where:J.where?[...Q.map((M)=>({...J.where,...M}))]:Q}}let $=await v.find(N),B=J.where;if(H){let Q=[{deviceName:T(`%${H}%`)},{deviceType:T(`%${H}%`)},{browser:T(`%${H}%`)},{operatingSystem:T(`%${H}%`)},{location:T(`%${H}%`)}];B=J.where?[...Q.map((M)=>({...J.where,...M}))]:Q}let F=await this.count(B),b=Math.ceil(F/z);return{resources:$,total:F,totalPages:b,page:G,limit:z}}async findOne(x){return await(await this.open()).findOne({where:{id:x}})}async findOneBy(x){return await(await this.open()).findOne({where:x})}async findByToken(x){return await(await this.open()).findOne({where:{token:x}})}async findByRefreshToken(x){return await(await this.open()).findOne({where:{refreshToken:x}})}async findActiveSessions(x){return await(await this.open()).find({where:{user:{id:x},isActive:!0},order:{lastAccessAt:"DESC"}})}async findExpiredSessions(){return await(await this.open()).find({where:{expiresAt:r(new Date),isActive:!0}})}async create(x,v){return await(await this.open()).save(x,v)}async createMany(x,v){return await(await this.open()).save(x,v)}async update(x,v){return await this.create(x,v)}async updateMany(x,v){return await this.createMany(x,v)}async delete(x){return await(await this.open()).softDelete(x)}async revokeSession(x,v){let G=await this.open(),z={isActive:!1,revokedAt:new Date};if(v!==void 0)z.revokedReason=v;return await G.update(x,z)}async revokeAllUserSessions(x,v){let G=await this.open(),z={isActive:!1,revokedAt:new Date};if(v!==void 0)z.revokedReason=v;return await G.update({user:{id:x},isActive:!0},z)}async count(x){return await(await this.open()).count(x?{where:x}:{})}}V=Y([s.repository(),Z(0,n("database")),_("design:paramtypes",[typeof ITypeormDatabase==="undefined"?Object:ITypeormDatabase])],V);import{inject as o}from"@ooneex/container";import{decorator as e}from"@ooneex/repository";class S{database;constructor(x){this.database=x}async open(){return await this.database.open(m)}async close(){await this.database.close()}async find(x){let v=await this.open(),{page:G=1,limit:z=100,...H}=x,J,K=z===0?100:z;if(G&&G>0&&z&&z>0)J=(G-1)*K;let X=await v.find({...H,take:K,...J!==void 0&&{skip:J}}),N=await this.count(H.where),$=Math.ceil(N/z);return{resources:X,total:N,totalPages:$,page:G,limit:z}}async findOne(x){return await(await this.open()).findOne({where:{id:x}})}async findOneBy(x){return await(await this.open()).findOne({where:x})}async create(x,v){return await(await this.open()).save(x,v)}async createMany(x,v){return await(await this.open()).save(x,v)}async update(x,v){return await this.create(x,v)}async updateMany(x,v){return await this.createMany(x,v)}async delete(x){return await(await this.open()).softDelete(x)}async count(x){return await(await this.open()).count(x?{where:x}:{})}}S=Y([e.repository(),Z(0,o("database")),_("design:paramtypes",[typeof ITypeormDatabase==="undefined"?Object:ITypeormDatabase])],S);import{inject as t}from"@ooneex/container";import{decorator as i}from"@ooneex/repository";class O{database;constructor(x){this.database=x}async open(){return await this.database.open(q)}async close(){await this.database.close()}async find(x){let v=await this.open(),{page:G=1,limit:z=100,...H}=x,J,K=z===0?100:z;if(G&&G>0&&z&&z>0)J=(G-1)*K;let X=await v.find({...H,take:K,...J!==void 0&&{skip:J}}),N=await this.count(H.where),$=Math.ceil(N/z);return{resources:X,total:N,totalPages:$,page:G,limit:z}}async findOne(x){return await(await this.open()).findOne({where:{id:x}})}async findOneBy(x){return await(await this.open()).findOne({where:x})}async create(x,v){return await(await this.open()).save(x,v)}async createMany(x,v){return await(await this.open()).save(x,v)}async update(x,v){return await this.create(x,v)}async updateMany(x,v){return await this.createMany(x,v)}async delete(x){return await(await this.open()).softDelete(x)}async count(x){return await(await this.open()).count(x?{where:x}:{})}}O=Y([i.repository(),Z(0,t("database")),_("design:paramtypes",[typeof ITypeormDatabase==="undefined"?Object:ITypeormDatabase])],O);import{inject as xx}from"@ooneex/container";import{decorator as vx}from"@ooneex/repository";import{EProfileUpdateStatus as L}from"@ooneex/user";import{ILike as P}from"typeorm";class C{database;constructor(x){this.database=x}async open(){return await this.database.open(u)}async close(){await this.database.close()}async find(x){let v=await this.open(),{page:G=1,limit:z=100,q:H,...J}=x,K,X=z===0?100:z;if(G&&G>0&&z&&z>0)K=(G-1)*X;let N={...J,take:X,...K!==void 0&&{skip:K}};if(H){let Q=[{updateReason:P(`%${H}%`)},{description:P(`%${H}%`)}];N={...N,where:J.where?[...Q.map((M)=>({...J.where,...M}))]:Q}}let $=await v.find(N),B=J.where;if(H){let Q=[{updateReason:P(`%${H}%`)},{description:P(`%${H}%`)}];B=J.where?[...Q.map((M)=>({...J.where,...M}))]:Q}let F=await this.count(B),b=Math.ceil(F/z);return{resources:$,total:F,totalPages:b,page:G,limit:z}}async findOne(x){return await(await this.open()).findOne({where:{id:x}})}async findOneBy(x){return await(await this.open()).findOne({where:x})}async create(x,v){return await(await this.open()).save(x,v)}async createMany(x,v){return await(await this.open()).save(x,v)}async update(x,v){return await this.create(x,v)}async updateMany(x,v){return await this.createMany(x,v)}async markAsCompleted(x){return await(await this.open()).update(x,{status:L.COMPLETED,appliedAt:new Date})}async markAsFailed(x,v){let G=await this.open(),z={status:L.FAILED};if(v!==void 0)z.description=v;return await G.update(x,z)}async markAsReverted(x,v){let G=await this.open(),z={status:L.REVERTED};if(v!==void 0)z.description=v;return await G.update(x,z)}async delete(x){return await(await this.open()).softDelete(x)}async count(x){return await(await this.open()).count(x?{where:x}:{})}}C=Y([vx.repository(),Z(0,xx("database")),_("design:paramtypes",[typeof ITypeormDatabase==="undefined"?Object:ITypeormDatabase])],C);import{inject as zx}from"@ooneex/container";import{decorator as Gx}from"@ooneex/repository";class w{database;constructor(x){this.database=x}async open(){return await this.database.open(k)}async close(){await this.database.close()}async find(x){let v=await this.open(),{page:G=1,limit:z=100,...H}=x,J,K=z===0?100:z;if(G&&G>0&&z&&z>0)J=(G-1)*K;let X=await v.find({...H,take:K,...J!==void 0&&{skip:J}}),N=await this.count(H.where),$=Math.ceil(N/z);return{resources:X,total:N,totalPages:$,page:G,limit:z}}async findOne(x){return await(await this.open()).findOne({where:{id:x}})}async findOneBy(x){return await(await this.open()).findOne({where:x})}async create(x,v){return await(await this.open()).save(x,v)}async createMany(x,v){return await(await this.open()).save(x,v)}async update(x,v){return await this.create(x,v)}async updateMany(x,v){return await this.createMany(x,v)}async delete(x){return await(await this.open()).softDelete(x)}async count(x){return await(await this.open()).count(x?{where:x}:{})}}w=Y([Gx.repository(),Z(0,zx("database")),_("design:paramtypes",[typeof ITypeormDatabase==="undefined"?Object:ITypeormDatabase])],w);import{inject as Hx}from"@ooneex/container";import{decorator as Jx}from"@ooneex/repository";import{ILike as A}from"typeorm";class f{database;constructor(x){this.database=x}async open(){return await this.database.open(y)}async close(){await this.database.close()}async find(x){let v=await this.open(),{page:G=1,limit:z=100,q:H,...J}=x,K,X=z===0?100:z;if(G&&G>0&&z&&z>0)K=(G-1)*X;let N={...J,take:X,...K!==void 0&&{skip:K}};if(H){let Q=[{email:A(`%${H}%`)},{name:A(`%${H}%`)},{firstName:A(`%${H}%`)},{lastName:A(`%${H}%`)},{username:A(`%${H}%`)}];N={...N,where:J.where?[...Q.map((M)=>({...J.where,...M}))]:Q}}let $=await v.find(N),B=J.where;if(H){let Q=[{email:A(`%${H}%`)},{name:A(`%${H}%`)},{firstName:A(`%${H}%`)},{lastName:A(`%${H}%`)},{username:A(`%${H}%`)}];B=J.where?[...Q.map((M)=>({...J.where,...M}))]:Q}let F=await this.count(B),b=Math.ceil(F/z);return{resources:$,total:F,totalPages:b,page:G,limit:z}}async findOne(x){return await(await this.open()).findOne({where:{id:x}})}async findOneBy(x){return await(await this.open()).findOne({where:x})}async create(x,v){return await(await this.open()).save(x,v)}async createMany(x,v){return await(await this.open()).save(x,v)}async update(x,v){return await this.create(x,v)}async updateMany(x,v){return await this.createMany(x,v)}async delete(x){return await(await this.open()).softDelete(x)}async count(x){return await(await this.open()).count(x?{where:x}:{})}}f=Y([Jx.repository(),Z(0,Hx("database")),_("design:paramtypes",[typeof ITypeormDatabase==="undefined"?Object:ITypeormDatabase])],f);import{inject as Kx}from"@ooneex/container";import{decorator as Nx}from"@ooneex/repository";class E{database;constructor(x){this.database=x}async open(){return await this.database.open(l)}async close(){await this.database.close()}async find(x){let v=await this.open(),{page:G=1,limit:z=100,...H}=x,J,K=z===0?100:z;if(G&&G>0&&z&&z>0)J=(G-1)*K;let X=await v.find({...H,take:K,...J!==void 0&&{skip:J}}),N=await this.count(H.where),$=Math.ceil(N/z);return{resources:X,total:N,totalPages:$,page:G,limit:z}}async findOne(x){return await(await this.open()).findOne({where:{id:x}})}async findOneBy(x){return await(await this.open()).findOne({where:x})}async create(x,v){return await(await this.open()).save(x,v)}async createMany(x,v){return await(await this.open()).save(x,v)}async update(x,v){return await this.create(x,v)}async updateMany(x,v){return await this.createMany(x,v)}async delete(x){return await(await this.open()).softDelete(x)}async count(x){return await(await this.open()).count(x?{where:x}:{})}}E=Y([Nx.repository(),Z(0,Kx("database")),_("design:paramtypes",[typeof ITypeormDatabase==="undefined"?Object:ITypeormDatabase])],E);import{inject as Qx}from"@ooneex/container";import{decorator as Xx}from"@ooneex/repository";class R{database;constructor(x){this.database=x}async open(){return await this.database.open(d)}async close(){await this.database.close()}async find(x){let v=await this.open(),{page:G=1,limit:z=100,...H}=x,J,K=z===0?100:z;if(G&&G>0&&z&&z>0)J=(G-1)*K;let X=await v.find({...H,take:K,...J!==void 0&&{skip:J}}),N=await this.count(H.where),$=Math.ceil(N/z);return{resources:X,total:N,totalPages:$,page:G,limit:z}}async findOne(x){return await(await this.open()).findOne({where:{id:x}})}async findOneBy(x){return await(await this.open()).findOne({where:x})}async create(x,v){return await(await this.open()).save(x,v)}async createMany(x,v){return await(await this.open()).save(x,v)}async update(x,v){return await this.create(x,v)}async updateMany(x,v){return await this.createMany(x,v)}async delete(x){return await(await this.open()).softDelete(x)}async count(x){return await(await this.open()).count(x?{where:x}:{})}}R=Y([Xx.repository(),Z(0,Qx("database")),_("design:paramtypes",[typeof ITypeormDatabase==="undefined"?Object:ITypeormDatabase])],R);import{inject as Yx}from"@ooneex/container";import{decorator as Zx}from"@ooneex/repository";import{ILike as D,MoreThan as c}from"typeorm";class h{database;constructor(x){this.database=x}async open(){return await this.database.open(U)}async close(){await this.database.close()}async find(x){let v=await this.open(),{page:G=1,limit:z=100,q:H,...J}=x,K,X=z===0?100:z;if(G&&G>0&&z&&z>0)K=(G-1)*X;let N={...J,take:X,...K!==void 0&&{skip:K}};if(H){let Q=[{email:D(`%${H}%`)},{phone:D(`%${H}%`)},{token:D(`%${H}%`)},{code:D(`%${H}%`)},{description:D(`%${H}%`)}];N={...N,where:J.where?[...Q.map((M)=>({...J.where,...M}))]:Q}}let $=await v.find(N),B=J.where;if(H){let Q=[{email:D(`%${H}%`)},{phone:D(`%${H}%`)},{token:D(`%${H}%`)},{code:D(`%${H}%`)},{description:D(`%${H}%`)}];B=J.where?[...Q.map((M)=>({...J.where,...M}))]:Q}let F=await this.count(B),b=Math.ceil(F/z);return{resources:$,total:F,totalPages:b,page:G,limit:z}}async findOne(x){return await(await this.open()).findOne({where:{id:x}})}async findOneBy(x){return await(await this.open()).findOne({where:x})}async findByToken(x){return await(await this.open()).findOne({where:{token:x,isUsed:!1,expiresAt:c(new Date)}})}async findByCode(x){return await(await this.open()).findOne({where:{code:x,isUsed:!1,expiresAt:c(new Date)}})}async create(x,v){return await(await this.open()).save(x,v)}async createMany(x,v){return await(await this.open()).save(x,v)}async update(x,v){return await this.create(x,v)}async updateMany(x,v){return await this.createMany(x,v)}async markAsUsed(x){return await(await this.open()).update(x,{isUsed:!0,usedAt:new Date})}async incrementAttempts(x){return await(await this.open()).createQueryBuilder().update(U).set({attemptsCount:()=>"attempts_count + 1"}).where("id = :id",{id:x}).execute()}async delete(x){return await(await this.open()).softDelete(x)}async count(x){return await(await this.open()).count(x?{where:x}:{})}}h=Y([Zx.repository(),Z(0,Yx("database")),_("design:paramtypes",[typeof ITypeormDatabase==="undefined"?Object:ITypeormDatabase])],h);export{h as VerificationRepository,R as UserViewedRepository,E as UserStatRepository,f as UserRepository,w as UserReportRepository,C as UserProfileUpdateRepository,O as UserFollowedRepository,S as UserBlockedRepository,V as SessionRepository,W as AccountRepository};
23
3
 
24
- // src/repositories/user/AccountRepository.ts
25
- import { inject } from "@ooneex/container";
26
- import { decorator } from "@ooneex/repository";
27
- import { ILike } from "typeorm";
28
- class AccountRepository {
29
- database;
30
- constructor(database) {
31
- this.database = database;
32
- }
33
- async open() {
34
- return await this.database.open(AccountEntity);
35
- }
36
- async close() {
37
- await this.database.close();
38
- }
39
- async find(criteria) {
40
- const repository = await this.open();
41
- const { page = 1, limit = 100, q, ...rest } = criteria;
42
- let skip;
43
- const take = limit === 0 ? 100 : limit;
44
- if (page && page > 0 && limit && limit > 0) {
45
- skip = (page - 1) * take;
46
- }
47
- let findOptions = { ...rest, take, ...skip !== undefined && { skip } };
48
- if (q) {
49
- const searchConditions = [
50
- { provider: ILike(`%${q}%`) },
51
- { providerAccountId: ILike(`%${q}%`) },
52
- { email: ILike(`%${q}%`) },
53
- { name: ILike(`%${q}%`) }
54
- ];
55
- findOptions = {
56
- ...findOptions,
57
- where: rest.where ? [...searchConditions.map((condition) => ({ ...rest.where, ...condition }))] : searchConditions
58
- };
59
- }
60
- const result = await repository.find(findOptions);
61
- let countWhere = rest.where;
62
- if (q) {
63
- const searchConditions = [
64
- { provider: ILike(`%${q}%`) },
65
- { providerAccountId: ILike(`%${q}%`) },
66
- { email: ILike(`%${q}%`) },
67
- { name: ILike(`%${q}%`) }
68
- ];
69
- countWhere = rest.where ? [...searchConditions.map((condition) => ({ ...rest.where, ...condition }))] : searchConditions;
70
- }
71
- const total = await this.count(countWhere);
72
- const totalPages = Math.ceil(total / limit);
73
- return {
74
- resources: result,
75
- total,
76
- totalPages,
77
- page,
78
- limit
79
- };
80
- }
81
- async findOne(id) {
82
- const repository = await this.open();
83
- return await repository.findOne({
84
- where: { id }
85
- });
86
- }
87
- async findOneBy(criteria) {
88
- const repository = await this.open();
89
- return await repository.findOne({
90
- where: criteria
91
- });
92
- }
93
- async create(entity, options) {
94
- const repository = await this.open();
95
- return await repository.save(entity, options);
96
- }
97
- async createMany(entities, options) {
98
- const repository = await this.open();
99
- return await repository.save(entities, options);
100
- }
101
- async update(entity, options) {
102
- return await this.create(entity, options);
103
- }
104
- async updateMany(entities, options) {
105
- return await this.createMany(entities, options);
106
- }
107
- async delete(criteria) {
108
- const repository = await this.open();
109
- return await repository.softDelete(criteria);
110
- }
111
- async count(criteria) {
112
- const repository = await this.open();
113
- return await repository.count(criteria ? { where: criteria } : {});
114
- }
115
- }
116
- AccountRepository = __legacyDecorateClassTS([
117
- decorator.repository(),
118
- __legacyDecorateParamTS(0, inject("database")),
119
- __legacyMetadataTS("design:paramtypes", [
120
- typeof ITypeormDatabase === "undefined" ? Object : ITypeormDatabase
121
- ])
122
- ], AccountRepository);
123
- // src/repositories/user/SessionRepository.ts
124
- import { inject as inject2 } from "@ooneex/container";
125
- import { decorator as decorator2 } from "@ooneex/repository";
126
- import { ILike as ILike2, LessThan } from "typeorm";
127
- class SessionRepository {
128
- database;
129
- constructor(database) {
130
- this.database = database;
131
- }
132
- async open() {
133
- return await this.database.open(SessionEntity);
134
- }
135
- async close() {
136
- await this.database.close();
137
- }
138
- async find(criteria) {
139
- const repository = await this.open();
140
- const { page = 1, limit = 100, q, ...rest } = criteria;
141
- let skip;
142
- const take = limit === 0 ? 100 : limit;
143
- if (page && page > 0 && limit && limit > 0) {
144
- skip = (page - 1) * take;
145
- }
146
- let findOptions = { ...rest, take, ...skip !== undefined && { skip } };
147
- if (q) {
148
- const searchConditions = [
149
- { deviceName: ILike2(`%${q}%`) },
150
- { deviceType: ILike2(`%${q}%`) },
151
- { browser: ILike2(`%${q}%`) },
152
- { operatingSystem: ILike2(`%${q}%`) },
153
- { location: ILike2(`%${q}%`) }
154
- ];
155
- findOptions = {
156
- ...findOptions,
157
- where: rest.where ? [...searchConditions.map((condition) => ({ ...rest.where, ...condition }))] : searchConditions
158
- };
159
- }
160
- const result = await repository.find(findOptions);
161
- let countWhere = rest.where;
162
- if (q) {
163
- const searchConditions = [
164
- { deviceName: ILike2(`%${q}%`) },
165
- { deviceType: ILike2(`%${q}%`) },
166
- { browser: ILike2(`%${q}%`) },
167
- { operatingSystem: ILike2(`%${q}%`) },
168
- { location: ILike2(`%${q}%`) }
169
- ];
170
- countWhere = rest.where ? [...searchConditions.map((condition) => ({ ...rest.where, ...condition }))] : searchConditions;
171
- }
172
- const total = await this.count(countWhere);
173
- const totalPages = Math.ceil(total / limit);
174
- return {
175
- resources: result,
176
- total,
177
- totalPages,
178
- page,
179
- limit
180
- };
181
- }
182
- async findOne(id) {
183
- const repository = await this.open();
184
- return await repository.findOne({
185
- where: { id }
186
- });
187
- }
188
- async findOneBy(criteria) {
189
- const repository = await this.open();
190
- return await repository.findOne({
191
- where: criteria
192
- });
193
- }
194
- async findByToken(token) {
195
- const repository = await this.open();
196
- return await repository.findOne({
197
- where: { token }
198
- });
199
- }
200
- async findByRefreshToken(refreshToken) {
201
- const repository = await this.open();
202
- return await repository.findOne({
203
- where: { refreshToken }
204
- });
205
- }
206
- async findActiveSessions(userId) {
207
- const repository = await this.open();
208
- return await repository.find({
209
- where: { user: { id: userId }, isActive: true },
210
- order: { lastAccessAt: "DESC" }
211
- });
212
- }
213
- async findExpiredSessions() {
214
- const repository = await this.open();
215
- return await repository.find({
216
- where: { expiresAt: LessThan(new Date), isActive: true }
217
- });
218
- }
219
- async create(entity, options) {
220
- const repository = await this.open();
221
- return await repository.save(entity, options);
222
- }
223
- async createMany(entities, options) {
224
- const repository = await this.open();
225
- return await repository.save(entities, options);
226
- }
227
- async update(entity, options) {
228
- return await this.create(entity, options);
229
- }
230
- async updateMany(entities, options) {
231
- return await this.createMany(entities, options);
232
- }
233
- async delete(criteria) {
234
- const repository = await this.open();
235
- return await repository.softDelete(criteria);
236
- }
237
- async revokeSession(sessionId, reason) {
238
- const repository = await this.open();
239
- const updateData = {
240
- isActive: false,
241
- revokedAt: new Date
242
- };
243
- if (reason !== undefined) {
244
- updateData.revokedReason = reason;
245
- }
246
- return await repository.update(sessionId, updateData);
247
- }
248
- async revokeAllUserSessions(userId, reason) {
249
- const repository = await this.open();
250
- const updateData = {
251
- isActive: false,
252
- revokedAt: new Date
253
- };
254
- if (reason !== undefined) {
255
- updateData.revokedReason = reason;
256
- }
257
- return await repository.update({ user: { id: userId }, isActive: true }, updateData);
258
- }
259
- async count(criteria) {
260
- const repository = await this.open();
261
- return await repository.count(criteria ? { where: criteria } : {});
262
- }
263
- }
264
- SessionRepository = __legacyDecorateClassTS([
265
- decorator2.repository(),
266
- __legacyDecorateParamTS(0, inject2("database")),
267
- __legacyMetadataTS("design:paramtypes", [
268
- typeof ITypeormDatabase === "undefined" ? Object : ITypeormDatabase
269
- ])
270
- ], SessionRepository);
271
- // src/repositories/user/UserBlockedRepository.ts
272
- import { inject as inject3 } from "@ooneex/container";
273
- import { decorator as decorator3 } from "@ooneex/repository";
274
- class UserBlockedRepository {
275
- database;
276
- constructor(database) {
277
- this.database = database;
278
- }
279
- async open() {
280
- return await this.database.open(UserBlockedEntity);
281
- }
282
- async close() {
283
- await this.database.close();
284
- }
285
- async find(criteria) {
286
- const repository = await this.open();
287
- const { page = 1, limit = 100, ...rest } = criteria;
288
- let skip;
289
- const take = limit === 0 ? 100 : limit;
290
- if (page && page > 0 && limit && limit > 0) {
291
- skip = (page - 1) * take;
292
- }
293
- const result = await repository.find({ ...rest, take, ...skip !== undefined && { skip } });
294
- const total = await this.count(rest.where);
295
- const totalPages = Math.ceil(total / limit);
296
- return {
297
- resources: result,
298
- total,
299
- totalPages,
300
- page,
301
- limit
302
- };
303
- }
304
- async findOne(id) {
305
- const repository = await this.open();
306
- return await repository.findOne({
307
- where: { id }
308
- });
309
- }
310
- async findOneBy(criteria) {
311
- const repository = await this.open();
312
- return await repository.findOne({
313
- where: criteria
314
- });
315
- }
316
- async create(entity, options) {
317
- const repository = await this.open();
318
- return await repository.save(entity, options);
319
- }
320
- async createMany(entities, options) {
321
- const repository = await this.open();
322
- return await repository.save(entities, options);
323
- }
324
- async update(entity, options) {
325
- return await this.create(entity, options);
326
- }
327
- async updateMany(entities, options) {
328
- return await this.createMany(entities, options);
329
- }
330
- async delete(criteria) {
331
- const repository = await this.open();
332
- return await repository.softDelete(criteria);
333
- }
334
- async count(criteria) {
335
- const repository = await this.open();
336
- return await repository.count(criteria ? { where: criteria } : {});
337
- }
338
- }
339
- UserBlockedRepository = __legacyDecorateClassTS([
340
- decorator3.repository(),
341
- __legacyDecorateParamTS(0, inject3("database")),
342
- __legacyMetadataTS("design:paramtypes", [
343
- typeof ITypeormDatabase === "undefined" ? Object : ITypeormDatabase
344
- ])
345
- ], UserBlockedRepository);
346
- // src/repositories/user/UserFollowedRepository.ts
347
- import { inject as inject4 } from "@ooneex/container";
348
- import { decorator as decorator4 } from "@ooneex/repository";
349
- class UserFollowedRepository {
350
- database;
351
- constructor(database) {
352
- this.database = database;
353
- }
354
- async open() {
355
- return await this.database.open(UserFollowedEntity);
356
- }
357
- async close() {
358
- await this.database.close();
359
- }
360
- async find(criteria) {
361
- const repository = await this.open();
362
- const { page = 1, limit = 100, ...rest } = criteria;
363
- let skip;
364
- const take = limit === 0 ? 100 : limit;
365
- if (page && page > 0 && limit && limit > 0) {
366
- skip = (page - 1) * take;
367
- }
368
- const result = await repository.find({ ...rest, take, ...skip !== undefined && { skip } });
369
- const total = await this.count(rest.where);
370
- const totalPages = Math.ceil(total / limit);
371
- return {
372
- resources: result,
373
- total,
374
- totalPages,
375
- page,
376
- limit
377
- };
378
- }
379
- async findOne(id) {
380
- const repository = await this.open();
381
- return await repository.findOne({
382
- where: { id }
383
- });
384
- }
385
- async findOneBy(criteria) {
386
- const repository = await this.open();
387
- return await repository.findOne({
388
- where: criteria
389
- });
390
- }
391
- async create(entity, options) {
392
- const repository = await this.open();
393
- return await repository.save(entity, options);
394
- }
395
- async createMany(entities, options) {
396
- const repository = await this.open();
397
- return await repository.save(entities, options);
398
- }
399
- async update(entity, options) {
400
- return await this.create(entity, options);
401
- }
402
- async updateMany(entities, options) {
403
- return await this.createMany(entities, options);
404
- }
405
- async delete(criteria) {
406
- const repository = await this.open();
407
- return await repository.softDelete(criteria);
408
- }
409
- async count(criteria) {
410
- const repository = await this.open();
411
- return await repository.count(criteria ? { where: criteria } : {});
412
- }
413
- }
414
- UserFollowedRepository = __legacyDecorateClassTS([
415
- decorator4.repository(),
416
- __legacyDecorateParamTS(0, inject4("database")),
417
- __legacyMetadataTS("design:paramtypes", [
418
- typeof ITypeormDatabase === "undefined" ? Object : ITypeormDatabase
419
- ])
420
- ], UserFollowedRepository);
421
- // src/repositories/user/UserProfileUpdateRepository.ts
422
- import { inject as inject5 } from "@ooneex/container";
423
- import { decorator as decorator5 } from "@ooneex/repository";
424
- import { EProfileUpdateStatus } from "@ooneex/user";
425
- import { ILike as ILike3 } from "typeorm";
426
- class UserProfileUpdateRepository {
427
- database;
428
- constructor(database) {
429
- this.database = database;
430
- }
431
- async open() {
432
- return await this.database.open(UserProfileUpdateEntity);
433
- }
434
- async close() {
435
- await this.database.close();
436
- }
437
- async find(criteria) {
438
- const repository = await this.open();
439
- const { page = 1, limit = 100, q, ...rest } = criteria;
440
- let skip;
441
- const take = limit === 0 ? 100 : limit;
442
- if (page && page > 0 && limit && limit > 0) {
443
- skip = (page - 1) * take;
444
- }
445
- let findOptions = { ...rest, take, ...skip !== undefined && { skip } };
446
- if (q) {
447
- const searchConditions = [{ updateReason: ILike3(`%${q}%`) }, { description: ILike3(`%${q}%`) }];
448
- findOptions = {
449
- ...findOptions,
450
- where: rest.where ? [...searchConditions.map((condition) => ({ ...rest.where, ...condition }))] : searchConditions
451
- };
452
- }
453
- const result = await repository.find(findOptions);
454
- let countWhere = rest.where;
455
- if (q) {
456
- const searchConditions = [{ updateReason: ILike3(`%${q}%`) }, { description: ILike3(`%${q}%`) }];
457
- countWhere = rest.where ? [...searchConditions.map((condition) => ({ ...rest.where, ...condition }))] : searchConditions;
458
- }
459
- const total = await this.count(countWhere);
460
- const totalPages = Math.ceil(total / limit);
461
- return {
462
- resources: result,
463
- total,
464
- totalPages,
465
- page,
466
- limit
467
- };
468
- }
469
- async findOne(id) {
470
- const repository = await this.open();
471
- return await repository.findOne({
472
- where: { id }
473
- });
474
- }
475
- async findOneBy(criteria) {
476
- const repository = await this.open();
477
- return await repository.findOne({
478
- where: criteria
479
- });
480
- }
481
- async create(entity, options) {
482
- const repository = await this.open();
483
- return await repository.save(entity, options);
484
- }
485
- async createMany(entities, options) {
486
- const repository = await this.open();
487
- return await repository.save(entities, options);
488
- }
489
- async update(entity, options) {
490
- return await this.create(entity, options);
491
- }
492
- async updateMany(entities, options) {
493
- return await this.createMany(entities, options);
494
- }
495
- async markAsCompleted(id) {
496
- const repository = await this.open();
497
- return await repository.update(id, {
498
- status: EProfileUpdateStatus.COMPLETED,
499
- appliedAt: new Date
500
- });
501
- }
502
- async markAsFailed(id, reason) {
503
- const repository = await this.open();
504
- const updateData = {
505
- status: EProfileUpdateStatus.FAILED
506
- };
507
- if (reason !== undefined) {
508
- updateData.description = reason;
509
- }
510
- return await repository.update(id, updateData);
511
- }
512
- async markAsReverted(id, reason) {
513
- const repository = await this.open();
514
- const updateData = {
515
- status: EProfileUpdateStatus.REVERTED
516
- };
517
- if (reason !== undefined) {
518
- updateData.description = reason;
519
- }
520
- return await repository.update(id, updateData);
521
- }
522
- async delete(criteria) {
523
- const repository = await this.open();
524
- return await repository.softDelete(criteria);
525
- }
526
- async count(criteria) {
527
- const repository = await this.open();
528
- return await repository.count(criteria ? { where: criteria } : {});
529
- }
530
- }
531
- UserProfileUpdateRepository = __legacyDecorateClassTS([
532
- decorator5.repository(),
533
- __legacyDecorateParamTS(0, inject5("database")),
534
- __legacyMetadataTS("design:paramtypes", [
535
- typeof ITypeormDatabase === "undefined" ? Object : ITypeormDatabase
536
- ])
537
- ], UserProfileUpdateRepository);
538
- // src/repositories/user/UserReportRepository.ts
539
- import { inject as inject6 } from "@ooneex/container";
540
- import { decorator as decorator6 } from "@ooneex/repository";
541
- class UserReportRepository {
542
- database;
543
- constructor(database) {
544
- this.database = database;
545
- }
546
- async open() {
547
- return await this.database.open(UserReportEntity);
548
- }
549
- async close() {
550
- await this.database.close();
551
- }
552
- async find(criteria) {
553
- const repository = await this.open();
554
- const { page = 1, limit = 100, ...rest } = criteria;
555
- let skip;
556
- const take = limit === 0 ? 100 : limit;
557
- if (page && page > 0 && limit && limit > 0) {
558
- skip = (page - 1) * take;
559
- }
560
- const result = await repository.find({ ...rest, take, ...skip !== undefined && { skip } });
561
- const total = await this.count(rest.where);
562
- const totalPages = Math.ceil(total / limit);
563
- return {
564
- resources: result,
565
- total,
566
- totalPages,
567
- page,
568
- limit
569
- };
570
- }
571
- async findOne(id) {
572
- const repository = await this.open();
573
- return await repository.findOne({
574
- where: { id }
575
- });
576
- }
577
- async findOneBy(criteria) {
578
- const repository = await this.open();
579
- return await repository.findOne({
580
- where: criteria
581
- });
582
- }
583
- async create(entity, options) {
584
- const repository = await this.open();
585
- return await repository.save(entity, options);
586
- }
587
- async createMany(entities, options) {
588
- const repository = await this.open();
589
- return await repository.save(entities, options);
590
- }
591
- async update(entity, options) {
592
- return await this.create(entity, options);
593
- }
594
- async updateMany(entities, options) {
595
- return await this.createMany(entities, options);
596
- }
597
- async delete(criteria) {
598
- const repository = await this.open();
599
- return await repository.softDelete(criteria);
600
- }
601
- async count(criteria) {
602
- const repository = await this.open();
603
- return await repository.count(criteria ? { where: criteria } : {});
604
- }
605
- }
606
- UserReportRepository = __legacyDecorateClassTS([
607
- decorator6.repository(),
608
- __legacyDecorateParamTS(0, inject6("database")),
609
- __legacyMetadataTS("design:paramtypes", [
610
- typeof ITypeormDatabase === "undefined" ? Object : ITypeormDatabase
611
- ])
612
- ], UserReportRepository);
613
- // src/repositories/user/UserRepository.ts
614
- import { inject as inject7 } from "@ooneex/container";
615
- import { decorator as decorator7 } from "@ooneex/repository";
616
- import { ILike as ILike4 } from "typeorm";
617
- class UserRepository {
618
- database;
619
- constructor(database) {
620
- this.database = database;
621
- }
622
- async open() {
623
- return await this.database.open(UserEntity);
624
- }
625
- async close() {
626
- await this.database.close();
627
- }
628
- async find(criteria) {
629
- const repository = await this.open();
630
- const { page = 1, limit = 100, q, ...rest } = criteria;
631
- let skip;
632
- const take = limit === 0 ? 100 : limit;
633
- if (page && page > 0 && limit && limit > 0) {
634
- skip = (page - 1) * take;
635
- }
636
- let findOptions = { ...rest, take, ...skip !== undefined && { skip } };
637
- if (q) {
638
- const searchConditions = [
639
- { email: ILike4(`%${q}%`) },
640
- { name: ILike4(`%${q}%`) },
641
- { firstName: ILike4(`%${q}%`) },
642
- { lastName: ILike4(`%${q}%`) },
643
- { username: ILike4(`%${q}%`) }
644
- ];
645
- findOptions = {
646
- ...findOptions,
647
- where: rest.where ? [...searchConditions.map((condition) => ({ ...rest.where, ...condition }))] : searchConditions
648
- };
649
- }
650
- const result = await repository.find(findOptions);
651
- let countWhere = rest.where;
652
- if (q) {
653
- const searchConditions = [
654
- { email: ILike4(`%${q}%`) },
655
- { name: ILike4(`%${q}%`) },
656
- { firstName: ILike4(`%${q}%`) },
657
- { lastName: ILike4(`%${q}%`) },
658
- { username: ILike4(`%${q}%`) }
659
- ];
660
- countWhere = rest.where ? [...searchConditions.map((condition) => ({ ...rest.where, ...condition }))] : searchConditions;
661
- }
662
- const total = await this.count(countWhere);
663
- const totalPages = Math.ceil(total / limit);
664
- return {
665
- resources: result,
666
- total,
667
- totalPages,
668
- page,
669
- limit
670
- };
671
- }
672
- async findOne(id) {
673
- const repository = await this.open();
674
- return await repository.findOne({
675
- where: { id }
676
- });
677
- }
678
- async findOneBy(criteria) {
679
- const repository = await this.open();
680
- return await repository.findOne({
681
- where: criteria
682
- });
683
- }
684
- async create(entity, options) {
685
- const repository = await this.open();
686
- return await repository.save(entity, options);
687
- }
688
- async createMany(entities, options) {
689
- const repository = await this.open();
690
- return await repository.save(entities, options);
691
- }
692
- async update(entity, options) {
693
- return await this.create(entity, options);
694
- }
695
- async updateMany(entities, options) {
696
- return await this.createMany(entities, options);
697
- }
698
- async delete(criteria) {
699
- const repository = await this.open();
700
- return await repository.softDelete(criteria);
701
- }
702
- async count(criteria) {
703
- const repository = await this.open();
704
- return await repository.count(criteria ? { where: criteria } : {});
705
- }
706
- }
707
- UserRepository = __legacyDecorateClassTS([
708
- decorator7.repository(),
709
- __legacyDecorateParamTS(0, inject7("database")),
710
- __legacyMetadataTS("design:paramtypes", [
711
- typeof ITypeormDatabase === "undefined" ? Object : ITypeormDatabase
712
- ])
713
- ], UserRepository);
714
- // src/repositories/user/UserStatRepository.ts
715
- import { inject as inject8 } from "@ooneex/container";
716
- import { decorator as decorator8 } from "@ooneex/repository";
717
- class UserStatRepository {
718
- database;
719
- constructor(database) {
720
- this.database = database;
721
- }
722
- async open() {
723
- return await this.database.open(UserStatEntity);
724
- }
725
- async close() {
726
- await this.database.close();
727
- }
728
- async find(criteria) {
729
- const repository = await this.open();
730
- const { page = 1, limit = 100, ...rest } = criteria;
731
- let skip;
732
- const take = limit === 0 ? 100 : limit;
733
- if (page && page > 0 && limit && limit > 0) {
734
- skip = (page - 1) * take;
735
- }
736
- const result = await repository.find({ ...rest, take, ...skip !== undefined && { skip } });
737
- const total = await this.count(rest.where);
738
- const totalPages = Math.ceil(total / limit);
739
- return {
740
- resources: result,
741
- total,
742
- totalPages,
743
- page,
744
- limit
745
- };
746
- }
747
- async findOne(id) {
748
- const repository = await this.open();
749
- return await repository.findOne({
750
- where: { id }
751
- });
752
- }
753
- async findOneBy(criteria) {
754
- const repository = await this.open();
755
- return await repository.findOne({
756
- where: criteria
757
- });
758
- }
759
- async create(entity, options) {
760
- const repository = await this.open();
761
- return await repository.save(entity, options);
762
- }
763
- async createMany(entities, options) {
764
- const repository = await this.open();
765
- return await repository.save(entities, options);
766
- }
767
- async update(entity, options) {
768
- return await this.create(entity, options);
769
- }
770
- async updateMany(entities, options) {
771
- return await this.createMany(entities, options);
772
- }
773
- async delete(criteria) {
774
- const repository = await this.open();
775
- return await repository.softDelete(criteria);
776
- }
777
- async count(criteria) {
778
- const repository = await this.open();
779
- return await repository.count(criteria ? { where: criteria } : {});
780
- }
781
- }
782
- UserStatRepository = __legacyDecorateClassTS([
783
- decorator8.repository(),
784
- __legacyDecorateParamTS(0, inject8("database")),
785
- __legacyMetadataTS("design:paramtypes", [
786
- typeof ITypeormDatabase === "undefined" ? Object : ITypeormDatabase
787
- ])
788
- ], UserStatRepository);
789
- // src/repositories/user/UserViewedRepository.ts
790
- import { inject as inject9 } from "@ooneex/container";
791
- import { decorator as decorator9 } from "@ooneex/repository";
792
- class UserViewedRepository {
793
- database;
794
- constructor(database) {
795
- this.database = database;
796
- }
797
- async open() {
798
- return await this.database.open(UserViewedEntity);
799
- }
800
- async close() {
801
- await this.database.close();
802
- }
803
- async find(criteria) {
804
- const repository = await this.open();
805
- const { page = 1, limit = 100, ...rest } = criteria;
806
- let skip;
807
- const take = limit === 0 ? 100 : limit;
808
- if (page && page > 0 && limit && limit > 0) {
809
- skip = (page - 1) * take;
810
- }
811
- const result = await repository.find({ ...rest, take, ...skip !== undefined && { skip } });
812
- const total = await this.count(rest.where);
813
- const totalPages = Math.ceil(total / limit);
814
- return {
815
- resources: result,
816
- total,
817
- totalPages,
818
- page,
819
- limit
820
- };
821
- }
822
- async findOne(id) {
823
- const repository = await this.open();
824
- return await repository.findOne({
825
- where: { id }
826
- });
827
- }
828
- async findOneBy(criteria) {
829
- const repository = await this.open();
830
- return await repository.findOne({
831
- where: criteria
832
- });
833
- }
834
- async create(entity, options) {
835
- const repository = await this.open();
836
- return await repository.save(entity, options);
837
- }
838
- async createMany(entities, options) {
839
- const repository = await this.open();
840
- return await repository.save(entities, options);
841
- }
842
- async update(entity, options) {
843
- return await this.create(entity, options);
844
- }
845
- async updateMany(entities, options) {
846
- return await this.createMany(entities, options);
847
- }
848
- async delete(criteria) {
849
- const repository = await this.open();
850
- return await repository.softDelete(criteria);
851
- }
852
- async count(criteria) {
853
- const repository = await this.open();
854
- return await repository.count(criteria ? { where: criteria } : {});
855
- }
856
- }
857
- UserViewedRepository = __legacyDecorateClassTS([
858
- decorator9.repository(),
859
- __legacyDecorateParamTS(0, inject9("database")),
860
- __legacyMetadataTS("design:paramtypes", [
861
- typeof ITypeormDatabase === "undefined" ? Object : ITypeormDatabase
862
- ])
863
- ], UserViewedRepository);
864
- // src/repositories/user/VerificationRepository.ts
865
- import { inject as inject10 } from "@ooneex/container";
866
- import { decorator as decorator10 } from "@ooneex/repository";
867
- import { ILike as ILike5, MoreThan } from "typeorm";
868
- class VerificationRepository {
869
- database;
870
- constructor(database) {
871
- this.database = database;
872
- }
873
- async open() {
874
- return await this.database.open(VerificationEntity);
875
- }
876
- async close() {
877
- await this.database.close();
878
- }
879
- async find(criteria) {
880
- const repository = await this.open();
881
- const { page = 1, limit = 100, q, ...rest } = criteria;
882
- let skip;
883
- const take = limit === 0 ? 100 : limit;
884
- if (page && page > 0 && limit && limit > 0) {
885
- skip = (page - 1) * take;
886
- }
887
- let findOptions = { ...rest, take, ...skip !== undefined && { skip } };
888
- if (q) {
889
- const searchConditions = [
890
- { email: ILike5(`%${q}%`) },
891
- { phone: ILike5(`%${q}%`) },
892
- { token: ILike5(`%${q}%`) },
893
- { code: ILike5(`%${q}%`) },
894
- { description: ILike5(`%${q}%`) }
895
- ];
896
- findOptions = {
897
- ...findOptions,
898
- where: rest.where ? [...searchConditions.map((condition) => ({ ...rest.where, ...condition }))] : searchConditions
899
- };
900
- }
901
- const result = await repository.find(findOptions);
902
- let countWhere = rest.where;
903
- if (q) {
904
- const searchConditions = [
905
- { email: ILike5(`%${q}%`) },
906
- { phone: ILike5(`%${q}%`) },
907
- { token: ILike5(`%${q}%`) },
908
- { code: ILike5(`%${q}%`) },
909
- { description: ILike5(`%${q}%`) }
910
- ];
911
- countWhere = rest.where ? [...searchConditions.map((condition) => ({ ...rest.where, ...condition }))] : searchConditions;
912
- }
913
- const total = await this.count(countWhere);
914
- const totalPages = Math.ceil(total / limit);
915
- return {
916
- resources: result,
917
- total,
918
- totalPages,
919
- page,
920
- limit
921
- };
922
- }
923
- async findOne(id) {
924
- const repository = await this.open();
925
- return await repository.findOne({
926
- where: { id }
927
- });
928
- }
929
- async findOneBy(criteria) {
930
- const repository = await this.open();
931
- return await repository.findOne({
932
- where: criteria
933
- });
934
- }
935
- async findByToken(token) {
936
- const repository = await this.open();
937
- return await repository.findOne({
938
- where: { token, isUsed: false, expiresAt: MoreThan(new Date) }
939
- });
940
- }
941
- async findByCode(code) {
942
- const repository = await this.open();
943
- return await repository.findOne({
944
- where: { code, isUsed: false, expiresAt: MoreThan(new Date) }
945
- });
946
- }
947
- async create(entity, options) {
948
- const repository = await this.open();
949
- return await repository.save(entity, options);
950
- }
951
- async createMany(entities, options) {
952
- const repository = await this.open();
953
- return await repository.save(entities, options);
954
- }
955
- async update(entity, options) {
956
- return await this.create(entity, options);
957
- }
958
- async updateMany(entities, options) {
959
- return await this.createMany(entities, options);
960
- }
961
- async markAsUsed(id) {
962
- const repository = await this.open();
963
- return await repository.update(id, {
964
- isUsed: true,
965
- usedAt: new Date
966
- });
967
- }
968
- async incrementAttempts(id) {
969
- const repository = await this.open();
970
- return await repository.createQueryBuilder().update(VerificationEntity).set({ attemptsCount: () => "attempts_count + 1" }).where("id = :id", { id }).execute();
971
- }
972
- async delete(criteria) {
973
- const repository = await this.open();
974
- return await repository.softDelete(criteria);
975
- }
976
- async count(criteria) {
977
- const repository = await this.open();
978
- return await repository.count(criteria ? { where: criteria } : {});
979
- }
980
- }
981
- VerificationRepository = __legacyDecorateClassTS([
982
- decorator10.repository(),
983
- __legacyDecorateParamTS(0, inject10("database")),
984
- __legacyMetadataTS("design:paramtypes", [
985
- typeof ITypeormDatabase === "undefined" ? Object : ITypeormDatabase
986
- ])
987
- ], VerificationRepository);
988
- export {
989
- VerificationRepository,
990
- UserViewedRepository,
991
- UserStatRepository,
992
- UserRepository,
993
- UserReportRepository,
994
- UserProfileUpdateRepository,
995
- UserFollowedRepository,
996
- UserBlockedRepository,
997
- SessionRepository,
998
- AccountRepository
999
- };
1000
-
1001
- //# debugId=D1B819A6A6304F3664756E2164756E21
4
+ //# debugId=7571045582C886C264756E2164756E21