@lilaquadrat/studio 9.15.2 → 9.15.3

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 (391) hide show
  1. package/lib/cjs/errors.d.ts +5 -0
  2. package/lib/cjs/errors.js +15 -0
  3. package/lib/cjs/errors.js.map +1 -0
  4. package/lib/cjs/helpers.d.ts +14 -0
  5. package/lib/cjs/helpers.js +36 -0
  6. package/lib/cjs/helpers.js.map +1 -0
  7. package/lib/cjs/main.d.ts +17 -0
  8. package/lib/cjs/main.js +73 -0
  9. package/lib/cjs/main.js.map +1 -0
  10. package/lib/cjs/models.d.ts +35 -0
  11. package/lib/cjs/models.js +75 -0
  12. package/lib/cjs/models.js.map +1 -0
  13. package/lib/cjs/services.d.ts +33 -0
  14. package/lib/cjs/services.js +105 -0
  15. package/lib/cjs/services.js.map +1 -0
  16. package/lib/cjs/src/AzureBlobStorage.share.d.ts +18 -0
  17. package/lib/cjs/src/AzureBlobStorage.share.js +157 -0
  18. package/lib/cjs/src/AzureBlobStorage.share.js.map +1 -0
  19. package/lib/cjs/src/AzureFileStorage.share.d.ts +21 -0
  20. package/lib/cjs/src/AzureFileStorage.share.js +144 -0
  21. package/lib/cjs/src/AzureFileStorage.share.js.map +1 -0
  22. package/lib/cjs/src/AzureVault.d.ts +14 -0
  23. package/lib/cjs/src/AzureVault.js +30 -0
  24. package/lib/cjs/src/AzureVault.js.map +1 -0
  25. package/lib/cjs/src/Filesystem.share.d.ts +15 -0
  26. package/lib/cjs/src/Filesystem.share.js +87 -0
  27. package/lib/cjs/src/Filesystem.share.js.map +1 -0
  28. package/lib/cjs/src/Immutable.class.d.ts +56 -0
  29. package/lib/cjs/src/Immutable.class.js +228 -0
  30. package/lib/cjs/src/Immutable.class.js.map +1 -0
  31. package/lib/cjs/src/Mock.share.d.ts +14 -0
  32. package/lib/cjs/src/Mock.share.js +36 -0
  33. package/lib/cjs/src/Mock.share.js.map +1 -0
  34. package/lib/cjs/src/ShareClientFactory.class.d.ts +7 -0
  35. package/lib/cjs/src/ShareClientFactory.class.js +34 -0
  36. package/lib/cjs/src/ShareClientFactory.class.js.map +1 -0
  37. package/lib/cjs/src/Timeseries.class.d.ts +11 -0
  38. package/lib/cjs/src/Timeseries.class.js +16 -0
  39. package/lib/cjs/src/Timeseries.class.js.map +1 -0
  40. package/lib/cjs/src/aggegations/childData.aggregation.d.ts +194 -0
  41. package/lib/cjs/src/aggegations/childData.aggregation.js +102 -0
  42. package/lib/cjs/src/aggegations/childData.aggregation.js.map +1 -0
  43. package/lib/cjs/src/aggegations/genericData.aggregation.d.ts +76 -0
  44. package/lib/cjs/src/aggegations/genericData.aggregation.js +79 -0
  45. package/lib/cjs/src/aggegations/genericData.aggregation.js.map +1 -0
  46. package/lib/cjs/src/aggegations/partial.aggregation.d.ts +88 -0
  47. package/lib/cjs/src/aggegations/partial.aggregation.js +68 -0
  48. package/lib/cjs/src/aggegations/partial.aggregation.js.map +1 -0
  49. package/lib/cjs/src/aggegations/publishData.aggregation.d.ts +89 -0
  50. package/lib/cjs/src/aggegations/publishData.aggregation.js +79 -0
  51. package/lib/cjs/src/aggegations/publishData.aggregation.js.map +1 -0
  52. package/lib/cjs/src/aggegations/resultData.aggregation.d.ts +151 -0
  53. package/lib/cjs/src/aggegations/resultData.aggregation.js +124 -0
  54. package/lib/cjs/src/aggegations/resultData.aggregation.js.map +1 -0
  55. package/lib/cjs/src/aggegations/structures.aggregation.d.ts +143 -0
  56. package/lib/cjs/src/aggegations/structures.aggregation.js +72 -0
  57. package/lib/cjs/src/aggegations/structures.aggregation.js.map +1 -0
  58. package/lib/cjs/src/aggegations/user.aggregation.d.ts +2 -0
  59. package/lib/cjs/src/aggegations/user.aggregation.js +38 -0
  60. package/lib/cjs/src/aggegations/user.aggregation.js.map +1 -0
  61. package/lib/cjs/src/classes/ControllerBase.class.d.ts +115 -0
  62. package/lib/cjs/src/classes/ControllerBase.class.js +274 -0
  63. package/lib/cjs/src/classes/ControllerBase.class.js.map +1 -0
  64. package/lib/cjs/src/classes/TimeseriesModel.class.d.ts +28 -0
  65. package/lib/cjs/src/classes/TimeseriesModel.class.js +72 -0
  66. package/lib/cjs/src/classes/TimeseriesModel.class.js.map +1 -0
  67. package/lib/cjs/src/classes/cache.class.d.ts +31 -0
  68. package/lib/cjs/src/classes/cache.class.js +71 -0
  69. package/lib/cjs/src/classes/cache.class.js.map +1 -0
  70. package/lib/cjs/src/classes/errors/Agreements.error.d.ts +6 -0
  71. package/lib/cjs/src/classes/errors/Agreements.error.js +12 -0
  72. package/lib/cjs/src/classes/errors/Agreements.error.js.map +1 -0
  73. package/lib/cjs/src/classes/errors/History.error.d.ts +6 -0
  74. package/lib/cjs/src/classes/errors/History.error.js +12 -0
  75. package/lib/cjs/src/classes/errors/History.error.js.map +1 -0
  76. package/lib/cjs/src/classes/errors/Immutable.error.d.ts +6 -0
  77. package/lib/cjs/src/classes/errors/Immutable.error.js +12 -0
  78. package/lib/cjs/src/classes/errors/Immutable.error.js.map +1 -0
  79. package/lib/cjs/src/classes/errors/InvalidId.error.d.ts +6 -0
  80. package/lib/cjs/src/classes/errors/InvalidId.error.js +12 -0
  81. package/lib/cjs/src/classes/errors/InvalidId.error.js.map +1 -0
  82. package/lib/cjs/src/classes/models.class.d.ts +13 -0
  83. package/lib/cjs/src/classes/models.class.js +46 -0
  84. package/lib/cjs/src/classes/models.class.js.map +1 -0
  85. package/lib/cjs/src/classes/modelv2.class.d.ts +82 -0
  86. package/lib/cjs/src/classes/modelv2.class.js +149 -0
  87. package/lib/cjs/src/classes/modelv2.class.js.map +1 -0
  88. package/lib/cjs/src/classes/mongo.class.d.ts +24 -0
  89. package/lib/cjs/src/classes/mongo.class.js +100 -0
  90. package/lib/cjs/src/classes/mongo.class.js.map +1 -0
  91. package/lib/cjs/src/dns.challenge.class.d.ts +17 -0
  92. package/lib/cjs/src/dns.challenge.class.js +47 -0
  93. package/lib/cjs/src/dns.challenge.class.js.map +1 -0
  94. package/lib/cjs/src/docker-compose.class.d.ts +14 -0
  95. package/lib/cjs/src/docker-compose.class.js +88 -0
  96. package/lib/cjs/src/docker-compose.class.js.map +1 -0
  97. package/lib/cjs/src/filterMergeModules.d.ts +3 -0
  98. package/lib/cjs/src/filterMergeModules.js +31 -0
  99. package/lib/cjs/src/filterMergeModules.js.map +1 -0
  100. package/lib/cjs/src/functions/handleError.d.ts +5 -0
  101. package/lib/cjs/src/functions/handleError.js +46 -0
  102. package/lib/cjs/src/functions/handleError.js.map +1 -0
  103. package/lib/cjs/src/functions/optionsHelper.d.ts +6 -0
  104. package/lib/cjs/src/functions/optionsHelper.js +16 -0
  105. package/lib/cjs/src/functions/optionsHelper.js.map +1 -0
  106. package/lib/cjs/src/functions/respondCode.d.ts +3 -0
  107. package/lib/cjs/src/functions/respondCode.js +5 -0
  108. package/lib/cjs/src/functions/respondCode.js.map +1 -0
  109. package/lib/cjs/src/helpers/HttpStatusCode.enum.d.ts +318 -0
  110. package/lib/cjs/src/helpers/HttpStatusCode.enum.js +324 -0
  111. package/lib/cjs/src/helpers/HttpStatusCode.enum.js.map +1 -0
  112. package/lib/cjs/src/helpers/cleanObject.d.ts +5 -0
  113. package/lib/cjs/src/helpers/cleanObject.js +9 -0
  114. package/lib/cjs/src/helpers/cleanObject.js.map +1 -0
  115. package/lib/cjs/src/helpers/companyRights.d.ts +3 -0
  116. package/lib/cjs/src/helpers/companyRights.js +18 -0
  117. package/lib/cjs/src/helpers/companyRights.js.map +1 -0
  118. package/lib/cjs/src/helpers/convertCountryISO2.d.ts +2 -0
  119. package/lib/cjs/src/helpers/convertCountryISO2.js +248 -0
  120. package/lib/cjs/src/helpers/convertCountryISO2.js.map +1 -0
  121. package/lib/cjs/src/helpers/countries.d.ts +4 -0
  122. package/lib/cjs/src/helpers/countries.js +14 -0
  123. package/lib/cjs/src/helpers/countries.js.map +1 -0
  124. package/lib/cjs/src/helpers/createError.d.ts +7 -0
  125. package/lib/cjs/src/helpers/createError.js +16 -0
  126. package/lib/cjs/src/helpers/createError.js.map +1 -0
  127. package/lib/cjs/src/helpers/createSasToken.d.ts +2 -0
  128. package/lib/cjs/src/helpers/createSasToken.js +36 -0
  129. package/lib/cjs/src/helpers/createSasToken.js.map +1 -0
  130. package/lib/cjs/src/helpers/findObjetcsWithKeys.d.ts +13 -0
  131. package/lib/cjs/src/helpers/findObjetcsWithKeys.js +34 -0
  132. package/lib/cjs/src/helpers/findObjetcsWithKeys.js.map +1 -0
  133. package/lib/cjs/src/helpers/getSecrets.d.ts +4 -0
  134. package/lib/cjs/src/helpers/getSecrets.js +20 -0
  135. package/lib/cjs/src/helpers/getSecrets.js.map +1 -0
  136. package/lib/cjs/src/helpers/hardCopy.d.ts +2 -0
  137. package/lib/cjs/src/helpers/hardCopy.js +5 -0
  138. package/lib/cjs/src/helpers/hardCopy.js.map +1 -0
  139. package/lib/cjs/src/helpers/isDeepEmpty.d.ts +1 -0
  140. package/lib/cjs/src/helpers/isDeepEmpty.js +23 -0
  141. package/lib/cjs/src/helpers/isDeepEmpty.js.map +1 -0
  142. package/lib/cjs/src/helpers/isValidObjectId.d.ts +15 -0
  143. package/lib/cjs/src/helpers/isValidObjectId.js +22 -0
  144. package/lib/cjs/src/helpers/isValidObjectId.js.map +1 -0
  145. package/lib/cjs/src/helpers/matchSortArray.d.ts +2 -0
  146. package/lib/cjs/src/helpers/matchSortArray.js +20 -0
  147. package/lib/cjs/src/helpers/matchSortArray.js.map +1 -0
  148. package/lib/cjs/src/helpers/safeObjectId.d.ts +8 -0
  149. package/lib/cjs/src/helpers/safeObjectId.js +18 -0
  150. package/lib/cjs/src/helpers/safeObjectId.js.map +1 -0
  151. package/lib/cjs/src/helpers/updateMappedId.d.ts +2 -0
  152. package/lib/cjs/src/helpers/updateMappedId.js +8 -0
  153. package/lib/cjs/src/helpers/updateMappedId.js.map +1 -0
  154. package/lib/cjs/src/http.challenge.class.d.ts +33 -0
  155. package/lib/cjs/src/http.challenge.class.js +64 -0
  156. package/lib/cjs/src/http.challenge.class.js.map +1 -0
  157. package/lib/cjs/src/logger.d.ts +2 -0
  158. package/lib/cjs/src/logger.js +45 -0
  159. package/lib/cjs/src/logger.js.map +1 -0
  160. package/lib/cjs/src/models/access.model.d.ts +4 -0
  161. package/lib/cjs/src/models/access.model.js +16 -0
  162. package/lib/cjs/src/models/access.model.js.map +1 -0
  163. package/lib/cjs/src/models/app.model.d.ts +4 -0
  164. package/lib/cjs/src/models/app.model.js +86 -0
  165. package/lib/cjs/src/models/app.model.js.map +1 -0
  166. package/lib/cjs/src/models/cache.model.d.ts +4 -0
  167. package/lib/cjs/src/models/cache.model.js +15 -0
  168. package/lib/cjs/src/models/cache.model.js.map +1 -0
  169. package/lib/cjs/src/models/cart.model.d.ts +4 -0
  170. package/lib/cjs/src/models/cart.model.js +76 -0
  171. package/lib/cjs/src/models/cart.model.js.map +1 -0
  172. package/lib/cjs/src/models/certificate-action.model.d.ts +5 -0
  173. package/lib/cjs/src/models/certificate-action.model.js +235 -0
  174. package/lib/cjs/src/models/certificate-action.model.js.map +1 -0
  175. package/lib/cjs/src/models/certificate.model.d.ts +4 -0
  176. package/lib/cjs/src/models/certificate.model.js +101 -0
  177. package/lib/cjs/src/models/certificate.model.js.map +1 -0
  178. package/lib/cjs/src/models/company.model.d.ts +4 -0
  179. package/lib/cjs/src/models/company.model.js +84 -0
  180. package/lib/cjs/src/models/company.model.js.map +1 -0
  181. package/lib/cjs/src/models/customers.model.d.ts +7 -0
  182. package/lib/cjs/src/models/customers.model.js +199 -0
  183. package/lib/cjs/src/models/customers.model.js.map +1 -0
  184. package/lib/cjs/src/models/domain.model.d.ts +4 -0
  185. package/lib/cjs/src/models/domain.model.js +90 -0
  186. package/lib/cjs/src/models/domain.model.js.map +1 -0
  187. package/lib/cjs/src/models/editor.model.d.ts +4 -0
  188. package/lib/cjs/src/models/editor.model.js +174 -0
  189. package/lib/cjs/src/models/editor.model.js.map +1 -0
  190. package/lib/cjs/src/models/editorBase.model.d.ts +4 -0
  191. package/lib/cjs/src/models/editorBase.model.js +44 -0
  192. package/lib/cjs/src/models/editorBase.model.js.map +1 -0
  193. package/lib/cjs/src/models/history.model.d.ts +4 -0
  194. package/lib/cjs/src/models/history.model.js +54 -0
  195. package/lib/cjs/src/models/history.model.js.map +1 -0
  196. package/lib/cjs/src/models/hosting.model.d.ts +4 -0
  197. package/lib/cjs/src/models/hosting.model.js +44 -0
  198. package/lib/cjs/src/models/hosting.model.js.map +1 -0
  199. package/lib/cjs/src/models/hostingCommand.model.d.ts +4 -0
  200. package/lib/cjs/src/models/hostingCommand.model.js +30 -0
  201. package/lib/cjs/src/models/hostingCommand.model.js.map +1 -0
  202. package/lib/cjs/src/models/hostingSettings.model.d.ts +4 -0
  203. package/lib/cjs/src/models/hostingSettings.model.js +29 -0
  204. package/lib/cjs/src/models/hostingSettings.model.js.map +1 -0
  205. package/lib/cjs/src/models/id.model.d.ts +12 -0
  206. package/lib/cjs/src/models/id.model.js +28 -0
  207. package/lib/cjs/src/models/id.model.js.map +1 -0
  208. package/lib/cjs/src/models/import.model.d.ts +4 -0
  209. package/lib/cjs/src/models/import.model.js +40 -0
  210. package/lib/cjs/src/models/import.model.js.map +1 -0
  211. package/lib/cjs/src/models/lists.model.d.ts +4 -0
  212. package/lib/cjs/src/models/lists.model.js +183 -0
  213. package/lib/cjs/src/models/lists.model.js.map +1 -0
  214. package/lib/cjs/src/models/listsParticipants.model.d.ts +4 -0
  215. package/lib/cjs/src/models/listsParticipants.model.js +87 -0
  216. package/lib/cjs/src/models/listsParticipants.model.js.map +1 -0
  217. package/lib/cjs/src/models/mailFrom.model.d.ts +4 -0
  218. package/lib/cjs/src/models/mailFrom.model.js +37 -0
  219. package/lib/cjs/src/models/mailFrom.model.js.map +1 -0
  220. package/lib/cjs/src/models/me.model.d.ts +4 -0
  221. package/lib/cjs/src/models/me.model.js +42 -0
  222. package/lib/cjs/src/models/me.model.js.map +1 -0
  223. package/lib/cjs/src/models/media.model.d.ts +4 -0
  224. package/lib/cjs/src/models/media.model.js +139 -0
  225. package/lib/cjs/src/models/media.model.js.map +1 -0
  226. package/lib/cjs/src/models/payment-provider.model.d.ts +4 -0
  227. package/lib/cjs/src/models/payment-provider.model.js +72 -0
  228. package/lib/cjs/src/models/payment-provider.model.js.map +1 -0
  229. package/lib/cjs/src/models/payment.model.d.ts +4 -0
  230. package/lib/cjs/src/models/payment.model.js +66 -0
  231. package/lib/cjs/src/models/payment.model.js.map +1 -0
  232. package/lib/cjs/src/models/permissions.model.d.ts +9 -0
  233. package/lib/cjs/src/models/permissions.model.js +264 -0
  234. package/lib/cjs/src/models/permissions.model.js.map +1 -0
  235. package/lib/cjs/src/models/project.model.d.ts +4 -0
  236. package/lib/cjs/src/models/project.model.js +80 -0
  237. package/lib/cjs/src/models/project.model.js.map +1 -0
  238. package/lib/cjs/src/models/publish-method.model.d.ts +4 -0
  239. package/lib/cjs/src/models/publish-method.model.js +452 -0
  240. package/lib/cjs/src/models/publish-method.model.js.map +1 -0
  241. package/lib/cjs/src/models/publish.model.d.ts +4 -0
  242. package/lib/cjs/src/models/publish.model.js +188 -0
  243. package/lib/cjs/src/models/publish.model.js.map +1 -0
  244. package/lib/cjs/src/models/secrets.model.d.ts +4 -0
  245. package/lib/cjs/src/models/secrets.model.js +42 -0
  246. package/lib/cjs/src/models/secrets.model.js.map +1 -0
  247. package/lib/cjs/src/models/settings.model.d.ts +4 -0
  248. package/lib/cjs/src/models/settings.model.js +21 -0
  249. package/lib/cjs/src/models/settings.model.js.map +1 -0
  250. package/lib/cjs/src/models/structure.model.d.ts +4 -0
  251. package/lib/cjs/src/models/structure.model.js +187 -0
  252. package/lib/cjs/src/models/structure.model.js.map +1 -0
  253. package/lib/cjs/src/models/tracker.model.d.ts +4 -0
  254. package/lib/cjs/src/models/tracker.model.js +59 -0
  255. package/lib/cjs/src/models/tracker.model.js.map +1 -0
  256. package/lib/cjs/src/models/universal.model.d.ts +4 -0
  257. package/lib/cjs/src/models/universal.model.js +9 -0
  258. package/lib/cjs/src/models/universal.model.js.map +1 -0
  259. package/lib/cjs/src/models/webhook-call.model.d.ts +4 -0
  260. package/lib/cjs/src/models/webhook-call.model.js +31 -0
  261. package/lib/cjs/src/models/webhook-call.model.js.map +1 -0
  262. package/lib/cjs/src/nginx.class.d.ts +11 -0
  263. package/lib/cjs/src/nginx.class.js +49 -0
  264. package/lib/cjs/src/nginx.class.js.map +1 -0
  265. package/lib/cjs/src/prepareContent.d.ts +7 -0
  266. package/lib/cjs/src/prepareContent.js +89 -0
  267. package/lib/cjs/src/prepareContent.js.map +1 -0
  268. package/lib/cjs/src/services/access.service.d.ts +37 -0
  269. package/lib/cjs/src/services/access.service.js +115 -0
  270. package/lib/cjs/src/services/access.service.js.map +1 -0
  271. package/lib/cjs/src/services/cart.service.d.ts +39 -0
  272. package/lib/cjs/src/services/cart.service.js +196 -0
  273. package/lib/cjs/src/services/cart.service.js.map +1 -0
  274. package/lib/cjs/src/services/certificates.service.d.ts +56 -0
  275. package/lib/cjs/src/services/certificates.service.js +177 -0
  276. package/lib/cjs/src/services/certificates.service.js.map +1 -0
  277. package/lib/cjs/src/services/certificatesAction.service.d.ts +41 -0
  278. package/lib/cjs/src/services/certificatesAction.service.js +195 -0
  279. package/lib/cjs/src/services/certificatesAction.service.js.map +1 -0
  280. package/lib/cjs/src/services/conf.service.d.ts +35 -0
  281. package/lib/cjs/src/services/conf.service.js +189 -0
  282. package/lib/cjs/src/services/conf.service.js.map +1 -0
  283. package/lib/cjs/src/services/customers.service.d.ts +74 -0
  284. package/lib/cjs/src/services/customers.service.js +397 -0
  285. package/lib/cjs/src/services/customers.service.js.map +1 -0
  286. package/lib/cjs/src/services/domains.service.d.ts +115 -0
  287. package/lib/cjs/src/services/domains.service.js +635 -0
  288. package/lib/cjs/src/services/domains.service.js.map +1 -0
  289. package/lib/cjs/src/services/editor.service.d.ts +65 -0
  290. package/lib/cjs/src/services/editor.service.js +532 -0
  291. package/lib/cjs/src/services/editor.service.js.map +1 -0
  292. package/lib/cjs/src/services/editorBase.service.d.ts +46 -0
  293. package/lib/cjs/src/services/editorBase.service.js +163 -0
  294. package/lib/cjs/src/services/editorBase.service.js.map +1 -0
  295. package/lib/cjs/src/services/handleFile.service.d.ts +9 -0
  296. package/lib/cjs/src/services/handleFile.service.js +52 -0
  297. package/lib/cjs/src/services/handleFile.service.js.map +1 -0
  298. package/lib/cjs/src/services/history.service.d.ts +37 -0
  299. package/lib/cjs/src/services/history.service.js +268 -0
  300. package/lib/cjs/src/services/history.service.js.map +1 -0
  301. package/lib/cjs/src/services/hosting.service.d.ts +38 -0
  302. package/lib/cjs/src/services/hosting.service.js +221 -0
  303. package/lib/cjs/src/services/hosting.service.js.map +1 -0
  304. package/lib/cjs/src/services/hostingAdmin.service.d.ts +11 -0
  305. package/lib/cjs/src/services/hostingAdmin.service.js +21 -0
  306. package/lib/cjs/src/services/hostingAdmin.service.js.map +1 -0
  307. package/lib/cjs/src/services/hostingCommands.service.d.ts +17 -0
  308. package/lib/cjs/src/services/hostingCommands.service.js +80 -0
  309. package/lib/cjs/src/services/hostingCommands.service.js.map +1 -0
  310. package/lib/cjs/src/services/id.service.d.ts +4 -0
  311. package/lib/cjs/src/services/id.service.js +18 -0
  312. package/lib/cjs/src/services/id.service.js.map +1 -0
  313. package/lib/cjs/src/services/import.service.d.ts +33 -0
  314. package/lib/cjs/src/services/import.service.js +99 -0
  315. package/lib/cjs/src/services/import.service.js.map +1 -0
  316. package/lib/cjs/src/services/listParticipants.service.d.ts +242 -0
  317. package/lib/cjs/src/services/listParticipants.service.js +905 -0
  318. package/lib/cjs/src/services/listParticipants.service.js.map +1 -0
  319. package/lib/cjs/src/services/lists.service.d.ts +40 -0
  320. package/lib/cjs/src/services/lists.service.js +626 -0
  321. package/lib/cjs/src/services/lists.service.js.map +1 -0
  322. package/lib/cjs/src/services/mailFrom.service.d.ts +10 -0
  323. package/lib/cjs/src/services/mailFrom.service.js +53 -0
  324. package/lib/cjs/src/services/mailFrom.service.js.map +1 -0
  325. package/lib/cjs/src/services/me.service.d.ts +68 -0
  326. package/lib/cjs/src/services/me.service.js +350 -0
  327. package/lib/cjs/src/services/me.service.js.map +1 -0
  328. package/lib/cjs/src/services/media.service.d.ts +34 -0
  329. package/lib/cjs/src/services/media.service.js +422 -0
  330. package/lib/cjs/src/services/media.service.js.map +1 -0
  331. package/lib/cjs/src/services/paymentProviders.service.d.ts +13 -0
  332. package/lib/cjs/src/services/paymentProviders.service.js +33 -0
  333. package/lib/cjs/src/services/paymentProviders.service.js.map +1 -0
  334. package/lib/cjs/src/services/payments.service.d.ts +70 -0
  335. package/lib/cjs/src/services/payments.service.js +151 -0
  336. package/lib/cjs/src/services/payments.service.js.map +1 -0
  337. package/lib/cjs/src/services/permissions.service.d.ts +35 -0
  338. package/lib/cjs/src/services/permissions.service.js +739 -0
  339. package/lib/cjs/src/services/permissions.service.js.map +1 -0
  340. package/lib/cjs/src/services/publish.service.d.ts +40 -0
  341. package/lib/cjs/src/services/publish.service.js +366 -0
  342. package/lib/cjs/src/services/publish.service.js.map +1 -0
  343. package/lib/cjs/src/services/publishData.service.d.ts +18 -0
  344. package/lib/cjs/src/services/publishData.service.js +120 -0
  345. package/lib/cjs/src/services/publishData.service.js.map +1 -0
  346. package/lib/cjs/src/services/publishMethod.service.d.ts +16 -0
  347. package/lib/cjs/src/services/publishMethod.service.js +64 -0
  348. package/lib/cjs/src/services/publishMethod.service.js.map +1 -0
  349. package/lib/cjs/src/services/secret.service.d.ts +17 -0
  350. package/lib/cjs/src/services/secret.service.js +50 -0
  351. package/lib/cjs/src/services/secret.service.js.map +1 -0
  352. package/lib/cjs/src/services/spamAnalasys.service.d.ts +15 -0
  353. package/lib/cjs/src/services/spamAnalasys.service.js +100 -0
  354. package/lib/cjs/src/services/spamAnalasys.service.js.map +1 -0
  355. package/lib/cjs/src/services/structures.service.d.ts +40 -0
  356. package/lib/cjs/src/services/structures.service.js +267 -0
  357. package/lib/cjs/src/services/structures.service.js.map +1 -0
  358. package/lib/cjs/src/services/universal.service.d.ts +17 -0
  359. package/lib/cjs/src/services/universal.service.js +145 -0
  360. package/lib/cjs/src/services/universal.service.js.map +1 -0
  361. package/lib/cjs/src/services/webhooks-calls.service.d.ts +13 -0
  362. package/lib/cjs/src/services/webhooks-calls.service.js +59 -0
  363. package/lib/cjs/src/services/webhooks-calls.service.js.map +1 -0
  364. package/lib/cjs/tests/editorService.spec.d.ts +1 -0
  365. package/lib/cjs/tests/editorService.spec.js +49 -0
  366. package/lib/cjs/tests/editorService.spec.js.map +1 -0
  367. package/lib/cjs/tests/getUnsetObject.spec.d.ts +1 -0
  368. package/lib/cjs/tests/getUnsetObject.spec.js +68 -0
  369. package/lib/cjs/tests/getUnsetObject.spec.js.map +1 -0
  370. package/lib/esm/frontend.d.ts +7 -0
  371. package/lib/esm/frontend.js +8 -0
  372. package/lib/esm/frontend.js.map +1 -0
  373. package/lib/esm/src/filterMergeModules.d.ts +3 -0
  374. package/lib/esm/src/filterMergeModules.js +29 -0
  375. package/lib/esm/src/filterMergeModules.js.map +1 -0
  376. package/lib/esm/src/helpers/convertCountryISO2.d.ts +2 -0
  377. package/lib/esm/src/helpers/convertCountryISO2.js +246 -0
  378. package/lib/esm/src/helpers/convertCountryISO2.js.map +1 -0
  379. package/lib/esm/src/helpers/findObjetcsWithKeys.d.ts +13 -0
  380. package/lib/esm/src/helpers/findObjetcsWithKeys.js +31 -0
  381. package/lib/esm/src/helpers/findObjetcsWithKeys.js.map +1 -0
  382. package/lib/esm/src/helpers/hardCopy.d.ts +2 -0
  383. package/lib/esm/src/helpers/hardCopy.js +3 -0
  384. package/lib/esm/src/helpers/hardCopy.js.map +1 -0
  385. package/lib/esm/src/helpers/isDeepEmpty.d.ts +1 -0
  386. package/lib/esm/src/helpers/isDeepEmpty.js +20 -0
  387. package/lib/esm/src/helpers/isDeepEmpty.js.map +1 -0
  388. package/lib/esm/src/prepareContent.d.ts +7 -0
  389. package/lib/esm/src/prepareContent.js +83 -0
  390. package/lib/esm/src/prepareContent.js.map +1 -0
  391. package/package.json +5 -4
@@ -0,0 +1,905 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ListParticipantsService = void 0;
7
+ const mongodb_1 = require("mongodb");
8
+ const Immutable_class_1 = __importDefault(require("../Immutable.class"));
9
+ const listsParticipants_model_1 = __importDefault(require("../models/listsParticipants.model"));
10
+ const services_1 = require("../../services");
11
+ const customers_service_1 = __importDefault(require("./customers.service"));
12
+ const hardCopy_1 = __importDefault(require("../helpers/hardCopy"));
13
+ const Agreements_error_1 = __importDefault(require("../classes/errors/Agreements.error"));
14
+ const storage_queue_1 = require("@azure/storage-queue");
15
+ const publish_service_1 = __importDefault(require("./publish.service"));
16
+ const safeObjectId_1 = __importDefault(require("../helpers/safeObjectId"));
17
+ const cleanObject_1 = __importDefault(require("../helpers/cleanObject"));
18
+ const identity_1 = require("@azure/identity");
19
+ const structures_service_1 = __importDefault(require("./structures.service"));
20
+ const customers_model_1 = __importDefault(require("../models/customers.model"));
21
+ const Immutable_error_1 = __importDefault(require("../classes/errors/Immutable.error"));
22
+ const structures_aggregation_1 = require("../aggegations/structures.aggregation");
23
+ class ListParticipantsService extends Immutable_class_1.default {
24
+ constructor(connectionString, accountName, queue) {
25
+ super();
26
+ this.model = listsParticipants_model_1.default;
27
+ this.customerLookup = [
28
+ {
29
+ $lookup: {
30
+ from: 'customers',
31
+ as: 'userData',
32
+ let: { userid: '$user' },
33
+ pipeline: [
34
+ {
35
+ $match: {
36
+ $and: [
37
+ { $expr: { $eq: ['$_id', '$$userid'] } },
38
+ ],
39
+ },
40
+ },
41
+ ],
42
+ },
43
+ },
44
+ {
45
+ $unwind: {
46
+ path: '$userData',
47
+ preserveNullAndEmptyArrays: true,
48
+ },
49
+ },
50
+ {
51
+ $addFields: {
52
+ 'user': {
53
+ name: { $concat: ['$userData.name', ', ', '$userData.prename'] },
54
+ email: '$userData.email',
55
+ id: '$userData.id',
56
+ _id: '$userData._id',
57
+ },
58
+ },
59
+ },
60
+ {
61
+ $project: {
62
+ 'userData': 0,
63
+ },
64
+ },
65
+ ];
66
+ this.paymentLookup = [
67
+ {
68
+ $lookup: {
69
+ from: 'payments',
70
+ as: 'paymentData',
71
+ let: { paymentid: '$payment' },
72
+ pipeline: [
73
+ {
74
+ $match: {
75
+ $and: [
76
+ { $expr: { $eq: ['$_id', '$$paymentid'] } },
77
+ ],
78
+ },
79
+ },
80
+ ],
81
+ },
82
+ },
83
+ {
84
+ $unwind: {
85
+ path: '$paymentData',
86
+ preserveNullAndEmptyArrays: true,
87
+ },
88
+ },
89
+ {
90
+ $addFields: {
91
+ 'payment': {
92
+ _id: '$paymentData._id',
93
+ amount: '$paymentData.amount',
94
+ currency: '$paymentData.currency',
95
+ provider: '$paymentData.provider',
96
+ items: '$paymentData.items',
97
+ state: '$paymentData.state',
98
+ },
99
+ },
100
+ },
101
+ {
102
+ $project: {
103
+ 'paymentData': 0,
104
+ },
105
+ },
106
+ ];
107
+ this.paymentLookupList = [
108
+ {
109
+ $lookup: {
110
+ from: 'payments',
111
+ as: 'paymentData',
112
+ let: { paymentid: '$payment' },
113
+ pipeline: [
114
+ {
115
+ $match: {
116
+ $and: [
117
+ { $expr: { $eq: ['$_id', '$$paymentid'] } },
118
+ ],
119
+ },
120
+ },
121
+ ],
122
+ },
123
+ },
124
+ {
125
+ $unwind: {
126
+ path: '$paymentData',
127
+ preserveNullAndEmptyArrays: true,
128
+ },
129
+ },
130
+ {
131
+ $addFields: {
132
+ 'payment': {
133
+ amount: '$paymentData.amount',
134
+ },
135
+ },
136
+ },
137
+ {
138
+ $project: {
139
+ 'paymentData': 0,
140
+ },
141
+ },
142
+ ];
143
+ if (accountName) {
144
+ this.service = new storage_queue_1.QueueServiceClient(`https://${accountName}.queue.core.windows.net`, new identity_1.DefaultAzureCredential());
145
+ }
146
+ else if (connectionString && queue) {
147
+ this.service = storage_queue_1.QueueServiceClient.fromConnectionString(connectionString);
148
+ this.queue = queue;
149
+ }
150
+ if (this.service) {
151
+ this.client = this.service.getQueueClient(queue);
152
+ }
153
+ }
154
+ getCustomerLookup(search) {
155
+ const lookup = (0, hardCopy_1.default)(this.customerLookup);
156
+ if (search) {
157
+ lookup[0].$lookup?.pipeline[0].$match.$and.push({
158
+ $expr: {
159
+ $regexMatch: {
160
+ input: '$name',
161
+ regex: search,
162
+ options: 'i',
163
+ },
164
+ },
165
+ });
166
+ lookup[1].$unwind.preserveNullAndEmptyArrays = false;
167
+ }
168
+ return lookup;
169
+ }
170
+ single(list, internalId, options) {
171
+ let aggregation = [
172
+ {
173
+ $match: {
174
+ $and: [
175
+ { $expr: { $eq: ['$company', options.company] } },
176
+ { $expr: { $eq: ['$project', options.project] } },
177
+ { $expr: { $eq: ['$list', list] } },
178
+ { $expr: { $eq: ['$_id', internalId] } },
179
+ ],
180
+ },
181
+ },
182
+ ...this.customerLookup,
183
+ ...this.paymentLookup,
184
+ ...structures_aggregation_1.projectStructuresAggregation,
185
+ ];
186
+ return this.model.db.aggregate(aggregation).toArray()
187
+ .then((data) => data[0] || undefined);
188
+ }
189
+ /**
190
+ * get state of the provided account for this list
191
+ */
192
+ async stateForAccount(list, account, options) {
193
+ const customer = await customers_service_1.default.getCustomerByAccount(account, options.app);
194
+ if (!customer)
195
+ throw new Error('CUSTOMER_NOT_FOUND');
196
+ let aggregation = [
197
+ {
198
+ $match: {
199
+ $and: [
200
+ { $expr: { $eq: ['$company', options.company] } },
201
+ { $expr: { $eq: ['$project', options.project] } },
202
+ { $expr: { $eq: ['$list', list] } },
203
+ { $expr: { $eq: ['$user', customer._id] } },
204
+ ],
205
+ },
206
+ },
207
+ ];
208
+ return this.model.db.aggregate(aggregation).toArray()
209
+ .then((data) => data[0] || undefined);
210
+ }
211
+ async updateAfterCheck(useful, explanation, partiticpantInternalId, listInternalId, options) {
212
+ const list = await services_1.ListsService.single(listInternalId, undefined, options);
213
+ if (!list)
214
+ throw new Error('LIST_NOT_FOUND');
215
+ let entryState = 'notuseful';
216
+ if (useful) {
217
+ if (list.mode === 'contact')
218
+ entryState = 'enlisted';
219
+ if (list.mode === 'content')
220
+ entryState = 'enlisted';
221
+ if (list.mode === 'reservation')
222
+ entryState = 'reserved';
223
+ }
224
+ return this.immutable({ _id: partiticpantInternalId }, { state: entryState, explanation }, options.user, 'change', options.app, undefined, undefined, 'updateAfterCheck');
225
+ }
226
+ getValidatorForStructures(contactCategories, structures, model, schemaHint) {
227
+ const required = [];
228
+ const compatibleModels = {
229
+ listsParticipants: listsParticipants_model_1.default,
230
+ customers: customers_model_1.default,
231
+ };
232
+ contactCategories.forEach((single) => {
233
+ single.required?.forEach((singleRequired) => {
234
+ const singleStructure = structures.find((structure) => structure._id?.toString() === singleRequired);
235
+ if (singleStructure)
236
+ required.push(singleStructure.id);
237
+ });
238
+ });
239
+ const useModel = compatibleModels[model];
240
+ if (!useModel)
241
+ throw new Error('MODEL_FOR_VALIDATOR_NOT_FOUND');
242
+ /**
243
+ * get the base schema and create a validator
244
+ */
245
+ const baseSchema = useModel.getSchema(schemaHint);
246
+ if (!baseSchema)
247
+ throw new Error('SCHEMA_NOT_FOUND');
248
+ return structures_service_1.default.createValidator([], required, structures, (0, hardCopy_1.default)(baseSchema.schema));
249
+ }
250
+ createParticipantsObject(list, mode, user, state, message, category, payment, structureInput, agreements, options) {
251
+ let participant = {
252
+ list,
253
+ user,
254
+ message,
255
+ category,
256
+ agreements,
257
+ state,
258
+ payment,
259
+ company: options.company,
260
+ project: options.project,
261
+ };
262
+ if (structureInput) {
263
+ participant = { ...participant, ...structureInput };
264
+ }
265
+ (0, cleanObject_1.default)(participant);
266
+ return participant;
267
+ }
268
+ /**
269
+ * join a list from customer perspective
270
+ */
271
+ async join(listInternalId, person, message, category, agreements, structureInput, options) {
272
+ let customerModelAction = 'createPersonExternal';
273
+ const list = await services_1.ListsService.single(listInternalId, undefined, options);
274
+ const modelHints = { listsParticipants: '', customers: 'createPersonExternal' };
275
+ const optionsWithValidatorCustomers = { ...options };
276
+ const optionsWithValidatorListsParticipants = { ...options };
277
+ /**
278
+ * Separate structures by type for easier access
279
+ */
280
+ let structuresByModel = {};
281
+ let structuresInputByModel = {};
282
+ const validatorByModel = {};
283
+ if (!list)
284
+ throw new Error('LIST_NOT_FOUND');
285
+ if (!list.participants?.available)
286
+ throw new Error('LIST_NO_SPOT_AVAILABLE');
287
+ if (!person?.email)
288
+ throw new Error('EMAIL_INVALID');
289
+ const checkEmail = await services_1.SpamAnalasysService.checkEmailDns(person.email);
290
+ if (!checkEmail)
291
+ throw new Error('EMAIL_INVALID');
292
+ let entryState = 'unchecked';
293
+ // if (list.mode === 'contact') entryState = 'enlisted';
294
+ if (list.mode === 'content')
295
+ entryState = 'enlisted';
296
+ if (list.mode === 'reservation')
297
+ entryState = 'reserved';
298
+ modelHints.listsParticipants = `${list.mode}-create`;
299
+ // if the address is required use the matching action in the model for validation
300
+ if (list.participants?.addressRequired) {
301
+ customerModelAction = 'createPersonExternalWithAddress';
302
+ }
303
+ const agreementsMissing = this.agreementsMissing(list.agreements, agreements);
304
+ if (agreementsMissing.length) {
305
+ throw new Agreements_error_1.default('accepted', [
306
+ {
307
+ keyword: 'accepted',
308
+ instancePath: 'agreements',
309
+ schemaPath: '#/accepted',
310
+ params: { missingProperty: 'agreements', missing: agreementsMissing },
311
+ },
312
+ ], { required: agreementsMissing });
313
+ }
314
+ /**
315
+ * existing parent id indicates that we need to check if we have a contact module with structures in it
316
+ */
317
+ if (options.parentId) {
318
+ /**
319
+ * get the editor and find used the contact module
320
+ */
321
+ const editor = await services_1.EditorService.getById(options.parentId, options);
322
+ const contactModule = editor.modules.find((single) => single.uuid === options.uuid && single.type === 'contact-module');
323
+ if (editor.genericData?.structures && contactModule) {
324
+ /**
325
+ * get all used structures for the contact module
326
+ */
327
+ const structures = await structures_service_1.default.byMultipleInternalIds(editor.genericData?.structures, options);
328
+ const contactCategories = contactModule.categories;
329
+ const groupedStructures = structures_service_1.default.groupStructuresByModel(structures, structureInput);
330
+ structuresByModel = groupedStructures.structuresByModel;
331
+ structuresInputByModel = groupedStructures.structuresInputByModel;
332
+ /**
333
+ * create a validator each model
334
+ */
335
+ Object.keys(structuresByModel).forEach((model) => {
336
+ validatorByModel[model] = this.getValidatorForStructures(contactCategories, structuresByModel[model], model, modelHints[model]);
337
+ });
338
+ if (validatorByModel.customers)
339
+ optionsWithValidatorCustomers.validator = validatorByModel.customers;
340
+ if (validatorByModel.listsParticipants)
341
+ optionsWithValidatorListsParticipants.validator = validatorByModel.listsParticipants;
342
+ }
343
+ }
344
+ else {
345
+ throw new Error('PARENT_NOT_FOUND');
346
+ }
347
+ /**
348
+ * user id is only for validation and needs to be replaced with the real customer id
349
+ */
350
+ const participantsObject = this.createParticipantsObject(listInternalId, list.mode, new mongodb_1.ObjectId(), entryState, message, category, undefined, structuresInputByModel.listsParticipants, agreements, optionsWithValidatorListsParticipants);
351
+ /**
352
+ * TODO: double validation needs to be removed
353
+ * we currently validate the data two times
354
+ * with this pre validation of the listsParticipants we dont create a customer if the list validation fails
355
+ */
356
+ if (validatorByModel.listsParticipants) {
357
+ if (!validatorByModel.listsParticipants(participantsObject)) {
358
+ throw new Immutable_error_1.default('VALIDATION_FAILED', validatorByModel.listsParticipants.errors);
359
+ }
360
+ }
361
+ /**
362
+ * if the customer exists we don't update the data.
363
+ * because in general everybody with the knowledge of the email could overwrite the data for the customer
364
+ * updating the customer data will be only possible via members and from the admins
365
+ */
366
+ const customerResponse = await customers_service_1.default.getOrCreateByEmail({ ...person, ...structuresInputByModel.customers }, customerModelAction, optionsWithValidatorCustomers);
367
+ if (!customerResponse?.customer)
368
+ throw new Error('CUSTOMER_NOT_FOUND');
369
+ /**
370
+ * update the user id with the real customer id
371
+ */
372
+ participantsObject.user = customerResponse.customer._id;
373
+ const participantInList = await this.singleWithoutLookup(listInternalId, customerResponse.customer._id, options);
374
+ if (list.participants?.unique && participantInList) {
375
+ throw new Error('LIST_UNIQUE_CUSTOMER_CONFIRMED');
376
+ }
377
+ if (participantInList?.state === 'blocked') {
378
+ throw new Error('LIST_CANNOT_JOIN');
379
+ }
380
+ const addResponse = await this.addParticipantViaObject(participantsObject, list.mode, optionsWithValidatorListsParticipants);
381
+ await this.sendStateAndAudienceAwareEmail(list._id, customerResponse.customer._id, entryState, 'public', { ...options, disableEmailConfirmedCheck: true });
382
+ /**
383
+ * only add to the queue and initiate the spam check when the entry state is unchecked
384
+ */
385
+ if (entryState === 'unchecked') {
386
+ await this.client.sendMessage(Buffer.from(JSON.stringify({ _id: addResponse._id, listId: list._id })).toString('base64'));
387
+ }
388
+ return customerResponse.customer;
389
+ }
390
+ async joinManually(listInternalId, customerId, category, state, note, options) {
391
+ const list = await services_1.ListsService.single(listInternalId, undefined, options);
392
+ if (!list)
393
+ throw new Error('LIST_NOT_FOUND');
394
+ const customer = await customers_service_1.default.customerExists(customerId);
395
+ if (!customer)
396
+ throw new Error('CUSTOMER_NOT_FOUND');
397
+ const listCategory = list.categories?.find((single) => single.id === category);
398
+ if (!listCategory)
399
+ throw new Error('LIST_CATEGORY_NOT_FOUND');
400
+ let participant = {
401
+ list: listInternalId,
402
+ user: customerId,
403
+ category,
404
+ note,
405
+ agreements: [],
406
+ state,
407
+ company: options.company,
408
+ project: options.project,
409
+ };
410
+ (0, cleanObject_1.default)(participant);
411
+ return this.create(participant, options.user, options.app, undefined, undefined, 'create-manually');
412
+ }
413
+ /**
414
+ * join a list through payment
415
+ */
416
+ async joinViaPayment(listInternalId, customerId, message, category, payment, agreements, options) {
417
+ const list = await services_1.ListsService.single(listInternalId, undefined, options);
418
+ if (!list)
419
+ throw new Error('LIST_NOT_FOUND');
420
+ let entryState = 'paid';
421
+ const participantInList = await this.singleWithoutLookup(listInternalId, customerId, options);
422
+ if (list.participants?.unique && participantInList) {
423
+ throw new Error('LIST_UNIQUE_CUSTOMER_CONFIRMED');
424
+ }
425
+ if (participantInList?.state === 'blocked') {
426
+ throw new Error('LIST_CANNOT_JOIN');
427
+ }
428
+ await this.addParticipant(listInternalId, list.mode, customerId, entryState, message, category, payment, undefined, agreements, options);
429
+ await this.sendStateAndAudienceAwareEmail(list._id, customerId, entryState, 'public', { ...options, disableEmailConfirmedCheck: true });
430
+ return customerId;
431
+ }
432
+ /**
433
+ * join a list from members perspective
434
+ */
435
+ async membersJoin(listInternalId, account, message, category, agreements, structureInput, options) {
436
+ const modelHints = { listsParticipants: '', customers: 'changePersonMinimal' };
437
+ const optionsWithValidatorCustomers = { ...options };
438
+ const optionsWithValidatorListsParticipants = { ...options };
439
+ /**
440
+ * Separate structures by type for easier access
441
+ */
442
+ let structuresByModel = {};
443
+ let structuresInputByModel = {};
444
+ const validatorByModel = {};
445
+ const list = await services_1.ListsService.single(listInternalId, undefined, options);
446
+ if (!list)
447
+ throw new Error('LIST_NOT_FOUND');
448
+ if (!list.participants?.available)
449
+ throw new Error('LIST_NO_SPOT_AVAILABLE');
450
+ let entryState = 'unchecked';
451
+ // if (list.mode === 'contact') entryState = 'enlisted';
452
+ if (list.mode === 'content')
453
+ entryState = 'enlisted';
454
+ if (list.mode === 'reservation')
455
+ entryState = 'reserved';
456
+ modelHints.listsParticipants = `${list.mode}-create`;
457
+ const agreementsMissing = this.agreementsMissing(list.agreements, agreements);
458
+ if (agreementsMissing.length) {
459
+ throw new Agreements_error_1.default('accepted', [
460
+ {
461
+ keyword: 'accepted',
462
+ instancePath: 'agreements',
463
+ schemaPath: '#/accepted',
464
+ params: { missingProperty: 'agreements', missing: agreementsMissing },
465
+ },
466
+ ], { required: agreementsMissing });
467
+ }
468
+ /**
469
+ * existing parent id indicates that we need to check if we have a contact module with structures in it
470
+ */
471
+ if (options.parentId) {
472
+ /**
473
+ * get the editor and find used the contact module
474
+ */
475
+ const editor = await services_1.EditorService.getById(options.parentId, options);
476
+ const contactModule = editor.modules.find((single) => single.uuid === options.uuid);
477
+ if (editor.genericData?.structures && contactModule) {
478
+ /**
479
+ * get all used structures for the contact module
480
+ */
481
+ const structures = await structures_service_1.default.byMultipleInternalIds(editor.genericData?.structures, options);
482
+ const contactCategories = contactModule.categories;
483
+ const groupedStructures = structures_service_1.default.groupStructuresByModel(structures, structureInput);
484
+ structuresByModel = groupedStructures.structuresByModel;
485
+ structuresInputByModel = groupedStructures.structuresInputByModel;
486
+ /**
487
+ * create a validator each model
488
+ */
489
+ Object.keys(structuresByModel).forEach((model) => {
490
+ validatorByModel[model] = this.getValidatorForStructures(contactCategories, structuresByModel[model], model, modelHints[model]);
491
+ });
492
+ if (validatorByModel.customers)
493
+ optionsWithValidatorCustomers.validator = validatorByModel.customers;
494
+ if (validatorByModel.listsParticipants)
495
+ optionsWithValidatorListsParticipants.validator = validatorByModel.listsParticipants;
496
+ }
497
+ }
498
+ else {
499
+ throw new Error('PARENT_NOT_FOUND');
500
+ }
501
+ /**
502
+ * user id is only for validation and needs to be replaced with the real customer id
503
+ */
504
+ const participantsObject = this.createParticipantsObject(listInternalId, list.mode, new mongodb_1.ObjectId(), entryState, message, category, undefined, structuresInputByModel.listsParticipants, agreements, optionsWithValidatorListsParticipants);
505
+ /**
506
+ * TODO: double validation needs to be removed
507
+ * we currently validate the data two times
508
+ * with this pre validation of the listsParticipants we dont create a customer if the list validation fails
509
+ */
510
+ if (validatorByModel.listsParticipants) {
511
+ if (!validatorByModel.listsParticipants(participantsObject)) {
512
+ throw new Immutable_error_1.default('VALIDATION_FAILED', validatorByModel.listsParticipants.errors);
513
+ }
514
+ }
515
+ const customer = await customers_service_1.default.getCustomerByAccount(account, options.app, { history: 0, accounts: 0 });
516
+ if (!customer)
517
+ throw new Error('CUSTOMER_NOT_FOUND');
518
+ const customerId = customer._id;
519
+ participantsObject.user = customerId;
520
+ delete customer._id;
521
+ if (structuresInputByModel.customers) {
522
+ await customers_service_1.default.immutable({ _id: customerId }, { ...customer, ...structuresInputByModel.customers }, options.user, 'change', options.app, undefined, undefined, 'changePersonMinimal', { validator: optionsWithValidatorCustomers.validator });
523
+ }
524
+ const participantInList = await this.singleWithoutLookup(listInternalId, customerId, options);
525
+ if (list.participants?.unique && participantInList) {
526
+ throw new Error('LIST_UNIQUE_CUSTOMER_CONFIRMED');
527
+ }
528
+ if (participantInList?.state === 'blocked') {
529
+ throw new Error('LIST_CANNOT_JOIN');
530
+ }
531
+ const addResponse = await this.addParticipantViaObject(participantsObject, list.mode, optionsWithValidatorListsParticipants);
532
+ // const addResponse = await this.addParticipant(listInternalId, list.mode, customer._id, entryState, message, category, undefined, undefined, agreements, options);
533
+ /**
534
+ * only add to the queue and initiate the spam check when the entrystate is unchecked
535
+ */
536
+ if (entryState === 'unchecked') {
537
+ await this.client.sendMessage(Buffer.from(JSON.stringify({ _id: addResponse._id, listId: list._id })).toString('base64'));
538
+ }
539
+ await this.sendStateAndAudienceAwareEmail(list._id, customerId, entryState, 'members', options);
540
+ return customerId;
541
+ }
542
+ /**
543
+ * Sends an email based on participant state and audience criteria.
544
+ * if the options for disableEmailConfirmedCheck is set to true, the email will be sent regardless of the email confirmation status.
545
+ */
546
+ async sendStateAndAudienceAwareEmail(listId, customerId, state, audience, options) {
547
+ const list = await services_1.ListsService.single(listId, undefined, options);
548
+ if (!list)
549
+ return;
550
+ const email = list.emails?.find((single) => single.affectedState === state && single.audience === audience);
551
+ if (!email)
552
+ return;
553
+ if (!options.disableEmailConfirmedCheck) {
554
+ const customer = await customers_service_1.default.single(customerId, options);
555
+ if (!customer)
556
+ return;
557
+ if (!customer.emailConfirmed) {
558
+ console.debug('EMAIL_NOT_CONFIRMED');
559
+ return;
560
+ }
561
+ }
562
+ return publish_service_1.default.email((0, safeObjectId_1.default)(email.contentId), customerId, undefined, options);
563
+ }
564
+ async remove(list, participationId, options) {
565
+ return this.delete(participationId, options.user, options.app);
566
+ }
567
+ /**
568
+ * Updates the state of a participant in a list
569
+ */
570
+ async state(list, participationId, state, options) {
571
+ await this.immutable({ _id: participationId, list, company: options.company, project: options.project }, { state }, options.user, 'change', options.app, undefined, undefined, 'updateState');
572
+ const participant = await this.model.db.findOne({ _id: participationId, company: options.company, project: options.project });
573
+ if (!participant)
574
+ return;
575
+ const customer = await customers_service_1.default.single(participant.user, options);
576
+ if (customer?.type === 'person') {
577
+ // Determine the audience type based on whether the customer has accounts
578
+ // 'members' for customers with accounts, 'public' for those without
579
+ const audience = customer.accounts && customer.accounts[0] ? 'members' : 'public';
580
+ // Send an email notification based on the new state and audience type
581
+ await this.sendStateAndAudienceAwareEmail(list, customer._id, state, audience, options);
582
+ }
583
+ }
584
+ async note(list, participationId, note, options) {
585
+ return this.immutable({ _id: participationId, list, company: options.company, project: options.project }, note ? { note } : {}, options.user, 'change', options.app, undefined, undefined, 'updateNote');
586
+ }
587
+ async participantInList(list, user, options) {
588
+ return await this.model.db.countDocuments({ list, user, company: options.company, project: options.project }) > 0;
589
+ }
590
+ singleWithoutLookup(list, user, options) {
591
+ return this.model.db.findOne({ list, user, company: options.company, project: options.project });
592
+ }
593
+ viaPayment(listId, paymentId, options) {
594
+ let aggregation = [
595
+ {
596
+ $match: {
597
+ $and: [
598
+ { $expr: { $eq: ['$company', options.company] } },
599
+ { $expr: { $eq: ['$project', options.project] } },
600
+ { $expr: { $eq: ['$list', listId] } },
601
+ { $expr: { $eq: ['$payment', paymentId] } },
602
+ ],
603
+ },
604
+ },
605
+ ...this.customerLookup,
606
+ ...this.paymentLookup,
607
+ ...structures_aggregation_1.projectStructuresAggregation,
608
+ ];
609
+ return this.model.db.aggregate(aggregation).toArray()
610
+ .then((data) => data[0] || undefined);
611
+ }
612
+ byInternalId(internalId, customerLookup) {
613
+ if (!customerLookup) {
614
+ return this.model.db.findOne({ _id: internalId });
615
+ }
616
+ let aggregation = [
617
+ {
618
+ $match: {
619
+ $and: [
620
+ { $expr: { $eq: ['$_id', internalId] } },
621
+ ],
622
+ },
623
+ },
624
+ {
625
+ $lookup: {
626
+ from: 'customers',
627
+ as: 'userData',
628
+ let: { userid: '$user' },
629
+ pipeline: [
630
+ {
631
+ $match: {
632
+ $and: [
633
+ { $expr: { $eq: ['$_id', '$$userid'] } },
634
+ ],
635
+ },
636
+ },
637
+ ],
638
+ },
639
+ },
640
+ {
641
+ $unwind: {
642
+ path: '$userData',
643
+ preserveNullAndEmptyArrays: true,
644
+ },
645
+ },
646
+ {
647
+ $addFields: {
648
+ user: '$userData',
649
+ },
650
+ },
651
+ {
652
+ $project: {
653
+ userData: 0,
654
+ },
655
+ },
656
+ ];
657
+ return this.model.db.aggregate(aggregation).toArray()
658
+ .then((data) => data[0] || undefined);
659
+ }
660
+ addParticipant(list, mode, user, state, message, category, payment, structureInput, agreements, options) {
661
+ let participant = {
662
+ list,
663
+ user,
664
+ message,
665
+ category,
666
+ agreements,
667
+ state,
668
+ payment,
669
+ company: options.company,
670
+ project: options.project,
671
+ };
672
+ if (structureInput) {
673
+ participant = { ...participant, ...structureInput };
674
+ }
675
+ (0, cleanObject_1.default)(participant);
676
+ const partial = `${mode}-create`;
677
+ return this.create(participant, options.user, options.app, undefined, undefined, partial, { validator: options.validator });
678
+ }
679
+ addParticipantViaObject(participant, mode, options) {
680
+ const partial = `${mode}-create`;
681
+ return this.create(participant, options.user, options.app, undefined, undefined, partial, { validator: options.validator });
682
+ }
683
+ removeParticipant(list, user, options) {
684
+ }
685
+ listHistory(list, reason, options) {
686
+ const query = services_1.HistoryService.createQuery(options.company, options.project, undefined, reason, 'listParticipants');
687
+ query.countQuery.list = list;
688
+ query.aggregation[0].$match.$and.push({ $expr: { $eq: ['$list', list] } });
689
+ query.aggregation = [
690
+ query.aggregation[0],
691
+ query.aggregation[1],
692
+ ...this.customerLookup,
693
+ ];
694
+ return services_1.HistoryService.listCustomQuery(query);
695
+ }
696
+ agreementsMissing(listAgreements, providedAgreements) {
697
+ let missing = [];
698
+ const required = listAgreements?.filter((single) => single.required);
699
+ required.push({ required: true, contentId: 'contact-dsgvo', text: '' });
700
+ required.forEach((single) => {
701
+ if (!providedAgreements?.find((singleResponse) => singleResponse.id === single.contentId)) {
702
+ missing.push(single.contentId);
703
+ }
704
+ });
705
+ return missing;
706
+ }
707
+ async listParticipants(list, state, category, lastname, options) {
708
+ let aggregation = [
709
+ {
710
+ $match: {
711
+ $and: [
712
+ { $expr: { $eq: ['$company', options.company] } },
713
+ { $expr: { $eq: ['$list', list] } },
714
+ ],
715
+ },
716
+ },
717
+ ];
718
+ aggregation.push({
719
+ $sort: options.sort || { _id: -1 },
720
+ });
721
+ if (options.project) {
722
+ aggregation[0].$match.$and.push({ $expr: { $eq: ['$project', options.project] } });
723
+ }
724
+ if (state) {
725
+ aggregation[0].$match.$and.push({ $expr: { $in: ['$state', state] } });
726
+ }
727
+ else {
728
+ aggregation[0].$match.$and.push({ $expr: { $not: { $in: ['$state', ['blocked', 'unchecked', 'notuseful']] } } });
729
+ }
730
+ if (category) {
731
+ aggregation[0].$match.$and.push({ $expr: { $in: ['$category', category] } });
732
+ }
733
+ aggregation = [
734
+ ...aggregation,
735
+ ...this.getCustomerLookup(lastname),
736
+ ...this.paymentLookupList,
737
+ ];
738
+ aggregation.push({
739
+ $addFields: {
740
+ message: {
741
+ $substrCP: ['$message', 0, 150],
742
+ },
743
+ },
744
+ });
745
+ aggregation.push({
746
+ $facet: {
747
+ all: [
748
+ {
749
+ $count: 'all',
750
+ },
751
+ ],
752
+ data: [
753
+ {
754
+ $skip: options.skip,
755
+ },
756
+ {
757
+ $limit: options.limit,
758
+ },
759
+ ],
760
+ },
761
+ }, {
762
+ $unwind: '$all',
763
+ });
764
+ const data = await this.model.db.aggregate(aggregation)
765
+ .toArray();
766
+ return data[0] ? { all: data[0].all.all, data: data[0].data, count: data[0].data?.length } : { all: 0, data: [], count: 0 };
767
+ }
768
+ async getMyListsQuery(customerInternalId, filter, options) {
769
+ const aggregation = [
770
+ {
771
+ $match: {
772
+ user: customerInternalId,
773
+ },
774
+ },
775
+ {
776
+ $lookup: {
777
+ from: 'lists',
778
+ localField: 'list',
779
+ foreignField: '_id',
780
+ as: 'listData',
781
+ },
782
+ },
783
+ {
784
+ $unwind: '$listData',
785
+ },
786
+ {
787
+ $addFields: {
788
+ 'listData.user': {
789
+ state: '$state',
790
+ created: '$history.created',
791
+ updated: '$history.updated',
792
+ },
793
+ },
794
+ },
795
+ {
796
+ $group: {
797
+ _id: '$listData._id',
798
+ list: {
799
+ $first: '$listData',
800
+ },
801
+ },
802
+ },
803
+ {
804
+ $replaceRoot: {
805
+ newRoot: '$list',
806
+ },
807
+ },
808
+ {
809
+ $project: {
810
+ _id: 1,
811
+ name: 1,
812
+ payment: 1,
813
+ mode: 1,
814
+ company: 1,
815
+ project: 1,
816
+ user: 1,
817
+ },
818
+ },
819
+ {
820
+ $addFields: {
821
+ all: '$count',
822
+ },
823
+ },
824
+ ];
825
+ aggregation.push({
826
+ $sort: options.sort || { _id: -1 },
827
+ });
828
+ aggregation.push({
829
+ $facet: {
830
+ all: [
831
+ {
832
+ $count: 'all',
833
+ },
834
+ ],
835
+ data: [
836
+ {
837
+ $skip: options.skip,
838
+ },
839
+ {
840
+ $limit: options.limit,
841
+ },
842
+ ],
843
+ },
844
+ }, {
845
+ $unwind: '$all',
846
+ });
847
+ const data = await this.model.db.aggregate(aggregation)
848
+ .toArray();
849
+ return data[0] ? { all: data[0].all.all, data: data[0].data, count: data[0].data?.length } : { all: 0, data: [], count: 0 };
850
+ }
851
+ updateImportIds(importData, options) {
852
+ const idMapping = {};
853
+ /**
854
+ * update the unique datasets with new object ids and company and project
855
+ */
856
+ importData.map((single) => {
857
+ const originalId = single._id?.toString();
858
+ const newId = new mongodb_1.ObjectId();
859
+ single._id = newId;
860
+ single.company = options.company;
861
+ single.project = options.project;
862
+ idMapping[originalId] = newId;
863
+ });
864
+ return idMapping;
865
+ }
866
+ export(options) {
867
+ return this.model.db.find({ company: options.company, project: options.project }).toArray();
868
+ }
869
+ async import(importData, importHistoryData, idMapping, bulkHistory, options) {
870
+ const bulk = this.model.db.initializeUnorderedBulkOp();
871
+ [...importData, ...importHistoryData].forEach((participant) => {
872
+ participant.list = idMapping[participant.list?.toString()];
873
+ participant.user = idMapping[participant.user?.toString()];
874
+ participant.payment = idMapping[participant.payment?.toString()];
875
+ participant.agreements?.forEach((agreement) => {
876
+ if (agreement.id !== 'contact-dsgvo') {
877
+ agreement.id = idMapping[agreement.id]?.toString().toString();
878
+ }
879
+ });
880
+ });
881
+ importHistoryData.map((single) => {
882
+ const newParentId = idMapping[single.history.parent?.toString()];
883
+ single._id = new mongodb_1.ObjectId();
884
+ /**
885
+ * update the parent id
886
+ */
887
+ single.history.parent = newParentId;
888
+ /**
889
+ * update the company and project to the new import data
890
+ */
891
+ single.company = options.company;
892
+ single.project = options.project;
893
+ });
894
+ importData.map((single) => {
895
+ bulk.insert(single);
896
+ });
897
+ importHistoryData.map((single) => {
898
+ bulkHistory.insert(single);
899
+ });
900
+ return { bulk };
901
+ }
902
+ }
903
+ exports.ListParticipantsService = ListParticipantsService;
904
+ exports.default = new ListParticipantsService(process.env.PUBLISH_QUEUE_CONNECTION_STRING, process.env.STORAGE_ACCOUNT, 'check');
905
+ //# sourceMappingURL=listParticipants.service.js.map