@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
package/package.json
CHANGED
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/backend",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.120.1",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "./dist/index.js",
|
|
5
6
|
"exports": {
|
|
6
7
|
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js",
|
|
7
10
|
"require": "./dist/index.js"
|
|
8
11
|
},
|
|
9
|
-
"./
|
|
12
|
+
"./migrate": {
|
|
13
|
+
"types": "./dist/src/migrate.d.ts",
|
|
14
|
+
"import": "./dist/src/migrate.js",
|
|
10
15
|
"require": "./dist/src/migrate.js"
|
|
11
16
|
},
|
|
12
|
-
"./
|
|
17
|
+
"./boot": {
|
|
18
|
+
"types": "./dist/src/boot.d.ts",
|
|
19
|
+
"import": "./dist/src/boot.js",
|
|
13
20
|
"require": "./dist/src/boot.js"
|
|
14
21
|
},
|
|
15
22
|
"./tests/helpers": {
|
|
23
|
+
"@stamhoofd/source": "./tests/helpers/index.ts",
|
|
24
|
+
"types": "./dist/tests/helpers/index.d.ts",
|
|
25
|
+
"import": "./dist/tests/helpers/index.js",
|
|
16
26
|
"require": "./dist/tests/helpers/index.js"
|
|
17
27
|
}
|
|
18
28
|
},
|
|
19
29
|
"license": "UNLICENCED",
|
|
20
30
|
"scripts": {
|
|
21
31
|
"dev": "wait-on ../../shared/middleware/dist/index.js && concurrently -r 'yarn -s build --watch --preserveWatchOutput' \"yarn -s dev:watch\"",
|
|
32
|
+
"dev:build": "yarn -s build",
|
|
22
33
|
"dev:full": "yarn -s dev",
|
|
23
34
|
"dev:watch": "wait-on ./dist/index.js && nodemon --quiet --inspect=5858 --watch dist --watch '../../../shared/*/dist/' --watch '../../shared/*/dist/' --ext .ts,.json,.sql,.js --delay 2000ms --exec 'node --enable-source-maps ./dist/index.js' --signal SIGTERM",
|
|
24
35
|
"dev:backend": "yarn -s dev",
|
|
25
|
-
"build": "
|
|
26
|
-
"copy-assets": "rsync --delete --mkpath --exclude='*.ts' --exclude='*.js' -r --checksum ./src/ ./dist/src/",
|
|
36
|
+
"build": "tsc --build tsconfig.build.json --clean && yarn -s copy-assets && tsc --build tsconfig.build.json",
|
|
37
|
+
"copy-assets": "rsync --delete --mkpath --exclude='*.ts' --exclude='*.js' --exclude='*.map' -r --checksum ./src/ ./dist/src/",
|
|
27
38
|
"build:full": "yarn -s clear && yarn -s build",
|
|
28
|
-
"clear": "rm -rf ./dist",
|
|
39
|
+
"clear": "rm -rf ./dist && rm -f *.tsbuildinfo",
|
|
29
40
|
"start": "yarn -s build && node --enable-source-maps ./dist/index.js",
|
|
30
|
-
"test": "
|
|
31
|
-
"test:
|
|
32
|
-
"test:reset": "yarn -s build:full && jest --runInBand",
|
|
41
|
+
"test": "vitest",
|
|
42
|
+
"test:reset": "yarn -s build:full && yarn -s test",
|
|
33
43
|
"migrations": "yarn -s build:full && node ./dist/migrations.js",
|
|
34
44
|
"lint": "eslint"
|
|
35
45
|
},
|
|
@@ -51,18 +61,18 @@
|
|
|
51
61
|
"@aws-sdk/s3-request-presigner": "^3.839.0",
|
|
52
62
|
"@bwip-js/node": "^4.5.1",
|
|
53
63
|
"@mollie/api-client": "4.3.3",
|
|
54
|
-
"@simonbackx/simple-database": "1.
|
|
55
|
-
"@simonbackx/simple-encoding": "2.
|
|
56
|
-
"@simonbackx/simple-endpoints": "1.
|
|
64
|
+
"@simonbackx/simple-database": "1.36.12",
|
|
65
|
+
"@simonbackx/simple-encoding": "2.26.5",
|
|
66
|
+
"@simonbackx/simple-endpoints": "1.21.0",
|
|
57
67
|
"@simonbackx/simple-logging": "^1.0.1",
|
|
58
|
-
"@stamhoofd/backend-i18n": "2.
|
|
59
|
-
"@stamhoofd/backend-middleware": "2.
|
|
60
|
-
"@stamhoofd/email": "2.
|
|
61
|
-
"@stamhoofd/models": "2.
|
|
62
|
-
"@stamhoofd/queues": "2.
|
|
63
|
-
"@stamhoofd/sql": "2.
|
|
64
|
-
"@stamhoofd/structures": "2.
|
|
65
|
-
"@stamhoofd/utility": "2.
|
|
68
|
+
"@stamhoofd/backend-i18n": "2.120.1",
|
|
69
|
+
"@stamhoofd/backend-middleware": "2.120.1",
|
|
70
|
+
"@stamhoofd/email": "2.120.1",
|
|
71
|
+
"@stamhoofd/models": "2.120.1",
|
|
72
|
+
"@stamhoofd/queues": "2.120.1",
|
|
73
|
+
"@stamhoofd/sql": "2.120.1",
|
|
74
|
+
"@stamhoofd/structures": "2.120.1",
|
|
75
|
+
"@stamhoofd/utility": "2.120.1",
|
|
66
76
|
"archiver": "^7.0.1",
|
|
67
77
|
"axios": "^1.13.2",
|
|
68
78
|
"cookie": "^0.7.0",
|
|
@@ -72,7 +82,7 @@
|
|
|
72
82
|
"luxon": "3.4.4",
|
|
73
83
|
"mailparser": "^3.9.1",
|
|
74
84
|
"mockdate": "^3.0.2",
|
|
75
|
-
"mysql2": "^3.
|
|
85
|
+
"mysql2": "^3.20.0",
|
|
76
86
|
"node-rsa": "1.1.1",
|
|
77
87
|
"openid-client": "^5.4.0",
|
|
78
88
|
"stripe": "^16.6.0"
|
|
@@ -80,5 +90,5 @@
|
|
|
80
90
|
"publishConfig": {
|
|
81
91
|
"access": "public"
|
|
82
92
|
},
|
|
83
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "00f65fc28d68feb86c30789784181a8954d638d7"
|
|
84
94
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ModelEvent } from '@simonbackx/simple-database';
|
|
2
|
+
import { Model } from '@simonbackx/simple-database';
|
|
2
3
|
import { AuditLog } from '@stamhoofd/models';
|
|
3
4
|
import { ObjectDiffer } from '@stamhoofd/object-differ';
|
|
4
|
-
import {
|
|
5
|
+
import type { AuditLogType } from '@stamhoofd/structures';
|
|
6
|
+
import { AuditLogPatchItem, AuditLogPatchItemType, AuditLogReplacement, AuditLogSource } from '@stamhoofd/structures';
|
|
5
7
|
import { ContextInstance } from '../helpers/Context.js';
|
|
6
8
|
import { AuditLogService } from '../services/AuditLogService.js';
|
|
7
9
|
|
package/src/boot.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Email } from '@stamhoofd/email';
|
|
|
5
5
|
import { loadLogger } from '@stamhoofd/logging';
|
|
6
6
|
import { Version } from '@stamhoofd/structures';
|
|
7
7
|
import { sleep } from '@stamhoofd/utility';
|
|
8
|
+
import { checkReadOnly } from '@stamhoofd/crons';
|
|
8
9
|
|
|
9
10
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
10
11
|
import { startCrons, stopCrons, waitForCrons } from '@stamhoofd/crons';
|
|
@@ -16,12 +17,15 @@ import { SetupStepUpdater } from './helpers/SetupStepUpdater.js';
|
|
|
16
17
|
import { ContextMiddleware } from './middleware/ContextMiddleware.js';
|
|
17
18
|
import { AuditLogService } from './services/AuditLogService.js';
|
|
18
19
|
import { BalanceItemService } from './services/BalanceItemService.js';
|
|
20
|
+
import { BootChecksService } from './services/BootChecksService.js';
|
|
19
21
|
import { CpuService } from './services/CpuService.js';
|
|
20
22
|
import { DocumentService } from './services/DocumentService.js';
|
|
21
23
|
import { FileSignService } from './services/FileSignService.js';
|
|
22
24
|
import { PlatformMembershipService } from './services/PlatformMembershipService.js';
|
|
23
25
|
import { UitpasService } from './services/uitpas/UitpasService.js';
|
|
24
26
|
import { UniqueUserService } from './services/UniqueUserService.js';
|
|
27
|
+
import { AutoEncoder } from '@simonbackx/simple-encoding';
|
|
28
|
+
import { StyledText } from '@simonbackx/simple-logging';
|
|
25
29
|
|
|
26
30
|
process.on('unhandledRejection', (error: Error) => {
|
|
27
31
|
console.error('unhandledRejection');
|
|
@@ -35,16 +39,31 @@ Column.setJSONVersion(Version);
|
|
|
35
39
|
// Set timezone
|
|
36
40
|
process.env.TZ = 'UTC';
|
|
37
41
|
|
|
42
|
+
if (STAMHOOFD.environment === 'development') {
|
|
43
|
+
Error.stackTraceLimit = 100;
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
// Quick check
|
|
39
47
|
if (new Date().getTimezoneOffset() !== 0) {
|
|
40
48
|
throw new Error('Process should always run in UTC timezone');
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
const seeds = async () => {
|
|
51
|
+
const seeds = async (options: {shutdown: () => Promise<void>}) => {
|
|
52
|
+
if (await checkReadOnly()) {
|
|
53
|
+
console.error(new StyledText(`[SEEDS] `).addClass('migration', 'tag'), new StyledText('MySQL is in read-only mode: Seeds are disabled.').addClass('error'));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
44
57
|
try {
|
|
45
58
|
// Internal
|
|
46
59
|
await AuditLogService.disable(async () => {
|
|
47
|
-
await Migration.runAll(
|
|
60
|
+
if (!await Migration.runAll(import.meta.dirname + '/seeds')) {
|
|
61
|
+
console.error(new StyledText(`[SEEDS] `).addClass('migration', 'tag'), new StyledText('Seeds failed!').addClass('error'));
|
|
62
|
+
|
|
63
|
+
if (STAMHOOFD.environment === 'test' || STAMHOOFD.environment === 'development') {
|
|
64
|
+
await options.shutdown();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
48
67
|
});
|
|
49
68
|
}
|
|
50
69
|
catch (e) {
|
|
@@ -61,14 +80,21 @@ function productionLog(message: string) {
|
|
|
61
80
|
}
|
|
62
81
|
|
|
63
82
|
export const boot = async (options: { killProcess: boolean }) => {
|
|
83
|
+
// Make sure we use the current environment for connecting to the database
|
|
84
|
+
await Database.reload({})
|
|
85
|
+
|
|
64
86
|
productionLog('Running server at v' + Version);
|
|
65
87
|
productionLog('Running server at port ' + STAMHOOFD.PORT);
|
|
66
88
|
productionLog('Running server on DB ' + process.env.DB_DATABASE); // note, should always use process env here
|
|
89
|
+
console.log('Node version is: ' + process.version);
|
|
90
|
+
|
|
91
|
+
AutoEncoder.skipDefaultValuesVersion = 10000; // todo
|
|
67
92
|
|
|
68
93
|
loadLogger();
|
|
69
94
|
|
|
70
95
|
await GlobalHelper.load();
|
|
71
96
|
await UniqueUserService.check();
|
|
97
|
+
await BootChecksService.checkDatabaseCollation();
|
|
72
98
|
|
|
73
99
|
// Init platform shared struct: otherwise permissions won't work with missing responsibilities
|
|
74
100
|
productionLog('Loading platform...');
|
|
@@ -79,17 +105,17 @@ export const boot = async (options: { killProcess: boolean }) => {
|
|
|
79
105
|
productionLog('Loading endpoints...');
|
|
80
106
|
|
|
81
107
|
// Note: we should load endpoints one by once to have a reliable order of url matching
|
|
82
|
-
await router.loadAllEndpoints(
|
|
83
|
-
await router.loadAllEndpoints(
|
|
84
|
-
await router.loadAllEndpoints(
|
|
85
|
-
|
|
86
|
-
await router.loadAllEndpoints(
|
|
87
|
-
await router.loadAllEndpoints(
|
|
88
|
-
await router.loadAllEndpoints(
|
|
89
|
-
await router.loadAllEndpoints(
|
|
90
|
-
await router.loadAllEndpoints(
|
|
91
|
-
await router.loadAllEndpoints(
|
|
92
|
-
await router.loadAllEndpoints(
|
|
108
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/global/*');
|
|
109
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/admin/*');
|
|
110
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/frontend');
|
|
111
|
+
|
|
112
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/auth');
|
|
113
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/organization/dashboard/*');
|
|
114
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/organization/registration');
|
|
115
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/organization/webshops');
|
|
116
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/organization/shared');
|
|
117
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/organization/shared/*');
|
|
118
|
+
await router.loadAllEndpoints(import.meta.dirname + '/endpoints/system');
|
|
93
119
|
|
|
94
120
|
router.endpoints.push(new CORSPreflightEndpoint());
|
|
95
121
|
|
|
@@ -257,7 +283,7 @@ export const boot = async (options: { killProcess: boolean }) => {
|
|
|
257
283
|
UitpasService.listen();
|
|
258
284
|
|
|
259
285
|
startCrons();
|
|
260
|
-
seeds().catch(console.error);
|
|
286
|
+
seeds({ shutdown }).catch(console.error);
|
|
261
287
|
|
|
262
288
|
return { shutdown };
|
|
263
289
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { registerCron } from '@stamhoofd/crons';
|
|
2
2
|
import { CachedBalance, Email, EmailRecipient, Organization, User } from '@stamhoofd/models';
|
|
3
|
-
import { IterableSQLSelect
|
|
4
|
-
import {
|
|
3
|
+
import type { IterableSQLSelect} from '@stamhoofd/sql';
|
|
4
|
+
import { readDynamicSQLExpression, SQL, SQLCalculation, SQLPlusSign } from '@stamhoofd/sql';
|
|
5
|
+
import type { OrganizationEmail, StamhoofdFilter } from '@stamhoofd/structures';
|
|
6
|
+
import { EmailRecipientFilter, EmailRecipientFilterType, EmailRecipientSubfilter, EmailTemplateType, ReceivableBalanceType } from '@stamhoofd/structures';
|
|
5
7
|
import { ContextInstance } from '../helpers/Context.js';
|
|
6
8
|
|
|
7
9
|
registerCron('balanceEmails', balanceEmails);
|
|
@@ -3,8 +3,8 @@ import fs from 'fs/promises';
|
|
|
3
3
|
import { clearExcelCacheHelper } from './clearExcelCache.js';
|
|
4
4
|
|
|
5
5
|
const testPath = '/Users/user/project/backend/app/api/.cache';
|
|
6
|
-
|
|
7
|
-
const fsMock =
|
|
6
|
+
vitest.mock('fs/promises');
|
|
7
|
+
const fsMock = vitest.mocked(fs, { deep: false });
|
|
8
8
|
|
|
9
9
|
describe('clearExcelCacheHelper', () => {
|
|
10
10
|
it('should only run between 3 and 6 AM', async () => {
|
|
@@ -34,7 +34,7 @@ describe('clearExcelCacheHelper', () => {
|
|
|
34
34
|
environment: 'production',
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
expect(didClear).
|
|
37
|
+
expect(didClear).toBe(false);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
for (const date of shouldPass) {
|
|
@@ -45,7 +45,7 @@ describe('clearExcelCacheHelper', () => {
|
|
|
45
45
|
environment: 'production',
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
expect(didClear).
|
|
48
|
+
expect(didClear).toBe(true);
|
|
49
49
|
}
|
|
50
50
|
// #endregion
|
|
51
51
|
});
|
|
@@ -70,7 +70,7 @@ describe('clearExcelCacheHelper', () => {
|
|
|
70
70
|
environment: 'production',
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
expect(didClearSecondTry).
|
|
73
|
+
expect(didClearSecondTry).toBe(false);
|
|
74
74
|
|
|
75
75
|
// third try, should pass because the last clear was more than a day ago
|
|
76
76
|
const didClearThirdTry = await clearExcelCacheHelper({
|
|
@@ -80,7 +80,7 @@ describe('clearExcelCacheHelper', () => {
|
|
|
80
80
|
environment: 'production',
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
expect(didClearThirdTry).
|
|
83
|
+
expect(didClearThirdTry).toBe(true);
|
|
84
84
|
|
|
85
85
|
// fourth try, should fail because 5 min earlier the cache was cleared
|
|
86
86
|
const didClearFourthTry = await clearExcelCacheHelper({
|
|
@@ -90,7 +90,7 @@ describe('clearExcelCacheHelper', () => {
|
|
|
90
90
|
environment: 'production',
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
-
expect(didClearFourthTry).
|
|
93
|
+
expect(didClearFourthTry).toBe(false);
|
|
94
94
|
// #endregion
|
|
95
95
|
});
|
|
96
96
|
|
|
@@ -132,7 +132,7 @@ describe('clearExcelCacheHelper', () => {
|
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
fsMock.readdir.mockReturnValue(
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
Promise.resolve([...directories, file1]) as any,
|
|
137
137
|
);
|
|
138
138
|
// #endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { CachedBalance } from '@stamhoofd/models';
|
|
2
1
|
import { registerCron } from '@stamhoofd/crons';
|
|
2
|
+
import { CachedBalance } from '@stamhoofd/models';
|
|
3
|
+
import { ReceivableBalanceType } from '@stamhoofd/structures';
|
|
3
4
|
|
|
4
5
|
registerCron('updateCachedBalances', updateCachedBalances);
|
|
5
6
|
|
|
@@ -11,28 +12,53 @@ async function updateCachedBalances() {
|
|
|
11
12
|
|
|
12
13
|
const balances = await CachedBalance.select().where(
|
|
13
14
|
CachedBalance.whereNeedsUpdate(),
|
|
14
|
-
)
|
|
15
|
+
)
|
|
16
|
+
/**
|
|
17
|
+
* Cached balances of member should be updated before the cached balances of the user
|
|
18
|
+
* because the cached balances of the user are dependent on the cached balances of the member.
|
|
19
|
+
*/
|
|
20
|
+
.orderBy('objectType', 'ASC')
|
|
21
|
+
// minimize the number of queries when updating
|
|
22
|
+
.orderBy('organizationId', 'ASC')
|
|
23
|
+
.limit(100).fetch();
|
|
15
24
|
|
|
16
|
-
// Group by object type
|
|
17
|
-
const grouped = new Map<string, CachedBalance[]
|
|
25
|
+
// Group by object type, next by organization id
|
|
26
|
+
const grouped = new Map<ReceivableBalanceType, Map<string, CachedBalance[]>>();
|
|
18
27
|
|
|
19
28
|
for (const balance of balances) {
|
|
20
|
-
const
|
|
21
|
-
|
|
29
|
+
const objectType = balance.objectType;
|
|
30
|
+
let organizationMap = grouped.get(objectType);
|
|
31
|
+
if (!organizationMap) {
|
|
32
|
+
organizationMap = new Map<string, CachedBalance[]>();
|
|
33
|
+
grouped.set(objectType, organizationMap);
|
|
34
|
+
}
|
|
22
35
|
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
const organizationId = balance.organizationId;
|
|
37
|
+
const balances = organizationMap.get(organizationId);
|
|
38
|
+
|
|
39
|
+
if (!balances) {
|
|
40
|
+
organizationMap.set(organizationId, [balance]);
|
|
25
41
|
continue;
|
|
26
42
|
}
|
|
27
43
|
|
|
28
|
-
|
|
44
|
+
balances.push(balance);
|
|
29
45
|
}
|
|
30
46
|
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
// update member balances first
|
|
48
|
+
const objectTypeMemberFirst = Array.from(grouped.entries());
|
|
49
|
+
objectTypeMemberFirst.sort((a, b) => {
|
|
50
|
+
const aIsMember = a[0] === ReceivableBalanceType.member;
|
|
51
|
+
const bIsMember = b[0] === ReceivableBalanceType.member;
|
|
52
|
+
if (aIsMember && !bIsMember) return -1;
|
|
53
|
+
if (!aIsMember && bIsMember) return 1;
|
|
54
|
+
return 0;
|
|
55
|
+
});
|
|
33
56
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
57
|
+
for (const [objectType, organizationMap] of objectTypeMemberFirst) {
|
|
58
|
+
for (const [organizationId, balances] of organizationMap) {
|
|
59
|
+
const ids = balances.map(b => b.objectId);
|
|
60
|
+
console.log('Updating', ids.length, objectType, 'for', organizationId);
|
|
61
|
+
await CachedBalance.updateForObjects(organizationId, ids, objectType);
|
|
62
|
+
}
|
|
37
63
|
}
|
|
38
64
|
}
|
package/src/debug.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Column } from '@simonbackx/simple-database';
|
|
2
|
-
import {
|
|
2
|
+
import type { ResponseMiddleware, RouterServer } from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { EncodedResponse, Router } from '@simonbackx/simple-endpoints';
|
|
3
4
|
import { logger } from '@simonbackx/simple-logging';
|
|
4
5
|
import { requestPrefix } from '@stamhoofd/backend-middleware';
|
|
5
6
|
|
|
6
7
|
import { AutoEncoder } from '@simonbackx/simple-encoding';
|
|
7
|
-
import { Request, Response } from '@simonbackx/simple-endpoints';
|
|
8
|
+
import type { Request, Response } from '@simonbackx/simple-endpoints';
|
|
8
9
|
import { SQLLogger } from '@stamhoofd/sql';
|
|
9
10
|
import { ContextInstance } from './helpers/Context.js';
|
|
10
11
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Email, Member } from '@stamhoofd/models';
|
|
2
2
|
import { SQL } from '@stamhoofd/sql';
|
|
3
|
-
import {
|
|
3
|
+
import type { LimitedFilteredRequest} from '@stamhoofd/structures';
|
|
4
|
+
import { EmailRecipient, EmailRecipientFilterType, PaginatedResponse, Replacement } from '@stamhoofd/structures';
|
|
4
5
|
import { GetDocumentsEndpoint } from '../endpoints/organization/dashboard/documents/GetDocumentsEndpoint.js';
|
|
5
6
|
|
|
6
7
|
async function fetch(query: LimitedFilteredRequest) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Email } from '@stamhoofd/models';
|
|
2
2
|
import { SQL } from '@stamhoofd/sql';
|
|
3
|
-
import { EmailRecipient,
|
|
3
|
+
import type { EmailRecipient, LimitedFilteredRequest, MembersBlob} from '@stamhoofd/structures';
|
|
4
|
+
import { EmailRecipientFilterType, PaginatedResponse, mergeFilters } from '@stamhoofd/structures';
|
|
4
5
|
import { GetMembersEndpoint } from '../endpoints/global/members/GetMembersEndpoint.js';
|
|
5
6
|
|
|
6
7
|
async function getRecipients(result: PaginatedResponse<MembersBlob, LimitedFilteredRequest>, type: 'member' | 'parents' | 'unverified') {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Email, Webshop } from '@stamhoofd/models';
|
|
2
|
-
import { EmailRecipient,
|
|
2
|
+
import type { EmailRecipient, LimitedFilteredRequest, WebshopPreview } from '@stamhoofd/structures';
|
|
3
|
+
import { EmailRecipientFilterType, mergeFilters, PaginatedResponse } from '@stamhoofd/structures';
|
|
3
4
|
import { GetWebshopOrdersEndpoint } from '../endpoints/organization/dashboard/webshops/GetWebshopOrdersEndpoint.js';
|
|
4
5
|
import { AuthenticatedStructures } from '../helpers/AuthenticatedStructures.js';
|
|
5
6
|
import { Context } from '../helpers/Context.js';
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { RecipientLoader} from '@stamhoofd/models';
|
|
2
|
+
import { BalanceItem, BalanceItemPayment, Email, Member, MemberResponsibilityRecord, Order, Organization, Payment, User, Webshop } from '@stamhoofd/models';
|
|
2
3
|
import { compileToSQLFilter, SQL } from '@stamhoofd/sql';
|
|
3
|
-
import {
|
|
4
|
+
import type { LimitedFilteredRequest, PaymentGeneral, StamhoofdFilter } from '@stamhoofd/structures';
|
|
5
|
+
import { CountFilteredRequest, EmailRecipient, EmailRecipientFilterType, PaginatedResponse, PaymentMethod } from '@stamhoofd/structures';
|
|
4
6
|
import { Formatter } from '@stamhoofd/utility';
|
|
5
7
|
import { GetPaymentsEndpoint } from '../endpoints/organization/dashboard/payments/GetPaymentsEndpoint.js';
|
|
6
8
|
import { memberResponsibilityRecordFilterCompilers } from '../sql-filters/member-responsibility-records.js';
|
|
7
|
-
import {
|
|
9
|
+
import type { ReplacementsOptions } from '../email-replacements/getEmailReplacementsForPayment.js';
|
|
10
|
+
import { buildReplacementOptions, getEmailReplacementsForPayment } from '../email-replacements/getEmailReplacementsForPayment.js';
|
|
8
11
|
|
|
9
12
|
type BeforeFetchAllResult = {
|
|
10
13
|
doesIncludePaymentWithoutOrders: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CachedBalance, Email } from '@stamhoofd/models';
|
|
2
|
-
import {
|
|
2
|
+
import type { LimitedFilteredRequest, StamhoofdFilter } from '@stamhoofd/structures';
|
|
3
|
+
import { BalanceItem as BalanceItemStruct, compileToInMemoryFilter, EmailRecipient, EmailRecipientFilterType, PaginatedResponse, receivableBalanceObjectContactInMemoryFilterCompilers, ReceivableBalanceType, Replacement } from '@stamhoofd/structures';
|
|
3
4
|
import { Formatter } from '@stamhoofd/utility';
|
|
4
5
|
import { GetReceivableBalancesEndpoint } from '../endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesEndpoint.js';
|
|
5
6
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Email, Member } from '@stamhoofd/models';
|
|
2
2
|
import { SQL } from '@stamhoofd/sql';
|
|
3
|
-
import { EmailRecipient,
|
|
3
|
+
import type { EmailRecipient, LimitedFilteredRequest, RegistrationsBlob} from '@stamhoofd/structures';
|
|
4
|
+
import { EmailRecipientFilterType, PaginatedResponse, mergeFilters } from '@stamhoofd/structures';
|
|
4
5
|
import { GetRegistrationsEndpoint } from '../endpoints/global/registration/GetRegistrationsEndpoint.js';
|
|
5
6
|
import { memberJoin } from '../sql-filters/registrations.js';
|
|
6
7
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Order, Organization, Webshop } from '@stamhoofd/models';
|
|
2
|
-
import { BalanceItemPaymentsHtmlTableItem,
|
|
2
|
+
import type { BalanceItemPaymentsHtmlTableItem, PaymentGeneral} from '@stamhoofd/structures';
|
|
3
|
+
import { BalanceItemRelationType, BalanceItemType, getBalanceItemPaymentsHtmlTable, PaymentMethod, PaymentMethodHelper, Replacement, Webshop as WebshopStruct } from '@stamhoofd/structures';
|
|
3
4
|
import { Formatter } from '@stamhoofd/utility';
|
|
4
5
|
import { createOrderDataHTMLTable } from '../helpers/email-html-helpers.js';
|
|
5
6
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { DecodedRequest,
|
|
1
|
+
import type { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
3
4
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
5
|
import { ChargeRequest, LimitedFilteredRequest, PermissionLevel } from '@stamhoofd/structures';
|
|
5
6
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DecodedRequest,
|
|
1
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
2
3
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
3
4
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
4
5
|
import { Context } from '../../../helpers/Context.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DecodedRequest,
|
|
1
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
2
3
|
import { Platform } from '@stamhoofd/models';
|
|
3
4
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
4
5
|
import { SQL, SQLAlias, SQLCount, SQLDistinct, SQLSelectAs, SQLSum, SQLWhereSign } from '@stamhoofd/sql';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { DecodedRequest,
|
|
1
|
+
import type { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
3
4
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
5
|
import { ChargeRequest, LimitedFilteredRequest } from '@stamhoofd/structures';
|
|
5
6
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { DecodedRequest,
|
|
1
|
+
import type { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
3
4
|
import { CountFilteredRequest, CountResponse } from '@stamhoofd/structures';
|
|
4
5
|
|
|
5
6
|
import { Context } from '../../../helpers/Context.js';
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { DecodedRequest,
|
|
1
|
+
import type { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
3
4
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
5
|
import { Organization } from '@stamhoofd/models';
|
|
5
6
|
import { SQL, applySQLSorter, compileToSQLFilter } from '@stamhoofd/sql';
|
|
6
|
-
import { CountFilteredRequest,
|
|
7
|
+
import type { CountFilteredRequest, Organization as OrganizationStruct, StamhoofdFilter} from '@stamhoofd/structures';
|
|
8
|
+
import { LimitedFilteredRequest, PaginatedResponse, PermissionLevel, assertSort, getSortFilter } from '@stamhoofd/structures';
|
|
7
9
|
|
|
8
|
-
import { SQLResultNamespacedRow } from '@simonbackx/simple-database';
|
|
10
|
+
import type { SQLResultNamespacedRow } from '@simonbackx/simple-database';
|
|
9
11
|
import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructures.js';
|
|
10
12
|
import { Context } from '../../../helpers/Context.js';
|
|
11
13
|
import { organizationFilterCompilers } from '../../../sql-filters/organizations.js';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { AutoEncoderPatchType, Decoder, PatchableArrayAutoEncoder
|
|
2
|
-
import {
|
|
1
|
+
import type { AutoEncoderPatchType, Decoder, PatchableArrayAutoEncoder} from '@simonbackx/simple-encoding';
|
|
2
|
+
import { PatchableArrayDecoder, StringDecoder } from '@simonbackx/simple-encoding';
|
|
3
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
4
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
3
5
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
6
|
import { Organization, OrganizationRegistrationPeriod, Platform, RegistrationPeriod } from '@stamhoofd/models';
|
|
5
7
|
import { Organization as OrganizationStruct } from '@stamhoofd/structures';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { DecodedRequest,
|
|
1
|
+
import type { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
3
4
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
5
|
import { ChargeRequest, LimitedFilteredRequest, PermissionLevel } from '@stamhoofd/structures';
|
|
5
6
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { DecodedRequest,
|
|
1
|
+
import type { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
3
4
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
5
|
import { PasswordToken, Platform, sendEmailTemplate, User } from '@stamhoofd/models';
|
|
5
|
-
import {
|
|
6
|
+
import type { UserWithMembers } from '@stamhoofd/structures';
|
|
7
|
+
import { EmailTemplateType, Recipient, Replacement, UserPermissions, User as UserStruct } from '@stamhoofd/structures';
|
|
6
8
|
import { Formatter } from '@stamhoofd/utility';
|
|
7
9
|
|
|
8
10
|
import { AuthenticatedStructures } from '../../helpers/AuthenticatedStructures.js';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { DecodedRequest,
|
|
1
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
2
3
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
3
4
|
import { EmailVerificationCode, PasswordToken, Platform, Token, User } from '@stamhoofd/models';
|
|
4
|
-
import { ChallengeGrantStruct,
|
|
5
|
+
import type { ChallengeGrantStruct, PasswordGrantStruct, PasswordTokenGrantStruct, RefreshTokenGrantStruct, RequestChallengeGrantStruct} from '@stamhoofd/structures';
|
|
6
|
+
import { CreateTokenStruct, LoginMethod, SignupResponse, Token as TokenStruct } from '@stamhoofd/structures';
|
|
5
7
|
|
|
6
8
|
import { Context } from '../../helpers/Context.js';
|
|
7
9
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DecodedRequest,
|
|
1
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
2
3
|
|
|
3
4
|
import { Context } from '../../helpers/Context.js';
|
|
4
5
|
|