@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/src/helpers/FileCache.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { Formatter } from '@stamhoofd/utility';
|
|
|
3
3
|
import basex from 'base-x';
|
|
4
4
|
import crypto from 'crypto';
|
|
5
5
|
import fs from 'node:fs';
|
|
6
|
-
import { Writable } from 'node:stream';
|
|
7
|
-
import { Readable } from 'stream';
|
|
6
|
+
import type { Writable } from 'node:stream';
|
|
7
|
+
import type { Readable } from 'stream';
|
|
8
8
|
|
|
9
9
|
const ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';
|
|
10
10
|
const baseEncoder = basex(ALPHABET);
|
|
@@ -61,7 +61,7 @@ export class FileCache {
|
|
|
61
61
|
throw new SimpleError({
|
|
62
62
|
code: 'invalid_file',
|
|
63
63
|
message: 'Invalid file',
|
|
64
|
-
human: $t(`
|
|
64
|
+
human: $t(`%Fk`),
|
|
65
65
|
statusCode: 400,
|
|
66
66
|
});
|
|
67
67
|
}
|
|
@@ -73,7 +73,7 @@ export class FileCache {
|
|
|
73
73
|
throw new SimpleError({
|
|
74
74
|
code: 'invalid_file',
|
|
75
75
|
message: 'Invalid file',
|
|
76
|
-
human: $t(`
|
|
76
|
+
human: $t(`%Fk`),
|
|
77
77
|
statusCode: 400,
|
|
78
78
|
});
|
|
79
79
|
}
|
|
@@ -86,7 +86,7 @@ export class FileCache {
|
|
|
86
86
|
throw new SimpleError({
|
|
87
87
|
code: 'invalid_file',
|
|
88
88
|
message: 'Invalid file',
|
|
89
|
-
human: $t(`
|
|
89
|
+
human: $t(`%Fl`),
|
|
90
90
|
statusCode: 400,
|
|
91
91
|
});
|
|
92
92
|
}
|
|
@@ -99,7 +99,7 @@ export class FileCache {
|
|
|
99
99
|
throw new SimpleError({
|
|
100
100
|
code: 'invalid_file',
|
|
101
101
|
message: 'Invalid file',
|
|
102
|
-
human: $t(`
|
|
102
|
+
human: $t(`%Fm`),
|
|
103
103
|
statusCode: 400,
|
|
104
104
|
});
|
|
105
105
|
}
|
|
@@ -111,7 +111,7 @@ export class FileCache {
|
|
|
111
111
|
throw new SimpleError({
|
|
112
112
|
code: 'invalid_file',
|
|
113
113
|
message: 'Invalid file',
|
|
114
|
-
human: $t(`
|
|
114
|
+
human: $t(`%Fn`),
|
|
115
115
|
statusCode: 400,
|
|
116
116
|
});
|
|
117
117
|
}
|
|
@@ -126,7 +126,7 @@ export class FileCache {
|
|
|
126
126
|
throw new SimpleError({
|
|
127
127
|
code: 'file_expired',
|
|
128
128
|
message: 'File expired',
|
|
129
|
-
human: $t(`
|
|
129
|
+
human: $t(`%Fo`),
|
|
130
130
|
statusCode: 404,
|
|
131
131
|
});
|
|
132
132
|
}
|
|
@@ -142,7 +142,7 @@ export class FileCache {
|
|
|
142
142
|
throw new SimpleError({
|
|
143
143
|
code: 'file_expired',
|
|
144
144
|
message: 'File expired',
|
|
145
|
-
human: $t(`
|
|
145
|
+
human: $t(`%Fp`),
|
|
146
146
|
statusCode: 404,
|
|
147
147
|
});
|
|
148
148
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import type { EmailInterface, EmailInterfaceRecipient } from '@stamhoofd/email';
|
|
4
|
+
import { Email, EmailAddress } from '@stamhoofd/email';
|
|
4
5
|
import { Organization, Platform } from '@stamhoofd/models';
|
|
5
6
|
import { Formatter } from '@stamhoofd/utility';
|
|
6
7
|
import { simpleParser } from 'mailparser';
|
|
@@ -67,7 +68,7 @@ export class ForwardHandler {
|
|
|
67
68
|
let defaultEmail: EmailInterfaceRecipient[] = [Email.getWebmasterToEmail()];
|
|
68
69
|
let organizationEmails: EmailInterfaceRecipient[] = [];
|
|
69
70
|
const platform = await Platform.getShared();
|
|
70
|
-
const extraDescription = $t(`
|
|
71
|
+
const extraDescription = $t(`%Fq`) + ' ' + email + $t(`%Fr`) + ' ' + platform.config.name + ' ' + $t(`%Fs`);
|
|
71
72
|
|
|
72
73
|
function doBounce() {
|
|
73
74
|
if (!from) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GroupCategory, GroupCategorySettings, GroupGenderType, GroupSettings, Group as GroupStruct, OrganizationGenderType, OrganizationType, OrganizationTypeHelper, TranslatedString, UmbrellaOrganization } from '@stamhoofd/structures';
|
|
2
|
-
import {
|
|
2
|
+
import type { Organization} from '@stamhoofd/models';
|
|
3
|
+
import { Group, OrganizationRegistrationPeriod, RegistrationPeriod } from '@stamhoofd/models';
|
|
3
4
|
|
|
4
5
|
export class GroupBuilder {
|
|
5
6
|
organization: Organization;
|
|
@@ -3,19 +3,19 @@ import { GroupedThrottledQueue } from './GroupedThrottledQueue.js';
|
|
|
3
3
|
describe('GroupedThrottledQueue', () => {
|
|
4
4
|
// Mock timers for controlling setTimeout
|
|
5
5
|
beforeEach(() => {
|
|
6
|
-
|
|
6
|
+
vitest.useFakeTimers();
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
afterEach(() => {
|
|
10
|
-
|
|
10
|
+
vitest.useRealTimers();
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
afterAll(() => {
|
|
14
|
-
|
|
14
|
+
vitest.clearAllMocks();
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
it('should create an instance with the provided handler', () => {
|
|
18
|
-
const handler =
|
|
18
|
+
const handler = vitest.fn();
|
|
19
19
|
const queue = new GroupedThrottledQueue(handler);
|
|
20
20
|
|
|
21
21
|
expect(queue.handler).toBe(handler);
|
|
@@ -23,7 +23,7 @@ describe('GroupedThrottledQueue', () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
it('should call handler when processing items from a group', async () => {
|
|
26
|
-
const handler =
|
|
26
|
+
const handler = vitest.fn().mockResolvedValue(undefined);
|
|
27
27
|
const queue = new GroupedThrottledQueue<number>(handler);
|
|
28
28
|
|
|
29
29
|
queue.addItem('group1', 1);
|
|
@@ -33,7 +33,7 @@ describe('GroupedThrottledQueue', () => {
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
it('should process items from different groups separately', async () => {
|
|
36
|
-
const handler =
|
|
36
|
+
const handler = vitest.fn().mockResolvedValue(undefined);
|
|
37
37
|
const queue = new GroupedThrottledQueue<number>(handler);
|
|
38
38
|
|
|
39
39
|
queue.addItem('group1', 1);
|
|
@@ -47,7 +47,7 @@ describe('GroupedThrottledQueue', () => {
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
it('should batch items from the same group', async () => {
|
|
50
|
-
const handler =
|
|
50
|
+
const handler = vitest.fn().mockResolvedValue(undefined);
|
|
51
51
|
const queue = new GroupedThrottledQueue<number>(handler);
|
|
52
52
|
|
|
53
53
|
queue.addItems('group1', [1, 2, 3]);
|
|
@@ -59,7 +59,7 @@ describe('GroupedThrottledQueue', () => {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
it('should flush only the specified group', async () => {
|
|
62
|
-
const handler =
|
|
62
|
+
const handler = vitest.fn().mockResolvedValue(undefined);
|
|
63
63
|
const queue = new GroupedThrottledQueue<number>(handler);
|
|
64
64
|
|
|
65
65
|
queue.addItem('group1', 1);
|
|
@@ -77,7 +77,7 @@ describe('GroupedThrottledQueue', () => {
|
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
it('should remove the group when all items are processed', async () => {
|
|
80
|
-
const handler =
|
|
80
|
+
const handler = vitest.fn().mockResolvedValue(undefined);
|
|
81
81
|
const queue = new GroupedThrottledQueue<number>(handler);
|
|
82
82
|
|
|
83
83
|
queue.addItem('group1', 1);
|
|
@@ -93,7 +93,7 @@ describe('GroupedThrottledQueue', () => {
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
it('should handle multiple items added to the same group', async () => {
|
|
96
|
-
const handler =
|
|
96
|
+
const handler = vitest.fn().mockResolvedValue(undefined);
|
|
97
97
|
const queue = new GroupedThrottledQueue<number>(handler);
|
|
98
98
|
|
|
99
99
|
queue.addItem('group1', 1);
|
|
@@ -107,7 +107,7 @@ describe('GroupedThrottledQueue', () => {
|
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
it('should handle large batch sizes correctly', async () => {
|
|
110
|
-
const handler =
|
|
110
|
+
const handler = vitest.fn().mockResolvedValue(undefined);
|
|
111
111
|
const queue = new GroupedThrottledQueue<number>(handler);
|
|
112
112
|
|
|
113
113
|
// Create a large array of items
|
|
@@ -127,9 +127,9 @@ describe('GroupedThrottledQueue', () => {
|
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
it('should handle errors in handler without failing the queue', async () => {
|
|
130
|
-
const consoleErrorMock =
|
|
130
|
+
const consoleErrorMock = vitest.spyOn(console, 'error');// .mockImplementation();
|
|
131
131
|
|
|
132
|
-
const handler =
|
|
132
|
+
const handler = vitest.fn().mockImplementation((group, items) => {
|
|
133
133
|
if (group === 'error-group') {
|
|
134
134
|
throw new Error('Test error');
|
|
135
135
|
}
|
|
@@ -155,7 +155,7 @@ describe('GroupedThrottledQueue', () => {
|
|
|
155
155
|
it('should handle async handler functions', async () => {
|
|
156
156
|
let processingPromise: Promise<void> | null = null;
|
|
157
157
|
|
|
158
|
-
const handler =
|
|
158
|
+
const handler = vitest.fn().mockImplementation((group, items) => {
|
|
159
159
|
processingPromise = new Promise((resolve) => {
|
|
160
160
|
setTimeout(() => {
|
|
161
161
|
resolve();
|
|
@@ -174,7 +174,7 @@ describe('GroupedThrottledQueue', () => {
|
|
|
174
174
|
expect(queue.queues.size).toBe(1);
|
|
175
175
|
|
|
176
176
|
// Fast-forward time to resolve the processing promise
|
|
177
|
-
|
|
177
|
+
vitest.advanceTimersByTime(100);
|
|
178
178
|
|
|
179
179
|
// Wait for the processing to complete
|
|
180
180
|
await waitPromise;
|
|
@@ -184,7 +184,7 @@ describe('GroupedThrottledQueue', () => {
|
|
|
184
184
|
});
|
|
185
185
|
|
|
186
186
|
it('should not error when flushing non-existing groups', async () => {
|
|
187
|
-
const handler =
|
|
187
|
+
const handler = vitest.fn();
|
|
188
188
|
const queue = new GroupedThrottledQueue<number>(handler);
|
|
189
189
|
|
|
190
190
|
await expect(queue.flushGroupAndWait('non-existing')).resolves.not.toThrow();
|
|
@@ -194,21 +194,21 @@ describe('GroupedThrottledQueue', () => {
|
|
|
194
194
|
});
|
|
195
195
|
|
|
196
196
|
it('should automatically flush after maxDelay', async () => {
|
|
197
|
-
const handler =
|
|
197
|
+
const handler = vitest.fn().mockResolvedValue(undefined);
|
|
198
198
|
const queue = new GroupedThrottledQueue(handler);
|
|
199
199
|
queue.maxDelay = 1000; // Set a max delay for the timeout
|
|
200
200
|
|
|
201
201
|
queue.addItem('group-1', 1);
|
|
202
202
|
expect(queue.timeout).not.toBeNull();
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
vitest.advanceTimersByTime(500);
|
|
205
205
|
|
|
206
206
|
queue.addItem('group-2', 2);
|
|
207
207
|
await queue.wait();
|
|
208
208
|
expect(handler).not.toHaveBeenCalled();
|
|
209
209
|
|
|
210
210
|
// Fast-forward time
|
|
211
|
-
|
|
211
|
+
vitest.advanceTimersByTime(500);
|
|
212
212
|
|
|
213
213
|
await queue.wait();
|
|
214
214
|
expect(handler).toHaveBeenCalledWith('group-1', [1]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
2
|
-
import { SQLSortDefinitions } from '@stamhoofd/sql';
|
|
2
|
+
import type { SQLSortDefinitions } from '@stamhoofd/sql';
|
|
3
3
|
import { getSortFilter, LimitedFilteredRequest } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
5
|
export class LimitedFilteredRequestHelper {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BalanceItem } from '@stamhoofd/models';
|
|
2
|
-
import {
|
|
2
|
+
import type { MemberWithRegistrationsBlob } from '@stamhoofd/structures';
|
|
3
|
+
import { BalanceItemType } from '@stamhoofd/structures';
|
|
3
4
|
|
|
4
5
|
export class MemberCharger {
|
|
5
6
|
static async chargeMany({ chargingOrganizationId, membersToCharge, price, amount, description, dueAt, createdAt }: { chargingOrganizationId: string; membersToCharge: MemberWithRegistrationsBlob[]; price: number; amount?: number; description: string; dueAt: Date | null; createdAt: Date | null }) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { MemberWithUsers } from '@stamhoofd/models';
|
|
2
|
+
import { CachedBalance, Member, MemberResponsibilityRecord, Organization, Platform, User } from '@stamhoofd/models';
|
|
2
3
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
3
4
|
import { SQL } from '@stamhoofd/sql';
|
|
4
|
-
import {
|
|
5
|
+
import type { MemberDetails, PermissionRole } from '@stamhoofd/structures';
|
|
6
|
+
import { AuditLogSource, Permissions, ReceivableBalanceType, UserPermissions } from '@stamhoofd/structures';
|
|
5
7
|
import { Formatter } from '@stamhoofd/utility';
|
|
6
8
|
import basex from 'base-x';
|
|
7
9
|
import crypto from 'crypto';
|
|
@@ -96,7 +98,8 @@ export class MemberUserSyncerStatic {
|
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
|
|
101
|
+
// Generate security code (only for userMode platform)
|
|
102
|
+
if (STAMHOOFD.userMode !== 'organization' && member.details.securityCode === null) {
|
|
100
103
|
console.log('Generating security code for member ' + member.id);
|
|
101
104
|
|
|
102
105
|
const length = 16;
|
|
@@ -17,7 +17,7 @@ export const MembershipCharger = {
|
|
|
17
17
|
throw new SimpleError({
|
|
18
18
|
code: 'missing_membership_organization',
|
|
19
19
|
message: 'Missing membershipOrganizationId',
|
|
20
|
-
human: $t(`
|
|
20
|
+
human: $t(`%Ft`),
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -97,7 +97,7 @@ export const MembershipCharger = {
|
|
|
97
97
|
const balanceItem = new BalanceItem();
|
|
98
98
|
balanceItem.unitPrice = membership.price;
|
|
99
99
|
balanceItem.amount = 1;
|
|
100
|
-
balanceItem.description = Formatter.dateNumber(membership.startDate, true) + ' ' + $t(`
|
|
100
|
+
balanceItem.description = Formatter.dateNumber(membership.startDate, true) + ' ' + $t(`%10C`) + ' ' + Formatter.dateNumber(membership.expireDate ?? membership.endDate, true);
|
|
101
101
|
balanceItem.relations = new Map([
|
|
102
102
|
[
|
|
103
103
|
BalanceItemRelationType.Member,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BalanceItem } from '@stamhoofd/models';
|
|
2
|
-
import {
|
|
2
|
+
import type { Organization as OrganizationStruct } from '@stamhoofd/structures';
|
|
3
|
+
import { BalanceItemType } from '@stamhoofd/structures';
|
|
3
4
|
|
|
4
5
|
export class OrganizationCharger {
|
|
5
6
|
static async chargeMany({ chargingOrganizationId, organizationsToCharge, price, amount, description, dueAt, createdAt }: { chargingOrganizationId: string; organizationsToCharge: OrganizationStruct[]; price: number; amount?: number; description: string; dueAt: Date | null; createdAt: Date | null }) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
2
|
-
import {
|
|
2
|
+
import type { RegistrationPeriod } from '@stamhoofd/models';
|
|
3
|
+
import { Group, Member, MemberResponsibilityRecord, Organization, OrganizationRegistrationPeriod, Platform } from '@stamhoofd/models';
|
|
3
4
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
4
5
|
import { AuditLogSource, Group as GroupStruct, PermissionLevel } from '@stamhoofd/structures';
|
|
5
6
|
import { PatchOrganizationRegistrationPeriodsEndpoint } from '../endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { SQLColumnExpression, SQLExpression, SQLExpressionOptions, SQLQuery
|
|
2
|
-
import {
|
|
1
|
+
import type { SQLColumnExpression, SQLExpression, SQLExpressionOptions, SQLQuery } from '@stamhoofd/sql';
|
|
2
|
+
import { SQLTranslatedStringHelper } from '@stamhoofd/sql';
|
|
3
|
+
import { Language } from '@stamhoofd/types/Language';
|
|
3
4
|
|
|
4
5
|
export class SQLTranslatedString implements SQLExpression {
|
|
5
6
|
private helper: SQLTranslatedStringHelper;
|
|
@@ -11,14 +11,15 @@ import {
|
|
|
11
11
|
} from '@stamhoofd/models';
|
|
12
12
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
13
13
|
import { SQL, SQLWhereSign } from '@stamhoofd/sql';
|
|
14
|
+
import type {
|
|
15
|
+
MemberResponsibility,
|
|
16
|
+
Platform as PlatformStruct,
|
|
17
|
+
SetupSteps} from '@stamhoofd/structures';
|
|
14
18
|
import {
|
|
15
19
|
AuditLogSource,
|
|
16
20
|
GroupType,
|
|
17
|
-
MemberResponsibility,
|
|
18
|
-
Platform as PlatformStruct,
|
|
19
21
|
RecordCategory,
|
|
20
|
-
SetupStepType
|
|
21
|
-
SetupSteps,
|
|
22
|
+
SetupStepType
|
|
22
23
|
} from '@stamhoofd/structures';
|
|
23
24
|
import { Formatter } from '@stamhoofd/utility';
|
|
24
25
|
import { AuditLogService } from '../services/AuditLogService.js';
|
|
@@ -195,7 +196,7 @@ export class SetupStepUpdater {
|
|
|
195
196
|
throw new SimpleError({
|
|
196
197
|
code: 'not_found',
|
|
197
198
|
message: 'Organization not found',
|
|
198
|
-
human: $t(`
|
|
199
|
+
human: $t(`%Fu`),
|
|
199
200
|
});
|
|
200
201
|
}
|
|
201
202
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
2
|
-
import { I18n } from '@stamhoofd/backend-i18n';
|
|
3
|
-
import { BalanceItem, BalanceItemPayment, Organization,
|
|
2
|
+
import type { I18n } from '@stamhoofd/backend-i18n';
|
|
3
|
+
import type { BalanceItem, BalanceItemPayment, Organization, StripeAccount} from '@stamhoofd/models';
|
|
4
|
+
import { Payment, StripeCheckoutSession, StripePaymentIntent } from '@stamhoofd/models';
|
|
4
5
|
import { calculateVATPercentage, PaymentMethod, PaymentMethodHelper, PaymentStatus } from '@stamhoofd/structures';
|
|
5
6
|
import { Formatter } from '@stamhoofd/utility';
|
|
6
7
|
import Stripe from 'stripe';
|
|
@@ -11,7 +12,7 @@ export class StripeHelper {
|
|
|
11
12
|
return new SimpleError({
|
|
12
13
|
code: 'not_configured',
|
|
13
14
|
message: 'Stripe is not yet configured for this platform',
|
|
14
|
-
human: $t('
|
|
15
|
+
human: $t('%Fv'),
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -225,7 +226,7 @@ export class StripeHelper {
|
|
|
225
226
|
if (!stripeAccount) {
|
|
226
227
|
throw new SimpleError({
|
|
227
228
|
code: '',
|
|
228
|
-
message: $t(
|
|
229
|
+
message: $t(`%w3`, { method: PaymentMethodHelper.getName(payment.method) }),
|
|
229
230
|
});
|
|
230
231
|
}
|
|
231
232
|
|
|
@@ -235,7 +236,7 @@ export class StripeHelper {
|
|
|
235
236
|
throw new SimpleError({
|
|
236
237
|
code: 'minimum_amount',
|
|
237
238
|
message: 'The minimum amount for an online payment is € 0,50',
|
|
238
|
-
human: $t(`
|
|
239
|
+
human: $t(`%wl`),
|
|
239
240
|
});
|
|
240
241
|
}
|
|
241
242
|
|
|
@@ -280,7 +281,7 @@ export class StripeHelper {
|
|
|
280
281
|
const paymentMethod = await stripe.paymentMethods.create({
|
|
281
282
|
type: payment.method.toLowerCase() as 'bancontact' | 'ideal',
|
|
282
283
|
billing_details: {
|
|
283
|
-
name: payment.customer?.dynamicName || (customer.name.length > 2 ? customer.name : $t(`
|
|
284
|
+
name: payment.customer?.dynamicName || (customer.name.length > 2 ? customer.name : $t(`%Gr`)),
|
|
284
285
|
email: payment.customer?.dynamicEmail || customer.email,
|
|
285
286
|
address: payment.customer?.company?.address
|
|
286
287
|
? {
|
|
@@ -319,7 +320,7 @@ export class StripeHelper {
|
|
|
319
320
|
console.error('Stripe payment intent status is not requires_action', paymentIntent);
|
|
320
321
|
throw new SimpleError({
|
|
321
322
|
code: 'invalid_status',
|
|
322
|
-
message: $t(`
|
|
323
|
+
message: $t(`%wm`) + ' ' + PaymentMethodHelper.getName(payment.method) + ' ' + $t(`%wn`),
|
|
323
324
|
});
|
|
324
325
|
}
|
|
325
326
|
|
|
@@ -387,7 +388,7 @@ export class StripeHelper {
|
|
|
387
388
|
console.error('Stripe session has no url', session);
|
|
388
389
|
throw new SimpleError({
|
|
389
390
|
code: 'invalid_status',
|
|
390
|
-
message: $t(`
|
|
391
|
+
message: $t(`%wm`) + ' ' + PaymentMethodHelper.getName(payment.method) + ' ' + $t(`%wn`),
|
|
391
392
|
});
|
|
392
393
|
}
|
|
393
394
|
paymentUrl = session.url;
|
|
@@ -292,8 +292,8 @@ describe('TagHelper', () => {
|
|
|
292
292
|
const result2 = TagHelper.validateTags(validPlatformTags);
|
|
293
293
|
|
|
294
294
|
// assert
|
|
295
|
-
expect(result1).
|
|
296
|
-
expect(result2).
|
|
295
|
+
expect(result1).toBe(false);
|
|
296
|
+
expect(result2).toBe(true);
|
|
297
297
|
});
|
|
298
298
|
|
|
299
299
|
it('should return false if a tag is a child tag of multiple tags', () => {
|
|
@@ -339,8 +339,8 @@ describe('TagHelper', () => {
|
|
|
339
339
|
const result2 = TagHelper.validateTags(validPlatformTags);
|
|
340
340
|
|
|
341
341
|
// assert
|
|
342
|
-
expect(result1).
|
|
343
|
-
expect(result2).
|
|
342
|
+
expect(result1).toBe(false);
|
|
343
|
+
expect(result2).toBe(true);
|
|
344
344
|
});
|
|
345
345
|
|
|
346
346
|
it('should return false if the child tags contain an infinite loop', () => {
|
|
@@ -367,7 +367,7 @@ describe('TagHelper', () => {
|
|
|
367
367
|
const result = TagHelper.validateTags(platformTagsWithInfiniteLoop);
|
|
368
368
|
|
|
369
369
|
// assert
|
|
370
|
-
expect(result).
|
|
370
|
+
expect(result).toBe(false);
|
|
371
371
|
});
|
|
372
372
|
});
|
|
373
373
|
});
|
package/src/helpers/TagHelper.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Organization, Platform } from '@stamhoofd/models';
|
|
2
2
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
3
|
-
import {
|
|
3
|
+
import type { OrganizationTag} from '@stamhoofd/structures';
|
|
4
|
+
import { AuditLogSource, TagHelper as SharedTagHelper } from '@stamhoofd/structures';
|
|
4
5
|
import { AuditLogService } from '../services/AuditLogService.js';
|
|
5
6
|
|
|
6
7
|
export class TagHelper extends SharedTagHelper {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PermissionLevel } from '@stamhoofd/structures';
|
|
2
|
+
import { getPermissionLevelNumber } from '@stamhoofd/structures';
|
|
2
3
|
|
|
3
4
|
const userMemberTemporaryAccessCache = new Map<string, { memberId: string; level: PermissionLevel; validUntil: Date }[]>();
|
|
4
5
|
|
|
@@ -3,19 +3,19 @@ import { ThrottledQueue } from './ThrottledQueue.js';
|
|
|
3
3
|
describe('ThrottledQueue', () => {
|
|
4
4
|
// Mock timers for controlling setTimeout
|
|
5
5
|
beforeEach(() => {
|
|
6
|
-
|
|
6
|
+
vitest.useFakeTimers();
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
afterEach(() => {
|
|
10
|
-
|
|
10
|
+
vitest.useRealTimers();
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
afterAll(() => {
|
|
14
|
-
|
|
14
|
+
vitest.clearAllMocks();
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
it('should create an instance with the provided handler', () => {
|
|
18
|
-
const handler =
|
|
18
|
+
const handler = vitest.fn();
|
|
19
19
|
const queue = new ThrottledQueue(handler);
|
|
20
20
|
|
|
21
21
|
expect(queue.handler).toBe(handler);
|
|
@@ -24,7 +24,7 @@ describe('ThrottledQueue', () => {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
it('should add items to the queue', () => {
|
|
27
|
-
const handler =
|
|
27
|
+
const handler = vitest.fn();
|
|
28
28
|
const queue = new ThrottledQueue(handler);
|
|
29
29
|
|
|
30
30
|
queue.addItem(1);
|
|
@@ -33,7 +33,7 @@ describe('ThrottledQueue', () => {
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
it('should add multiple items to the queue', () => {
|
|
36
|
-
const handler =
|
|
36
|
+
const handler = vitest.fn();
|
|
37
37
|
const queue = new ThrottledQueue(handler);
|
|
38
38
|
|
|
39
39
|
queue.addItems([1, 2, 3]);
|
|
@@ -44,12 +44,12 @@ describe('ThrottledQueue', () => {
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
it('should flush automatically when reaching maxBatchSize', async () => {
|
|
47
|
-
const handler =
|
|
47
|
+
const handler = vitest.fn().mockResolvedValue(undefined);
|
|
48
48
|
const queue = new ThrottledQueue(handler);
|
|
49
49
|
queue.maxBatchSize = 3;
|
|
50
50
|
|
|
51
51
|
// Spy on flushAll to check if it's called
|
|
52
|
-
const flushAllSpy =
|
|
52
|
+
const flushAllSpy = vitest.spyOn(queue, 'flushAll');
|
|
53
53
|
|
|
54
54
|
queue.addItems([1, 2]);
|
|
55
55
|
expect(flushAllSpy).not.toHaveBeenCalled();
|
|
@@ -65,7 +65,7 @@ describe('ThrottledQueue', () => {
|
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
it('should process items in batches when exceeding maxBatchSize', async () => {
|
|
68
|
-
const handler =
|
|
68
|
+
const handler = vitest.fn().mockResolvedValue(undefined);
|
|
69
69
|
const queue = new ThrottledQueue(handler);
|
|
70
70
|
queue.maxBatchSize = 3;
|
|
71
71
|
|
|
@@ -88,9 +88,9 @@ describe('ThrottledQueue', () => {
|
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
it('should call emptyHandler when queue becomes empty', async () => {
|
|
91
|
-
const handler =
|
|
91
|
+
const handler = vitest.fn().mockResolvedValue(undefined);
|
|
92
92
|
const queue = new ThrottledQueue(handler);
|
|
93
|
-
const emptyHandler =
|
|
93
|
+
const emptyHandler = vitest.fn();
|
|
94
94
|
queue.emptyHandler = emptyHandler;
|
|
95
95
|
|
|
96
96
|
queue.maxBatchSize = 3;
|
|
@@ -101,9 +101,9 @@ describe('ThrottledQueue', () => {
|
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
it('should not call emptyHandler when queue is filled during processing', async () => {
|
|
104
|
-
const handler =
|
|
104
|
+
const handler = vitest.fn().mockResolvedValue(undefined);
|
|
105
105
|
const queue = new ThrottledQueue(handler);
|
|
106
|
-
const emptyHandler =
|
|
106
|
+
const emptyHandler = vitest.fn();
|
|
107
107
|
queue.emptyHandler = emptyHandler;
|
|
108
108
|
|
|
109
109
|
queue.maxBatchSize = 3;
|
|
@@ -120,11 +120,11 @@ describe('ThrottledQueue', () => {
|
|
|
120
120
|
|
|
121
121
|
it('should not fail if handler throws an error', async () => {
|
|
122
122
|
const error = new Error('Test error');
|
|
123
|
-
const handler =
|
|
123
|
+
const handler = vitest.fn().mockRejectedValue(error);
|
|
124
124
|
const queue = new ThrottledQueue(handler);
|
|
125
125
|
|
|
126
126
|
// Spy on console.error
|
|
127
|
-
const consoleErrorSpy =
|
|
127
|
+
const consoleErrorSpy = vitest.spyOn(console, 'error').mockImplementation(() => {});
|
|
128
128
|
|
|
129
129
|
queue.addItem(1);
|
|
130
130
|
await queue.flushAndWait();
|
|
@@ -137,7 +137,7 @@ describe('ThrottledQueue', () => {
|
|
|
137
137
|
});
|
|
138
138
|
|
|
139
139
|
it('should handle flushAndWait when queue is empty', async () => {
|
|
140
|
-
const handler =
|
|
140
|
+
const handler = vitest.fn();
|
|
141
141
|
const queue = new ThrottledQueue(handler);
|
|
142
142
|
|
|
143
143
|
await queue.flushAndWait();
|
|
@@ -160,7 +160,7 @@ describe('ThrottledQueue', () => {
|
|
|
160
160
|
});
|
|
161
161
|
|
|
162
162
|
it('should handle startTimeout and stopTimeout correctly', async () => {
|
|
163
|
-
const handler =
|
|
163
|
+
const handler = vitest.fn();
|
|
164
164
|
const queue = new ThrottledQueue(handler);
|
|
165
165
|
queue.maxDelay = 1000; // Set a max delay for the timeout
|
|
166
166
|
|
|
@@ -172,19 +172,19 @@ describe('ThrottledQueue', () => {
|
|
|
172
172
|
});
|
|
173
173
|
|
|
174
174
|
it('should automatically flush after maxDelay', async () => {
|
|
175
|
-
const handler =
|
|
175
|
+
const handler = vitest.fn().mockResolvedValue(undefined);
|
|
176
176
|
const queue = new ThrottledQueue(handler);
|
|
177
177
|
queue.maxDelay = 1000; // Set a max delay for the timeout
|
|
178
178
|
|
|
179
179
|
queue.addItem(1);
|
|
180
180
|
expect(queue.timeout).not.toBeNull();
|
|
181
181
|
|
|
182
|
-
|
|
182
|
+
vitest.advanceTimersByTime(500);
|
|
183
183
|
await queue.wait();
|
|
184
184
|
expect(handler).not.toHaveBeenCalled();
|
|
185
185
|
|
|
186
186
|
// Fast-forward time
|
|
187
|
-
|
|
187
|
+
vitest.advanceTimersByTime(500);
|
|
188
188
|
|
|
189
189
|
await queue.wait();
|
|
190
190
|
expect(handler).toHaveBeenCalledWith([1]);
|