@stamhoofd/backend 2.118.1 → 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/package.json +32 -22
- package/src/audit-logs/ModelLogger.ts +4 -2
- package/src/audit-logs/OrderLogger.ts +1 -1
- package/src/boot.ts +32 -14
- package/src/crons/balance-emails.ts +4 -2
- package/src/crons/clearExcelCache.test.ts +8 -8
- package/src/crons/update-cached-balances.ts +40 -14
- package/src/debug.ts +3 -2
- package/src/decoders/StringArrayDecoder.ts +1 -1
- package/src/decoders/StringNullableDecoder.ts +1 -1
- package/src/email-recipient-loaders/documents.ts +2 -1
- package/src/email-recipient-loaders/members.ts +2 -1
- package/src/email-recipient-loaders/orders.ts +2 -1
- package/src/email-recipient-loaders/payments.ts +6 -3
- package/src/email-recipient-loaders/receivable-balances.ts +2 -1
- package/src/email-recipient-loaders/registrations.ts +2 -1
- package/src/email-replacements/getEmailReplacementsForPayment.ts +8 -7
- package/src/endpoints/admin/members/ChargeMembersEndpoint.ts +7 -6
- package/src/endpoints/admin/memberships/ChargeMembershipsEndpoint.ts +3 -2
- package/src/endpoints/admin/memberships/GetChargeMembershipsSummaryEndpoint.ts +2 -1
- package/src/endpoints/admin/organizations/ChargeOrganizationsEndpoint.ts +4 -3
- package/src/endpoints/admin/organizations/GetOrganizationsCountEndpoint.ts +3 -2
- package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +7 -5
- package/src/endpoints/admin/organizations/PatchOrganizationsEndpoint.ts +12 -10
- package/src/endpoints/admin/registrations/ChargeRegistrationsEndpoint.ts +4 -3
- package/src/endpoints/auth/CreateAdminEndpoint.ts +8 -6
- package/src/endpoints/auth/CreateTokenEndpoint.ts +14 -12
- package/src/endpoints/auth/DeleteTokenEndpoint.ts +2 -1
- package/src/endpoints/auth/DeleteUserEndpoint.ts +2 -1
- package/src/endpoints/auth/ForgotPasswordEndpoint.ts +5 -4
- package/src/endpoints/auth/GetOtherUserEndpoint.ts +3 -2
- package/src/endpoints/auth/GetUserEndpoint.ts +3 -2
- package/src/endpoints/auth/OpenIDConnectAuthTokenEndpoint.ts +2 -1
- package/src/endpoints/auth/OpenIDConnectCallbackEndpoint.ts +4 -2
- package/src/endpoints/auth/OpenIDConnectStartEndpoint.ts +3 -2
- package/src/endpoints/auth/PatchUserEndpoint.ts +15 -12
- package/src/endpoints/auth/PollEmailVerificationEndpoint.ts +3 -2
- package/src/endpoints/auth/RetryEmailVerificationEndpoint.ts +3 -2
- package/src/endpoints/auth/SignupEndpoint.ts +5 -4
- package/src/endpoints/auth/VerifyEmailEndpoint.ts +6 -5
- package/src/endpoints/frontend/FrontendEnvironmentEndpoint.ts +3 -2
- package/src/endpoints/global/addresses/SearchRegionsEndpoint.ts +8 -5
- package/src/endpoints/global/addresses/ValidateAddressEndpoint.ts +5 -3
- package/src/endpoints/global/audit-logs/GetAuditLogsEndpoint.ts +8 -5
- package/src/endpoints/global/billing/ActivatePackagesEndpoint.ts +9 -7
- package/src/endpoints/global/billing/DeactivatePackageEndpoint.ts +4 -3
- package/src/endpoints/global/caddy/CheckDomainCertEndpoint.ts +4 -2
- package/src/endpoints/global/email/CreateEmailEndpoint.ts +9 -7
- package/src/endpoints/global/email/GetAdminEmailsEndpoint.test.ts +2 -1
- package/src/endpoints/global/email/GetAdminEmailsEndpoint.ts +22 -19
- package/src/endpoints/global/email/GetEmailAddressEndpoint.ts +6 -4
- package/src/endpoints/global/email/GetEmailEndpoint.ts +4 -3
- package/src/endpoints/global/email/GetUserEmailsEndpoint.test.ts +3 -2
- package/src/endpoints/global/email/GetUserEmailsEndpoint.ts +7 -4
- package/src/endpoints/global/email/ManageEmailAddressEndpoint.ts +7 -5
- package/src/endpoints/global/email/PatchEmailEndpoint.test.ts +11 -11
- package/src/endpoints/global/email/PatchEmailEndpoint.ts +14 -11
- package/src/endpoints/global/email-recipients/GetEmailRecipientsCountEndpoint.ts +3 -2
- package/src/endpoints/global/email-recipients/GetEmailRecipientsEndpoint.test.ts +2 -1
- package/src/endpoints/global/email-recipients/GetEmailRecipientsEndpoint.ts +8 -5
- package/src/endpoints/global/email-recipients/RetryEmailRecipientEndpoint.ts +7 -5
- package/src/endpoints/global/email-recipients/helpers/validateEmailRecipientFilter.ts +4 -3
- package/src/endpoints/global/events/GetEventNotificationsCountEndpoint.ts +3 -2
- package/src/endpoints/global/events/GetEventNotificationsEndpoint.ts +9 -6
- package/src/endpoints/global/events/GetEventsEndpoint.ts +7 -4
- package/src/endpoints/global/events/PatchEventNotificationsEndpoint.test.ts +4 -2
- package/src/endpoints/global/events/PatchEventNotificationsEndpoint.ts +17 -15
- package/src/endpoints/global/events/PatchEventsEndpoint.test.ts +4 -2
- package/src/endpoints/global/events/PatchEventsEndpoint.ts +28 -26
- package/src/endpoints/global/files/ExportToExcelEndpoint.ts +8 -5
- package/src/endpoints/global/files/GetFileCache.ts +5 -3
- package/src/endpoints/global/files/UploadFile.ts +10 -4
- package/src/endpoints/global/files/UploadImage.ts +4 -2
- package/src/endpoints/global/groups/GetGroupsEndpoint.test.ts +4 -2
- package/src/endpoints/global/groups/GetGroupsEndpoint.ts +8 -5
- package/src/endpoints/global/members/GetMemberFamilyEndpoint.ts +7 -5
- package/src/endpoints/global/members/GetMembersCountEndpoint.ts +3 -2
- package/src/endpoints/global/members/GetMembersEndpoint.test.ts +4 -2
- package/src/endpoints/global/members/GetMembersEndpoint.ts +10 -8
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.test.ts +257 -6
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +162 -107
- package/src/endpoints/global/members/helpers/validateGroupFilter.ts +4 -3
- package/src/endpoints/global/members/shouldCheckIfMemberIsDuplicate.ts +3 -2
- package/src/endpoints/global/organizations/CheckRegisterCodeEndpoint.ts +3 -2
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.test.ts +3 -2
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.ts +8 -7
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.ts +5 -3
- package/src/endpoints/global/organizations/GetOrganizationFromUriEndpoint.ts +5 -3
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.ts +8 -5
- package/src/endpoints/global/payments/StripeWebhookEndpoint.ts +4 -2
- package/src/endpoints/global/platform/GetPlatformAdminsEndpoint.ts +2 -1
- package/src/endpoints/global/platform/GetPlatformEndpoint.ts +3 -2
- package/src/endpoints/global/platform/PatchPlatformEnpoint.test.ts +3 -2
- package/src/endpoints/global/platform/PatchPlatformEnpoint.ts +7 -4
- package/src/endpoints/global/platform-memberships/GetPlatformMembershipsCountEndpoint.ts +47 -0
- package/src/endpoints/global/platform-memberships/GetPlatformMembershipsEndpoint.ts +206 -0
- package/src/endpoints/global/registration/GetRegistrationsCountEndpoint.ts +3 -2
- package/src/endpoints/global/registration/GetRegistrationsEndpoint.test.ts +2 -1
- package/src/endpoints/global/registration/GetRegistrationsEndpoint.ts +10 -7
- package/src/endpoints/global/registration/GetUserDetailedPayableBalanceEndpoint.ts +4 -2
- package/src/endpoints/global/registration/GetUserDocumentsEndpoint.ts +4 -2
- package/src/endpoints/global/registration/GetUserMembersEndpoint.ts +3 -2
- package/src/endpoints/global/registration/GetUserPayableBalanceEndpoint.ts +2 -1
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.test.ts +5 -3
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.ts +13 -9
- package/src/endpoints/global/registration/RegisterMembersEndpoint.test.ts +50 -49
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +25 -22
- package/src/endpoints/global/registration-periods/GetRegistrationPeriodsEndpoint.ts +8 -5
- package/src/endpoints/global/registration-periods/PatchRegistrationPeriodsEndpoint.ts +9 -7
- package/src/endpoints/global/sso/GetSSOEndpoint.ts +4 -2
- package/src/endpoints/global/sso/SetSSOEndpoint.ts +3 -2
- package/src/endpoints/global/webshops/GetWebshopFromDomainEndpoint.ts +4 -2
- package/src/endpoints/global/webshops/GetWebshopsCountEndpoint.ts +43 -0
- package/src/endpoints/global/webshops/GetWebshopsEndpoint.test.ts +808 -0
- package/src/endpoints/global/webshops/GetWebshopsEndpoint.ts +221 -0
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemEndpoint.ts +4 -3
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsEndpoint.ts +6 -4
- package/src/endpoints/organization/dashboard/balance-items/PatchBalanceItemsEndpoint.ts +15 -13
- package/src/endpoints/organization/dashboard/billing/GetOrganizationDetailedPayableBalanceEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/billing/GetOrganizationPayableBalanceEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/billing/GetPackagesEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplateXML.ts +3 -2
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplatesCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplatesEndpoint.ts +7 -4
- package/src/endpoints/organization/dashboard/documents/GetDocumentsCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/documents/GetDocumentsEndpoint.ts +7 -4
- package/src/endpoints/organization/dashboard/documents/PatchDocumentEndpoint.ts +9 -7
- package/src/endpoints/organization/dashboard/documents/PatchDocumentTemplatesEndpoint.test.ts +4 -2
- package/src/endpoints/organization/dashboard/documents/PatchDocumentTemplatesEndpoint.ts +7 -5
- package/src/endpoints/organization/dashboard/email/CheckEmailBouncesEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.test.ts +36 -1
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.ts +13 -4
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.test.ts +4 -2
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.ts +7 -5
- package/src/endpoints/organization/dashboard/invoices/GetInvoicesCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/invoices/GetInvoicesEndpoint.ts +6 -4
- package/src/endpoints/organization/dashboard/invoices/PatchInvoicesEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/mollie/CheckMollieEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/mollie/ConnectMollieEndpoint.ts +6 -3
- package/src/endpoints/organization/dashboard/mollie/DisconnectMollieEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/mollie/GetMollieDashboardEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/nolt/CreateNoltTokenEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/organization/GetOrganizationArchivedGroups.ts +4 -2
- package/src/endpoints/organization/dashboard/organization/GetOrganizationDeletedGroups.ts +3 -2
- package/src/endpoints/organization/dashboard/organization/GetUitpasClientIdEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.test.ts +5 -3
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +22 -19
- package/src/endpoints/organization/dashboard/organization/SearchUitpasOrganizersEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/organization/SetOrganizationDomainEndpoint.ts +11 -9
- package/src/endpoints/organization/dashboard/organization/SetUitpasClientCredentialsEndpoint.ts +8 -7
- package/src/endpoints/organization/dashboard/payments/GetMemberBalanceEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/payments/GetPaymentsCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/payments/GetPaymentsEndpoint.ts +7 -5
- package/src/endpoints/organization/dashboard/payments/PatchPaymentsEndpoint.ts +18 -16
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalanceEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.test.ts +2 -1
- package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.ts +8 -5
- package/src/endpoints/organization/dashboard/registration-periods/MoveRegistrationPeriods.test.ts +4 -2
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.test.ts +4 -2
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.ts +32 -29
- package/src/endpoints/organization/dashboard/registration-periods/SetupStepReviewEndpoint.ts +6 -3
- package/src/endpoints/organization/dashboard/stripe/ConnectStripeEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/stripe/DeleteStripeAccountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountLinkEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountsEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/stripe/GetStripeLoginLinkEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/stripe/UpdateStripeAccountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/users/CreateApiUserEndpoint.ts +4 -3
- package/src/endpoints/organization/dashboard/users/DeleteUserEndpoint.ts +4 -3
- package/src/endpoints/organization/dashboard/users/GetApiUsersEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/users/GetOrganizationAdminsEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/users/PatchApiUserEndpoint.ts +6 -4
- package/src/endpoints/organization/dashboard/webshops/CreateWebshopEndpoint.ts +7 -6
- package/src/endpoints/organization/dashboard/webshops/DeleteWebshopEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/webshops/GetDiscountCodesEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersEndpoint.ts +7 -4
- package/src/endpoints/organization/dashboard/webshops/{GetWebshopTicketsCountEndpoint → GetWebshopTicketsCountEndpoint.ts} +7 -7
- package/src/endpoints/organization/dashboard/webshops/GetWebshopTicketsEndpoint.ts +9 -6
- package/src/endpoints/organization/dashboard/webshops/GetWebshopUriAvailabilityEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/webshops/PatchDiscountCodesEndpoint.ts +6 -4
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopEndpoint.ts +13 -12
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopTicketsEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/webshops/SearchUitpasEventsEndpoint.ts +6 -4
- package/src/endpoints/organization/dashboard/webshops/VerifyWebshopDomainEndpoint.ts +2 -1
- package/src/endpoints/organization/shared/ExchangePaymentEndpoint.ts +6 -4
- package/src/endpoints/organization/shared/GetDocumentHtml.ts +4 -3
- package/src/endpoints/organization/shared/GetPaymentEndpoint.ts +4 -3
- package/src/endpoints/organization/shared/GetUitpasNumberDetailsEndpoint.ts +3 -2
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.ts +3 -2
- package/src/endpoints/organization/webshops/CheckWebshopDiscountCodesEndpoint.ts +4 -3
- package/src/endpoints/organization/webshops/GetOrderByPaymentEndpoint.ts +5 -4
- package/src/endpoints/organization/webshops/GetOrderEndpoint.ts +4 -3
- package/src/endpoints/organization/webshops/GetTicketsEndpoint.ts +7 -5
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.ts +4 -3
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.test.ts +7 -3
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.ts +11 -10
- package/src/endpoints/organization/webshops/RetrieveUitpasSocialTariffPriceEndpoint.ts +5 -4
- package/src/endpoints/system/HealthEndpoint.test.ts +44 -0
- package/src/endpoints/system/HealthEndpoint.ts +14 -6
- package/src/excel-loaders/balance-items.ts +19 -17
- package/src/excel-loaders/event-notifications.ts +15 -13
- package/src/excel-loaders/index.ts +1 -0
- package/src/excel-loaders/members.ts +45 -43
- package/src/excel-loaders/organizations.ts +26 -25
- package/src/excel-loaders/payments.ts +44 -42
- package/src/excel-loaders/platform-memberships.ts +202 -0
- package/src/excel-loaders/receivable-balances.ts +25 -23
- package/src/excel-loaders/registrations.ts +30 -28
- package/src/helpers/AddressValidator.test.ts +2 -1
- package/src/helpers/AddressValidator.ts +13 -10
- package/src/helpers/AdminPermissionChecker.ts +193 -95
- package/src/helpers/AuthenticatedStructures.ts +13 -11
- package/src/helpers/BuckarooHelper.ts +3 -2
- package/src/helpers/Context.ts +8 -6
- package/src/helpers/CookieHelper.ts +2 -2
- package/src/helpers/FileCache.ts +9 -9
- package/src/helpers/ForwardHandler.ts +3 -2
- package/src/helpers/GlobalHelper.ts +2 -0
- package/src/helpers/GroupBuilder.ts +2 -1
- package/src/helpers/GroupedThrottledQueue.test.ts +19 -19
- package/src/helpers/LimitedFilteredRequestHelper.ts +1 -1
- package/src/helpers/MemberCharger.ts +2 -1
- package/src/helpers/MemberUserSyncer.ts +6 -3
- package/src/helpers/MembershipCharger.ts +2 -2
- package/src/helpers/OrganizationCharger.ts +2 -1
- package/src/helpers/PeriodHelper.ts +2 -1
- package/src/helpers/SQLTranslatedString.ts +3 -2
- package/src/helpers/ServiceFeeHelper.ts +1 -1
- package/src/helpers/SetupStepUpdater.ts +6 -5
- package/src/helpers/StripeHelper.ts +9 -8
- package/src/helpers/TagHelper.test.ts +5 -5
- package/src/helpers/TagHelper.ts +2 -1
- package/src/helpers/TemporaryMemberAccess.ts +2 -1
- package/src/helpers/ThrottledQueue.test.ts +20 -20
- package/src/helpers/UitpasTokenRepository.ts +7 -7
- package/src/helpers/ViesHelper.ts +5 -4
- package/src/helpers/XlsxTransformerColumnHelper.ts +21 -19
- package/src/helpers/email-html-helpers.ts +13 -12
- package/src/helpers/fetchToAsyncIterator.ts +1 -1
- package/src/helpers/outstandingBalanceJoin.ts +2 -1
- package/src/helpers/updateMemberDetailsUitpasNumber.ts +5 -4
- package/src/middleware/ContextMiddleware.ts +1 -1
- package/src/migrate.ts +21 -4
- package/src/seeds/0000000003-default-email-templates.ts +1 -1
- package/src/seeds/0000000004-single-organization.ts +2 -1
- package/src/seeds/1752848561-groups-registration-periods.ts +3 -2
- package/src/seeds/1754560914-groups-prices.test.ts +2 -1
- package/src/seeds/1754560914-groups-prices.ts +2 -1
- package/src/seeds/1755790070-fill-email-recipient-errors.ts +6 -6
- package/src/seeds/1755876819-remove-duplicate-members.ts +2 -1
- package/src/seeds/1765896674-document-update-year.test.ts +2 -1
- package/src/seeds/1773754928-force-save-members.ts +15 -0
- package/src/services/AuditLogService.ts +3 -2
- package/src/services/BalanceItemPaymentService.ts +2 -2
- package/src/services/BalanceItemService.ts +2 -1
- package/src/services/BootChecksService.test.ts +33 -0
- package/src/services/BootChecksService.ts +21 -0
- package/src/services/DatabaseCollationService.test.ts +18 -0
- package/src/services/DatabaseCollationService.ts +81 -0
- package/src/services/DocumentService.ts +1 -1
- package/src/services/EventNotificationService.ts +5 -4
- package/src/services/FileSignService.ts +2 -2
- package/src/services/InvoiceService.ts +3 -3
- package/src/services/MemberNumberService.ts +6 -4
- package/src/services/MemberRecordStore.ts +28 -19
- package/src/services/PaymentReallocationService.test.ts +2 -1
- package/src/services/PaymentReallocationService.ts +2 -1
- package/src/services/PaymentService.ts +28 -26
- package/src/services/RegistrationService.ts +65 -3
- package/src/services/SSOService.ts +13 -9
- package/src/services/STPackageService.ts +7 -5
- package/src/services/StartupHealthService.ts +15 -0
- package/src/services/uitpas/PassholderEndpoints.ts +2 -2
- package/src/services/uitpas/UitpasService.ts +11 -8
- package/src/services/uitpas/cancelTicketSales.ts +1 -1
- package/src/services/uitpas/checkPermissionsFor.ts +9 -9
- package/src/services/uitpas/getSocialTariffForEvent.ts +4 -4
- package/src/services/uitpas/getSocialTariffForUitpasNumbers.ts +5 -5
- package/src/services/uitpas/handleUitpasResponse.ts +1 -1
- package/src/services/uitpas/registerTicketSales.ts +4 -4
- package/src/services/uitpas/searchUitpasEvents.ts +3 -3
- package/src/services/uitpas/searchUitpasOrganizers.ts +3 -3
- package/src/sql-filters/audit-logs.ts +2 -1
- package/src/sql-filters/balance-item-payments.ts +2 -1
- package/src/sql-filters/balance-items.ts +2 -1
- package/src/sql-filters/base-registration-filter-compilers.ts +6 -4
- package/src/sql-filters/document-templates.ts +2 -1
- package/src/sql-filters/documents.ts +2 -1
- package/src/sql-filters/email-recipients.ts +2 -1
- package/src/sql-filters/emails.ts +2 -1
- package/src/sql-filters/event-notifications.ts +2 -1
- package/src/sql-filters/events.ts +2 -1
- package/src/sql-filters/groups.ts +2 -1
- package/src/sql-filters/invoiced-balance-items.ts +2 -1
- package/src/sql-filters/invoices.ts +2 -1
- package/src/sql-filters/member-responsibility-records.ts +2 -1
- package/src/sql-filters/members.ts +8 -7
- package/src/sql-filters/orders.ts +3 -2
- package/src/sql-filters/organization-registration-periods.ts +2 -1
- package/src/sql-filters/organizations.ts +2 -1
- package/src/sql-filters/payments.ts +2 -1
- package/src/sql-filters/platform-memberships.ts +67 -0
- package/src/sql-filters/receivable-balances.ts +2 -1
- package/src/sql-filters/registration-periods.ts +2 -1
- package/src/sql-filters/registrations.ts +2 -1
- package/src/sql-filters/tickets.ts +2 -1
- package/src/sql-filters/users.ts +2 -1
- package/src/sql-filters/webshops.ts +38 -0
- package/src/sql-sorters/audit-logs.ts +3 -2
- package/src/sql-sorters/balance-items.ts +3 -2
- package/src/sql-sorters/document-templates.ts +3 -2
- package/src/sql-sorters/documents.ts +3 -2
- package/src/sql-sorters/email-recipients.ts +3 -2
- package/src/sql-sorters/emails.ts +3 -2
- package/src/sql-sorters/event-notifications.ts +3 -2
- package/src/sql-sorters/events.ts +3 -2
- package/src/sql-sorters/groups.ts +3 -2
- package/src/sql-sorters/invoices.ts +3 -2
- package/src/sql-sorters/members.ts +3 -2
- package/src/sql-sorters/orders.ts +3 -2
- package/src/sql-sorters/organization-registration-periods.ts +3 -2
- package/src/sql-sorters/organizations.ts +3 -2
- package/src/sql-sorters/payments.ts +3 -2
- package/src/sql-sorters/platform-memberships.ts +40 -0
- package/src/sql-sorters/receivable-balances.ts +3 -2
- package/src/sql-sorters/registration-periods.ts +3 -2
- package/src/sql-sorters/registrations.ts +3 -2
- package/src/sql-sorters/tickets.ts +3 -2
- package/src/sql-sorters/webshops.ts +40 -0
- package/tests/actions/patchOrganizationMember.ts +5 -4
- package/tests/actions/patchPaymentStatus.ts +2 -2
- package/tests/actions/patchUserMember.ts +6 -4
- package/tests/e2e/api-rate-limits.test.ts +4 -5
- package/tests/e2e/bundle-discounts.test.ts +3 -2
- package/tests/e2e/charge-members.test.ts +7 -5
- package/tests/e2e/documents.test.ts +3 -2
- package/tests/e2e/private-files.test.ts +11 -13
- package/tests/e2e/register.test.ts +6 -5
- package/tests/e2e/stock.test.ts +6 -8
- package/tests/e2e/tickets.test.ts +4 -2
- package/tests/helpers/StripeMocker.ts +3 -3
- package/tests/init/initAdmin.ts +4 -2
- package/tests/init/initBundleDiscount.ts +3 -2
- package/tests/init/initPayconiq.ts +1 -1
- package/tests/init/initPermissionRole.ts +4 -2
- package/tests/init/initPlatformRecordCategory.ts +1 -1
- package/tests/init/initStripe.ts +1 -1
- package/tests/vitest.global.setup.ts +26 -0
- package/tests/{jest.setup.ts → vitest.setup.ts} +4 -3
- package/tsconfig.build.json +17 -0
- package/tsconfig.json +10 -41
- package/tsconfig.test.json +17 -0
- package/vitest.config.js +13 -0
- package/eslint.config.mjs +0 -5
- package/jest.config.cjs +0 -27
- package/tests/jest.global.setup.ts +0 -33
- package/tests/toMatchMap.ts +0 -68
package/package.json
CHANGED
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/backend",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.120.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "./dist/index.js",
|
|
5
6
|
"exports": {
|
|
6
7
|
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js",
|
|
7
10
|
"require": "./dist/index.js"
|
|
8
11
|
},
|
|
9
|
-
"./
|
|
12
|
+
"./migrate": {
|
|
13
|
+
"types": "./dist/src/migrate.d.ts",
|
|
14
|
+
"import": "./dist/src/migrate.js",
|
|
10
15
|
"require": "./dist/src/migrate.js"
|
|
11
16
|
},
|
|
12
|
-
"./
|
|
17
|
+
"./boot": {
|
|
18
|
+
"types": "./dist/src/boot.d.ts",
|
|
19
|
+
"import": "./dist/src/boot.js",
|
|
13
20
|
"require": "./dist/src/boot.js"
|
|
14
21
|
},
|
|
15
22
|
"./tests/helpers": {
|
|
23
|
+
"@stamhoofd/source": "./tests/helpers/index.ts",
|
|
24
|
+
"types": "./dist/tests/helpers/index.d.ts",
|
|
25
|
+
"import": "./dist/tests/helpers/index.js",
|
|
16
26
|
"require": "./dist/tests/helpers/index.js"
|
|
17
27
|
}
|
|
18
28
|
},
|
|
19
29
|
"license": "UNLICENCED",
|
|
20
30
|
"scripts": {
|
|
21
31
|
"dev": "wait-on ../../shared/middleware/dist/index.js && concurrently -r 'yarn -s build --watch --preserveWatchOutput' \"yarn -s dev:watch\"",
|
|
32
|
+
"dev:build": "yarn -s build",
|
|
22
33
|
"dev:full": "yarn -s dev",
|
|
23
34
|
"dev:watch": "wait-on ./dist/index.js && nodemon --quiet --inspect=5858 --watch dist --watch '../../../shared/*/dist/' --watch '../../shared/*/dist/' --ext .ts,.json,.sql,.js --delay 2000ms --exec 'node --enable-source-maps ./dist/index.js' --signal SIGTERM",
|
|
24
35
|
"dev:backend": "yarn -s dev",
|
|
25
|
-
"build": "
|
|
26
|
-
"copy-assets": "rsync --delete --mkpath --exclude='*.ts' --exclude='*.js' -r --checksum ./src/ ./dist/src/",
|
|
36
|
+
"build": "tsc --build tsconfig.build.json --clean && yarn -s copy-assets && tsc --build tsconfig.build.json",
|
|
37
|
+
"copy-assets": "rsync --delete --mkpath --exclude='*.ts' --exclude='*.js' --exclude='*.map' -r --checksum ./src/ ./dist/src/",
|
|
27
38
|
"build:full": "yarn -s clear && yarn -s build",
|
|
28
|
-
"clear": "rm -rf ./dist",
|
|
39
|
+
"clear": "rm -rf ./dist && rm -f *.tsbuildinfo",
|
|
29
40
|
"start": "yarn -s build && node --enable-source-maps ./dist/index.js",
|
|
30
|
-
"test": "
|
|
31
|
-
"test:
|
|
32
|
-
"test:reset": "yarn -s build:full && jest --runInBand",
|
|
41
|
+
"test": "vitest",
|
|
42
|
+
"test:reset": "yarn -s build:full && yarn -s test",
|
|
33
43
|
"migrations": "yarn -s build:full && node ./dist/migrations.js",
|
|
34
44
|
"lint": "eslint"
|
|
35
45
|
},
|
|
@@ -51,18 +61,18 @@
|
|
|
51
61
|
"@aws-sdk/s3-request-presigner": "^3.839.0",
|
|
52
62
|
"@bwip-js/node": "^4.5.1",
|
|
53
63
|
"@mollie/api-client": "4.3.3",
|
|
54
|
-
"@simonbackx/simple-database": "1.
|
|
55
|
-
"@simonbackx/simple-encoding": "2.
|
|
56
|
-
"@simonbackx/simple-endpoints": "1.
|
|
64
|
+
"@simonbackx/simple-database": "1.36.12",
|
|
65
|
+
"@simonbackx/simple-encoding": "2.26.5",
|
|
66
|
+
"@simonbackx/simple-endpoints": "1.21.0",
|
|
57
67
|
"@simonbackx/simple-logging": "^1.0.1",
|
|
58
|
-
"@stamhoofd/backend-i18n": "2.
|
|
59
|
-
"@stamhoofd/backend-middleware": "2.
|
|
60
|
-
"@stamhoofd/email": "2.
|
|
61
|
-
"@stamhoofd/models": "2.
|
|
62
|
-
"@stamhoofd/queues": "2.
|
|
63
|
-
"@stamhoofd/sql": "2.
|
|
64
|
-
"@stamhoofd/structures": "2.
|
|
65
|
-
"@stamhoofd/utility": "2.
|
|
68
|
+
"@stamhoofd/backend-i18n": "2.120.0",
|
|
69
|
+
"@stamhoofd/backend-middleware": "2.120.0",
|
|
70
|
+
"@stamhoofd/email": "2.120.0",
|
|
71
|
+
"@stamhoofd/models": "2.120.0",
|
|
72
|
+
"@stamhoofd/queues": "2.120.0",
|
|
73
|
+
"@stamhoofd/sql": "2.120.0",
|
|
74
|
+
"@stamhoofd/structures": "2.120.0",
|
|
75
|
+
"@stamhoofd/utility": "2.120.0",
|
|
66
76
|
"archiver": "^7.0.1",
|
|
67
77
|
"axios": "^1.13.2",
|
|
68
78
|
"cookie": "^0.7.0",
|
|
@@ -72,7 +82,7 @@
|
|
|
72
82
|
"luxon": "3.4.4",
|
|
73
83
|
"mailparser": "^3.9.1",
|
|
74
84
|
"mockdate": "^3.0.2",
|
|
75
|
-
"mysql2": "^3.
|
|
85
|
+
"mysql2": "^3.20.0",
|
|
76
86
|
"node-rsa": "1.1.1",
|
|
77
87
|
"openid-client": "^5.4.0",
|
|
78
88
|
"stripe": "^16.6.0"
|
|
@@ -80,5 +90,5 @@
|
|
|
80
90
|
"publishConfig": {
|
|
81
91
|
"access": "public"
|
|
82
92
|
},
|
|
83
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "f38f79c15ce16b0c8c14743ff3eb61feda5a18d4"
|
|
84
94
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ModelEvent } from '@simonbackx/simple-database';
|
|
2
|
+
import { Model } from '@simonbackx/simple-database';
|
|
2
3
|
import { AuditLog } from '@stamhoofd/models';
|
|
3
4
|
import { ObjectDiffer } from '@stamhoofd/object-differ';
|
|
4
|
-
import {
|
|
5
|
+
import type { AuditLogType } from '@stamhoofd/structures';
|
|
6
|
+
import { AuditLogPatchItem, AuditLogPatchItemType, AuditLogReplacement, AuditLogSource } from '@stamhoofd/structures';
|
|
5
7
|
import { ContextInstance } from '../helpers/Context.js';
|
|
6
8
|
import { AuditLogService } from '../services/AuditLogService.js';
|
|
7
9
|
|
|
@@ -50,7 +50,7 @@ export const OrderLogger = new ModelLogger(Order, {
|
|
|
50
50
|
id: model.id,
|
|
51
51
|
value: model.number ? `bestelling #${model.number}` : `bestelling van ${model.data.customer.name}`,
|
|
52
52
|
type: AuditLogReplacementType.Order,
|
|
53
|
-
description: model.number ? model.data.customer.name : $t(`
|
|
53
|
+
description: model.number ? model.data.customer.name : $t(`%Cq`),
|
|
54
54
|
})],
|
|
55
55
|
]);
|
|
56
56
|
},
|
package/src/boot.ts
CHANGED
|
@@ -16,12 +16,14 @@ import { SetupStepUpdater } from './helpers/SetupStepUpdater.js';
|
|
|
16
16
|
import { ContextMiddleware } from './middleware/ContextMiddleware.js';
|
|
17
17
|
import { AuditLogService } from './services/AuditLogService.js';
|
|
18
18
|
import { BalanceItemService } from './services/BalanceItemService.js';
|
|
19
|
+
import { BootChecksService } from './services/BootChecksService.js';
|
|
19
20
|
import { CpuService } from './services/CpuService.js';
|
|
20
21
|
import { DocumentService } from './services/DocumentService.js';
|
|
21
22
|
import { FileSignService } from './services/FileSignService.js';
|
|
22
23
|
import { PlatformMembershipService } from './services/PlatformMembershipService.js';
|
|
23
24
|
import { UitpasService } from './services/uitpas/UitpasService.js';
|
|
24
25
|
import { UniqueUserService } from './services/UniqueUserService.js';
|
|
26
|
+
import { AutoEncoder } from '@simonbackx/simple-encoding';
|
|
25
27
|
|
|
26
28
|
process.on('unhandledRejection', (error: Error) => {
|
|
27
29
|
console.error('unhandledRejection');
|
|
@@ -35,16 +37,25 @@ Column.setJSONVersion(Version);
|
|
|
35
37
|
// Set timezone
|
|
36
38
|
process.env.TZ = 'UTC';
|
|
37
39
|
|
|
40
|
+
if (STAMHOOFD.environment === 'development') {
|
|
41
|
+
Error.stackTraceLimit = 100;
|
|
42
|
+
}
|
|
43
|
+
|
|
38
44
|
// Quick check
|
|
39
45
|
if (new Date().getTimezoneOffset() !== 0) {
|
|
40
46
|
throw new Error('Process should always run in UTC timezone');
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
const seeds = async () => {
|
|
49
|
+
const seeds = async (options: {shutdown: () => Promise<void>}) => {
|
|
44
50
|
try {
|
|
45
51
|
// Internal
|
|
46
52
|
await AuditLogService.disable(async () => {
|
|
47
|
-
await Migration.runAll(
|
|
53
|
+
if (!await Migration.runAll(import.meta.dirname + '/seeds')) {
|
|
54
|
+
console.error('Seeds failed!')
|
|
55
|
+
if (STAMHOOFD.environment === 'test' || STAMHOOFD.environment === 'development') {
|
|
56
|
+
await options.shutdown();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
48
59
|
});
|
|
49
60
|
}
|
|
50
61
|
catch (e) {
|
|
@@ -61,14 +72,21 @@ function productionLog(message: string) {
|
|
|
61
72
|
}
|
|
62
73
|
|
|
63
74
|
export const boot = async (options: { killProcess: boolean }) => {
|
|
75
|
+
// Make sure we use the current environment for connecting to the database
|
|
76
|
+
await Database.reload({})
|
|
77
|
+
|
|
64
78
|
productionLog('Running server at v' + Version);
|
|
65
79
|
productionLog('Running server at port ' + STAMHOOFD.PORT);
|
|
66
80
|
productionLog('Running server on DB ' + process.env.DB_DATABASE); // note, should always use process env here
|
|
81
|
+
console.log('Node version is: ' + process.version);
|
|
82
|
+
|
|
83
|
+
AutoEncoder.skipDefaultValuesVersion = 10000; // todo
|
|
67
84
|
|
|
68
85
|
loadLogger();
|
|
69
86
|
|
|
70
87
|
await GlobalHelper.load();
|
|
71
88
|
await UniqueUserService.check();
|
|
89
|
+
await BootChecksService.checkDatabaseCollation();
|
|
72
90
|
|
|
73
91
|
// Init platform shared struct: otherwise permissions won't work with missing responsibilities
|
|
74
92
|
productionLog('Loading platform...');
|
|
@@ -79,17 +97,17 @@ export const boot = async (options: { killProcess: boolean }) => {
|
|
|
79
97
|
productionLog('Loading endpoints...');
|
|
80
98
|
|
|
81
99
|
// Note: we should load endpoints one by once to have a reliable order of url matching
|
|
82
|
-
await router.loadAllEndpoints(
|
|
83
|
-
await router.loadAllEndpoints(
|
|
84
|
-
await router.loadAllEndpoints(
|
|
85
|
-
|
|
86
|
-
await router.loadAllEndpoints(
|
|
87
|
-
await router.loadAllEndpoints(
|
|
88
|
-
await router.loadAllEndpoints(
|
|
89
|
-
await router.loadAllEndpoints(
|
|
90
|
-
await router.loadAllEndpoints(
|
|
91
|
-
await router.loadAllEndpoints(
|
|
92
|
-
await router.loadAllEndpoints(
|
|
100
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/global/*');
|
|
101
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/admin/*');
|
|
102
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/frontend');
|
|
103
|
+
|
|
104
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/auth');
|
|
105
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/organization/dashboard/*');
|
|
106
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/organization/registration');
|
|
107
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/organization/webshops');
|
|
108
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/organization/shared');
|
|
109
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/organization/shared/*');
|
|
110
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/system');
|
|
93
111
|
|
|
94
112
|
router.endpoints.push(new CORSPreflightEndpoint());
|
|
95
113
|
|
|
@@ -257,7 +275,7 @@ export const boot = async (options: { killProcess: boolean }) => {
|
|
|
257
275
|
UitpasService.listen();
|
|
258
276
|
|
|
259
277
|
startCrons();
|
|
260
|
-
seeds().catch(console.error);
|
|
278
|
+
seeds({ shutdown }).catch(console.error);
|
|
261
279
|
|
|
262
280
|
return { shutdown };
|
|
263
281
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { registerCron } from '@stamhoofd/crons';
|
|
2
2
|
import { CachedBalance, Email, EmailRecipient, Organization, User } from '@stamhoofd/models';
|
|
3
|
-
import { IterableSQLSelect
|
|
4
|
-
import {
|
|
3
|
+
import type { IterableSQLSelect} from '@stamhoofd/sql';
|
|
4
|
+
import { readDynamicSQLExpression, SQL, SQLCalculation, SQLPlusSign } from '@stamhoofd/sql';
|
|
5
|
+
import type { OrganizationEmail, StamhoofdFilter } from '@stamhoofd/structures';
|
|
6
|
+
import { EmailRecipientFilter, EmailRecipientFilterType, EmailRecipientSubfilter, EmailTemplateType, ReceivableBalanceType } from '@stamhoofd/structures';
|
|
5
7
|
import { ContextInstance } from '../helpers/Context.js';
|
|
6
8
|
|
|
7
9
|
registerCron('balanceEmails', balanceEmails);
|
|
@@ -3,8 +3,8 @@ import fs from 'fs/promises';
|
|
|
3
3
|
import { clearExcelCacheHelper } from './clearExcelCache.js';
|
|
4
4
|
|
|
5
5
|
const testPath = '/Users/user/project/backend/app/api/.cache';
|
|
6
|
-
|
|
7
|
-
const fsMock =
|
|
6
|
+
vitest.mock('fs/promises');
|
|
7
|
+
const fsMock = vitest.mocked(fs, { deep: false });
|
|
8
8
|
|
|
9
9
|
describe('clearExcelCacheHelper', () => {
|
|
10
10
|
it('should only run between 3 and 6 AM', async () => {
|
|
@@ -34,7 +34,7 @@ describe('clearExcelCacheHelper', () => {
|
|
|
34
34
|
environment: 'production',
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
expect(didClear).
|
|
37
|
+
expect(didClear).toBe(false);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
for (const date of shouldPass) {
|
|
@@ -45,7 +45,7 @@ describe('clearExcelCacheHelper', () => {
|
|
|
45
45
|
environment: 'production',
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
expect(didClear).
|
|
48
|
+
expect(didClear).toBe(true);
|
|
49
49
|
}
|
|
50
50
|
// #endregion
|
|
51
51
|
});
|
|
@@ -70,7 +70,7 @@ describe('clearExcelCacheHelper', () => {
|
|
|
70
70
|
environment: 'production',
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
expect(didClearSecondTry).
|
|
73
|
+
expect(didClearSecondTry).toBe(false);
|
|
74
74
|
|
|
75
75
|
// third try, should pass because the last clear was more than a day ago
|
|
76
76
|
const didClearThirdTry = await clearExcelCacheHelper({
|
|
@@ -80,7 +80,7 @@ describe('clearExcelCacheHelper', () => {
|
|
|
80
80
|
environment: 'production',
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
expect(didClearThirdTry).
|
|
83
|
+
expect(didClearThirdTry).toBe(true);
|
|
84
84
|
|
|
85
85
|
// fourth try, should fail because 5 min earlier the cache was cleared
|
|
86
86
|
const didClearFourthTry = await clearExcelCacheHelper({
|
|
@@ -90,7 +90,7 @@ describe('clearExcelCacheHelper', () => {
|
|
|
90
90
|
environment: 'production',
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
-
expect(didClearFourthTry).
|
|
93
|
+
expect(didClearFourthTry).toBe(false);
|
|
94
94
|
// #endregion
|
|
95
95
|
});
|
|
96
96
|
|
|
@@ -132,7 +132,7 @@ describe('clearExcelCacheHelper', () => {
|
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
fsMock.readdir.mockReturnValue(
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
Promise.resolve([...directories, file1]) as any,
|
|
137
137
|
);
|
|
138
138
|
// #endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { CachedBalance } from '@stamhoofd/models';
|
|
2
1
|
import { registerCron } from '@stamhoofd/crons';
|
|
2
|
+
import { CachedBalance } from '@stamhoofd/models';
|
|
3
|
+
import { ReceivableBalanceType } from '@stamhoofd/structures';
|
|
3
4
|
|
|
4
5
|
registerCron('updateCachedBalances', updateCachedBalances);
|
|
5
6
|
|
|
@@ -11,28 +12,53 @@ async function updateCachedBalances() {
|
|
|
11
12
|
|
|
12
13
|
const balances = await CachedBalance.select().where(
|
|
13
14
|
CachedBalance.whereNeedsUpdate(),
|
|
14
|
-
)
|
|
15
|
+
)
|
|
16
|
+
/**
|
|
17
|
+
* Cached balances of member should be updated before the cached balances of the user
|
|
18
|
+
* because the cached balances of the user are dependent on the cached balances of the member.
|
|
19
|
+
*/
|
|
20
|
+
.orderBy('objectType', 'ASC')
|
|
21
|
+
// minimize the number of queries when updating
|
|
22
|
+
.orderBy('organizationId', 'ASC')
|
|
23
|
+
.limit(100).fetch();
|
|
15
24
|
|
|
16
|
-
// Group by object type
|
|
17
|
-
const grouped = new Map<string, CachedBalance[]
|
|
25
|
+
// Group by object type, next by organization id
|
|
26
|
+
const grouped = new Map<ReceivableBalanceType, Map<string, CachedBalance[]>>();
|
|
18
27
|
|
|
19
28
|
for (const balance of balances) {
|
|
20
|
-
const
|
|
21
|
-
|
|
29
|
+
const objectType = balance.objectType;
|
|
30
|
+
let organizationMap = grouped.get(objectType);
|
|
31
|
+
if (!organizationMap) {
|
|
32
|
+
organizationMap = new Map<string, CachedBalance[]>();
|
|
33
|
+
grouped.set(objectType, organizationMap);
|
|
34
|
+
}
|
|
22
35
|
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
const organizationId = balance.organizationId;
|
|
37
|
+
const balances = organizationMap.get(organizationId);
|
|
38
|
+
|
|
39
|
+
if (!balances) {
|
|
40
|
+
organizationMap.set(organizationId, [balance]);
|
|
25
41
|
continue;
|
|
26
42
|
}
|
|
27
43
|
|
|
28
|
-
|
|
44
|
+
balances.push(balance);
|
|
29
45
|
}
|
|
30
46
|
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
// update member balances first
|
|
48
|
+
const objectTypeMemberFirst = Array.from(grouped.entries());
|
|
49
|
+
objectTypeMemberFirst.sort((a, b) => {
|
|
50
|
+
const aIsMember = a[0] === ReceivableBalanceType.member;
|
|
51
|
+
const bIsMember = b[0] === ReceivableBalanceType.member;
|
|
52
|
+
if (aIsMember && !bIsMember) return -1;
|
|
53
|
+
if (!aIsMember && bIsMember) return 1;
|
|
54
|
+
return 0;
|
|
55
|
+
});
|
|
33
56
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
57
|
+
for (const [objectType, organizationMap] of objectTypeMemberFirst) {
|
|
58
|
+
for (const [organizationId, balances] of organizationMap) {
|
|
59
|
+
const ids = balances.map(b => b.objectId);
|
|
60
|
+
console.log('Updating', ids.length, objectType, 'for', organizationId);
|
|
61
|
+
await CachedBalance.updateForObjects(organizationId, ids, objectType);
|
|
62
|
+
}
|
|
37
63
|
}
|
|
38
64
|
}
|
package/src/debug.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Column } from '@simonbackx/simple-database';
|
|
2
|
-
import {
|
|
2
|
+
import type { ResponseMiddleware, RouterServer } from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { EncodedResponse, Router } from '@simonbackx/simple-endpoints';
|
|
3
4
|
import { logger } from '@simonbackx/simple-logging';
|
|
4
5
|
import { requestPrefix } from '@stamhoofd/backend-middleware';
|
|
5
6
|
|
|
6
7
|
import { AutoEncoder } from '@simonbackx/simple-encoding';
|
|
7
|
-
import { Request, Response } from '@simonbackx/simple-endpoints';
|
|
8
|
+
import type { Request, Response } from '@simonbackx/simple-endpoints';
|
|
8
9
|
import { SQLLogger } from '@stamhoofd/sql';
|
|
9
10
|
import { ContextInstance } from './helpers/Context.js';
|
|
10
11
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Email, Member } from '@stamhoofd/models';
|
|
2
2
|
import { SQL } from '@stamhoofd/sql';
|
|
3
|
-
import {
|
|
3
|
+
import type { LimitedFilteredRequest} from '@stamhoofd/structures';
|
|
4
|
+
import { EmailRecipient, EmailRecipientFilterType, PaginatedResponse, Replacement } from '@stamhoofd/structures';
|
|
4
5
|
import { GetDocumentsEndpoint } from '../endpoints/organization/dashboard/documents/GetDocumentsEndpoint.js';
|
|
5
6
|
|
|
6
7
|
async function fetch(query: LimitedFilteredRequest) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Email } from '@stamhoofd/models';
|
|
2
2
|
import { SQL } from '@stamhoofd/sql';
|
|
3
|
-
import { EmailRecipient,
|
|
3
|
+
import type { EmailRecipient, LimitedFilteredRequest, MembersBlob} from '@stamhoofd/structures';
|
|
4
|
+
import { EmailRecipientFilterType, PaginatedResponse, mergeFilters } from '@stamhoofd/structures';
|
|
4
5
|
import { GetMembersEndpoint } from '../endpoints/global/members/GetMembersEndpoint.js';
|
|
5
6
|
|
|
6
7
|
async function getRecipients(result: PaginatedResponse<MembersBlob, LimitedFilteredRequest>, type: 'member' | 'parents' | 'unverified') {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Email, Webshop } from '@stamhoofd/models';
|
|
2
|
-
import { EmailRecipient,
|
|
2
|
+
import type { EmailRecipient, LimitedFilteredRequest, WebshopPreview } from '@stamhoofd/structures';
|
|
3
|
+
import { EmailRecipientFilterType, mergeFilters, PaginatedResponse } from '@stamhoofd/structures';
|
|
3
4
|
import { GetWebshopOrdersEndpoint } from '../endpoints/organization/dashboard/webshops/GetWebshopOrdersEndpoint.js';
|
|
4
5
|
import { AuthenticatedStructures } from '../helpers/AuthenticatedStructures.js';
|
|
5
6
|
import { Context } from '../helpers/Context.js';
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { RecipientLoader} from '@stamhoofd/models';
|
|
2
|
+
import { BalanceItem, BalanceItemPayment, Email, Member, MemberResponsibilityRecord, Order, Organization, Payment, User, Webshop } from '@stamhoofd/models';
|
|
2
3
|
import { compileToSQLFilter, SQL } from '@stamhoofd/sql';
|
|
3
|
-
import {
|
|
4
|
+
import type { LimitedFilteredRequest, PaymentGeneral, StamhoofdFilter } from '@stamhoofd/structures';
|
|
5
|
+
import { CountFilteredRequest, EmailRecipient, EmailRecipientFilterType, PaginatedResponse, PaymentMethod } from '@stamhoofd/structures';
|
|
4
6
|
import { Formatter } from '@stamhoofd/utility';
|
|
5
7
|
import { GetPaymentsEndpoint } from '../endpoints/organization/dashboard/payments/GetPaymentsEndpoint.js';
|
|
6
8
|
import { memberResponsibilityRecordFilterCompilers } from '../sql-filters/member-responsibility-records.js';
|
|
7
|
-
import {
|
|
9
|
+
import type { ReplacementsOptions } from '../email-replacements/getEmailReplacementsForPayment.js';
|
|
10
|
+
import { buildReplacementOptions, getEmailReplacementsForPayment } from '../email-replacements/getEmailReplacementsForPayment.js';
|
|
8
11
|
|
|
9
12
|
type BeforeFetchAllResult = {
|
|
10
13
|
doesIncludePaymentWithoutOrders: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CachedBalance, Email } from '@stamhoofd/models';
|
|
2
|
-
import {
|
|
2
|
+
import type { LimitedFilteredRequest, StamhoofdFilter } from '@stamhoofd/structures';
|
|
3
|
+
import { BalanceItem as BalanceItemStruct, compileToInMemoryFilter, EmailRecipient, EmailRecipientFilterType, PaginatedResponse, receivableBalanceObjectContactInMemoryFilterCompilers, ReceivableBalanceType, Replacement } from '@stamhoofd/structures';
|
|
3
4
|
import { Formatter } from '@stamhoofd/utility';
|
|
4
5
|
import { GetReceivableBalancesEndpoint } from '../endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesEndpoint.js';
|
|
5
6
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Email, Member } from '@stamhoofd/models';
|
|
2
2
|
import { SQL } from '@stamhoofd/sql';
|
|
3
|
-
import { EmailRecipient,
|
|
3
|
+
import type { EmailRecipient, LimitedFilteredRequest, RegistrationsBlob} from '@stamhoofd/structures';
|
|
4
|
+
import { EmailRecipientFilterType, PaginatedResponse, mergeFilters } from '@stamhoofd/structures';
|
|
4
5
|
import { GetRegistrationsEndpoint } from '../endpoints/global/registration/GetRegistrationsEndpoint.js';
|
|
5
6
|
import { memberJoin } from '../sql-filters/registrations.js';
|
|
6
7
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Order, Organization, Webshop } from '@stamhoofd/models';
|
|
2
|
-
import { BalanceItemPaymentsHtmlTableItem,
|
|
2
|
+
import type { BalanceItemPaymentsHtmlTableItem, PaymentGeneral} from '@stamhoofd/structures';
|
|
3
|
+
import { BalanceItemRelationType, BalanceItemType, getBalanceItemPaymentsHtmlTable, PaymentMethod, PaymentMethodHelper, Replacement, Webshop as WebshopStruct } from '@stamhoofd/structures';
|
|
3
4
|
import { Formatter } from '@stamhoofd/utility';
|
|
4
5
|
import { createOrderDataHTMLTable } from '../helpers/email-html-helpers.js';
|
|
5
6
|
|
|
@@ -216,7 +217,7 @@ function getPaymentContext(payment: PaymentGeneral, { orderMap, webshopMap }: Re
|
|
|
216
217
|
const webshop = webshopMap.get(order.webshopId);
|
|
217
218
|
if (webshop) {
|
|
218
219
|
if (order.number) {
|
|
219
|
-
overviewContext.add($t('
|
|
220
|
+
overviewContext.add($t('%1Kz', {
|
|
220
221
|
webshop: webshop.meta.name,
|
|
221
222
|
orderNumber: order.number ?? '',
|
|
222
223
|
}));
|
|
@@ -226,7 +227,7 @@ function getPaymentContext(payment: PaymentGeneral, { orderMap, webshopMap }: Re
|
|
|
226
227
|
}
|
|
227
228
|
}
|
|
228
229
|
else {
|
|
229
|
-
overviewContext.add($t('
|
|
230
|
+
overviewContext.add($t('%1L0', {
|
|
230
231
|
orderNumber: order.number ?? '',
|
|
231
232
|
}));
|
|
232
233
|
}
|
|
@@ -252,8 +253,8 @@ function getPaymentContext(payment: PaymentGeneral, { orderMap, webshopMap }: Re
|
|
|
252
253
|
}
|
|
253
254
|
|
|
254
255
|
if (registrationMemberNames.size > 0) {
|
|
255
|
-
const memberNames = Formatter.joinLast([...registrationMemberNames], ', ', ' ' + $t(`
|
|
256
|
-
overviewContext.add($t(`
|
|
256
|
+
const memberNames = Formatter.joinLast([...registrationMemberNames], ', ', ' ' + $t(`%M1`) + ' ');
|
|
257
|
+
overviewContext.add($t(`%x6`) + ' ' + memberNames);
|
|
257
258
|
}
|
|
258
259
|
|
|
259
260
|
if (overviewContext.size === 0) {
|
|
@@ -273,11 +274,11 @@ function getPaymentContext(payment: PaymentGeneral, { orderMap, webshopMap }: Re
|
|
|
273
274
|
}
|
|
274
275
|
|
|
275
276
|
// else return default text for multiple items
|
|
276
|
-
return $t('
|
|
277
|
+
return $t('%1Kx', { count: payment.balanceItemPayments.length });
|
|
277
278
|
}
|
|
278
279
|
|
|
279
280
|
// else return default text for single item
|
|
280
|
-
return $t('
|
|
281
|
+
return $t('%1Ky');
|
|
281
282
|
}
|
|
282
283
|
|
|
283
284
|
// join texts for balance items with type order or registration
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { DecodedRequest,
|
|
1
|
+
import type { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
3
4
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
5
|
import { ChargeRequest, LimitedFilteredRequest, PermissionLevel } from '@stamhoofd/structures';
|
|
5
6
|
|
|
@@ -35,7 +36,7 @@ export class ChargeMembersEndpoint extends Endpoint<Params, Query, Body, Respons
|
|
|
35
36
|
throw new SimpleError({
|
|
36
37
|
code: 'invalid_field',
|
|
37
38
|
message: 'Invalid description',
|
|
38
|
-
human: $t(`
|
|
39
|
+
human: $t(`%Cr`),
|
|
39
40
|
field: 'description',
|
|
40
41
|
});
|
|
41
42
|
}
|
|
@@ -44,7 +45,7 @@ export class ChargeMembersEndpoint extends Endpoint<Params, Query, Body, Respons
|
|
|
44
45
|
throw new SimpleError({
|
|
45
46
|
code: 'invalid_field',
|
|
46
47
|
message: 'Invalid price',
|
|
47
|
-
human: $t(`
|
|
48
|
+
human: $t(`%Cs`),
|
|
48
49
|
field: 'price',
|
|
49
50
|
});
|
|
50
51
|
}
|
|
@@ -53,7 +54,7 @@ export class ChargeMembersEndpoint extends Endpoint<Params, Query, Body, Respons
|
|
|
53
54
|
throw new SimpleError({
|
|
54
55
|
code: 'invalid_field',
|
|
55
56
|
message: 'Invalid amount',
|
|
56
|
-
human: $t(`
|
|
57
|
+
human: $t(`%Ct`),
|
|
57
58
|
field: 'amount',
|
|
58
59
|
});
|
|
59
60
|
}
|
|
@@ -77,7 +78,7 @@ export class ChargeMembersEndpoint extends Endpoint<Params, Query, Body, Respons
|
|
|
77
78
|
throw new SimpleError({
|
|
78
79
|
code: 'charge_pending',
|
|
79
80
|
message: 'Charge members already pending',
|
|
80
|
-
human: $t(`
|
|
81
|
+
human: $t(`%Cu`),
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
84
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DecodedRequest,
|
|
1
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
2
3
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
3
4
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
4
5
|
import { Context } from '../../../helpers/Context.js';
|
|
@@ -34,7 +35,7 @@ export class ChargeMembershipsEndpoint extends Endpoint<Params, Query, Body, Res
|
|
|
34
35
|
throw new SimpleError({
|
|
35
36
|
code: 'charge_pending',
|
|
36
37
|
message: 'Charge already pending',
|
|
37
|
-
human: $t(`
|
|
38
|
+
human: $t(`%Cu`),
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DecodedRequest,
|
|
1
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
2
3
|
import { Platform } from '@stamhoofd/models';
|
|
3
4
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
4
5
|
import { SQL, SQLAlias, SQLCount, SQLDistinct, SQLSelectAs, SQLSum, SQLWhereSign } from '@stamhoofd/sql';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { DecodedRequest,
|
|
1
|
+
import type { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
3
4
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
5
|
import { ChargeRequest, LimitedFilteredRequest } from '@stamhoofd/structures';
|
|
5
6
|
|
|
@@ -48,7 +49,7 @@ export class ChargeOrganizationsEndpoint extends Endpoint<Params, Query, Body, R
|
|
|
48
49
|
throw new SimpleError({
|
|
49
50
|
code: 'charge_pending',
|
|
50
51
|
message: 'Charge organizations already pending',
|
|
51
|
-
human: $t(`
|
|
52
|
+
human: $t(`%Cu`),
|
|
52
53
|
});
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { DecodedRequest,
|
|
1
|
+
import type { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
3
4
|
import { CountFilteredRequest, CountResponse } from '@stamhoofd/structures';
|
|
4
5
|
|
|
5
6
|
import { Context } from '../../../helpers/Context.js';
|