@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,7 +1,9 @@
|
|
|
1
1
|
import { PatchableArray, PatchMap, patchObject } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { Endpoint
|
|
2
|
+
import type { Endpoint} from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Request } from '@simonbackx/simple-endpoints';
|
|
3
4
|
import { EmailMocker } from '@stamhoofd/email';
|
|
4
|
-
import {
|
|
5
|
+
import type { User} from '@stamhoofd/models';
|
|
6
|
+
import { EmailTemplateFactory, EventFactory, EventNotification, EventNotificationFactory, EventNotificationTypeFactory, Organization, OrganizationFactory, Platform, RecordAnswerFactory, RecordCategoryFactory, RegistrationPeriod, RegistrationPeriodFactory, Token, UserFactory } from '@stamhoofd/models';
|
|
5
7
|
import { AccessRight, BaseOrganization, EmailTemplateType, Event, EventNotificationStatus, EventNotification as EventNotificationStruct, Permissions, PermissionsResourceType, RecordType, ResourcePermissions } from '@stamhoofd/structures';
|
|
6
8
|
import { STExpect, TestUtils } from '@stamhoofd/test-utils';
|
|
7
9
|
import { testServer } from '../../../../tests/helpers/TestServer.js';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { AutoEncoderPatchType, Decoder, PatchableArrayAutoEncoder
|
|
2
|
-
import {
|
|
1
|
+
import type { AutoEncoderPatchType, Decoder, PatchableArrayAutoEncoder} from '@simonbackx/simple-encoding';
|
|
2
|
+
import { PatchableArrayDecoder, patchObject, 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 { Event, EventNotification, Platform, RegistrationPeriod } from '@stamhoofd/models';
|
|
4
6
|
import { EmailTemplateType, EventNotificationStatus, EventNotification as EventNotificationStruct, PermissionLevel, RecordCategory } from '@stamhoofd/structures';
|
|
5
7
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PatchableArray } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { Endpoint
|
|
3
|
-
import {
|
|
2
|
+
import type { Endpoint} from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Request } from '@simonbackx/simple-endpoints';
|
|
4
|
+
import type { Organization, User} from '@stamhoofd/models';
|
|
5
|
+
import { EventFactory, OrganizationFactory, OrganizationRegistrationPeriodFactory, PlatformEventTypeFactory, RegistrationPeriodFactory, Token, UserFactory } from '@stamhoofd/models';
|
|
4
6
|
import { AccessRight, Event, Group, GroupSettings, GroupType, PermissionLevel, Permissions, PermissionsResourceType, ResourcePermissions, TranslatedString } from '@stamhoofd/structures';
|
|
5
7
|
import { STExpect, TestUtils } from '@stamhoofd/test-utils';
|
|
6
8
|
import { testServer } from '../../../../tests/helpers/TestServer.js';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { AutoEncoderPatchType, Decoder, PatchableArrayAutoEncoder
|
|
2
|
-
import {
|
|
1
|
+
import type { AutoEncoderPatchType, Decoder, PatchableArrayAutoEncoder} from '@simonbackx/simple-encoding';
|
|
2
|
+
import { PatchableArrayDecoder, patchObject, 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 { Event, Group, OrganizationRegistrationPeriod, Platform, RegistrationPeriod, Webshop } from '@stamhoofd/models';
|
|
4
6
|
import { AuditLogSource, Event as EventStruct, Group as GroupStruct, GroupType, NamedObject, PermissionLevel } from '@stamhoofd/structures';
|
|
5
7
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { DecodedRequest,
|
|
1
|
+
import type { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import type { DecodedRequest, Request} from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Endpoint, Response } from '@simonbackx/simple-endpoints';
|
|
3
4
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
|
-
import {
|
|
5
|
+
import type { XlsxTransformerSheet} from '@stamhoofd/excel-writer';
|
|
6
|
+
import { ArchiverWriterAdapter, exportToExcel, XlsxWriter } from '@stamhoofd/excel-writer';
|
|
5
7
|
import { Platform, RateLimiter, sendEmailTemplate } from '@stamhoofd/models';
|
|
6
8
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
7
|
-
import {
|
|
9
|
+
import type { ExcelExportType, IPaginatedResponse, LimitedFilteredRequest} from '@stamhoofd/structures';
|
|
10
|
+
import { EmailTemplateType, ExcelExportRequest, ExcelExportResponse, Replacement, Version } from '@stamhoofd/structures';
|
|
8
11
|
import { sleep } from '@stamhoofd/utility';
|
|
9
12
|
import { Context } from '../../../helpers/Context.js';
|
|
10
13
|
import { fetchToAsyncIterator } from '../../../helpers/fetchToAsyncIterator.js';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
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';
|
|
5
|
+
import type { Readable } from 'node:stream';
|
|
4
6
|
import { Context } from '../../../helpers/Context.js';
|
|
5
7
|
import { FileCache } from '../../../helpers/FileCache.js';
|
|
6
8
|
import { Formatter } from '@stamhoofd/utility';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3'; // ES Modules import
|
|
2
|
-
import { DecodedRequest,
|
|
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 { File } from '@stamhoofd/structures';
|
|
5
6
|
import { Formatter } from '@stamhoofd/utility';
|
|
@@ -7,7 +8,8 @@ import formidable from 'formidable';
|
|
|
7
8
|
import { promises as fs } from 'fs';
|
|
8
9
|
import { v4 as uuidv4 } from 'uuid';
|
|
9
10
|
|
|
10
|
-
import {
|
|
11
|
+
import type { Decoder} from '@simonbackx/simple-encoding';
|
|
12
|
+
import { AutoEncoder, BooleanDecoder, field } from '@simonbackx/simple-encoding';
|
|
11
13
|
import { Context } from '../../../helpers/Context.js';
|
|
12
14
|
import { limiter } from './UploadImage.js';
|
|
13
15
|
import { Image } from '@stamhoofd/models';
|
|
@@ -121,7 +123,11 @@ export class UploadFile extends Endpoint<Params, Query, Body, ResponseBody> {
|
|
|
121
123
|
prefix += '/';
|
|
122
124
|
}
|
|
123
125
|
|
|
124
|
-
|
|
126
|
+
const envPrefix = STAMHOOFD.environment !== 'production' ? STAMHOOFD.environment : null;
|
|
127
|
+
|
|
128
|
+
if (envPrefix && envPrefix !== (STAMHOOFD.SPACES_PREFIX ?? '')) {
|
|
129
|
+
prefix += envPrefix + '/';
|
|
130
|
+
}
|
|
125
131
|
|
|
126
132
|
// Prepend user id to the file path
|
|
127
133
|
if (request.query.isPrivate && user) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Decoder} from '@simonbackx/simple-encoding';
|
|
2
|
+
import { AutoEncoder, BooleanDecoder, field, ObjectData } 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 { Image, RateLimiter } from '@stamhoofd/models';
|
|
5
7
|
import { Image as ImageStruct, ResolutionRequest } from '@stamhoofd/structures';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Request } from '@simonbackx/simple-endpoints';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { Organization, RegistrationPeriod} from '@stamhoofd/models';
|
|
3
|
+
import { GroupFactory, OrganizationFactory, OrganizationRegistrationPeriodFactory, RegistrationPeriodFactory, Token, UserFactory } from '@stamhoofd/models';
|
|
4
|
+
import type { StamhoofdFilter } from '@stamhoofd/structures';
|
|
5
|
+
import { BundleDiscountGroupPriceSettings, GroupPrice, GroupType, LimitedFilteredRequest } from '@stamhoofd/structures';
|
|
4
6
|
import { STExpect, TestUtils } from '@stamhoofd/test-utils';
|
|
5
7
|
import { testServer } from '../../../../tests/helpers/TestServer.js';
|
|
6
8
|
import { initAdmin, initBundleDiscount, initPlatformAdmin } from '../../../../tests/init/index.js';
|
|
@@ -1,10 +1,13 @@
|
|
|
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 { CountFilteredRequest, Group as GroupStruct, StamhoofdFilter } from '@stamhoofd/structures';
|
|
4
|
+
import { assertSort, getSortFilter, LimitedFilteredRequest, PaginatedResponse } from '@stamhoofd/structures';
|
|
3
5
|
|
|
4
|
-
import { Decoder } from '@simonbackx/simple-encoding';
|
|
6
|
+
import type { Decoder } from '@simonbackx/simple-encoding';
|
|
5
7
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
6
8
|
import { Group } from '@stamhoofd/models';
|
|
7
|
-
import {
|
|
9
|
+
import type { SQLFilterDefinitions, SQLSortDefinitions } from '@stamhoofd/sql';
|
|
10
|
+
import { applySQLSorter, compileToSQLFilter } from '@stamhoofd/sql';
|
|
8
11
|
import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructures.js';
|
|
9
12
|
import { Context } from '../../../helpers/Context.js';
|
|
10
13
|
import { groupFilterCompilers } from '../../../sql-filters/groups.js';
|
|
@@ -1,7 +1,9 @@
|
|
|
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 { MemberWithUsersRegistrationsAndGroups } from '@stamhoofd/models';
|
|
4
|
+
import { Member } from '@stamhoofd/models';
|
|
3
5
|
|
|
4
|
-
import { MembersBlob } from '@stamhoofd/structures';
|
|
6
|
+
import type { MembersBlob } from '@stamhoofd/structures';
|
|
5
7
|
import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructures.js';
|
|
6
8
|
import { Context } from '../../../helpers/Context.js';
|
|
7
9
|
type Params = { id: string };
|
|
@@ -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,7 @@
|
|
|
1
|
-
import { Endpoint
|
|
2
|
-
import {
|
|
1
|
+
import type { Endpoint} from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { Request } from '@simonbackx/simple-endpoints';
|
|
3
|
+
import type { RegistrationPeriod} from '@stamhoofd/models';
|
|
4
|
+
import { EventFactory, GroupFactory, MemberFactory, OrganizationFactory, RecordCategoryFactory, RegistrationFactory, RegistrationPeriodFactory, Token, UserFactory } from '@stamhoofd/models';
|
|
3
5
|
import { AccessRight, EventMeta, GroupType, LimitedFilteredRequest, NamedObject, PermissionLevel, PermissionRoleDetailed, Permissions, PermissionsResourceType, RecordAnswer, RecordTextAnswer, RecordType, ResourcePermissions } from '@stamhoofd/structures';
|
|
4
6
|
import { STExpect, TestUtils } from '@stamhoofd/test-utils';
|
|
5
7
|
import { GetMembersEndpoint } from './GetMembersEndpoint.js';
|
|
@@ -1,12 +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 } from '@stamhoofd/models';
|
|
5
6
|
import { SQL, applySQLSorter, compileToSQLFilter } from '@stamhoofd/sql';
|
|
6
|
-
import { CountFilteredRequest,
|
|
7
|
+
import type { CountFilteredRequest, MembersBlob, StamhoofdFilter } from '@stamhoofd/structures';
|
|
8
|
+
import { GroupType, LimitedFilteredRequest, PaginatedResponse, PermissionLevel, assertSort, getSortFilter } from '@stamhoofd/structures';
|
|
9
|
+
import type { CountryCode } from '@stamhoofd/types/Country';
|
|
10
|
+
import { Country } from '@stamhoofd/types/Country';
|
|
7
11
|
import { DataValidator } from '@stamhoofd/utility';
|
|
8
|
-
|
|
9
|
-
import { SQLResultNamespacedRow } from '@simonbackx/simple-database';
|
|
10
12
|
import parsePhoneNumber from 'libphonenumber-js/max';
|
|
11
13
|
import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructures.js';
|
|
12
14
|
import { Context } from '../../../helpers/Context.js';
|
|
@@ -202,7 +204,7 @@ export class GetMembersEndpoint extends Endpoint<Params, Query, Body, ResponseBo
|
|
|
202
204
|
}
|
|
203
205
|
|
|
204
206
|
// Is lidnummer?
|
|
205
|
-
if (!searchFilter && (search.match(
|
|
207
|
+
if (!searchFilter && (search.match(/^\d{4}-\d{6}-\d{1,2}$/) || search.match(/^\d{9,10}$/))) {
|
|
206
208
|
searchFilter = {
|
|
207
209
|
memberNumber: {
|
|
208
210
|
$eq: search,
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { Database } from '@simonbackx/simple-database';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Column, Database } from '@simonbackx/simple-database';
|
|
2
|
+
import type { PatchableArrayAutoEncoder } from '@simonbackx/simple-encoding';
|
|
3
|
+
import { PatchableArray, PatchMap } from '@simonbackx/simple-encoding';
|
|
4
|
+
import type { Endpoint } from '@simonbackx/simple-endpoints';
|
|
5
|
+
import { Request } from '@simonbackx/simple-endpoints';
|
|
4
6
|
import { GroupFactory, Member, MemberFactory, OrganizationFactory, OrganizationTagFactory, Platform, RegistrationFactory, Token, UserFactory } from '@stamhoofd/models';
|
|
5
|
-
import {
|
|
7
|
+
import { SQL } from '@stamhoofd/sql';
|
|
8
|
+
import type { PatchAnswers } from '@stamhoofd/structures';
|
|
9
|
+
import { Address, EmergencyContact, MemberDetails, MemberWithRegistrationsBlob, OrganizationMetaData, OrganizationRecordsConfiguration, Parent, PermissionLevel, Permissions, PermissionsResourceType, RecordCategory, RecordSettings, RecordTextAnswer, ResourcePermissions, ReviewTime, ReviewTimes, TranslatedString, UitpasNumberDetails, UitpasSocialTariff, UitpasSocialTariffStatus, Version } from '@stamhoofd/structures';
|
|
6
10
|
import { STExpect, TestUtils } from '@stamhoofd/test-utils';
|
|
11
|
+
import { Country } from '@stamhoofd/types/Country';
|
|
7
12
|
import { testServer } from '../../../../tests/helpers/TestServer.js';
|
|
8
13
|
import { initUitpasApi } from '../../../../tests/init/index.js';
|
|
9
14
|
import { PatchOrganizationMembersEndpoint } from './PatchOrganizationMembersEndpoint.js';
|
|
@@ -28,7 +33,7 @@ describe('Endpoint.PatchOrganizationMembersEndpoint', () => {
|
|
|
28
33
|
});
|
|
29
34
|
|
|
30
35
|
describe('Duplicate members', () => {
|
|
31
|
-
test('The security code should be a requirement', async () => {
|
|
36
|
+
test('The security code should be a requirement in userMode platform', async () => {
|
|
32
37
|
const organization = await new OrganizationFactory({ }).create();
|
|
33
38
|
const user = await new UserFactory({
|
|
34
39
|
permissions: Permissions.create({ level: PermissionLevel.Full }),
|
|
@@ -61,6 +66,192 @@ describe('Endpoint.PatchOrganizationMembersEndpoint', () => {
|
|
|
61
66
|
.toThrow(STExpect.errorWithCode('known_member_missing_rights'));
|
|
62
67
|
});
|
|
63
68
|
|
|
69
|
+
test('Should throw if duplicate member without rights in userMode organization - put', async () => {
|
|
70
|
+
TestUtils.setEnvironment('userMode', 'organization');
|
|
71
|
+
const organization = await new OrganizationFactory({ }).create();
|
|
72
|
+
|
|
73
|
+
const resources = new Map();
|
|
74
|
+
|
|
75
|
+
// Give read permission to the group
|
|
76
|
+
resources.set(
|
|
77
|
+
PermissionsResourceType.Groups, new Map([[
|
|
78
|
+
'id-does-not-matter',
|
|
79
|
+
ResourcePermissions.create({
|
|
80
|
+
level: PermissionLevel.Write,
|
|
81
|
+
}),
|
|
82
|
+
]]),
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const user = await new UserFactory({
|
|
86
|
+
permissions: Permissions.create({ level: PermissionLevel.None, resources }),
|
|
87
|
+
organization, // since we are in platform mode, this will only set the permissions for this organization
|
|
88
|
+
}).create();
|
|
89
|
+
|
|
90
|
+
const existingMember = await new MemberFactory({
|
|
91
|
+
firstName,
|
|
92
|
+
lastName,
|
|
93
|
+
birthDay,
|
|
94
|
+
generateData: true,
|
|
95
|
+
// should be member of the same organization
|
|
96
|
+
organization
|
|
97
|
+
}).create();
|
|
98
|
+
|
|
99
|
+
const token = await Token.createToken(user);
|
|
100
|
+
|
|
101
|
+
const arr: Body = new PatchableArray();
|
|
102
|
+
const put = MemberWithRegistrationsBlob.create({
|
|
103
|
+
details: MemberDetails.create({
|
|
104
|
+
firstName,
|
|
105
|
+
lastName,
|
|
106
|
+
birthDay: new Date(existingMember.details.birthDay!.getTime() + 1),
|
|
107
|
+
}),
|
|
108
|
+
});
|
|
109
|
+
arr.addPut(put);
|
|
110
|
+
|
|
111
|
+
const request = Request.buildJson('PATCH', baseUrl, organization.getApiHost(), arr);
|
|
112
|
+
request.headers.authorization = 'Bearer ' + token.accessToken;
|
|
113
|
+
await expect(testServer.test(endpoint, request))
|
|
114
|
+
.rejects
|
|
115
|
+
.toThrow(STExpect.errorWithCode('known_member_missing_rights'));
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('Should throw if duplicate member without rights in userMode organization - patch', async () => {
|
|
119
|
+
TestUtils.setEnvironment('userMode', 'organization');
|
|
120
|
+
const organization = await new OrganizationFactory({ }).create();
|
|
121
|
+
|
|
122
|
+
const resources = new Map();
|
|
123
|
+
|
|
124
|
+
const group = await new GroupFactory({
|
|
125
|
+
organization,
|
|
126
|
+
}).create();
|
|
127
|
+
|
|
128
|
+
// Give read permission to the group
|
|
129
|
+
resources.set(
|
|
130
|
+
PermissionsResourceType.Groups, new Map([[
|
|
131
|
+
group.id,
|
|
132
|
+
ResourcePermissions.create({
|
|
133
|
+
level: PermissionLevel.Write,
|
|
134
|
+
}),
|
|
135
|
+
]]),
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const user = await new UserFactory({
|
|
139
|
+
permissions: Permissions.create({ level: PermissionLevel.None, resources }),
|
|
140
|
+
organization, // since we are in platform mode, this will only set the permissions for this organization
|
|
141
|
+
}).create();
|
|
142
|
+
|
|
143
|
+
// existing member
|
|
144
|
+
await new MemberFactory({
|
|
145
|
+
firstName,
|
|
146
|
+
lastName,
|
|
147
|
+
birthDay,
|
|
148
|
+
generateData: true,
|
|
149
|
+
// should be member of the same organization
|
|
150
|
+
organization
|
|
151
|
+
}).create();
|
|
152
|
+
|
|
153
|
+
const memberToPatch = await new MemberFactory({
|
|
154
|
+
firstName: 'otherName',
|
|
155
|
+
lastName,
|
|
156
|
+
birthDay,
|
|
157
|
+
generateData: true,
|
|
158
|
+
// should be member of the same organization
|
|
159
|
+
organization
|
|
160
|
+
}).create();
|
|
161
|
+
|
|
162
|
+
// Register this member
|
|
163
|
+
await new RegistrationFactory({
|
|
164
|
+
member: memberToPatch,
|
|
165
|
+
group,
|
|
166
|
+
}).create();
|
|
167
|
+
|
|
168
|
+
const token = await Token.createToken(user);
|
|
169
|
+
|
|
170
|
+
const arr: Body = new PatchableArray();
|
|
171
|
+
|
|
172
|
+
// create a patch that sets the firstName to the same as the existing member
|
|
173
|
+
const patch = MemberWithRegistrationsBlob.patch({
|
|
174
|
+
id: memberToPatch.id,
|
|
175
|
+
details: MemberDetails.patch({
|
|
176
|
+
firstName
|
|
177
|
+
})
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
arr.addPatch(patch);
|
|
181
|
+
|
|
182
|
+
const request = Request.buildJson('PATCH', baseUrl, organization.getApiHost(), arr);
|
|
183
|
+
request.headers.authorization = 'Bearer ' + token.accessToken;
|
|
184
|
+
await expect(testServer.test(endpoint, request))
|
|
185
|
+
.rejects
|
|
186
|
+
.toThrow(STExpect.errorWithCode('not_found'));
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test('Should be able to create duplicate from another organization in userMode organization', async () => {
|
|
190
|
+
TestUtils.setEnvironment('userMode', 'organization');
|
|
191
|
+
const organization = await new OrganizationFactory({ }).create();
|
|
192
|
+
const otherOrganization = await new OrganizationFactory({ }).create();
|
|
193
|
+
|
|
194
|
+
const resources = new Map();
|
|
195
|
+
|
|
196
|
+
// Give read permission to the group
|
|
197
|
+
resources.set(
|
|
198
|
+
PermissionsResourceType.Groups, new Map([[
|
|
199
|
+
'id-does-not-matter',
|
|
200
|
+
ResourcePermissions.create({
|
|
201
|
+
level: PermissionLevel.Write,
|
|
202
|
+
}),
|
|
203
|
+
]]),
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
const user = await new UserFactory({
|
|
207
|
+
permissions: Permissions.create({ level: PermissionLevel.None, resources }),
|
|
208
|
+
organization, // since we are in platform mode, this will only set the permissions for this organization
|
|
209
|
+
}).create();
|
|
210
|
+
|
|
211
|
+
const existingMember = await new MemberFactory({
|
|
212
|
+
firstName,
|
|
213
|
+
lastName,
|
|
214
|
+
birthDay,
|
|
215
|
+
generateData: true,
|
|
216
|
+
// member of other organization
|
|
217
|
+
organization: otherOrganization,
|
|
218
|
+
details: MemberDetails.create({
|
|
219
|
+
email: 'existing@test.be'
|
|
220
|
+
})
|
|
221
|
+
}).create();
|
|
222
|
+
|
|
223
|
+
const token = await Token.createToken(user);
|
|
224
|
+
|
|
225
|
+
const arr: Body = new PatchableArray();
|
|
226
|
+
const newBirthDay = new Date(existingMember.details.birthDay!.getTime() + 1);
|
|
227
|
+
const put = MemberWithRegistrationsBlob.create({
|
|
228
|
+
details: MemberDetails.create({
|
|
229
|
+
firstName,
|
|
230
|
+
lastName,
|
|
231
|
+
birthDay: newBirthDay,
|
|
232
|
+
email: 'anewemail@example.com',
|
|
233
|
+
}),
|
|
234
|
+
});
|
|
235
|
+
arr.addPut(put);
|
|
236
|
+
|
|
237
|
+
const request = Request.buildJson('PATCH', baseUrl, organization.getApiHost(), arr);
|
|
238
|
+
request.headers.authorization = 'Bearer ' + token.accessToken;
|
|
239
|
+
const response = await testServer.test(endpoint, request);
|
|
240
|
+
expect(response.status).toBe(200);
|
|
241
|
+
|
|
242
|
+
// Check id of the returned memeber does not match the existing member (should not merge)
|
|
243
|
+
expect(response.body.members.length).toBe(1);
|
|
244
|
+
expect(response.body.members[0].id).not.toBe(existingMember.id);
|
|
245
|
+
|
|
246
|
+
// Check data matches the original data + changes from the put
|
|
247
|
+
const member = response.body.members[0];
|
|
248
|
+
expect(member.details.firstName).toBe(firstName);
|
|
249
|
+
expect(member.details.lastName).toBe(lastName);
|
|
250
|
+
expect(member.details.birthDay).toEqual(newBirthDay);
|
|
251
|
+
expect(member.details.email).toBe('anewemail@example.com'); // this has been merged
|
|
252
|
+
expect(member.details.alternativeEmails).toHaveLength(0);
|
|
253
|
+
});
|
|
254
|
+
|
|
64
255
|
test('The security code is not a requirement for members without additional data', async () => {
|
|
65
256
|
const organization = await new OrganizationFactory({ }).create();
|
|
66
257
|
const user = await new UserFactory({
|
|
@@ -124,14 +315,35 @@ describe('Endpoint.PatchOrganizationMembersEndpoint', () => {
|
|
|
124
315
|
firstName: 'Jane',
|
|
125
316
|
lastName: 'Doe',
|
|
126
317
|
email: 'jane.doe@example.com',
|
|
318
|
+
createdAt: new Date(500),
|
|
127
319
|
}),
|
|
128
320
|
],
|
|
129
321
|
});
|
|
130
322
|
|
|
323
|
+
console.error(details.parents);
|
|
324
|
+
Column.setJSONVersion(Version);
|
|
325
|
+
|
|
131
326
|
const existingMember = await new MemberFactory({
|
|
132
327
|
birthDay,
|
|
133
328
|
details,
|
|
134
329
|
}).create();
|
|
330
|
+
console.error(existingMember.details.parents);
|
|
331
|
+
console.error(existingMember.details.parents[0].encode({ version: Version }));
|
|
332
|
+
console.error(
|
|
333
|
+
MemberDetails.decodeField(
|
|
334
|
+
existingMember.details.encode({ version: Version }),
|
|
335
|
+
{ version: Version },
|
|
336
|
+
),
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
console.error(
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
const rawData = await SQL.select().from('members').where('id', existingMember.id).fetch();
|
|
343
|
+
console.error(rawData);
|
|
344
|
+
|
|
345
|
+
await existingMember.refresh();
|
|
346
|
+
console.error(existingMember.details.parents);
|
|
135
347
|
|
|
136
348
|
// Create a registration for this member
|
|
137
349
|
const group = await new GroupFactory({ organization }).create();
|
|
@@ -180,6 +392,45 @@ describe('Endpoint.PatchOrganizationMembersEndpoint', () => {
|
|
|
180
392
|
expect(member.details.parents.length).toBe(1);
|
|
181
393
|
expect(member.details.parents[0]).toEqual(existingMember.details.parents[0]);
|
|
182
394
|
});
|
|
395
|
+
|
|
396
|
+
test('Creating a member with duplicate member number throws invalid_field', async () => {
|
|
397
|
+
TestUtils.setEnvironment('userMode', 'organization');
|
|
398
|
+
|
|
399
|
+
const organization = await new OrganizationFactory({ }).create();
|
|
400
|
+
const user = await new UserFactory({
|
|
401
|
+
permissions: Permissions.create({ level: PermissionLevel.Full }),
|
|
402
|
+
organization,
|
|
403
|
+
}).create();
|
|
404
|
+
|
|
405
|
+
const existingMember = await new MemberFactory({
|
|
406
|
+
firstName: 'Existing',
|
|
407
|
+
lastName: 'Member',
|
|
408
|
+
birthDay,
|
|
409
|
+
generateData: false,
|
|
410
|
+
}).create();
|
|
411
|
+
existingMember.details.memberNumber = 'LID-100';
|
|
412
|
+
await existingMember.save();
|
|
413
|
+
|
|
414
|
+
const token = await Token.createToken(user);
|
|
415
|
+
|
|
416
|
+
const arr: Body = new PatchableArray();
|
|
417
|
+
const put = MemberWithRegistrationsBlob.create({
|
|
418
|
+
details: MemberDetails.create({
|
|
419
|
+
firstName: 'New',
|
|
420
|
+
lastName: 'Member',
|
|
421
|
+
birthDay: new Date('2015-01-01'),
|
|
422
|
+
memberNumber: 'LID-100',
|
|
423
|
+
}),
|
|
424
|
+
});
|
|
425
|
+
arr.addPut(put);
|
|
426
|
+
|
|
427
|
+
const request = Request.buildJson('PATCH', baseUrl, organization.getApiHost(), arr);
|
|
428
|
+
request.headers.authorization = 'Bearer ' + token.accessToken;
|
|
429
|
+
|
|
430
|
+
await expect(testServer.test(endpoint, request))
|
|
431
|
+
.rejects
|
|
432
|
+
.toThrow(STExpect.errorWithCode('invalid_field'));
|
|
433
|
+
});
|
|
183
434
|
});
|
|
184
435
|
|
|
185
436
|
describe('Permission checking', () => {
|
|
@@ -2936,7 +3187,7 @@ describe('Endpoint.PatchOrganizationMembersEndpoint', () => {
|
|
|
2936
3187
|
expect(result.body.members[0].details.uitpasNumberDetails?.uitpasNumber).toEqual('0900011354819');
|
|
2937
3188
|
expect(result.body.members[0].details.uitpasNumberDetails?.socialTariff?.status).toEqual(UitpasSocialTariffStatus.Active);
|
|
2938
3189
|
expect(result.body.members[0].details.uitpasNumberDetails?.socialTariff?.updatedAt.getTime()).not.toEqual(new Date(2030, 0, 1).getTime());
|
|
2939
|
-
expect(result.body.members[0].details.uitpasNumberDetails?.socialTariff?.endDate).
|
|
3190
|
+
expect(result.body.members[0].details.uitpasNumberDetails?.socialTariff?.endDate).toBeInstanceOf(Date);
|
|
2940
3191
|
});
|
|
2941
3192
|
|
|
2942
3193
|
test('Should throw if invalid uitpas number', async () => {
|