@stamhoofd/backend 2.119.0 → 2.120.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +32 -22
- package/src/audit-logs/ModelLogger.ts +4 -2
- package/src/boot.ts +40 -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 +2 -1
- package/src/endpoints/admin/members/ChargeMembersEndpoint.ts +3 -2
- package/src/endpoints/admin/memberships/ChargeMembershipsEndpoint.ts +2 -1
- package/src/endpoints/admin/memberships/GetChargeMembershipsSummaryEndpoint.ts +2 -1
- package/src/endpoints/admin/organizations/ChargeOrganizationsEndpoint.ts +3 -2
- package/src/endpoints/admin/organizations/GetOrganizationsCountEndpoint.ts +3 -2
- package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +6 -4
- package/src/endpoints/admin/organizations/PatchOrganizationsEndpoint.ts +4 -2
- package/src/endpoints/admin/registrations/ChargeRegistrationsEndpoint.ts +3 -2
- package/src/endpoints/auth/CreateAdminEndpoint.ts +5 -3
- package/src/endpoints/auth/CreateTokenEndpoint.ts +4 -2
- package/src/endpoints/auth/DeleteTokenEndpoint.ts +2 -1
- package/src/endpoints/auth/DeleteUserEndpoint.ts +2 -1
- package/src/endpoints/auth/ForgotPasswordEndpoint.ts +3 -2
- 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 +6 -3
- package/src/endpoints/auth/PollEmailVerificationEndpoint.ts +3 -2
- package/src/endpoints/auth/RetryEmailVerificationEndpoint.ts +3 -2
- package/src/endpoints/auth/SignupEndpoint.ts +3 -2
- package/src/endpoints/auth/VerifyEmailEndpoint.ts +3 -2
- 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 +7 -4
- package/src/endpoints/global/billing/ActivatePackagesEndpoint.ts +6 -4
- package/src/endpoints/global/billing/DeactivatePackageEndpoint.ts +2 -1
- package/src/endpoints/global/caddy/CheckDomainCertEndpoint.ts +4 -2
- package/src/endpoints/global/email/CreateEmailEndpoint.ts +5 -3
- 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 +4 -2
- package/src/endpoints/global/email/GetEmailEndpoint.ts +3 -2
- package/src/endpoints/global/email/GetUserEmailsEndpoint.test.ts +2 -1
- package/src/endpoints/global/email/GetUserEmailsEndpoint.ts +7 -4
- package/src/endpoints/global/email/ManageEmailAddressEndpoint.ts +4 -2
- package/src/endpoints/global/email/PatchEmailEndpoint.test.ts +11 -11
- package/src/endpoints/global/email/PatchEmailEndpoint.ts +6 -3
- 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 +7 -4
- package/src/endpoints/global/email-recipients/RetryEmailRecipientEndpoint.ts +4 -2
- package/src/endpoints/global/email-recipients/helpers/validateEmailRecipientFilter.ts +2 -1
- package/src/endpoints/global/events/GetEventNotificationsCountEndpoint.ts +3 -2
- package/src/endpoints/global/events/GetEventNotificationsEndpoint.ts +8 -5
- 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 +4 -2
- package/src/endpoints/global/events/PatchEventsEndpoint.test.ts +4 -2
- package/src/endpoints/global/events/PatchEventsEndpoint.ts +4 -2
- package/src/endpoints/global/files/ExportToExcelEndpoint.ts +7 -4
- package/src/endpoints/global/files/GetFileCache.ts +5 -3
- package/src/endpoints/global/files/UploadFile.ts +9 -3
- 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 +7 -4
- package/src/endpoints/global/members/GetMemberFamilyEndpoint.ts +5 -3
- 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 +8 -6
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.test.ts +257 -6
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +114 -59
- package/src/endpoints/global/members/helpers/validateGroupFilter.ts +2 -1
- package/src/endpoints/global/members/shouldCheckIfMemberIsDuplicate.ts +3 -2
- package/src/endpoints/global/organizations/CheckRegisterCodeEndpoint.ts +2 -1
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.test.ts +3 -2
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.ts +3 -2
- 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 +6 -3
- package/src/endpoints/global/platform-memberships/GetPlatformMembershipsCountEndpoint.ts +47 -0
- package/src/endpoints/global/platform-memberships/GetPlatformMembershipsEndpoint.ts +211 -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 +8 -5
- 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 +9 -5
- package/src/endpoints/global/registration/RegisterMembersEndpoint.test.ts +50 -49
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +7 -4
- package/src/endpoints/global/registration-periods/GetRegistrationPeriodsEndpoint.ts +7 -4
- package/src/endpoints/global/registration-periods/PatchRegistrationPeriodsEndpoint.ts +4 -2
- 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 +3 -2
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/balance-items/PatchBalanceItemsEndpoint.ts +4 -2
- 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 +2 -1
- 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 +4 -2
- package/src/endpoints/organization/dashboard/documents/PatchDocumentTemplatesEndpoint.test.ts +4 -2
- package/src/endpoints/organization/dashboard/documents/PatchDocumentTemplatesEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/email/CheckEmailBouncesEndpoint.ts +2 -1
- 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 +4 -2
- package/src/endpoints/organization/dashboard/invoices/GetInvoicesCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/invoices/GetInvoicesEndpoint.ts +5 -3
- 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 +6 -3
- 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 +3 -2
- 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 +6 -4
- package/src/endpoints/organization/dashboard/payments/PatchPaymentsEndpoint.ts +5 -3
- 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 +7 -4
- 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 +6 -3
- 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 +2 -1
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountLinkEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountsEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/stripe/GetStripeLoginLinkEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/stripe/UpdateStripeAccountEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/users/CreateApiUserEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/users/DeleteUserEndpoint.ts +2 -1
- 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 +4 -2
- package/src/endpoints/organization/dashboard/webshops/CreateWebshopEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/webshops/DeleteWebshopEndpoint.ts +2 -1
- 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 +4 -2
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopEndpoint.ts +4 -3
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopTicketsEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/webshops/SearchUitpasEventsEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/webshops/VerifyWebshopDomainEndpoint.ts +2 -1
- package/src/endpoints/organization/shared/ExchangePaymentEndpoint.ts +5 -3
- package/src/endpoints/organization/shared/GetDocumentHtml.ts +2 -1
- package/src/endpoints/organization/shared/GetPaymentEndpoint.ts +3 -2
- 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 +3 -2
- package/src/endpoints/organization/webshops/GetOrderByPaymentEndpoint.ts +3 -2
- package/src/endpoints/organization/webshops/GetOrderEndpoint.ts +3 -2
- package/src/endpoints/organization/webshops/GetTicketsEndpoint.ts +4 -2
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.ts +3 -2
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.test.ts +7 -3
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.ts +3 -2
- package/src/endpoints/organization/webshops/RetrieveUitpasSocialTariffPriceEndpoint.ts +3 -2
- package/src/endpoints/system/HealthEndpoint.test.ts +44 -0
- package/src/endpoints/system/HealthEndpoint.ts +14 -6
- package/src/excel-loaders/balance-items.ts +4 -2
- package/src/excel-loaders/event-notifications.ts +7 -5
- package/src/excel-loaders/index.ts +1 -0
- package/src/excel-loaders/members.ts +6 -4
- package/src/excel-loaders/organizations.ts +8 -7
- package/src/excel-loaders/payments.ts +5 -3
- package/src/excel-loaders/platform-memberships.ts +262 -0
- package/src/excel-loaders/receivable-balances.ts +7 -5
- package/src/excel-loaders/registrations.ts +9 -7
- package/src/helpers/AddressValidator.test.ts +2 -1
- package/src/helpers/AddressValidator.ts +7 -4
- package/src/helpers/AdminPermissionChecker.ts +190 -92
- package/src/helpers/AuthenticatedStructures.ts +4 -2
- package/src/helpers/BuckarooHelper.ts +2 -1
- package/src/helpers/Context.ts +4 -2
- package/src/helpers/CookieHelper.ts +2 -2
- package/src/helpers/FileCache.ts +2 -2
- package/src/helpers/ForwardHandler.ts +2 -1
- 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/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 +5 -4
- package/src/helpers/StripeHelper.ts +3 -2
- 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/ViesHelper.ts +4 -3
- package/src/helpers/XlsxTransformerColumnHelper.ts +4 -2
- package/src/helpers/email-html-helpers.ts +5 -4
- package/src/helpers/fetchToAsyncIterator.ts +1 -1
- package/src/helpers/outstandingBalanceJoin.ts +2 -1
- package/src/helpers/updateMemberDetailsUitpasNumber.ts +4 -3
- 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 +2 -1
- package/src/seeds/1754560914-groups-prices.test.ts +2 -1
- package/src/seeds/1754560914-groups-prices.ts +2 -1
- 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 +2 -1
- package/src/services/FileSignService.ts +1 -1
- package/src/services/MemberNumberService.ts +3 -1
- 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 +5 -3
- package/src/services/RegistrationService.ts +65 -3
- package/src/services/SSOService.ts +8 -4
- package/src/services/STPackageService.ts +5 -3
- package/src/services/StartupHealthService.ts +15 -0
- package/src/services/uitpas/UitpasService.ts +6 -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 +4 -2
- 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 +2 -1
- package/src/sql-filters/orders.ts +2 -1
- 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 +72 -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
|
@@ -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;
|
|
@@ -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';
|
|
@@ -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';
|
|
@@ -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]);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { AutoEncoderPatchType } from '@simonbackx/simple-encoding';
|
|
1
|
+
import type { AutoEncoderPatchType } from '@simonbackx/simple-encoding';
|
|
2
2
|
import { isSimpleError, isSimpleErrors, SimpleError } from '@simonbackx/simple-errors';
|
|
3
|
-
import { Company
|
|
3
|
+
import type { Company } from '@stamhoofd/structures';
|
|
4
|
+
import { Country } from '@stamhoofd/types/Country';
|
|
4
5
|
import axios from 'axios';
|
|
5
6
|
import * as jsvat from 'jsvat-next'; // has no default export, so we need the wildcard
|
|
6
7
|
|
|
@@ -135,7 +136,7 @@ export class ViesHelperStatic {
|
|
|
135
136
|
const formatted = result.value ?? vatNumber;
|
|
136
137
|
|
|
137
138
|
try {
|
|
138
|
-
const cleaned = formatted.substring(2).replace(/(
|
|
139
|
+
const cleaned = formatted.substring(2).replace(/(?:\.-\s)+/g, '');
|
|
139
140
|
const response = await this.request('POST', 'https://ec.europa.eu/taxation_customs/vies/rest-api/check-vat-number', {
|
|
140
141
|
countryCode: country,
|
|
141
142
|
vatNumber: cleaned,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { XlsxTransformerColumn, XlsxTransformerConcreteColumn } from '@stamhoofd/excel-writer';
|
|
2
|
+
import { isXlsxTransformerConcreteColumn } from '@stamhoofd/excel-writer';
|
|
3
|
+
import type { Address, Parent, PlatformMember, RecordAnswer, RecordSettings} from '@stamhoofd/structures';
|
|
4
|
+
import { CountryHelper, ParentTypeHelper, RecordCategory, RecordType } from '@stamhoofd/structures';
|
|
3
5
|
|
|
4
6
|
export class XlsxTransformerColumnHelper {
|
|
5
7
|
static formatBoolean(value: boolean | undefined | null): string {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Order, Webshop } from '@stamhoofd/models';
|
|
2
|
-
import {
|
|
1
|
+
import type { Order, Webshop } from '@stamhoofd/models';
|
|
2
|
+
import type { WebshopTakeoutMethod } from '@stamhoofd/structures';
|
|
3
|
+
import { CheckoutMethodType, PaymentGeneral, PaymentMethod, PaymentMethodHelper, RecordCategory, RecordCheckboxAnswer } from '@stamhoofd/structures';
|
|
3
4
|
import { Formatter } from '@stamhoofd/utility';
|
|
4
5
|
|
|
5
6
|
export function createOrderDataHTMLTable(order: Order, webshop: Webshop): string {
|
|
@@ -17,7 +18,7 @@ export function createOrderDataHTMLTable(order: Order, webshop: Webshop): string
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
if (order.data.checkoutMethod?.type === CheckoutMethodType.OnSite) {
|
|
20
|
-
return $t(`%
|
|
21
|
+
return $t(`%8a`);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
return $t(`%Us`);
|
|
@@ -55,7 +56,7 @@ export function createOrderDataHTMLTable(order: Order, webshop: Webshop): string
|
|
|
55
56
|
value: order.data.timeSlot?.timeRangeString() ?? '',
|
|
56
57
|
},
|
|
57
58
|
{
|
|
58
|
-
title: $t(`%
|
|
59
|
+
title: $t(`%1Os`),
|
|
59
60
|
value: order.data.customer.name,
|
|
60
61
|
},
|
|
61
62
|
...(order.data.customer.phone
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPaginatedResponse, LimitedFilteredRequest } from '@stamhoofd/structures';
|
|
1
|
+
import type { IPaginatedResponse, LimitedFilteredRequest } from '@stamhoofd/structures';
|
|
2
2
|
import { FileSignService } from '../services/FileSignService.js';
|
|
3
3
|
|
|
4
4
|
export function fetchToAsyncIterator<T>(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CachedBalance, Registration } from '@stamhoofd/models';
|
|
2
|
-
import {
|
|
2
|
+
import type { SQLNamedExpression} from '@stamhoofd/sql';
|
|
3
|
+
import { SQL, SQLAlias, SQLCalculation, SQLPlusSign, SQLSelectAs, SQLSum } from '@stamhoofd/sql';
|
|
3
4
|
|
|
4
5
|
export const memberCachedBalanceForOrganizationJoin = SQL.leftJoin(
|
|
5
6
|
SQL.select('objectId', 'organizationId',
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { AutoEncoderPatchType } from '@simonbackx/simple-encoding';
|
|
1
|
+
import type { AutoEncoderPatchType } from '@simonbackx/simple-encoding';
|
|
2
2
|
import { isSimpleError, SimpleError } from '@simonbackx/simple-errors';
|
|
3
3
|
import { Member } from '@stamhoofd/models';
|
|
4
|
-
import { MemberDetails, ReviewTimes
|
|
5
|
-
import {
|
|
4
|
+
import type { MemberDetails, ReviewTimes} from '@stamhoofd/structures';
|
|
5
|
+
import { UitpasSocialTariff, UitpasSocialTariffStatus } from '@stamhoofd/structures';
|
|
6
|
+
import type { GetPassResponse } from '../services/uitpas/PassholderEndpoints.js';
|
|
6
7
|
import { UitpasService } from '../services/uitpas/UitpasService.js';
|
|
7
8
|
import { throwIfInvalidUitpasNumber } from '../services/uitpas/checkUitpasNumbers.js';
|
|
8
9
|
|
package/src/migrate.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
|
|
3
|
-
import { Column, DatabaseInstance, Migration } from '@simonbackx/simple-database';
|
|
3
|
+
import { Column, Database, DatabaseInstance, Migration } from '@simonbackx/simple-database';
|
|
4
4
|
import { Version } from '@stamhoofd/structures';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
|
|
7
7
|
Column.setJSONVersion(Version);
|
|
8
8
|
process.env.TZ = 'UTC';
|
|
9
9
|
|
|
10
|
+
// Polyfill require.resolve, since import.meta.resolve is not supported by vitest
|
|
11
|
+
import { createRequire } from 'node:module';
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
|
|
10
14
|
const emailPath = require.resolve('@stamhoofd/email');
|
|
11
15
|
const modelsPath = require.resolve('@stamhoofd/models');
|
|
12
16
|
|
|
@@ -20,6 +24,10 @@ const start = async () => {
|
|
|
20
24
|
throw new Error('STAMHOOFD.DB_DATABASE is not set');
|
|
21
25
|
}
|
|
22
26
|
|
|
27
|
+
// Reload database so we are sure we are running on the correct database in the
|
|
28
|
+
// environment
|
|
29
|
+
await Database.reload({})
|
|
30
|
+
|
|
23
31
|
let killSignalReceived = false;
|
|
24
32
|
const handler = () => {
|
|
25
33
|
// Ignore
|
|
@@ -41,17 +49,26 @@ const start = async () => {
|
|
|
41
49
|
await globalDatabase.statement(query);
|
|
42
50
|
|
|
43
51
|
// External migrations
|
|
44
|
-
await Migration.runAll(path.dirname(modelsPath) + '/migrations')
|
|
45
|
-
|
|
52
|
+
if (!await Migration.runAll(path.dirname(modelsPath) + '/migrations')) {
|
|
53
|
+
throw new Error('Migrations failed')
|
|
54
|
+
}
|
|
55
|
+
if (!await Migration.runAll(path.dirname(emailPath) + '/../migrations')) {
|
|
56
|
+
throw new Error('Email migrations failed')
|
|
57
|
+
}
|
|
46
58
|
|
|
47
59
|
// Internal
|
|
48
|
-
await Migration.runAll(
|
|
60
|
+
if (!await Migration.runAll(import.meta.dirname + '/migrations')) {
|
|
61
|
+
throw new Error('Internal migrations failed')
|
|
62
|
+
}
|
|
49
63
|
|
|
50
64
|
if (killSignalReceived) {
|
|
51
65
|
console.error(chalk.red('Killing process due to received signal during migration'));
|
|
52
66
|
process.exit(1);
|
|
53
67
|
}
|
|
54
68
|
|
|
69
|
+
// Reload database to prevent connection state leakage
|
|
70
|
+
await Database.reload({})
|
|
71
|
+
|
|
55
72
|
process.off('SIGTERM', handler);
|
|
56
73
|
process.off('SIGINT', handler);
|
|
57
74
|
};
|
|
@@ -12,7 +12,7 @@ export default new Migration(async () => {
|
|
|
12
12
|
|
|
13
13
|
// Insert defaults
|
|
14
14
|
console.log('Inserting default email templates');
|
|
15
|
-
const sqlStatement = await fs.readFile(
|
|
15
|
+
const sqlStatement = await fs.readFile(import.meta.dirname + '/data/default-email-templates.sql', { encoding: 'utf-8' });
|
|
16
16
|
await Database.statement(sqlStatement);
|
|
17
17
|
|
|
18
18
|
// Do something here
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Migration } from '@simonbackx/simple-database';
|
|
2
2
|
import { Organization, RegistrationPeriod } from '@stamhoofd/models';
|
|
3
|
-
import { Address
|
|
3
|
+
import { Address } from '@stamhoofd/structures';
|
|
4
|
+
import { Country } from '@stamhoofd/types/Country';
|
|
4
5
|
import { Formatter } from '@stamhoofd/utility';
|
|
5
6
|
|
|
6
7
|
export default new Migration(async () => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Migration } from '@simonbackx/simple-database';
|
|
2
2
|
import { Group, Organization, OrganizationRegistrationPeriod, Registration, RegistrationPeriod } from '@stamhoofd/models';
|
|
3
|
-
import { CycleInformation
|
|
3
|
+
import type { CycleInformation} from '@stamhoofd/structures';
|
|
4
|
+
import { GroupCategory, GroupCategorySettings, GroupPrivateSettings, GroupSettings, GroupStatus, GroupType, RegistrationPeriodSettings, TranslatedString } from '@stamhoofd/structures';
|
|
4
5
|
|
|
5
6
|
export default new Migration(async () => {
|
|
6
7
|
if (STAMHOOFD.environment === 'test') {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Organization, RegistrationPeriod} from '@stamhoofd/models';
|
|
2
|
+
import { Group, GroupFactory, OrganizationFactory, OrganizationRegistrationPeriod, OrganizationRegistrationPeriodFactory, RegistrationPeriodFactory } from '@stamhoofd/models';
|
|
2
3
|
import { GroupCategory, GroupCategorySettings, GroupPriceDiscountType, GroupStatus, OldGroupPrice, OldGroupPrices, TranslatedString } from '@stamhoofd/structures';
|
|
3
4
|
import { migratePrices } from './1754560914-groups-prices.js';
|
|
4
5
|
|