@lilaquadrat/studio 9.15.2 → 9.15.4
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.
- package/lib/cjs/errors.d.ts +5 -0
- package/lib/cjs/errors.js +15 -0
- package/lib/cjs/errors.js.map +1 -0
- package/lib/cjs/helpers.d.ts +14 -0
- package/lib/cjs/helpers.js +36 -0
- package/lib/cjs/helpers.js.map +1 -0
- package/lib/cjs/main.d.ts +17 -0
- package/lib/cjs/main.js +73 -0
- package/lib/cjs/main.js.map +1 -0
- package/lib/cjs/models.d.ts +35 -0
- package/lib/cjs/models.js +75 -0
- package/lib/cjs/models.js.map +1 -0
- package/lib/cjs/services.d.ts +33 -0
- package/lib/cjs/services.js +105 -0
- package/lib/cjs/services.js.map +1 -0
- package/lib/cjs/src/AzureBlobStorage.share.d.ts +18 -0
- package/lib/cjs/src/AzureBlobStorage.share.js +157 -0
- package/lib/cjs/src/AzureBlobStorage.share.js.map +1 -0
- package/lib/cjs/src/AzureFileStorage.share.d.ts +21 -0
- package/lib/cjs/src/AzureFileStorage.share.js +144 -0
- package/lib/cjs/src/AzureFileStorage.share.js.map +1 -0
- package/lib/cjs/src/AzureVault.d.ts +14 -0
- package/lib/cjs/src/AzureVault.js +30 -0
- package/lib/cjs/src/AzureVault.js.map +1 -0
- package/lib/cjs/src/Filesystem.share.d.ts +15 -0
- package/lib/cjs/src/Filesystem.share.js +87 -0
- package/lib/cjs/src/Filesystem.share.js.map +1 -0
- package/lib/cjs/src/Immutable.class.d.ts +56 -0
- package/lib/cjs/src/Immutable.class.js +228 -0
- package/lib/cjs/src/Immutable.class.js.map +1 -0
- package/lib/cjs/src/Mock.share.d.ts +14 -0
- package/lib/cjs/src/Mock.share.js +36 -0
- package/lib/cjs/src/Mock.share.js.map +1 -0
- package/lib/cjs/src/ShareClientFactory.class.d.ts +7 -0
- package/lib/cjs/src/ShareClientFactory.class.js +34 -0
- package/lib/cjs/src/ShareClientFactory.class.js.map +1 -0
- package/lib/cjs/src/Timeseries.class.d.ts +11 -0
- package/lib/cjs/src/Timeseries.class.js +16 -0
- package/lib/cjs/src/Timeseries.class.js.map +1 -0
- package/lib/cjs/src/aggegations/childData.aggregation.d.ts +194 -0
- package/lib/cjs/src/aggegations/childData.aggregation.js +102 -0
- package/lib/cjs/src/aggegations/childData.aggregation.js.map +1 -0
- package/lib/cjs/src/aggegations/genericData.aggregation.d.ts +76 -0
- package/lib/cjs/src/aggegations/genericData.aggregation.js +79 -0
- package/lib/cjs/src/aggegations/genericData.aggregation.js.map +1 -0
- package/lib/cjs/src/aggegations/partial.aggregation.d.ts +88 -0
- package/lib/cjs/src/aggegations/partial.aggregation.js +68 -0
- package/lib/cjs/src/aggegations/partial.aggregation.js.map +1 -0
- package/lib/cjs/src/aggegations/publishData.aggregation.d.ts +89 -0
- package/lib/cjs/src/aggegations/publishData.aggregation.js +79 -0
- package/lib/cjs/src/aggegations/publishData.aggregation.js.map +1 -0
- package/lib/cjs/src/aggegations/resultData.aggregation.d.ts +151 -0
- package/lib/cjs/src/aggegations/resultData.aggregation.js +124 -0
- package/lib/cjs/src/aggegations/resultData.aggregation.js.map +1 -0
- package/lib/cjs/src/aggegations/structures.aggregation.d.ts +143 -0
- package/lib/cjs/src/aggegations/structures.aggregation.js +72 -0
- package/lib/cjs/src/aggegations/structures.aggregation.js.map +1 -0
- package/lib/cjs/src/aggegations/user.aggregation.d.ts +2 -0
- package/lib/cjs/src/aggegations/user.aggregation.js +38 -0
- package/lib/cjs/src/aggegations/user.aggregation.js.map +1 -0
- package/lib/cjs/src/classes/ControllerBase.class.d.ts +115 -0
- package/lib/cjs/src/classes/ControllerBase.class.js +274 -0
- package/lib/cjs/src/classes/ControllerBase.class.js.map +1 -0
- package/lib/cjs/src/classes/TimeseriesModel.class.d.ts +28 -0
- package/lib/cjs/src/classes/TimeseriesModel.class.js +72 -0
- package/lib/cjs/src/classes/TimeseriesModel.class.js.map +1 -0
- package/lib/cjs/src/classes/cache.class.d.ts +31 -0
- package/lib/cjs/src/classes/cache.class.js +71 -0
- package/lib/cjs/src/classes/cache.class.js.map +1 -0
- package/lib/cjs/src/classes/errors/Agreements.error.d.ts +6 -0
- package/lib/cjs/src/classes/errors/Agreements.error.js +12 -0
- package/lib/cjs/src/classes/errors/Agreements.error.js.map +1 -0
- package/lib/cjs/src/classes/errors/History.error.d.ts +6 -0
- package/lib/cjs/src/classes/errors/History.error.js +12 -0
- package/lib/cjs/src/classes/errors/History.error.js.map +1 -0
- package/lib/cjs/src/classes/errors/Immutable.error.d.ts +6 -0
- package/lib/cjs/src/classes/errors/Immutable.error.js +12 -0
- package/lib/cjs/src/classes/errors/Immutable.error.js.map +1 -0
- package/lib/cjs/src/classes/errors/InvalidId.error.d.ts +6 -0
- package/lib/cjs/src/classes/errors/InvalidId.error.js +12 -0
- package/lib/cjs/src/classes/errors/InvalidId.error.js.map +1 -0
- package/lib/cjs/src/classes/models.class.d.ts +13 -0
- package/lib/cjs/src/classes/models.class.js +46 -0
- package/lib/cjs/src/classes/models.class.js.map +1 -0
- package/lib/cjs/src/classes/modelv2.class.d.ts +82 -0
- package/lib/cjs/src/classes/modelv2.class.js +149 -0
- package/lib/cjs/src/classes/modelv2.class.js.map +1 -0
- package/lib/cjs/src/classes/mongo.class.d.ts +24 -0
- package/lib/cjs/src/classes/mongo.class.js +100 -0
- package/lib/cjs/src/classes/mongo.class.js.map +1 -0
- package/lib/cjs/src/dns.challenge.class.d.ts +17 -0
- package/lib/cjs/src/dns.challenge.class.js +47 -0
- package/lib/cjs/src/dns.challenge.class.js.map +1 -0
- package/lib/cjs/src/docker-compose.class.d.ts +14 -0
- package/lib/cjs/src/docker-compose.class.js +88 -0
- package/lib/cjs/src/docker-compose.class.js.map +1 -0
- package/lib/cjs/src/filterMergeModules.d.ts +3 -0
- package/lib/cjs/src/filterMergeModules.js +31 -0
- package/lib/cjs/src/filterMergeModules.js.map +1 -0
- package/lib/cjs/src/functions/handleError.d.ts +5 -0
- package/lib/cjs/src/functions/handleError.js +46 -0
- package/lib/cjs/src/functions/handleError.js.map +1 -0
- package/lib/cjs/src/functions/optionsHelper.d.ts +6 -0
- package/lib/cjs/src/functions/optionsHelper.js +16 -0
- package/lib/cjs/src/functions/optionsHelper.js.map +1 -0
- package/lib/cjs/src/functions/respondCode.d.ts +3 -0
- package/lib/cjs/src/functions/respondCode.js +5 -0
- package/lib/cjs/src/functions/respondCode.js.map +1 -0
- package/lib/cjs/src/helpers/HttpStatusCode.enum.d.ts +318 -0
- package/lib/cjs/src/helpers/HttpStatusCode.enum.js +324 -0
- package/lib/cjs/src/helpers/HttpStatusCode.enum.js.map +1 -0
- package/lib/cjs/src/helpers/cleanObject.d.ts +5 -0
- package/lib/cjs/src/helpers/cleanObject.js +9 -0
- package/lib/cjs/src/helpers/cleanObject.js.map +1 -0
- package/lib/cjs/src/helpers/companyRights.d.ts +3 -0
- package/lib/cjs/src/helpers/companyRights.js +18 -0
- package/lib/cjs/src/helpers/companyRights.js.map +1 -0
- package/lib/cjs/src/helpers/convertCountryISO2.d.ts +2 -0
- package/lib/cjs/src/helpers/convertCountryISO2.js +248 -0
- package/lib/cjs/src/helpers/convertCountryISO2.js.map +1 -0
- package/lib/cjs/src/helpers/countries.d.ts +4 -0
- package/lib/cjs/src/helpers/countries.js +14 -0
- package/lib/cjs/src/helpers/countries.js.map +1 -0
- package/lib/cjs/src/helpers/createError.d.ts +7 -0
- package/lib/cjs/src/helpers/createError.js +16 -0
- package/lib/cjs/src/helpers/createError.js.map +1 -0
- package/lib/cjs/src/helpers/createSasToken.d.ts +2 -0
- package/lib/cjs/src/helpers/createSasToken.js +36 -0
- package/lib/cjs/src/helpers/createSasToken.js.map +1 -0
- package/lib/cjs/src/helpers/findObjetcsWithKeys.d.ts +13 -0
- package/lib/cjs/src/helpers/findObjetcsWithKeys.js +34 -0
- package/lib/cjs/src/helpers/findObjetcsWithKeys.js.map +1 -0
- package/lib/cjs/src/helpers/getSecrets.d.ts +4 -0
- package/lib/cjs/src/helpers/getSecrets.js +20 -0
- package/lib/cjs/src/helpers/getSecrets.js.map +1 -0
- package/lib/cjs/src/helpers/hardCopy.d.ts +2 -0
- package/lib/cjs/src/helpers/hardCopy.js +5 -0
- package/lib/cjs/src/helpers/hardCopy.js.map +1 -0
- package/lib/cjs/src/helpers/isDeepEmpty.d.ts +1 -0
- package/lib/cjs/src/helpers/isDeepEmpty.js +23 -0
- package/lib/cjs/src/helpers/isDeepEmpty.js.map +1 -0
- package/lib/cjs/src/helpers/isValidObjectId.d.ts +15 -0
- package/lib/cjs/src/helpers/isValidObjectId.js +22 -0
- package/lib/cjs/src/helpers/isValidObjectId.js.map +1 -0
- package/lib/cjs/src/helpers/matchSortArray.d.ts +2 -0
- package/lib/cjs/src/helpers/matchSortArray.js +20 -0
- package/lib/cjs/src/helpers/matchSortArray.js.map +1 -0
- package/lib/cjs/src/helpers/safeObjectId.d.ts +8 -0
- package/lib/cjs/src/helpers/safeObjectId.js +18 -0
- package/lib/cjs/src/helpers/safeObjectId.js.map +1 -0
- package/lib/cjs/src/helpers/updateMappedId.d.ts +2 -0
- package/lib/cjs/src/helpers/updateMappedId.js +8 -0
- package/lib/cjs/src/helpers/updateMappedId.js.map +1 -0
- package/lib/cjs/src/http.challenge.class.d.ts +33 -0
- package/lib/cjs/src/http.challenge.class.js +64 -0
- package/lib/cjs/src/http.challenge.class.js.map +1 -0
- package/lib/cjs/src/logger.d.ts +2 -0
- package/lib/cjs/src/logger.js +45 -0
- package/lib/cjs/src/logger.js.map +1 -0
- package/lib/cjs/src/models/access.model.d.ts +4 -0
- package/lib/cjs/src/models/access.model.js +16 -0
- package/lib/cjs/src/models/access.model.js.map +1 -0
- package/lib/cjs/src/models/app.model.d.ts +4 -0
- package/lib/cjs/src/models/app.model.js +86 -0
- package/lib/cjs/src/models/app.model.js.map +1 -0
- package/lib/cjs/src/models/cache.model.d.ts +4 -0
- package/lib/cjs/src/models/cache.model.js +15 -0
- package/lib/cjs/src/models/cache.model.js.map +1 -0
- package/lib/cjs/src/models/cart.model.d.ts +4 -0
- package/lib/cjs/src/models/cart.model.js +76 -0
- package/lib/cjs/src/models/cart.model.js.map +1 -0
- package/lib/cjs/src/models/certificate-action.model.d.ts +5 -0
- package/lib/cjs/src/models/certificate-action.model.js +235 -0
- package/lib/cjs/src/models/certificate-action.model.js.map +1 -0
- package/lib/cjs/src/models/certificate.model.d.ts +4 -0
- package/lib/cjs/src/models/certificate.model.js +101 -0
- package/lib/cjs/src/models/certificate.model.js.map +1 -0
- package/lib/cjs/src/models/company.model.d.ts +4 -0
- package/lib/cjs/src/models/company.model.js +84 -0
- package/lib/cjs/src/models/company.model.js.map +1 -0
- package/lib/cjs/src/models/customers.model.d.ts +7 -0
- package/lib/cjs/src/models/customers.model.js +199 -0
- package/lib/cjs/src/models/customers.model.js.map +1 -0
- package/lib/cjs/src/models/domain.model.d.ts +4 -0
- package/lib/cjs/src/models/domain.model.js +90 -0
- package/lib/cjs/src/models/domain.model.js.map +1 -0
- package/lib/cjs/src/models/editor.model.d.ts +4 -0
- package/lib/cjs/src/models/editor.model.js +174 -0
- package/lib/cjs/src/models/editor.model.js.map +1 -0
- package/lib/cjs/src/models/editorBase.model.d.ts +4 -0
- package/lib/cjs/src/models/editorBase.model.js +44 -0
- package/lib/cjs/src/models/editorBase.model.js.map +1 -0
- package/lib/cjs/src/models/history.model.d.ts +4 -0
- package/lib/cjs/src/models/history.model.js +54 -0
- package/lib/cjs/src/models/history.model.js.map +1 -0
- package/lib/cjs/src/models/hosting.model.d.ts +4 -0
- package/lib/cjs/src/models/hosting.model.js +44 -0
- package/lib/cjs/src/models/hosting.model.js.map +1 -0
- package/lib/cjs/src/models/hostingCommand.model.d.ts +4 -0
- package/lib/cjs/src/models/hostingCommand.model.js +30 -0
- package/lib/cjs/src/models/hostingCommand.model.js.map +1 -0
- package/lib/cjs/src/models/hostingSettings.model.d.ts +4 -0
- package/lib/cjs/src/models/hostingSettings.model.js +29 -0
- package/lib/cjs/src/models/hostingSettings.model.js.map +1 -0
- package/lib/cjs/src/models/id.model.d.ts +12 -0
- package/lib/cjs/src/models/id.model.js +28 -0
- package/lib/cjs/src/models/id.model.js.map +1 -0
- package/lib/cjs/src/models/import.model.d.ts +4 -0
- package/lib/cjs/src/models/import.model.js +40 -0
- package/lib/cjs/src/models/import.model.js.map +1 -0
- package/lib/cjs/src/models/lists.model.d.ts +4 -0
- package/lib/cjs/src/models/lists.model.js +183 -0
- package/lib/cjs/src/models/lists.model.js.map +1 -0
- package/lib/cjs/src/models/listsParticipants.model.d.ts +4 -0
- package/lib/cjs/src/models/listsParticipants.model.js +87 -0
- package/lib/cjs/src/models/listsParticipants.model.js.map +1 -0
- package/lib/cjs/src/models/mailFrom.model.d.ts +4 -0
- package/lib/cjs/src/models/mailFrom.model.js +37 -0
- package/lib/cjs/src/models/mailFrom.model.js.map +1 -0
- package/lib/cjs/src/models/me.model.d.ts +4 -0
- package/lib/cjs/src/models/me.model.js +42 -0
- package/lib/cjs/src/models/me.model.js.map +1 -0
- package/lib/cjs/src/models/media.model.d.ts +4 -0
- package/lib/cjs/src/models/media.model.js +139 -0
- package/lib/cjs/src/models/media.model.js.map +1 -0
- package/lib/cjs/src/models/payment-provider.model.d.ts +4 -0
- package/lib/cjs/src/models/payment-provider.model.js +72 -0
- package/lib/cjs/src/models/payment-provider.model.js.map +1 -0
- package/lib/cjs/src/models/payment.model.d.ts +4 -0
- package/lib/cjs/src/models/payment.model.js +66 -0
- package/lib/cjs/src/models/payment.model.js.map +1 -0
- package/lib/cjs/src/models/permissions.model.d.ts +9 -0
- package/lib/cjs/src/models/permissions.model.js +264 -0
- package/lib/cjs/src/models/permissions.model.js.map +1 -0
- package/lib/cjs/src/models/project.model.d.ts +4 -0
- package/lib/cjs/src/models/project.model.js +80 -0
- package/lib/cjs/src/models/project.model.js.map +1 -0
- package/lib/cjs/src/models/publish-method.model.d.ts +4 -0
- package/lib/cjs/src/models/publish-method.model.js +452 -0
- package/lib/cjs/src/models/publish-method.model.js.map +1 -0
- package/lib/cjs/src/models/publish.model.d.ts +4 -0
- package/lib/cjs/src/models/publish.model.js +188 -0
- package/lib/cjs/src/models/publish.model.js.map +1 -0
- package/lib/cjs/src/models/secrets.model.d.ts +4 -0
- package/lib/cjs/src/models/secrets.model.js +42 -0
- package/lib/cjs/src/models/secrets.model.js.map +1 -0
- package/lib/cjs/src/models/settings.model.d.ts +4 -0
- package/lib/cjs/src/models/settings.model.js +21 -0
- package/lib/cjs/src/models/settings.model.js.map +1 -0
- package/lib/cjs/src/models/structure.model.d.ts +4 -0
- package/lib/cjs/src/models/structure.model.js +187 -0
- package/lib/cjs/src/models/structure.model.js.map +1 -0
- package/lib/cjs/src/models/tracker.model.d.ts +4 -0
- package/lib/cjs/src/models/tracker.model.js +59 -0
- package/lib/cjs/src/models/tracker.model.js.map +1 -0
- package/lib/cjs/src/models/universal.model.d.ts +4 -0
- package/lib/cjs/src/models/universal.model.js +9 -0
- package/lib/cjs/src/models/universal.model.js.map +1 -0
- package/lib/cjs/src/models/webhook-call.model.d.ts +4 -0
- package/lib/cjs/src/models/webhook-call.model.js +31 -0
- package/lib/cjs/src/models/webhook-call.model.js.map +1 -0
- package/lib/cjs/src/nginx.class.d.ts +11 -0
- package/lib/cjs/src/nginx.class.js +49 -0
- package/lib/cjs/src/nginx.class.js.map +1 -0
- package/lib/cjs/src/prepareContent.d.ts +7 -0
- package/lib/cjs/src/prepareContent.js +89 -0
- package/lib/cjs/src/prepareContent.js.map +1 -0
- package/lib/cjs/src/services/access.service.d.ts +37 -0
- package/lib/cjs/src/services/access.service.js +115 -0
- package/lib/cjs/src/services/access.service.js.map +1 -0
- package/lib/cjs/src/services/cart.service.d.ts +39 -0
- package/lib/cjs/src/services/cart.service.js +196 -0
- package/lib/cjs/src/services/cart.service.js.map +1 -0
- package/lib/cjs/src/services/certificates.service.d.ts +56 -0
- package/lib/cjs/src/services/certificates.service.js +177 -0
- package/lib/cjs/src/services/certificates.service.js.map +1 -0
- package/lib/cjs/src/services/certificatesAction.service.d.ts +41 -0
- package/lib/cjs/src/services/certificatesAction.service.js +195 -0
- package/lib/cjs/src/services/certificatesAction.service.js.map +1 -0
- package/lib/cjs/src/services/conf.service.d.ts +35 -0
- package/lib/cjs/src/services/conf.service.js +189 -0
- package/lib/cjs/src/services/conf.service.js.map +1 -0
- package/lib/cjs/src/services/customers.service.d.ts +74 -0
- package/lib/cjs/src/services/customers.service.js +397 -0
- package/lib/cjs/src/services/customers.service.js.map +1 -0
- package/lib/cjs/src/services/domains.service.d.ts +115 -0
- package/lib/cjs/src/services/domains.service.js +635 -0
- package/lib/cjs/src/services/domains.service.js.map +1 -0
- package/lib/cjs/src/services/editor.service.d.ts +65 -0
- package/lib/cjs/src/services/editor.service.js +532 -0
- package/lib/cjs/src/services/editor.service.js.map +1 -0
- package/lib/cjs/src/services/editorBase.service.d.ts +46 -0
- package/lib/cjs/src/services/editorBase.service.js +163 -0
- package/lib/cjs/src/services/editorBase.service.js.map +1 -0
- package/lib/cjs/src/services/handleFile.service.d.ts +9 -0
- package/lib/cjs/src/services/handleFile.service.js +52 -0
- package/lib/cjs/src/services/handleFile.service.js.map +1 -0
- package/lib/cjs/src/services/history.service.d.ts +37 -0
- package/lib/cjs/src/services/history.service.js +268 -0
- package/lib/cjs/src/services/history.service.js.map +1 -0
- package/lib/cjs/src/services/hosting.service.d.ts +38 -0
- package/lib/cjs/src/services/hosting.service.js +221 -0
- package/lib/cjs/src/services/hosting.service.js.map +1 -0
- package/lib/cjs/src/services/hostingAdmin.service.d.ts +11 -0
- package/lib/cjs/src/services/hostingAdmin.service.js +21 -0
- package/lib/cjs/src/services/hostingAdmin.service.js.map +1 -0
- package/lib/cjs/src/services/hostingCommands.service.d.ts +17 -0
- package/lib/cjs/src/services/hostingCommands.service.js +80 -0
- package/lib/cjs/src/services/hostingCommands.service.js.map +1 -0
- package/lib/cjs/src/services/id.service.d.ts +4 -0
- package/lib/cjs/src/services/id.service.js +18 -0
- package/lib/cjs/src/services/id.service.js.map +1 -0
- package/lib/cjs/src/services/import.service.d.ts +33 -0
- package/lib/cjs/src/services/import.service.js +99 -0
- package/lib/cjs/src/services/import.service.js.map +1 -0
- package/lib/cjs/src/services/listParticipants.service.d.ts +242 -0
- package/lib/cjs/src/services/listParticipants.service.js +907 -0
- package/lib/cjs/src/services/listParticipants.service.js.map +1 -0
- package/lib/cjs/src/services/lists.service.d.ts +40 -0
- package/lib/cjs/src/services/lists.service.js +626 -0
- package/lib/cjs/src/services/lists.service.js.map +1 -0
- package/lib/cjs/src/services/mailFrom.service.d.ts +10 -0
- package/lib/cjs/src/services/mailFrom.service.js +53 -0
- package/lib/cjs/src/services/mailFrom.service.js.map +1 -0
- package/lib/cjs/src/services/me.service.d.ts +68 -0
- package/lib/cjs/src/services/me.service.js +350 -0
- package/lib/cjs/src/services/me.service.js.map +1 -0
- package/lib/cjs/src/services/media.service.d.ts +34 -0
- package/lib/cjs/src/services/media.service.js +422 -0
- package/lib/cjs/src/services/media.service.js.map +1 -0
- package/lib/cjs/src/services/paymentProviders.service.d.ts +13 -0
- package/lib/cjs/src/services/paymentProviders.service.js +33 -0
- package/lib/cjs/src/services/paymentProviders.service.js.map +1 -0
- package/lib/cjs/src/services/payments.service.d.ts +70 -0
- package/lib/cjs/src/services/payments.service.js +151 -0
- package/lib/cjs/src/services/payments.service.js.map +1 -0
- package/lib/cjs/src/services/permissions.service.d.ts +35 -0
- package/lib/cjs/src/services/permissions.service.js +739 -0
- package/lib/cjs/src/services/permissions.service.js.map +1 -0
- package/lib/cjs/src/services/publish.service.d.ts +40 -0
- package/lib/cjs/src/services/publish.service.js +366 -0
- package/lib/cjs/src/services/publish.service.js.map +1 -0
- package/lib/cjs/src/services/publishData.service.d.ts +18 -0
- package/lib/cjs/src/services/publishData.service.js +120 -0
- package/lib/cjs/src/services/publishData.service.js.map +1 -0
- package/lib/cjs/src/services/publishMethod.service.d.ts +16 -0
- package/lib/cjs/src/services/publishMethod.service.js +64 -0
- package/lib/cjs/src/services/publishMethod.service.js.map +1 -0
- package/lib/cjs/src/services/secret.service.d.ts +17 -0
- package/lib/cjs/src/services/secret.service.js +50 -0
- package/lib/cjs/src/services/secret.service.js.map +1 -0
- package/lib/cjs/src/services/spamAnalasys.service.d.ts +15 -0
- package/lib/cjs/src/services/spamAnalasys.service.js +100 -0
- package/lib/cjs/src/services/spamAnalasys.service.js.map +1 -0
- package/lib/cjs/src/services/structures.service.d.ts +40 -0
- package/lib/cjs/src/services/structures.service.js +267 -0
- package/lib/cjs/src/services/structures.service.js.map +1 -0
- package/lib/cjs/src/services/universal.service.d.ts +17 -0
- package/lib/cjs/src/services/universal.service.js +145 -0
- package/lib/cjs/src/services/universal.service.js.map +1 -0
- package/lib/cjs/src/services/webhooks-calls.service.d.ts +13 -0
- package/lib/cjs/src/services/webhooks-calls.service.js +59 -0
- package/lib/cjs/src/services/webhooks-calls.service.js.map +1 -0
- package/lib/cjs/tests/editorService.spec.d.ts +1 -0
- package/lib/cjs/tests/editorService.spec.js +49 -0
- package/lib/cjs/tests/editorService.spec.js.map +1 -0
- package/lib/cjs/tests/getUnsetObject.spec.d.ts +1 -0
- package/lib/cjs/tests/getUnsetObject.spec.js +68 -0
- package/lib/cjs/tests/getUnsetObject.spec.js.map +1 -0
- package/lib/esm/frontend.d.ts +7 -0
- package/lib/esm/frontend.js +8 -0
- package/lib/esm/frontend.js.map +1 -0
- package/lib/esm/src/filterMergeModules.d.ts +3 -0
- package/lib/esm/src/filterMergeModules.js +29 -0
- package/lib/esm/src/filterMergeModules.js.map +1 -0
- package/lib/esm/src/helpers/convertCountryISO2.d.ts +2 -0
- package/lib/esm/src/helpers/convertCountryISO2.js +246 -0
- package/lib/esm/src/helpers/convertCountryISO2.js.map +1 -0
- package/lib/esm/src/helpers/findObjetcsWithKeys.d.ts +13 -0
- package/lib/esm/src/helpers/findObjetcsWithKeys.js +31 -0
- package/lib/esm/src/helpers/findObjetcsWithKeys.js.map +1 -0
- package/lib/esm/src/helpers/hardCopy.d.ts +2 -0
- package/lib/esm/src/helpers/hardCopy.js +3 -0
- package/lib/esm/src/helpers/hardCopy.js.map +1 -0
- package/lib/esm/src/helpers/isDeepEmpty.d.ts +1 -0
- package/lib/esm/src/helpers/isDeepEmpty.js +20 -0
- package/lib/esm/src/helpers/isDeepEmpty.js.map +1 -0
- package/lib/esm/src/prepareContent.d.ts +7 -0
- package/lib/esm/src/prepareContent.js +83 -0
- package/lib/esm/src/prepareContent.js.map +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1,907 @@
|
|
|
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
|
+
if (!state)
|
|
401
|
+
throw new Error('LIST_CATEGORY_NOT_FOUND');
|
|
402
|
+
let participant = {
|
|
403
|
+
list: listInternalId,
|
|
404
|
+
user: customerId,
|
|
405
|
+
category,
|
|
406
|
+
note,
|
|
407
|
+
agreements: [],
|
|
408
|
+
state,
|
|
409
|
+
company: options.company,
|
|
410
|
+
project: options.project,
|
|
411
|
+
};
|
|
412
|
+
(0, cleanObject_1.default)(participant);
|
|
413
|
+
return this.create(participant, options.user, options.app, undefined, undefined, 'create-manually');
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* join a list through payment
|
|
417
|
+
*/
|
|
418
|
+
async joinViaPayment(listInternalId, customerId, message, category, payment, agreements, options) {
|
|
419
|
+
const list = await services_1.ListsService.single(listInternalId, undefined, options);
|
|
420
|
+
if (!list)
|
|
421
|
+
throw new Error('LIST_NOT_FOUND');
|
|
422
|
+
let entryState = 'paid';
|
|
423
|
+
const participantInList = await this.singleWithoutLookup(listInternalId, customerId, options);
|
|
424
|
+
if (list.participants?.unique && participantInList) {
|
|
425
|
+
throw new Error('LIST_UNIQUE_CUSTOMER_CONFIRMED');
|
|
426
|
+
}
|
|
427
|
+
if (participantInList?.state === 'blocked') {
|
|
428
|
+
throw new Error('LIST_CANNOT_JOIN');
|
|
429
|
+
}
|
|
430
|
+
await this.addParticipant(listInternalId, list.mode, customerId, entryState, message, category, payment, undefined, agreements, options);
|
|
431
|
+
await this.sendStateAndAudienceAwareEmail(list._id, customerId, entryState, 'public', { ...options, disableEmailConfirmedCheck: true });
|
|
432
|
+
return customerId;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* join a list from members perspective
|
|
436
|
+
*/
|
|
437
|
+
async membersJoin(listInternalId, account, message, category, agreements, structureInput, options) {
|
|
438
|
+
const modelHints = { listsParticipants: '', customers: 'changePersonMinimal' };
|
|
439
|
+
const optionsWithValidatorCustomers = { ...options };
|
|
440
|
+
const optionsWithValidatorListsParticipants = { ...options };
|
|
441
|
+
/**
|
|
442
|
+
* Separate structures by type for easier access
|
|
443
|
+
*/
|
|
444
|
+
let structuresByModel = {};
|
|
445
|
+
let structuresInputByModel = {};
|
|
446
|
+
const validatorByModel = {};
|
|
447
|
+
const list = await services_1.ListsService.single(listInternalId, undefined, options);
|
|
448
|
+
if (!list)
|
|
449
|
+
throw new Error('LIST_NOT_FOUND');
|
|
450
|
+
if (!list.participants?.available)
|
|
451
|
+
throw new Error('LIST_NO_SPOT_AVAILABLE');
|
|
452
|
+
let entryState = 'unchecked';
|
|
453
|
+
// if (list.mode === 'contact') entryState = 'enlisted';
|
|
454
|
+
if (list.mode === 'content')
|
|
455
|
+
entryState = 'enlisted';
|
|
456
|
+
if (list.mode === 'reservation')
|
|
457
|
+
entryState = 'reserved';
|
|
458
|
+
modelHints.listsParticipants = `${list.mode}-create`;
|
|
459
|
+
const agreementsMissing = this.agreementsMissing(list.agreements, agreements);
|
|
460
|
+
if (agreementsMissing.length) {
|
|
461
|
+
throw new Agreements_error_1.default('accepted', [
|
|
462
|
+
{
|
|
463
|
+
keyword: 'accepted',
|
|
464
|
+
instancePath: 'agreements',
|
|
465
|
+
schemaPath: '#/accepted',
|
|
466
|
+
params: { missingProperty: 'agreements', missing: agreementsMissing },
|
|
467
|
+
},
|
|
468
|
+
], { required: agreementsMissing });
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* existing parent id indicates that we need to check if we have a contact module with structures in it
|
|
472
|
+
*/
|
|
473
|
+
if (options.parentId) {
|
|
474
|
+
/**
|
|
475
|
+
* get the editor and find used the contact module
|
|
476
|
+
*/
|
|
477
|
+
const editor = await services_1.EditorService.getById(options.parentId, options);
|
|
478
|
+
const contactModule = editor.modules.find((single) => single.uuid === options.uuid);
|
|
479
|
+
if (editor.genericData?.structures && contactModule) {
|
|
480
|
+
/**
|
|
481
|
+
* get all used structures for the contact module
|
|
482
|
+
*/
|
|
483
|
+
const structures = await structures_service_1.default.byMultipleInternalIds(editor.genericData?.structures, options);
|
|
484
|
+
const contactCategories = contactModule.categories;
|
|
485
|
+
const groupedStructures = structures_service_1.default.groupStructuresByModel(structures, structureInput);
|
|
486
|
+
structuresByModel = groupedStructures.structuresByModel;
|
|
487
|
+
structuresInputByModel = groupedStructures.structuresInputByModel;
|
|
488
|
+
/**
|
|
489
|
+
* create a validator each model
|
|
490
|
+
*/
|
|
491
|
+
Object.keys(structuresByModel).forEach((model) => {
|
|
492
|
+
validatorByModel[model] = this.getValidatorForStructures(contactCategories, structuresByModel[model], model, modelHints[model]);
|
|
493
|
+
});
|
|
494
|
+
if (validatorByModel.customers)
|
|
495
|
+
optionsWithValidatorCustomers.validator = validatorByModel.customers;
|
|
496
|
+
if (validatorByModel.listsParticipants)
|
|
497
|
+
optionsWithValidatorListsParticipants.validator = validatorByModel.listsParticipants;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
throw new Error('PARENT_NOT_FOUND');
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* user id is only for validation and needs to be replaced with the real customer id
|
|
505
|
+
*/
|
|
506
|
+
const participantsObject = this.createParticipantsObject(listInternalId, list.mode, new mongodb_1.ObjectId(), entryState, message, category, undefined, structuresInputByModel.listsParticipants, agreements, optionsWithValidatorListsParticipants);
|
|
507
|
+
/**
|
|
508
|
+
* TODO: double validation needs to be removed
|
|
509
|
+
* we currently validate the data two times
|
|
510
|
+
* with this pre validation of the listsParticipants we dont create a customer if the list validation fails
|
|
511
|
+
*/
|
|
512
|
+
if (validatorByModel.listsParticipants) {
|
|
513
|
+
if (!validatorByModel.listsParticipants(participantsObject)) {
|
|
514
|
+
throw new Immutable_error_1.default('VALIDATION_FAILED', validatorByModel.listsParticipants.errors);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
const customer = await customers_service_1.default.getCustomerByAccount(account, options.app, { history: 0, accounts: 0 });
|
|
518
|
+
if (!customer)
|
|
519
|
+
throw new Error('CUSTOMER_NOT_FOUND');
|
|
520
|
+
const customerId = customer._id;
|
|
521
|
+
participantsObject.user = customerId;
|
|
522
|
+
delete customer._id;
|
|
523
|
+
if (structuresInputByModel.customers) {
|
|
524
|
+
await customers_service_1.default.immutable({ _id: customerId }, { ...customer, ...structuresInputByModel.customers }, options.user, 'change', options.app, undefined, undefined, 'changePersonMinimal', { validator: optionsWithValidatorCustomers.validator });
|
|
525
|
+
}
|
|
526
|
+
const participantInList = await this.singleWithoutLookup(listInternalId, customerId, options);
|
|
527
|
+
if (list.participants?.unique && participantInList) {
|
|
528
|
+
throw new Error('LIST_UNIQUE_CUSTOMER_CONFIRMED');
|
|
529
|
+
}
|
|
530
|
+
if (participantInList?.state === 'blocked') {
|
|
531
|
+
throw new Error('LIST_CANNOT_JOIN');
|
|
532
|
+
}
|
|
533
|
+
const addResponse = await this.addParticipantViaObject(participantsObject, list.mode, optionsWithValidatorListsParticipants);
|
|
534
|
+
// const addResponse = await this.addParticipant(listInternalId, list.mode, customer._id, entryState, message, category, undefined, undefined, agreements, options);
|
|
535
|
+
/**
|
|
536
|
+
* only add to the queue and initiate the spam check when the entrystate is unchecked
|
|
537
|
+
*/
|
|
538
|
+
if (entryState === 'unchecked') {
|
|
539
|
+
await this.client.sendMessage(Buffer.from(JSON.stringify({ _id: addResponse._id, listId: list._id })).toString('base64'));
|
|
540
|
+
}
|
|
541
|
+
await this.sendStateAndAudienceAwareEmail(list._id, customerId, entryState, 'members', options);
|
|
542
|
+
return customerId;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Sends an email based on participant state and audience criteria.
|
|
546
|
+
* if the options for disableEmailConfirmedCheck is set to true, the email will be sent regardless of the email confirmation status.
|
|
547
|
+
*/
|
|
548
|
+
async sendStateAndAudienceAwareEmail(listId, customerId, state, audience, options) {
|
|
549
|
+
const list = await services_1.ListsService.single(listId, undefined, options);
|
|
550
|
+
if (!list)
|
|
551
|
+
return;
|
|
552
|
+
const email = list.emails?.find((single) => single.affectedState === state && single.audience === audience);
|
|
553
|
+
if (!email)
|
|
554
|
+
return;
|
|
555
|
+
if (!options.disableEmailConfirmedCheck) {
|
|
556
|
+
const customer = await customers_service_1.default.single(customerId, options);
|
|
557
|
+
if (!customer)
|
|
558
|
+
return;
|
|
559
|
+
if (!customer.emailConfirmed) {
|
|
560
|
+
console.debug('EMAIL_NOT_CONFIRMED');
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return publish_service_1.default.email((0, safeObjectId_1.default)(email.contentId), customerId, undefined, options);
|
|
565
|
+
}
|
|
566
|
+
async remove(list, participationId, options) {
|
|
567
|
+
return this.delete(participationId, options.user, options.app);
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Updates the state of a participant in a list
|
|
571
|
+
*/
|
|
572
|
+
async state(list, participationId, state, options) {
|
|
573
|
+
await this.immutable({ _id: participationId, list, company: options.company, project: options.project }, { state }, options.user, 'change', options.app, undefined, undefined, 'updateState');
|
|
574
|
+
const participant = await this.model.db.findOne({ _id: participationId, company: options.company, project: options.project });
|
|
575
|
+
if (!participant)
|
|
576
|
+
return;
|
|
577
|
+
const customer = await customers_service_1.default.single(participant.user, options);
|
|
578
|
+
if (customer?.type === 'person') {
|
|
579
|
+
// Determine the audience type based on whether the customer has accounts
|
|
580
|
+
// 'members' for customers with accounts, 'public' for those without
|
|
581
|
+
const audience = customer.accounts && customer.accounts[0] ? 'members' : 'public';
|
|
582
|
+
// Send an email notification based on the new state and audience type
|
|
583
|
+
await this.sendStateAndAudienceAwareEmail(list, customer._id, state, audience, options);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
async note(list, participationId, note, options) {
|
|
587
|
+
return this.immutable({ _id: participationId, list, company: options.company, project: options.project }, note ? { note } : {}, options.user, 'change', options.app, undefined, undefined, 'updateNote');
|
|
588
|
+
}
|
|
589
|
+
async participantInList(list, user, options) {
|
|
590
|
+
return await this.model.db.countDocuments({ list, user, company: options.company, project: options.project }) > 0;
|
|
591
|
+
}
|
|
592
|
+
singleWithoutLookup(list, user, options) {
|
|
593
|
+
return this.model.db.findOne({ list, user, company: options.company, project: options.project });
|
|
594
|
+
}
|
|
595
|
+
viaPayment(listId, paymentId, options) {
|
|
596
|
+
let aggregation = [
|
|
597
|
+
{
|
|
598
|
+
$match: {
|
|
599
|
+
$and: [
|
|
600
|
+
{ $expr: { $eq: ['$company', options.company] } },
|
|
601
|
+
{ $expr: { $eq: ['$project', options.project] } },
|
|
602
|
+
{ $expr: { $eq: ['$list', listId] } },
|
|
603
|
+
{ $expr: { $eq: ['$payment', paymentId] } },
|
|
604
|
+
],
|
|
605
|
+
},
|
|
606
|
+
},
|
|
607
|
+
...this.customerLookup,
|
|
608
|
+
...this.paymentLookup,
|
|
609
|
+
...structures_aggregation_1.projectStructuresAggregation,
|
|
610
|
+
];
|
|
611
|
+
return this.model.db.aggregate(aggregation).toArray()
|
|
612
|
+
.then((data) => data[0] || undefined);
|
|
613
|
+
}
|
|
614
|
+
byInternalId(internalId, customerLookup) {
|
|
615
|
+
if (!customerLookup) {
|
|
616
|
+
return this.model.db.findOne({ _id: internalId });
|
|
617
|
+
}
|
|
618
|
+
let aggregation = [
|
|
619
|
+
{
|
|
620
|
+
$match: {
|
|
621
|
+
$and: [
|
|
622
|
+
{ $expr: { $eq: ['$_id', internalId] } },
|
|
623
|
+
],
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
$lookup: {
|
|
628
|
+
from: 'customers',
|
|
629
|
+
as: 'userData',
|
|
630
|
+
let: { userid: '$user' },
|
|
631
|
+
pipeline: [
|
|
632
|
+
{
|
|
633
|
+
$match: {
|
|
634
|
+
$and: [
|
|
635
|
+
{ $expr: { $eq: ['$_id', '$$userid'] } },
|
|
636
|
+
],
|
|
637
|
+
},
|
|
638
|
+
},
|
|
639
|
+
],
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
$unwind: {
|
|
644
|
+
path: '$userData',
|
|
645
|
+
preserveNullAndEmptyArrays: true,
|
|
646
|
+
},
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
$addFields: {
|
|
650
|
+
user: '$userData',
|
|
651
|
+
},
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
$project: {
|
|
655
|
+
userData: 0,
|
|
656
|
+
},
|
|
657
|
+
},
|
|
658
|
+
];
|
|
659
|
+
return this.model.db.aggregate(aggregation).toArray()
|
|
660
|
+
.then((data) => data[0] || undefined);
|
|
661
|
+
}
|
|
662
|
+
addParticipant(list, mode, user, state, message, category, payment, structureInput, agreements, options) {
|
|
663
|
+
let participant = {
|
|
664
|
+
list,
|
|
665
|
+
user,
|
|
666
|
+
message,
|
|
667
|
+
category,
|
|
668
|
+
agreements,
|
|
669
|
+
state,
|
|
670
|
+
payment,
|
|
671
|
+
company: options.company,
|
|
672
|
+
project: options.project,
|
|
673
|
+
};
|
|
674
|
+
if (structureInput) {
|
|
675
|
+
participant = { ...participant, ...structureInput };
|
|
676
|
+
}
|
|
677
|
+
(0, cleanObject_1.default)(participant);
|
|
678
|
+
const partial = `${mode}-create`;
|
|
679
|
+
return this.create(participant, options.user, options.app, undefined, undefined, partial, { validator: options.validator });
|
|
680
|
+
}
|
|
681
|
+
addParticipantViaObject(participant, mode, options) {
|
|
682
|
+
const partial = `${mode}-create`;
|
|
683
|
+
return this.create(participant, options.user, options.app, undefined, undefined, partial, { validator: options.validator });
|
|
684
|
+
}
|
|
685
|
+
removeParticipant(list, user, options) {
|
|
686
|
+
}
|
|
687
|
+
listHistory(list, reason, options) {
|
|
688
|
+
const query = services_1.HistoryService.createQuery(options.company, options.project, undefined, reason, 'listParticipants');
|
|
689
|
+
query.countQuery.list = list;
|
|
690
|
+
query.aggregation[0].$match.$and.push({ $expr: { $eq: ['$list', list] } });
|
|
691
|
+
query.aggregation = [
|
|
692
|
+
query.aggregation[0],
|
|
693
|
+
query.aggregation[1],
|
|
694
|
+
...this.customerLookup,
|
|
695
|
+
];
|
|
696
|
+
return services_1.HistoryService.listCustomQuery(query);
|
|
697
|
+
}
|
|
698
|
+
agreementsMissing(listAgreements, providedAgreements) {
|
|
699
|
+
let missing = [];
|
|
700
|
+
const required = listAgreements?.filter((single) => single.required);
|
|
701
|
+
required.push({ required: true, contentId: 'contact-dsgvo', text: '' });
|
|
702
|
+
required.forEach((single) => {
|
|
703
|
+
if (!providedAgreements?.find((singleResponse) => singleResponse.id === single.contentId)) {
|
|
704
|
+
missing.push(single.contentId);
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
return missing;
|
|
708
|
+
}
|
|
709
|
+
async listParticipants(list, state, category, lastname, options) {
|
|
710
|
+
let aggregation = [
|
|
711
|
+
{
|
|
712
|
+
$match: {
|
|
713
|
+
$and: [
|
|
714
|
+
{ $expr: { $eq: ['$company', options.company] } },
|
|
715
|
+
{ $expr: { $eq: ['$list', list] } },
|
|
716
|
+
],
|
|
717
|
+
},
|
|
718
|
+
},
|
|
719
|
+
];
|
|
720
|
+
aggregation.push({
|
|
721
|
+
$sort: options.sort || { _id: -1 },
|
|
722
|
+
});
|
|
723
|
+
if (options.project) {
|
|
724
|
+
aggregation[0].$match.$and.push({ $expr: { $eq: ['$project', options.project] } });
|
|
725
|
+
}
|
|
726
|
+
if (state) {
|
|
727
|
+
aggregation[0].$match.$and.push({ $expr: { $in: ['$state', state] } });
|
|
728
|
+
}
|
|
729
|
+
else {
|
|
730
|
+
aggregation[0].$match.$and.push({ $expr: { $not: { $in: ['$state', ['blocked', 'unchecked', 'notuseful']] } } });
|
|
731
|
+
}
|
|
732
|
+
if (category) {
|
|
733
|
+
aggregation[0].$match.$and.push({ $expr: { $in: ['$category', category] } });
|
|
734
|
+
}
|
|
735
|
+
aggregation = [
|
|
736
|
+
...aggregation,
|
|
737
|
+
...this.getCustomerLookup(lastname),
|
|
738
|
+
...this.paymentLookupList,
|
|
739
|
+
];
|
|
740
|
+
aggregation.push({
|
|
741
|
+
$addFields: {
|
|
742
|
+
message: {
|
|
743
|
+
$substrCP: ['$message', 0, 150],
|
|
744
|
+
},
|
|
745
|
+
},
|
|
746
|
+
});
|
|
747
|
+
aggregation.push({
|
|
748
|
+
$facet: {
|
|
749
|
+
all: [
|
|
750
|
+
{
|
|
751
|
+
$count: 'all',
|
|
752
|
+
},
|
|
753
|
+
],
|
|
754
|
+
data: [
|
|
755
|
+
{
|
|
756
|
+
$skip: options.skip,
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
$limit: options.limit,
|
|
760
|
+
},
|
|
761
|
+
],
|
|
762
|
+
},
|
|
763
|
+
}, {
|
|
764
|
+
$unwind: '$all',
|
|
765
|
+
});
|
|
766
|
+
const data = await this.model.db.aggregate(aggregation)
|
|
767
|
+
.toArray();
|
|
768
|
+
return data[0] ? { all: data[0].all.all, data: data[0].data, count: data[0].data?.length } : { all: 0, data: [], count: 0 };
|
|
769
|
+
}
|
|
770
|
+
async getMyListsQuery(customerInternalId, filter, options) {
|
|
771
|
+
const aggregation = [
|
|
772
|
+
{
|
|
773
|
+
$match: {
|
|
774
|
+
user: customerInternalId,
|
|
775
|
+
},
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
$lookup: {
|
|
779
|
+
from: 'lists',
|
|
780
|
+
localField: 'list',
|
|
781
|
+
foreignField: '_id',
|
|
782
|
+
as: 'listData',
|
|
783
|
+
},
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
$unwind: '$listData',
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
$addFields: {
|
|
790
|
+
'listData.user': {
|
|
791
|
+
state: '$state',
|
|
792
|
+
created: '$history.created',
|
|
793
|
+
updated: '$history.updated',
|
|
794
|
+
},
|
|
795
|
+
},
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
$group: {
|
|
799
|
+
_id: '$listData._id',
|
|
800
|
+
list: {
|
|
801
|
+
$first: '$listData',
|
|
802
|
+
},
|
|
803
|
+
},
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
$replaceRoot: {
|
|
807
|
+
newRoot: '$list',
|
|
808
|
+
},
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
$project: {
|
|
812
|
+
_id: 1,
|
|
813
|
+
name: 1,
|
|
814
|
+
payment: 1,
|
|
815
|
+
mode: 1,
|
|
816
|
+
company: 1,
|
|
817
|
+
project: 1,
|
|
818
|
+
user: 1,
|
|
819
|
+
},
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
$addFields: {
|
|
823
|
+
all: '$count',
|
|
824
|
+
},
|
|
825
|
+
},
|
|
826
|
+
];
|
|
827
|
+
aggregation.push({
|
|
828
|
+
$sort: options.sort || { _id: -1 },
|
|
829
|
+
});
|
|
830
|
+
aggregation.push({
|
|
831
|
+
$facet: {
|
|
832
|
+
all: [
|
|
833
|
+
{
|
|
834
|
+
$count: 'all',
|
|
835
|
+
},
|
|
836
|
+
],
|
|
837
|
+
data: [
|
|
838
|
+
{
|
|
839
|
+
$skip: options.skip,
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
$limit: options.limit,
|
|
843
|
+
},
|
|
844
|
+
],
|
|
845
|
+
},
|
|
846
|
+
}, {
|
|
847
|
+
$unwind: '$all',
|
|
848
|
+
});
|
|
849
|
+
const data = await this.model.db.aggregate(aggregation)
|
|
850
|
+
.toArray();
|
|
851
|
+
return data[0] ? { all: data[0].all.all, data: data[0].data, count: data[0].data?.length } : { all: 0, data: [], count: 0 };
|
|
852
|
+
}
|
|
853
|
+
updateImportIds(importData, options) {
|
|
854
|
+
const idMapping = {};
|
|
855
|
+
/**
|
|
856
|
+
* update the unique datasets with new object ids and company and project
|
|
857
|
+
*/
|
|
858
|
+
importData.map((single) => {
|
|
859
|
+
const originalId = single._id?.toString();
|
|
860
|
+
const newId = new mongodb_1.ObjectId();
|
|
861
|
+
single._id = newId;
|
|
862
|
+
single.company = options.company;
|
|
863
|
+
single.project = options.project;
|
|
864
|
+
idMapping[originalId] = newId;
|
|
865
|
+
});
|
|
866
|
+
return idMapping;
|
|
867
|
+
}
|
|
868
|
+
export(options) {
|
|
869
|
+
return this.model.db.find({ company: options.company, project: options.project }).toArray();
|
|
870
|
+
}
|
|
871
|
+
async import(importData, importHistoryData, idMapping, bulkHistory, options) {
|
|
872
|
+
const bulk = this.model.db.initializeUnorderedBulkOp();
|
|
873
|
+
[...importData, ...importHistoryData].forEach((participant) => {
|
|
874
|
+
participant.list = idMapping[participant.list?.toString()];
|
|
875
|
+
participant.user = idMapping[participant.user?.toString()];
|
|
876
|
+
participant.payment = idMapping[participant.payment?.toString()];
|
|
877
|
+
participant.agreements?.forEach((agreement) => {
|
|
878
|
+
if (agreement.id !== 'contact-dsgvo') {
|
|
879
|
+
agreement.id = idMapping[agreement.id]?.toString().toString();
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
});
|
|
883
|
+
importHistoryData.map((single) => {
|
|
884
|
+
const newParentId = idMapping[single.history.parent?.toString()];
|
|
885
|
+
single._id = new mongodb_1.ObjectId();
|
|
886
|
+
/**
|
|
887
|
+
* update the parent id
|
|
888
|
+
*/
|
|
889
|
+
single.history.parent = newParentId;
|
|
890
|
+
/**
|
|
891
|
+
* update the company and project to the new import data
|
|
892
|
+
*/
|
|
893
|
+
single.company = options.company;
|
|
894
|
+
single.project = options.project;
|
|
895
|
+
});
|
|
896
|
+
importData.map((single) => {
|
|
897
|
+
bulk.insert(single);
|
|
898
|
+
});
|
|
899
|
+
importHistoryData.map((single) => {
|
|
900
|
+
bulkHistory.insert(single);
|
|
901
|
+
});
|
|
902
|
+
return { bulk };
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
exports.ListParticipantsService = ListParticipantsService;
|
|
906
|
+
exports.default = new ListParticipantsService(process.env.PUBLISH_QUEUE_CONNECTION_STRING, process.env.STORAGE_ACCOUNT, 'check');
|
|
907
|
+
//# sourceMappingURL=listParticipants.service.js.map
|