@stamhoofd/backend 2.118.1 → 2.120.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +32 -22
- package/src/audit-logs/ModelLogger.ts +4 -2
- package/src/audit-logs/OrderLogger.ts +1 -1
- package/src/boot.ts +32 -14
- package/src/crons/balance-emails.ts +4 -2
- package/src/crons/clearExcelCache.test.ts +8 -8
- package/src/crons/update-cached-balances.ts +40 -14
- package/src/debug.ts +3 -2
- package/src/decoders/StringArrayDecoder.ts +1 -1
- package/src/decoders/StringNullableDecoder.ts +1 -1
- package/src/email-recipient-loaders/documents.ts +2 -1
- package/src/email-recipient-loaders/members.ts +2 -1
- package/src/email-recipient-loaders/orders.ts +2 -1
- package/src/email-recipient-loaders/payments.ts +6 -3
- package/src/email-recipient-loaders/receivable-balances.ts +2 -1
- package/src/email-recipient-loaders/registrations.ts +2 -1
- package/src/email-replacements/getEmailReplacementsForPayment.ts +8 -7
- package/src/endpoints/admin/members/ChargeMembersEndpoint.ts +7 -6
- package/src/endpoints/admin/memberships/ChargeMembershipsEndpoint.ts +3 -2
- package/src/endpoints/admin/memberships/GetChargeMembershipsSummaryEndpoint.ts +2 -1
- package/src/endpoints/admin/organizations/ChargeOrganizationsEndpoint.ts +4 -3
- package/src/endpoints/admin/organizations/GetOrganizationsCountEndpoint.ts +3 -2
- package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +7 -5
- package/src/endpoints/admin/organizations/PatchOrganizationsEndpoint.ts +12 -10
- package/src/endpoints/admin/registrations/ChargeRegistrationsEndpoint.ts +4 -3
- package/src/endpoints/auth/CreateAdminEndpoint.ts +8 -6
- package/src/endpoints/auth/CreateTokenEndpoint.ts +14 -12
- package/src/endpoints/auth/DeleteTokenEndpoint.ts +2 -1
- package/src/endpoints/auth/DeleteUserEndpoint.ts +2 -1
- package/src/endpoints/auth/ForgotPasswordEndpoint.ts +5 -4
- package/src/endpoints/auth/GetOtherUserEndpoint.ts +3 -2
- package/src/endpoints/auth/GetUserEndpoint.ts +3 -2
- package/src/endpoints/auth/OpenIDConnectAuthTokenEndpoint.ts +2 -1
- package/src/endpoints/auth/OpenIDConnectCallbackEndpoint.ts +4 -2
- package/src/endpoints/auth/OpenIDConnectStartEndpoint.ts +3 -2
- package/src/endpoints/auth/PatchUserEndpoint.ts +15 -12
- package/src/endpoints/auth/PollEmailVerificationEndpoint.ts +3 -2
- package/src/endpoints/auth/RetryEmailVerificationEndpoint.ts +3 -2
- package/src/endpoints/auth/SignupEndpoint.ts +5 -4
- package/src/endpoints/auth/VerifyEmailEndpoint.ts +6 -5
- package/src/endpoints/frontend/FrontendEnvironmentEndpoint.ts +3 -2
- package/src/endpoints/global/addresses/SearchRegionsEndpoint.ts +8 -5
- package/src/endpoints/global/addresses/ValidateAddressEndpoint.ts +5 -3
- package/src/endpoints/global/audit-logs/GetAuditLogsEndpoint.ts +8 -5
- package/src/endpoints/global/billing/ActivatePackagesEndpoint.ts +9 -7
- package/src/endpoints/global/billing/DeactivatePackageEndpoint.ts +4 -3
- package/src/endpoints/global/caddy/CheckDomainCertEndpoint.ts +4 -2
- package/src/endpoints/global/email/CreateEmailEndpoint.ts +9 -7
- package/src/endpoints/global/email/GetAdminEmailsEndpoint.test.ts +2 -1
- package/src/endpoints/global/email/GetAdminEmailsEndpoint.ts +22 -19
- package/src/endpoints/global/email/GetEmailAddressEndpoint.ts +6 -4
- package/src/endpoints/global/email/GetEmailEndpoint.ts +4 -3
- package/src/endpoints/global/email/GetUserEmailsEndpoint.test.ts +3 -2
- package/src/endpoints/global/email/GetUserEmailsEndpoint.ts +7 -4
- package/src/endpoints/global/email/ManageEmailAddressEndpoint.ts +7 -5
- package/src/endpoints/global/email/PatchEmailEndpoint.test.ts +11 -11
- package/src/endpoints/global/email/PatchEmailEndpoint.ts +14 -11
- package/src/endpoints/global/email-recipients/GetEmailRecipientsCountEndpoint.ts +3 -2
- package/src/endpoints/global/email-recipients/GetEmailRecipientsEndpoint.test.ts +2 -1
- package/src/endpoints/global/email-recipients/GetEmailRecipientsEndpoint.ts +8 -5
- package/src/endpoints/global/email-recipients/RetryEmailRecipientEndpoint.ts +7 -5
- package/src/endpoints/global/email-recipients/helpers/validateEmailRecipientFilter.ts +4 -3
- package/src/endpoints/global/events/GetEventNotificationsCountEndpoint.ts +3 -2
- package/src/endpoints/global/events/GetEventNotificationsEndpoint.ts +9 -6
- package/src/endpoints/global/events/GetEventsEndpoint.ts +7 -4
- package/src/endpoints/global/events/PatchEventNotificationsEndpoint.test.ts +4 -2
- package/src/endpoints/global/events/PatchEventNotificationsEndpoint.ts +17 -15
- package/src/endpoints/global/events/PatchEventsEndpoint.test.ts +4 -2
- package/src/endpoints/global/events/PatchEventsEndpoint.ts +28 -26
- package/src/endpoints/global/files/ExportToExcelEndpoint.ts +8 -5
- package/src/endpoints/global/files/GetFileCache.ts +5 -3
- package/src/endpoints/global/files/UploadFile.ts +10 -4
- package/src/endpoints/global/files/UploadImage.ts +4 -2
- package/src/endpoints/global/groups/GetGroupsEndpoint.test.ts +4 -2
- package/src/endpoints/global/groups/GetGroupsEndpoint.ts +8 -5
- package/src/endpoints/global/members/GetMemberFamilyEndpoint.ts +7 -5
- package/src/endpoints/global/members/GetMembersCountEndpoint.ts +3 -2
- package/src/endpoints/global/members/GetMembersEndpoint.test.ts +4 -2
- package/src/endpoints/global/members/GetMembersEndpoint.ts +10 -8
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.test.ts +257 -6
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +162 -107
- package/src/endpoints/global/members/helpers/validateGroupFilter.ts +4 -3
- package/src/endpoints/global/members/shouldCheckIfMemberIsDuplicate.ts +3 -2
- package/src/endpoints/global/organizations/CheckRegisterCodeEndpoint.ts +3 -2
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.test.ts +3 -2
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.ts +8 -7
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.ts +5 -3
- package/src/endpoints/global/organizations/GetOrganizationFromUriEndpoint.ts +5 -3
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.ts +8 -5
- package/src/endpoints/global/payments/StripeWebhookEndpoint.ts +4 -2
- package/src/endpoints/global/platform/GetPlatformAdminsEndpoint.ts +2 -1
- package/src/endpoints/global/platform/GetPlatformEndpoint.ts +3 -2
- package/src/endpoints/global/platform/PatchPlatformEnpoint.test.ts +3 -2
- package/src/endpoints/global/platform/PatchPlatformEnpoint.ts +7 -4
- package/src/endpoints/global/platform-memberships/GetPlatformMembershipsCountEndpoint.ts +47 -0
- package/src/endpoints/global/platform-memberships/GetPlatformMembershipsEndpoint.ts +206 -0
- package/src/endpoints/global/registration/GetRegistrationsCountEndpoint.ts +3 -2
- package/src/endpoints/global/registration/GetRegistrationsEndpoint.test.ts +2 -1
- package/src/endpoints/global/registration/GetRegistrationsEndpoint.ts +10 -7
- package/src/endpoints/global/registration/GetUserDetailedPayableBalanceEndpoint.ts +4 -2
- package/src/endpoints/global/registration/GetUserDocumentsEndpoint.ts +4 -2
- package/src/endpoints/global/registration/GetUserMembersEndpoint.ts +3 -2
- package/src/endpoints/global/registration/GetUserPayableBalanceEndpoint.ts +2 -1
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.test.ts +5 -3
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.ts +13 -9
- package/src/endpoints/global/registration/RegisterMembersEndpoint.test.ts +50 -49
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +25 -22
- package/src/endpoints/global/registration-periods/GetRegistrationPeriodsEndpoint.ts +8 -5
- package/src/endpoints/global/registration-periods/PatchRegistrationPeriodsEndpoint.ts +9 -7
- package/src/endpoints/global/sso/GetSSOEndpoint.ts +4 -2
- package/src/endpoints/global/sso/SetSSOEndpoint.ts +3 -2
- package/src/endpoints/global/webshops/GetWebshopFromDomainEndpoint.ts +4 -2
- package/src/endpoints/global/webshops/GetWebshopsCountEndpoint.ts +43 -0
- package/src/endpoints/global/webshops/GetWebshopsEndpoint.test.ts +808 -0
- package/src/endpoints/global/webshops/GetWebshopsEndpoint.ts +221 -0
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemEndpoint.ts +4 -3
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsEndpoint.ts +6 -4
- package/src/endpoints/organization/dashboard/balance-items/PatchBalanceItemsEndpoint.ts +15 -13
- package/src/endpoints/organization/dashboard/billing/GetOrganizationDetailedPayableBalanceEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/billing/GetOrganizationPayableBalanceEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/billing/GetPackagesEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplateXML.ts +3 -2
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplatesCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplatesEndpoint.ts +7 -4
- package/src/endpoints/organization/dashboard/documents/GetDocumentsCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/documents/GetDocumentsEndpoint.ts +7 -4
- package/src/endpoints/organization/dashboard/documents/PatchDocumentEndpoint.ts +9 -7
- package/src/endpoints/organization/dashboard/documents/PatchDocumentTemplatesEndpoint.test.ts +4 -2
- package/src/endpoints/organization/dashboard/documents/PatchDocumentTemplatesEndpoint.ts +7 -5
- package/src/endpoints/organization/dashboard/email/CheckEmailBouncesEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.test.ts +36 -1
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.ts +13 -4
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.test.ts +4 -2
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.ts +7 -5
- package/src/endpoints/organization/dashboard/invoices/GetInvoicesCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/invoices/GetInvoicesEndpoint.ts +6 -4
- package/src/endpoints/organization/dashboard/invoices/PatchInvoicesEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/mollie/CheckMollieEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/mollie/ConnectMollieEndpoint.ts +6 -3
- package/src/endpoints/organization/dashboard/mollie/DisconnectMollieEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/mollie/GetMollieDashboardEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/nolt/CreateNoltTokenEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/organization/GetOrganizationArchivedGroups.ts +4 -2
- package/src/endpoints/organization/dashboard/organization/GetOrganizationDeletedGroups.ts +3 -2
- package/src/endpoints/organization/dashboard/organization/GetUitpasClientIdEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.test.ts +5 -3
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +22 -19
- package/src/endpoints/organization/dashboard/organization/SearchUitpasOrganizersEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/organization/SetOrganizationDomainEndpoint.ts +11 -9
- package/src/endpoints/organization/dashboard/organization/SetUitpasClientCredentialsEndpoint.ts +8 -7
- package/src/endpoints/organization/dashboard/payments/GetMemberBalanceEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/payments/GetPaymentsCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/payments/GetPaymentsEndpoint.ts +7 -5
- package/src/endpoints/organization/dashboard/payments/PatchPaymentsEndpoint.ts +18 -16
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalanceEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.test.ts +2 -1
- package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.ts +8 -5
- package/src/endpoints/organization/dashboard/registration-periods/MoveRegistrationPeriods.test.ts +4 -2
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.test.ts +4 -2
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.ts +32 -29
- package/src/endpoints/organization/dashboard/registration-periods/SetupStepReviewEndpoint.ts +6 -3
- package/src/endpoints/organization/dashboard/stripe/ConnectStripeEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/stripe/DeleteStripeAccountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountLinkEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountsEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/stripe/GetStripeLoginLinkEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/stripe/UpdateStripeAccountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/users/CreateApiUserEndpoint.ts +4 -3
- package/src/endpoints/organization/dashboard/users/DeleteUserEndpoint.ts +4 -3
- package/src/endpoints/organization/dashboard/users/GetApiUsersEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/users/GetOrganizationAdminsEndpoint.ts +2 -1
- package/src/endpoints/organization/dashboard/users/PatchApiUserEndpoint.ts +6 -4
- package/src/endpoints/organization/dashboard/webshops/CreateWebshopEndpoint.ts +7 -6
- package/src/endpoints/organization/dashboard/webshops/DeleteWebshopEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/webshops/GetDiscountCodesEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersCountEndpoint.ts +3 -2
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersEndpoint.ts +7 -4
- package/src/endpoints/organization/dashboard/webshops/{GetWebshopTicketsCountEndpoint → GetWebshopTicketsCountEndpoint.ts} +7 -7
- package/src/endpoints/organization/dashboard/webshops/GetWebshopTicketsEndpoint.ts +9 -6
- package/src/endpoints/organization/dashboard/webshops/GetWebshopUriAvailabilityEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/webshops/PatchDiscountCodesEndpoint.ts +6 -4
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopEndpoint.ts +13 -12
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint.ts +4 -2
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopTicketsEndpoint.ts +5 -3
- package/src/endpoints/organization/dashboard/webshops/SearchUitpasEventsEndpoint.ts +6 -4
- package/src/endpoints/organization/dashboard/webshops/VerifyWebshopDomainEndpoint.ts +2 -1
- package/src/endpoints/organization/shared/ExchangePaymentEndpoint.ts +6 -4
- package/src/endpoints/organization/shared/GetDocumentHtml.ts +4 -3
- package/src/endpoints/organization/shared/GetPaymentEndpoint.ts +4 -3
- package/src/endpoints/organization/shared/GetUitpasNumberDetailsEndpoint.ts +3 -2
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.ts +3 -2
- package/src/endpoints/organization/webshops/CheckWebshopDiscountCodesEndpoint.ts +4 -3
- package/src/endpoints/organization/webshops/GetOrderByPaymentEndpoint.ts +5 -4
- package/src/endpoints/organization/webshops/GetOrderEndpoint.ts +4 -3
- package/src/endpoints/organization/webshops/GetTicketsEndpoint.ts +7 -5
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.ts +4 -3
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.test.ts +7 -3
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.ts +11 -10
- package/src/endpoints/organization/webshops/RetrieveUitpasSocialTariffPriceEndpoint.ts +5 -4
- package/src/endpoints/system/HealthEndpoint.test.ts +44 -0
- package/src/endpoints/system/HealthEndpoint.ts +14 -6
- package/src/excel-loaders/balance-items.ts +19 -17
- package/src/excel-loaders/event-notifications.ts +15 -13
- package/src/excel-loaders/index.ts +1 -0
- package/src/excel-loaders/members.ts +45 -43
- package/src/excel-loaders/organizations.ts +26 -25
- package/src/excel-loaders/payments.ts +44 -42
- package/src/excel-loaders/platform-memberships.ts +202 -0
- package/src/excel-loaders/receivable-balances.ts +25 -23
- package/src/excel-loaders/registrations.ts +30 -28
- package/src/helpers/AddressValidator.test.ts +2 -1
- package/src/helpers/AddressValidator.ts +13 -10
- package/src/helpers/AdminPermissionChecker.ts +193 -95
- package/src/helpers/AuthenticatedStructures.ts +13 -11
- package/src/helpers/BuckarooHelper.ts +3 -2
- package/src/helpers/Context.ts +8 -6
- package/src/helpers/CookieHelper.ts +2 -2
- package/src/helpers/FileCache.ts +9 -9
- package/src/helpers/ForwardHandler.ts +3 -2
- package/src/helpers/GlobalHelper.ts +2 -0
- package/src/helpers/GroupBuilder.ts +2 -1
- package/src/helpers/GroupedThrottledQueue.test.ts +19 -19
- package/src/helpers/LimitedFilteredRequestHelper.ts +1 -1
- package/src/helpers/MemberCharger.ts +2 -1
- package/src/helpers/MemberUserSyncer.ts +6 -3
- package/src/helpers/MembershipCharger.ts +2 -2
- package/src/helpers/OrganizationCharger.ts +2 -1
- package/src/helpers/PeriodHelper.ts +2 -1
- package/src/helpers/SQLTranslatedString.ts +3 -2
- package/src/helpers/ServiceFeeHelper.ts +1 -1
- package/src/helpers/SetupStepUpdater.ts +6 -5
- package/src/helpers/StripeHelper.ts +9 -8
- package/src/helpers/TagHelper.test.ts +5 -5
- package/src/helpers/TagHelper.ts +2 -1
- package/src/helpers/TemporaryMemberAccess.ts +2 -1
- package/src/helpers/ThrottledQueue.test.ts +20 -20
- package/src/helpers/UitpasTokenRepository.ts +7 -7
- package/src/helpers/ViesHelper.ts +5 -4
- package/src/helpers/XlsxTransformerColumnHelper.ts +21 -19
- package/src/helpers/email-html-helpers.ts +13 -12
- package/src/helpers/fetchToAsyncIterator.ts +1 -1
- package/src/helpers/outstandingBalanceJoin.ts +2 -1
- package/src/helpers/updateMemberDetailsUitpasNumber.ts +5 -4
- package/src/middleware/ContextMiddleware.ts +1 -1
- package/src/migrate.ts +21 -4
- package/src/seeds/0000000003-default-email-templates.ts +1 -1
- package/src/seeds/0000000004-single-organization.ts +2 -1
- package/src/seeds/1752848561-groups-registration-periods.ts +3 -2
- package/src/seeds/1754560914-groups-prices.test.ts +2 -1
- package/src/seeds/1754560914-groups-prices.ts +2 -1
- package/src/seeds/1755790070-fill-email-recipient-errors.ts +6 -6
- package/src/seeds/1755876819-remove-duplicate-members.ts +2 -1
- package/src/seeds/1765896674-document-update-year.test.ts +2 -1
- package/src/seeds/1773754928-force-save-members.ts +15 -0
- package/src/services/AuditLogService.ts +3 -2
- package/src/services/BalanceItemPaymentService.ts +2 -2
- package/src/services/BalanceItemService.ts +2 -1
- package/src/services/BootChecksService.test.ts +33 -0
- package/src/services/BootChecksService.ts +21 -0
- package/src/services/DatabaseCollationService.test.ts +18 -0
- package/src/services/DatabaseCollationService.ts +81 -0
- package/src/services/DocumentService.ts +1 -1
- package/src/services/EventNotificationService.ts +5 -4
- package/src/services/FileSignService.ts +2 -2
- package/src/services/InvoiceService.ts +3 -3
- package/src/services/MemberNumberService.ts +6 -4
- package/src/services/MemberRecordStore.ts +28 -19
- package/src/services/PaymentReallocationService.test.ts +2 -1
- package/src/services/PaymentReallocationService.ts +2 -1
- package/src/services/PaymentService.ts +28 -26
- package/src/services/RegistrationService.ts +65 -3
- package/src/services/SSOService.ts +13 -9
- package/src/services/STPackageService.ts +7 -5
- package/src/services/StartupHealthService.ts +15 -0
- package/src/services/uitpas/PassholderEndpoints.ts +2 -2
- package/src/services/uitpas/UitpasService.ts +11 -8
- package/src/services/uitpas/cancelTicketSales.ts +1 -1
- package/src/services/uitpas/checkPermissionsFor.ts +9 -9
- package/src/services/uitpas/getSocialTariffForEvent.ts +4 -4
- package/src/services/uitpas/getSocialTariffForUitpasNumbers.ts +5 -5
- package/src/services/uitpas/handleUitpasResponse.ts +1 -1
- package/src/services/uitpas/registerTicketSales.ts +4 -4
- package/src/services/uitpas/searchUitpasEvents.ts +3 -3
- package/src/services/uitpas/searchUitpasOrganizers.ts +3 -3
- package/src/sql-filters/audit-logs.ts +2 -1
- package/src/sql-filters/balance-item-payments.ts +2 -1
- package/src/sql-filters/balance-items.ts +2 -1
- package/src/sql-filters/base-registration-filter-compilers.ts +6 -4
- package/src/sql-filters/document-templates.ts +2 -1
- package/src/sql-filters/documents.ts +2 -1
- package/src/sql-filters/email-recipients.ts +2 -1
- package/src/sql-filters/emails.ts +2 -1
- package/src/sql-filters/event-notifications.ts +2 -1
- package/src/sql-filters/events.ts +2 -1
- package/src/sql-filters/groups.ts +2 -1
- package/src/sql-filters/invoiced-balance-items.ts +2 -1
- package/src/sql-filters/invoices.ts +2 -1
- package/src/sql-filters/member-responsibility-records.ts +2 -1
- package/src/sql-filters/members.ts +8 -7
- package/src/sql-filters/orders.ts +3 -2
- package/src/sql-filters/organization-registration-periods.ts +2 -1
- package/src/sql-filters/organizations.ts +2 -1
- package/src/sql-filters/payments.ts +2 -1
- package/src/sql-filters/platform-memberships.ts +67 -0
- package/src/sql-filters/receivable-balances.ts +2 -1
- package/src/sql-filters/registration-periods.ts +2 -1
- package/src/sql-filters/registrations.ts +2 -1
- package/src/sql-filters/tickets.ts +2 -1
- package/src/sql-filters/users.ts +2 -1
- package/src/sql-filters/webshops.ts +38 -0
- package/src/sql-sorters/audit-logs.ts +3 -2
- package/src/sql-sorters/balance-items.ts +3 -2
- package/src/sql-sorters/document-templates.ts +3 -2
- package/src/sql-sorters/documents.ts +3 -2
- package/src/sql-sorters/email-recipients.ts +3 -2
- package/src/sql-sorters/emails.ts +3 -2
- package/src/sql-sorters/event-notifications.ts +3 -2
- package/src/sql-sorters/events.ts +3 -2
- package/src/sql-sorters/groups.ts +3 -2
- package/src/sql-sorters/invoices.ts +3 -2
- package/src/sql-sorters/members.ts +3 -2
- package/src/sql-sorters/orders.ts +3 -2
- package/src/sql-sorters/organization-registration-periods.ts +3 -2
- package/src/sql-sorters/organizations.ts +3 -2
- package/src/sql-sorters/payments.ts +3 -2
- package/src/sql-sorters/platform-memberships.ts +40 -0
- package/src/sql-sorters/receivable-balances.ts +3 -2
- package/src/sql-sorters/registration-periods.ts +3 -2
- package/src/sql-sorters/registrations.ts +3 -2
- package/src/sql-sorters/tickets.ts +3 -2
- package/src/sql-sorters/webshops.ts +40 -0
- package/tests/actions/patchOrganizationMember.ts +5 -4
- package/tests/actions/patchPaymentStatus.ts +2 -2
- package/tests/actions/patchUserMember.ts +6 -4
- package/tests/e2e/api-rate-limits.test.ts +4 -5
- package/tests/e2e/bundle-discounts.test.ts +3 -2
- package/tests/e2e/charge-members.test.ts +7 -5
- package/tests/e2e/documents.test.ts +3 -2
- package/tests/e2e/private-files.test.ts +11 -13
- package/tests/e2e/register.test.ts +6 -5
- package/tests/e2e/stock.test.ts +6 -8
- package/tests/e2e/tickets.test.ts +4 -2
- package/tests/helpers/StripeMocker.ts +3 -3
- package/tests/init/initAdmin.ts +4 -2
- package/tests/init/initBundleDiscount.ts +3 -2
- package/tests/init/initPayconiq.ts +1 -1
- package/tests/init/initPermissionRole.ts +4 -2
- package/tests/init/initPlatformRecordCategory.ts +1 -1
- package/tests/init/initStripe.ts +1 -1
- package/tests/vitest.global.setup.ts +26 -0
- package/tests/{jest.setup.ts → vitest.setup.ts} +4 -3
- package/tsconfig.build.json +17 -0
- package/tsconfig.json +10 -41
- package/tsconfig.test.json +17 -0
- package/vitest.config.js +13 -0
- package/eslint.config.mjs +0 -5
- package/jest.config.cjs +0 -27
- package/tests/jest.global.setup.ts +0 -33
- package/tests/toMatchMap.ts +0 -68
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AutoEncoderPatchType } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { MemberDetails
|
|
1
|
+
import type { AutoEncoderPatchType } from '@simonbackx/simple-encoding';
|
|
2
|
+
import type { MemberDetails} from '@stamhoofd/structures';
|
|
3
|
+
import { MemberWithRegistrationsBlob } from '@stamhoofd/structures';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Returns true when either the firstname, lastname or birthday has changed
|
|
@@ -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 { Organization, RegisterCode } from '@stamhoofd/models';
|
|
4
5
|
import { RegisterCode as RegisterCodeStruct } from '@stamhoofd/structures';
|
|
@@ -36,7 +37,7 @@ export class CheckRegisterCodeEndpoint extends Endpoint<Params, Query, Body, Res
|
|
|
36
37
|
throw new SimpleError({
|
|
37
38
|
code: 'invalid_code',
|
|
38
39
|
message: 'Invalid code',
|
|
39
|
-
human: $t(`
|
|
40
|
+
human: $t(`%EC`),
|
|
40
41
|
field: 'registerCode',
|
|
41
42
|
});
|
|
42
43
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Request } from '@simonbackx/simple-endpoints';
|
|
2
|
-
import { Address,
|
|
2
|
+
import { Address, CreateOrganization, NewUser, Organization as OrganizationStruct, Version } from '@stamhoofd/structures';
|
|
3
|
+
import { Country } from '@stamhoofd/types/Country';
|
|
3
4
|
|
|
4
5
|
import { testServer } from '../../../../tests/helpers/TestServer.js';
|
|
5
6
|
import { CreateOrganizationEndpoint } from './CreateOrganizationEndpoint.js';
|
|
@@ -29,7 +30,7 @@ describe.skip('Endpoint.CreateOrganization', () => {
|
|
|
29
30
|
}).encode({ version: Version }));
|
|
30
31
|
|
|
31
32
|
const response = await testServer.test(endpoint, r);
|
|
32
|
-
expect(response.body.token).not.
|
|
33
|
+
expect(response.body.token).not.toEqual([]);
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
test('Creating an organization with an in-use URI throws', async () => {
|
|
@@ -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 { AuditLog, EmailVerificationCode, Organization, OrganizationRegistrationPeriod, RegistrationPeriod, User } from '@stamhoofd/models';
|
|
5
6
|
import { AuditLogSource, AuditLogType, CreateOrganization, PermissionLevel, Permissions, RegistrationPeriodSettings, SignupResponse, UserPermissions } from '@stamhoofd/structures';
|
|
@@ -32,7 +33,7 @@ export class CreateOrganizationEndpoint extends Endpoint<Params, Query, Body, Re
|
|
|
32
33
|
throw new SimpleError({
|
|
33
34
|
code: 'invalid_field',
|
|
34
35
|
message: 'Not allowed',
|
|
35
|
-
human: $t(`
|
|
36
|
+
human: $t(`%ED`),
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
39
|
|
|
@@ -41,7 +42,7 @@ export class CreateOrganizationEndpoint extends Endpoint<Params, Query, Body, Re
|
|
|
41
42
|
throw new SimpleError({
|
|
42
43
|
code: 'invalid_field',
|
|
43
44
|
message: 'Should not be empty',
|
|
44
|
-
human: $t(`
|
|
45
|
+
human: $t(`%Cz`),
|
|
45
46
|
field: 'organization.name',
|
|
46
47
|
});
|
|
47
48
|
}
|
|
@@ -49,7 +50,7 @@ export class CreateOrganizationEndpoint extends Endpoint<Params, Query, Body, Re
|
|
|
49
50
|
throw new SimpleError({
|
|
50
51
|
code: 'invalid_field',
|
|
51
52
|
message: 'Field is too short',
|
|
52
|
-
human: $t(`
|
|
53
|
+
human: $t(`%D0`),
|
|
53
54
|
field: 'organization.name',
|
|
54
55
|
});
|
|
55
56
|
}
|
|
@@ -60,7 +61,7 @@ export class CreateOrganizationEndpoint extends Endpoint<Params, Query, Body, Re
|
|
|
60
61
|
throw new SimpleError({
|
|
61
62
|
code: 'invalid_field',
|
|
62
63
|
message: 'Field is too long',
|
|
63
|
-
human: $t(`
|
|
64
|
+
human: $t(`%D1`),
|
|
64
65
|
field: 'organization.name',
|
|
65
66
|
});
|
|
66
67
|
}
|
|
@@ -70,7 +71,7 @@ export class CreateOrganizationEndpoint extends Endpoint<Params, Query, Body, Re
|
|
|
70
71
|
throw new SimpleError({
|
|
71
72
|
code: 'name_taken',
|
|
72
73
|
message: 'An organization with the same name already exists',
|
|
73
|
-
human: $t(`
|
|
74
|
+
human: $t(`%D3`),
|
|
74
75
|
field: 'name',
|
|
75
76
|
});
|
|
76
77
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Decoder} from '@simonbackx/simple-encoding';
|
|
2
|
+
import { AutoEncoder, field, 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 } from '@stamhoofd/models';
|
|
5
|
-
import { Organization as OrganizationStruct } from '@stamhoofd/structures';
|
|
7
|
+
import type { Organization as OrganizationStruct } from '@stamhoofd/structures';
|
|
6
8
|
import { GoogleTranslateHelper } from '@stamhoofd/utility';
|
|
7
9
|
import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructures.js';
|
|
8
10
|
type Params = Record<string, never>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Decoder} from '@simonbackx/simple-encoding';
|
|
2
|
+
import { AutoEncoder, field, 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 } from '@stamhoofd/models';
|
|
5
|
-
import { Organization as OrganizationStruct } from '@stamhoofd/structures';
|
|
7
|
+
import type { Organization as OrganizationStruct } from '@stamhoofd/structures';
|
|
6
8
|
import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructures.js';
|
|
7
9
|
type Params = Record<string, never>;
|
|
8
10
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Decoder} from '@simonbackx/simple-encoding';
|
|
2
|
+
import { AutoEncoder, field, 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 { Organization } from '@stamhoofd/models';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
+
import type { SQLWhere} from '@stamhoofd/sql';
|
|
7
|
+
import { scalarToSQLExpression, SQL, SQLMatch, SQLWhereLike } from '@stamhoofd/sql';
|
|
8
|
+
import type { Organization as OrganizationStruct } from '@stamhoofd/structures';
|
|
6
9
|
import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructures.js';
|
|
7
10
|
|
|
8
11
|
type Params = Record<string, never>;
|
|
@@ -33,7 +36,7 @@ export class SearchOrganizationEndpoint extends Endpoint<Params, Query, Body, Re
|
|
|
33
36
|
|
|
34
37
|
async handle(request: DecodedRequest<Params, Query, Body>) {
|
|
35
38
|
// Escape query
|
|
36
|
-
const query = request.query.query.replace(/
|
|
39
|
+
const query = request.query.query.replace(/[-+><()~*"@\s]+/g, ' ').replace(/\W+$/, '').trim();
|
|
37
40
|
if (query.length === 0) {
|
|
38
41
|
// Do not try searching...
|
|
39
42
|
return new Response([]);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Decoder} from '@simonbackx/simple-encoding';
|
|
2
|
+
import { AnyDecoder, AutoEncoder, field, 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, StripeAccount, StripeCheckoutSession, StripePaymentIntent } from '@stamhoofd/models';
|
|
5
7
|
import { isDebouncedError, QueueHandler } from '@stamhoofd/queues';
|
|
@@ -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 { User } from '@stamhoofd/models';
|
|
3
4
|
import { OrganizationAdmins } from '@stamhoofd/structures';
|
|
4
5
|
|
|
@@ -1,6 +1,7 @@
|
|
|
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
|
-
import { Platform as PlatformStruct } from '@stamhoofd/structures';
|
|
4
|
+
import type { Platform as PlatformStruct } from '@stamhoofd/structures';
|
|
4
5
|
|
|
5
6
|
import { Context } from '../../../helpers/Context.js';
|
|
6
7
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Request } from '@simonbackx/simple-endpoints';
|
|
2
|
-
import { Organization
|
|
2
|
+
import type { Organization} from '@stamhoofd/models';
|
|
3
|
+
import { OrganizationFactory, Platform, RegistrationPeriod, RegistrationPeriodFactory, Token, UserFactory } from '@stamhoofd/models';
|
|
3
4
|
import { PermissionLevel, Permissions, PlatformConfig, Platform as PlatformStruct, Version } from '@stamhoofd/structures';
|
|
4
5
|
|
|
5
|
-
import { AutoEncoderPatchType } from '@simonbackx/simple-encoding';
|
|
6
|
+
import type { AutoEncoderPatchType } from '@simonbackx/simple-encoding';
|
|
6
7
|
import { TestUtils } from '@stamhoofd/test-utils';
|
|
7
8
|
import { testServer } from '../../../../tests/helpers/TestServer.js';
|
|
8
9
|
import { PatchPlatformEndpoint } from './PatchPlatformEnpoint.js';
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { AutoEncoderPatchType, Decoder
|
|
2
|
-
import {
|
|
1
|
+
import type { AutoEncoderPatchType, Decoder} from '@simonbackx/simple-encoding';
|
|
2
|
+
import { isPatchableArray, patchObject } from '@simonbackx/simple-encoding';
|
|
3
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
4
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
3
5
|
import { Organization, Platform, RegistrationPeriod } from '@stamhoofd/models';
|
|
4
|
-
import { MemberResponsibility, PlatformConfig, PlatformPremiseType
|
|
6
|
+
import type { MemberResponsibility, PlatformConfig, PlatformPremiseType} from '@stamhoofd/structures';
|
|
7
|
+
import { Platform as PlatformStruct } from '@stamhoofd/structures';
|
|
5
8
|
|
|
6
9
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
7
10
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
@@ -163,7 +166,7 @@ export class PatchPlatformEndpoint extends Endpoint<
|
|
|
163
166
|
throw new SimpleError({
|
|
164
167
|
code: 'cannot_set_locked_period',
|
|
165
168
|
message: 'Platform period cannot be set to a locked period',
|
|
166
|
-
human: $t(`
|
|
169
|
+
human: $t(`%EE`),
|
|
167
170
|
});
|
|
168
171
|
}
|
|
169
172
|
platform.periodId = period.id;
|
|
@@ -0,0 +1,47 @@
|
|
|
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';
|
|
4
|
+
import { CountFilteredRequest, CountResponse } from '@stamhoofd/structures';
|
|
5
|
+
import { Context } from '../../../helpers/Context.js';
|
|
6
|
+
import { GetPlatformMembershipsEndpoint } from './GetPlatformMembershipsEndpoint.js';
|
|
7
|
+
|
|
8
|
+
type Params = Record<string, never>;
|
|
9
|
+
type Query = CountFilteredRequest;
|
|
10
|
+
type Body = undefined;
|
|
11
|
+
type ResponseBody = CountResponse
|
|
12
|
+
|
|
13
|
+
export class GetPlatformMembershipsCountEndpoint extends Endpoint<Params, Query, Body, ResponseBody> {
|
|
14
|
+
queryDecoder = CountFilteredRequest as Decoder<CountFilteredRequest>;
|
|
15
|
+
|
|
16
|
+
protected doesMatch(request: Request): [true, Params] | [false] {
|
|
17
|
+
if (request.method !== 'GET') {
|
|
18
|
+
return [false];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const params = Endpoint.parseParameters(request.url, '/platform-memberships/count', {});
|
|
22
|
+
|
|
23
|
+
if (params) {
|
|
24
|
+
return [true, params as Params];
|
|
25
|
+
}
|
|
26
|
+
return [false];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async handle(request: DecodedRequest<Params, Query, Body>) {
|
|
30
|
+
await Context.authenticate();
|
|
31
|
+
|
|
32
|
+
if (!Context.auth.hasPlatformFullAccess()) {
|
|
33
|
+
throw Context.auth.error();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const query = await GetPlatformMembershipsEndpoint.buildQuery(request.query);
|
|
37
|
+
|
|
38
|
+
const count = await query
|
|
39
|
+
.count();
|
|
40
|
+
|
|
41
|
+
return new Response(
|
|
42
|
+
CountResponse.create({
|
|
43
|
+
count,
|
|
44
|
+
}),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
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';
|
|
4
|
+
import { SimpleError } from '@simonbackx/simple-errors';
|
|
5
|
+
import { Member, MemberPlatformMembership, Organization } from '@stamhoofd/models';
|
|
6
|
+
import { applySQLSorter, compileToSQLFilter } from '@stamhoofd/sql';
|
|
7
|
+
import type { CountFilteredRequest, StamhoofdFilter } from '@stamhoofd/structures';
|
|
8
|
+
import { assertSort, getSortFilter, LimitedFilteredRequest, PaginatedResponse, PlatformMembershiMemberDetails, PlatformMembership, PlatformMembershipOrganizationDetails } from '@stamhoofd/structures';
|
|
9
|
+
import { Formatter } from '@stamhoofd/utility';
|
|
10
|
+
import { Context } from '../../../helpers/Context.js';
|
|
11
|
+
import { platformMembershipFilterCompilers } from '../../../sql-filters/platform-memberships.js';
|
|
12
|
+
import { platformMembershipSorters } from '../../../sql-sorters/platform-memberships.js';
|
|
13
|
+
|
|
14
|
+
type Params = Record<string, never>;
|
|
15
|
+
type Query = LimitedFilteredRequest;
|
|
16
|
+
type Body = undefined;
|
|
17
|
+
type ResponseBody = PaginatedResponse<PlatformMembership[], LimitedFilteredRequest>;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const sorters = platformMembershipSorters;
|
|
21
|
+
const filterCompilers = platformMembershipFilterCompilers;
|
|
22
|
+
|
|
23
|
+
export class GetPlatformMembershipsEndpoint extends Endpoint<Params, Query, Body, ResponseBody> {
|
|
24
|
+
queryDecoder = LimitedFilteredRequest as Decoder<LimitedFilteredRequest>;
|
|
25
|
+
|
|
26
|
+
protected doesMatch(request: Request): [true, Params] | [false] {
|
|
27
|
+
if (request.method !== 'GET') {
|
|
28
|
+
return [false];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const params = Endpoint.parseParameters(request.url, '/platform-memberships', {});
|
|
32
|
+
|
|
33
|
+
if (params) {
|
|
34
|
+
return [true, params as Params];
|
|
35
|
+
}
|
|
36
|
+
return [false];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static async buildQuery(q: CountFilteredRequest | LimitedFilteredRequest) {
|
|
40
|
+
if (!Context.auth.hasPlatformFullAccess()) {
|
|
41
|
+
throw Context.auth.error();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const query = MemberPlatformMembership.select()
|
|
45
|
+
.setMaxExecutionTime(15 * 1000)
|
|
46
|
+
.where('deletedAt', null);
|
|
47
|
+
|
|
48
|
+
if (q.filter) {
|
|
49
|
+
query.where(await compileToSQLFilter(q.filter, filterCompilers));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const searchFilter = GetPlatformMembershipsEndpoint.buildSearchFilter(q.search);
|
|
53
|
+
|
|
54
|
+
if (searchFilter) {
|
|
55
|
+
query.where(await compileToSQLFilter(searchFilter, filterCompilers));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (q instanceof LimitedFilteredRequest) {
|
|
59
|
+
if (q.pageFilter) {
|
|
60
|
+
query.where(await compileToSQLFilter(q.pageFilter, filterCompilers));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
q.sort = assertSort(q.sort, [{ key: 'id' }]);
|
|
64
|
+
applySQLSorter(query, q.sort, sorters);
|
|
65
|
+
query.limit(q.limit);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return query;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static buildSearchFilter(search: string | null): StamhoofdFilter | null {
|
|
72
|
+
if (!search) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Is member number?
|
|
77
|
+
if (search.match(/^\d{4}-\d{6}-\d{1,2}$/) || search.match(/^\d{9,10}$/)) {
|
|
78
|
+
return {
|
|
79
|
+
member: {
|
|
80
|
+
memberNumber: {
|
|
81
|
+
$eq: search,
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
member: {
|
|
90
|
+
name: {
|
|
91
|
+
$contains: search,
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static async buildData(requestQuery: LimitedFilteredRequest) {
|
|
98
|
+
const query = await GetPlatformMembershipsEndpoint.buildQuery(requestQuery);
|
|
99
|
+
|
|
100
|
+
let data: MemberPlatformMembership[];
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
data = await query.fetch();
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (error.message.includes('ER_QUERY_TIMEOUT')) {
|
|
107
|
+
throw new SimpleError({
|
|
108
|
+
code: 'timeout',
|
|
109
|
+
message: 'Query took too long',
|
|
110
|
+
human: $t(`%Cv`),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const memberIds = Formatter.uniqueArray(data.map(d => d.memberId));
|
|
117
|
+
const organizationIds = Formatter.uniqueArray(data.map(d => d.organizationId));
|
|
118
|
+
const members = await Member.getByIDs(...memberIds);
|
|
119
|
+
const organizations = await Organization.getByIDs(...organizationIds);
|
|
120
|
+
|
|
121
|
+
const results: PlatformMembership[] = [];
|
|
122
|
+
|
|
123
|
+
for (const model of data) {
|
|
124
|
+
const member = members.find(m => m.id === model.memberId);
|
|
125
|
+
if (!member) {
|
|
126
|
+
throw new SimpleError({
|
|
127
|
+
code: 'not_found',
|
|
128
|
+
message: 'Member not found',
|
|
129
|
+
human: $t(`Het lid dat bij de aansluiting hoort is niet gevonden.`),
|
|
130
|
+
statusCode: 404,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const organization = organizations.find(o => o.id === model.organizationId);
|
|
135
|
+
if (!organization) {
|
|
136
|
+
throw new SimpleError({
|
|
137
|
+
code: 'not_found',
|
|
138
|
+
message: 'Organization not found',
|
|
139
|
+
human: $t(`De vereniging die bij de aansluiting hoort is niet gevonden.`),
|
|
140
|
+
statusCode: 404,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
results.push(PlatformMembership.create({
|
|
145
|
+
...model,
|
|
146
|
+
member: PlatformMembershiMemberDetails.create(member),
|
|
147
|
+
organization: PlatformMembershipOrganizationDetails.create(organization)
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
let next: LimitedFilteredRequest | undefined;
|
|
152
|
+
|
|
153
|
+
if (results.length >= requestQuery.limit) {
|
|
154
|
+
const lastObject = results[results.length - 1];
|
|
155
|
+
const nextFilter = getSortFilter(lastObject, sorters, requestQuery.sort);
|
|
156
|
+
|
|
157
|
+
next = new LimitedFilteredRequest({
|
|
158
|
+
filter: requestQuery.filter,
|
|
159
|
+
pageFilter: nextFilter,
|
|
160
|
+
sort: requestQuery.sort,
|
|
161
|
+
limit: requestQuery.limit,
|
|
162
|
+
search: requestQuery.search,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
if (JSON.stringify(nextFilter) === JSON.stringify(requestQuery.pageFilter)) {
|
|
166
|
+
console.error('Found infinite loading loop for', requestQuery);
|
|
167
|
+
next = undefined;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return new PaginatedResponse<PlatformMembership[], LimitedFilteredRequest>({
|
|
172
|
+
results,
|
|
173
|
+
next,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async handle(request: DecodedRequest<Params, Query, Body>) {
|
|
178
|
+
await Context.authenticate();
|
|
179
|
+
|
|
180
|
+
if (!Context.auth.hasPlatformFullAccess()) {
|
|
181
|
+
throw Context.auth.error();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const maxLimit = 1000;
|
|
185
|
+
|
|
186
|
+
if (request.query.limit > maxLimit) {
|
|
187
|
+
throw new SimpleError({
|
|
188
|
+
code: 'invalid_field',
|
|
189
|
+
field: 'limit',
|
|
190
|
+
message: 'Limit can not be more than ' + maxLimit,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (request.query.limit < 1) {
|
|
195
|
+
throw new SimpleError({
|
|
196
|
+
code: 'invalid_field',
|
|
197
|
+
field: 'limit',
|
|
198
|
+
message: 'Limit can not be less than 1',
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return new Response(
|
|
203
|
+
await GetPlatformMembershipsEndpoint.buildData(request.query),
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -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,5 +1,6 @@
|
|
|
1
1
|
import { Request } from '@simonbackx/simple-endpoints';
|
|
2
|
-
import {
|
|
2
|
+
import type { RegistrationPeriod} from '@stamhoofd/models';
|
|
3
|
+
import { EventFactory, GroupFactory, MemberFactory, OrganizationFactory, RegistrationFactory, RegistrationPeriodFactory, Token, UserFactory } from '@stamhoofd/models';
|
|
3
4
|
import { AccessRight, EventMeta, GroupType, LimitedFilteredRequest, NamedObject, PermissionLevel, PermissionRoleDetailed, Permissions, PermissionsResourceType, ResourcePermissions } from '@stamhoofd/structures';
|
|
4
5
|
import { STExpect, TestUtils } from '@stamhoofd/test-utils';
|
|
5
6
|
import { testServer } from '../../../../tests/helpers/TestServer.js';
|
|
@@ -1,11 +1,14 @@
|
|
|
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 { Group, Member, Platform, Registration } from '@stamhoofd/models';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import type { SQLExpression, SQLSortDefinitions} from '@stamhoofd/sql';
|
|
7
|
+
import { SQL, SQLSelect, applySQLSorter, compileToSQLFilter } from '@stamhoofd/sql';
|
|
8
|
+
import type { CountFilteredRequest, RegistrationWithMemberBlob, StamhoofdFilter, RegistrationsBlob } from '@stamhoofd/structures';
|
|
9
|
+
import { GroupType, LimitedFilteredRequest, PaginatedResponse, PermissionLevel, assertSort } from '@stamhoofd/structures';
|
|
7
10
|
|
|
8
|
-
import { SQLResultNamespacedRow } from '@simonbackx/simple-database';
|
|
11
|
+
import type { SQLResultNamespacedRow } from '@simonbackx/simple-database';
|
|
9
12
|
import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructures.js';
|
|
10
13
|
import { Context } from '../../../helpers/Context.js';
|
|
11
14
|
import { LimitedFilteredRequestHelper } from '../../../helpers/LimitedFilteredRequestHelper.js';
|
|
@@ -135,7 +138,7 @@ export class GetRegistrationsEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
135
138
|
if (groupIds.length === 0) {
|
|
136
139
|
throw Context.auth.error({
|
|
137
140
|
message: 'You must filter on a group of the organization you are trying to access',
|
|
138
|
-
human: $t(`
|
|
141
|
+
human: $t(`%15g`),
|
|
139
142
|
});
|
|
140
143
|
}
|
|
141
144
|
|
|
@@ -205,7 +208,7 @@ export class GetRegistrationsEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
205
208
|
throw new SimpleError({
|
|
206
209
|
code: 'timeout',
|
|
207
210
|
message: 'Query took too long',
|
|
208
|
-
human: $t(`
|
|
211
|
+
human: $t(`%Cv`),
|
|
209
212
|
});
|
|
210
213
|
}
|
|
211
214
|
throw error;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { DecodedRequest,
|
|
2
|
-
import {
|
|
1
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
3
|
+
import type { Payment } from '@stamhoofd/models';
|
|
4
|
+
import { BalanceItem, Member, Organization } from '@stamhoofd/models';
|
|
3
5
|
import { DetailedPayableBalanceCollection, DetailedPayableBalance } from '@stamhoofd/structures';
|
|
4
6
|
|
|
5
7
|
import { Formatter } from '@stamhoofd/utility';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { DecodedRequest,
|
|
1
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
2
3
|
import { Document, DocumentTemplate, Member } from '@stamhoofd/models';
|
|
3
|
-
import { Document as DocumentStruct
|
|
4
|
+
import type { Document as DocumentStruct} from '@stamhoofd/structures';
|
|
5
|
+
import { DocumentStatus } from '@stamhoofd/structures';
|
|
4
6
|
import { Sorter } from '@stamhoofd/utility';
|
|
5
7
|
|
|
6
8
|
import { Context } from '../../../helpers/Context.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { DecodedRequest,
|
|
1
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
2
3
|
import { Member } from '@stamhoofd/models';
|
|
3
|
-
import { MembersBlob } from '@stamhoofd/structures';
|
|
4
|
+
import type { MembersBlob } from '@stamhoofd/structures';
|
|
4
5
|
|
|
5
6
|
import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructures.js';
|
|
6
7
|
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 { CachedBalance, Organization } from '@stamhoofd/models';
|
|
3
4
|
import { PayableBalance, PayableBalanceCollection, ReceivableBalanceType } from '@stamhoofd/structures';
|
|
4
5
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Database } from '@simonbackx/simple-database';
|
|
2
2
|
import { PatchableArray, PatchMap } from '@simonbackx/simple-encoding';
|
|
3
|
-
import { Endpoint
|
|
3
|
+
import type { Endpoint} from '@simonbackx/simple-endpoints';
|
|
4
|
+
import { Request } from '@simonbackx/simple-endpoints';
|
|
4
5
|
import { GroupFactory, Member, MemberFactory, OrganizationFactory, Platform, RegistrationFactory, Token, UserFactory } from '@stamhoofd/models';
|
|
5
|
-
import {
|
|
6
|
+
import type { PatchAnswers} from '@stamhoofd/structures';
|
|
7
|
+
import { MemberDetails, MemberWithRegistrationsBlob, OrganizationMetaData, OrganizationRecordsConfiguration, Parent, PermissionLevel, RecordCategory, RecordSettings, RecordTextAnswer, TranslatedString, UitpasNumberDetails, UitpasSocialTariff, UitpasSocialTariffStatus } from '@stamhoofd/structures';
|
|
6
8
|
import { STExpect, TestUtils } from '@stamhoofd/test-utils';
|
|
7
9
|
import { testServer } from '../../../../tests/helpers/TestServer.js';
|
|
8
10
|
import { initUitpasApi } from '../../../../tests/init/index.js';
|
|
@@ -540,7 +542,7 @@ describe('Endpoint.PatchUserMembersEndpoint', () => {
|
|
|
540
542
|
expect(result.body.members[0].details.uitpasNumberDetails?.uitpasNumber).toEqual('0900011354819');
|
|
541
543
|
expect(result.body.members[0].details.uitpasNumberDetails?.socialTariff?.status).toEqual(UitpasSocialTariffStatus.Active);
|
|
542
544
|
expect(result.body.members[0].details.uitpasNumberDetails?.socialTariff?.updatedAt.getTime()).not.toEqual(new Date(2030, 0, 1).getTime());
|
|
543
|
-
expect(result.body.members[0].details.uitpasNumberDetails?.socialTariff?.endDate).
|
|
545
|
+
expect(result.body.members[0].details.uitpasNumberDetails?.socialTariff?.endDate).toBeInstanceOf(Date);
|
|
544
546
|
});
|
|
545
547
|
|
|
546
548
|
test('Should throw if invalid uitpas number', async () => {
|