@stamhoofd/models 2.1.1
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/src/assets/Metropolis-Black.woff2 +0 -0
- package/dist/src/assets/Metropolis-BlackItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-Bold.woff2 +0 -0
- package/dist/src/assets/Metropolis-BoldItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-ExtraBold.woff2 +0 -0
- package/dist/src/assets/Metropolis-ExtraBoldItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-ExtraLight.woff2 +0 -0
- package/dist/src/assets/Metropolis-ExtraLightItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-Light.woff2 +0 -0
- package/dist/src/assets/Metropolis-LightItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-Medium.woff2 +0 -0
- package/dist/src/assets/Metropolis-MediumItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-Regular.woff2 +0 -0
- package/dist/src/assets/Metropolis-RegularItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-SemiBold.woff2 +0 -0
- package/dist/src/assets/Metropolis-SemiBoldItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-Thin.woff2 +0 -0
- package/dist/src/assets/Metropolis-ThinItalic.woff2 +0 -0
- 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/assets/logo.png +0 -0
- package/dist/src/factories/AddressFactory.d.ts +10 -0
- package/dist/src/factories/AddressFactory.d.ts.map +1 -0
- package/dist/src/factories/AddressFactory.js +42 -0
- package/dist/src/factories/AddressFactory.js.map +1 -0
- package/dist/src/factories/EmergencyContactFactory.d.ts +9 -0
- package/dist/src/factories/EmergencyContactFactory.d.ts.map +1 -0
- package/dist/src/factories/EmergencyContactFactory.js +42 -0
- package/dist/src/factories/EmergencyContactFactory.js.map +1 -0
- package/dist/src/factories/GroupFactory.d.ts +19 -0
- package/dist/src/factories/GroupFactory.d.ts.map +1 -0
- package/dist/src/factories/GroupFactory.js +52 -0
- package/dist/src/factories/GroupFactory.js.map +1 -0
- package/dist/src/factories/MemberFactory.d.ts +16 -0
- package/dist/src/factories/MemberFactory.d.ts.map +1 -0
- package/dist/src/factories/MemberFactory.js +98 -0
- package/dist/src/factories/MemberFactory.js.map +1 -0
- package/dist/src/factories/OrganizationFactory.d.ts +16 -0
- package/dist/src/factories/OrganizationFactory.d.ts.map +1 -0
- package/dist/src/factories/OrganizationFactory.js +40 -0
- package/dist/src/factories/OrganizationFactory.js.map +1 -0
- package/dist/src/factories/ParentFactory.d.ts +10 -0
- package/dist/src/factories/ParentFactory.d.ts.map +1 -0
- package/dist/src/factories/ParentFactory.js +44 -0
- package/dist/src/factories/ParentFactory.js.map +1 -0
- package/dist/src/factories/RecordFactory.d.ts +10 -0
- package/dist/src/factories/RecordFactory.d.ts.map +1 -0
- package/dist/src/factories/RecordFactory.js +14 -0
- package/dist/src/factories/RecordFactory.js.map +1 -0
- package/dist/src/factories/RegisterCodeFactory.d.ts +18 -0
- package/dist/src/factories/RegisterCodeFactory.d.ts.map +1 -0
- package/dist/src/factories/RegisterCodeFactory.js +19 -0
- package/dist/src/factories/RegisterCodeFactory.js.map +1 -0
- package/dist/src/factories/RegistrationFactory.d.ts +14 -0
- package/dist/src/factories/RegistrationFactory.d.ts.map +1 -0
- package/dist/src/factories/RegistrationFactory.js +26 -0
- package/dist/src/factories/RegistrationFactory.js.map +1 -0
- package/dist/src/factories/UserFactory.d.ts +21 -0
- package/dist/src/factories/UserFactory.d.ts.map +1 -0
- package/dist/src/factories/UserFactory.js +41 -0
- package/dist/src/factories/UserFactory.js.map +1 -0
- package/dist/src/factories/WebshopFactory.d.ts +16 -0
- package/dist/src/factories/WebshopFactory.d.ts.map +1 -0
- package/dist/src/factories/WebshopFactory.js +35 -0
- package/dist/src/factories/WebshopFactory.js.map +1 -0
- package/dist/src/helpers/DNSValidator.d.ts +6 -0
- package/dist/src/helpers/DNSValidator.d.ts.map +1 -0
- package/dist/src/helpers/DNSValidator.js +144 -0
- package/dist/src/helpers/DNSValidator.js.map +1 -0
- package/dist/src/helpers/EmailBuilder.d.ts +22 -0
- package/dist/src/helpers/EmailBuilder.d.ts.map +1 -0
- package/dist/src/helpers/EmailBuilder.js +100 -0
- package/dist/src/helpers/EmailBuilder.js.map +1 -0
- package/dist/src/helpers/GroupBuilder.d.ts +9 -0
- package/dist/src/helpers/GroupBuilder.d.ts.map +1 -0
- package/dist/src/helpers/GroupBuilder.js +382 -0
- package/dist/src/helpers/GroupBuilder.js.map +1 -0
- package/dist/src/helpers/Handlebars.d.ts +2 -0
- package/dist/src/helpers/Handlebars.d.ts.map +1 -0
- package/dist/src/helpers/Handlebars.js +192 -0
- package/dist/src/helpers/Handlebars.js.map +1 -0
- package/dist/src/helpers/InvoiceBuilder.d.ts +29 -0
- package/dist/src/helpers/InvoiceBuilder.d.ts.map +1 -0
- package/dist/src/helpers/InvoiceBuilder.js +406 -0
- package/dist/src/helpers/InvoiceBuilder.js.map +1 -0
- package/dist/src/helpers/InvoiceBuilder.test.d.ts +2 -0
- package/dist/src/helpers/InvoiceBuilder.test.d.ts.map +1 -0
- package/dist/src/helpers/InvoiceBuilder.test.js +52 -0
- package/dist/src/helpers/InvoiceBuilder.test.js.map +1 -0
- package/dist/src/helpers/RateLimiter.d.ts +27 -0
- package/dist/src/helpers/RateLimiter.d.ts.map +1 -0
- package/dist/src/helpers/RateLimiter.js +57 -0
- package/dist/src/helpers/RateLimiter.js.map +1 -0
- package/dist/src/helpers/WebshopCounter.d.ts +6 -0
- package/dist/src/helpers/WebshopCounter.d.ts.map +1 -0
- package/dist/src/helpers/WebshopCounter.js +36 -0
- package/dist/src/helpers/WebshopCounter.js.map +1 -0
- package/dist/src/helpers/WebshopCounter.test.d.ts +2 -0
- package/dist/src/helpers/WebshopCounter.test.d.ts.map +1 -0
- package/dist/src/helpers/WebshopCounter.test.js +17 -0
- package/dist/src/helpers/WebshopCounter.test.js.map +1 -0
- package/dist/src/index.d.ts +18 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +23 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/migrations/1593773929-create-initial-tables.sql +634 -0
- package/dist/src/migrations/1605261999-gemeenten-tmp.sql +2820 -0
- package/dist/src/migrations/1605262045-import-postcodes.d.ts +16 -0
- package/dist/src/migrations/1605262045-import-postcodes.d.ts.map +1 -0
- package/dist/src/migrations/1605262045-import-postcodes.js +116 -0
- package/dist/src/migrations/1605262045-import-postcodes.js.map +1 -0
- package/dist/src/migrations/1605262046-import-postcodes-nl.d.ts +4 -0
- package/dist/src/migrations/1605262046-import-postcodes-nl.d.ts.map +1 -0
- package/dist/src/migrations/1605262046-import-postcodes-nl.js +83 -0
- package/dist/src/migrations/1605262046-import-postcodes-nl.js.map +1 -0
- package/dist/src/migrations/1605279038-drop-gemeenten-tmp.sql +1 -0
- package/dist/src/migrations/1648392491-default-templates.sql +9 -0
- package/dist/src/migrations/1651245707-default-templates-reminders.sql +6 -0
- package/dist/src/migrations/1708607340-tickets-deleted-at.sql +1 -0
- package/dist/src/migrations/1710459176-register-code-invoices.sql +3 -0
- package/dist/src/migrations/1712158247-discount-codes.sql +17 -0
- package/dist/src/migrations/1713178665-drop-invites.sql +1 -0
- package/dist/src/migrations/1713178666-drop-keychain.sql +1 -0
- package/dist/src/migrations/1713178667-drop-challenges.sql +1 -0
- package/dist/src/migrations/1713178668-drop-user-keys.sql +7 -0
- package/dist/src/migrations/1713178669-drop-organization-key.sql +2 -0
- package/dist/src/migrations/data/postcodes/nl/Drenthe +291 -0
- package/dist/src/migrations/data/postcodes/nl/Flevoland +107 -0
- package/dist/src/migrations/data/postcodes/nl/Friesland +518 -0
- package/dist/src/migrations/data/postcodes/nl/Gelderland +601 -0
- package/dist/src/migrations/data/postcodes/nl/Groningen +279 -0
- package/dist/src/migrations/data/postcodes/nl/Limburg +324 -0
- package/dist/src/migrations/data/postcodes/nl/Noord-Brabant +620 -0
- package/dist/src/migrations/data/postcodes/nl/Noord-Holland +566 -0
- package/dist/src/migrations/data/postcodes/nl/Overrijsel +344 -0
- package/dist/src/migrations/data/postcodes/nl/Utrecht +278 -0
- package/dist/src/migrations/data/postcodes/nl/Zeeland +179 -0
- package/dist/src/migrations/data/postcodes/nl/Zuid-Holland +662 -0
- package/dist/src/models/BalanceItem.d.ts +57 -0
- package/dist/src/models/BalanceItem.d.ts.map +1 -0
- package/dist/src/models/BalanceItem.js +346 -0
- package/dist/src/models/BalanceItem.js.map +1 -0
- package/dist/src/models/BalanceItemPayment.d.ts +31 -0
- package/dist/src/models/BalanceItemPayment.d.ts.map +1 -0
- package/dist/src/models/BalanceItemPayment.js +101 -0
- package/dist/src/models/BalanceItemPayment.js.map +1 -0
- package/dist/src/models/BuckarooPayment.d.ts +8 -0
- package/dist/src/models/BuckarooPayment.d.ts.map +1 -0
- package/dist/src/models/BuckarooPayment.js +24 -0
- package/dist/src/models/BuckarooPayment.js.map +1 -0
- package/dist/src/models/Document.d.ts +44 -0
- package/dist/src/models/Document.d.ts.map +1 -0
- package/dist/src/models/Document.js +194 -0
- package/dist/src/models/Document.js.map +1 -0
- package/dist/src/models/DocumentTemplate.d.ts +45 -0
- package/dist/src/models/DocumentTemplate.d.ts.map +1 -0
- package/dist/src/models/DocumentTemplate.js +533 -0
- package/dist/src/models/DocumentTemplate.js.map +1 -0
- package/dist/src/models/EmailTemplate.d.ts +22 -0
- package/dist/src/models/EmailTemplate.d.ts.map +1 -0
- package/dist/src/models/EmailTemplate.js +70 -0
- package/dist/src/models/EmailTemplate.js.map +1 -0
- package/dist/src/models/EmailVerificationCode.d.ts +60 -0
- package/dist/src/models/EmailVerificationCode.d.ts.map +1 -0
- package/dist/src/models/EmailVerificationCode.js +307 -0
- package/dist/src/models/EmailVerificationCode.js.map +1 -0
- package/dist/src/models/Group.d.ts +36 -0
- package/dist/src/models/Group.d.ts.map +1 -0
- package/dist/src/models/Group.js +231 -0
- package/dist/src/models/Group.js.map +1 -0
- package/dist/src/models/Image.d.ts +12 -0
- package/dist/src/models/Image.d.ts.map +1 -0
- package/dist/src/models/Image.js +137 -0
- package/dist/src/models/Image.js.map +1 -0
- package/dist/src/models/Member.d.ts +66 -0
- package/dist/src/models/Member.d.ts.map +1 -0
- package/dist/src/models/Member.js +309 -0
- package/dist/src/models/Member.js.map +1 -0
- package/dist/src/models/MemberResponsibilityRecord.d.ts +11 -0
- package/dist/src/models/MemberResponsibilityRecord.d.ts.map +1 -0
- package/dist/src/models/MemberResponsibilityRecord.js +47 -0
- package/dist/src/models/MemberResponsibilityRecord.js.map +1 -0
- package/dist/src/models/MolliePayment.d.ts +8 -0
- package/dist/src/models/MolliePayment.d.ts.map +1 -0
- package/dist/src/models/MolliePayment.js +24 -0
- package/dist/src/models/MolliePayment.js.map +1 -0
- package/dist/src/models/MollieToken.d.ts +45 -0
- package/dist/src/models/MollieToken.d.ts.map +1 -0
- package/dist/src/models/MollieToken.js +333 -0
- package/dist/src/models/MollieToken.js.map +1 -0
- package/dist/src/models/OneTimeToken.d.ts +38 -0
- package/dist/src/models/OneTimeToken.d.ts.map +1 -0
- package/dist/src/models/OneTimeToken.js +126 -0
- package/dist/src/models/OneTimeToken.js.map +1 -0
- package/dist/src/models/Order.d.ts +99 -0
- package/dist/src/models/Order.d.ts.map +1 -0
- package/dist/src/models/Order.js +912 -0
- package/dist/src/models/Order.js.map +1 -0
- package/dist/src/models/Organization.d.ts +119 -0
- package/dist/src/models/Organization.d.ts.map +1 -0
- package/dist/src/models/Organization.js +900 -0
- package/dist/src/models/Organization.js.map +1 -0
- package/dist/src/models/OrganizationRegistrationPeriod.d.ts +14 -0
- package/dist/src/models/OrganizationRegistrationPeriod.d.ts.map +1 -0
- package/dist/src/models/OrganizationRegistrationPeriod.js +62 -0
- package/dist/src/models/OrganizationRegistrationPeriod.js.map +1 -0
- package/dist/src/models/PasswordToken.d.ts +29 -0
- package/dist/src/models/PasswordToken.d.ts.map +1 -0
- package/dist/src/models/PasswordToken.js +118 -0
- package/dist/src/models/PasswordToken.js.map +1 -0
- package/dist/src/models/PayconiqPayment.d.ts +18 -0
- package/dist/src/models/PayconiqPayment.d.ts.map +1 -0
- package/dist/src/models/PayconiqPayment.js +216 -0
- package/dist/src/models/PayconiqPayment.js.map +1 -0
- package/dist/src/models/Payment.d.ts +62 -0
- package/dist/src/models/Payment.d.ts.map +1 -0
- package/dist/src/models/Payment.js +199 -0
- package/dist/src/models/Payment.js.map +1 -0
- package/dist/src/models/Platform.d.ts +15 -0
- package/dist/src/models/Platform.d.ts.map +1 -0
- package/dist/src/models/Platform.js +77 -0
- package/dist/src/models/Platform.js.map +1 -0
- package/dist/src/models/RegisterCode.d.ts +27 -0
- package/dist/src/models/RegisterCode.d.ts.map +1 -0
- package/dist/src/models/RegisterCode.js +162 -0
- package/dist/src/models/RegisterCode.js.map +1 -0
- package/dist/src/models/Registration.d.ts +47 -0
- package/dist/src/models/Registration.d.ts.map +1 -0
- package/dist/src/models/Registration.js +369 -0
- package/dist/src/models/Registration.js.map +1 -0
- package/dist/src/models/RegistrationPeriod.d.ts +15 -0
- package/dist/src/models/RegistrationPeriod.d.ts.map +1 -0
- package/dist/src/models/RegistrationPeriod.js +64 -0
- package/dist/src/models/RegistrationPeriod.js.map +1 -0
- package/dist/src/models/STCredit.d.ts +20 -0
- package/dist/src/models/STCredit.d.ts.map +1 -0
- package/dist/src/models/STCredit.js +129 -0
- package/dist/src/models/STCredit.js.map +1 -0
- package/dist/src/models/STInvoice.d.ts +51 -0
- package/dist/src/models/STInvoice.d.ts.map +1 -0
- package/dist/src/models/STInvoice.js +453 -0
- package/dist/src/models/STInvoice.js.map +1 -0
- package/dist/src/models/STPackage.d.ts +36 -0
- package/dist/src/models/STPackage.d.ts.map +1 -0
- package/dist/src/models/STPackage.js +300 -0
- package/dist/src/models/STPackage.js.map +1 -0
- package/dist/src/models/STPendingInvoice.d.ts +45 -0
- package/dist/src/models/STPendingInvoice.d.ts.map +1 -0
- package/dist/src/models/STPendingInvoice.js +284 -0
- package/dist/src/models/STPendingInvoice.js.map +1 -0
- package/dist/src/models/StripeAccount.d.ts +17 -0
- package/dist/src/models/StripeAccount.d.ts.map +1 -0
- package/dist/src/models/StripeAccount.js +81 -0
- package/dist/src/models/StripeAccount.js.map +1 -0
- package/dist/src/models/StripeCheckoutSession.d.ts +9 -0
- package/dist/src/models/StripeCheckoutSession.d.ts.map +1 -0
- package/dist/src/models/StripeCheckoutSession.js +31 -0
- package/dist/src/models/StripeCheckoutSession.js.map +1 -0
- package/dist/src/models/StripePaymentIntent.d.ts +9 -0
- package/dist/src/models/StripePaymentIntent.d.ts.map +1 -0
- package/dist/src/models/StripePaymentIntent.js +31 -0
- package/dist/src/models/StripePaymentIntent.js.map +1 -0
- package/dist/src/models/Ticket.d.ts +61 -0
- package/dist/src/models/Ticket.d.ts.map +1 -0
- package/dist/src/models/Ticket.js +143 -0
- package/dist/src/models/Ticket.js.map +1 -0
- package/dist/src/models/Token.d.ts +49 -0
- package/dist/src/models/Token.d.ts.map +1 -0
- package/dist/src/models/Token.js +218 -0
- package/dist/src/models/Token.js.map +1 -0
- package/dist/src/models/Token.test.d.ts +2 -0
- package/dist/src/models/Token.test.d.ts.map +1 -0
- package/dist/src/models/Token.test.js +60 -0
- package/dist/src/models/Token.test.js.map +1 -0
- package/dist/src/models/UsedRegisterCode.d.ts +22 -0
- package/dist/src/models/UsedRegisterCode.d.ts.map +1 -0
- package/dist/src/models/UsedRegisterCode.js +158 -0
- package/dist/src/models/UsedRegisterCode.js.map +1 -0
- package/dist/src/models/User.d.ts +55 -0
- package/dist/src/models/User.d.ts.map +1 -0
- package/dist/src/models/User.js +314 -0
- package/dist/src/models/User.js.map +1 -0
- package/dist/src/models/UserPermissions.d.ts +15 -0
- package/dist/src/models/UserPermissions.d.ts.map +1 -0
- package/dist/src/models/UserPermissions.js +57 -0
- package/dist/src/models/UserPermissions.js.map +1 -0
- package/dist/src/models/Webshop.d.ts +44 -0
- package/dist/src/models/Webshop.d.ts.map +1 -0
- package/dist/src/models/Webshop.js +184 -0
- package/dist/src/models/Webshop.js.map +1 -0
- package/dist/src/models/WebshopDiscountCode.d.ts +18 -0
- package/dist/src/models/WebshopDiscountCode.d.ts.map +1 -0
- package/dist/src/models/WebshopDiscountCode.js +88 -0
- package/dist/src/models/WebshopDiscountCode.js.map +1 -0
- package/dist/src/models/addresses/City.d.ts +14 -0
- package/dist/src/models/addresses/City.d.ts.map +1 -0
- package/dist/src/models/addresses/City.js +37 -0
- package/dist/src/models/addresses/City.js.map +1 -0
- package/dist/src/models/addresses/PostalCode.d.ts +20 -0
- package/dist/src/models/addresses/PostalCode.d.ts.map +1 -0
- package/dist/src/models/addresses/PostalCode.js +138 -0
- package/dist/src/models/addresses/PostalCode.js.map +1 -0
- package/dist/src/models/addresses/PostalCode.test.d.ts +2 -0
- package/dist/src/models/addresses/PostalCode.test.d.ts.map +1 -0
- package/dist/src/models/addresses/PostalCode.test.js +98 -0
- package/dist/src/models/addresses/PostalCode.test.js.map +1 -0
- package/dist/src/models/addresses/Province.d.ts +9 -0
- package/dist/src/models/addresses/Province.d.ts.map +1 -0
- package/dist/src/models/addresses/Province.js +24 -0
- package/dist/src/models/addresses/Province.js.map +1 -0
- package/dist/src/models/addresses/Street.d.ts +10 -0
- package/dist/src/models/addresses/Street.d.ts.map +1 -0
- package/dist/src/models/addresses/Street.js +26 -0
- package/dist/src/models/addresses/Street.js.map +1 -0
- package/dist/src/models/index.d.ts +37 -0
- package/dist/src/models/index.d.ts.map +1 -0
- package/dist/src/models/index.js +53 -0
- package/dist/src/models/index.js.map +1 -0
- package/dist/src/structures/OrganizationServerMetaData.d.ts +43 -0
- package/dist/src/structures/OrganizationServerMetaData.d.ts.map +1 -0
- package/dist/src/structures/OrganizationServerMetaData.js +128 -0
- package/dist/src/structures/OrganizationServerMetaData.js.map +1 -0
- package/dist/tests/jest.global.setup.d.ts +3 -0
- package/dist/tests/jest.global.setup.d.ts.map +1 -0
- package/dist/tests/jest.global.setup.js +20 -0
- package/dist/tests/jest.global.setup.js.map +1 -0
- package/dist/tests/jest.setup.d.ts +2 -0
- package/dist/tests/jest.setup.d.ts.map +1 -0
- package/dist/tests/jest.setup.js +15 -0
- package/dist/tests/jest.setup.js.map +1 -0
- package/package.json +30 -0
- package/src/assets/Metropolis-Black.woff2 +0 -0
- package/src/assets/Metropolis-BlackItalic.woff2 +0 -0
- package/src/assets/Metropolis-Bold.woff2 +0 -0
- package/src/assets/Metropolis-BoldItalic.woff2 +0 -0
- package/src/assets/Metropolis-ExtraBold.woff2 +0 -0
- package/src/assets/Metropolis-ExtraBoldItalic.woff2 +0 -0
- package/src/assets/Metropolis-ExtraLight.woff2 +0 -0
- package/src/assets/Metropolis-ExtraLightItalic.woff2 +0 -0
- package/src/assets/Metropolis-Light.woff2 +0 -0
- package/src/assets/Metropolis-LightItalic.woff2 +0 -0
- package/src/assets/Metropolis-Medium.woff2 +0 -0
- package/src/assets/Metropolis-MediumItalic.woff2 +0 -0
- package/src/assets/Metropolis-Regular.woff2 +0 -0
- package/src/assets/Metropolis-RegularItalic.woff2 +0 -0
- package/src/assets/Metropolis-SemiBold.woff2 +0 -0
- package/src/assets/Metropolis-SemiBoldItalic.woff2 +0 -0
- package/src/assets/Metropolis-Thin.woff2 +0 -0
- package/src/assets/Metropolis-ThinItalic.woff2 +0 -0
- package/src/assets/logo.png +0 -0
- package/src/factories/AddressFactory.ts +42 -0
- package/src/factories/EmergencyContactFactory.ts +43 -0
- package/src/factories/GroupFactory.ts +66 -0
- package/src/factories/MemberFactory.ts +122 -0
- package/src/factories/OrganizationFactory.ts +45 -0
- package/src/factories/ParentFactory.ts +49 -0
- package/src/factories/RecordFactory.ts +12 -0
- package/src/factories/RegisterCodeFactory.ts +25 -0
- package/src/factories/RegistrationFactory.ts +32 -0
- package/src/factories/UserFactory.ts +66 -0
- package/src/factories/WebshopFactory.ts +43 -0
- package/src/helpers/DNSValidator.ts +153 -0
- package/src/helpers/EmailBuilder.ts +127 -0
- package/src/helpers/GroupBuilder.ts +438 -0
- package/src/helpers/Handlebars.ts +203 -0
- package/src/helpers/InvoiceBuilder.test.ts +57 -0
- package/src/helpers/InvoiceBuilder.ts +501 -0
- package/src/helpers/RateLimiter.ts +75 -0
- package/src/helpers/WebshopCounter.test.ts +16 -0
- package/src/helpers/WebshopCounter.ts +36 -0
- package/src/index.ts +21 -0
- package/src/migrations/1593773929-create-initial-tables.sql +634 -0
- package/src/migrations/1605261999-gemeenten-tmp.sql +2820 -0
- package/src/migrations/1605262045-import-postcodes.ts +132 -0
- package/src/migrations/1605262046-import-postcodes-nl.ts +97 -0
- package/src/migrations/1605279038-drop-gemeenten-tmp.sql +1 -0
- package/src/migrations/1648392491-default-templates.sql +9 -0
- package/src/migrations/1651245707-default-templates-reminders.sql +6 -0
- package/src/migrations/1708607340-tickets-deleted-at.sql +1 -0
- package/src/migrations/1710459176-register-code-invoices.sql +3 -0
- package/src/migrations/1712158247-discount-codes.sql +17 -0
- package/src/migrations/1713178665-drop-invites.sql +1 -0
- package/src/migrations/1713178666-drop-keychain.sql +1 -0
- package/src/migrations/1713178667-drop-challenges.sql +1 -0
- package/src/migrations/1713178668-drop-user-keys.sql +7 -0
- package/src/migrations/1713178669-drop-organization-key.sql +2 -0
- package/src/migrations/1714985451-user-nullable-organization-id.sql +2 -0
- package/src/migrations/1714985452-email-verification-code-nullable-organization-id.sql +2 -0
- package/src/migrations/1714985453-user-organization-permissions.sql +2 -0
- package/src/migrations/1714985454-user-organization-permissions.sql +2 -0
- package/src/migrations/1715079362-platform.sql +6 -0
- package/src/migrations/1715181649-registrations-organization-id.sql +2 -0
- package/src/migrations/1715181650-registrations-organization-id-fill.sql +1 -0
- package/src/migrations/1715181651-registrations-organization-id-drop-null.sql +2 -0
- package/src/migrations/1716117067-members-nullable-organization-id.sql +2 -0
- package/src/migrations/1719567581-registration-periods.sql +13 -0
- package/src/migrations/1719567582-organization-registration-periods.sql +13 -0
- package/src/migrations/1719567881-organization-periodId.sql +2 -0
- package/src/migrations/1719567882-groups-periodId.sql +2 -0
- package/src/migrations/1719567883-platform-periodId.sql +2 -0
- package/src/migrations/1719568079-default-period.sql +2 -0
- package/src/migrations/1719568080-set-default-period-platform.sql +1 -0
- package/src/migrations/1719568081-set-default-period-organizations.sql +1 -0
- package/src/migrations/1719568082-set-default-period-groups.sql +1 -0
- package/src/migrations/1719580828-registrations-periodId.sql +2 -0
- package/src/migrations/1719580829-set-default-period-registrations.sql +1 -0
- package/src/migrations/data/postcodes/nl/Drenthe +291 -0
- package/src/migrations/data/postcodes/nl/Flevoland +107 -0
- package/src/migrations/data/postcodes/nl/Friesland +518 -0
- package/src/migrations/data/postcodes/nl/Gelderland +601 -0
- package/src/migrations/data/postcodes/nl/Groningen +279 -0
- package/src/migrations/data/postcodes/nl/Limburg +324 -0
- package/src/migrations/data/postcodes/nl/Noord-Brabant +620 -0
- package/src/migrations/data/postcodes/nl/Noord-Holland +566 -0
- package/src/migrations/data/postcodes/nl/Overrijsel +344 -0
- package/src/migrations/data/postcodes/nl/Utrecht +278 -0
- package/src/migrations/data/postcodes/nl/Zeeland +179 -0
- package/src/migrations/data/postcodes/nl/Zuid-Holland +662 -0
- package/src/models/BalanceItem.ts +392 -0
- package/src/models/BalanceItemPayment.ts +106 -0
- package/src/models/BuckarooPayment.ts +19 -0
- package/src/models/Document.ts +203 -0
- package/src/models/DocumentTemplate.ts +583 -0
- package/src/models/EmailTemplate.ts +64 -0
- package/src/models/EmailVerificationCode.ts +352 -0
- package/src/models/Group.ts +293 -0
- package/src/models/Image.ts +147 -0
- package/src/models/Member.ts +386 -0
- package/src/models/MemberResponsibilityRecord.ts +39 -0
- package/src/models/MolliePayment.ts +19 -0
- package/src/models/MollieToken.ts +369 -0
- package/src/models/OneTimeToken.ts +131 -0
- package/src/models/Order.ts +1030 -0
- package/src/models/Organization.ts +1085 -0
- package/src/models/OrganizationRegistrationPeriod.ts +54 -0
- package/src/models/PasswordToken.ts +139 -0
- package/src/models/PayconiqPayment.ts +241 -0
- package/src/models/Payment.ts +216 -0
- package/src/models/Platform.ts +76 -0
- package/src/models/RegisterCode.ts +164 -0
- package/src/models/Registration.ts +405 -0
- package/src/models/RegistrationPeriod.ts +55 -0
- package/src/models/STCredit.ts +134 -0
- package/src/models/STInvoice.ts +507 -0
- package/src/models/STPackage.ts +324 -0
- package/src/models/STPendingInvoice.ts +308 -0
- package/src/models/StripeAccount.ts +71 -0
- package/src/models/StripeCheckoutSession.ts +22 -0
- package/src/models/StripePaymentIntent.ts +22 -0
- package/src/models/Ticket.ts +145 -0
- package/src/models/Token.test.ts +69 -0
- package/src/models/Token.ts +269 -0
- package/src/models/UsedRegisterCode.ts +166 -0
- package/src/models/User.ts +445 -0
- package/src/models/UserPermissions.ts +54 -0
- package/src/models/Webshop.ts +206 -0
- package/src/models/WebshopDiscountCode.ts +81 -0
- package/src/models/addresses/City.ts +31 -0
- package/src/models/addresses/PostalCode.test.ts +117 -0
- package/src/models/addresses/PostalCode.ts +164 -0
- package/src/models/addresses/Province.ts +20 -0
- package/src/models/addresses/Street.ts +25 -0
- package/src/models/index.ts +49 -0
- package/src/structures/OrganizationServerMetaData.ts +117 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
|
|
2
|
+
import { column, Model } from "@simonbackx/simple-database";
|
|
3
|
+
import { ArrayDecoder } from '@simonbackx/simple-encoding';
|
|
4
|
+
import { SimpleError } from '@simonbackx/simple-errors';
|
|
5
|
+
import { File, Resolution, ResolutionRequest } from '@stamhoofd/structures';
|
|
6
|
+
import AWS from 'aws-sdk';
|
|
7
|
+
import sharp from "sharp";
|
|
8
|
+
import { v4 as uuidv4 } from "uuid";
|
|
9
|
+
|
|
10
|
+
export class Image extends Model {
|
|
11
|
+
static table = "images";
|
|
12
|
+
|
|
13
|
+
@column({ primary: true, type: "string", beforeSave(value) {
|
|
14
|
+
return value ?? uuidv4();
|
|
15
|
+
} })
|
|
16
|
+
id!: string;
|
|
17
|
+
|
|
18
|
+
@column({ type: "json", decoder: File })
|
|
19
|
+
source: File
|
|
20
|
+
|
|
21
|
+
@column({ type: "json", decoder: new ArrayDecoder(Resolution) })
|
|
22
|
+
resolutions: Resolution[] = []
|
|
23
|
+
|
|
24
|
+
@column({ type: "datetime" })
|
|
25
|
+
createdAt: Date = new Date()
|
|
26
|
+
|
|
27
|
+
static async create(fileContent: string | Buffer, type: string | undefined, resolutions: ResolutionRequest[]): Promise<Image> {
|
|
28
|
+
if (!STAMHOOFD.SPACES_BUCKET || !STAMHOOFD.SPACES_ENDPOINT || !STAMHOOFD.SPACES_KEY || !STAMHOOFD.SPACES_SECRET) {
|
|
29
|
+
throw new SimpleError({
|
|
30
|
+
code: "not_available",
|
|
31
|
+
message: "Uploading is not available",
|
|
32
|
+
statusCode: 503
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let fileType = 'png';
|
|
37
|
+
if (fileType == "image/jpeg" || fileType == "image/jpg") {
|
|
38
|
+
fileType = "jpg";
|
|
39
|
+
}
|
|
40
|
+
if (fileType === "image/svg+xml" || fileType === "image/svg") {
|
|
41
|
+
fileType = "svg";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const supportsTransparency = fileType == "png" || fileType == "svg"
|
|
45
|
+
const promises: Promise<{data: Buffer;info: sharp.OutputInfo}>[] = [];
|
|
46
|
+
|
|
47
|
+
if (resolutions.length) {
|
|
48
|
+
let sharpStream = sharp(fileContent, fileType === 'svg' ? {density: 600} : {}).rotate();
|
|
49
|
+
if (!supportsTransparency) {
|
|
50
|
+
sharpStream = sharpStream.flatten({background: {r: 255, g: 255, b: 255}});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
for(const r of resolutions) {
|
|
54
|
+
const size = {
|
|
55
|
+
width: r.width ?? undefined,
|
|
56
|
+
height: r.height ?? undefined,
|
|
57
|
+
fit: r.fit,
|
|
58
|
+
withoutEnlargement: type !== "image/svg+xml"
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let t = sharpStream.resize(size);
|
|
62
|
+
|
|
63
|
+
// Generate the image data
|
|
64
|
+
if (!supportsTransparency) {
|
|
65
|
+
t = t.jpeg({
|
|
66
|
+
quality: 80,
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
t = t.png();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
promises.push(t.toBuffer({ resolveWithObject: true }));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const files = await Promise.all(promises);
|
|
77
|
+
|
|
78
|
+
const s3 = new AWS.S3({
|
|
79
|
+
endpoint: STAMHOOFD.SPACES_ENDPOINT,
|
|
80
|
+
accessKeyId: STAMHOOFD.SPACES_KEY,
|
|
81
|
+
secretAccessKey: STAMHOOFD.SPACES_SECRET
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
let prefix = (STAMHOOFD.SPACES_PREFIX ?? "")
|
|
85
|
+
if (prefix.length > 0) {
|
|
86
|
+
prefix += "/"
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const uploadPromises: Promise<any>[] = []
|
|
90
|
+
const image = new Image()
|
|
91
|
+
image.id = uuidv4();
|
|
92
|
+
|
|
93
|
+
for (const f of files) {
|
|
94
|
+
const fileId = uuidv4();
|
|
95
|
+
|
|
96
|
+
const key = prefix+(STAMHOOFD.environment ?? "development")+"/"+image.id+"/"+fileId+(!supportsTransparency ? '.jpg' : '.png');
|
|
97
|
+
const params = {
|
|
98
|
+
Bucket: STAMHOOFD.SPACES_BUCKET,
|
|
99
|
+
Key: key,
|
|
100
|
+
Body: f.data,
|
|
101
|
+
ContentType: !supportsTransparency ? 'image/jpeg' : 'image/png',
|
|
102
|
+
ACL: "public-read"
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
uploadPromises.push(s3.putObject(params).promise());
|
|
106
|
+
|
|
107
|
+
const _file = new File({
|
|
108
|
+
id: fileId,
|
|
109
|
+
server: "https://"+STAMHOOFD.SPACES_BUCKET+"."+STAMHOOFD.SPACES_ENDPOINT,
|
|
110
|
+
path: key,
|
|
111
|
+
size: f.info.size
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const _image = new Resolution({
|
|
115
|
+
file: _file,
|
|
116
|
+
width: f.info.width,
|
|
117
|
+
height: f.info.height,
|
|
118
|
+
});
|
|
119
|
+
image.resolutions.push(_image)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Also include the source, in private mode
|
|
123
|
+
const fileId = uuidv4();
|
|
124
|
+
const uploadExt = fileType
|
|
125
|
+
const key = prefix+(STAMHOOFD.environment ?? "development")+"/"+image.id+"/"+fileId+"."+uploadExt;
|
|
126
|
+
const params = {
|
|
127
|
+
Bucket: STAMHOOFD.SPACES_BUCKET,
|
|
128
|
+
Key: key,
|
|
129
|
+
Body: fileContent,
|
|
130
|
+
ContentType: type ?? "image/jpeg",
|
|
131
|
+
ACL: "private"
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
image.source = new File({
|
|
135
|
+
id: fileId,
|
|
136
|
+
server: "https://"+STAMHOOFD.SPACES_BUCKET+"."+STAMHOOFD.SPACES_ENDPOINT,
|
|
137
|
+
path: key,
|
|
138
|
+
size: fileContent.length
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
uploadPromises.push(s3.putObject(params).promise());
|
|
142
|
+
|
|
143
|
+
await Promise.all(uploadPromises);
|
|
144
|
+
await image.save();
|
|
145
|
+
return image
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { column, Database, ManyToManyRelation, ManyToOneRelation, Model, OneToManyRelation } from '@simonbackx/simple-database';
|
|
2
|
+
import { SQL } from "@stamhoofd/sql";
|
|
3
|
+
import { Member as MemberStruct, MemberDetails, MemberWithRegistrationsBlob, RegistrationWithMember as RegistrationWithMemberStruct, User as UserStruct } from '@stamhoofd/structures';
|
|
4
|
+
import { Formatter } from '@stamhoofd/utility';
|
|
5
|
+
import { v4 as uuidv4 } from "uuid";
|
|
6
|
+
|
|
7
|
+
import { Group, Payment, Registration, User } from './';
|
|
8
|
+
export type MemberWithRegistrations = Member & {
|
|
9
|
+
users: User[],
|
|
10
|
+
registrations: (Registration & {group: Group})[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Defined here to prevent cycles
|
|
14
|
+
export type RegistrationWithMember = Registration & { member: Member }
|
|
15
|
+
|
|
16
|
+
export class Member extends Model {
|
|
17
|
+
static table = "members"
|
|
18
|
+
|
|
19
|
+
// Columns
|
|
20
|
+
@column({
|
|
21
|
+
primary: true, type: "string", beforeSave(value) {
|
|
22
|
+
return value ?? uuidv4();
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
id!: string;
|
|
26
|
+
|
|
27
|
+
@column({ type: "string", nullable: true })
|
|
28
|
+
organizationId: string|null = null;
|
|
29
|
+
|
|
30
|
+
@column({
|
|
31
|
+
type: "string",
|
|
32
|
+
beforeSave: function() {
|
|
33
|
+
return this.details?.firstName ?? ''
|
|
34
|
+
},
|
|
35
|
+
skipUpdate: true
|
|
36
|
+
})
|
|
37
|
+
firstName: string
|
|
38
|
+
|
|
39
|
+
@column({ type: "string",
|
|
40
|
+
beforeSave: function() {
|
|
41
|
+
return this.details?.lastName ?? ''
|
|
42
|
+
},
|
|
43
|
+
skipUpdate: true })
|
|
44
|
+
lastName: string
|
|
45
|
+
|
|
46
|
+
@column({
|
|
47
|
+
type: "string",
|
|
48
|
+
nullable: true,
|
|
49
|
+
beforeSave: function(this: Member) {
|
|
50
|
+
return this.details?.birthDay ? Formatter.dateIso(this.details.birthDay) : null
|
|
51
|
+
},
|
|
52
|
+
skipUpdate: true
|
|
53
|
+
})
|
|
54
|
+
birthDay: string | null
|
|
55
|
+
|
|
56
|
+
@column({ type: "json", decoder: MemberDetails })
|
|
57
|
+
details: MemberDetails
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Not yet paid balance
|
|
61
|
+
*/
|
|
62
|
+
@column({ type: "integer" })
|
|
63
|
+
outstandingBalance = 0
|
|
64
|
+
|
|
65
|
+
@column({
|
|
66
|
+
type: "datetime", beforeSave(old?: any) {
|
|
67
|
+
if (old !== undefined) {
|
|
68
|
+
return old;
|
|
69
|
+
}
|
|
70
|
+
const date = new Date()
|
|
71
|
+
date.setMilliseconds(0)
|
|
72
|
+
return date
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
createdAt: Date
|
|
76
|
+
|
|
77
|
+
@column({
|
|
78
|
+
type: "datetime", beforeSave() {
|
|
79
|
+
const date = new Date()
|
|
80
|
+
date.setMilliseconds(0)
|
|
81
|
+
return date
|
|
82
|
+
},
|
|
83
|
+
skipUpdate: true
|
|
84
|
+
})
|
|
85
|
+
updatedAt: Date
|
|
86
|
+
|
|
87
|
+
static registrations = new OneToManyRelation(Member, Registration, "registrations", "memberId")
|
|
88
|
+
|
|
89
|
+
// Note: all relations should point to their parents, not the other way around to avoid reference cycles
|
|
90
|
+
static users = new ManyToManyRelation(Member, User, "users");
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Fetch all members with their corresponding (valid) registration
|
|
94
|
+
*/
|
|
95
|
+
static async getWithRegistrations(id: string): Promise<MemberWithRegistrations | null> {
|
|
96
|
+
return (await this.getBlobByIds(id))[0] ?? null
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Update the outstanding balance of multiple members in one go (or all members)
|
|
101
|
+
*/
|
|
102
|
+
static async updateOutstandingBalance(memberIds: string[] | 'all') {
|
|
103
|
+
if (memberIds !== 'all' && memberIds.length == 0) {
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const params: any[] = []
|
|
108
|
+
let firstWhere = ''
|
|
109
|
+
let secondWhere = ''
|
|
110
|
+
|
|
111
|
+
if (memberIds !== 'all') {
|
|
112
|
+
firstWhere = ` AND memberId IN (?)`
|
|
113
|
+
params.push(memberIds)
|
|
114
|
+
|
|
115
|
+
secondWhere = `WHERE members.id IN (?)`
|
|
116
|
+
params.push(memberIds)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const query = `UPDATE
|
|
120
|
+
members
|
|
121
|
+
LEFT JOIN (
|
|
122
|
+
SELECT
|
|
123
|
+
memberId,
|
|
124
|
+
sum(price) - sum(pricePaid) AS outstandingBalance
|
|
125
|
+
FROM
|
|
126
|
+
balance_items
|
|
127
|
+
WHERE status != 'Hidden'${firstWhere}
|
|
128
|
+
GROUP BY
|
|
129
|
+
memberId
|
|
130
|
+
) i ON i.memberId = members.id
|
|
131
|
+
SET members.outstandingBalance = COALESCE(i.outstandingBalance, 0)
|
|
132
|
+
${secondWhere}`
|
|
133
|
+
|
|
134
|
+
await Database.update(query, params)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Fetch all registrations with members with their corresponding (valid) registrations
|
|
139
|
+
*/
|
|
140
|
+
static async getRegistrationWithMembersByIDs(ids: string[]): Promise<RegistrationWithMember[]> {
|
|
141
|
+
if (ids.length === 0) {
|
|
142
|
+
return []
|
|
143
|
+
}
|
|
144
|
+
let query = `SELECT ${Member.getDefaultSelect()}, ${Registration.getDefaultSelect()} from \`${Member.table}\`\n`;
|
|
145
|
+
|
|
146
|
+
query += `JOIN \`${Registration.table}\` ON \`${Registration.table}\`.\`${Member.registrations.foreignKey}\` = \`${Member.table}\`.\`${Member.primary.name}\` AND (\`${Registration.table}\`.\`registeredAt\` is not null OR \`${Registration.table}\`.\`waitingList\` = 1)\n`
|
|
147
|
+
|
|
148
|
+
// We do an extra join because we also need to get the other registrations of each member (only one regitration has to match the query)
|
|
149
|
+
query += `where \`${Registration.table}\`.\`${Registration.primary.name}\` IN (?)`
|
|
150
|
+
|
|
151
|
+
const [results] = await Database.select(query, [ids])
|
|
152
|
+
const registrations: RegistrationWithMember[] = []
|
|
153
|
+
|
|
154
|
+
// In the future we might add a 'reverse' method on manytoone relation, instead of defining the new relation. But then we need to store 2 model types in the many to one relation.
|
|
155
|
+
const registrationMemberRelation = new ManyToOneRelation(Member, "member")
|
|
156
|
+
registrationMemberRelation.foreignKey = Member.registrations.foreignKey
|
|
157
|
+
|
|
158
|
+
for (const row of results) {
|
|
159
|
+
const registration = Registration.fromRow(row[Registration.table])
|
|
160
|
+
if (!registration) {
|
|
161
|
+
throw new Error("Expected registration in every row")
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const foundMember = Member.fromRow(row[Member.table])
|
|
165
|
+
if (!foundMember) {
|
|
166
|
+
throw new Error("Expected member in every row")
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const _f = registration.setRelation(registrationMemberRelation, foundMember)
|
|
170
|
+
registrations.push(_f)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return registrations
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Fetch all registrations with members with their corresponding (valid) registrations
|
|
178
|
+
*/
|
|
179
|
+
static async getRegistrationWithMembersForGroup(groupId: string, cycle: number): Promise<RegistrationWithMember[]> {
|
|
180
|
+
let query = `SELECT ${Member.getDefaultSelect()}, ${Registration.getDefaultSelect()} from \`${Member.table}\`\n`;
|
|
181
|
+
|
|
182
|
+
query += `JOIN \`${Registration.table}\` ON \`${Registration.table}\`.\`${Member.registrations.foreignKey}\` = \`${Member.table}\`.\`${Member.primary.name}\` AND (\`${Registration.table}\`.\`registeredAt\` is not null OR \`${Registration.table}\`.\`waitingList\` = 1)\n`
|
|
183
|
+
|
|
184
|
+
// We do an extra join because we also need to get the other registrations of each member (only one regitration has to match the query)
|
|
185
|
+
query += `where \`${Registration.table}\`.\`groupId\` = ? AND \`${Registration.table}\`.\`cycle\` = ?`
|
|
186
|
+
|
|
187
|
+
const [results] = await Database.select(query, [groupId, cycle])
|
|
188
|
+
const registrations: RegistrationWithMember[] = []
|
|
189
|
+
|
|
190
|
+
// In the future we might add a 'reverse' method on manytoone relation, instead of defining the new relation. But then we need to store 2 model types in the many to one relation.
|
|
191
|
+
const registrationMemberRelation = new ManyToOneRelation(Member, "member")
|
|
192
|
+
registrationMemberRelation.foreignKey = Member.registrations.foreignKey
|
|
193
|
+
|
|
194
|
+
for (const row of results) {
|
|
195
|
+
const registration = Registration.fromRow(row[Registration.table])
|
|
196
|
+
if (!registration) {
|
|
197
|
+
throw new Error("Expected registration in every row")
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const foundMember = Member.fromRow(row[Member.table])
|
|
201
|
+
if (!foundMember) {
|
|
202
|
+
throw new Error("Expected member in every row")
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const _f = registration.setRelation(registrationMemberRelation, foundMember)
|
|
206
|
+
registrations.push(_f)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return registrations
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Fetch all registrations with members with their corresponding (valid) registrations and payment
|
|
214
|
+
*/
|
|
215
|
+
static async getRegistrationWithMembersForPayment(paymentId: string): Promise<RegistrationWithMember[]> {
|
|
216
|
+
const { BalanceItem, BalanceItemPayment} = await import('./');
|
|
217
|
+
|
|
218
|
+
let query = `SELECT ${Member.getDefaultSelect()}, ${Registration.getDefaultSelect()} from \`${Member.table}\`\n`;
|
|
219
|
+
|
|
220
|
+
query += `JOIN \`${Registration.table}\` ON \`${Registration.table}\`.\`${Member.registrations.foreignKey}\` = \`${Member.table}\`.\`${Member.primary.name}\`\n`
|
|
221
|
+
|
|
222
|
+
query += `LEFT JOIN \`${BalanceItem.table}\` ON \`${BalanceItem.table}\`.\`registrationId\` = \`${Registration.table}\`.\`${Registration.primary.name}\`\n`
|
|
223
|
+
query += `LEFT JOIN \`${BalanceItemPayment.table}\` ON \`${BalanceItemPayment.table}\`.\`${BalanceItemPayment.balanceItem.foreignKey}\` = \`${BalanceItem.table}\`.\`${BalanceItem.primary.name}\`\n`
|
|
224
|
+
query += `JOIN \`${Payment.table}\` ON \`${Payment.table}\`.\`${Payment.primary.name}\` = \`${BalanceItemPayment.table}\`.\`${BalanceItemPayment.payment.foreignKey}\`\n`
|
|
225
|
+
|
|
226
|
+
// We do an extra join because we also need to get the other registrations of each member (only one regitration has to match the query)
|
|
227
|
+
query += `WHERE \`${Payment.table}\`.\`${Payment.primary.name}\` = ?\n`
|
|
228
|
+
query += `GROUP BY \`${Registration.table}\`.\`${Registration.primary.name}\`, \`${Member.table}\`.\`${Member.primary.name}\``
|
|
229
|
+
|
|
230
|
+
const [results] = await Database.select(query, [paymentId])
|
|
231
|
+
const registrations: RegistrationWithMember[] = []
|
|
232
|
+
|
|
233
|
+
// In the future we might add a 'reverse' method on manytoone relation, instead of defining the new relation. But then we need to store 2 model types in the many to one relation.
|
|
234
|
+
const registrationMemberRelation = new ManyToOneRelation(Member, "member")
|
|
235
|
+
registrationMemberRelation.foreignKey = Member.registrations.foreignKey
|
|
236
|
+
|
|
237
|
+
for (const row of results) {
|
|
238
|
+
const registration = Registration.fromRow(row[Registration.table])
|
|
239
|
+
if (!registration) {
|
|
240
|
+
throw new Error("Expected registration in every row")
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const foundMember = Member.fromRow(row[Member.table])
|
|
244
|
+
if (!foundMember) {
|
|
245
|
+
throw new Error("Expected member in every row")
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const _f = registration.setRelation(registrationMemberRelation, foundMember)
|
|
249
|
+
registrations.push(_f)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return registrations
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Fetch all members with their corresponding (valid) registrations, users
|
|
257
|
+
*/
|
|
258
|
+
static async getBlobByIds(...ids: string[]): Promise<MemberWithRegistrations[]> {
|
|
259
|
+
if (ids.length == 0) {
|
|
260
|
+
return []
|
|
261
|
+
}
|
|
262
|
+
let query = `SELECT ${Member.getDefaultSelect()}, ${Registration.getDefaultSelect()}, ${User.getDefaultSelect()} from \`${Member.table}\`\n`;
|
|
263
|
+
query += `LEFT JOIN \`${Registration.table}\` ON \`${Registration.table}\`.\`${Member.registrations.foreignKey}\` = \`${Member.table}\`.\`${Member.primary.name}\` AND (\`${Registration.table}\`.\`registeredAt\` is not null OR \`${Registration.table}\`.\`waitingList\` = 1)\n`
|
|
264
|
+
query += Member.users.joinQuery(Member.table, User.table)+"\n"
|
|
265
|
+
|
|
266
|
+
// We do an extra join because we also need to get the other registrations of each member (only one regitration has to match the query)
|
|
267
|
+
query += `where \`${Member.table}\`.\`${Member.primary.name}\` IN (?)`
|
|
268
|
+
|
|
269
|
+
const [results] = await Database.select(query, [ids])
|
|
270
|
+
const members: MemberWithRegistrations[] = []
|
|
271
|
+
|
|
272
|
+
// Load groups
|
|
273
|
+
const groupIds = results.map(r => r[Registration.table]?.groupId).filter(id => id) as string[]
|
|
274
|
+
const groups = await Group.getByIDs(...Formatter.uniqueArray(groupIds))
|
|
275
|
+
|
|
276
|
+
for (const row of results) {
|
|
277
|
+
const foundMember = Member.fromRow(row[Member.table])
|
|
278
|
+
if (!foundMember) {
|
|
279
|
+
throw new Error("Expected member in every row")
|
|
280
|
+
}
|
|
281
|
+
const _f = foundMember
|
|
282
|
+
.setManyRelation(Member.registrations as unknown as OneToManyRelation<"registrations", Member, Registration & {group: Group}>, [])
|
|
283
|
+
.setManyRelation(Member.users, [])
|
|
284
|
+
|
|
285
|
+
// Seach if we already got this member?
|
|
286
|
+
const existingMember = members.find(m => m.id == _f.id)
|
|
287
|
+
|
|
288
|
+
const member: MemberWithRegistrations = (existingMember ?? _f)
|
|
289
|
+
if (!existingMember) {
|
|
290
|
+
members.push(member)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Check if we have a registration with a payment
|
|
294
|
+
const registration = Registration.fromRow(row[Registration.table])
|
|
295
|
+
if (registration) {
|
|
296
|
+
// Check if we already have this registration
|
|
297
|
+
if (!member.registrations.find(r => r.id == registration.id)) {
|
|
298
|
+
const g = groups.find(g => g.id == registration.groupId)
|
|
299
|
+
if (!g) {
|
|
300
|
+
throw new Error("Group not found")
|
|
301
|
+
}
|
|
302
|
+
member.registrations.push(registration.setRelation(Registration.group, g))
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// Check if we have a user
|
|
307
|
+
const user = User.fromRow(row[User.table])
|
|
308
|
+
if (user) {
|
|
309
|
+
// Check if we already have this registration
|
|
310
|
+
if (!member.users.find(r => r.id == user.id)) {
|
|
311
|
+
member.users.push(user)
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return members
|
|
317
|
+
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Fetch all members with their corresponding (valid) registrations and payment
|
|
322
|
+
*/
|
|
323
|
+
static async getFamilyWithRegistrations(id: string): Promise<MemberWithRegistrations[]> {
|
|
324
|
+
let query = `SELECT l2.membersId as id from _members_users l1\n`;
|
|
325
|
+
query += `JOIN _members_users l2 on l2.usersId = l1.usersId \n`
|
|
326
|
+
query += `where l1.membersId = ? group by l2.membersId`
|
|
327
|
+
|
|
328
|
+
const [results] = await Database.select(query, [id])
|
|
329
|
+
const ids: string[] = []
|
|
330
|
+
for (const row of results) {
|
|
331
|
+
ids.push(row["l2"]["id"] as string)
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (!ids.includes(id)) {
|
|
335
|
+
// Member has no users
|
|
336
|
+
ids.push(id)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return await this.getBlobByIds(...ids)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Fetch all members with their corresponding (valid) registrations or waiting lists and payments
|
|
344
|
+
*/
|
|
345
|
+
static async getMembersWithRegistrationForUser(user: User): Promise<MemberWithRegistrations[]> {
|
|
346
|
+
const query = SQL
|
|
347
|
+
.select(
|
|
348
|
+
SQL.column('id')
|
|
349
|
+
)
|
|
350
|
+
.from(SQL.table(Member.table))
|
|
351
|
+
.join(
|
|
352
|
+
SQL.leftJoin(
|
|
353
|
+
SQL.table('_members_users')
|
|
354
|
+
).where(
|
|
355
|
+
SQL.column('_members_users', 'membersId'),
|
|
356
|
+
SQL.column(Member.table, 'id'),
|
|
357
|
+
)
|
|
358
|
+
).where(
|
|
359
|
+
SQL.column('_members_users', 'usersId'),
|
|
360
|
+
user.id,
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
const data = await query.fetch()
|
|
364
|
+
return this.getBlobByIds(...data.map((r) => r.members.id as string));
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
getStructureWithRegistrations(this: MemberWithRegistrations, forOrganization: null | boolean = null) {
|
|
368
|
+
return MemberWithRegistrationsBlob.create({
|
|
369
|
+
...this,
|
|
370
|
+
registrations: this.registrations.map(r => r.getStructure()),
|
|
371
|
+
details: this.details,
|
|
372
|
+
users: this.users.map(u => UserStruct.create({
|
|
373
|
+
...u,
|
|
374
|
+
hasAccount: u.hasAccount()
|
|
375
|
+
})),
|
|
376
|
+
})
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
static getRegistrationWithMemberStructure(registration: RegistrationWithMember & {group: import('./Group').Group}): RegistrationWithMemberStruct {
|
|
380
|
+
return RegistrationWithMemberStruct.create({
|
|
381
|
+
...registration.getStructure(),
|
|
382
|
+
cycle: registration.cycle,
|
|
383
|
+
member: MemberStruct.create(registration.member),
|
|
384
|
+
})
|
|
385
|
+
}
|
|
386
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { column, Model } from '@simonbackx/simple-database';
|
|
2
|
+
import { v4 as uuidv4 } from "uuid";
|
|
3
|
+
|
|
4
|
+
export class MemberResponsibilityRecord extends Model {
|
|
5
|
+
static table = "member_responsibility_records"
|
|
6
|
+
|
|
7
|
+
// Columns
|
|
8
|
+
@column({
|
|
9
|
+
primary: true, type: "string", beforeSave(value) {
|
|
10
|
+
return value ?? uuidv4();
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
id!: string;
|
|
14
|
+
|
|
15
|
+
@column({ type: "string", nullable: true })
|
|
16
|
+
organizationId: string|null = null;
|
|
17
|
+
|
|
18
|
+
@column({ type: "string" })
|
|
19
|
+
memberId: string
|
|
20
|
+
|
|
21
|
+
@column({ type: "string" })
|
|
22
|
+
responsibilityId: string
|
|
23
|
+
|
|
24
|
+
@column({
|
|
25
|
+
type: "datetime", beforeSave(old?: any) {
|
|
26
|
+
if (old !== undefined) {
|
|
27
|
+
return old;
|
|
28
|
+
}
|
|
29
|
+
const date = new Date()
|
|
30
|
+
date.setMilliseconds(0)
|
|
31
|
+
return date
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
startDate: Date
|
|
35
|
+
|
|
36
|
+
@column({ type: "datetime", nullable: true })
|
|
37
|
+
endDate: Date | null = null
|
|
38
|
+
|
|
39
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { column,Model } from "@simonbackx/simple-database";
|
|
2
|
+
import { v4 as uuidv4 } from "uuid";
|
|
3
|
+
|
|
4
|
+
export class MolliePayment extends Model {
|
|
5
|
+
static table = "mollie_payments";
|
|
6
|
+
|
|
7
|
+
@column({
|
|
8
|
+
primary: true, type: "string", beforeSave(value) {
|
|
9
|
+
return value ?? uuidv4();
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
id!: string;
|
|
13
|
+
|
|
14
|
+
@column({ type: "string" })
|
|
15
|
+
paymentId: string;
|
|
16
|
+
|
|
17
|
+
@column({ type: "string" })
|
|
18
|
+
mollieId: string;
|
|
19
|
+
}
|