@stamhoofd/backend 2.115.1 → 2.117.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations.ts +1 -1
- package/package.json +10 -10
- package/src/audit-logs/DocumentTemplateLogger.ts +1 -1
- package/src/audit-logs/EmailAddressLogger.ts +1 -1
- package/src/audit-logs/EmailLogger.ts +1 -1
- package/src/audit-logs/EmailTemplateLogger.ts +1 -1
- package/src/audit-logs/EventLogger.ts +1 -1
- package/src/audit-logs/GroupLogger.ts +1 -1
- package/src/audit-logs/MemberLogger.ts +1 -1
- package/src/audit-logs/MemberPlatformMembershipLogger.ts +1 -1
- package/src/audit-logs/MemberResponsibilityRecordLogger.ts +1 -1
- package/src/audit-logs/ModelLogger.ts +27 -19
- package/src/audit-logs/OrderLogger.ts +1 -1
- package/src/audit-logs/OrganizationLogger.ts +23 -3
- package/src/audit-logs/OrganizationRegistrationPeriodLogger.ts +1 -1
- package/src/audit-logs/PaymentLogger.ts +1 -1
- package/src/audit-logs/PlatformLogger.ts +1 -1
- package/src/audit-logs/RegistrationLogger.ts +1 -1
- package/src/audit-logs/RegistrationPeriodLogger.ts +1 -1
- package/src/audit-logs/StripeAccountLogger.ts +1 -1
- package/src/audit-logs/UserLogger.ts +1 -1
- package/src/audit-logs/WebshopLogger.ts +1 -1
- package/src/audit-logs/init.ts +40 -0
- package/src/boot.ts +6 -4
- package/src/crons/amazon-ses.ts +1 -1
- package/src/crons/balance-emails.ts +1 -1
- package/src/crons/clearExcelCache.test.ts +1 -1
- package/src/crons/delete-archived-data.ts +47 -0
- package/src/crons/endFunctionsOfUsersWithoutRegistration.ts +1 -1
- package/src/crons/index.ts +1 -0
- package/src/crons.ts +3 -3
- package/src/debug.ts +230 -0
- package/src/email-recipient-loaders/documents.ts +1 -1
- package/src/email-recipient-loaders/members.ts +1 -1
- package/src/email-recipient-loaders/orders.ts +3 -3
- package/src/email-recipient-loaders/payments.ts +118 -353
- package/src/email-replacements/getEmailReplacementsForPayment.ts +321 -0
- package/src/endpoints/admin/members/ChargeMembersEndpoint.ts +9 -7
- package/src/endpoints/admin/memberships/ChargeMembershipsEndpoint.ts +2 -2
- package/src/endpoints/admin/memberships/GetChargeMembershipsSummaryEndpoint.ts +1 -1
- package/src/endpoints/admin/organizations/ChargeOrganizationsEndpoint.ts +16 -50
- package/src/endpoints/admin/organizations/GetOrganizationsCountEndpoint.ts +2 -2
- package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +4 -4
- package/src/endpoints/admin/organizations/PatchOrganizationsEndpoint.ts +21 -6
- package/src/endpoints/admin/registrations/ChargeRegistrationsEndpoint.ts +9 -7
- package/src/endpoints/auth/CreateAdminEndpoint.ts +2 -2
- package/src/endpoints/auth/CreateTokenEndpoint.test.ts +2 -2
- package/src/endpoints/auth/CreateTokenEndpoint.ts +1 -1
- package/src/endpoints/auth/DeleteTokenEndpoint.ts +1 -1
- package/src/endpoints/auth/DeleteUserEndpoint.ts +1 -1
- package/src/endpoints/auth/ForgotPasswordEndpoint.ts +1 -1
- package/src/endpoints/auth/GetOtherUserEndpoint.ts +2 -2
- package/src/endpoints/auth/GetUserEndpoint.test.ts +2 -2
- package/src/endpoints/auth/GetUserEndpoint.ts +2 -2
- package/src/endpoints/auth/OpenIDConnectAuthTokenEndpoint.ts +2 -2
- package/src/endpoints/auth/OpenIDConnectCallbackEndpoint.ts +2 -2
- package/src/endpoints/auth/OpenIDConnectStartEndpoint.ts +2 -2
- package/src/endpoints/auth/PatchUserEndpoint.ts +4 -4
- package/src/endpoints/auth/PollEmailVerificationEndpoint.ts +1 -1
- package/src/endpoints/auth/RetryEmailVerificationEndpoint.ts +1 -1
- package/src/endpoints/auth/SignupEndpoint.ts +1 -1
- package/src/endpoints/auth/VerifyEmailEndpoint.ts +1 -1
- package/src/endpoints/global/addresses/ValidateAddressEndpoint.ts +1 -1
- package/src/endpoints/global/audit-logs/GetAuditLogsEndpoint.ts +4 -4
- package/src/endpoints/global/billing/ActivatePackagesEndpoint.ts +191 -7
- package/src/endpoints/global/billing/DeactivatePackageEndpoint.ts +64 -0
- package/src/endpoints/global/email/GetAdminEmailsEndpoint.test.ts +2 -2
- package/src/endpoints/global/email/GetAdminEmailsEndpoint.ts +3 -3
- package/src/endpoints/global/email/GetEmailAddressEndpoint.ts +1 -1
- package/src/endpoints/global/email/GetEmailEndpoint.ts +1 -1
- package/src/endpoints/global/email/GetUserEmailsEndpoint.test.ts +2 -2
- package/src/endpoints/global/email/GetUserEmailsEndpoint.ts +3 -3
- package/src/endpoints/global/email/ManageEmailAddressEndpoint.ts +62 -16
- package/src/endpoints/global/email/PatchEmailEndpoint.test.ts +6 -6
- package/src/endpoints/global/email-recipients/GetEmailRecipientsCountEndpoint.ts +2 -2
- package/src/endpoints/global/email-recipients/GetEmailRecipientsEndpoint.test.ts +2 -2
- package/src/endpoints/global/email-recipients/GetEmailRecipientsEndpoint.ts +4 -4
- package/src/endpoints/global/email-recipients/RetryEmailRecipientEndpoint.ts +1 -1
- package/src/endpoints/global/email-recipients/helpers/validateEmailRecipientFilter.ts +1 -1
- package/src/endpoints/global/events/GetEventNotificationsCountEndpoint.ts +2 -2
- package/src/endpoints/global/events/GetEventNotificationsEndpoint.ts +4 -4
- package/src/endpoints/global/events/GetEventsEndpoint.ts +4 -4
- package/src/endpoints/global/events/PatchEventNotificationsEndpoint.test.ts +2 -2
- package/src/endpoints/global/events/PatchEventNotificationsEndpoint.ts +3 -3
- package/src/endpoints/global/events/PatchEventsEndpoint.test.ts +2 -2
- package/src/endpoints/global/events/PatchEventsEndpoint.ts +5 -5
- package/src/endpoints/global/files/ExportToExcelEndpoint.ts +4 -4
- package/src/endpoints/global/files/GetFileCache.ts +2 -2
- package/src/endpoints/global/files/UploadFile.ts +2 -2
- package/src/endpoints/global/files/UploadImage.ts +1 -1
- package/src/endpoints/global/groups/GetGroupsEndpoint.test.ts +3 -3
- package/src/endpoints/global/groups/GetGroupsEndpoint.ts +4 -4
- package/src/endpoints/global/members/GetMemberFamilyEndpoint.ts +4 -4
- package/src/endpoints/global/members/GetMembersEndpoint.test.ts +3 -3
- package/src/endpoints/global/members/GetMembersEndpoint.ts +4 -16
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +8 -7
- package/src/endpoints/global/members/helpers/validateGroupFilter.ts +1 -1
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.test.ts +2 -2
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.ts +23 -12
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.test.ts +2 -2
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.ts +1 -1
- package/src/endpoints/global/organizations/GetOrganizationFromUriEndpoint.ts +1 -1
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.test.ts +2 -2
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.ts +1 -1
- package/src/endpoints/global/payments/StripeWebhookEndpoint.ts +3 -3
- package/src/endpoints/global/platform/GetPlatformAdminsEndpoint.ts +1 -1
- package/src/endpoints/global/platform/GetPlatformEndpoint.test.ts +2 -2
- package/src/endpoints/global/platform/GetPlatformEndpoint.ts +1 -1
- package/src/endpoints/global/platform/PatchPlatformEnpoint.test.ts +2 -2
- package/src/endpoints/global/platform/PatchPlatformEnpoint.ts +7 -7
- package/src/endpoints/global/registration/GetRegistrationsEndpoint.test.ts +2 -2
- package/src/endpoints/global/registration/GetRegistrationsEndpoint.ts +1 -2
- package/src/endpoints/global/registration/GetUserDetailedPayableBalanceEndpoint.ts +2 -2
- package/src/endpoints/global/registration/GetUserDocumentsEndpoint.ts +2 -2
- package/src/endpoints/global/registration/GetUserMembersEndpoint.ts +2 -2
- package/src/endpoints/global/registration/GetUserPayableBalanceEndpoint.ts +2 -2
- package/src/endpoints/global/registration/RegisterMembersEndpoint.test.ts +2 -2
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +24 -389
- package/src/endpoints/global/registration-periods/GetRegistrationPeriodsEndpoint.ts +3 -3
- package/src/endpoints/global/registration-periods/PatchRegistrationPeriodsEndpoint.ts +2 -2
- package/src/endpoints/global/sso/GetSSOEndpoint.ts +2 -2
- package/src/endpoints/global/sso/SetSSOEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemEndpoint.ts +55 -0
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsCountEndpoint.ts +43 -0
- package/src/endpoints/organization/dashboard/balance-items/GetBalanceItemsEndpoint.ts +160 -0
- package/src/endpoints/organization/dashboard/{payments → balance-items}/PatchBalanceItemsEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/billing/GetOrganizationDetailedPayableBalanceEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/billing/GetOrganizationPayableBalanceEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/billing/GetPackagesEndpoint.test.ts +3 -3
- package/src/endpoints/organization/dashboard/billing/GetPackagesEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplateXML.ts +1 -1
- package/src/endpoints/organization/dashboard/documents/GetDocumentsCountEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/documents/PatchDocumentEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/email/CheckEmailBouncesEndpoint.ts +37 -6
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.test.ts +2 -2
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.test.ts +2 -2
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/invoices/PatchInvoicesEndpoint.ts +53 -0
- package/src/endpoints/organization/dashboard/mollie/CheckMollieEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/mollie/ConnectMollieEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/mollie/DisconnectMollieEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/mollie/GetMollieDashboardEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/nolt/CreateNoltTokenEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/organization/GetOrganizationArchivedGroups.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/GetOrganizationDeletedGroups.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/GetUitpasClientIdEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.test.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +12 -1
- package/src/endpoints/organization/dashboard/organization/SearchUitpasOrganizersEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/SetOrganizationDomainEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/organization/SetUitpasClientCredentialsEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/payments/GetPaymentsCountEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/payments/GetPaymentsEndpoint.ts +4 -4
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalanceEndpoint.ts +12 -12
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesCountEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/receivable-balances/GetReceivableBalancesEndpoint.ts +4 -4
- package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.test.ts +2 -2
- package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.ts +4 -4
- package/src/endpoints/organization/dashboard/registration-periods/MoveRegistrationPeriods.test.ts +2 -2
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.test.ts +2 -2
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/registration-periods/SetupStepReviewEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/stripe/ConnectStripeEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/stripe/DeleteStripeAccountEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountLinkEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountsEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/stripe/GetStripeLoginLinkEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/stripe/UpdateStripeAccountEndpoint.ts +3 -3
- package/src/endpoints/organization/dashboard/users/CreateApiUserEndpoint.test.ts +3 -3
- package/src/endpoints/organization/dashboard/users/CreateApiUserEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/users/DeleteUserEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/users/GetApiUsersEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/users/GetOrganizationAdminsEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/users/PatchApiUserEndpoint.test.ts +3 -3
- package/src/endpoints/organization/dashboard/users/PatchApiUserEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/CreateWebshopEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/DeleteWebshopEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/webshops/GetDiscountCodesEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersCountEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersEndpoint.ts +5 -5
- package/src/endpoints/organization/dashboard/webshops/GetWebshopTicketsEndpoint.ts +5 -5
- package/src/endpoints/organization/dashboard/webshops/GetWebshopUriAvailabilityEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/PatchDiscountCodesEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopTicketsEndpoint.ts +1 -1
- package/src/endpoints/organization/dashboard/webshops/SearchUitpasEventsEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/webshops/VerifyWebshopDomainEndpoint.ts +1 -1
- package/src/endpoints/organization/shared/ExchangePaymentEndpoint.ts +3 -3
- package/src/endpoints/organization/shared/GetDocumentHtml.ts +1 -1
- package/src/endpoints/organization/shared/GetPaymentEndpoint.ts +2 -2
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.test.ts +2 -2
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.ts +2 -2
- package/src/endpoints/organization/webshops/CheckWebshopDiscountCodesEndpoint.ts +1 -1
- package/src/endpoints/organization/webshops/GetOrderByPaymentEndpoint.ts +1 -1
- package/src/endpoints/organization/webshops/GetOrderEndpoint.ts +1 -1
- package/src/endpoints/organization/webshops/GetTicketsEndpoint.ts +1 -1
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.test.ts +2 -2
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.ts +2 -2
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.test.ts +4 -4
- package/src/excel-loaders/balance-items.ts +268 -0
- package/src/excel-loaders/event-notifications.ts +3 -3
- package/src/excel-loaders/index.ts +6 -5
- package/src/excel-loaders/organizations.ts +4 -4
- package/src/excel-loaders/payments.ts +11 -3
- package/src/excel-loaders/receivable-balances.ts +2 -2
- package/src/helpers/AddressValidator.test.ts +1 -1
- package/src/helpers/AddressValidator.ts +1 -1
- package/src/helpers/AdminPermissionChecker.ts +20 -17
- package/src/helpers/AuthenticatedStructures.ts +194 -109
- package/src/helpers/Context.ts +2 -0
- package/src/helpers/EmailResumer.ts +1 -1
- package/src/helpers/FlagMomentCleanup.ts +1 -1
- package/src/helpers/ForwardHandler.test.ts +1 -1
- package/src/helpers/ForwardHandler.ts +1 -1
- package/src/helpers/GlobalHelper.ts +4 -4
- package/src/helpers/GroupBuilder.ts +417 -0
- package/src/helpers/GroupedThrottledQueue.test.ts +1 -1
- package/src/helpers/GroupedThrottledQueue.ts +1 -1
- package/src/helpers/MemberUserSyncer.test.ts +1 -1
- package/src/helpers/MemberUserSyncer.ts +1 -1
- package/src/helpers/PeriodHelper.ts +5 -45
- package/src/helpers/ServiceFeeHelper.ts +5 -1
- package/src/helpers/SetupStepUpdater.ts +5 -4
- package/src/helpers/TagHelper.ts +1 -1
- package/src/helpers/ThrottledQueue.test.ts +1 -1
- package/src/helpers/ViesHelper.ts +9 -0
- package/src/helpers/email-html-helpers.ts +0 -41
- package/src/helpers/outstandingBalanceJoin.ts +3 -1
- package/src/middleware/ContextMiddleware.ts +1 -1
- package/src/seeds/1726572303-schedule-stock-updates.ts +1 -1
- package/src/seeds/1726847064-setup-steps.ts +1 -1
- package/src/seeds/1728928974-update-cached-outstanding-balance-from-items.ts +1 -1
- package/src/seeds/1740046783-update-membership.ts +1 -1
- package/src/seeds/1754560914-groups-prices.test.ts +1 -1
- package/src/seeds/1755876819-remove-duplicate-members.ts +1 -1
- package/src/seeds/1760702454-update-cached-outstanding-balance-from-items.ts +1 -1
- package/src/seeds/1761665607-sync-member-users.ts +1 -1
- package/src/seeds/data/default-email-templates.sql +1 -1
- package/src/seeds-temporary/1732117645-move-rrn.ts +1 -1
- package/src/services/AuditLogService.ts +1 -41
- package/src/services/BalanceItemPaymentService.ts +1 -1
- package/src/services/BalanceItemService.ts +12 -5
- package/src/services/EventNotificationService.ts +3 -3
- package/src/services/InvoiceService.ts +131 -17
- package/src/services/MemberRecordStore.ts +1 -1
- package/src/services/PaymentReallocationService.test.ts +9 -10
- package/src/services/PaymentReallocationService.ts +1 -1
- package/src/services/PaymentService.ts +560 -18
- package/src/services/PlatformMembershipService.ts +3 -3
- package/src/services/RegistrationService.ts +3 -3
- package/src/services/SSOService.ts +2 -2
- package/src/services/STPackageService.ts +241 -0
- package/src/services/uitpas/UitpasService.test.ts +1 -1
- package/src/sql-filters/balance-items.ts +56 -0
- package/src/sql-filters/emails.ts +1 -1
- package/src/sql-filters/event-notifications.ts +2 -2
- package/src/sql-filters/events.ts +51 -0
- package/src/sql-filters/members.ts +38 -2
- package/src/sql-filters/receivable-balances.ts +3 -3
- package/src/sql-filters/users.ts +10 -0
- package/src/sql-sorters/balance-items.ts +36 -0
- package/src/sql-sorters/document-templates.ts +2 -2
- package/src/sql-sorters/documents.ts +2 -2
- package/src/sql-sorters/event-notifications.ts +1 -1
- package/src/sql-sorters/members.ts +2 -2
- package/src/sql-sorters/orders.ts +2 -2
- package/src/sql-sorters/tickets.ts +2 -2
- package/tests/actions/patchOrganizationMember.ts +3 -3
- package/tests/actions/patchPaymentStatus.ts +3 -3
- package/tests/actions/patchUserMember.ts +2 -2
- package/tests/assertions/assertBalances.ts +1 -1
- package/tests/e2e/api-rate-limits.test.ts +3 -3
- package/tests/e2e/charge-members.test.ts +14 -14
- package/tests/e2e/documents.test.ts +8 -8
- package/tests/e2e/private-files.test.ts +4 -4
- package/tests/e2e/register.test.ts +10 -10
- package/tests/e2e/stock.test.ts +4 -4
- package/tests/e2e/tickets.test.ts +4 -4
- package/tests/helpers/TestServer.ts +2 -2
- package/tests/init/index.ts +7 -7
- package/tests/init/initAdmin.ts +1 -1
- package/src/endpoints/global/registration/GetPaymentRegistrations.ts +0 -67
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
2
2
|
import { LoginProviderType, OpenIDClientConfiguration } from '@stamhoofd/structures';
|
|
3
3
|
|
|
4
|
-
import { Context } from '../../../helpers/Context';
|
|
4
|
+
import { Context } from '../../../helpers/Context.js';
|
|
5
5
|
import { Platform } from '@stamhoofd/models';
|
|
6
6
|
import { AutoEncoder, Decoder, EnumDecoder, field } from '@simonbackx/simple-encoding';
|
|
7
|
-
import { SSOService } from '../../../services/SSOService';
|
|
7
|
+
import { SSOService } from '../../../services/SSOService.js';
|
|
8
8
|
|
|
9
9
|
type Params = Record<string, never>;
|
|
10
10
|
export class SSOQuery extends AutoEncoder {
|
|
@@ -2,9 +2,9 @@ import { AutoEncoderPatchType, Decoder } from '@simonbackx/simple-encoding';
|
|
|
2
2
|
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
3
3
|
import { OpenIDClientConfiguration } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
|
-
import { Context } from '../../../helpers/Context';
|
|
6
|
-
import { SSOService } from '../../../services/SSOService';
|
|
7
|
-
import { SSOQuery } from './GetSSOEndpoint';
|
|
5
|
+
import { Context } from '../../../helpers/Context.js';
|
|
6
|
+
import { SSOService } from '../../../services/SSOService.js';
|
|
7
|
+
import { SSOQuery } from './GetSSOEndpoint.js';
|
|
8
8
|
|
|
9
9
|
type Params = Record<string, never>;
|
|
10
10
|
type Query = SSOQuery;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { SimpleError } from '@simonbackx/simple-errors';
|
|
3
|
+
import { BalanceItem } from '@stamhoofd/models';
|
|
4
|
+
import { BalanceItemWithPayments } from '@stamhoofd/structures';
|
|
5
|
+
|
|
6
|
+
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures.js';
|
|
7
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
8
|
+
|
|
9
|
+
type Params = { id: string };
|
|
10
|
+
type Query = undefined;
|
|
11
|
+
type Body = undefined;
|
|
12
|
+
type ResponseBody = BalanceItemWithPayments;
|
|
13
|
+
|
|
14
|
+
export class GetBalanceItemEndpoint extends Endpoint<Params, Query, Body, ResponseBody> {
|
|
15
|
+
protected doesMatch(request: Request): [true, Params] | [false] {
|
|
16
|
+
if (request.method !== 'GET') {
|
|
17
|
+
return [false];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const params = Endpoint.parseParameters(request.url, '/balance-items/@id', { id: String });
|
|
21
|
+
|
|
22
|
+
if (params) {
|
|
23
|
+
return [true, params as Params];
|
|
24
|
+
}
|
|
25
|
+
return [false];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async handle(request: DecodedRequest<Params, Query, Body>) {
|
|
29
|
+
const organization = await Context.setOrganizationScope();
|
|
30
|
+
await Context.authenticate();
|
|
31
|
+
|
|
32
|
+
if (!await Context.auth.hasSomeAccess(organization.id)) {
|
|
33
|
+
throw Context.auth.error();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const balanceItem = await BalanceItem.getByID(request.params.id);
|
|
37
|
+
|
|
38
|
+
if (!balanceItem || balanceItem.organizationId !== organization.id) {
|
|
39
|
+
throw new SimpleError({
|
|
40
|
+
code: 'not_found',
|
|
41
|
+
statusCode: 404,
|
|
42
|
+
message: 'Balance item not found',
|
|
43
|
+
human: $t('7bc08947-2409-4a7c-b597-2d6d43884a96'),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!await Context.auth.canAccessBalanceItems([balanceItem])) {
|
|
48
|
+
throw Context.auth.error();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return new Response(
|
|
52
|
+
(await AuthenticatedStructures.balanceItemsWithPayments([balanceItem]))[0],
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { CountFilteredRequest, CountResponse } from '@stamhoofd/structures';
|
|
4
|
+
|
|
5
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
6
|
+
import { GetBalanceItemsEndpoint } from './GetBalanceItemsEndpoint.js';
|
|
7
|
+
|
|
8
|
+
type Params = Record<string, never>;
|
|
9
|
+
type Query = CountFilteredRequest;
|
|
10
|
+
type Body = undefined;
|
|
11
|
+
type ResponseBody = CountResponse;
|
|
12
|
+
|
|
13
|
+
export class GetBalanceItemsCountEndpoint 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, '/balance-items/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.setOrganizationScope();
|
|
31
|
+
await Context.authenticate();
|
|
32
|
+
const query = await GetBalanceItemsEndpoint.buildQuery(request.query);
|
|
33
|
+
|
|
34
|
+
const count = await query
|
|
35
|
+
.count();
|
|
36
|
+
|
|
37
|
+
return new Response(
|
|
38
|
+
CountResponse.create({
|
|
39
|
+
count,
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Decoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
|
+
import { BalanceItem } from '@stamhoofd/models';
|
|
5
|
+
import { applySQLSorter, compileToSQLFilter } from '@stamhoofd/sql';
|
|
6
|
+
import { BalanceItem as BalanceItemStruct, CountFilteredRequest, LimitedFilteredRequest, PaginatedResponse, StamhoofdFilter, assertSort, getSortFilter } from '@stamhoofd/structures';
|
|
7
|
+
|
|
8
|
+
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures.js';
|
|
9
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
10
|
+
import { balanceItemFilterCompilers } from '../../../../sql-filters/balance-items.js';
|
|
11
|
+
import { balanceItemSorters } from '../../../../sql-sorters/balance-items.js';
|
|
12
|
+
|
|
13
|
+
type Params = Record<string, never>;
|
|
14
|
+
type Query = LimitedFilteredRequest;
|
|
15
|
+
type Body = undefined;
|
|
16
|
+
type ResponseBody = PaginatedResponse<BalanceItemStruct[], LimitedFilteredRequest>;
|
|
17
|
+
|
|
18
|
+
const filterCompilers = balanceItemFilterCompilers;
|
|
19
|
+
const sorters = balanceItemSorters;
|
|
20
|
+
|
|
21
|
+
export class GetBalanceItemsEndpoint extends Endpoint<Params, Query, Body, ResponseBody> {
|
|
22
|
+
queryDecoder = LimitedFilteredRequest as Decoder<LimitedFilteredRequest>;
|
|
23
|
+
|
|
24
|
+
protected doesMatch(request: Request): [true, Params] | [false] {
|
|
25
|
+
if (request.method !== 'GET') {
|
|
26
|
+
return [false];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const params = Endpoint.parseParameters(request.url, '/balance-items', {});
|
|
30
|
+
|
|
31
|
+
if (params) {
|
|
32
|
+
return [true, params as Params];
|
|
33
|
+
}
|
|
34
|
+
return [false];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static async buildQuery(q: CountFilteredRequest | LimitedFilteredRequest) {
|
|
38
|
+
const organization = Context.organization;
|
|
39
|
+
let scopeFilter: StamhoofdFilter | undefined = undefined;
|
|
40
|
+
|
|
41
|
+
if (!organization) {
|
|
42
|
+
throw Context.auth.error();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!await Context.auth.canManagePayments(organization.id)) {
|
|
46
|
+
throw Context.auth.error();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
scopeFilter = {
|
|
50
|
+
organizationId: organization.id,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const query = BalanceItem.select()
|
|
54
|
+
.setMaxExecutionTime(15 * 1000);
|
|
55
|
+
|
|
56
|
+
if (scopeFilter) {
|
|
57
|
+
query.where(await compileToSQLFilter(scopeFilter, filterCompilers));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (q.filter) {
|
|
61
|
+
query.where(await compileToSQLFilter(q.filter, filterCompilers));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (q.search) {
|
|
65
|
+
let searchFilter: StamhoofdFilter | null = null;
|
|
66
|
+
searchFilter = {
|
|
67
|
+
description: {
|
|
68
|
+
$contains: q.search,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
if (searchFilter) {
|
|
73
|
+
query.where(await compileToSQLFilter(searchFilter, filterCompilers));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (q instanceof LimitedFilteredRequest) {
|
|
78
|
+
if (q.pageFilter) {
|
|
79
|
+
query.where(await compileToSQLFilter(q.pageFilter, filterCompilers));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
q.sort = assertSort(q.sort, [{ key: 'id' }]);
|
|
83
|
+
applySQLSorter(query, q.sort, sorters);
|
|
84
|
+
query.limit(q.limit);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return query;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static async buildData(requestQuery: LimitedFilteredRequest) {
|
|
91
|
+
const query = await this.buildQuery(requestQuery);
|
|
92
|
+
let balanceItems: BalanceItem[];
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
balanceItems = await query.fetch();
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (error.message.includes('ER_QUERY_TIMEOUT')) {
|
|
99
|
+
throw new SimpleError({
|
|
100
|
+
code: 'timeout',
|
|
101
|
+
message: 'Query took too long',
|
|
102
|
+
human: $t(`dce51638-6129-448b-8a15-e6d778f3a76a`),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let next: LimitedFilteredRequest | undefined;
|
|
109
|
+
|
|
110
|
+
if (balanceItems.length >= requestQuery.limit) {
|
|
111
|
+
const lastObject = balanceItems[balanceItems.length - 1];
|
|
112
|
+
const nextFilter = getSortFilter(lastObject, sorters, requestQuery.sort);
|
|
113
|
+
|
|
114
|
+
next = new LimitedFilteredRequest({
|
|
115
|
+
filter: requestQuery.filter,
|
|
116
|
+
pageFilter: nextFilter,
|
|
117
|
+
sort: requestQuery.sort,
|
|
118
|
+
limit: requestQuery.limit,
|
|
119
|
+
search: requestQuery.search,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
if (JSON.stringify(nextFilter) === JSON.stringify(requestQuery.pageFilter)) {
|
|
123
|
+
console.error('Found infinite loading loop for', requestQuery);
|
|
124
|
+
next = undefined;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return new PaginatedResponse<BalanceItemStruct[], LimitedFilteredRequest>({
|
|
129
|
+
results: await AuthenticatedStructures.balanceItems(balanceItems),
|
|
130
|
+
next,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async handle(request: DecodedRequest<Params, Query, Body>) {
|
|
135
|
+
await Context.setOrganizationScope();
|
|
136
|
+
await Context.authenticate();
|
|
137
|
+
|
|
138
|
+
const maxLimit = Context.auth.hasSomePlatformAccess() ? 1000 : 100;
|
|
139
|
+
|
|
140
|
+
if (request.query.limit > maxLimit) {
|
|
141
|
+
throw new SimpleError({
|
|
142
|
+
code: 'invalid_field',
|
|
143
|
+
field: 'limit',
|
|
144
|
+
message: 'Limit can not be more than ' + maxLimit,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (request.query.limit < 1) {
|
|
149
|
+
throw new SimpleError({
|
|
150
|
+
code: 'invalid_field',
|
|
151
|
+
field: 'limit',
|
|
152
|
+
message: 'Limit can not be less than 1',
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return new Response(
|
|
157
|
+
await GetBalanceItemsEndpoint.buildData(request.query),
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
package/src/endpoints/organization/dashboard/{payments → balance-items}/PatchBalanceItemsEndpoint.ts
RENAMED
|
@@ -242,7 +242,7 @@ export class PatchBalanceItemsEndpoint extends Endpoint<Params, Query, Body, Res
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
async validateMemberId(memberId: string) {
|
|
245
|
-
const member = (await Member.
|
|
245
|
+
const member = (await Member.getByIdWithUsersAndRegistrations(memberId));
|
|
246
246
|
|
|
247
247
|
if (!member || !(await Context.auth.canLinkBalanceItemToMember(member))) {
|
|
248
248
|
throw new SimpleError({
|
|
@@ -3,8 +3,8 @@ import { DetailedPayableBalanceCollection, PaymentStatus } from '@stamhoofd/stru
|
|
|
3
3
|
|
|
4
4
|
import { BalanceItem, Payment } from '@stamhoofd/models';
|
|
5
5
|
import { SQL } from '@stamhoofd/sql';
|
|
6
|
-
import { Context } from '../../../../helpers/Context';
|
|
7
|
-
import { GetUserDetailedPayableBalanceEndpoint } from '../../../global/registration/GetUserDetailedPayableBalanceEndpoint';
|
|
6
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
7
|
+
import { GetUserDetailedPayableBalanceEndpoint } from '../../../global/registration/GetUserDetailedPayableBalanceEndpoint.js';
|
|
8
8
|
|
|
9
9
|
type Params = Record<string, never>;
|
|
10
10
|
type Query = undefined;
|
package/src/endpoints/organization/dashboard/billing/GetOrganizationPayableBalanceEndpoint.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
2
2
|
import { PayableBalanceCollection, ReceivableBalanceType } from '@stamhoofd/structures';
|
|
3
3
|
|
|
4
|
-
import { Context } from '../../../../helpers/Context';
|
|
5
|
-
import { GetUserPayableBalanceEndpoint } from '../../../global/registration/GetUserPayableBalanceEndpoint';
|
|
4
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
5
|
+
import { GetUserPayableBalanceEndpoint } from '../../../global/registration/GetUserPayableBalanceEndpoint.js';
|
|
6
6
|
|
|
7
7
|
type Params = Record<string, never>;
|
|
8
8
|
type Query = undefined;
|
|
@@ -2,9 +2,9 @@ import { Request } from '@simonbackx/simple-endpoints';
|
|
|
2
2
|
import { OrganizationFactory, STPackageFactory } from '@stamhoofd/models';
|
|
3
3
|
import { AccessRight, LimitedFilteredRequest, STPackageBundle, STPackageType } from '@stamhoofd/structures';
|
|
4
4
|
import { STExpect, TestUtils } from '@stamhoofd/test-utils';
|
|
5
|
-
import { testServer } from '../../../../../tests/helpers/TestServer';
|
|
6
|
-
import { initAdmin } from '../../../../../tests/init';
|
|
7
|
-
import { GetPackagesEndpoint } from './GetPackagesEndpoint';
|
|
5
|
+
import { testServer } from '../../../../../tests/helpers/TestServer.js';
|
|
6
|
+
import { initAdmin } from '../../../../../tests/init/index.js';
|
|
7
|
+
import { GetPackagesEndpoint } from './GetPackagesEndpoint.js';
|
|
8
8
|
|
|
9
9
|
const baseUrl = `/organization/packages`;
|
|
10
10
|
const endpoint = new GetPackagesEndpoint();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
2
|
-
import { STPackage } from '@stamhoofd/models';
|
|
3
2
|
import { OrganizationPackagesStatus, STPackage as STPackageStruct } from '@stamhoofd/structures';
|
|
4
|
-
import { Context } from '../../../../helpers/Context';
|
|
3
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
4
|
+
import { STPackageService } from '../../../../services/STPackageService.js';
|
|
5
5
|
|
|
6
6
|
type Params = Record<string, never>;
|
|
7
7
|
type Query = undefined;
|
|
@@ -31,7 +31,7 @@ export class GetPackagesEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
31
31
|
throw Context.auth.error();
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const packages = await
|
|
34
|
+
const packages = await STPackageService.getActivePackages(organization.id);
|
|
35
35
|
|
|
36
36
|
return new Response(OrganizationPackagesStatus.create({
|
|
37
37
|
packages: packages.map(p => STPackageStruct.create(p)),
|
|
@@ -2,7 +2,7 @@ import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-
|
|
|
2
2
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
3
3
|
import { DocumentTemplate } from '@stamhoofd/models';
|
|
4
4
|
|
|
5
|
-
import { Context } from '../../../../helpers/Context';
|
|
5
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
6
6
|
|
|
7
7
|
type Params = { id: string };
|
|
8
8
|
type Query = undefined;
|
|
@@ -2,8 +2,8 @@ import { Decoder } from '@simonbackx/simple-encoding';
|
|
|
2
2
|
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
3
3
|
import { CountFilteredRequest, CountResponse } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
|
-
import { Context } from '../../../../helpers/Context';
|
|
6
|
-
import { GetDocumentsEndpoint } from './GetDocumentsEndpoint';
|
|
5
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
6
|
+
import { GetDocumentsEndpoint } from './GetDocumentsEndpoint.js';
|
|
7
7
|
|
|
8
8
|
type Params = Record<string, never>;
|
|
9
9
|
type Query = CountFilteredRequest;
|
|
@@ -4,7 +4,7 @@ import { SimpleError } from '@simonbackx/simple-errors';
|
|
|
4
4
|
import { Document, DocumentTemplate, Member, Registration } from '@stamhoofd/models';
|
|
5
5
|
import { DocumentStatus, Document as DocumentStruct, PermissionLevel } from '@stamhoofd/structures';
|
|
6
6
|
|
|
7
|
-
import { Context } from '../../../../helpers/Context';
|
|
7
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
8
8
|
|
|
9
9
|
type Params = Record<string, never>;
|
|
10
10
|
type Query = undefined;
|
|
@@ -104,7 +104,7 @@ export class PatchDocumentEndpoint extends Endpoint<Params, Query, Body, Respons
|
|
|
104
104
|
put.memberId = registration.memberId;
|
|
105
105
|
}
|
|
106
106
|
if (put.memberId) {
|
|
107
|
-
const member = await Member.
|
|
107
|
+
const member = await Member.getByIdWithUsersAndRegistrations(put.memberId);
|
|
108
108
|
if (!member || !await Context.auth.canAccessMember(member, PermissionLevel.Read)) {
|
|
109
109
|
throw new SimpleError({
|
|
110
110
|
code: 'not_found',
|
|
@@ -4,7 +4,7 @@ import { SimpleError } from '@simonbackx/simple-errors';
|
|
|
4
4
|
import { EmailAddress } from '@stamhoofd/email';
|
|
5
5
|
import { EmailInformation } from '@stamhoofd/structures';
|
|
6
6
|
|
|
7
|
-
import { Context } from '../../../../helpers/Context';
|
|
7
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
8
8
|
|
|
9
9
|
type Params = Record<string, never>;
|
|
10
10
|
type Query = undefined;
|
|
@@ -28,14 +28,17 @@ export class CheckEmailBouncesEndpoint extends Endpoint<Params, Query, Body, Res
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
async handle(request: DecodedRequest<Params, Query, Body>) {
|
|
31
|
-
const organization = await Context.
|
|
31
|
+
const organization = await Context.setOptionalOrganizationScope();
|
|
32
32
|
await Context.authenticate();
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
// null if platform
|
|
35
|
+
const organizationId: string | null = organization ? organization.id : null;
|
|
36
|
+
|
|
37
|
+
if (!await Context.auth.canAccessEmailBounces(organizationId)) {
|
|
35
38
|
throw Context.auth.error();
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
if (request.body.length >
|
|
41
|
+
if (request.body.length > 1000) {
|
|
39
42
|
throw new SimpleError({
|
|
40
43
|
code: 'too_many_recipients',
|
|
41
44
|
message: 'Too many recipients',
|
|
@@ -44,7 +47,35 @@ export class CheckEmailBouncesEndpoint extends Endpoint<Params, Query, Body, Res
|
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
const emails = await EmailAddress.getByEmails(request.body,
|
|
48
|
-
|
|
50
|
+
const emails = await EmailAddress.getByEmails(request.body, organizationId);
|
|
51
|
+
|
|
52
|
+
// Remove duplicates + remove emails where all values are false
|
|
53
|
+
const cleaned: EmailInformation[] = [];
|
|
54
|
+
for (const email of emails) {
|
|
55
|
+
const c = EmailInformation.create(email);
|
|
56
|
+
const existing = cleaned.find(cc => cc.email === email.email);
|
|
57
|
+
if (existing) {
|
|
58
|
+
existing.markedAsSpam = existing.markedAsSpam || c.markedAsSpam;
|
|
59
|
+
existing.hardBounce = existing.hardBounce || c.hardBounce;
|
|
60
|
+
|
|
61
|
+
if (email.organizationId === null && organizationId === null) {
|
|
62
|
+
// Only show unsubscribe status of platform
|
|
63
|
+
existing.unsubscribedAll = c.unsubscribedAll;
|
|
64
|
+
existing.unsubscribedMarketing = c.unsubscribedMarketing;
|
|
65
|
+
}
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (email.organizationId !== null && organizationId === null) {
|
|
70
|
+
// Only show unsubscribe status of platform
|
|
71
|
+
c.unsubscribedAll = false;
|
|
72
|
+
c.unsubscribedMarketing = false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
cleaned.push(c);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// We don't return empty ones to increase privacy a bit - admins should not know what email addresses are in the system unless they have bounced
|
|
79
|
+
return new Response(cleaned.filter(c => c.markedAsSpam || c.hardBounce || c.unsubscribedAll || c.unsubscribedMarketing));
|
|
49
80
|
}
|
|
50
81
|
}
|
package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.test.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { Request } from '@simonbackx/simple-endpoints';
|
|
|
2
2
|
import { EmailTemplate, GroupFactory, Organization, OrganizationFactory, Platform, RegistrationPeriod, RegistrationPeriodFactory, Token, UserFactory } from '@stamhoofd/models';
|
|
3
3
|
import { EmailTemplateType, PermissionLevel, PermissionRoleDetailed, Permissions, PermissionsResourceType, ResourcePermissions, Version } from '@stamhoofd/structures';
|
|
4
4
|
import { TestUtils } from '@stamhoofd/test-utils';
|
|
5
|
-
import { testServer } from '../../../../../tests/helpers/TestServer';
|
|
6
|
-
import { GetEmailTemplatesEndpoint } from './GetEmailTemplatesEndpoint';
|
|
5
|
+
import { testServer } from '../../../../../tests/helpers/TestServer.js';
|
|
6
|
+
import { GetEmailTemplatesEndpoint } from './GetEmailTemplatesEndpoint.js';
|
|
7
7
|
|
|
8
8
|
const baseUrl = `/v${Version}/email-templates`;
|
|
9
9
|
|
|
@@ -4,9 +4,9 @@ import { EmailTemplate } from '@stamhoofd/models';
|
|
|
4
4
|
import { EmailTemplate as EmailTemplateStruct, EmailTemplateType } from '@stamhoofd/structures';
|
|
5
5
|
|
|
6
6
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
7
|
-
import { StringArrayDecoder } from '../../../../decoders/StringArrayDecoder';
|
|
8
|
-
import { StringNullableDecoder } from '../../../../decoders/StringNullableDecoder';
|
|
9
|
-
import { Context } from '../../../../helpers/Context';
|
|
7
|
+
import { StringArrayDecoder } from '../../../../decoders/StringArrayDecoder.js';
|
|
8
|
+
import { StringNullableDecoder } from '../../../../decoders/StringNullableDecoder.js';
|
|
9
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
10
10
|
|
|
11
11
|
type Params = Record<string, never>;
|
|
12
12
|
type Body = undefined;
|
package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.test.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { Request } from '@simonbackx/simple-endpoints';
|
|
|
3
3
|
import { EmailTemplate, GroupFactory, Organization, OrganizationFactory, Platform, RegistrationPeriod, RegistrationPeriodFactory, Token, UserFactory } from '@stamhoofd/models';
|
|
4
4
|
import { EmailTemplate as EmailTemplateStruct, EmailTemplateType, PermissionLevel, PermissionRoleDetailed, Permissions, PermissionsResourceType, ResourcePermissions, Version } from '@stamhoofd/structures';
|
|
5
5
|
import { TestUtils } from '@stamhoofd/test-utils';
|
|
6
|
-
import { testServer } from '../../../../../tests/helpers/TestServer';
|
|
7
|
-
import { PatchEmailTemplatesEndpoint } from './PatchEmailTemplatesEndpoint';
|
|
6
|
+
import { testServer } from '../../../../../tests/helpers/TestServer.js';
|
|
7
|
+
import { PatchEmailTemplatesEndpoint } from './PatchEmailTemplatesEndpoint.js';
|
|
8
8
|
|
|
9
9
|
const baseUrl = `/v${Version}/email-templates`;
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@ import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-
|
|
|
3
3
|
import { EmailTemplate, Group, Webshop } from '@stamhoofd/models';
|
|
4
4
|
import { EmailTemplate as EmailTemplateStruct, PermissionLevel } from '@stamhoofd/structures';
|
|
5
5
|
|
|
6
|
-
import { Context } from '../../../../helpers/Context';
|
|
6
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
7
7
|
|
|
8
8
|
type Params = Record<string, never>;
|
|
9
9
|
type Body = PatchableArrayAutoEncoder<EmailTemplateStruct>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { AutoEncoderPatchType, Decoder, PatchableArrayAutoEncoder, PatchableArrayDecoder, StringDecoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Invoice as InvoiceStruct } from '@stamhoofd/structures';
|
|
4
|
+
|
|
5
|
+
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures.js';
|
|
6
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
7
|
+
import { Invoice } from '@stamhoofd/models';
|
|
8
|
+
import { SimpleError } from '@simonbackx/simple-errors';
|
|
9
|
+
import { ViesHelper } from '../../../../helpers/ViesHelper.js';
|
|
10
|
+
import { InvoiceService } from '../../../../services/InvoiceService.js';
|
|
11
|
+
|
|
12
|
+
type Params = Record<string, never>;
|
|
13
|
+
type Query = undefined;
|
|
14
|
+
type Body = PatchableArrayAutoEncoder<InvoiceStruct>;
|
|
15
|
+
type ResponseBody = InvoiceStruct[];
|
|
16
|
+
|
|
17
|
+
export class PatchInvoicesEndpoint extends Endpoint<Params, Query, Body, ResponseBody> {
|
|
18
|
+
bodyDecoder = new PatchableArrayDecoder(InvoiceStruct as Decoder<InvoiceStruct>, InvoiceStruct.patchType() as Decoder<AutoEncoderPatchType<InvoiceStruct>>, StringDecoder);
|
|
19
|
+
|
|
20
|
+
protected doesMatch(request: Request): [true, Params] | [false] {
|
|
21
|
+
if (request.method !== 'PATCH') {
|
|
22
|
+
return [false];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const params = Endpoint.parseParameters(request.url, '/invoices', {});
|
|
26
|
+
|
|
27
|
+
if (params) {
|
|
28
|
+
return [true, params as Params];
|
|
29
|
+
}
|
|
30
|
+
return [false];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async handle(request: DecodedRequest<Params, Query, Body>) {
|
|
34
|
+
const organization = await Context.setOrganizationScope();
|
|
35
|
+
await Context.authenticate();
|
|
36
|
+
|
|
37
|
+
// Fast throw first (more in depth checking for patches later)
|
|
38
|
+
if (!await Context.auth.hasFullAccess(organization.id)) {
|
|
39
|
+
throw Context.auth.error();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const invoices: Invoice[] = [];
|
|
43
|
+
|
|
44
|
+
for (const { put } of request.body.getPuts()) {
|
|
45
|
+
const model = await InvoiceService.createFrom(organization, put);
|
|
46
|
+
invoices.push(model);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return new Response(
|
|
50
|
+
await AuthenticatedStructures.invoices(invoices),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -2,8 +2,8 @@ import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-
|
|
|
2
2
|
import { MollieToken } from '@stamhoofd/models';
|
|
3
3
|
import { CheckMollieResponse, Organization as OrganizationStruct, PermissionLevel } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
|
-
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures';
|
|
6
|
-
import { Context } from '../../../../helpers/Context';
|
|
5
|
+
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures.js';
|
|
6
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
7
7
|
|
|
8
8
|
type Params = Record<string, never>;
|
|
9
9
|
type Body = undefined;
|
|
@@ -3,9 +3,9 @@ import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-
|
|
|
3
3
|
import { MollieToken } from '@stamhoofd/models';
|
|
4
4
|
import { Organization as OrganizationStruct, PermissionLevel } from '@stamhoofd/structures';
|
|
5
5
|
|
|
6
|
-
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures';
|
|
7
|
-
import { checkMollieSettlementsFor } from '../../../../helpers/CheckSettlements';
|
|
8
|
-
import { Context } from '../../../../helpers/Context';
|
|
6
|
+
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures.js';
|
|
7
|
+
import { checkMollieSettlementsFor } from '../../../../helpers/CheckSettlements.js';
|
|
8
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
9
9
|
|
|
10
10
|
type Params = Record<string, never>;
|
|
11
11
|
|
|
@@ -2,8 +2,8 @@ import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-
|
|
|
2
2
|
import { MollieToken } from '@stamhoofd/models';
|
|
3
3
|
import { Organization as OrganizationStruct, PermissionLevel } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
|
-
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures';
|
|
6
|
-
import { Context } from '../../../../helpers/Context';
|
|
5
|
+
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures.js';
|
|
6
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
7
7
|
|
|
8
8
|
type Params = Record<string, never>;
|
|
9
9
|
type Body = undefined;
|
|
@@ -3,7 +3,7 @@ import { isSimpleError, isSimpleErrors, SimpleError } from '@simonbackx/simple-e
|
|
|
3
3
|
import { MollieToken } from '@stamhoofd/models';
|
|
4
4
|
import { PermissionLevel } from '@stamhoofd/structures';
|
|
5
5
|
|
|
6
|
-
import { Context } from '../../../../helpers/Context';
|
|
6
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
7
7
|
|
|
8
8
|
type Params = Record<string, never>;
|
|
9
9
|
type Body = undefined;
|
|
@@ -2,7 +2,7 @@ import { AutoEncoder, field, StringDecoder } from '@simonbackx/simple-encoding';
|
|
|
2
2
|
import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
|
|
3
3
|
import jwt from 'jsonwebtoken';
|
|
4
4
|
|
|
5
|
-
import { Context } from '../../../../helpers/Context';
|
|
5
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
6
6
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
7
7
|
|
|
8
8
|
type Params = Record<string, never>;
|
|
@@ -3,8 +3,8 @@ import { SimpleError } from '@simonbackx/simple-errors';
|
|
|
3
3
|
import { Group, Token } from '@stamhoofd/models';
|
|
4
4
|
import { Group as GroupStruct, GroupStatus } from '@stamhoofd/structures';
|
|
5
5
|
|
|
6
|
-
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures';
|
|
7
|
-
import { Context } from '../../../../helpers/Context';
|
|
6
|
+
import { AuthenticatedStructures } from '../../../../helpers/AuthenticatedStructures.js';
|
|
7
|
+
import { Context } from '../../../../helpers/Context.js';
|
|
8
8
|
type Params = Record<string, never>;
|
|
9
9
|
type Query = undefined;
|
|
10
10
|
type Body = undefined;
|