@stamhoofd/models 2.119.0 → 2.120.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/factories/AddressFactory.d.ts.map +1 -0
- package/dist/factories/AddressFactory.js +38 -0
- package/dist/factories/AddressFactory.js.map +1 -0
- package/dist/factories/BalanceItemFactory.d.ts +29 -0
- package/dist/factories/BalanceItemFactory.d.ts.map +1 -0
- package/dist/factories/BalanceItemFactory.js +56 -0
- package/dist/factories/BalanceItemFactory.js.map +1 -0
- package/dist/factories/DocumentTemplateFactory.d.ts +22 -0
- package/dist/factories/DocumentTemplateFactory.d.ts.map +1 -0
- package/dist/factories/DocumentTemplateFactory.js +145 -0
- package/dist/factories/DocumentTemplateFactory.js.map +1 -0
- package/dist/factories/EmailTemplateFactory.d.ts +18 -0
- package/dist/factories/EmailTemplateFactory.d.ts.map +1 -0
- package/dist/factories/EmailTemplateFactory.js +39 -0
- package/dist/factories/EmailTemplateFactory.js.map +1 -0
- package/dist/factories/EmergencyContactFactory.d.ts.map +1 -0
- package/dist/factories/EmergencyContactFactory.js +38 -0
- package/dist/factories/EmergencyContactFactory.js.map +1 -0
- package/dist/factories/EventFactory.d.ts +19 -0
- package/dist/factories/EventFactory.d.ts.map +1 -0
- package/dist/factories/EventFactory.js +31 -0
- package/dist/factories/EventFactory.js.map +1 -0
- package/dist/factories/EventNotificationFactory.d.ts +23 -0
- package/dist/factories/EventNotificationFactory.d.ts.map +1 -0
- package/dist/factories/EventNotificationFactory.js +40 -0
- package/dist/factories/EventNotificationFactory.js.map +1 -0
- package/dist/factories/EventNotificationTypeFactory.d.ts +12 -0
- package/dist/factories/EventNotificationTypeFactory.d.ts.map +1 -0
- package/dist/factories/EventNotificationTypeFactory.js +21 -0
- package/dist/factories/EventNotificationTypeFactory.js.map +1 -0
- package/dist/factories/GroupFactory.d.ts +27 -0
- package/dist/factories/GroupFactory.d.ts.map +1 -0
- package/dist/factories/GroupFactory.js +88 -0
- package/dist/factories/GroupFactory.js.map +1 -0
- package/dist/factories/MemberFactory.d.ts +26 -0
- package/dist/factories/MemberFactory.d.ts.map +1 -0
- package/dist/factories/MemberFactory.js +131 -0
- package/dist/factories/MemberFactory.js.map +1 -0
- package/dist/factories/MemberResponsibilityRecordFactory.d.ts +15 -0
- package/dist/factories/MemberResponsibilityRecordFactory.d.ts.map +1 -0
- package/dist/factories/MemberResponsibilityRecordFactory.js +30 -0
- package/dist/factories/MemberResponsibilityRecordFactory.js.map +1 -0
- package/dist/factories/OrganizationFactory.d.ts +20 -0
- package/dist/factories/OrganizationFactory.d.ts.map +1 -0
- package/dist/factories/OrganizationFactory.js +61 -0
- package/dist/factories/OrganizationFactory.js.map +1 -0
- package/dist/factories/OrganizationRegistrationPeriodFactory.d.ts +13 -0
- package/dist/factories/OrganizationRegistrationPeriodFactory.d.ts.map +1 -0
- package/dist/factories/OrganizationRegistrationPeriodFactory.js +16 -0
- package/dist/factories/OrganizationRegistrationPeriodFactory.js.map +1 -0
- package/dist/factories/OrganizationTagFactory.d.ts.map +1 -0
- package/dist/factories/OrganizationTagFactory.js +19 -0
- package/dist/factories/OrganizationTagFactory.js.map +1 -0
- package/dist/factories/ParentFactory.d.ts.map +1 -0
- package/dist/factories/ParentFactory.js +39 -0
- package/dist/factories/ParentFactory.js.map +1 -0
- package/dist/factories/PlatformEventTypeFactory.d.ts.map +1 -0
- package/dist/factories/PlatformEventTypeFactory.js +23 -0
- package/dist/factories/PlatformEventTypeFactory.js.map +1 -0
- package/dist/factories/PlatformResponsibilityFactory.d.ts.map +1 -0
- package/dist/factories/PlatformResponsibilityFactory.js +21 -0
- package/dist/factories/PlatformResponsibilityFactory.js.map +1 -0
- package/dist/factories/RecordAnswerFactory.d.ts +18 -0
- package/dist/factories/RecordAnswerFactory.d.ts.map +1 -0
- package/dist/factories/RecordAnswerFactory.js +91 -0
- package/dist/factories/RecordAnswerFactory.js.map +1 -0
- package/dist/factories/RecordCategoryFactory.d.ts +11 -0
- package/dist/factories/RecordCategoryFactory.d.ts.map +1 -0
- package/dist/factories/RecordCategoryFactory.js +19 -0
- package/dist/factories/RecordCategoryFactory.js.map +1 -0
- package/dist/factories/RecordFactory.d.ts.map +1 -0
- package/dist/factories/RecordFactory.js +16 -0
- package/dist/factories/RecordFactory.js.map +1 -0
- package/dist/factories/RegisterCodeFactory.d.ts.map +1 -0
- package/dist/factories/RegisterCodeFactory.js +14 -0
- package/dist/factories/RegisterCodeFactory.js.map +1 -0
- package/dist/factories/RegistrationFactory.d.ts +21 -0
- package/dist/factories/RegistrationFactory.d.ts.map +1 -0
- package/dist/factories/RegistrationFactory.js +21 -0
- package/dist/factories/RegistrationFactory.js.map +1 -0
- package/dist/factories/RegistrationPeriodFactory.d.ts +16 -0
- package/dist/factories/RegistrationPeriodFactory.d.ts.map +1 -0
- package/dist/factories/RegistrationPeriodFactory.js +30 -0
- package/dist/factories/RegistrationPeriodFactory.js.map +1 -0
- package/dist/factories/STPackageFactory.d.ts +15 -0
- package/dist/factories/STPackageFactory.d.ts.map +1 -0
- package/dist/factories/STPackageFactory.js +34 -0
- package/dist/factories/STPackageFactory.js.map +1 -0
- package/dist/factories/UserFactory.d.ts +22 -0
- package/dist/factories/UserFactory.d.ts.map +1 -0
- package/dist/factories/UserFactory.js +63 -0
- package/dist/factories/UserFactory.js.map +1 -0
- package/dist/factories/WebshopFactory.d.ts +17 -0
- package/dist/factories/WebshopFactory.d.ts.map +1 -0
- package/dist/factories/WebshopFactory.js +35 -0
- package/dist/factories/WebshopFactory.js.map +1 -0
- package/dist/factories/index.d.ts.map +1 -0
- package/dist/factories/index.js +27 -0
- package/dist/factories/index.js.map +1 -0
- package/dist/helpers/DNSValidator.d.ts +6 -0
- package/dist/helpers/DNSValidator.d.ts.map +1 -0
- package/dist/helpers/DNSValidator.js +142 -0
- package/dist/helpers/DNSValidator.js.map +1 -0
- package/dist/helpers/EmailBuilder.d.ts +88 -0
- package/dist/helpers/EmailBuilder.d.ts.map +1 -0
- package/dist/helpers/EmailBuilder.js +603 -0
- package/dist/helpers/EmailBuilder.js.map +1 -0
- package/dist/helpers/Handlebars.d.ts.map +1 -0
- package/dist/helpers/Handlebars.js +244 -0
- package/dist/helpers/Handlebars.js.map +1 -0
- package/dist/helpers/MemberMerger.d.ts.map +1 -0
- package/dist/helpers/MemberMerger.js +364 -0
- package/dist/helpers/MemberMerger.js.map +1 -0
- package/dist/helpers/RateLimiter.d.ts.map +1 -0
- package/dist/helpers/RateLimiter.js +64 -0
- package/dist/helpers/RateLimiter.js.map +1 -0
- package/dist/helpers/WebshopCounter.d.ts +8 -0
- package/dist/helpers/WebshopCounter.d.ts.map +1 -0
- package/dist/helpers/WebshopCounter.js +46 -0
- package/dist/helpers/WebshopCounter.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/1605262045-import-postcodes.d.ts.map +1 -0
- package/dist/migrations/1605262045-import-postcodes.js +117 -0
- package/dist/migrations/1605262045-import-postcodes.js.map +1 -0
- package/dist/migrations/1605262046-import-postcodes-nl.d.ts.map +1 -0
- package/dist/migrations/1605262046-import-postcodes-nl.js +80 -0
- package/dist/migrations/1605262046-import-postcodes-nl.js.map +1 -0
- package/dist/migrations/1720080976-convert-charset-leads.d.ts +10 -0
- package/dist/migrations/1720080976-convert-charset-leads.d.ts.map +1 -0
- package/dist/migrations/1720080976-convert-charset-leads.js +41 -0
- package/dist/migrations/1720080976-convert-charset-leads.js.map +1 -0
- package/dist/models/AuditLog.d.ts.map +1 -0
- package/dist/models/AuditLog.js +94 -0
- package/dist/models/AuditLog.js.map +1 -0
- package/dist/models/BalanceItem.d.ts +218 -0
- package/dist/models/BalanceItem.d.ts.map +1 -0
- package/dist/models/BalanceItem.js +626 -0
- package/dist/models/BalanceItem.js.map +1 -0
- package/dist/models/BalanceItemPayment.d.ts +24 -0
- package/dist/models/BalanceItemPayment.d.ts.map +1 -0
- package/dist/models/BalanceItemPayment.js +65 -0
- package/dist/models/BalanceItemPayment.js.map +1 -0
- package/dist/models/BuckarooPayment.d.ts.map +1 -0
- package/dist/models/BuckarooPayment.js +24 -0
- package/dist/models/BuckarooPayment.js.map +1 -0
- package/dist/models/CachedBalance.d.ts +51 -0
- package/dist/models/CachedBalance.d.ts.map +1 -0
- package/dist/models/CachedBalance.js +390 -0
- package/dist/models/CachedBalance.js.map +1 -0
- package/dist/models/Document.d.ts +41 -0
- package/dist/models/Document.d.ts.map +1 -0
- package/dist/models/Document.js +251 -0
- package/dist/models/Document.js.map +1 -0
- package/dist/models/DocumentTemplate.d.ts +56 -0
- package/dist/models/DocumentTemplate.d.ts.map +1 -0
- package/dist/models/DocumentTemplate.js +719 -0
- package/dist/models/DocumentTemplate.js.map +1 -0
- package/dist/models/Email.d.ts +141 -0
- package/dist/models/Email.d.ts.map +1 -0
- package/dist/models/Email.js +1341 -0
- package/dist/models/Email.js.map +1 -0
- package/dist/models/EmailRecipient.d.ts.map +1 -0
- package/dist/models/EmailRecipient.js +194 -0
- package/dist/models/EmailRecipient.js.map +1 -0
- package/dist/models/EmailTemplate.d.ts +24 -0
- package/dist/models/EmailTemplate.d.ts.map +1 -0
- package/dist/models/EmailTemplate.js +79 -0
- package/dist/models/EmailTemplate.js.map +1 -0
- package/dist/models/EmailVerificationCode.d.ts +61 -0
- package/dist/models/EmailVerificationCode.d.ts.map +1 -0
- package/dist/models/EmailVerificationCode.js +339 -0
- package/dist/models/EmailVerificationCode.js.map +1 -0
- package/dist/models/Event.d.ts.map +1 -0
- package/dist/models/Event.js +132 -0
- package/dist/models/Event.js.map +1 -0
- package/dist/models/EventNotification.d.ts +32 -0
- package/dist/models/EventNotification.d.ts.map +1 -0
- package/dist/models/EventNotification.js +98 -0
- package/dist/models/EventNotification.js.map +1 -0
- package/dist/models/Group.d.ts +46 -0
- package/dist/models/Group.d.ts.map +1 -0
- package/dist/models/Group.js +213 -0
- package/dist/models/Group.js.map +1 -0
- package/dist/models/Image.d.ts +17 -0
- package/dist/models/Image.d.ts.map +1 -0
- package/dist/models/Image.js +169 -0
- package/dist/models/Image.js.map +1 -0
- package/dist/models/Invoice.d.ts.map +1 -0
- package/dist/models/Invoice.js +186 -0
- package/dist/models/Invoice.js.map +1 -0
- package/dist/models/InvoicedBalanceItem.d.ts +66 -0
- package/dist/models/InvoicedBalanceItem.d.ts.map +1 -0
- package/dist/models/InvoicedBalanceItem.js +130 -0
- package/dist/models/InvoicedBalanceItem.js.map +1 -0
- package/dist/models/Member.d.ts +114 -0
- package/dist/models/Member.d.ts.map +1 -0
- package/dist/models/Member.js +415 -0
- package/dist/models/Member.js.map +1 -0
- package/dist/models/MemberPlatformMembership.d.ts +48 -0
- package/dist/models/MemberPlatformMembership.d.ts.map +1 -0
- package/dist/models/MemberPlatformMembership.js +377 -0
- package/dist/models/MemberPlatformMembership.js.map +1 -0
- package/dist/models/MemberResponsibilityRecord.d.ts +17 -0
- package/dist/models/MemberResponsibilityRecord.d.ts.map +1 -0
- package/dist/models/MemberResponsibilityRecord.js +65 -0
- package/dist/models/MemberResponsibilityRecord.js.map +1 -0
- package/dist/models/MemberUser.d.ts.map +1 -0
- package/dist/models/MemberUser.js +22 -0
- package/dist/models/MemberUser.js.map +1 -0
- package/dist/models/MergedMember.d.ts +23 -0
- package/dist/models/MergedMember.d.ts.map +1 -0
- package/dist/models/MergedMember.js +123 -0
- package/dist/models/MergedMember.js.map +1 -0
- package/dist/models/MolliePayment.d.ts.map +1 -0
- package/dist/models/MolliePayment.js +24 -0
- package/dist/models/MolliePayment.js.map +1 -0
- package/dist/models/MollieToken.d.ts +45 -0
- package/dist/models/MollieToken.d.ts.map +1 -0
- package/dist/models/MollieToken.js +330 -0
- package/dist/models/MollieToken.js.map +1 -0
- package/dist/models/OneTimeToken.d.ts +38 -0
- package/dist/models/OneTimeToken.d.ts.map +1 -0
- package/dist/models/OneTimeToken.js +125 -0
- package/dist/models/OneTimeToken.js.map +1 -0
- package/dist/models/Order.d.ts +115 -0
- package/dist/models/Order.d.ts.map +1 -0
- package/dist/models/Order.js +908 -0
- package/dist/models/Order.js.map +1 -0
- package/dist/models/Organization.d.ts +128 -0
- package/dist/models/Organization.d.ts.map +1 -0
- package/dist/models/Organization.js +846 -0
- package/dist/models/Organization.js.map +1 -0
- package/dist/models/OrganizationRegistrationPeriod.d.ts +22 -0
- package/dist/models/OrganizationRegistrationPeriod.d.ts.map +1 -0
- package/dist/models/OrganizationRegistrationPeriod.js +129 -0
- package/dist/models/OrganizationRegistrationPeriod.js.map +1 -0
- package/dist/models/PasswordToken.d.ts +31 -0
- package/dist/models/PasswordToken.d.ts.map +1 -0
- package/dist/models/PasswordToken.js +129 -0
- package/dist/models/PasswordToken.js.map +1 -0
- package/dist/models/PayconiqPayment.d.ts +24 -0
- package/dist/models/PayconiqPayment.d.ts.map +1 -0
- package/dist/models/PayconiqPayment.js +272 -0
- package/dist/models/PayconiqPayment.js.map +1 -0
- package/dist/models/Payment.d.ts +120 -0
- package/dist/models/Payment.d.ts.map +1 -0
- package/dist/models/Payment.js +289 -0
- package/dist/models/Payment.js.map +1 -0
- package/dist/models/Platform.d.ts.map +1 -0
- package/dist/models/Platform.js +178 -0
- package/dist/models/Platform.js.map +1 -0
- package/dist/models/RegisterCode.d.ts.map +1 -0
- package/dist/models/RegisterCode.js +76 -0
- package/dist/models/RegisterCode.js.map +1 -0
- package/dist/models/Registration.d.ts +85 -0
- package/dist/models/Registration.d.ts.map +1 -0
- package/dist/models/Registration.js +190 -0
- package/dist/models/Registration.js.map +1 -0
- package/dist/models/RegistrationPeriod.d.ts.map +1 -0
- package/dist/models/RegistrationPeriod.js +140 -0
- package/dist/models/RegistrationPeriod.js.map +1 -0
- package/dist/models/STCredit.d.ts.map +1 -0
- package/dist/models/STCredit.js +61 -0
- package/dist/models/STCredit.js.map +1 -0
- package/dist/models/STInvoice.d.ts +37 -0
- package/dist/models/STInvoice.d.ts.map +1 -0
- package/dist/models/STInvoice.js +139 -0
- package/dist/models/STInvoice.js.map +1 -0
- package/dist/models/STPackage.d.ts.map +1 -0
- package/dist/models/STPackage.js +276 -0
- package/dist/models/STPackage.js.map +1 -0
- package/dist/models/STPendingInvoice.d.ts +26 -0
- package/dist/models/STPendingInvoice.d.ts.map +1 -0
- package/dist/models/STPendingInvoice.js +68 -0
- package/dist/models/STPendingInvoice.js.map +1 -0
- package/dist/models/StripeAccount.d.ts.map +1 -0
- package/dist/models/StripeAccount.js +81 -0
- package/dist/models/StripeAccount.js.map +1 -0
- package/dist/models/StripeCheckoutSession.d.ts.map +1 -0
- package/dist/models/StripeCheckoutSession.js +35 -0
- package/dist/models/StripeCheckoutSession.js.map +1 -0
- package/dist/models/StripePaymentIntent.d.ts.map +1 -0
- package/dist/models/StripePaymentIntent.js +35 -0
- package/dist/models/StripePaymentIntent.js.map +1 -0
- package/dist/models/Ticket.d.ts +65 -0
- package/dist/models/Ticket.d.ts.map +1 -0
- package/dist/models/Ticket.js +157 -0
- package/dist/models/Ticket.js.map +1 -0
- package/dist/models/Token.d.ts +48 -0
- package/dist/models/Token.d.ts.map +1 -0
- package/dist/models/Token.js +208 -0
- package/dist/models/Token.js.map +1 -0
- package/dist/models/UitpasClientCredential.d.ts.map +1 -0
- package/dist/models/UitpasClientCredential.js +62 -0
- package/dist/models/UitpasClientCredential.js.map +1 -0
- package/dist/models/UsedRegisterCode.d.ts.map +1 -0
- package/dist/models/UsedRegisterCode.js +58 -0
- package/dist/models/UsedRegisterCode.js.map +1 -0
- package/dist/models/User.d.ts +76 -0
- package/dist/models/User.d.ts.map +1 -0
- package/dist/models/User.js +484 -0
- package/dist/models/User.js.map +1 -0
- package/dist/models/UserPermissions.d.ts +16 -0
- package/dist/models/UserPermissions.d.ts.map +1 -0
- package/dist/models/UserPermissions.js +56 -0
- package/dist/models/UserPermissions.js.map +1 -0
- package/dist/models/Webshop.d.ts +45 -0
- package/dist/models/Webshop.d.ts.map +1 -0
- package/dist/models/Webshop.js +187 -0
- package/dist/models/Webshop.js.map +1 -0
- package/dist/models/WebshopDiscountCode.d.ts.map +1 -0
- package/dist/models/WebshopDiscountCode.js +89 -0
- package/dist/models/WebshopDiscountCode.js.map +1 -0
- package/dist/models/WebshopUitpasNumber.d.ts.map +1 -0
- package/dist/models/WebshopUitpasNumber.js +91 -0
- package/dist/models/WebshopUitpasNumber.js.map +1 -0
- package/dist/models/_relations.d.ts +8 -0
- package/dist/models/_relations.d.ts.map +1 -0
- package/dist/models/_relations.js +110 -0
- package/dist/models/_relations.js.map +1 -0
- package/dist/models/addresses/City.d.ts +15 -0
- package/dist/models/addresses/City.d.ts.map +1 -0
- package/dist/models/addresses/City.js +35 -0
- package/dist/models/addresses/City.js.map +1 -0
- package/dist/models/addresses/PostalCode.d.ts +21 -0
- package/dist/models/addresses/PostalCode.d.ts.map +1 -0
- package/dist/models/addresses/PostalCode.js +139 -0
- package/dist/models/addresses/PostalCode.js.map +1 -0
- package/dist/models/addresses/Province.d.ts +9 -0
- package/dist/models/addresses/Province.d.ts.map +1 -0
- package/dist/models/addresses/Province.js +24 -0
- package/dist/models/addresses/Province.js.map +1 -0
- package/dist/models/addresses/Street.d.ts.map +1 -0
- package/dist/models/addresses/Street.js +26 -0
- package/dist/models/addresses/Street.js.map +1 -0
- package/dist/models/index.d.ts +55 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +55 -0
- package/dist/models/index.js.map +1 -0
- package/dist/structures/OrganizationServerMetaData.d.ts.map +1 -0
- package/dist/structures/OrganizationServerMetaData.js +130 -0
- package/dist/structures/OrganizationServerMetaData.js.map +1 -0
- package/package.json +13 -10
- package/src/factories/AddressFactory.ts +3 -2
- package/src/factories/BalanceItemFactory.ts +2 -1
- package/src/factories/DocumentTemplateFactory.ts +2 -1
- package/src/factories/EmailTemplateFactory.ts +3 -2
- package/src/factories/EmergencyContactFactory.ts +1 -1
- package/src/factories/EventFactory.ts +2 -2
- package/src/factories/EventNotificationFactory.ts +6 -4
- package/src/factories/EventNotificationTypeFactory.ts +2 -1
- package/src/factories/GroupFactory.ts +4 -3
- package/src/factories/MemberFactory.ts +6 -5
- package/src/factories/MemberResponsibilityRecordFactory.ts +3 -2
- package/src/factories/OrganizationFactory.ts +4 -2
- package/src/factories/OrganizationRegistrationPeriodFactory.ts +2 -2
- package/src/factories/ParentFactory.ts +1 -1
- package/src/factories/RecordAnswerFactory.ts +2 -1
- package/src/factories/RecordCategoryFactory.ts +4 -2
- package/src/factories/RegistrationFactory.ts +5 -4
- package/src/factories/RegistrationPeriodFactory.ts +2 -1
- package/src/factories/STPackageFactory.ts +1 -1
- package/src/factories/UserFactory.ts +3 -2
- package/src/factories/WebshopFactory.ts +3 -2
- package/src/helpers/DNSValidator.ts +2 -1
- package/src/helpers/EmailBuilder.ts +13 -4
- package/src/helpers/Handlebars.ts +3 -3
- package/src/helpers/MemberMerger.test.ts +1 -1
- package/src/helpers/MemberMerger.ts +5 -4
- package/src/helpers/WebshopCounter.ts +1 -1
- package/src/migrations/1605262045-import-postcodes.ts +1 -1
- package/src/migrations/1605262046-import-postcodes-nl.ts +2 -2
- package/src/migrations/1720080976-convert-charset-leads.ts +53 -0
- package/src/models/AuditLog.ts +2 -1
- package/src/models/BalanceItem.ts +4 -3
- package/src/models/BalanceItemPayment.ts +9 -6
- package/src/models/CachedBalance.test.ts +331 -0
- package/src/models/CachedBalance.ts +3 -2
- package/src/models/Document.ts +2 -2
- package/src/models/DocumentTemplate.ts +5 -3
- package/src/models/Email.test.ts +32 -31
- package/src/models/Email.ts +7 -4
- package/src/models/EmailTemplate.ts +2 -1
- package/src/models/EmailVerificationCode.ts +7 -5
- package/src/models/EventNotification.ts +3 -2
- package/src/models/Group.ts +5 -15
- package/src/models/Image.ts +2 -1
- package/src/models/InvoicedBalanceItem.ts +9 -8
- package/src/models/Member.ts +8 -4
- package/src/models/MemberPlatformMembership.ts +1 -1
- package/src/models/MemberResponsibilityRecord.ts +2 -1
- package/src/models/MergedMember.ts +1 -1
- package/src/models/MollieToken.ts +3 -3
- package/src/models/OneTimeToken.ts +1 -1
- package/src/models/Order.ts +17 -9
- package/src/models/Organization.ts +39 -11
- package/src/models/OrganizationRegistrationPeriod.ts +2 -2
- package/src/models/PasswordToken.ts +7 -5
- package/src/models/PayconiqPayment.ts +6 -3
- package/src/models/Payment.ts +8 -5
- package/src/models/Registration.ts +9 -97
- package/src/models/STInvoice.ts +1 -4
- package/src/models/STPackage.ts +1 -1
- package/src/models/STPendingInvoice.ts +5 -4
- package/src/models/Ticket.ts +11 -9
- package/src/models/Token.test.ts +2 -2
- package/src/models/Token.ts +6 -6
- package/src/models/User.ts +7 -8
- package/src/models/UserPermissions.ts +7 -6
- package/src/models/Webshop.ts +5 -5
- package/src/models/_relations.ts +133 -0
- package/src/models/addresses/City.ts +1 -1
- package/src/models/addresses/PostalCode.test.ts +1 -1
- package/src/models/addresses/PostalCode.ts +1 -1
- package/src/models/addresses/Province.ts +1 -1
- package/src/models/index.ts +22 -20
- package/src/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/dist/src/factories/AddressFactory.d.ts.map +0 -1
- package/dist/src/factories/AddressFactory.js +0 -42
- package/dist/src/factories/AddressFactory.js.map +0 -1
- package/dist/src/factories/BalanceItemFactory.d.ts +0 -28
- package/dist/src/factories/BalanceItemFactory.d.ts.map +0 -1
- package/dist/src/factories/BalanceItemFactory.js +0 -60
- package/dist/src/factories/BalanceItemFactory.js.map +0 -1
- package/dist/src/factories/DocumentTemplateFactory.d.ts +0 -21
- package/dist/src/factories/DocumentTemplateFactory.d.ts.map +0 -1
- package/dist/src/factories/DocumentTemplateFactory.js +0 -149
- package/dist/src/factories/DocumentTemplateFactory.js.map +0 -1
- package/dist/src/factories/EmailTemplateFactory.d.ts +0 -18
- package/dist/src/factories/EmailTemplateFactory.d.ts.map +0 -1
- package/dist/src/factories/EmailTemplateFactory.js +0 -43
- package/dist/src/factories/EmailTemplateFactory.js.map +0 -1
- package/dist/src/factories/EmergencyContactFactory.d.ts.map +0 -1
- package/dist/src/factories/EmergencyContactFactory.js +0 -42
- package/dist/src/factories/EmergencyContactFactory.js.map +0 -1
- package/dist/src/factories/EventFactory.d.ts +0 -19
- package/dist/src/factories/EventFactory.d.ts.map +0 -1
- package/dist/src/factories/EventFactory.js +0 -35
- package/dist/src/factories/EventFactory.js.map +0 -1
- package/dist/src/factories/EventNotificationFactory.d.ts +0 -21
- package/dist/src/factories/EventNotificationFactory.d.ts.map +0 -1
- package/dist/src/factories/EventNotificationFactory.js +0 -44
- package/dist/src/factories/EventNotificationFactory.js.map +0 -1
- package/dist/src/factories/EventNotificationTypeFactory.d.ts +0 -11
- package/dist/src/factories/EventNotificationTypeFactory.d.ts.map +0 -1
- package/dist/src/factories/EventNotificationTypeFactory.js +0 -25
- package/dist/src/factories/EventNotificationTypeFactory.js.map +0 -1
- package/dist/src/factories/GroupFactory.d.ts +0 -26
- package/dist/src/factories/GroupFactory.d.ts.map +0 -1
- package/dist/src/factories/GroupFactory.js +0 -92
- package/dist/src/factories/GroupFactory.js.map +0 -1
- package/dist/src/factories/MemberFactory.d.ts +0 -26
- package/dist/src/factories/MemberFactory.d.ts.map +0 -1
- package/dist/src/factories/MemberFactory.js +0 -135
- package/dist/src/factories/MemberFactory.js.map +0 -1
- package/dist/src/factories/MemberResponsibilityRecordFactory.d.ts +0 -14
- package/dist/src/factories/MemberResponsibilityRecordFactory.d.ts.map +0 -1
- package/dist/src/factories/MemberResponsibilityRecordFactory.js +0 -34
- package/dist/src/factories/MemberResponsibilityRecordFactory.js.map +0 -1
- package/dist/src/factories/OrganizationFactory.d.ts +0 -19
- package/dist/src/factories/OrganizationFactory.d.ts.map +0 -1
- package/dist/src/factories/OrganizationFactory.js +0 -64
- package/dist/src/factories/OrganizationFactory.js.map +0 -1
- package/dist/src/factories/OrganizationRegistrationPeriodFactory.d.ts +0 -13
- package/dist/src/factories/OrganizationRegistrationPeriodFactory.d.ts.map +0 -1
- package/dist/src/factories/OrganizationRegistrationPeriodFactory.js +0 -20
- package/dist/src/factories/OrganizationRegistrationPeriodFactory.js.map +0 -1
- package/dist/src/factories/OrganizationTagFactory.d.ts.map +0 -1
- package/dist/src/factories/OrganizationTagFactory.js +0 -23
- package/dist/src/factories/OrganizationTagFactory.js.map +0 -1
- package/dist/src/factories/ParentFactory.d.ts.map +0 -1
- package/dist/src/factories/ParentFactory.js +0 -43
- package/dist/src/factories/ParentFactory.js.map +0 -1
- package/dist/src/factories/PlatformEventTypeFactory.d.ts.map +0 -1
- package/dist/src/factories/PlatformEventTypeFactory.js +0 -27
- package/dist/src/factories/PlatformEventTypeFactory.js.map +0 -1
- package/dist/src/factories/PlatformResponsibilityFactory.d.ts.map +0 -1
- package/dist/src/factories/PlatformResponsibilityFactory.js +0 -25
- package/dist/src/factories/PlatformResponsibilityFactory.js.map +0 -1
- package/dist/src/factories/RecordAnswerFactory.d.ts +0 -17
- package/dist/src/factories/RecordAnswerFactory.d.ts.map +0 -1
- package/dist/src/factories/RecordAnswerFactory.js +0 -95
- package/dist/src/factories/RecordAnswerFactory.js.map +0 -1
- package/dist/src/factories/RecordCategoryFactory.d.ts +0 -11
- package/dist/src/factories/RecordCategoryFactory.d.ts.map +0 -1
- package/dist/src/factories/RecordCategoryFactory.js +0 -23
- package/dist/src/factories/RecordCategoryFactory.js.map +0 -1
- package/dist/src/factories/RecordFactory.d.ts.map +0 -1
- package/dist/src/factories/RecordFactory.js +0 -21
- package/dist/src/factories/RecordFactory.js.map +0 -1
- package/dist/src/factories/RegisterCodeFactory.d.ts.map +0 -1
- package/dist/src/factories/RegisterCodeFactory.js +0 -18
- package/dist/src/factories/RegisterCodeFactory.js.map +0 -1
- package/dist/src/factories/RegistrationFactory.d.ts +0 -21
- package/dist/src/factories/RegistrationFactory.d.ts.map +0 -1
- package/dist/src/factories/RegistrationFactory.js +0 -25
- package/dist/src/factories/RegistrationFactory.js.map +0 -1
- package/dist/src/factories/RegistrationPeriodFactory.d.ts +0 -15
- package/dist/src/factories/RegistrationPeriodFactory.d.ts.map +0 -1
- package/dist/src/factories/RegistrationPeriodFactory.js +0 -34
- package/dist/src/factories/RegistrationPeriodFactory.js.map +0 -1
- package/dist/src/factories/STPackageFactory.d.ts +0 -15
- package/dist/src/factories/STPackageFactory.d.ts.map +0 -1
- package/dist/src/factories/STPackageFactory.js +0 -38
- package/dist/src/factories/STPackageFactory.js.map +0 -1
- package/dist/src/factories/UserFactory.d.ts +0 -22
- package/dist/src/factories/UserFactory.d.ts.map +0 -1
- package/dist/src/factories/UserFactory.js +0 -67
- package/dist/src/factories/UserFactory.js.map +0 -1
- package/dist/src/factories/WebshopFactory.d.ts +0 -16
- package/dist/src/factories/WebshopFactory.d.ts.map +0 -1
- package/dist/src/factories/WebshopFactory.js +0 -39
- package/dist/src/factories/WebshopFactory.js.map +0 -1
- package/dist/src/factories/index.d.ts.map +0 -1
- package/dist/src/factories/index.js +0 -30
- package/dist/src/factories/index.js.map +0 -1
- package/dist/src/helpers/DNSValidator.d.ts +0 -6
- package/dist/src/helpers/DNSValidator.d.ts.map +0 -1
- package/dist/src/helpers/DNSValidator.js +0 -145
- package/dist/src/helpers/DNSValidator.js.map +0 -1
- package/dist/src/helpers/EmailBuilder.d.ts +0 -83
- package/dist/src/helpers/EmailBuilder.d.ts.map +0 -1
- package/dist/src/helpers/EmailBuilder.js +0 -646
- package/dist/src/helpers/EmailBuilder.js.map +0 -1
- package/dist/src/helpers/Handlebars.d.ts.map +0 -1
- package/dist/src/helpers/Handlebars.js +0 -248
- package/dist/src/helpers/Handlebars.js.map +0 -1
- package/dist/src/helpers/MemberMerger.d.ts.map +0 -1
- package/dist/src/helpers/MemberMerger.js +0 -371
- package/dist/src/helpers/MemberMerger.js.map +0 -1
- package/dist/src/helpers/MemberMerger.test.d.ts +0 -2
- package/dist/src/helpers/MemberMerger.test.d.ts.map +0 -1
- package/dist/src/helpers/MemberMerger.test.js +0 -644
- package/dist/src/helpers/MemberMerger.test.js.map +0 -1
- package/dist/src/helpers/RateLimiter.d.ts.map +0 -1
- package/dist/src/helpers/RateLimiter.js +0 -69
- package/dist/src/helpers/RateLimiter.js.map +0 -1
- package/dist/src/helpers/WebshopCounter.d.ts +0 -8
- package/dist/src/helpers/WebshopCounter.d.ts.map +0 -1
- package/dist/src/helpers/WebshopCounter.js +0 -50
- package/dist/src/helpers/WebshopCounter.js.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -14
- package/dist/src/index.js.map +0 -1
- package/dist/src/migrations/1605262045-import-postcodes.js +0 -121
- package/dist/src/migrations/1605262046-import-postcodes-nl.js +0 -83
- package/dist/src/models/AuditLog.d.ts.map +0 -1
- package/dist/src/models/AuditLog.js +0 -98
- package/dist/src/models/AuditLog.js.map +0 -1
- package/dist/src/models/BalanceItem.d.ts +0 -217
- package/dist/src/models/BalanceItem.d.ts.map +0 -1
- package/dist/src/models/BalanceItem.js +0 -630
- package/dist/src/models/BalanceItem.js.map +0 -1
- package/dist/src/models/BalanceItemPayment.d.ts +0 -23
- package/dist/src/models/BalanceItemPayment.d.ts.map +0 -1
- package/dist/src/models/BalanceItemPayment.js +0 -70
- package/dist/src/models/BalanceItemPayment.js.map +0 -1
- package/dist/src/models/BuckarooPayment.d.ts.map +0 -1
- package/dist/src/models/BuckarooPayment.js +0 -28
- package/dist/src/models/BuckarooPayment.js.map +0 -1
- package/dist/src/models/CachedBalance.d.ts +0 -50
- package/dist/src/models/CachedBalance.d.ts.map +0 -1
- package/dist/src/models/CachedBalance.js +0 -394
- package/dist/src/models/CachedBalance.js.map +0 -1
- package/dist/src/models/Document.d.ts +0 -41
- package/dist/src/models/Document.d.ts.map +0 -1
- package/dist/src/models/Document.js +0 -255
- package/dist/src/models/Document.js.map +0 -1
- package/dist/src/models/DocumentTemplate.d.ts +0 -55
- package/dist/src/models/DocumentTemplate.d.ts.map +0 -1
- package/dist/src/models/DocumentTemplate.js +0 -723
- package/dist/src/models/DocumentTemplate.js.map +0 -1
- package/dist/src/models/DocumentTemplate.test.d.ts +0 -2
- package/dist/src/models/DocumentTemplate.test.d.ts.map +0 -1
- package/dist/src/models/DocumentTemplate.test.js +0 -57
- package/dist/src/models/DocumentTemplate.test.js.map +0 -1
- package/dist/src/models/Email.d.ts +0 -140
- package/dist/src/models/Email.d.ts.map +0 -1
- package/dist/src/models/Email.js +0 -1345
- package/dist/src/models/Email.js.map +0 -1
- package/dist/src/models/Email.test.d.ts +0 -2
- package/dist/src/models/Email.test.d.ts.map +0 -1
- package/dist/src/models/Email.test.js +0 -1036
- package/dist/src/models/Email.test.js.map +0 -1
- package/dist/src/models/EmailRecipient.d.ts.map +0 -1
- package/dist/src/models/EmailRecipient.js +0 -198
- package/dist/src/models/EmailRecipient.js.map +0 -1
- package/dist/src/models/EmailTemplate.d.ts +0 -23
- package/dist/src/models/EmailTemplate.d.ts.map +0 -1
- package/dist/src/models/EmailTemplate.js +0 -83
- package/dist/src/models/EmailTemplate.js.map +0 -1
- package/dist/src/models/EmailVerificationCode.d.ts +0 -59
- package/dist/src/models/EmailVerificationCode.d.ts.map +0 -1
- package/dist/src/models/EmailVerificationCode.js +0 -343
- package/dist/src/models/EmailVerificationCode.js.map +0 -1
- package/dist/src/models/Event.d.ts.map +0 -1
- package/dist/src/models/Event.js +0 -136
- package/dist/src/models/Event.js.map +0 -1
- package/dist/src/models/EventNotification.d.ts +0 -31
- package/dist/src/models/EventNotification.d.ts.map +0 -1
- package/dist/src/models/EventNotification.js +0 -102
- package/dist/src/models/EventNotification.js.map +0 -1
- package/dist/src/models/Group.d.ts +0 -45
- package/dist/src/models/Group.d.ts.map +0 -1
- package/dist/src/models/Group.js +0 -228
- package/dist/src/models/Group.js.map +0 -1
- package/dist/src/models/Image.d.ts +0 -16
- package/dist/src/models/Image.d.ts.map +0 -1
- package/dist/src/models/Image.js +0 -173
- package/dist/src/models/Image.js.map +0 -1
- package/dist/src/models/Invoice.d.ts.map +0 -1
- package/dist/src/models/Invoice.js +0 -190
- package/dist/src/models/Invoice.js.map +0 -1
- package/dist/src/models/InvoicedBalanceItem.d.ts +0 -66
- package/dist/src/models/InvoicedBalanceItem.d.ts.map +0 -1
- package/dist/src/models/InvoicedBalanceItem.js +0 -136
- package/dist/src/models/InvoicedBalanceItem.js.map +0 -1
- package/dist/src/models/Member.d.ts +0 -112
- package/dist/src/models/Member.d.ts.map +0 -1
- package/dist/src/models/Member.js +0 -415
- package/dist/src/models/Member.js.map +0 -1
- package/dist/src/models/MemberPlatformMembership.d.ts +0 -48
- package/dist/src/models/MemberPlatformMembership.d.ts.map +0 -1
- package/dist/src/models/MemberPlatformMembership.js +0 -381
- package/dist/src/models/MemberPlatformMembership.js.map +0 -1
- package/dist/src/models/MemberResponsibilityRecord.d.ts +0 -16
- package/dist/src/models/MemberResponsibilityRecord.d.ts.map +0 -1
- package/dist/src/models/MemberResponsibilityRecord.js +0 -69
- package/dist/src/models/MemberResponsibilityRecord.js.map +0 -1
- package/dist/src/models/MemberUser.d.ts.map +0 -1
- package/dist/src/models/MemberUser.js +0 -26
- package/dist/src/models/MemberUser.js.map +0 -1
- package/dist/src/models/MergedMember.d.ts +0 -23
- package/dist/src/models/MergedMember.d.ts.map +0 -1
- package/dist/src/models/MergedMember.js +0 -127
- package/dist/src/models/MergedMember.js.map +0 -1
- package/dist/src/models/MolliePayment.d.ts.map +0 -1
- package/dist/src/models/MolliePayment.js +0 -28
- package/dist/src/models/MolliePayment.js.map +0 -1
- package/dist/src/models/MollieToken.d.ts +0 -45
- package/dist/src/models/MollieToken.d.ts.map +0 -1
- package/dist/src/models/MollieToken.js +0 -334
- package/dist/src/models/MollieToken.js.map +0 -1
- package/dist/src/models/OneTimeToken.d.ts +0 -38
- package/dist/src/models/OneTimeToken.d.ts.map +0 -1
- package/dist/src/models/OneTimeToken.js +0 -129
- package/dist/src/models/OneTimeToken.js.map +0 -1
- package/dist/src/models/Order.d.ts +0 -112
- package/dist/src/models/Order.d.ts.map +0 -1
- package/dist/src/models/Order.js +0 -906
- package/dist/src/models/Order.js.map +0 -1
- package/dist/src/models/Organization.d.ts +0 -120
- package/dist/src/models/Organization.d.ts.map +0 -1
- package/dist/src/models/Organization.js +0 -828
- package/dist/src/models/Organization.js.map +0 -1
- package/dist/src/models/OrganizationRegistrationPeriod.d.ts +0 -22
- package/dist/src/models/OrganizationRegistrationPeriod.d.ts.map +0 -1
- package/dist/src/models/OrganizationRegistrationPeriod.js +0 -133
- package/dist/src/models/OrganizationRegistrationPeriod.js.map +0 -1
- package/dist/src/models/PasswordToken.d.ts +0 -30
- package/dist/src/models/PasswordToken.d.ts.map +0 -1
- package/dist/src/models/PasswordToken.js +0 -133
- package/dist/src/models/PasswordToken.js.map +0 -1
- package/dist/src/models/PayconiqPayment.d.ts +0 -22
- package/dist/src/models/PayconiqPayment.d.ts.map +0 -1
- package/dist/src/models/PayconiqPayment.js +0 -276
- package/dist/src/models/PayconiqPayment.js.map +0 -1
- package/dist/src/models/Payment.d.ts +0 -117
- package/dist/src/models/Payment.d.ts.map +0 -1
- package/dist/src/models/Payment.js +0 -293
- package/dist/src/models/Payment.js.map +0 -1
- package/dist/src/models/Platform.d.ts.map +0 -1
- package/dist/src/models/Platform.js +0 -182
- package/dist/src/models/Platform.js.map +0 -1
- package/dist/src/models/Platform.test.d.ts +0 -2
- package/dist/src/models/Platform.test.d.ts.map +0 -1
- package/dist/src/models/Platform.test.js +0 -90
- package/dist/src/models/Platform.test.js.map +0 -1
- package/dist/src/models/RegisterCode.d.ts.map +0 -1
- package/dist/src/models/RegisterCode.js +0 -80
- package/dist/src/models/RegisterCode.js.map +0 -1
- package/dist/src/models/Registration.d.ts +0 -93
- package/dist/src/models/Registration.d.ts.map +0 -1
- package/dist/src/models/Registration.js +0 -267
- package/dist/src/models/Registration.js.map +0 -1
- package/dist/src/models/RegistrationPeriod.d.ts.map +0 -1
- package/dist/src/models/RegistrationPeriod.js +0 -144
- package/dist/src/models/RegistrationPeriod.js.map +0 -1
- package/dist/src/models/STCredit.d.ts.map +0 -1
- package/dist/src/models/STCredit.js +0 -65
- package/dist/src/models/STCredit.js.map +0 -1
- package/dist/src/models/STInvoice.d.ts +0 -37
- package/dist/src/models/STInvoice.d.ts.map +0 -1
- package/dist/src/models/STInvoice.js +0 -145
- package/dist/src/models/STInvoice.js.map +0 -1
- package/dist/src/models/STPackage.d.ts.map +0 -1
- package/dist/src/models/STPackage.js +0 -280
- package/dist/src/models/STPackage.js.map +0 -1
- package/dist/src/models/STPendingInvoice.d.ts +0 -26
- package/dist/src/models/STPendingInvoice.d.ts.map +0 -1
- package/dist/src/models/STPendingInvoice.js +0 -73
- package/dist/src/models/STPendingInvoice.js.map +0 -1
- package/dist/src/models/StripeAccount.d.ts.map +0 -1
- package/dist/src/models/StripeAccount.js +0 -85
- package/dist/src/models/StripeAccount.js.map +0 -1
- package/dist/src/models/StripeCheckoutSession.d.ts.map +0 -1
- package/dist/src/models/StripeCheckoutSession.js +0 -39
- package/dist/src/models/StripeCheckoutSession.js.map +0 -1
- package/dist/src/models/StripePaymentIntent.d.ts.map +0 -1
- package/dist/src/models/StripePaymentIntent.js +0 -39
- package/dist/src/models/StripePaymentIntent.js.map +0 -1
- package/dist/src/models/Ticket.d.ts +0 -63
- package/dist/src/models/Ticket.d.ts.map +0 -1
- package/dist/src/models/Ticket.js +0 -162
- package/dist/src/models/Ticket.js.map +0 -1
- package/dist/src/models/Token.d.ts +0 -48
- package/dist/src/models/Token.d.ts.map +0 -1
- package/dist/src/models/Token.js +0 -212
- package/dist/src/models/Token.js.map +0 -1
- package/dist/src/models/Token.test.d.ts +0 -2
- package/dist/src/models/Token.test.d.ts.map +0 -1
- package/dist/src/models/Token.test.js +0 -60
- package/dist/src/models/Token.test.js.map +0 -1
- package/dist/src/models/UitpasClientCredential.d.ts.map +0 -1
- package/dist/src/models/UitpasClientCredential.js +0 -66
- package/dist/src/models/UitpasClientCredential.js.map +0 -1
- package/dist/src/models/UsedRegisterCode.d.ts.map +0 -1
- package/dist/src/models/UsedRegisterCode.js +0 -62
- package/dist/src/models/UsedRegisterCode.js.map +0 -1
- package/dist/src/models/User.d.ts +0 -77
- package/dist/src/models/User.d.ts.map +0 -1
- package/dist/src/models/User.js +0 -490
- package/dist/src/models/User.js.map +0 -1
- package/dist/src/models/UserPermissions.d.ts +0 -16
- package/dist/src/models/UserPermissions.d.ts.map +0 -1
- package/dist/src/models/UserPermissions.js +0 -61
- package/dist/src/models/UserPermissions.js.map +0 -1
- package/dist/src/models/Webshop.d.ts +0 -45
- package/dist/src/models/Webshop.d.ts.map +0 -1
- package/dist/src/models/Webshop.js +0 -192
- package/dist/src/models/Webshop.js.map +0 -1
- package/dist/src/models/WebshopDiscountCode.d.ts.map +0 -1
- package/dist/src/models/WebshopDiscountCode.js +0 -93
- package/dist/src/models/WebshopDiscountCode.js.map +0 -1
- package/dist/src/models/WebshopUitpasNumber.d.ts.map +0 -1
- package/dist/src/models/WebshopUitpasNumber.js +0 -95
- package/dist/src/models/WebshopUitpasNumber.js.map +0 -1
- package/dist/src/models/addresses/City.d.ts +0 -15
- package/dist/src/models/addresses/City.d.ts.map +0 -1
- package/dist/src/models/addresses/City.js +0 -39
- package/dist/src/models/addresses/City.js.map +0 -1
- package/dist/src/models/addresses/PostalCode.d.ts +0 -21
- package/dist/src/models/addresses/PostalCode.d.ts.map +0 -1
- package/dist/src/models/addresses/PostalCode.js +0 -143
- package/dist/src/models/addresses/PostalCode.js.map +0 -1
- package/dist/src/models/addresses/PostalCode.test.d.ts +0 -2
- package/dist/src/models/addresses/PostalCode.test.d.ts.map +0 -1
- package/dist/src/models/addresses/PostalCode.test.js +0 -98
- package/dist/src/models/addresses/PostalCode.test.js.map +0 -1
- package/dist/src/models/addresses/Province.d.ts +0 -9
- package/dist/src/models/addresses/Province.d.ts.map +0 -1
- package/dist/src/models/addresses/Province.js +0 -28
- package/dist/src/models/addresses/Province.js.map +0 -1
- package/dist/src/models/addresses/Street.d.ts.map +0 -1
- package/dist/src/models/addresses/Street.js +0 -30
- package/dist/src/models/addresses/Street.js.map +0 -1
- package/dist/src/models/index.d.ts +0 -54
- package/dist/src/models/index.d.ts.map +0 -1
- package/dist/src/models/index.js +0 -69
- package/dist/src/models/index.js.map +0 -1
- package/dist/src/structures/OrganizationServerMetaData.d.ts.map +0 -1
- package/dist/src/structures/OrganizationServerMetaData.js +0 -135
- package/dist/src/structures/OrganizationServerMetaData.js.map +0 -1
- package/dist/tests/jest.global.setup.d.ts +0 -3
- package/dist/tests/jest.global.setup.d.ts.map +0 -1
- package/dist/tests/jest.global.setup.js +0 -33
- package/dist/tests/jest.global.setup.js.map +0 -1
- package/dist/tests/jest.setup.d.ts +0 -2
- package/dist/tests/jest.setup.d.ts.map +0 -1
- package/dist/tests/jest.setup.js +0 -32
- package/dist/tests/jest.setup.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/dist/{src/assets → assets}/Metropolis-Black.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-BlackItalic.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-Bold.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-BoldItalic.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-ExtraBold.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-ExtraBoldItalic.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-ExtraLight.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-ExtraLightItalic.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-Light.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-LightItalic.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-Medium.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-MediumItalic.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-Regular.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-RegularItalic.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-SemiBold.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-SemiBoldItalic.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-Thin.woff2 +0 -0
- /package/dist/{src/assets → assets}/Metropolis-ThinItalic.woff2 +0 -0
- /package/dist/{src/assets → assets}/logo.png +0 -0
- /package/dist/{src/factories → factories}/AddressFactory.d.ts +0 -0
- /package/dist/{src/factories → factories}/EmergencyContactFactory.d.ts +0 -0
- /package/dist/{src/factories → factories}/OrganizationTagFactory.d.ts +0 -0
- /package/dist/{src/factories → factories}/ParentFactory.d.ts +0 -0
- /package/dist/{src/factories → factories}/PlatformEventTypeFactory.d.ts +0 -0
- /package/dist/{src/factories → factories}/PlatformResponsibilityFactory.d.ts +0 -0
- /package/dist/{src/factories → factories}/RecordFactory.d.ts +0 -0
- /package/dist/{src/factories → factories}/RegisterCodeFactory.d.ts +0 -0
- /package/dist/{src/factories → factories}/index.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/Handlebars.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/MemberMerger.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/RateLimiter.d.ts +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{src/migrations → migrations}/1593773929-create-initial-tables.sql +0 -0
- /package/dist/{src/migrations → migrations}/1605261999-gemeenten-tmp.sql +0 -0
- /package/dist/{src/migrations → migrations}/1605262045-import-postcodes.d.ts +0 -0
- /package/dist/{src/migrations → migrations}/1605262046-import-postcodes-nl.d.ts +0 -0
- /package/dist/{src/migrations → migrations}/1605279038-drop-gemeenten-tmp.sql +0 -0
- /package/dist/{src/migrations → migrations}/1708607340-tickets-deleted-at.sql +0 -0
- /package/dist/{src/migrations → migrations}/1710459176-register-code-invoices.sql +0 -0
- /package/dist/{src/migrations → migrations}/1712158247-discount-codes.sql +0 -0
- /package/dist/{src/migrations → migrations}/1713178665-drop-invites.sql +0 -0
- /package/dist/{src/migrations → migrations}/1713178666-drop-keychain.sql +0 -0
- /package/dist/{src/migrations → migrations}/1713178667-drop-challenges.sql +0 -0
- /package/dist/{src/migrations → migrations}/1713178668-drop-user-keys.sql +0 -0
- /package/dist/{src/migrations → migrations}/1713178669-drop-organization-key.sql +0 -0
- /package/dist/{src/migrations → migrations}/1714985451-user-nullable-organization-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1714985452-email-verification-code-nullable-organization-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1714985453-user-organization-permissions.sql +0 -0
- /package/dist/{src/migrations → migrations}/1714985454-user-organization-permissions.sql +0 -0
- /package/dist/{src/migrations → migrations}/1715079362-platform.sql +0 -0
- /package/dist/{src/migrations → migrations}/1715181649-registrations-organization-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1715181650-registrations-organization-id-fill.sql +0 -0
- /package/dist/{src/migrations → migrations}/1715181651-registrations-organization-id-drop-null.sql +0 -0
- /package/dist/{src/migrations → migrations}/1716117067-members-nullable-organization-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1719567581-registration-periods.sql +0 -0
- /package/dist/{src/migrations → migrations}/1719567582-organization-registration-periods.sql +0 -0
- /package/dist/{src/migrations → migrations}/1719567881-organization-periodId.sql +0 -0
- /package/dist/{src/migrations → migrations}/1719567882-groups-periodId.sql +0 -0
- /package/dist/{src/migrations → migrations}/1719567883-platform-periodId.sql +0 -0
- /package/dist/{src/migrations → migrations}/1719568079-default-period.sql +0 -0
- /package/dist/{src/migrations → migrations}/1719568080-set-default-period-platform.sql +0 -0
- /package/dist/{src/migrations → migrations}/1719568081-set-default-period-organizations.sql +0 -0
- /package/dist/{src/migrations → migrations}/1719568082-set-default-period-groups.sql +0 -0
- /package/dist/{src/migrations → migrations}/1719580828-registrations-periodId.sql +0 -0
- /package/dist/{src/migrations → migrations}/1719580829-set-default-period-registrations.sql +0 -0
- /package/dist/{src/migrations → migrations}/1719931362-groups-default-age-group-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1720080975-convert-charset.sql +0 -0
- /package/dist/{src/migrations → migrations}/1720080976-responsibilities.sql +0 -0
- /package/dist/{src/migrations → migrations}/1720088136-member-membership-types.sql +0 -0
- /package/dist/{src/migrations → migrations}/1720088137-member-membership-types-expire-date.sql +0 -0
- /package/dist/{src/migrations → migrations}/1720444931-organization-active.sql +0 -0
- /package/dist/{src/migrations → migrations}/1721050380-email-table.sql +0 -0
- /package/dist/{src/migrations → migrations}/1721050381-email-recipients-table.sql +0 -0
- /package/dist/{src/migrations → migrations}/1721342679-responsibility-groupId.sql +0 -0
- /package/dist/{src/migrations → migrations}/1721342680-responsibility-groupId-foreign-key.sql +0 -0
- /package/dist/{src/migrations → migrations}/1721400546-users-memberId.sql +0 -0
- /package/dist/{src/migrations → migrations}/1721639159-membership-deleted-at.sql +0 -0
- /package/dist/{src/migrations → migrations}/1721639160-membership-generated.sql +0 -0
- /package/dist/{src/migrations → migrations}/1721841819-group-type.sql +0 -0
- /package/dist/{src/migrations → migrations}/1722090482-events.sql +0 -0
- /package/dist/{src/migrations → migrations}/1722269236-group-waitinglist-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1722525785-balance-item-paying-organization-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1722525787-depending-balance-item.sql +0 -0
- /package/dist/{src/migrations → migrations}/1722845608-registration-stock-reservations.sql +0 -0
- /package/dist/{src/migrations → migrations}/1722845609-group-stock-reservations.sql +0 -0
- /package/dist/{src/migrations → migrations}/1722852362-stripe-intents-account-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1722852363-stripe-checkout-sessions-account-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1722959111-allow-multiple-registrations.sql +0 -0
- /package/dist/{src/migrations → migrations}/1722963554-registration-group-price-and-options.sql +0 -0
- /package/dist/{src/migrations → migrations}/1723202125-member-number.sql +0 -0
- /package/dist/{src/migrations → migrations}/1723202126-member-number-index.sql +0 -0
- /package/dist/{src/migrations → migrations}/1723218160-balance-item-unit-price.sql +0 -0
- /package/dist/{src/migrations → migrations}/1723218161-balance-item-amount.sql +0 -0
- /package/dist/{src/migrations → migrations}/1723218162-balance-item-type.sql +0 -0
- /package/dist/{src/migrations → migrations}/1723218163-balance-item-type-defaults.sql +0 -0
- /package/dist/{src/migrations → migrations}/1723218164-balance-item-relations.sql +0 -0
- /package/dist/{src/migrations → migrations}/1723652795-payments-paying-user-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1723652796-payments-paying-organization-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1723652797-payments-paying-organization-id-fk.sql +0 -0
- /package/dist/{src/migrations → migrations}/1723652798-payments-customer.sql +0 -0
- /package/dist/{src/migrations → migrations}/1723736282-merged-members.sql +0 -0
- /package/dist/{src/migrations → migrations}/1724076162-setup-steps.sql +0 -0
- /package/dist/{src/migrations → migrations}/1724156666-member-indexes.sql +0 -0
- /package/dist/{src/migrations → migrations}/1724156667-organization-tag-index.sql +0 -0
- /package/dist/{src/migrations → migrations}/1724256125-membership-balance-item-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1724256126-membership-balance-item-fk.sql +0 -0
- /package/dist/{src/migrations → migrations}/1724258844-membershipOrganizationId.sql +0 -0
- /package/dist/{src/migrations → migrations}/1724258845-membershipOrganizationId-fk.sql +0 -0
- /package/dist/{src/migrations → migrations}/1726054851-balance-item-price-pending.sql +0 -0
- /package/dist/{src/migrations → migrations}/1726054852-cached-outstanding-balances.sql +0 -0
- /package/dist/{src/migrations → migrations}/1726668114-maximum-free-amount.sql +0 -0
- /package/dist/{src/migrations → migrations}/1726668115-free-amount.sql +0 -0
- /package/dist/{src/migrations → migrations}/1726668116-price-without-discount.sql +0 -0
- /package/dist/{src/migrations → migrations}/1727947041-registration-record-answers.sql +0 -0
- /package/dist/{src/migrations → migrations}/1729251385-order-extra-filter-columns.sql +0 -0
- /package/dist/{src/migrations → migrations}/1732285080-audit-logs.sql +0 -0
- /package/dist/{src/migrations → migrations}/1733129611-clear-audit-logs.sql +0 -0
- /package/dist/{src/migrations → migrations}/1733129612-audit-logs-source.sql +0 -0
- /package/dist/{src/migrations → migrations}/1733317908-added-missing-organization-fk-on-registrations.sql +0 -0
- /package/dist/{src/migrations → migrations}/1733317909-paying-organization-id-registrations.sql +0 -0
- /package/dist/{src/migrations → migrations}/1733317910-paying-organization-id-fk.sql +0 -0
- /package/dist/{src/migrations → migrations}/1733410641-audit-log-external-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1733418667-desc-audit-log-primary-key.sql +0 -0
- /package/dist/{src/migrations → migrations}/1733909398-balance-items-due-at.sql +0 -0
- /package/dist/{src/migrations → migrations}/1733909399-recalculate-at.sql +0 -0
- /package/dist/{src/migrations → migrations}/1733994454-balance-item-price-open.sql +0 -0
- /package/dist/{src/migrations → migrations}/1734084689-payment-type.sql +0 -0
- /package/dist/{src/migrations → migrations}/1734084690-move-payment-column-order.sql +0 -0
- /package/dist/{src/migrations → migrations}/1734084691-fill-payment-type-refunds.sql +0 -0
- /package/dist/{src/migrations → migrations}/1734084692-fill-payment-type-reallocations.sql +0 -0
- /package/dist/{src/migrations → migrations}/1734429094-registration-trial-until.sql +0 -0
- /package/dist/{src/migrations → migrations}/1734429095-membership-trial-until.sql +0 -0
- /package/dist/{src/migrations → migrations}/1734535120-registration-period-previous-period-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1734535121-platform-previous-period-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1734626607-cached-balance-amount-open.sql +0 -0
- /package/dist/{src/migrations → migrations}/1734698906-cached-balance-amount-paid.sql +0 -0
- /package/dist/{src/migrations → migrations}/1735573520-emails-email-type.sql +0 -0
- /package/dist/{src/migrations → migrations}/1735573521-email-recipients-email-type.sql +0 -0
- /package/dist/{src/migrations → migrations}/1735573522-emails-indexes.sql +0 -0
- /package/dist/{src/migrations → migrations}/1735982691-cached-balance-email-reminder-counts.sql +0 -0
- /package/dist/{src/migrations → migrations}/1736850097-audit-logs-meta.sql +0 -0
- /package/dist/{src/migrations → migrations}/1736947931-platform-server-config.sql +0 -0
- /package/dist/{src/migrations → migrations}/1738922428-membership-locked.sql +0 -0
- /package/dist/{src/migrations → migrations}/1739017508-event-notifications.sql +0 -0
- /package/dist/{src/migrations → migrations}/1739017509-event-notifications-link.sql +0 -0
- /package/dist/{src/migrations → migrations}/1739282590-event-notifications-submitted-at.sql +0 -0
- /package/dist/{src/migrations → migrations}/1741954610-event-notifications-accepted-record-answers.sql +0 -0
- /package/dist/{src/migrations → migrations}/1742579832-audit-log-longer-object-size.sql +0 -0
- /package/dist/{src/migrations → migrations}/1747913433-registration-discounts.sql +0 -0
- /package/dist/{src/migrations → migrations}/1747996262-balance-items-paid-at.sql +0 -0
- /package/dist/{src/migrations → migrations}/1747996263-balance-items-paid-at-fill.sql +0 -0
- /package/dist/{src/migrations → migrations}/1751633220-create-uitpas-client-credentials.sql +0 -0
- /package/dist/{src/migrations → migrations}/1751970372-create-webshop-uitpas-numbers.sql +0 -0
- /package/dist/{src/migrations → migrations}/1752655335-events-webshop-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1752678047-confirmation-email.sql +0 -0
- /package/dist/{src/migrations → migrations}/1753363434-service-fees.sql +0 -0
- /package/dist/{src/migrations → migrations}/1753430415-update-webshop-uitpasnumbers.sql +0 -0
- /package/dist/{src/migrations → migrations}/1755529026-email-sender-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1755789797-email-counts-errors.sql +0 -0
- /package/dist/{src/migrations → migrations}/1755789798-email-recipient-errors.sql +0 -0
- /package/dist/{src/migrations → migrations}/1756115313-email-recipient-ids-and-errors.sql +0 -0
- /package/dist/{src/migrations → migrations}/1756115314-email-recipient-email-optional.sql +0 -0
- /package/dist/{src/migrations → migrations}/1756115315-email-recipients-count.sql +0 -0
- /package/dist/{src/migrations → migrations}/1756115316-email-cached-counts.sql +0 -0
- /package/dist/{src/migrations → migrations}/1756115317-email-deleted-at.sql +0 -0
- /package/dist/{src/migrations → migrations}/1756293494-registration-period-next-period-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1756293495-platform-next-period-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1756387016-registration-period-custom-name.sql +0 -0
- /package/dist/{src/migrations → migrations}/1756391212-email-recipients-duplicate.sql +0 -0
- /package/dist/{src/migrations → migrations}/1756821154-email-send-as-email.sql +0 -0
- /package/dist/{src/migrations → migrations}/1758034021-email-recipient-previous-error.sql +0 -0
- /package/dist/{src/migrations → migrations}/1760535508-update-cached-balances-object-id-unique-constraint.sql +0 -0
- /package/dist/{src/migrations → migrations}/1761750780-renamed-invoice-organization-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1761750781-rename-index.sql +0 -0
- /package/dist/{src/migrations → migrations}/1761750782-invoices-add-organization-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1761750783-invoices-organization-id-fk.sql +0 -0
- /package/dist/{src/migrations → migrations}/1762521336-did-send-peppol.sql +0 -0
- /package/dist/{src/migrations → migrations}/1763216321-multiply-balance-item-payments.sql +0 -0
- /package/dist/{src/migrations → migrations}/1763216322-multiply-balance-items.sql +0 -0
- /package/dist/{src/migrations → migrations}/1763216323-bigint-cached-balances.sql +0 -0
- /package/dist/{src/migrations → migrations}/1763216324-multiply-cached-balances.sql +0 -0
- /package/dist/{src/migrations → migrations}/1763216325-multiply-member-platform-memberships.sql +0 -0
- /package/dist/{src/migrations → migrations}/1763216326-multiply-payments.sql +0 -0
- /package/dist/{src/migrations → migrations}/1763216327-multiply-register-codes.sql +0 -0
- /package/dist/{src/migrations → migrations}/1763216328-multiply-credits.sql +0 -0
- /package/dist/{src/migrations → migrations}/1763216329-multiply-orders.sql +0 -0
- /package/dist/{src/migrations → migrations}/1763216330-multiply-uitpas-numbers.sql +0 -0
- /package/dist/{src/migrations → migrations}/1763216331-balance-item-vat-percentages.sql +0 -0
- /package/dist/{src/migrations → migrations}/1763216332-balance-item-price-total.sql +0 -0
- /package/dist/{src/migrations → migrations}/1763216333-balance-item-price-total-fill.sql +0 -0
- /package/dist/{src/migrations → migrations}/1765895470-document-year.sql +0 -0
- /package/dist/{src/migrations → migrations}/1766150401-document-published-at.sql +0 -0
- /package/dist/{src/migrations → migrations}/1766410598-registration-end-date.sql +0 -0
- /package/dist/{src/migrations → migrations}/1769087807-invoices-table.sql +0 -0
- /package/dist/{src/migrations → migrations}/1769087808-invoiced-balance-items-table.sql +0 -0
- /package/dist/{src/migrations → migrations}/1769087809-payments-invoice-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1769621227-payments-rounding-amount.sql +0 -0
- /package/dist/{src/migrations → migrations}/1770917406-create-cached-balances-global-index.sql +0 -0
- /package/dist/{src/migrations → migrations}/1770917407-create-member-name-ordering-index.sql +0 -0
- /package/dist/{src/migrations → migrations}/1770917408-create-member-name-ordering-index-desc.sql +0 -0
- /package/dist/{src/migrations → migrations}/1770917409-create-member-age-ordering-index.sql +0 -0
- /package/dist/{src/migrations → migrations}/1770917410-create-member-age-ordering-index-desc.sql +0 -0
- /package/dist/{src/migrations → migrations}/1770917411-drop-duplicate-member-indexes.sql +0 -0
- /package/dist/{src/migrations → migrations}/1771510518-events-index-organization-id-start-date.sql +0 -0
- /package/dist/{src/migrations → migrations}/1771918307-membership-active-filter-index.sql +0 -0
- /package/dist/{src/migrations → migrations}/1772033555-balance-item-package-id.sql +0 -0
- /package/dist/{src/migrations → migrations}/1772033715-balance-item-start-end-date.sql +0 -0
- /package/dist/{src/migrations → migrations}/data/postcodes/nl/Drenthe +0 -0
- /package/dist/{src/migrations → migrations}/data/postcodes/nl/Flevoland +0 -0
- /package/dist/{src/migrations → migrations}/data/postcodes/nl/Friesland +0 -0
- /package/dist/{src/migrations → migrations}/data/postcodes/nl/Gelderland +0 -0
- /package/dist/{src/migrations → migrations}/data/postcodes/nl/Groningen +0 -0
- /package/dist/{src/migrations → migrations}/data/postcodes/nl/Limburg +0 -0
- /package/dist/{src/migrations → migrations}/data/postcodes/nl/Noord-Brabant +0 -0
- /package/dist/{src/migrations → migrations}/data/postcodes/nl/Noord-Holland +0 -0
- /package/dist/{src/migrations → migrations}/data/postcodes/nl/Overrijsel +0 -0
- /package/dist/{src/migrations → migrations}/data/postcodes/nl/Utrecht +0 -0
- /package/dist/{src/migrations → migrations}/data/postcodes/nl/Zeeland +0 -0
- /package/dist/{src/migrations → migrations}/data/postcodes/nl/Zuid-Holland +0 -0
- /package/dist/{src/models → models}/AuditLog.d.ts +0 -0
- /package/dist/{src/models → models}/BuckarooPayment.d.ts +0 -0
- /package/dist/{src/models → models}/EmailRecipient.d.ts +0 -0
- /package/dist/{src/models → models}/Event.d.ts +0 -0
- /package/dist/{src/models → models}/Invoice.d.ts +0 -0
- /package/dist/{src/models → models}/MemberUser.d.ts +0 -0
- /package/dist/{src/models → models}/MolliePayment.d.ts +0 -0
- /package/dist/{src/models → models}/Platform.d.ts +0 -0
- /package/dist/{src/models → models}/RegisterCode.d.ts +0 -0
- /package/dist/{src/models → models}/RegistrationPeriod.d.ts +0 -0
- /package/dist/{src/models → models}/STCredit.d.ts +0 -0
- /package/dist/{src/models → models}/STPackage.d.ts +0 -0
- /package/dist/{src/models → models}/StripeAccount.d.ts +0 -0
- /package/dist/{src/models → models}/StripeCheckoutSession.d.ts +0 -0
- /package/dist/{src/models → models}/StripePaymentIntent.d.ts +0 -0
- /package/dist/{src/models → models}/UitpasClientCredential.d.ts +0 -0
- /package/dist/{src/models → models}/UsedRegisterCode.d.ts +0 -0
- /package/dist/{src/models → models}/WebshopDiscountCode.d.ts +0 -0
- /package/dist/{src/models → models}/WebshopUitpasNumber.d.ts +0 -0
- /package/dist/{src/models → models}/addresses/Street.d.ts +0 -0
- /package/dist/{src/structures → structures}/OrganizationServerMetaData.d.ts +0 -0
|
@@ -0,0 +1,1341 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { column } from '@simonbackx/simple-database';
|
|
3
|
+
import { EmailAttachment, EmailPreview, EmailRecipientFilter, EmailRecipientsStatus, EmailStatus, Email as EmailStruct, EmailWithRecipients, getExampleRecipient, isSoftEmailRecipientError, LimitedFilteredRequest, SortItemDirection } from '@stamhoofd/structures';
|
|
4
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
+
import { AnyDecoder, ArrayDecoder } from '@simonbackx/simple-encoding';
|
|
6
|
+
import { isSimpleError, isSimpleErrors, SimpleError, SimpleErrors } from '@simonbackx/simple-errors';
|
|
7
|
+
import { I18n } from '@stamhoofd/backend-i18n/I18n';
|
|
8
|
+
import { Email as EmailClass } from '@stamhoofd/email';
|
|
9
|
+
import { isAbortedError, QueueHandler } from '@stamhoofd/queues';
|
|
10
|
+
import { QueryableModel, readDynamicSQLExpression, SQL, SQLAlias, SQLCalculation, SQLCount, SQLPlusSign, SQLSelectAs, SQLWhereSign } from '@stamhoofd/sql';
|
|
11
|
+
import { canSendFromEmail, fillRecipientReplacements, getEmailBuilder, mergeReplacementsIfEqual, removeUnusedReplacements, stripRecipientReplacementsForWebDisplay, stripSensitiveRecipientReplacements } from '../helpers/EmailBuilder.js';
|
|
12
|
+
import { EmailRecipient } from './EmailRecipient.js';
|
|
13
|
+
import { EmailTemplate } from './EmailTemplate.js';
|
|
14
|
+
import { Organization } from './Organization.js';
|
|
15
|
+
import { Platform } from './Platform.js';
|
|
16
|
+
import { User } from './User.js';
|
|
17
|
+
function errorToSimpleErrors(e) {
|
|
18
|
+
if (isSimpleErrors(e)) {
|
|
19
|
+
return e;
|
|
20
|
+
}
|
|
21
|
+
else if (isSimpleError(e)) {
|
|
22
|
+
return new SimpleErrors(e);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return new SimpleErrors(new SimpleError({
|
|
26
|
+
code: 'unknown_error',
|
|
27
|
+
message: ((typeof e === 'object' && e !== null && 'message' in e && typeof e.message === 'string') ? e.message : 'Unknown error'),
|
|
28
|
+
human: $t(`%1ED`),
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class Email extends QueryableModel {
|
|
33
|
+
static table = 'emails';
|
|
34
|
+
id;
|
|
35
|
+
organizationId = null;
|
|
36
|
+
senderId = null;
|
|
37
|
+
userId = null;
|
|
38
|
+
/**
|
|
39
|
+
* Send the message as an email.
|
|
40
|
+
* You can't edit this after the message has been published.
|
|
41
|
+
*
|
|
42
|
+
* If false, when sending the message, it will switch to 'Sent' directly without adjusting the email_recipients directly.
|
|
43
|
+
*/
|
|
44
|
+
sendAsEmail = true;
|
|
45
|
+
/**
|
|
46
|
+
* Show the message in the member portal
|
|
47
|
+
*
|
|
48
|
+
* Note: status should be 'Sent' for the message to be visible
|
|
49
|
+
*/
|
|
50
|
+
showInMemberPortal = true;
|
|
51
|
+
recipientFilter = EmailRecipientFilter.create({});
|
|
52
|
+
/**
|
|
53
|
+
* Helper to prevent sending too many emails to the same person.
|
|
54
|
+
* Allows for filtering on objects that didn't receive a specific email yet
|
|
55
|
+
*/
|
|
56
|
+
emailType = null;
|
|
57
|
+
subject;
|
|
58
|
+
/** Raw json structure to edit the template */
|
|
59
|
+
json = {};
|
|
60
|
+
html = null;
|
|
61
|
+
text = null;
|
|
62
|
+
fromAddress = null;
|
|
63
|
+
fromName = null;
|
|
64
|
+
/**
|
|
65
|
+
* Amount of recipients with an email address
|
|
66
|
+
*/
|
|
67
|
+
emailRecipientsCount = null;
|
|
68
|
+
/**
|
|
69
|
+
* Amount of recipients without an email address
|
|
70
|
+
*/
|
|
71
|
+
otherRecipientsCount = null;
|
|
72
|
+
/**
|
|
73
|
+
* Amount of recipients that have successfully received the email.
|
|
74
|
+
*/
|
|
75
|
+
succeededCount = 0;
|
|
76
|
+
/**
|
|
77
|
+
* Amount of recipients that somehow failed to receive the email,
|
|
78
|
+
* but with a soft error that doesn't require action.
|
|
79
|
+
* - Duplicate email in recipient list
|
|
80
|
+
* - Unsubscribed
|
|
81
|
+
*/
|
|
82
|
+
softFailedCount = 0;
|
|
83
|
+
/**
|
|
84
|
+
* Amount of recipients that somehow failed to receive the email:
|
|
85
|
+
* - Invalid email address
|
|
86
|
+
* - Full email inbox
|
|
87
|
+
*/
|
|
88
|
+
failedCount = 0;
|
|
89
|
+
/**
|
|
90
|
+
* Unique amount of members that are in the recipients list.
|
|
91
|
+
*/
|
|
92
|
+
membersCount = 0;
|
|
93
|
+
/**
|
|
94
|
+
* Does only include bounces AFTER sending the email
|
|
95
|
+
*/
|
|
96
|
+
hardBouncesCount = 0;
|
|
97
|
+
/**
|
|
98
|
+
* Does only include bounces AFTER sending the email
|
|
99
|
+
*/
|
|
100
|
+
softBouncesCount = 0;
|
|
101
|
+
/**
|
|
102
|
+
* Does only include bounces AFTER sending the email
|
|
103
|
+
*/
|
|
104
|
+
spamComplaintsCount = 0;
|
|
105
|
+
status = EmailStatus.Draft;
|
|
106
|
+
recipientsStatus = EmailRecipientsStatus.NotCreated;
|
|
107
|
+
/**
|
|
108
|
+
* Errors related to creating the recipients.
|
|
109
|
+
*/
|
|
110
|
+
recipientsErrors = null;
|
|
111
|
+
/**
|
|
112
|
+
* Errors related to sending the email.
|
|
113
|
+
*/
|
|
114
|
+
emailErrors = null;
|
|
115
|
+
/**
|
|
116
|
+
* todo: ignore automatically
|
|
117
|
+
*/
|
|
118
|
+
attachments = [];
|
|
119
|
+
sentAt = null;
|
|
120
|
+
deletedAt = null;
|
|
121
|
+
createdAt;
|
|
122
|
+
updatedAt;
|
|
123
|
+
static recipientLoaders = new Map();
|
|
124
|
+
static pendingNotificationCountUpdates = new Map();
|
|
125
|
+
throwIfNotReadyToSend() {
|
|
126
|
+
if (this.subject == null || this.subject.length == 0) {
|
|
127
|
+
throw new SimpleError({
|
|
128
|
+
code: 'invalid_field',
|
|
129
|
+
message: 'Missing subject',
|
|
130
|
+
human: $t(`%wu`),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (this.text == null || this.text.length == 0) {
|
|
134
|
+
throw new SimpleError({
|
|
135
|
+
code: 'invalid_field',
|
|
136
|
+
message: 'Missing text',
|
|
137
|
+
human: $t(`%wv`),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (this.html == null || this.html.length == 0) {
|
|
141
|
+
throw new SimpleError({
|
|
142
|
+
code: 'invalid_field',
|
|
143
|
+
message: 'Missing html',
|
|
144
|
+
human: $t(`%wv`),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (this.fromAddress == null || this.fromAddress.length == 0) {
|
|
148
|
+
throw new SimpleError({
|
|
149
|
+
code: 'invalid_field',
|
|
150
|
+
message: 'Missing from',
|
|
151
|
+
human: $t(`%ww`),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (this.status === EmailStatus.Draft && this.recipientsErrors !== null && this.recipientsStatus !== EmailRecipientsStatus.Created) {
|
|
155
|
+
throw new SimpleError({
|
|
156
|
+
code: 'invalid_recipients',
|
|
157
|
+
message: 'Failed to build recipients (count)',
|
|
158
|
+
human: $t(`%1EE`) + ' ' + this.recipientsErrors.getHuman(),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (this.deletedAt) {
|
|
162
|
+
throw new SimpleError({
|
|
163
|
+
code: 'invalid_state',
|
|
164
|
+
message: 'Email is deleted',
|
|
165
|
+
human: $t(`%1EF`),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
this.validateAttachments();
|
|
169
|
+
}
|
|
170
|
+
throwIfNoUnsubscribeButton() {
|
|
171
|
+
if (this.sendAsEmail === false) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (this.emailType) {
|
|
175
|
+
// System email, no need for unsubscribe button
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const replacement = '{{unsubscribeUrl}}';
|
|
179
|
+
if (this.html) {
|
|
180
|
+
// Check email contains an unsubscribe button
|
|
181
|
+
if (!this.html.includes(replacement)) {
|
|
182
|
+
throw new SimpleError({
|
|
183
|
+
code: 'missing_unsubscribe_button',
|
|
184
|
+
message: 'Missing unsubscribe button',
|
|
185
|
+
human: $t(`%DS`),
|
|
186
|
+
field: 'html',
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (this.text) {
|
|
191
|
+
// Check email contains an unsubscribe button
|
|
192
|
+
if (!this.text.includes(replacement)) {
|
|
193
|
+
throw new SimpleError({
|
|
194
|
+
code: 'missing_unsubscribe_button',
|
|
195
|
+
message: 'Missing unsubscribe button',
|
|
196
|
+
human: $t(`%DS`),
|
|
197
|
+
field: 'text',
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
validateAttachments() {
|
|
203
|
+
// Validate attachments
|
|
204
|
+
const size = this.attachments.reduce((value, attachment) => {
|
|
205
|
+
return value + attachment.bytes;
|
|
206
|
+
}, 0);
|
|
207
|
+
if (size > 9.5 * 1024 * 1024) {
|
|
208
|
+
throw new SimpleError({
|
|
209
|
+
code: 'too_big_attachments',
|
|
210
|
+
message: 'Too big attachments',
|
|
211
|
+
human: $t(`%wx`),
|
|
212
|
+
field: 'attachments',
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
const safeContentTypes = [
|
|
216
|
+
'application/msword',
|
|
217
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
218
|
+
'application/vnd.ms-excel',
|
|
219
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
220
|
+
'application/pdf',
|
|
221
|
+
'image/jpeg',
|
|
222
|
+
'image/png',
|
|
223
|
+
'image/gif',
|
|
224
|
+
];
|
|
225
|
+
for (const attachment of this.attachments) {
|
|
226
|
+
if (attachment.contentType && !safeContentTypes.includes(attachment.contentType)) {
|
|
227
|
+
throw new SimpleError({
|
|
228
|
+
code: 'content_type_not_supported',
|
|
229
|
+
message: 'Content-Type not supported',
|
|
230
|
+
human: $t(`%wy`),
|
|
231
|
+
field: 'attachments',
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
if (!attachment.content) {
|
|
235
|
+
if (!attachment.file) {
|
|
236
|
+
throw new SimpleError({
|
|
237
|
+
code: 'invalid_attachment',
|
|
238
|
+
message: 'Invalid attachment: missing file or content',
|
|
239
|
+
field: 'attachments',
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
if (!attachment.file.isPrivate) {
|
|
243
|
+
throw new SimpleError({
|
|
244
|
+
code: 'invalid_attachment',
|
|
245
|
+
message: 'Invalid attachment: file must be private',
|
|
246
|
+
field: 'attachments',
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
if (!attachment.file.signature) {
|
|
250
|
+
throw new SimpleError({
|
|
251
|
+
code: 'invalid_attachment',
|
|
252
|
+
message: 'Invalid attachment: file must be signed',
|
|
253
|
+
field: 'attachments',
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
getFromAddress() {
|
|
260
|
+
if (!this.fromName) {
|
|
261
|
+
return {
|
|
262
|
+
email: this.fromAddress,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
name: this.fromName,
|
|
267
|
+
email: this.fromAddress,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
getDefaultFromAddress(organization) {
|
|
271
|
+
const i18n = new I18n($getLanguage(), $getCountry());
|
|
272
|
+
let address = {
|
|
273
|
+
email: 'noreply@' + i18n.localizedDomains.defaultBroadcastEmail(),
|
|
274
|
+
};
|
|
275
|
+
if (organization) {
|
|
276
|
+
address = organization.getDefaultFrom(organization.i18n, 'broadcast');
|
|
277
|
+
}
|
|
278
|
+
if (!this.fromName) {
|
|
279
|
+
return address;
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
name: this.fromName,
|
|
283
|
+
email: address.email,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
async setFromTemplate(type) {
|
|
287
|
+
// Most specific template: for specific group
|
|
288
|
+
let templates = (await EmailTemplate.where({ type, organizationId: this.organizationId, groupId: null, webshopId: null }));
|
|
289
|
+
// Then default
|
|
290
|
+
if (templates.length === 0 && this.organizationId) {
|
|
291
|
+
templates = (await EmailTemplate.where({ type, organizationId: null, groupId: null, webshopId: null }));
|
|
292
|
+
}
|
|
293
|
+
if (templates.length === 0) {
|
|
294
|
+
// No default
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
const defaultTemplate = templates[0];
|
|
298
|
+
this.html = defaultTemplate.html;
|
|
299
|
+
this.text = defaultTemplate.text;
|
|
300
|
+
this.subject = defaultTemplate.subject;
|
|
301
|
+
this.json = defaultTemplate.json;
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
async lock(callback) {
|
|
305
|
+
if (!this.id) {
|
|
306
|
+
await this.save();
|
|
307
|
+
}
|
|
308
|
+
const id = this.id;
|
|
309
|
+
return await QueueHandler.schedule('lock-email-' + id, async (options) => {
|
|
310
|
+
const upToDate = await Email.getByID(id);
|
|
311
|
+
if (!upToDate) {
|
|
312
|
+
throw new SimpleError({
|
|
313
|
+
code: 'not_found',
|
|
314
|
+
message: 'Email not found',
|
|
315
|
+
human: $t(`%wz`),
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
const c = await callback(upToDate, options);
|
|
319
|
+
this.copyFrom(upToDate);
|
|
320
|
+
return c;
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
static async bumpNotificationCount(emailId, type) {
|
|
324
|
+
// Send an update query
|
|
325
|
+
const base = Email.update()
|
|
326
|
+
.where('id', emailId);
|
|
327
|
+
switch (type) {
|
|
328
|
+
case 'hard-bounce': {
|
|
329
|
+
base.set('hardBouncesCount', new SQLCalculation(SQL.column('hardBouncesCount'), new SQLPlusSign(), readDynamicSQLExpression(1)));
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
case 'soft-bounce': {
|
|
333
|
+
base.set('softBouncesCount', new SQLCalculation(SQL.column('softBouncesCount'), new SQLPlusSign(), readDynamicSQLExpression(1)));
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
case 'complaint': {
|
|
337
|
+
base.set('spamComplaintsCount', new SQLCalculation(SQL.column('spamComplaintsCount'), new SQLPlusSign(), readDynamicSQLExpression(1)));
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
await base.update();
|
|
342
|
+
await this.checkNeedsNotificationCountUpdate(emailId, true);
|
|
343
|
+
}
|
|
344
|
+
static async checkNeedsNotificationCountUpdate(emailId, didUpdate = false) {
|
|
345
|
+
const existing = this.pendingNotificationCountUpdates.get(emailId);
|
|
346
|
+
const object = existing ?? {
|
|
347
|
+
timer: null,
|
|
348
|
+
lastUpdate: didUpdate ? new Date() : null,
|
|
349
|
+
};
|
|
350
|
+
if (didUpdate) {
|
|
351
|
+
object.lastUpdate = new Date();
|
|
352
|
+
}
|
|
353
|
+
if (existing) {
|
|
354
|
+
this.pendingNotificationCountUpdates.set(emailId, object);
|
|
355
|
+
}
|
|
356
|
+
if (object.lastUpdate && object.lastUpdate < new Date(Date.now() - 5 * 60 * 1000)) {
|
|
357
|
+
// After 5 minutes without notifications, run an update.
|
|
358
|
+
await this.updateNotificationsCounts(emailId);
|
|
359
|
+
// Stop here
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
// Schedule a slow update of all counts
|
|
363
|
+
if (!object.timer) {
|
|
364
|
+
object.timer = setTimeout(() => {
|
|
365
|
+
object.timer = null;
|
|
366
|
+
this.checkNeedsNotificationCountUpdate(emailId).catch(console.error);
|
|
367
|
+
}, 1 * 60 * 1000);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
static async updateNotificationsCounts(emailId) {
|
|
371
|
+
QueueHandler.cancel('updateNotificationsCounts-' + emailId);
|
|
372
|
+
return await QueueHandler.schedule('updateNotificationsCounts-' + emailId, async () => {
|
|
373
|
+
const query = SQL.select(new SQLSelectAs(new SQLCount(SQL.column('hardBounceError')), new SQLAlias('data__hardBounces')),
|
|
374
|
+
// If the current amount_due is negative, we can ignore that negative part if there is a future due item
|
|
375
|
+
new SQLSelectAs(new SQLCount(SQL.column('softBounceError')), new SQLAlias('data__softBounces')), new SQLSelectAs(new SQLCount(SQL.column('spamComplaintError')), new SQLAlias('data__complaints')))
|
|
376
|
+
.from(EmailRecipient.table)
|
|
377
|
+
.where('emailId', emailId);
|
|
378
|
+
const result = await query.fetch();
|
|
379
|
+
if (result.length !== 1) {
|
|
380
|
+
console.error('Unexpected result', result);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
const row = result[0]['data'];
|
|
384
|
+
if (!row) {
|
|
385
|
+
console.error('Unexpected result row', result);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const hardBounces = row['hardBounces'];
|
|
389
|
+
const softBounces = row['softBounces'];
|
|
390
|
+
const complaints = row['complaints'];
|
|
391
|
+
if (typeof hardBounces !== 'number' || typeof softBounces !== 'number' || typeof complaints !== 'number') {
|
|
392
|
+
console.error('Unexpected result values', row);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
console.log('Updating email notification counts', emailId, hardBounces, softBounces, complaints);
|
|
396
|
+
// Send an update query
|
|
397
|
+
await Email.update()
|
|
398
|
+
.where('id', emailId)
|
|
399
|
+
.set('hardBouncesCount', hardBounces)
|
|
400
|
+
.set('softBouncesCount', softBounces)
|
|
401
|
+
.set('spamComplaintsCount', complaints)
|
|
402
|
+
.update();
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
async queueForSending(waitForSending = false) {
|
|
406
|
+
console.log('Queueing email for sending', this.id);
|
|
407
|
+
this.throwIfNotReadyToSend();
|
|
408
|
+
this.throwIfNoUnsubscribeButton();
|
|
409
|
+
await this.lock(async (upToDate) => {
|
|
410
|
+
if (upToDate.status === EmailStatus.Draft) {
|
|
411
|
+
upToDate.status = EmailStatus.Queued;
|
|
412
|
+
}
|
|
413
|
+
if (upToDate.status === EmailStatus.Failed) {
|
|
414
|
+
// Retry failed email
|
|
415
|
+
upToDate.status = EmailStatus.Queued;
|
|
416
|
+
}
|
|
417
|
+
await upToDate.save();
|
|
418
|
+
});
|
|
419
|
+
if (waitForSending) {
|
|
420
|
+
return await this.resumeSending();
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
this.resumeSending().catch(console.error);
|
|
424
|
+
}
|
|
425
|
+
return this;
|
|
426
|
+
}
|
|
427
|
+
async loadAttachments() {
|
|
428
|
+
const attachments = [];
|
|
429
|
+
for (const attachment of this.attachments) {
|
|
430
|
+
if (!attachment.content && !attachment.file) {
|
|
431
|
+
console.warn('Attachment without content found, skipping', attachment);
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
let filename = $t('%180');
|
|
435
|
+
if (attachment.contentType === 'application/pdf') {
|
|
436
|
+
// tmp solution for pdf only
|
|
437
|
+
filename += '.pdf';
|
|
438
|
+
}
|
|
439
|
+
if (attachment.file?.name) {
|
|
440
|
+
filename = attachment.file.name.toLowerCase().replace(/[^a-z0-9.]+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
|
|
441
|
+
}
|
|
442
|
+
// Correct file name if needed
|
|
443
|
+
if (attachment.filename) {
|
|
444
|
+
filename = attachment.filename.toLowerCase().replace(/[^a-z0-9.]+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
|
|
445
|
+
}
|
|
446
|
+
if (attachment.content) {
|
|
447
|
+
attachments.push({
|
|
448
|
+
filename: filename,
|
|
449
|
+
content: attachment.content,
|
|
450
|
+
contentType: attachment.contentType ?? undefined,
|
|
451
|
+
encoding: 'base64',
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
// Note: because we send lots of emails, we better download the file here so we can reuse it in every email instead of downloading it every time
|
|
456
|
+
const withSigned = await attachment.file.withSignedUrl();
|
|
457
|
+
if (!withSigned || !withSigned.signedUrl) {
|
|
458
|
+
throw new SimpleError({
|
|
459
|
+
code: 'attachment_not_found',
|
|
460
|
+
message: 'Attachment not found',
|
|
461
|
+
human: $t(`%181`),
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
const filePath = withSigned.signedUrl;
|
|
465
|
+
let fileBuffer = null;
|
|
466
|
+
try {
|
|
467
|
+
const response = await fetch(filePath);
|
|
468
|
+
fileBuffer = Buffer.from(await response.arrayBuffer());
|
|
469
|
+
}
|
|
470
|
+
catch (e) {
|
|
471
|
+
throw new SimpleError({
|
|
472
|
+
code: 'attachment_not_found',
|
|
473
|
+
message: 'Attachment not found',
|
|
474
|
+
human: $t(`%181`),
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
attachments.push({
|
|
478
|
+
filename: filename,
|
|
479
|
+
contentType: attachment.contentType ?? undefined,
|
|
480
|
+
content: fileBuffer,
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return attachments;
|
|
485
|
+
}
|
|
486
|
+
async sendSingleRecipient(recipient, organization, data) {
|
|
487
|
+
let promiseResolve;
|
|
488
|
+
const promise = new Promise((resolve) => {
|
|
489
|
+
promiseResolve = resolve;
|
|
490
|
+
});
|
|
491
|
+
const virtualRecipient = recipient.getRecipient();
|
|
492
|
+
let resolved = false;
|
|
493
|
+
const callback = async (error) => {
|
|
494
|
+
if (resolved) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
resolved = true;
|
|
498
|
+
try {
|
|
499
|
+
if (error === null) {
|
|
500
|
+
// Mark saved
|
|
501
|
+
recipient.sentAt = new Date();
|
|
502
|
+
recipient.failErrorMessage = null;
|
|
503
|
+
if (recipient.failError) {
|
|
504
|
+
recipient.previousFailError = recipient.failError;
|
|
505
|
+
}
|
|
506
|
+
recipient.failError = null;
|
|
507
|
+
// Update repacements that have been generated
|
|
508
|
+
recipient.replacements = virtualRecipient.replacements;
|
|
509
|
+
await recipient.save();
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
recipient.failCount += 1;
|
|
513
|
+
recipient.failErrorMessage = error.message;
|
|
514
|
+
if (recipient.failError) {
|
|
515
|
+
recipient.previousFailError = recipient.failError;
|
|
516
|
+
}
|
|
517
|
+
recipient.failError = errorToSimpleErrors(error);
|
|
518
|
+
recipient.firstFailedAt = recipient.firstFailedAt ?? new Date();
|
|
519
|
+
recipient.lastFailedAt = new Date();
|
|
520
|
+
await recipient.save();
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
catch (e) {
|
|
524
|
+
console.error(e);
|
|
525
|
+
}
|
|
526
|
+
promiseResolve();
|
|
527
|
+
};
|
|
528
|
+
// Do send the email
|
|
529
|
+
// Create e-mail builder
|
|
530
|
+
const builder = await getEmailBuilder(organization ?? null, {
|
|
531
|
+
recipients: [
|
|
532
|
+
virtualRecipient,
|
|
533
|
+
],
|
|
534
|
+
from: data.from,
|
|
535
|
+
replyTo: data.replyTo,
|
|
536
|
+
subject: this.subject,
|
|
537
|
+
html: this.html,
|
|
538
|
+
type: this.emailType ? 'transactional' : 'broadcast',
|
|
539
|
+
attachments: data.attachments,
|
|
540
|
+
callback(error) {
|
|
541
|
+
callback(error).catch(console.error);
|
|
542
|
+
},
|
|
543
|
+
headers: {
|
|
544
|
+
'X-Email-Id': this.id,
|
|
545
|
+
'X-Email-Recipient-Id': recipient.id,
|
|
546
|
+
},
|
|
547
|
+
});
|
|
548
|
+
EmailClass.schedule(builder);
|
|
549
|
+
return await promise;
|
|
550
|
+
}
|
|
551
|
+
async resumeSending(singleRecipientId = null) {
|
|
552
|
+
const id = this.id;
|
|
553
|
+
return await QueueHandler.schedule('send-email', async ({ abort }) => {
|
|
554
|
+
return await this.lock(async function (upToDate) {
|
|
555
|
+
if (upToDate.status === EmailStatus.Sent) {
|
|
556
|
+
// Already done
|
|
557
|
+
// In other cases -> queue has stopped and we can retry
|
|
558
|
+
if (!singleRecipientId) {
|
|
559
|
+
console.log('Email already sent, skipping...', upToDate.id);
|
|
560
|
+
return upToDate;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
if (singleRecipientId) {
|
|
565
|
+
// Not possible
|
|
566
|
+
throw new SimpleError({
|
|
567
|
+
code: 'invalid_state',
|
|
568
|
+
message: 'Cannot retry single recipient for email that is not yet sent',
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
if (upToDate.status === EmailStatus.Sending) {
|
|
572
|
+
// This is an automatic retry.
|
|
573
|
+
if (upToDate.emailType) {
|
|
574
|
+
// Not eligible for retry
|
|
575
|
+
upToDate.status = EmailStatus.Failed;
|
|
576
|
+
await upToDate.save();
|
|
577
|
+
return upToDate;
|
|
578
|
+
}
|
|
579
|
+
if (upToDate.createdAt < new Date(new Date().getTime() - 1000 * 60 * 60 * 24 * 2)) {
|
|
580
|
+
// Too long
|
|
581
|
+
console.error('Email has been sending for too long. Marking as failed...', upToDate.id);
|
|
582
|
+
upToDate.status = EmailStatus.Failed;
|
|
583
|
+
await upToDate.save();
|
|
584
|
+
return upToDate;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
else if (upToDate.status !== EmailStatus.Queued) {
|
|
588
|
+
console.error('Email is not queued or sending, cannot send', upToDate.id, upToDate.status);
|
|
589
|
+
return upToDate;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
const organization = upToDate.organizationId ? await Organization.getByID(upToDate.organizationId) : null;
|
|
593
|
+
let from = upToDate.getDefaultFromAddress(organization);
|
|
594
|
+
let replyTo = upToDate.getFromAddress();
|
|
595
|
+
let succeededCount = 0;
|
|
596
|
+
let softFailedCount = 0;
|
|
597
|
+
let failedCount = 0;
|
|
598
|
+
try {
|
|
599
|
+
upToDate.throwIfNotReadyToSend();
|
|
600
|
+
upToDate.throwIfNoUnsubscribeButton();
|
|
601
|
+
if (!from) {
|
|
602
|
+
throw new SimpleError({
|
|
603
|
+
code: 'invalid_field',
|
|
604
|
+
message: 'Missing from',
|
|
605
|
+
human: $t(`%ww`),
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
// Can we send from this e-mail or reply-to?
|
|
609
|
+
if (upToDate.fromAddress && await canSendFromEmail(upToDate.fromAddress, organization ?? null)) {
|
|
610
|
+
from = upToDate.getFromAddress();
|
|
611
|
+
replyTo = null;
|
|
612
|
+
}
|
|
613
|
+
abort.throwIfAborted();
|
|
614
|
+
if (!singleRecipientId) {
|
|
615
|
+
upToDate.status = EmailStatus.Sending;
|
|
616
|
+
}
|
|
617
|
+
upToDate.sentAt = upToDate.sentAt ?? new Date();
|
|
618
|
+
await upToDate.save();
|
|
619
|
+
// Create recipients if not yet created
|
|
620
|
+
await upToDate.buildRecipients();
|
|
621
|
+
abort.throwIfAborted();
|
|
622
|
+
// Refresh model
|
|
623
|
+
const c = (await Email.getByID(id));
|
|
624
|
+
if (!c) {
|
|
625
|
+
throw new SimpleError({
|
|
626
|
+
code: 'not_found',
|
|
627
|
+
message: 'Email not found',
|
|
628
|
+
human: $t(`%wz`),
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
upToDate.copyFrom(c);
|
|
632
|
+
if (upToDate.recipientsStatus !== EmailRecipientsStatus.Created) {
|
|
633
|
+
throw new SimpleError({
|
|
634
|
+
code: 'recipients_not_created',
|
|
635
|
+
message: 'Failed to create recipients',
|
|
636
|
+
human: $t(`%x0`),
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
// Create a buffer of all attachments
|
|
640
|
+
if (upToDate.sendAsEmail === true) {
|
|
641
|
+
const attachments = await upToDate.loadAttachments();
|
|
642
|
+
// Start actually sending in batches of recipients that are not yet sent
|
|
643
|
+
let idPointer = '';
|
|
644
|
+
const batchSize = 100;
|
|
645
|
+
let isSavingStatus = false;
|
|
646
|
+
let lastStatusSave = new Date();
|
|
647
|
+
async function saveStatus() {
|
|
648
|
+
if (singleRecipientId) {
|
|
649
|
+
// Don't save during looping
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
if (!upToDate) {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
if (isSavingStatus) {
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
if ((new Date().getTime() - lastStatusSave.getTime()) < 1000 * 5) {
|
|
659
|
+
// Save at most every 5 seconds
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
if (succeededCount < upToDate.succeededCount || softFailedCount < upToDate.softFailedCount || failedCount < upToDate.failedCount) {
|
|
663
|
+
// Do not update on retries
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
lastStatusSave = new Date();
|
|
667
|
+
isSavingStatus = true;
|
|
668
|
+
upToDate.succeededCount = succeededCount;
|
|
669
|
+
upToDate.softFailedCount = softFailedCount;
|
|
670
|
+
upToDate.failedCount = failedCount;
|
|
671
|
+
try {
|
|
672
|
+
await upToDate.save();
|
|
673
|
+
}
|
|
674
|
+
finally {
|
|
675
|
+
isSavingStatus = false;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
while (true) {
|
|
679
|
+
abort.throwIfAborted();
|
|
680
|
+
const data = await SQL.select()
|
|
681
|
+
.from('email_recipients')
|
|
682
|
+
.where('emailId', upToDate.id)
|
|
683
|
+
.where('id', SQLWhereSign.Greater, idPointer)
|
|
684
|
+
.orderBy(SQL.column('id'), 'ASC')
|
|
685
|
+
.limit(batchSize)
|
|
686
|
+
.fetch();
|
|
687
|
+
const recipients = EmailRecipient.fromRows(data, 'email_recipients');
|
|
688
|
+
if (recipients.length === 0) {
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
const sendingPromises = [];
|
|
692
|
+
let skipped = 0;
|
|
693
|
+
for (const recipient of recipients) {
|
|
694
|
+
idPointer = recipient.id;
|
|
695
|
+
if (recipient.sentAt) {
|
|
696
|
+
succeededCount += 1;
|
|
697
|
+
await saveStatus();
|
|
698
|
+
skipped++;
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
if (!recipient.email) {
|
|
702
|
+
skipped++;
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
if (recipient.duplicateOfRecipientId) {
|
|
706
|
+
skipped++;
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
if (singleRecipientId) {
|
|
710
|
+
if (recipient.id !== singleRecipientId) {
|
|
711
|
+
// Failed or soft-failed
|
|
712
|
+
if (recipient.failError && isSoftEmailRecipientError(recipient.failError)) {
|
|
713
|
+
softFailedCount += 1;
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
failedCount += 1;
|
|
717
|
+
}
|
|
718
|
+
skipped++;
|
|
719
|
+
await saveStatus();
|
|
720
|
+
continue;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
const promise = upToDate.sendSingleRecipient(recipient, organization ?? null, {
|
|
724
|
+
from,
|
|
725
|
+
replyTo,
|
|
726
|
+
attachments,
|
|
727
|
+
});
|
|
728
|
+
sendingPromises.push(promise.then(async () => {
|
|
729
|
+
if (recipient.sentAt) {
|
|
730
|
+
succeededCount += 1;
|
|
731
|
+
await saveStatus();
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
// Failed or soft-failed
|
|
735
|
+
if (recipient.failError && isSoftEmailRecipientError(recipient.failError)) {
|
|
736
|
+
softFailedCount += 1;
|
|
737
|
+
}
|
|
738
|
+
else {
|
|
739
|
+
failedCount += 1;
|
|
740
|
+
}
|
|
741
|
+
await saveStatus();
|
|
742
|
+
}
|
|
743
|
+
}));
|
|
744
|
+
}
|
|
745
|
+
if (sendingPromises.length > 0 || skipped > 0) {
|
|
746
|
+
await Promise.all(sendingPromises);
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
break;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
catch (e) {
|
|
755
|
+
if (!upToDate) {
|
|
756
|
+
throw e;
|
|
757
|
+
}
|
|
758
|
+
if (!singleRecipientId) {
|
|
759
|
+
upToDate.succeededCount = succeededCount;
|
|
760
|
+
upToDate.softFailedCount = softFailedCount;
|
|
761
|
+
upToDate.failedCount = failedCount;
|
|
762
|
+
if (isAbortedError(e) || ((isSimpleError(e) || isSimpleErrors(e)) && e.hasCode('SHUTDOWN'))) {
|
|
763
|
+
// Keep sending status: we'll resume after the reboot
|
|
764
|
+
await upToDate.save();
|
|
765
|
+
throw e;
|
|
766
|
+
}
|
|
767
|
+
upToDate.emailErrors = errorToSimpleErrors(e);
|
|
768
|
+
upToDate.status = EmailStatus.Failed;
|
|
769
|
+
await upToDate.save();
|
|
770
|
+
}
|
|
771
|
+
throw e;
|
|
772
|
+
}
|
|
773
|
+
if (!singleRecipientId) {
|
|
774
|
+
if (upToDate.sendAsEmail && upToDate.emailRecipientsCount === 0 && upToDate.userId === null) {
|
|
775
|
+
// We only delete automated emails (email type) if they have no recipients
|
|
776
|
+
console.log('No recipients found for email ', upToDate.id, ' deleting...');
|
|
777
|
+
await upToDate.delete();
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
console.log('Finished sending email', upToDate.id);
|
|
781
|
+
// Mark email as sent
|
|
782
|
+
if (upToDate.sendAsEmail && !upToDate.showInMemberPortal && (succeededCount + failedCount + softFailedCount) === 0) {
|
|
783
|
+
upToDate.status = EmailStatus.Failed;
|
|
784
|
+
upToDate.emailErrors = new SimpleErrors(new SimpleError({
|
|
785
|
+
code: 'no_recipients',
|
|
786
|
+
message: 'No recipients',
|
|
787
|
+
human: $t(`%1EG`),
|
|
788
|
+
}));
|
|
789
|
+
}
|
|
790
|
+
else {
|
|
791
|
+
upToDate.status = EmailStatus.Sent;
|
|
792
|
+
upToDate.emailErrors = null;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
upToDate.succeededCount = succeededCount;
|
|
796
|
+
upToDate.softFailedCount = softFailedCount;
|
|
797
|
+
upToDate.failedCount = failedCount;
|
|
798
|
+
await upToDate.save();
|
|
799
|
+
return upToDate;
|
|
800
|
+
});
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
async updateCount() {
|
|
804
|
+
// First reset
|
|
805
|
+
const id = this.id;
|
|
806
|
+
await QueueHandler.schedule('email-count-' + this.id, async function () {
|
|
807
|
+
const upToDate = await Email.getByID(id);
|
|
808
|
+
if (!upToDate || upToDate.sentAt || !upToDate.id || upToDate.status !== EmailStatus.Draft) {
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
if (upToDate.recipientsStatus === EmailRecipientsStatus.Created) {
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
upToDate.emailRecipientsCount = null;
|
|
815
|
+
upToDate.recipientsErrors = null;
|
|
816
|
+
await upToDate.save();
|
|
817
|
+
});
|
|
818
|
+
await this.refresh();
|
|
819
|
+
QueueHandler.abort('email-count-' + this.id);
|
|
820
|
+
QueueHandler.schedule('email-count-' + this.id, async function ({ abort }) {
|
|
821
|
+
let upToDate = await Email.getByID(id);
|
|
822
|
+
if (!upToDate || upToDate.sentAt || !upToDate.id || upToDate.status !== EmailStatus.Draft) {
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
if (upToDate.recipientsStatus === EmailRecipientsStatus.Created) {
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
let count = 0;
|
|
829
|
+
console.log('Updating recipient count for email', id);
|
|
830
|
+
try {
|
|
831
|
+
for (const subfilter of upToDate.recipientFilter.filters) {
|
|
832
|
+
// Create recipients
|
|
833
|
+
const loader = Email.recipientLoaders.get(subfilter.type);
|
|
834
|
+
if (!loader) {
|
|
835
|
+
throw new Error('Loader for type ' + subfilter.type + ' has not been initialised on the Email model');
|
|
836
|
+
}
|
|
837
|
+
const request = new LimitedFilteredRequest({
|
|
838
|
+
filter: subfilter.filter,
|
|
839
|
+
sort: [{ key: 'id', order: SortItemDirection.ASC }],
|
|
840
|
+
limit: 1,
|
|
841
|
+
search: subfilter.search,
|
|
842
|
+
});
|
|
843
|
+
abort.throwIfAborted();
|
|
844
|
+
const c = await loader.count(request, subfilter.subfilter);
|
|
845
|
+
count += c;
|
|
846
|
+
}
|
|
847
|
+
abort.throwIfAborted();
|
|
848
|
+
// Check if we have a more reliable emailRecipientsCount in the meantime
|
|
849
|
+
upToDate = await Email.getByID(id);
|
|
850
|
+
if (!upToDate) {
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
if (upToDate.recipientsStatus === EmailRecipientsStatus.Created) {
|
|
854
|
+
console.log('Canceled recipient count update for email', id, 'already created recipients');
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
upToDate.emailRecipientsCount = count;
|
|
858
|
+
upToDate.recipientsErrors = null;
|
|
859
|
+
await upToDate.save();
|
|
860
|
+
console.log('Updated recipient count for email', id, 'to', count);
|
|
861
|
+
}
|
|
862
|
+
catch (e) {
|
|
863
|
+
if (isAbortedError(e)) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
console.error('Failed to update count for email', id);
|
|
867
|
+
console.error(e);
|
|
868
|
+
// Check if we have a more reliable emailRecipientsCount in the meantime
|
|
869
|
+
upToDate = await Email.getByID(id);
|
|
870
|
+
if (!upToDate) {
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
if (upToDate.recipientsStatus === EmailRecipientsStatus.Created) {
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
upToDate.recipientsErrors = errorToSimpleErrors(e);
|
|
877
|
+
upToDate.emailRecipientsCount = null;
|
|
878
|
+
await upToDate.save();
|
|
879
|
+
}
|
|
880
|
+
}).catch(console.error);
|
|
881
|
+
}
|
|
882
|
+
async buildRecipients() {
|
|
883
|
+
const id = this.id;
|
|
884
|
+
await QueueHandler.schedule('email-build-recipients-' + this.id, async function ({ abort }) {
|
|
885
|
+
const upToDate = await Email.getByID(id);
|
|
886
|
+
if (!upToDate || !upToDate.id) {
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
if (upToDate.recipientsStatus === EmailRecipientsStatus.Created) {
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
if (upToDate.status === EmailStatus.Sent) {
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
abort.throwIfAborted();
|
|
896
|
+
const organization = upToDate.organizationId ? (await Organization.getByID(upToDate.organizationId) ?? null) : null;
|
|
897
|
+
if (upToDate.organizationId && !organization) {
|
|
898
|
+
throw new SimpleError({
|
|
899
|
+
code: 'organization_not_found',
|
|
900
|
+
message: 'Organization not found',
|
|
901
|
+
human: $t(`%1NV`),
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
const platform = await Platform.getSharedPrivateStruct();
|
|
905
|
+
console.log('Building recipients for email', id);
|
|
906
|
+
// If it is already creating -> something went wrong (e.g. server restart) and we can safely try again
|
|
907
|
+
upToDate.recipientsStatus = EmailRecipientsStatus.Creating;
|
|
908
|
+
await upToDate.save();
|
|
909
|
+
const membersSet = new Set();
|
|
910
|
+
const emailsSet = new Set();
|
|
911
|
+
let count = 0;
|
|
912
|
+
let countWithoutEmail = 0;
|
|
913
|
+
try {
|
|
914
|
+
// Delete all recipients
|
|
915
|
+
await SQL
|
|
916
|
+
.delete()
|
|
917
|
+
.from(SQL.table('email_recipients'))
|
|
918
|
+
.where(SQL.column('emailId'), upToDate.id);
|
|
919
|
+
abort.throwIfAborted();
|
|
920
|
+
for (const subfilter of upToDate.recipientFilter.filters) {
|
|
921
|
+
// Create recipients
|
|
922
|
+
const loader = Email.recipientLoaders.get(subfilter.type);
|
|
923
|
+
if (!loader) {
|
|
924
|
+
throw new Error('Loader for type ' + subfilter.type + ' has not been initialised on the Email model');
|
|
925
|
+
}
|
|
926
|
+
let request = new LimitedFilteredRequest({
|
|
927
|
+
filter: subfilter.filter,
|
|
928
|
+
sort: [{ key: 'id', order: SortItemDirection.ASC }],
|
|
929
|
+
limit: 100,
|
|
930
|
+
search: subfilter.search,
|
|
931
|
+
});
|
|
932
|
+
const beforeFetchAllResult = loader.beforeFetchAll ? await loader.beforeFetchAll(request, subfilter.subfilter) : undefined;
|
|
933
|
+
while (request) {
|
|
934
|
+
abort.throwIfAborted();
|
|
935
|
+
const response = await loader.fetch(request, subfilter.subfilter, beforeFetchAllResult);
|
|
936
|
+
for (const item of response.results) {
|
|
937
|
+
if (!item.email && !item.memberId && !item.userId) {
|
|
938
|
+
continue;
|
|
939
|
+
}
|
|
940
|
+
const recipient = new EmailRecipient();
|
|
941
|
+
recipient.emailType = upToDate.emailType;
|
|
942
|
+
recipient.objectId = item.objectId;
|
|
943
|
+
recipient.emailId = upToDate.id;
|
|
944
|
+
recipient.email = item.email;
|
|
945
|
+
recipient.firstName = item.firstName;
|
|
946
|
+
recipient.lastName = item.lastName;
|
|
947
|
+
recipient.replacements = item.replacements;
|
|
948
|
+
recipient.memberId = item.memberId ?? null;
|
|
949
|
+
recipient.userId = item.userId ?? null;
|
|
950
|
+
recipient.organizationId = upToDate.organizationId ?? null;
|
|
951
|
+
await fillRecipientReplacements(recipient, {
|
|
952
|
+
platform,
|
|
953
|
+
organization,
|
|
954
|
+
from: upToDate.getFromAddress(),
|
|
955
|
+
replyTo: null,
|
|
956
|
+
forPreview: false,
|
|
957
|
+
});
|
|
958
|
+
recipient.replacements = removeUnusedReplacements(upToDate.html ?? '', recipient.replacements);
|
|
959
|
+
let duplicateOfRecipientId = null;
|
|
960
|
+
if (item.email && emailsSet.has(item.email)) {
|
|
961
|
+
console.log('Found duplicate email recipient', item.email);
|
|
962
|
+
// Try to merge
|
|
963
|
+
const existing = await EmailRecipient.select()
|
|
964
|
+
.where('emailId', upToDate.id)
|
|
965
|
+
.where('email', item.email)
|
|
966
|
+
.where('duplicateOfRecipientId', null)
|
|
967
|
+
.fetch();
|
|
968
|
+
for (const other of existing) {
|
|
969
|
+
const merged = mergeReplacementsIfEqual(other.replacements, recipient.replacements);
|
|
970
|
+
if (merged !== false) {
|
|
971
|
+
console.log('Found mergeable duplicate email recipient', item.email, other.id);
|
|
972
|
+
duplicateOfRecipientId = other.id;
|
|
973
|
+
other.replacements = merged;
|
|
974
|
+
other.firstName = other.firstName || item.firstName;
|
|
975
|
+
other.lastName = other.lastName || item.lastName;
|
|
976
|
+
await other.save();
|
|
977
|
+
recipient.replacements = merged;
|
|
978
|
+
break;
|
|
979
|
+
}
|
|
980
|
+
else {
|
|
981
|
+
console.log('Could not merge duplicate email recipient', item.email, other.id, 'keeping both', other.replacements, item.replacements);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
recipient.duplicateOfRecipientId = duplicateOfRecipientId;
|
|
986
|
+
await recipient.save();
|
|
987
|
+
if (recipient.memberId) {
|
|
988
|
+
membersSet.add(recipient.memberId);
|
|
989
|
+
}
|
|
990
|
+
if (recipient.email) {
|
|
991
|
+
emailsSet.add(recipient.email);
|
|
992
|
+
}
|
|
993
|
+
if (!recipient.email || duplicateOfRecipientId) {
|
|
994
|
+
countWithoutEmail += 1;
|
|
995
|
+
}
|
|
996
|
+
else {
|
|
997
|
+
count += 1;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
request = response.next ?? null;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
upToDate.recipientsStatus = EmailRecipientsStatus.Created;
|
|
1004
|
+
upToDate.emailRecipientsCount = count;
|
|
1005
|
+
upToDate.otherRecipientsCount = countWithoutEmail;
|
|
1006
|
+
upToDate.recipientsErrors = null;
|
|
1007
|
+
upToDate.membersCount = membersSet.size;
|
|
1008
|
+
await upToDate.save();
|
|
1009
|
+
}
|
|
1010
|
+
catch (e) {
|
|
1011
|
+
console.error('Failed to build recipients for email', id);
|
|
1012
|
+
console.error(e);
|
|
1013
|
+
upToDate.recipientsStatus = EmailRecipientsStatus.NotCreated;
|
|
1014
|
+
upToDate.recipientsErrors = errorToSimpleErrors(e);
|
|
1015
|
+
await upToDate.save();
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
async buildExampleRecipient(isNewlyCreated = false) {
|
|
1020
|
+
const id = this.id;
|
|
1021
|
+
await QueueHandler.schedule('email-build-recipients-' + this.id, async function () {
|
|
1022
|
+
const upToDate = await Email.getByID(id);
|
|
1023
|
+
if (!upToDate || upToDate.sentAt || !upToDate.id) {
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
if (upToDate.recipientsStatus !== EmailRecipientsStatus.NotCreated) {
|
|
1027
|
+
return;
|
|
1028
|
+
}
|
|
1029
|
+
try {
|
|
1030
|
+
// Delete all recipients
|
|
1031
|
+
if (!isNewlyCreated) {
|
|
1032
|
+
await SQL
|
|
1033
|
+
.delete()
|
|
1034
|
+
.from(SQL.table('email_recipients'))
|
|
1035
|
+
.where(SQL.column('emailId'), upToDate.id);
|
|
1036
|
+
}
|
|
1037
|
+
for (const subfilter of upToDate.recipientFilter.filters) {
|
|
1038
|
+
// Create recipients
|
|
1039
|
+
const loader = Email.recipientLoaders.get(subfilter.type);
|
|
1040
|
+
if (!loader) {
|
|
1041
|
+
throw new Error('Loader for type ' + subfilter.type + ' has not been initialised on the Email model');
|
|
1042
|
+
}
|
|
1043
|
+
let request = new LimitedFilteredRequest({
|
|
1044
|
+
filter: subfilter.filter,
|
|
1045
|
+
sort: [{ key: 'id', order: SortItemDirection.ASC }],
|
|
1046
|
+
limit: 10,
|
|
1047
|
+
search: subfilter.search,
|
|
1048
|
+
});
|
|
1049
|
+
const beforeFetchAllResult = loader.beforeFetchAll ? await loader.beforeFetchAll(request, subfilter.subfilter) : undefined;
|
|
1050
|
+
while (request) {
|
|
1051
|
+
const response = await loader.fetch(request, subfilter.subfilter, beforeFetchAllResult);
|
|
1052
|
+
// Note: it is possible that a result in the database doesn't return a recipient (in memory filtering)
|
|
1053
|
+
// so we do need pagination
|
|
1054
|
+
for (const item of response.results) {
|
|
1055
|
+
const recipient = new EmailRecipient();
|
|
1056
|
+
recipient.emailType = upToDate.emailType;
|
|
1057
|
+
recipient.emailId = upToDate.id;
|
|
1058
|
+
recipient.objectId = item.objectId;
|
|
1059
|
+
recipient.email = item.email;
|
|
1060
|
+
recipient.firstName = item.firstName;
|
|
1061
|
+
recipient.lastName = item.lastName;
|
|
1062
|
+
recipient.replacements = item.replacements;
|
|
1063
|
+
recipient.memberId = item.memberId ?? null;
|
|
1064
|
+
recipient.userId = item.userId ?? null;
|
|
1065
|
+
recipient.organizationId = upToDate.organizationId ?? null;
|
|
1066
|
+
await recipient.save();
|
|
1067
|
+
if (recipient.email || recipient.userId) {
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
request = null;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
console.warn('No example recipient found for email', id);
|
|
1075
|
+
}
|
|
1076
|
+
catch (e) {
|
|
1077
|
+
console.error('Failed to build example recipient for email', id);
|
|
1078
|
+
console.error(e);
|
|
1079
|
+
}
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
getStructure() {
|
|
1083
|
+
return EmailStruct.create(this);
|
|
1084
|
+
}
|
|
1085
|
+
async getPreviewStructure() {
|
|
1086
|
+
const emailRecipient = await EmailRecipient.select()
|
|
1087
|
+
.where('emailId', this.id)
|
|
1088
|
+
.where('email', '!=', null)
|
|
1089
|
+
.first(false);
|
|
1090
|
+
let recipientRow;
|
|
1091
|
+
if (emailRecipient) {
|
|
1092
|
+
recipientRow = await emailRecipient.getStructure();
|
|
1093
|
+
}
|
|
1094
|
+
if (!recipientRow) {
|
|
1095
|
+
recipientRow = getExampleRecipient();
|
|
1096
|
+
}
|
|
1097
|
+
const virtualRecipient = recipientRow.getRecipient();
|
|
1098
|
+
const organization = this.organizationId ? (await Organization.getByID(this.organizationId)) : null;
|
|
1099
|
+
await fillRecipientReplacements(virtualRecipient, {
|
|
1100
|
+
organization,
|
|
1101
|
+
from: this.getFromAddress(),
|
|
1102
|
+
replyTo: null,
|
|
1103
|
+
forPreview: true,
|
|
1104
|
+
forceRefresh: !this.sentAt,
|
|
1105
|
+
});
|
|
1106
|
+
recipientRow.replacements = virtualRecipient.replacements;
|
|
1107
|
+
let user = null;
|
|
1108
|
+
if (this.userId) {
|
|
1109
|
+
const u = await User.getByID(this.userId);
|
|
1110
|
+
if (u) {
|
|
1111
|
+
user = u.getStructure();
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
let organizationStruct = null;
|
|
1115
|
+
if (organization) {
|
|
1116
|
+
organizationStruct = organization.getBaseStructure();
|
|
1117
|
+
}
|
|
1118
|
+
return EmailPreview.create({
|
|
1119
|
+
...this,
|
|
1120
|
+
user,
|
|
1121
|
+
organization: organizationStruct,
|
|
1122
|
+
exampleRecipient: recipientRow,
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
async getStructureForUser(user, memberIds) {
|
|
1126
|
+
const emailRecipients = await EmailRecipient.select()
|
|
1127
|
+
.where('emailId', this.id)
|
|
1128
|
+
.where('memberId', memberIds)
|
|
1129
|
+
.fetch();
|
|
1130
|
+
const organization = this.organizationId ? (await Organization.getByID(this.organizationId)) : null;
|
|
1131
|
+
const recipientsMap = new Map();
|
|
1132
|
+
for (const memberId of memberIds) {
|
|
1133
|
+
const preferred = emailRecipients.find(e => e.memberId === memberId && (e.userId === user.id || e.email === user.email));
|
|
1134
|
+
if (preferred) {
|
|
1135
|
+
recipientsMap.set(preferred.duplicateOfRecipientId ?? preferred.id, preferred);
|
|
1136
|
+
continue;
|
|
1137
|
+
}
|
|
1138
|
+
const byMember = emailRecipients.find(e => e.memberId === memberId && e.userId === null && e.email === null);
|
|
1139
|
+
if (byMember) {
|
|
1140
|
+
recipientsMap.set(byMember.duplicateOfRecipientId ?? byMember.id, byMember);
|
|
1141
|
+
continue;
|
|
1142
|
+
}
|
|
1143
|
+
const anyData = emailRecipients.find(e => e.memberId === memberId);
|
|
1144
|
+
if (anyData) {
|
|
1145
|
+
recipientsMap.set(anyData.duplicateOfRecipientId ?? anyData.id, anyData);
|
|
1146
|
+
continue;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
// Remove duplicates that are marked as the same recipient
|
|
1150
|
+
const cleanedRecipients = [...recipientsMap.values()];
|
|
1151
|
+
const structures = await EmailRecipient.getStructures(cleanedRecipients);
|
|
1152
|
+
for (const struct of structures) {
|
|
1153
|
+
if (!(struct.userId === user.id || struct.email === user.email) && !((struct.userId === null && struct.email === null))) {
|
|
1154
|
+
stripSensitiveRecipientReplacements(struct, {
|
|
1155
|
+
organization,
|
|
1156
|
+
willFill: true,
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
struct.firstName = user.firstName;
|
|
1160
|
+
struct.lastName = user.lastName;
|
|
1161
|
+
struct.email = user.email;
|
|
1162
|
+
struct.userId = user.id;
|
|
1163
|
+
// We always refresh the data when we display it on the web (so everything is up to date)
|
|
1164
|
+
await fillRecipientReplacements(struct, {
|
|
1165
|
+
organization,
|
|
1166
|
+
from: this.getFromAddress(),
|
|
1167
|
+
replyTo: null,
|
|
1168
|
+
forPreview: false,
|
|
1169
|
+
forceRefresh: true,
|
|
1170
|
+
});
|
|
1171
|
+
stripRecipientReplacementsForWebDisplay(struct, {
|
|
1172
|
+
organization,
|
|
1173
|
+
});
|
|
1174
|
+
if (this.html) {
|
|
1175
|
+
struct.replacements = removeUnusedReplacements(this.html, struct.replacements);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
// Loop structures and remove if they have exactly the same content
|
|
1179
|
+
// We do this here, because it is possible the user didn't receive any emails, so
|
|
1180
|
+
// the merging at time of sending the emails didn't happen (uniqueness happened on email)
|
|
1181
|
+
const uniqueStructures = [];
|
|
1182
|
+
for (const struct of structures) {
|
|
1183
|
+
let found = false;
|
|
1184
|
+
for (const unique of uniqueStructures) {
|
|
1185
|
+
const merged = mergeReplacementsIfEqual(unique.replacements, struct.replacements);
|
|
1186
|
+
if (merged !== false) {
|
|
1187
|
+
unique.replacements = merged;
|
|
1188
|
+
found = true;
|
|
1189
|
+
break;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
if (!found) {
|
|
1193
|
+
uniqueStructures.push(struct);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
let organizationStruct = null;
|
|
1197
|
+
if (organization) {
|
|
1198
|
+
organizationStruct = organization.getBaseStructure();
|
|
1199
|
+
}
|
|
1200
|
+
return EmailWithRecipients.create({
|
|
1201
|
+
...this,
|
|
1202
|
+
organization: organizationStruct,
|
|
1203
|
+
recipients: uniqueStructures,
|
|
1204
|
+
// Remove private-like data
|
|
1205
|
+
softBouncesCount: 0,
|
|
1206
|
+
failedCount: 0,
|
|
1207
|
+
emailErrors: null,
|
|
1208
|
+
recipientsErrors: null,
|
|
1209
|
+
succeededCount: 1,
|
|
1210
|
+
emailRecipientsCount: 1,
|
|
1211
|
+
hardBouncesCount: 0,
|
|
1212
|
+
spamComplaintsCount: 0,
|
|
1213
|
+
recipientFilter: EmailRecipientFilter.create({}),
|
|
1214
|
+
membersCount: 1,
|
|
1215
|
+
otherRecipientsCount: 0,
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
__decorate([
|
|
1220
|
+
column({
|
|
1221
|
+
primary: true, type: 'string', beforeSave(value) {
|
|
1222
|
+
return value ?? uuidv4();
|
|
1223
|
+
},
|
|
1224
|
+
})
|
|
1225
|
+
], Email.prototype, "id", void 0);
|
|
1226
|
+
__decorate([
|
|
1227
|
+
column({ type: 'string', nullable: true })
|
|
1228
|
+
], Email.prototype, "organizationId", void 0);
|
|
1229
|
+
__decorate([
|
|
1230
|
+
column({ type: 'string', nullable: true })
|
|
1231
|
+
], Email.prototype, "senderId", void 0);
|
|
1232
|
+
__decorate([
|
|
1233
|
+
column({ type: 'string', nullable: true })
|
|
1234
|
+
], Email.prototype, "userId", void 0);
|
|
1235
|
+
__decorate([
|
|
1236
|
+
column({ type: 'boolean' })
|
|
1237
|
+
], Email.prototype, "sendAsEmail", void 0);
|
|
1238
|
+
__decorate([
|
|
1239
|
+
column({ type: 'boolean' })
|
|
1240
|
+
], Email.prototype, "showInMemberPortal", void 0);
|
|
1241
|
+
__decorate([
|
|
1242
|
+
column({ type: 'json', decoder: EmailRecipientFilter })
|
|
1243
|
+
], Email.prototype, "recipientFilter", void 0);
|
|
1244
|
+
__decorate([
|
|
1245
|
+
column({ type: 'string', nullable: true })
|
|
1246
|
+
], Email.prototype, "emailType", void 0);
|
|
1247
|
+
__decorate([
|
|
1248
|
+
column({ type: 'string', nullable: true })
|
|
1249
|
+
], Email.prototype, "subject", void 0);
|
|
1250
|
+
__decorate([
|
|
1251
|
+
column({ type: 'json', decoder: AnyDecoder })
|
|
1252
|
+
], Email.prototype, "json", void 0);
|
|
1253
|
+
__decorate([
|
|
1254
|
+
column({ type: 'string', nullable: true })
|
|
1255
|
+
], Email.prototype, "html", void 0);
|
|
1256
|
+
__decorate([
|
|
1257
|
+
column({ type: 'string', nullable: true })
|
|
1258
|
+
], Email.prototype, "text", void 0);
|
|
1259
|
+
__decorate([
|
|
1260
|
+
column({ type: 'string', nullable: true })
|
|
1261
|
+
], Email.prototype, "fromAddress", void 0);
|
|
1262
|
+
__decorate([
|
|
1263
|
+
column({ type: 'string', nullable: true })
|
|
1264
|
+
], Email.prototype, "fromName", void 0);
|
|
1265
|
+
__decorate([
|
|
1266
|
+
column({ type: 'integer', nullable: true })
|
|
1267
|
+
], Email.prototype, "emailRecipientsCount", void 0);
|
|
1268
|
+
__decorate([
|
|
1269
|
+
column({ type: 'integer', nullable: true })
|
|
1270
|
+
], Email.prototype, "otherRecipientsCount", void 0);
|
|
1271
|
+
__decorate([
|
|
1272
|
+
column({ type: 'integer' })
|
|
1273
|
+
], Email.prototype, "succeededCount", void 0);
|
|
1274
|
+
__decorate([
|
|
1275
|
+
column({ type: 'integer' })
|
|
1276
|
+
], Email.prototype, "softFailedCount", void 0);
|
|
1277
|
+
__decorate([
|
|
1278
|
+
column({ type: 'integer' })
|
|
1279
|
+
], Email.prototype, "failedCount", void 0);
|
|
1280
|
+
__decorate([
|
|
1281
|
+
column({ type: 'integer' })
|
|
1282
|
+
], Email.prototype, "membersCount", void 0);
|
|
1283
|
+
__decorate([
|
|
1284
|
+
column({ type: 'integer' })
|
|
1285
|
+
], Email.prototype, "hardBouncesCount", void 0);
|
|
1286
|
+
__decorate([
|
|
1287
|
+
column({ type: 'integer' })
|
|
1288
|
+
], Email.prototype, "softBouncesCount", void 0);
|
|
1289
|
+
__decorate([
|
|
1290
|
+
column({ type: 'integer' })
|
|
1291
|
+
], Email.prototype, "spamComplaintsCount", void 0);
|
|
1292
|
+
__decorate([
|
|
1293
|
+
column({ type: 'string' })
|
|
1294
|
+
], Email.prototype, "status", void 0);
|
|
1295
|
+
__decorate([
|
|
1296
|
+
column({ type: 'string' })
|
|
1297
|
+
], Email.prototype, "recipientsStatus", void 0);
|
|
1298
|
+
__decorate([
|
|
1299
|
+
column({ type: 'json', nullable: true, decoder: SimpleErrors })
|
|
1300
|
+
], Email.prototype, "recipientsErrors", void 0);
|
|
1301
|
+
__decorate([
|
|
1302
|
+
column({ type: 'json', nullable: true, decoder: SimpleErrors })
|
|
1303
|
+
], Email.prototype, "emailErrors", void 0);
|
|
1304
|
+
__decorate([
|
|
1305
|
+
column({ type: 'json', decoder: new ArrayDecoder(EmailAttachment) })
|
|
1306
|
+
], Email.prototype, "attachments", void 0);
|
|
1307
|
+
__decorate([
|
|
1308
|
+
column({
|
|
1309
|
+
type: 'datetime',
|
|
1310
|
+
nullable: true,
|
|
1311
|
+
})
|
|
1312
|
+
], Email.prototype, "sentAt", void 0);
|
|
1313
|
+
__decorate([
|
|
1314
|
+
column({
|
|
1315
|
+
type: 'datetime',
|
|
1316
|
+
nullable: true,
|
|
1317
|
+
})
|
|
1318
|
+
], Email.prototype, "deletedAt", void 0);
|
|
1319
|
+
__decorate([
|
|
1320
|
+
column({
|
|
1321
|
+
type: 'datetime', beforeSave(old) {
|
|
1322
|
+
if (old !== undefined) {
|
|
1323
|
+
return old;
|
|
1324
|
+
}
|
|
1325
|
+
const date = new Date();
|
|
1326
|
+
date.setMilliseconds(0);
|
|
1327
|
+
return date;
|
|
1328
|
+
},
|
|
1329
|
+
})
|
|
1330
|
+
], Email.prototype, "createdAt", void 0);
|
|
1331
|
+
__decorate([
|
|
1332
|
+
column({
|
|
1333
|
+
type: 'datetime', beforeSave() {
|
|
1334
|
+
const date = new Date();
|
|
1335
|
+
date.setMilliseconds(0);
|
|
1336
|
+
return date;
|
|
1337
|
+
},
|
|
1338
|
+
skipUpdate: true,
|
|
1339
|
+
})
|
|
1340
|
+
], Email.prototype, "updatedAt", void 0);
|
|
1341
|
+
//# sourceMappingURL=Email.js.map
|