@stamhoofd/backend 2.111.0 → 2.112.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/LICENSE.md +32 -0
- package/package.json +14 -11
- package/src/boot.ts +1 -0
- package/src/email-recipient-loaders/documents.ts +66 -0
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.test.ts +701 -4
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +21 -10
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.test.ts +661 -4
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.ts +17 -6
- package/src/endpoints/global/registration/RegisterMembersEndpoint.test.ts +291 -8
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +22 -0
- package/src/endpoints/organization/dashboard/invoices/GetInvoicesCountEndpoint.ts +43 -0
- package/src/endpoints/organization/dashboard/invoices/GetInvoicesEndpoint.ts +219 -0
- package/src/endpoints/organization/dashboard/payments/PatchBalanceItemsEndpoint.ts +2 -2
- package/src/endpoints/organization/shared/GetUitpasNumberDetailsEndpoint.ts +72 -0
- package/src/endpoints/organization/webshops/RetrieveUitpasSocialTariffPriceEndpoint.ts +3 -2
- package/src/excel-loaders/members.ts +27 -27
- package/src/helpers/AdminPermissionChecker.ts +30 -10
- package/src/helpers/AuthenticatedStructures.ts +24 -5
- package/src/helpers/StripeHelper.ts +11 -1
- package/src/helpers/StripePayoutChecker.ts +7 -0
- package/src/helpers/UitpasTokenRepository.ts +7 -5
- package/src/helpers/passthroughFetch.ts +24 -0
- package/src/helpers/updateMemberDetailsUitpasNumber.ts +149 -0
- package/src/seeds/data/default-email-templates.sql +2 -1
- package/src/seeds/wip/1769088653-uitpas-status.ts +129 -0
- package/src/services/InvoiceService.ts +2 -2
- package/src/services/uitpas/PassholderEndpoints.ts +190 -0
- package/src/services/uitpas/UitpasService.ts +37 -12
- package/src/services/uitpas/checkUitpasNumbers.ts +16 -140
- package/src/services/uitpas/handleUitpasResponse.ts +89 -0
- package/src/sql-filters/invoiced-balance-items.ts +20 -0
- package/src/sql-filters/invoices.ts +122 -0
- package/src/sql-filters/payments.ts +11 -1
- package/src/sql-sorters/invoices.ts +83 -0
- package/src/sql-sorters/payments.ts +33 -0
- package/tests/e2e/bundle-discounts.test.ts +8 -8
- package/tests/e2e/tests-disable-net-connect.test.ts +5 -0
- package/tests/helpers/StripeMocker.ts +5 -5
- package/tests/helpers/UitpasApiMocker.ts +175 -0
- package/tests/helpers/index.ts +1 -0
- package/tests/helpers/resetNock.ts +7 -0
- package/tests/init/index.ts +1 -0
- package/tests/init/initPayconiq.ts +2 -2
- package/tests/init/initStripe.ts +1 -1
- package/tests/init/initUitpasApi.ts +14 -0
- package/tests/jest.global.setup.ts +6 -4
- package/tests/jest.setup.ts +12 -6
- package/LICENSE +0 -665
package/LICENSE.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Free Use License for Non-Profit Organizations
|
|
2
|
+
|
|
3
|
+
Copyright 2020 Codawood BV
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any non-profit organization with fewer than 2,000 members (each, a “Licensee”), to use this software and associated documentation files (the “Software”), subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
1. Eligibility:
|
|
8
|
+
This license applies only if neither the Licensee nor, if applicable, its parent or umbrella organization, is already subject to an existing license for this project. For the purposes of this license, a “parent or umbrella organization” means any organization with which the Licensee is affiliated, coordinated, or represented as part of a larger collective, including but not limited to national associations or federations.
|
|
9
|
+
|
|
10
|
+
2. Modifications:
|
|
11
|
+
Modifications to the Software are permitted only if they are published publicly under the MIT License, covering only the modifications; the original Software remains under this license and may not be sublicensed without a separate agreement. Any modification made by a Licensee (other than modifications by the original author, its representatives, or the copyright owner) shall be deemed to be distributed under the MIT License. Submission of modifications through publicly accessible channels, including but not limited to pull requests on code repositories such as GitHub, shall be considered an explicit acknowledgment and grant by the Licensee that such modifications are made available under the MIT License. Licensees may not sublicense, transfer, or assign the rights granted under this license except as expressly permitted herein.
|
|
12
|
+
|
|
13
|
+
3. Precedence of Existing Licenses:
|
|
14
|
+
If the Licensee, or its parent or umbrella organization, is already subject to an existing license for this project, that license shall take precedence, and no additional free license is granted. Nothing in this license shall be construed to override any pre-existing exclusive license agreement.
|
|
15
|
+
|
|
16
|
+
4. Data Protection / GDPR Responsibility:
|
|
17
|
+
Licensees are solely responsible for ensuring that any processing of personal data using this software complies with applicable data protection laws, including the EU General Data Protection Regulation (GDPR).
|
|
18
|
+
|
|
19
|
+
5. Termination and Revocation:
|
|
20
|
+
The copyright holders may revoke this license at any time, at their sole discretion.
|
|
21
|
+
|
|
22
|
+
6. Governing Law:
|
|
23
|
+
This license shall be governed by and construed in accordance with the laws of Belgium, without regard to conflict of law principles.
|
|
24
|
+
|
|
25
|
+
7. Third-Party Licenses:
|
|
26
|
+
Certain files or components included in the Software may be governed by separate licenses, including open-source licenses, or contributed by third parties under different terms. Such files are not automatically covered by this license. Licensees are responsible for reviewing and complying with any additional license terms that apply to these files.
|
|
27
|
+
|
|
28
|
+
For the purposes of this license, a “non-profit organization” means an entity recognized as non-profit under applicable law in its jurisdiction, which does not distribute profits to its members or owners.
|
|
29
|
+
|
|
30
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
31
|
+
|
|
32
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/backend",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.112.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
},
|
|
12
12
|
"./src/boot": {
|
|
13
13
|
"require": "./dist/src/boot.js"
|
|
14
|
+
},
|
|
15
|
+
"./tests/helpers": {
|
|
16
|
+
"require": "./dist/tests/helpers/index.js"
|
|
14
17
|
}
|
|
15
18
|
},
|
|
16
19
|
"license": "UNLICENCED",
|
|
@@ -35,7 +38,7 @@
|
|
|
35
38
|
"@types/mailparser": "^3",
|
|
36
39
|
"@types/mysql": "^2.15.20",
|
|
37
40
|
"@types/node": "^22",
|
|
38
|
-
"nock": "^
|
|
41
|
+
"nock": "^14.0.10",
|
|
39
42
|
"qs": "^6.11.2",
|
|
40
43
|
"sinon": "^18.0.0"
|
|
41
44
|
},
|
|
@@ -51,14 +54,14 @@
|
|
|
51
54
|
"@simonbackx/simple-encoding": "2.23.1",
|
|
52
55
|
"@simonbackx/simple-endpoints": "1.20.1",
|
|
53
56
|
"@simonbackx/simple-logging": "^1.0.1",
|
|
54
|
-
"@stamhoofd/backend-i18n": "2.
|
|
55
|
-
"@stamhoofd/backend-middleware": "2.
|
|
56
|
-
"@stamhoofd/email": "2.
|
|
57
|
-
"@stamhoofd/models": "2.
|
|
58
|
-
"@stamhoofd/queues": "2.
|
|
59
|
-
"@stamhoofd/sql": "2.
|
|
60
|
-
"@stamhoofd/structures": "2.
|
|
61
|
-
"@stamhoofd/utility": "2.
|
|
57
|
+
"@stamhoofd/backend-i18n": "2.112.0",
|
|
58
|
+
"@stamhoofd/backend-middleware": "2.112.0",
|
|
59
|
+
"@stamhoofd/email": "2.112.0",
|
|
60
|
+
"@stamhoofd/models": "2.112.0",
|
|
61
|
+
"@stamhoofd/queues": "2.112.0",
|
|
62
|
+
"@stamhoofd/sql": "2.112.0",
|
|
63
|
+
"@stamhoofd/structures": "2.112.0",
|
|
64
|
+
"@stamhoofd/utility": "2.112.0",
|
|
62
65
|
"archiver": "^7.0.1",
|
|
63
66
|
"axios": "^1.13.2",
|
|
64
67
|
"cookie": "^0.7.0",
|
|
@@ -76,5 +79,5 @@
|
|
|
76
79
|
"publishConfig": {
|
|
77
80
|
"access": "public"
|
|
78
81
|
},
|
|
79
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "8734fff2c389052210c5da51bd3c4beaf149bfd1"
|
|
80
83
|
}
|
package/src/boot.ts
CHANGED
|
@@ -131,6 +131,7 @@ export const boot = async (options: { killProcess: boolean }) => {
|
|
|
131
131
|
await import('./email-recipient-loaders/orders');
|
|
132
132
|
await import('./email-recipient-loaders/receivable-balances');
|
|
133
133
|
await import('./excel-loaders/registrations');
|
|
134
|
+
await import('./email-recipient-loaders/documents');
|
|
134
135
|
|
|
135
136
|
productionLog('Opening port...');
|
|
136
137
|
routerServer.listen(STAMHOOFD.PORT ?? 9090);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Email, Member } from '@stamhoofd/models';
|
|
2
|
+
import { SQL } from '@stamhoofd/sql';
|
|
3
|
+
import { EmailRecipient, EmailRecipientFilterType, LimitedFilteredRequest, PaginatedResponse, Replacement } from '@stamhoofd/structures';
|
|
4
|
+
import { GetDocumentsEndpoint } from '../endpoints/organization/dashboard/documents/GetDocumentsEndpoint.js';
|
|
5
|
+
|
|
6
|
+
async function fetch(query: LimitedFilteredRequest) {
|
|
7
|
+
const result = await GetDocumentsEndpoint.buildData(query);
|
|
8
|
+
|
|
9
|
+
const recipients: EmailRecipient[] = [];
|
|
10
|
+
const memberIds = new Set(result.results.map(doc => doc.memberId).filter(id => id !== null)); // silently skip null memberIds
|
|
11
|
+
|
|
12
|
+
const members = await Member.getBlobByIds(...memberIds);
|
|
13
|
+
for (const member of members) {
|
|
14
|
+
const emails = member.details.getNotificationEmails();
|
|
15
|
+
for (const user of member.users) {
|
|
16
|
+
if (!emails.includes(user.email.toLocaleLowerCase())) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const recipient = EmailRecipient.create({
|
|
20
|
+
objectId: member.id,
|
|
21
|
+
userId: user.id,
|
|
22
|
+
memberId: member.id,
|
|
23
|
+
firstName: user.firstName,
|
|
24
|
+
lastName: user.lastName,
|
|
25
|
+
email: user.email,
|
|
26
|
+
replacements: [
|
|
27
|
+
Replacement.create({
|
|
28
|
+
token: 'firstNameMember',
|
|
29
|
+
value: member.firstName,
|
|
30
|
+
}),
|
|
31
|
+
Replacement.create({
|
|
32
|
+
token: 'lastNameMember',
|
|
33
|
+
value: member.lastName,
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
recipients.push(recipient);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return new PaginatedResponse({
|
|
42
|
+
results: recipients,
|
|
43
|
+
next: result.next,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function count(request: LimitedFilteredRequest) {
|
|
48
|
+
const query = await GetDocumentsEndpoint.buildQuery(request);
|
|
49
|
+
const uniqueMemberIds = await query.count(SQL.distinct(SQL.column('memberId')));
|
|
50
|
+
|
|
51
|
+
if (uniqueMemberIds > 100 || uniqueMemberIds === 0) {
|
|
52
|
+
return uniqueMemberIds; // rough estimate
|
|
53
|
+
}
|
|
54
|
+
// do full count
|
|
55
|
+
request.limit = 100;
|
|
56
|
+
let count = 0;
|
|
57
|
+
let req: LimitedFilteredRequest | null = request;
|
|
58
|
+
while (req) {
|
|
59
|
+
const result = await fetch(request);
|
|
60
|
+
count += result.results.length;
|
|
61
|
+
req = result.next ?? null;
|
|
62
|
+
}
|
|
63
|
+
return count;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
Email.recipientLoaders.set(EmailRecipientFilterType.Documents, { fetch, count });
|