@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
package/migrations.ts
CHANGED
|
@@ -4,7 +4,7 @@ backendEnv.load({ service: 'api' }).catch((error) => {
|
|
|
4
4
|
console.error('Failed to load environment:', error);
|
|
5
5
|
process.exit(1);
|
|
6
6
|
}).then(async () => {
|
|
7
|
-
const { run } = await import('./src/migrate');
|
|
7
|
+
const { run } = await import('./src/migrate.js');
|
|
8
8
|
await run();
|
|
9
9
|
process.exit(0);
|
|
10
10
|
}).catch((error) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/backend",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.117.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
"@simonbackx/simple-encoding": "2.23.1",
|
|
56
56
|
"@simonbackx/simple-endpoints": "1.20.1",
|
|
57
57
|
"@simonbackx/simple-logging": "^1.0.1",
|
|
58
|
-
"@stamhoofd/backend-i18n": "2.
|
|
59
|
-
"@stamhoofd/backend-middleware": "2.
|
|
60
|
-
"@stamhoofd/email": "2.
|
|
61
|
-
"@stamhoofd/models": "2.
|
|
62
|
-
"@stamhoofd/queues": "2.
|
|
63
|
-
"@stamhoofd/sql": "2.
|
|
64
|
-
"@stamhoofd/structures": "2.
|
|
65
|
-
"@stamhoofd/utility": "2.
|
|
58
|
+
"@stamhoofd/backend-i18n": "2.117.0",
|
|
59
|
+
"@stamhoofd/backend-middleware": "2.117.0",
|
|
60
|
+
"@stamhoofd/email": "2.117.0",
|
|
61
|
+
"@stamhoofd/models": "2.117.0",
|
|
62
|
+
"@stamhoofd/queues": "2.117.0",
|
|
63
|
+
"@stamhoofd/sql": "2.117.0",
|
|
64
|
+
"@stamhoofd/structures": "2.117.0",
|
|
65
|
+
"@stamhoofd/utility": "2.117.0",
|
|
66
66
|
"archiver": "^7.0.1",
|
|
67
67
|
"axios": "^1.13.2",
|
|
68
68
|
"cookie": "^0.7.0",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "ad4b006dca3aa5a7c14b2afc83b6df3c2a72424c"
|
|
84
84
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DocumentTemplate } from '@stamhoofd/models';
|
|
2
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
2
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
3
3
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
5
|
export const DocumentTemplateLogger = new ModelLogger(DocumentTemplate, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EmailAddress } from '@stamhoofd/email';
|
|
2
2
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
3
|
-
import { ModelLogger } from './ModelLogger';
|
|
3
|
+
import { ModelLogger } from './ModelLogger.js';
|
|
4
4
|
|
|
5
5
|
export const EmailAddressLogger = new ModelLogger(EmailAddress, {
|
|
6
6
|
async optionsGenerator(event) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Email } from '@stamhoofd/models';
|
|
2
2
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType, EmailStatus } from '@stamhoofd/structures';
|
|
3
3
|
import { Formatter } from '@stamhoofd/utility';
|
|
4
|
-
import { ModelLogger } from './ModelLogger';
|
|
4
|
+
import { ModelLogger } from './ModelLogger.js';
|
|
5
5
|
|
|
6
6
|
export const EmailLogger = new ModelLogger(Email, {
|
|
7
7
|
skipKeys: ['json', 'text', 'status', 'userId', 'createdAt', 'updatedAt', 'deletedAt', 'recipientFilter', 'emailRecipientsCount', 'otherRecipientsCount', 'succeededCount', 'softFailedCount', 'failedCount', 'membersCount', 'hardBouncesCount', 'softBouncesCount', 'spamComplaintsCount', 'recipientsStatus', 'recipientsErrors', 'emailErrors', 'sentAt'],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EmailTemplate } from '@stamhoofd/models';
|
|
2
2
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
3
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
3
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
4
4
|
const defaultGenerator = getDefaultGenerator({
|
|
5
5
|
created: AuditLogType.EmailTemplateAdded,
|
|
6
6
|
updated: AuditLogType.EmailTemplateEdited,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Event } from '@stamhoofd/models';
|
|
2
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
2
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
3
3
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
5
|
export const EventLogger = new ModelLogger(Event, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Group } from '@stamhoofd/models';
|
|
2
2
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType, GroupType } from '@stamhoofd/structures';
|
|
3
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
3
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
4
4
|
|
|
5
5
|
const defaultGenerator = getDefaultGenerator({
|
|
6
6
|
created: AuditLogType.GroupAdded,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Member } from '@stamhoofd/models';
|
|
2
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
2
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
3
3
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
5
|
export const MemberLogger = new ModelLogger(Member, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Member, MemberPlatformMembership, Platform } from '@stamhoofd/models';
|
|
2
2
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
3
3
|
import { Formatter } from '@stamhoofd/utility';
|
|
4
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
4
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
5
5
|
|
|
6
6
|
const defaultGenerator = getDefaultGenerator({
|
|
7
7
|
created: AuditLogType.MemberPlatformMembershipAdded,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Group, Member, MemberResponsibilityRecord, Organization, Platform } from '@stamhoofd/models';
|
|
2
2
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
3
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
3
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
4
4
|
|
|
5
5
|
const defaultGenerator = getDefaultGenerator({
|
|
6
6
|
created: AuditLogType.MemberResponsibilityRecordAdded,
|
|
@@ -2,8 +2,8 @@ import { Model, ModelEvent } from '@simonbackx/simple-database';
|
|
|
2
2
|
import { AuditLog } from '@stamhoofd/models';
|
|
3
3
|
import { ObjectDiffer } from '@stamhoofd/object-differ';
|
|
4
4
|
import { AuditLogPatchItem, AuditLogPatchItemType, AuditLogReplacement, AuditLogSource, AuditLogType } from '@stamhoofd/structures';
|
|
5
|
-
import { ContextInstance } from '../helpers/Context';
|
|
6
|
-
import { AuditLogService } from '../services/AuditLogService';
|
|
5
|
+
import { ContextInstance } from '../helpers/Context.js';
|
|
6
|
+
import { AuditLogService } from '../services/AuditLogService.js';
|
|
7
7
|
|
|
8
8
|
export type ModelEventLogOptions<D> = {
|
|
9
9
|
type: AuditLogType;
|
|
@@ -33,11 +33,11 @@ export type ModelLoggerOptions<M extends Model, D = undefined> = {
|
|
|
33
33
|
|
|
34
34
|
const ModelEventsMap = new WeakMap<Model, { events: AuditLog[] }>();
|
|
35
35
|
|
|
36
|
-
export function getDefaultGenerator(types: DefaultLogOptionsType): EventOptionsGenerator<
|
|
37
|
-
return (event: ModelEvent<
|
|
36
|
+
export function getDefaultGenerator<M extends Model = Model>(types: DefaultLogOptionsType): EventOptionsGenerator<M, { model: M }> {
|
|
37
|
+
return (event: ModelEvent<M>) => {
|
|
38
38
|
if (event.type === 'created') {
|
|
39
39
|
if (types.created) {
|
|
40
|
-
return { type: types.created, data:
|
|
40
|
+
return { type: types.created, data: { model: event.model } };
|
|
41
41
|
}
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
@@ -54,7 +54,7 @@ export function getDefaultGenerator(types: DefaultLogOptionsType): EventOptionsG
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
if (types.deleted) {
|
|
57
|
-
return { type: types.deleted, data:
|
|
57
|
+
return { type: types.deleted, data: { model: event.model } };
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -67,19 +67,19 @@ export function getDefaultGenerator(types: DefaultLogOptionsType): EventOptionsG
|
|
|
67
67
|
// Merge into create event
|
|
68
68
|
const events = ModelEventsMap.get(event.model)?.events;
|
|
69
69
|
if (events && events.length > 0) {
|
|
70
|
-
mergeInto = events
|
|
70
|
+
mergeInto = events.find(e => e.type === types.created);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
return { type: types.updated, generatePatchList: true, data:
|
|
75
|
+
return { type: types.updated, generatePatchList: true, data: { model: event.model }, mergeInto };
|
|
76
76
|
}
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
if (event.type === 'deleted') {
|
|
81
81
|
if (types.deleted) {
|
|
82
|
-
return { type: types.deleted, data:
|
|
82
|
+
return { type: types.deleted, data: { model: event.model } };
|
|
83
83
|
}
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
@@ -110,9 +110,9 @@ export class ModelLogger<ModelType extends typeof Model, M extends InstanceType<
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
async logEvent(event: ModelEvent<M>) {
|
|
113
|
+
const log = new AuditLog();
|
|
113
114
|
try {
|
|
114
115
|
const context = ContextInstance.optional;
|
|
115
|
-
const log = new AuditLog();
|
|
116
116
|
let settings = AuditLogService.getContext();
|
|
117
117
|
let userId = settings?.userId !== undefined ? settings?.userId : (context?.optionalAuth?.user?.id ?? settings?.fallbackUserId ?? null);
|
|
118
118
|
|
|
@@ -130,6 +130,11 @@ export class ModelLogger<ModelType extends typeof Model, M extends InstanceType<
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
const options = await this.optionsGenerator(event);
|
|
134
|
+
|
|
135
|
+
if (!options) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
133
138
|
log.userId = userId;
|
|
134
139
|
|
|
135
140
|
log.organizationId = context?.organization?.id ?? settings?.fallbackOrganizationId ?? null;
|
|
@@ -149,12 +154,6 @@ export class ModelLogger<ModelType extends typeof Model, M extends InstanceType<
|
|
|
149
154
|
log.source = AuditLogSource.System;
|
|
150
155
|
}
|
|
151
156
|
|
|
152
|
-
const options = await this.optionsGenerator(event);
|
|
153
|
-
|
|
154
|
-
if (!options) {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
157
|
log.type = options.type;
|
|
159
158
|
log.objectId = options.objectId ?? event.model.getPrimaryKey()?.toString() ?? null;
|
|
160
159
|
log.replacements = this.createReplacements ? this.createReplacements(event.model as M, options) : new Map();
|
|
@@ -197,7 +196,6 @@ export class ModelLogger<ModelType extends typeof Model, M extends InstanceType<
|
|
|
197
196
|
}
|
|
198
197
|
}
|
|
199
198
|
else {
|
|
200
|
-
console.log('No changes');
|
|
201
199
|
return false;
|
|
202
200
|
}
|
|
203
201
|
}
|
|
@@ -233,16 +231,26 @@ export class ModelLogger<ModelType extends typeof Model, M extends InstanceType<
|
|
|
233
231
|
return await options.mergeInto.save();
|
|
234
232
|
}
|
|
235
233
|
|
|
234
|
+
try {
|
|
235
|
+
log.validate();
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
console.error('AuditLog dit not pass validation', log);
|
|
239
|
+
}
|
|
240
|
+
|
|
236
241
|
const saved = await log.save();
|
|
237
242
|
|
|
238
243
|
// Assign to map
|
|
244
|
+
const d = [...(ModelEventsMap.get(event.model)?.events ?? []), log];
|
|
245
|
+
|
|
239
246
|
ModelEventsMap.set(event.model, {
|
|
240
|
-
|
|
247
|
+
// Limit length of d to 1 - we only use the first event
|
|
248
|
+
events: d.slice(0, 1),
|
|
241
249
|
});
|
|
242
250
|
return saved;
|
|
243
251
|
}
|
|
244
252
|
catch (e) {
|
|
245
|
-
console.error('Failed to save log', e);
|
|
253
|
+
console.error('Failed to save log', e, log);
|
|
246
254
|
}
|
|
247
255
|
return false;
|
|
248
256
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Order, Webshop } from '@stamhoofd/models';
|
|
2
2
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType, OrderStatus } from '@stamhoofd/structures';
|
|
3
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
3
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
4
4
|
|
|
5
5
|
const defaultGenerator = getDefaultGenerator({
|
|
6
6
|
created: AuditLogType.OrderAdded,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Organization } from '@stamhoofd/models';
|
|
2
|
-
import { AuditLogType } from '@stamhoofd/structures';
|
|
3
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
2
|
+
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
3
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
4
4
|
|
|
5
5
|
export const OrganizationLogger = new ModelLogger(Organization, {
|
|
6
6
|
skipKeys: ['searchIndex', 'serverMeta'],
|
|
7
|
-
optionsGenerator: getDefaultGenerator({
|
|
7
|
+
optionsGenerator: getDefaultGenerator<Organization>({
|
|
8
8
|
created: AuditLogType.OrganizationAdded,
|
|
9
9
|
updated: AuditLogType.OrganizationEdited,
|
|
10
10
|
deleted: AuditLogType.OrganizationDeleted,
|
|
@@ -12,5 +12,25 @@ export const OrganizationLogger = new ModelLogger(Organization, {
|
|
|
12
12
|
|
|
13
13
|
postProcess(event, options, log) {
|
|
14
14
|
log.organizationId = event.model.id;
|
|
15
|
+
|
|
16
|
+
if (log.type === AuditLogType.OrganizationDeleted) {
|
|
17
|
+
// Never belongs to an organization - could cause constraint errors
|
|
18
|
+
log.organizationId = null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (log.type === AuditLogType.OrganizationAdded) {
|
|
22
|
+
// Should only be visible in the admin panel
|
|
23
|
+
log.organizationId = null;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
createReplacements: (model, options) => {
|
|
28
|
+
return new Map([
|
|
29
|
+
['org', AuditLogReplacement.create({
|
|
30
|
+
id: options.data.model.id,
|
|
31
|
+
value: options.data.model.name,
|
|
32
|
+
type: AuditLogReplacementType.Organization,
|
|
33
|
+
})],
|
|
34
|
+
]);
|
|
15
35
|
},
|
|
16
36
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Organization, OrganizationRegistrationPeriod, RegistrationPeriod } from '@stamhoofd/models';
|
|
2
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
2
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
3
3
|
import { AuditLogPatchItem, AuditLogPatchItemType, AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
5
|
const defaultGenerator = getDefaultGenerator({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Payment } from '@stamhoofd/models';
|
|
2
2
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType, PaymentMethod, PaymentMethodHelper, PaymentStatusHelper } from '@stamhoofd/structures';
|
|
3
3
|
import { Formatter } from '@stamhoofd/utility';
|
|
4
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
4
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
5
5
|
|
|
6
6
|
export const PaymentLogger = new ModelLogger(Payment, {
|
|
7
7
|
skipKeys: ['transferFee'],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Platform } from '@stamhoofd/models';
|
|
2
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
2
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
3
3
|
import { AuditLogType } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
5
|
export const PlatformLogger = new ModelLogger(Platform, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Group, Member, Registration } from '@stamhoofd/models';
|
|
2
|
-
import { ModelLogger } from './ModelLogger';
|
|
2
|
+
import { ModelLogger } from './ModelLogger.js';
|
|
3
3
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
5
|
export const RegistrationLogger = new ModelLogger(Registration, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RegistrationPeriod } from '@stamhoofd/models';
|
|
2
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
2
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
3
3
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
5
|
export const RegistrationPeriodLogger = new ModelLogger(RegistrationPeriod, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StripeAccount } from '@stamhoofd/models';
|
|
2
2
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogSource, AuditLogType } from '@stamhoofd/structures';
|
|
3
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
3
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
4
4
|
|
|
5
5
|
const defaultGenerator = getDefaultGenerator({
|
|
6
6
|
created: AuditLogType.StripeAccountAdded,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { User } from '@stamhoofd/models';
|
|
2
2
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
3
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
3
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
4
4
|
|
|
5
5
|
const defaultGenerator = getDefaultGenerator({
|
|
6
6
|
created: AuditLogType.UserAdded,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Webshop } from '@stamhoofd/models';
|
|
2
|
-
import { getDefaultGenerator, ModelLogger } from './ModelLogger';
|
|
2
|
+
import { getDefaultGenerator, ModelLogger } from './ModelLogger.js';
|
|
3
3
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogType } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
5
|
const defaultGenerator = getDefaultGenerator({
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DocumentTemplateLogger } from './DocumentTemplateLogger.js';
|
|
2
|
+
import { EmailAddressLogger } from './EmailAddressLogger.js';
|
|
3
|
+
import { EmailLogger } from './EmailLogger.js';
|
|
4
|
+
import { EmailTemplateLogger } from './EmailTemplateLogger.js';
|
|
5
|
+
import { EventLogger } from './EventLogger.js';
|
|
6
|
+
import { GroupLogger } from './GroupLogger.js';
|
|
7
|
+
import { MemberLogger } from './MemberLogger.js';
|
|
8
|
+
import { MemberPlatformMembershipLogger } from './MemberPlatformMembershipLogger.js';
|
|
9
|
+
import { MemberResponsibilityRecordLogger } from './MemberResponsibilityRecordLogger.js';
|
|
10
|
+
import { OrderLogger } from './OrderLogger.js';
|
|
11
|
+
import { OrganizationLogger } from './OrganizationLogger.js';
|
|
12
|
+
import { OrganizationRegistrationPeriodLogger } from './OrganizationRegistrationPeriodLogger.js';
|
|
13
|
+
import { PaymentLogger } from './PaymentLogger.js';
|
|
14
|
+
import { PlatformLogger } from './PlatformLogger.js';
|
|
15
|
+
import { RegistrationLogger } from './RegistrationLogger.js';
|
|
16
|
+
import { RegistrationPeriodLogger } from './RegistrationPeriodLogger.js';
|
|
17
|
+
import { StripeAccountLogger } from './StripeAccountLogger.js';
|
|
18
|
+
import { UserLogger } from './UserLogger.js';
|
|
19
|
+
import { WebshopLogger } from './WebshopLogger.js';
|
|
20
|
+
import { modelLogDefinitions } from '../services/AuditLogService.js';
|
|
21
|
+
|
|
22
|
+
modelLogDefinitions.set(RegistrationLogger.model, RegistrationLogger);
|
|
23
|
+
modelLogDefinitions.set(GroupLogger.model, GroupLogger);
|
|
24
|
+
modelLogDefinitions.set(OrganizationLogger.model, OrganizationLogger);
|
|
25
|
+
modelLogDefinitions.set(PlatformLogger.model, PlatformLogger);
|
|
26
|
+
modelLogDefinitions.set(EventLogger.model, EventLogger);
|
|
27
|
+
modelLogDefinitions.set(RegistrationPeriodLogger.model, RegistrationPeriodLogger);
|
|
28
|
+
modelLogDefinitions.set(OrganizationRegistrationPeriodLogger.model, OrganizationRegistrationPeriodLogger);
|
|
29
|
+
modelLogDefinitions.set(StripeAccountLogger.model, StripeAccountLogger);
|
|
30
|
+
modelLogDefinitions.set(MemberLogger.model, MemberLogger);
|
|
31
|
+
modelLogDefinitions.set(WebshopLogger.model, WebshopLogger);
|
|
32
|
+
modelLogDefinitions.set(OrderLogger.model, OrderLogger);
|
|
33
|
+
modelLogDefinitions.set(PaymentLogger.model, PaymentLogger);
|
|
34
|
+
modelLogDefinitions.set(MemberPlatformMembershipLogger.model, MemberPlatformMembershipLogger);
|
|
35
|
+
modelLogDefinitions.set(MemberResponsibilityRecordLogger.model, MemberResponsibilityRecordLogger);
|
|
36
|
+
modelLogDefinitions.set(DocumentTemplateLogger.model, DocumentTemplateLogger);
|
|
37
|
+
modelLogDefinitions.set(EmailLogger.model, EmailLogger);
|
|
38
|
+
modelLogDefinitions.set(EmailTemplateLogger.model, EmailTemplateLogger);
|
|
39
|
+
modelLogDefinitions.set(EmailAddressLogger.model, EmailAddressLogger);
|
|
40
|
+
modelLogDefinitions.set(UserLogger.model, UserLogger);
|
package/src/boot.ts
CHANGED
|
@@ -16,13 +16,12 @@ import { SetupStepUpdater } from './helpers/SetupStepUpdater.js';
|
|
|
16
16
|
import { ContextMiddleware } from './middleware/ContextMiddleware.js';
|
|
17
17
|
import { AuditLogService } from './services/AuditLogService.js';
|
|
18
18
|
import { BalanceItemService } from './services/BalanceItemService.js';
|
|
19
|
+
import { CpuService } from './services/CpuService.js';
|
|
19
20
|
import { DocumentService } from './services/DocumentService.js';
|
|
20
21
|
import { FileSignService } from './services/FileSignService.js';
|
|
21
22
|
import { PlatformMembershipService } from './services/PlatformMembershipService.js';
|
|
22
23
|
import { UitpasService } from './services/uitpas/UitpasService.js';
|
|
23
24
|
import { UniqueUserService } from './services/UniqueUserService.js';
|
|
24
|
-
import { CpuService } from './services/CpuService.js';
|
|
25
|
-
import { SQLLogger } from '@stamhoofd/sql';
|
|
26
25
|
|
|
27
26
|
process.on('unhandledRejection', (error: Error) => {
|
|
28
27
|
console.error('unhandledRejection');
|
|
@@ -149,8 +148,8 @@ export const boot = async (options: { killProcess: boolean }) => {
|
|
|
149
148
|
CpuService.startMonitoring();
|
|
150
149
|
}
|
|
151
150
|
else if (STAMHOOFD.environment === 'development') {
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
const { loadDebugFunctions } = await import('./debug.js');
|
|
152
|
+
loadDebugFunctions({ routerServer });
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
if (routerServer.server) {
|
|
@@ -248,7 +247,10 @@ export const boot = async (options: { killProcess: boolean }) => {
|
|
|
248
247
|
// Register crons
|
|
249
248
|
await import('./crons.js');
|
|
250
249
|
|
|
250
|
+
// Audit logs
|
|
251
|
+
await import('./audit-logs/init.js');
|
|
251
252
|
AuditLogService.listen();
|
|
253
|
+
|
|
252
254
|
PlatformMembershipService.listen();
|
|
253
255
|
DocumentService.listen();
|
|
254
256
|
SetupStepUpdater.listen();
|
package/src/crons/amazon-ses.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { registerCron } from '@stamhoofd/crons';
|
|
|
8
8
|
import { Email, EmailAddress } from '@stamhoofd/email';
|
|
9
9
|
import { AuditLog, EmailRecipient, Organization } from '@stamhoofd/models';
|
|
10
10
|
import { AuditLogReplacement, AuditLogReplacementType, AuditLogSource, AuditLogType } from '@stamhoofd/structures';
|
|
11
|
-
import { ForwardHandler } from '../helpers/ForwardHandler';
|
|
11
|
+
import { ForwardHandler } from '../helpers/ForwardHandler.js';
|
|
12
12
|
import { Email as EmailModel } from '@stamhoofd/models';
|
|
13
13
|
|
|
14
14
|
registerCron('checkComplaints', checkComplaints);
|
|
@@ -2,7 +2,7 @@ import { registerCron } from '@stamhoofd/crons';
|
|
|
2
2
|
import { CachedBalance, Email, EmailRecipient, Organization, User } from '@stamhoofd/models';
|
|
3
3
|
import { IterableSQLSelect, readDynamicSQLExpression, SQL, SQLCalculation, SQLPlusSign } from '@stamhoofd/sql';
|
|
4
4
|
import { EmailRecipientFilter, EmailRecipientFilterType, EmailRecipientSubfilter, EmailTemplateType, OrganizationEmail, ReceivableBalanceType, StamhoofdFilter } from '@stamhoofd/structures';
|
|
5
|
-
import { ContextInstance } from '../helpers/Context';
|
|
5
|
+
import { ContextInstance } from '../helpers/Context.js';
|
|
6
6
|
|
|
7
7
|
registerCron('balanceEmails', balanceEmails);
|
|
8
8
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dirent } from 'fs';
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
|
-
import { clearExcelCacheHelper } from './clearExcelCache';
|
|
3
|
+
import { clearExcelCacheHelper } from './clearExcelCache.js';
|
|
4
4
|
|
|
5
5
|
const testPath = '/Users/user/project/backend/app/api/.cache';
|
|
6
6
|
jest.mock('fs/promises');
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We cannot keep deletedAt data forever. We only keep it that way to debug things or be able to easily restore data.
|
|
3
|
+
* After 1 month of deletion, we should delete it permanently.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { registerCron } from '@stamhoofd/crons';
|
|
7
|
+
import { Group } from '@stamhoofd/models';
|
|
8
|
+
|
|
9
|
+
let lastRunDate: number | null = null;
|
|
10
|
+
const keepDeletedDataForDays = 30 * 24 * 60 * 60 * 1000; // 30 days in milliseconds
|
|
11
|
+
|
|
12
|
+
registerCron('delete-archived-data', deleteArchivedData);
|
|
13
|
+
|
|
14
|
+
function shouldRun() {
|
|
15
|
+
const now = new Date();
|
|
16
|
+
|
|
17
|
+
if (now.getDate() === lastRunDate) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const hour = now.getHours();
|
|
22
|
+
|
|
23
|
+
// between 4 and 5 AM - except in development
|
|
24
|
+
if (hour !== 4 && STAMHOOFD.environment !== 'development') {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function deleteArchivedData() {
|
|
32
|
+
if (!shouldRun()) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const now = new Date();
|
|
37
|
+
lastRunDate = now.getDate();
|
|
38
|
+
|
|
39
|
+
console.log('Deleting archived data...');
|
|
40
|
+
|
|
41
|
+
const result = await Group.delete()
|
|
42
|
+
.where('deletedAt', '<', new Date(now.getTime() - keepDeletedDataForDays))
|
|
43
|
+
.delete();
|
|
44
|
+
console.log('Deleted groups:', result.affectedRows);
|
|
45
|
+
|
|
46
|
+
// For now, we don't delete orders yet (can 'fuck' up pagination because deleted orders are still used in the frontend to remove cached orders)
|
|
47
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { registerCron } from '@stamhoofd/crons';
|
|
2
|
-
import { FlagMomentCleanup } from '../helpers/FlagMomentCleanup';
|
|
2
|
+
import { FlagMomentCleanup } from '../helpers/FlagMomentCleanup.js';
|
|
3
3
|
import { Platform, RegistrationPeriod } from '@stamhoofd/models';
|
|
4
4
|
|
|
5
5
|
// Only delete responsibilities when the server is running during a month change.
|
package/src/crons/index.ts
CHANGED
package/src/crons.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { PaymentMethod, PaymentProvider, PaymentStatus } from '@stamhoofd/struct
|
|
|
4
4
|
import { Formatter } from '@stamhoofd/utility';
|
|
5
5
|
import { SQL } from '@stamhoofd/sql';
|
|
6
6
|
import { registerCron } from '@stamhoofd/crons';
|
|
7
|
-
import { checkSettlements } from './helpers/CheckSettlements';
|
|
8
|
-
import { PaymentService } from './services/PaymentService';
|
|
9
|
-
import { RegistrationService } from './services/RegistrationService';
|
|
7
|
+
import { checkSettlements } from './helpers/CheckSettlements.js';
|
|
8
|
+
import { PaymentService } from './services/PaymentService.js';
|
|
9
|
+
import { RegistrationService } from './services/RegistrationService.js';
|
|
10
10
|
|
|
11
11
|
let lastDNSCheck: Date | null = null;
|
|
12
12
|
let lastDNSId = '';
|