@stamhoofd/backend 2.39.1 → 2.40.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/eslint.config.mjs +5 -0
- package/index.ts +81 -74
- package/jest.config.cjs +10 -0
- package/migrations.ts +16 -14
- package/package.json +11 -11
- package/src/crons/clear-excel-cache.test.ts +48 -50
- package/src/crons/clear-excel-cache.ts +18 -18
- package/src/crons/setup-steps.ts +2 -2
- package/src/crons.ts +325 -306
- package/src/decoders/StringArrayDecoder.ts +7 -7
- package/src/decoders/StringNullableDecoder.ts +1 -2
- package/src/email-recipient-loaders/members.ts +22 -22
- package/src/endpoints/admin/memberships/ChargeMembershipsEndpoint.ts +8 -9
- package/src/endpoints/admin/memberships/GetChargeMembershipsSummaryEndpoint.ts +39 -40
- package/src/endpoints/admin/organizations/GetOrganizationsCountEndpoint.ts +8 -8
- package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +44 -45
- package/src/endpoints/admin/organizations/PatchOrganizationsEndpoint.ts +58 -57
- package/src/endpoints/auth/CreateAdminEndpoint.ts +48 -45
- package/src/endpoints/auth/CreateTokenEndpoint.test.ts +31 -31
- package/src/endpoints/auth/CreateTokenEndpoint.ts +146 -147
- package/src/endpoints/auth/DeleteTokenEndpoint.ts +7 -7
- package/src/endpoints/auth/DeleteUserEndpoint.ts +15 -15
- package/src/endpoints/auth/ForgotPasswordEndpoint.ts +17 -18
- package/src/endpoints/auth/GetOtherUserEndpoint.ts +9 -10
- package/src/endpoints/auth/GetUserEndpoint.test.ts +32 -35
- package/src/endpoints/auth/GetUserEndpoint.ts +5 -6
- package/src/endpoints/auth/PatchApiUserEndpoint.ts +35 -33
- package/src/endpoints/auth/PatchUserEndpoint.ts +55 -52
- package/src/endpoints/auth/PollEmailVerificationEndpoint.ts +9 -9
- package/src/endpoints/auth/RetryEmailVerificationEndpoint.ts +8 -8
- package/src/endpoints/auth/SignupEndpoint.ts +37 -36
- package/src/endpoints/auth/VerifyEmailEndpoint.ts +29 -28
- package/src/endpoints/global/addresses/SearchRegionsEndpoint.ts +33 -33
- package/src/endpoints/global/addresses/ValidateAddressEndpoint.ts +7 -7
- package/src/endpoints/global/caddy/CheckDomainCertEndpoint.ts +37 -37
- package/src/endpoints/global/email/CreateEmailEndpoint.ts +30 -30
- package/src/endpoints/global/email/GetEmailAddressEndpoint.ts +13 -13
- package/src/endpoints/global/email/GetEmailEndpoint.ts +13 -13
- package/src/endpoints/global/email/ManageEmailAddressEndpoint.ts +16 -16
- package/src/endpoints/global/email/PatchEmailEndpoint.ts +25 -25
- package/src/endpoints/global/events/GetEventsEndpoint.ts +43 -44
- package/src/endpoints/global/events/PatchEventsEndpoint.ts +127 -172
- package/src/endpoints/global/files/ExportToExcelEndpoint.ts +49 -50
- package/src/endpoints/global/files/GetFileCache.ts +13 -13
- package/src/endpoints/global/files/UploadFile.ts +51 -54
- package/src/endpoints/global/files/UploadImage.ts +53 -53
- package/src/endpoints/global/groups/GetGroupsEndpoint.ts +25 -25
- package/src/endpoints/global/members/GetMemberFamilyEndpoint.ts +24 -23
- package/src/endpoints/global/members/GetMembersCountEndpoint.ts +8 -8
- package/src/endpoints/global/members/GetMembersEndpoint.ts +105 -102
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +240 -239
- package/src/endpoints/global/organizations/CheckRegisterCodeEndpoint.ts +12 -14
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.test.ts +32 -33
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.ts +48 -57
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.test.ts +21 -22
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.ts +28 -28
- package/src/endpoints/global/organizations/GetOrganizationFromUriEndpoint.ts +18 -18
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.test.ts +20 -20
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.ts +17 -17
- package/src/endpoints/global/payments/StripeWebhookEndpoint.ts +81 -75
- package/src/endpoints/global/platform/GetPlatformAdminsEndpoint.ts +14 -14
- package/src/endpoints/global/platform/GetPlatformEnpoint.ts +11 -11
- package/src/endpoints/global/platform/PatchPlatformEnpoint.ts +71 -68
- package/src/endpoints/global/registration/GetPaymentRegistrations.ts +27 -27
- package/src/endpoints/global/registration/GetUserBillingStatusEndpoint.ts +30 -30
- package/src/endpoints/global/registration/GetUserDetailedBillingStatusEndpoint.ts +34 -34
- package/src/endpoints/global/registration/GetUserDocumentsEndpoint.ts +26 -26
- package/src/endpoints/global/registration/GetUserMembersEndpoint.ts +12 -12
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.ts +90 -90
- package/src/endpoints/global/registration/RegisterMembersEndpoint.test.ts +118 -121
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +362 -350
- package/src/endpoints/global/registration-periods/GetRegistrationPeriodsEndpoint.ts +8 -9
- package/src/endpoints/global/registration-periods/PatchRegistrationPeriodsEndpoint.ts +21 -21
- package/src/endpoints/global/webshops/GetWebshopFromDomainEndpoint.ts +65 -65
- package/src/endpoints/organization/dashboard/billing/GetOrganizationBillingStatusEndpoint.ts +9 -9
- package/src/endpoints/organization/dashboard/billing/GetOrganizationDetailedBillingStatusEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplateXML.ts +17 -17
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplatesEndpoint.ts +21 -21
- package/src/endpoints/organization/dashboard/documents/GetDocumentsEndpoint.ts +15 -15
- package/src/endpoints/organization/dashboard/documents/PatchDocumentEndpoint.ts +52 -52
- package/src/endpoints/organization/dashboard/documents/PatchDocumentTemplateEndpoint.ts +37 -37
- package/src/endpoints/organization/dashboard/email/CheckEmailBouncesEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/email/EmailEndpoint.ts +113 -112
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.ts +29 -29
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.ts +48 -47
- package/src/endpoints/organization/dashboard/mollie/CheckMollieEndpoint.ts +22 -21
- package/src/endpoints/organization/dashboard/mollie/ConnectMollieEndpoint.ts +13 -14
- package/src/endpoints/organization/dashboard/mollie/DisconnectMollieEndpoint.ts +12 -13
- package/src/endpoints/organization/dashboard/mollie/GetMollieDashboardEndpoint.ts +24 -24
- package/src/endpoints/organization/dashboard/nolt/CreateNoltTokenEndpoint.ts +10 -12
- package/src/endpoints/organization/dashboard/organization/GetOrganizationArchivedGroups.ts +14 -14
- package/src/endpoints/organization/dashboard/organization/GetOrganizationDeletedGroups.ts +13 -13
- package/src/endpoints/organization/dashboard/organization/GetOrganizationSSOEndpoint.ts +12 -12
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.test.ts +120 -124
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +172 -173
- package/src/endpoints/organization/dashboard/organization/SetOrganizationDomainEndpoint.ts +88 -89
- package/src/endpoints/organization/dashboard/organization/SetOrganizationSSOEndpoint.ts +12 -12
- package/src/endpoints/organization/dashboard/payments/GetMemberBalanceEndpoint.ts +17 -17
- package/src/endpoints/organization/dashboard/payments/GetPaymentsCountEndpoint.ts +8 -8
- package/src/endpoints/organization/dashboard/payments/GetPaymentsEndpoint.ts +66 -67
- package/src/endpoints/organization/dashboard/payments/PatchBalanceItemsEndpoint.ts +47 -47
- package/src/endpoints/organization/dashboard/payments/PatchPaymentsEndpoint.ts +93 -91
- package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.ts +16 -17
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.ts +170 -167
- package/src/endpoints/organization/dashboard/registration-periods/SetupStepReviewEndpoint.ts +25 -24
- package/src/endpoints/organization/dashboard/stripe/ConnectStripeEndpoint.ts +22 -23
- package/src/endpoints/organization/dashboard/stripe/DeleteStripeAccountEndpoint.ts +22 -22
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountLinkEndpoint.ts +17 -18
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountsEndpoint.ts +8 -9
- package/src/endpoints/organization/dashboard/stripe/GetStripeLoginLinkEndpoint.ts +17 -18
- package/src/endpoints/organization/dashboard/stripe/UpdateStripeAccountEndpoint.ts +14 -15
- package/src/endpoints/organization/dashboard/users/CreateApiUserEndpoint.ts +19 -19
- package/src/endpoints/organization/dashboard/users/DeleteUserEndpoint.ts +19 -19
- package/src/endpoints/organization/dashboard/users/GetApiUsersEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/users/GetOrganizationAdminsEndpoint.ts +12 -12
- package/src/endpoints/organization/dashboard/webshops/CreateWebshopEndpoint.ts +103 -100
- package/src/endpoints/organization/dashboard/webshops/DeleteWebshopEndpoint.ts +11 -12
- package/src/endpoints/organization/dashboard/webshops/GetDiscountCodesEndpoint.ts +15 -15
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/webshops/GetWebshopTicketsEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/webshops/GetWebshopUriAvailabilityEndpoint.ts +23 -23
- package/src/endpoints/organization/dashboard/webshops/PatchDiscountCodesEndpoint.ts +54 -52
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopEndpoint.ts +84 -81
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint.ts +120 -111
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopTicketsEndpoint.ts +24 -24
- package/src/endpoints/organization/dashboard/webshops/VerifyWebshopDomainEndpoint.ts +18 -18
- package/src/endpoints/organization/shared/ExchangePaymentEndpoint.ts +141 -130
- package/src/endpoints/organization/shared/GetDocumentHtml.ts +25 -25
- package/src/endpoints/organization/shared/GetPaymentEndpoint.ts +18 -18
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.test.ts +36 -37
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.ts +9 -9
- package/src/endpoints/organization/shared/auth/OpenIDConnectCallbackEndpoint.ts +11 -11
- package/src/endpoints/organization/shared/auth/OpenIDConnectStartEndpoint.ts +28 -27
- package/src/endpoints/organization/webshops/CheckWebshopDiscountCodesEndpoint.ts +20 -20
- package/src/endpoints/organization/webshops/GetOrderByPaymentEndpoint.ts +22 -22
- package/src/endpoints/organization/webshops/GetOrderEndpoint.ts +14 -14
- package/src/endpoints/organization/webshops/GetTicketsEndpoint.ts +57 -56
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.test.ts +65 -66
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.ts +18 -17
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.test.ts +124 -128
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.ts +154 -145
- package/src/excel-loaders/members.ts +102 -103
- package/src/excel-loaders/payments.ts +155 -156
- package/src/helpers/AddressValidator.test.ts +32 -32
- package/src/helpers/AddressValidator.ts +128 -122
- package/src/helpers/AdminPermissionChecker.ts +339 -236
- package/src/helpers/AuthenticatedStructures.ts +233 -134
- package/src/helpers/BuckarooHelper.ts +134 -134
- package/src/helpers/CheckSettlements.ts +94 -88
- package/src/helpers/Context.ts +87 -86
- package/src/helpers/CookieHelper.ts +23 -22
- package/src/helpers/EmailResumer.ts +10 -10
- package/src/helpers/FileCache.ts +62 -62
- package/src/helpers/ForwardHandler.test.ts +122 -124
- package/src/helpers/ForwardHandler.ts +76 -70
- package/src/helpers/MemberUserSyncer.ts +101 -96
- package/src/helpers/MembershipCharger.ts +69 -69
- package/src/helpers/MembershipHelper.ts +11 -12
- package/src/helpers/OpenIDConnectHelper.ts +85 -82
- package/src/helpers/PeriodHelper.ts +65 -70
- package/src/helpers/StripeHelper.ts +146 -137
- package/src/helpers/StripePayoutChecker.ts +51 -52
- package/src/helpers/ViesHelper.ts +46 -44
- package/src/helpers/fetchToAsyncIterator.ts +14 -14
- package/src/helpers/xlsxAddressTransformerColumnFactory.ts +50 -52
- package/src/middleware/ContextMiddleware.ts +5 -5
- package/src/migrations/1646578856-validate-addresses.ts +6 -9
- package/src/seeds/0000000000-example.ts +3 -5
- package/src/seeds/1715028563-user-permissions.ts +16 -18
- package/src/seeds/1722256498-group-update-occupancy.ts +12 -12
- package/src/seeds/1722344162-sync-member-users.ts +14 -15
- package/src/seeds/1722344162-update-membership.ts +6 -6
- package/src/seeds/1726055544-balance-item-paid.ts +4 -4
- package/src/seeds/1726055545-balance-item-pending.ts +4 -4
- package/src/seeds/1726494419-update-cached-outstanding-balance.ts +16 -16
- package/src/seeds/1726494420-update-cached-outstanding-balance-from-items.ts +12 -12
- package/src/seeds/1726572303-schedule-stock-updates.ts +12 -12
- package/src/seeds/1726847064-setup-steps.ts +16 -0
- package/src/sql-filters/balance-item-payments.ts +7 -7
- package/src/sql-filters/events.ts +14 -14
- package/src/sql-filters/members.ts +96 -96
- package/src/sql-filters/organizations.ts +139 -75
- package/src/sql-filters/payments.ts +28 -28
- package/src/sql-filters/registrations.ts +14 -14
- package/src/sql-sorters/events.ts +25 -25
- package/src/sql-sorters/members.ts +26 -26
- package/src/sql-sorters/organizations.ts +36 -36
- package/src/sql-sorters/payments.ts +26 -26
- package/tests/e2e/stock.test.ts +616 -621
- package/tests/e2e/tickets.test.ts +255 -260
- package/tests/helpers/StripeMocker.ts +177 -179
- package/tests/helpers/TestServer.ts +9 -9
- package/tests/jest.global.setup.ts +14 -13
- package/tests/jest.setup.ts +33 -32
- package/.eslintrc.js +0 -61
- package/jest.config.js +0 -11
- package/src/helpers/SetupStepsUpdater.ts +0 -359
- package/src/seeds/1724076679-setup-steps.ts +0 -16
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Request } from
|
|
2
|
-
import { StripeAccount } from
|
|
3
|
-
import nock from
|
|
1
|
+
import { Request } from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { StripeAccount } from '@stamhoofd/models';
|
|
3
|
+
import nock from 'nock';
|
|
4
4
|
import qs from 'qs';
|
|
5
|
-
import { v4 as uuidv4 } from
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
6
|
|
|
7
|
-
import { StripeWebookEndpoint } from
|
|
8
|
-
import { StripeHelper } from
|
|
9
|
-
import { testServer } from
|
|
7
|
+
import { StripeWebookEndpoint } from '../../src/endpoints/global/payments/StripeWebhookEndpoint';
|
|
8
|
+
import { StripeHelper } from '../../src/helpers/StripeHelper';
|
|
9
|
+
import { testServer } from './TestServer';
|
|
10
10
|
|
|
11
11
|
export class StripeMocker {
|
|
12
|
-
paymentIntents: {id: string}[] = []
|
|
13
|
-
charges: {id: string}[] = [];
|
|
12
|
+
paymentIntents: { id: string }[] = [];
|
|
13
|
+
charges: { id: string }[] = [];
|
|
14
14
|
#forceFailure = false;
|
|
15
15
|
|
|
16
16
|
reset() {
|
|
@@ -55,7 +55,7 @@ export class StripeMocker {
|
|
|
55
55
|
return [500];
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
if (this.#forceFailure
|
|
58
|
+
if (this.#forceFailure) {
|
|
59
59
|
return [400];
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -63,8 +63,8 @@ export class StripeMocker {
|
|
|
63
63
|
// Ignore: this is just creating a saved payment method for Bancontact/iDEAL
|
|
64
64
|
return [200, {
|
|
65
65
|
object: 'payment_method',
|
|
66
|
-
id: this.createId('pm')
|
|
67
|
-
}]
|
|
66
|
+
id: this.createId('pm'),
|
|
67
|
+
}];
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (resource === 'payment_intents') {
|
|
@@ -73,8 +73,6 @@ export class StripeMocker {
|
|
|
73
73
|
|
|
74
74
|
return [500];
|
|
75
75
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
76
|
}
|
|
79
77
|
|
|
80
78
|
clear() {
|
|
@@ -89,7 +87,7 @@ export class StripeMocker {
|
|
|
89
87
|
#getPaymentIntent(id: string) {
|
|
90
88
|
const intent = this.paymentIntents.find(i => i.id === id);
|
|
91
89
|
if (!intent) {
|
|
92
|
-
return [404]
|
|
90
|
+
return [404];
|
|
93
91
|
}
|
|
94
92
|
return [200, intent];
|
|
95
93
|
}
|
|
@@ -97,7 +95,7 @@ export class StripeMocker {
|
|
|
97
95
|
#getCharge(id: string) {
|
|
98
96
|
const intent = this.charges.find(i => i.id === id);
|
|
99
97
|
if (!intent) {
|
|
100
|
-
return [404]
|
|
98
|
+
return [404];
|
|
101
99
|
}
|
|
102
100
|
return [200, intent];
|
|
103
101
|
}
|
|
@@ -109,16 +107,16 @@ export class StripeMocker {
|
|
|
109
107
|
status: 'requires_action',
|
|
110
108
|
next_action: {
|
|
111
109
|
redirect_to_url: {
|
|
112
|
-
url: 'https://paymenturl'
|
|
113
|
-
}
|
|
114
|
-
}
|
|
110
|
+
url: 'https://paymenturl',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
115
113
|
};
|
|
116
114
|
this.paymentIntents.push(intent);
|
|
117
115
|
return [200, intent];
|
|
118
116
|
}
|
|
119
117
|
|
|
120
118
|
getLastIntent() {
|
|
121
|
-
return this.paymentIntents[this.paymentIntents.length - 1]
|
|
119
|
+
return this.paymentIntents[this.paymentIntents.length - 1];
|
|
122
120
|
}
|
|
123
121
|
|
|
124
122
|
async succeedPayment(intent) {
|
|
@@ -127,9 +125,9 @@ export class StripeMocker {
|
|
|
127
125
|
payment_method_details: {
|
|
128
126
|
bancontact: {
|
|
129
127
|
iban_last4: 1234,
|
|
130
|
-
verified_name: 'John Doe'
|
|
131
|
-
}
|
|
132
|
-
}
|
|
128
|
+
verified_name: 'John Doe',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
133
131
|
};
|
|
134
132
|
|
|
135
133
|
this.charges.push(charge);
|
|
@@ -140,9 +138,9 @@ export class StripeMocker {
|
|
|
140
138
|
await this.#sendWebhook({
|
|
141
139
|
type: 'payment_intent.succeeded',
|
|
142
140
|
data: {
|
|
143
|
-
object: intent
|
|
144
|
-
}
|
|
145
|
-
})
|
|
141
|
+
object: intent,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
146
144
|
}
|
|
147
145
|
|
|
148
146
|
async failPayment(intent) {
|
|
@@ -151,22 +149,22 @@ export class StripeMocker {
|
|
|
151
149
|
await this.#sendWebhook({
|
|
152
150
|
type: 'payment_intent.payment_failed',
|
|
153
151
|
data: {
|
|
154
|
-
object: intent
|
|
155
|
-
}
|
|
156
|
-
})
|
|
152
|
+
object: intent,
|
|
153
|
+
},
|
|
154
|
+
});
|
|
157
155
|
}
|
|
158
156
|
|
|
159
|
-
async #sendWebhook(payload: {[key: string]: unknown}) {
|
|
157
|
+
async #sendWebhook(payload: { [key: string]: unknown }) {
|
|
160
158
|
payload.id = this.createId('wh');
|
|
161
159
|
|
|
162
|
-
const stripe = StripeHelper.getInstance()
|
|
163
|
-
const endpoint = new StripeWebookEndpoint()
|
|
164
|
-
|
|
165
|
-
const r = Request.buildJson(
|
|
160
|
+
const stripe = StripeHelper.getInstance();
|
|
161
|
+
const endpoint = new StripeWebookEndpoint();
|
|
162
|
+
|
|
163
|
+
const r = Request.buildJson('POST', `/stripe/webhooks`, undefined, payload);
|
|
166
164
|
r.headers['stripe-signature'] = stripe.webhooks.generateTestHeaderString({
|
|
167
165
|
payload: JSON.stringify(payload),
|
|
168
|
-
secret: STAMHOOFD.STRIPE_ENDPOINT_SECRET
|
|
169
|
-
})
|
|
166
|
+
secret: STAMHOOFD.STRIPE_ENDPOINT_SECRET,
|
|
167
|
+
});
|
|
170
168
|
await testServer.test(endpoint, r);
|
|
171
169
|
}
|
|
172
170
|
|
|
@@ -182,7 +180,7 @@ export class StripeMocker {
|
|
|
182
180
|
const keywords = {
|
|
183
181
|
true: true,
|
|
184
182
|
false: false,
|
|
185
|
-
null: null
|
|
183
|
+
null: null,
|
|
186
184
|
};
|
|
187
185
|
if (typeof value === 'string' && value in keywords) {
|
|
188
186
|
return keywords[value];
|
|
@@ -193,170 +191,170 @@ export class StripeMocker {
|
|
|
193
191
|
}
|
|
194
192
|
|
|
195
193
|
return value;
|
|
196
|
-
}
|
|
194
|
+
},
|
|
197
195
|
});
|
|
198
196
|
}
|
|
199
197
|
|
|
200
198
|
async createStripeAccount(organizationId: string): Promise<StripeAccount> {
|
|
201
|
-
const account = new StripeAccount()
|
|
202
|
-
account.organizationId = organizationId
|
|
199
|
+
const account = new StripeAccount();
|
|
200
|
+
account.organizationId = organizationId;
|
|
203
201
|
account.accountId = this.createId('acct');
|
|
204
|
-
account.setMetaFromStripeAccount(defaultBlobData)
|
|
202
|
+
account.setMetaFromStripeAccount(defaultBlobData);
|
|
205
203
|
await account.save();
|
|
206
204
|
return account;
|
|
207
205
|
}
|
|
208
206
|
|
|
209
207
|
stop() {
|
|
210
|
-
nock.cleanAll()
|
|
208
|
+
nock.cleanAll();
|
|
211
209
|
}
|
|
212
210
|
}
|
|
213
211
|
|
|
214
212
|
const defaultBlobData = {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
213
|
+
business_profile: {
|
|
214
|
+
annual_revenue: null,
|
|
215
|
+
estimated_worker_count: null,
|
|
216
|
+
mcc: '8641',
|
|
217
|
+
name: 'Demo vereniging',
|
|
218
|
+
support_address: null,
|
|
219
|
+
support_email: null,
|
|
220
|
+
support_phone: null,
|
|
221
|
+
support_url: null,
|
|
222
|
+
url: 'www.stamhoofd.be',
|
|
225
223
|
},
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
224
|
+
capabilities: {
|
|
225
|
+
bancontact_payments: 'active',
|
|
226
|
+
card_payments: 'active',
|
|
227
|
+
ideal_payments: 'active',
|
|
228
|
+
transfers: 'active',
|
|
231
229
|
},
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
230
|
+
charges_enabled: true,
|
|
231
|
+
country: 'BE',
|
|
232
|
+
created: 0,
|
|
233
|
+
default_currency: 'eur',
|
|
234
|
+
details_submitted: true,
|
|
235
|
+
email: 'tests@stamhoofd.be',
|
|
236
|
+
external_accounts: {
|
|
237
|
+
data: [
|
|
238
|
+
{
|
|
239
|
+
account: 'acct_test',
|
|
240
|
+
account_holder_name: null,
|
|
241
|
+
account_holder_type: null,
|
|
242
|
+
account_type: null,
|
|
243
|
+
available_payout_methods: [
|
|
244
|
+
'standard',
|
|
245
|
+
],
|
|
246
|
+
bank_name: 'KBC BANK NV',
|
|
247
|
+
country: 'BE',
|
|
248
|
+
currency: 'eur',
|
|
249
|
+
default_for_currency: true,
|
|
250
|
+
fingerprint: 'xxxxxxxxxxxx',
|
|
251
|
+
future_requirements: {
|
|
252
|
+
currently_due: [],
|
|
253
|
+
errors: [],
|
|
254
|
+
past_due: [],
|
|
255
|
+
pending_verification: [],
|
|
256
|
+
},
|
|
257
|
+
id: 'ba_xxxxxxxxxxx',
|
|
258
|
+
last4: '1111',
|
|
259
|
+
metadata: {},
|
|
260
|
+
object: 'bank_account',
|
|
261
|
+
requirements: {
|
|
262
|
+
currently_due: [],
|
|
263
|
+
errors: [],
|
|
264
|
+
past_due: [],
|
|
265
|
+
pending_verification: [],
|
|
266
|
+
},
|
|
267
|
+
routing_number: 'KREDBEBB',
|
|
268
|
+
status: 'new',
|
|
258
269
|
},
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
"currently_due": [],
|
|
265
|
-
"errors": [],
|
|
266
|
-
"past_due": [],
|
|
267
|
-
"pending_verification": []
|
|
268
|
-
},
|
|
269
|
-
"routing_number": "KREDBEBB",
|
|
270
|
-
"status": "new"
|
|
271
|
-
}
|
|
272
|
-
],
|
|
273
|
-
"has_more": false,
|
|
274
|
-
"object": "list",
|
|
275
|
-
"total_count": 1,
|
|
276
|
-
"url": "/v1/accounts/acct_test/external_accounts"
|
|
277
|
-
},
|
|
278
|
-
"future_requirements": {
|
|
279
|
-
"alternatives": [],
|
|
280
|
-
"current_deadline": null,
|
|
281
|
-
"currently_due": [],
|
|
282
|
-
"disabled_reason": null,
|
|
283
|
-
"errors": [],
|
|
284
|
-
"eventually_due": [],
|
|
285
|
-
"past_due": [],
|
|
286
|
-
"pending_verification": []
|
|
287
|
-
},
|
|
288
|
-
"id": "acct_text",
|
|
289
|
-
"login_links": {
|
|
290
|
-
"data": [],
|
|
291
|
-
"has_more": false,
|
|
292
|
-
"object": "list",
|
|
293
|
-
"total_count": 0,
|
|
294
|
-
"url": "/v1/accounts/acct_test/login_links"
|
|
270
|
+
],
|
|
271
|
+
has_more: false,
|
|
272
|
+
object: 'list',
|
|
273
|
+
total_count: 1,
|
|
274
|
+
url: '/v1/accounts/acct_test/external_accounts',
|
|
295
275
|
},
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
"eventually_due": [],
|
|
306
|
-
"past_due": [],
|
|
307
|
-
"pending_verification": []
|
|
276
|
+
future_requirements: {
|
|
277
|
+
alternatives: [],
|
|
278
|
+
current_deadline: null,
|
|
279
|
+
currently_due: [],
|
|
280
|
+
disabled_reason: null,
|
|
281
|
+
errors: [],
|
|
282
|
+
eventually_due: [],
|
|
283
|
+
past_due: [],
|
|
284
|
+
pending_verification: [],
|
|
308
285
|
},
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
286
|
+
id: 'acct_text',
|
|
287
|
+
login_links: {
|
|
288
|
+
data: [],
|
|
289
|
+
has_more: false,
|
|
290
|
+
object: 'list',
|
|
291
|
+
total_count: 0,
|
|
292
|
+
url: '/v1/accounts/acct_test/login_links',
|
|
313
293
|
},
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
294
|
+
metadata: {},
|
|
295
|
+
object: 'account',
|
|
296
|
+
payouts_enabled: true,
|
|
297
|
+
requirements: {
|
|
298
|
+
alternatives: [],
|
|
299
|
+
current_deadline: null,
|
|
300
|
+
currently_due: [],
|
|
301
|
+
disabled_reason: null,
|
|
302
|
+
errors: [],
|
|
303
|
+
eventually_due: [],
|
|
304
|
+
past_due: [],
|
|
305
|
+
pending_verification: [],
|
|
319
306
|
},
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
},
|
|
326
|
-
"card_payments": {
|
|
327
|
-
"decline_on": {
|
|
328
|
-
"avs_failure": false,
|
|
329
|
-
"cvc_failure": false
|
|
307
|
+
settings: {
|
|
308
|
+
bacs_debit_payments: {
|
|
309
|
+
display_name: null,
|
|
310
|
+
service_user_number: null,
|
|
330
311
|
},
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
"display_name": "Stamhoofd",
|
|
337
|
-
"timezone": "Etc/UTC"
|
|
338
|
-
},
|
|
339
|
-
"invoices": {
|
|
340
|
-
"default_account_tax_ids": null
|
|
341
|
-
},
|
|
342
|
-
"payments": {
|
|
343
|
-
"statement_descriptor": "WWW.STAMHOOFD.BE",
|
|
344
|
-
"statement_descriptor_kana": null,
|
|
345
|
-
"statement_descriptor_kanji": null
|
|
346
|
-
},
|
|
347
|
-
"payouts": {
|
|
348
|
-
"debit_negative_balances": true,
|
|
349
|
-
"schedule": {
|
|
350
|
-
"delay_days": 7,
|
|
351
|
-
"interval": "weekly",
|
|
352
|
-
"weekly_anchor": "monday"
|
|
312
|
+
branding: {
|
|
313
|
+
icon: 'file_test',
|
|
314
|
+
logo: null,
|
|
315
|
+
primary_color: '#000000',
|
|
316
|
+
secondary_color: '#000000',
|
|
353
317
|
},
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
318
|
+
card_issuing: {
|
|
319
|
+
tos_acceptance: {
|
|
320
|
+
date: null,
|
|
321
|
+
ip: null,
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
card_payments: {
|
|
325
|
+
decline_on: {
|
|
326
|
+
avs_failure: false,
|
|
327
|
+
cvc_failure: false,
|
|
328
|
+
},
|
|
329
|
+
statement_descriptor_prefix: null,
|
|
330
|
+
statement_descriptor_prefix_kana: null,
|
|
331
|
+
statement_descriptor_prefix_kanji: null,
|
|
332
|
+
},
|
|
333
|
+
dashboard: {
|
|
334
|
+
display_name: 'Stamhoofd',
|
|
335
|
+
timezone: 'Etc/UTC',
|
|
336
|
+
},
|
|
337
|
+
invoices: {
|
|
338
|
+
default_account_tax_ids: null,
|
|
339
|
+
},
|
|
340
|
+
payments: {
|
|
341
|
+
statement_descriptor: 'WWW.STAMHOOFD.BE',
|
|
342
|
+
statement_descriptor_kana: null,
|
|
343
|
+
statement_descriptor_kanji: null,
|
|
344
|
+
},
|
|
345
|
+
payouts: {
|
|
346
|
+
debit_negative_balances: true,
|
|
347
|
+
schedule: {
|
|
348
|
+
delay_days: 7,
|
|
349
|
+
interval: 'weekly',
|
|
350
|
+
weekly_anchor: 'monday',
|
|
351
|
+
},
|
|
352
|
+
statement_descriptor: null,
|
|
353
|
+
},
|
|
354
|
+
sepa_debit_payments: {},
|
|
357
355
|
},
|
|
358
|
-
|
|
359
|
-
|
|
356
|
+
tos_acceptance: {
|
|
357
|
+
date: 0,
|
|
360
358
|
},
|
|
361
|
-
|
|
362
|
-
};
|
|
359
|
+
type: 'express',
|
|
360
|
+
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { TestServer } from
|
|
2
|
-
import { VersionMiddleware } from
|
|
3
|
-
import { Version } from
|
|
1
|
+
import { TestServer } from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { VersionMiddleware } from '@stamhoofd/backend-middleware';
|
|
3
|
+
import { Version } from '@stamhoofd/structures';
|
|
4
4
|
|
|
5
|
-
import { ContextMiddleware } from
|
|
5
|
+
import { ContextMiddleware } from '../../src/middleware/ContextMiddleware';
|
|
6
6
|
|
|
7
7
|
export const testServer = new TestServer();
|
|
8
8
|
|
|
9
9
|
// Contexts
|
|
10
|
-
testServer.addRequestMiddleware(ContextMiddleware)
|
|
10
|
+
testServer.addRequestMiddleware(ContextMiddleware);
|
|
11
11
|
|
|
12
12
|
// Add version headers and minimum version
|
|
13
13
|
const versionMiddleware = new VersionMiddleware({
|
|
14
14
|
latestVersions: {
|
|
15
15
|
android: STAMHOOFD.LATEST_ANDROID_VERSION,
|
|
16
16
|
ios: STAMHOOFD.LATEST_IOS_VERSION,
|
|
17
|
-
web: Version
|
|
17
|
+
web: Version,
|
|
18
18
|
},
|
|
19
|
-
minimumVersion: 1 //168
|
|
20
|
-
})
|
|
21
|
-
testServer.addRequestMiddleware(versionMiddleware)
|
|
19
|
+
minimumVersion: 1, // 168
|
|
20
|
+
});
|
|
21
|
+
testServer.addRequestMiddleware(versionMiddleware);
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
import backendEnv from '@stamhoofd/backend-env';
|
|
2
|
+
backendEnv.load({ path: __dirname + '/../../.env.test.json' });
|
|
2
3
|
|
|
3
|
-
import { Database, Migration } from
|
|
4
|
-
import path from
|
|
5
|
-
const emailPath = require.resolve(
|
|
6
|
-
const modelsPath = require.resolve(
|
|
7
|
-
import nock from
|
|
4
|
+
import { Database, Migration } from '@simonbackx/simple-database';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
const emailPath = require.resolve('@stamhoofd/email');
|
|
7
|
+
const modelsPath = require.resolve('@stamhoofd/models');
|
|
8
|
+
import nock from 'nock';
|
|
8
9
|
|
|
9
10
|
// Disable network requests
|
|
10
|
-
nock.disableNetConnect()
|
|
11
|
+
nock.disableNetConnect();
|
|
11
12
|
|
|
12
13
|
// Set timezone!
|
|
13
|
-
process.env.TZ =
|
|
14
|
+
process.env.TZ = 'UTC';
|
|
14
15
|
|
|
15
16
|
// Quick check
|
|
16
|
-
if (new Date().getTimezoneOffset()
|
|
17
|
-
throw new Error(
|
|
17
|
+
if (new Date().getTimezoneOffset() !== 0) {
|
|
18
|
+
throw new Error('Process should always run in UTC timezone');
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export default async () => {
|
|
21
22
|
// External migrations
|
|
22
|
-
await Migration.runAll(path.dirname(modelsPath) +
|
|
23
|
-
await Migration.runAll(path.dirname(emailPath) +
|
|
23
|
+
await Migration.runAll(path.dirname(modelsPath) + '/migrations');
|
|
24
|
+
await Migration.runAll(path.dirname(emailPath) + '/migrations');
|
|
24
25
|
|
|
25
26
|
// Internal
|
|
26
|
-
await Migration.runAll(__dirname +
|
|
27
|
+
await Migration.runAll(__dirname + '/src/migrations');
|
|
27
28
|
|
|
28
29
|
await Database.end();
|
|
29
30
|
};
|
package/tests/jest.setup.ts
CHANGED
|
@@ -1,59 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
import backendEnv from '@stamhoofd/backend-env';
|
|
2
|
+
backendEnv.load({ path: __dirname + '/../../.env.test.json' });
|
|
2
3
|
|
|
3
|
-
import { Column,Database } from
|
|
4
|
+
import { Column, Database } from '@simonbackx/simple-database';
|
|
4
5
|
import { Request } from '@simonbackx/simple-endpoints';
|
|
5
|
-
import { I18n } from
|
|
6
|
-
import { Email } from
|
|
6
|
+
import { I18n } from '@stamhoofd/backend-i18n';
|
|
7
|
+
import { Email } from '@stamhoofd/email';
|
|
7
8
|
import { Version } from '@stamhoofd/structures';
|
|
8
|
-
import { sleep } from
|
|
9
|
-
import nock from
|
|
9
|
+
import { sleep } from '@stamhoofd/utility';
|
|
10
|
+
import nock from 'nock';
|
|
10
11
|
|
|
11
12
|
// Set version of saved structures
|
|
12
13
|
Column.setJSONVersion(Version);
|
|
13
14
|
|
|
14
15
|
// Disable network requests
|
|
15
|
-
nock.disableNetConnect()
|
|
16
|
+
nock.disableNetConnect();
|
|
16
17
|
|
|
17
18
|
// Automatically set endpoint default version to latest one (only in tests!)
|
|
18
|
-
Request.defaultVersion = Version
|
|
19
|
+
Request.defaultVersion = Version;
|
|
19
20
|
|
|
20
21
|
// Set timezone!
|
|
21
|
-
process.env.TZ =
|
|
22
|
+
process.env.TZ = 'UTC';
|
|
22
23
|
|
|
23
24
|
// Quick check
|
|
24
|
-
if (new Date().getTimezoneOffset()
|
|
25
|
-
throw new Error(
|
|
25
|
+
if (new Date().getTimezoneOffset() !== 0) {
|
|
26
|
+
throw new Error('Process should always run in UTC timezone');
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
console.log = jest.fn();
|
|
29
30
|
|
|
30
31
|
beforeAll(async () => {
|
|
31
|
-
await Database.delete(
|
|
32
|
-
await Database.delete(
|
|
33
|
-
await Database.delete(
|
|
34
|
-
await Database.delete(
|
|
35
|
-
await Database.delete(
|
|
36
|
-
await Database.delete(
|
|
37
|
-
await Database.delete(
|
|
38
|
-
|
|
39
|
-
await Database.delete(
|
|
40
|
-
await Database.delete(
|
|
41
|
-
await Database.delete(
|
|
42
|
-
await Database.delete(
|
|
43
|
-
|
|
44
|
-
await Database.delete(
|
|
45
|
-
|
|
46
|
-
await Database.delete(
|
|
47
|
-
await Database.delete(
|
|
48
|
-
|
|
49
|
-
await I18n.load()
|
|
32
|
+
await Database.delete('DELETE FROM `tokens`');
|
|
33
|
+
await Database.delete('DELETE FROM `users`');
|
|
34
|
+
await Database.delete('DELETE FROM `registrations`');
|
|
35
|
+
await Database.delete('DELETE FROM `members`');
|
|
36
|
+
await Database.delete('DELETE FROM `postal_codes`');
|
|
37
|
+
await Database.delete('DELETE FROM `cities`');
|
|
38
|
+
await Database.delete('DELETE FROM `provinces`');
|
|
39
|
+
|
|
40
|
+
await Database.delete('DELETE FROM `webshop_orders`');
|
|
41
|
+
await Database.delete('DELETE FROM `webshops`');
|
|
42
|
+
await Database.delete('DELETE FROM `groups`');
|
|
43
|
+
await Database.delete('DELETE FROM `email_addresses`');
|
|
44
|
+
|
|
45
|
+
await Database.delete('DELETE FROM `organizations`');
|
|
46
|
+
|
|
47
|
+
await Database.delete('DELETE FROM `payments`');
|
|
48
|
+
await Database.delete('OPTIMIZE TABLE organizations;'); // fix breaking of indexes due to deletes (mysql bug?)
|
|
49
|
+
|
|
50
|
+
await I18n.load();
|
|
50
51
|
});
|
|
51
52
|
|
|
52
53
|
afterAll(async () => {
|
|
53
54
|
// Wait for email queue etc
|
|
54
55
|
while (Email.currentQueue.length > 0) {
|
|
55
|
-
console.info(
|
|
56
|
-
await sleep(100)
|
|
56
|
+
console.info('Emails still in queue. Waiting...');
|
|
57
|
+
await sleep(100);
|
|
57
58
|
}
|
|
58
59
|
await Database.end();
|
|
59
60
|
});
|