@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
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { OneToManyRelation } from '@simonbackx/simple-database';
|
|
2
|
-
import { AutoEncoderPatchType, ConvertArrayToPatchableArray, Decoder,
|
|
3
|
-
import {
|
|
1
|
+
import type { OneToManyRelation } from '@simonbackx/simple-database';
|
|
2
|
+
import type { AutoEncoderPatchType, ConvertArrayToPatchableArray, Decoder, PatchableArrayAutoEncoder } from '@simonbackx/simple-encoding';
|
|
3
|
+
import { isEmptyPatch, isPatchableArray, PatchableArray, PatchableArrayDecoder, StringDecoder } from '@simonbackx/simple-encoding';
|
|
4
|
+
import type { DecodedRequest, Request } from '@simonbackx/simple-endpoints';
|
|
5
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
4
6
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
+
import type { MemberWithUsersRegistrationsAndGroups, Registration } from '@stamhoofd/models';
|
|
8
|
+
import { AuditLog, BalanceItem, Document, Group, Member, MemberFactory, MemberPlatformMembership, MemberResponsibilityRecord, mergeTwoMembers, Organization, Platform, RateLimiter, RegistrationPeriod, User } from '@stamhoofd/models';
|
|
9
|
+
import type { MemberResponsibility, MembersBlob } from '@stamhoofd/structures';
|
|
10
|
+
import { AuditLogReplacement, AuditLogReplacementType, AuditLogSource, AuditLogType, EmergencyContact, GroupType, MemberDetails, MemberWithRegistrationsBlob, Parent, PermissionLevel, PlatformMembershipTypeBehaviour, SetupStepType } from '@stamhoofd/structures';
|
|
7
11
|
import { Formatter } from '@stamhoofd/utility';
|
|
8
12
|
|
|
9
13
|
import { Email } from '@stamhoofd/email';
|
|
@@ -56,6 +60,18 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
56
60
|
return [false];
|
|
57
61
|
}
|
|
58
62
|
|
|
63
|
+
private static throwDuplicateMemberNumberError(error: unknown): never {
|
|
64
|
+
if (error && typeof error === 'object' && 'code' in error && error.code === 'ER_DUP_ENTRY' && 'message' in error && typeof error.message === 'string' && error.message.includes('memberNumber')) {
|
|
65
|
+
throw new SimpleError({
|
|
66
|
+
code: 'invalid_field',
|
|
67
|
+
message: 'Member number already in use',
|
|
68
|
+
human: $t('%1Oe'),
|
|
69
|
+
field: 'details.memberNumber',
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
|
|
59
75
|
async handle(request: DecodedRequest<Params, Query, Body>) {
|
|
60
76
|
const organization = await Context.setOptionalOrganizationScope();
|
|
61
77
|
await Context.authenticate();
|
|
@@ -129,7 +145,12 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
129
145
|
}
|
|
130
146
|
}
|
|
131
147
|
|
|
132
|
-
|
|
148
|
+
try {
|
|
149
|
+
await member.save();
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
PatchOrganizationMembersEndpoint.throwDuplicateMemberNumberError(error);
|
|
153
|
+
}
|
|
133
154
|
members.push(member);
|
|
134
155
|
updateMembershipMemberIds.add(member.id);
|
|
135
156
|
|
|
@@ -148,9 +169,7 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
148
169
|
throw Context.auth.memberNotFoundOrNoAccess();
|
|
149
170
|
}
|
|
150
171
|
|
|
151
|
-
|
|
152
|
-
await PatchOrganizationMembersEndpoint.checkSecurityCode(member, securityCode, 'patch');
|
|
153
|
-
}
|
|
172
|
+
await PatchOrganizationMembersEndpoint.checkCanAccessMember(member, securityCode, 'patch');
|
|
154
173
|
|
|
155
174
|
patch = await Context.auth.filterMemberPatch(member, patch);
|
|
156
175
|
const originalDetails = member.details.clone();
|
|
@@ -202,7 +221,12 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
202
221
|
}
|
|
203
222
|
}
|
|
204
223
|
|
|
205
|
-
|
|
224
|
+
try {
|
|
225
|
+
await member.save();
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
PatchOrganizationMembersEndpoint.throwDuplicateMemberNumberError(error);
|
|
229
|
+
}
|
|
206
230
|
|
|
207
231
|
// If parents changed or emergeny contacts: fetch family and merge data
|
|
208
232
|
if (patch.details && (!isEmptyPatch(patch.details?.parents) || !isEmptyPatch(patch.details?.emergencyContacts))) {
|
|
@@ -732,8 +756,10 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
732
756
|
] }).catch(console.error);
|
|
733
757
|
}
|
|
734
758
|
|
|
759
|
+
const r = await AuthenticatedStructures.membersBlob(members);
|
|
760
|
+
|
|
735
761
|
return new Response(
|
|
736
|
-
|
|
762
|
+
r,
|
|
737
763
|
);
|
|
738
764
|
}
|
|
739
765
|
|
|
@@ -929,73 +955,98 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
929
955
|
}
|
|
930
956
|
}
|
|
931
957
|
|
|
932
|
-
static async checkSecurityCode(member: MemberWithUsersRegistrationsAndGroups, securityCode: string
|
|
933
|
-
|
|
934
|
-
|
|
958
|
+
private static async checkSecurityCode(member: MemberWithUsersRegistrationsAndGroups, securityCode: string) {
|
|
959
|
+
try {
|
|
960
|
+
securityCodeLimiter.track(member.details.name, 1);
|
|
935
961
|
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
Email.sendWebmaster({
|
|
942
|
-
subject: $t(`%E9`),
|
|
943
|
-
text: $t(`%EA`) + ' ' + member.details.name + ' ' + $t(`%1G`) + ' ' + member.id + ')' + '\n\n' + e.message + '\n\nStamhoofd',
|
|
944
|
-
});
|
|
962
|
+
catch (e) {
|
|
963
|
+
Email.sendWebmaster({
|
|
964
|
+
subject: $t(`%E9`),
|
|
965
|
+
text: $t(`%EA`) + ' ' + member.details.name + ' ' + $t(`%1G`) + ' ' + member.id + ')' + '\n\n' + e.message + '\n\nStamhoofd',
|
|
966
|
+
});
|
|
945
967
|
|
|
968
|
+
throw new SimpleError({
|
|
969
|
+
code: 'too_many_tries',
|
|
970
|
+
message: 'Too many securityCodes limited',
|
|
971
|
+
human: $t(`%EB`),
|
|
972
|
+
field: 'details.securityCode',
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
// Entered the security code, so we can link the user to the member
|
|
977
|
+
if (STAMHOOFD.environment !== 'development') {
|
|
978
|
+
if (!member.details.securityCode || securityCode !== member.details.securityCode) {
|
|
946
979
|
throw new SimpleError({
|
|
947
|
-
code: '
|
|
948
|
-
message: 'Too many securityCodes limited',
|
|
949
|
-
human: $t(`%EB`),
|
|
980
|
+
code: 'invalid_field',
|
|
950
981
|
field: 'details.securityCode',
|
|
982
|
+
message: 'Invalid security code',
|
|
983
|
+
human: Context.i18n.$t('%2i'),
|
|
984
|
+
statusCode: 400,
|
|
951
985
|
});
|
|
952
986
|
}
|
|
987
|
+
}
|
|
953
988
|
|
|
954
|
-
|
|
955
|
-
if (STAMHOOFD.environment !== 'development') {
|
|
956
|
-
if (!member.details.securityCode || securityCode !== member.details.securityCode) {
|
|
957
|
-
throw new SimpleError({
|
|
958
|
-
code: 'invalid_field',
|
|
959
|
-
field: 'details.securityCode',
|
|
960
|
-
message: 'Invalid security code',
|
|
961
|
-
human: Context.i18n.$t('%2i'),
|
|
962
|
-
statusCode: 400,
|
|
963
|
-
});
|
|
964
|
-
}
|
|
965
|
-
}
|
|
989
|
+
console.log('checkSecurityCode: security code is correct - for ' + member.id);
|
|
966
990
|
|
|
967
|
-
|
|
991
|
+
// Grant temporary access to this member without needing to enter the security code again
|
|
992
|
+
await Context.auth.temporarilyGrantMemberAccess(member, PermissionLevel.Full);
|
|
968
993
|
|
|
969
|
-
|
|
970
|
-
|
|
994
|
+
const log = new AuditLog();
|
|
995
|
+
|
|
996
|
+
// a member has multiple organizations, so this is difficult to determine - for now it is only visible in the admin panel
|
|
997
|
+
log.organizationId = member.organizationId;
|
|
971
998
|
|
|
972
|
-
|
|
999
|
+
log.type = AuditLogType.MemberSecurityCodeUsed;
|
|
1000
|
+
log.source = AuditLogSource.Anonymous;
|
|
973
1001
|
|
|
974
|
-
|
|
975
|
-
log.
|
|
1002
|
+
if (Context.user) {
|
|
1003
|
+
log.userId = Context.user.id;
|
|
1004
|
+
log.source = AuditLogSource.User;
|
|
1005
|
+
}
|
|
976
1006
|
|
|
977
|
-
|
|
978
|
-
|
|
1007
|
+
log.objectId = member.id;
|
|
1008
|
+
log.replacements = new Map([
|
|
1009
|
+
['m', AuditLogReplacement.create({
|
|
1010
|
+
value: member.details.name,
|
|
1011
|
+
type: AuditLogReplacementType.Member,
|
|
1012
|
+
id: member.id,
|
|
1013
|
+
})],
|
|
1014
|
+
]);
|
|
1015
|
+
await log.save();
|
|
1016
|
+
}
|
|
979
1017
|
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
1018
|
+
static async checkCanAccessMember(member: MemberWithUsersRegistrationsAndGroups, securityCode: string | null | undefined, type: 'put' | 'patch') {
|
|
1019
|
+
// do not check security code for user mode organization (throw error if not allowed)
|
|
1020
|
+
if (STAMHOOFD.userMode === 'organization') {
|
|
1021
|
+
if ((type === 'put' && await member.isSafeToMergeDuplicateWithoutSecurityCode()) || await Context.auth.canAccessMember(member, PermissionLevel.Write)) {
|
|
1022
|
+
console.log('checkSecurityCode: allowed for ' + member.id);
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
if (type === 'patch') {
|
|
1027
|
+
throw Context.auth.memberNotFoundOrNoAccess();
|
|
983
1028
|
}
|
|
984
1029
|
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1030
|
+
throw new SimpleError({
|
|
1031
|
+
code: 'known_member_missing_rights',
|
|
1032
|
+
message: 'Creating known member without sufficient access rights',
|
|
1033
|
+
// different message for userMode organization because security codes are not available in that mode
|
|
1034
|
+
human: $t(`%1Oz`, { member: member.details.firstName }),
|
|
1035
|
+
statusCode: 400,
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
if ((type === 'put' && await member.isSafeToMergeDuplicateWithoutSecurityCode()) || await Context.auth.canAccessMember(member, PermissionLevel.Write)) {
|
|
1040
|
+
console.log('checkSecurityCode: without security code: allowed for ' + member.id);
|
|
1041
|
+
}
|
|
1042
|
+
else if (securityCode) {
|
|
1043
|
+
await this.checkSecurityCode(member, securityCode);
|
|
994
1044
|
}
|
|
995
1045
|
else {
|
|
996
1046
|
if (type === 'patch') {
|
|
997
1047
|
throw Context.auth.memberNotFoundOrNoAccess();
|
|
998
1048
|
}
|
|
1049
|
+
|
|
999
1050
|
throw new SimpleError({
|
|
1000
1051
|
code: 'known_member_missing_rights',
|
|
1001
1052
|
message: 'Creating known member without sufficient access rights',
|
|
@@ -1027,7 +1078,11 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
1027
1078
|
// Check for duplicates and prevent creating a duplicate member by a user
|
|
1028
1079
|
const duplicate = await this.findExistingMember(member);
|
|
1029
1080
|
if (duplicate) {
|
|
1030
|
-
|
|
1081
|
+
console.error('duplicate detection');
|
|
1082
|
+
console.error(member.details.parents);
|
|
1083
|
+
console.error(duplicate.details.parents);
|
|
1084
|
+
|
|
1085
|
+
await this.checkCanAccessMember(duplicate, securityCode, type);
|
|
1031
1086
|
|
|
1032
1087
|
// Merge data
|
|
1033
1088
|
// NOTE: We use mergeTwoMembers instead of mergeMultipleMembers, because we should never safe 'member' , because that one does not exist in the database
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
2
|
-
import {
|
|
2
|
+
import type { StamhoofdFilter, WrapperFilter } from '@stamhoofd/structures';
|
|
3
|
+
import { FilterWrapperMarker, PermissionLevel, unwrapFilter } from '@stamhoofd/structures';
|
|
3
4
|
import { Context } from '../../../../helpers/Context.js';
|
|
4
5
|
|
|
5
6
|
export async function validateGroupFilter({ filter, permissionLevel, key }: { filter: StamhoofdFilter; permissionLevel: PermissionLevel; key: string | null }) {
|
|
@@ -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';
|
|
@@ -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';
|
|
@@ -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';
|
|
@@ -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
|
+
}
|