@stamhoofd/models 2.151.1 → 2.153.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/dist/factories/UserFactory.d.ts +1 -0
- package/dist/factories/UserFactory.d.ts.map +1 -1
- package/dist/factories/UserFactory.js +3 -1
- package/dist/factories/UserFactory.js.map +1 -1
- package/dist/helpers/Handlebars.d.ts.map +1 -1
- package/dist/helpers/Handlebars.js +2 -10
- package/dist/helpers/Handlebars.js.map +1 -1
- package/dist/helpers/countDays.d.ts +5 -0
- package/dist/helpers/countDays.d.ts.map +1 -0
- package/dist/helpers/countDays.js +15 -0
- package/dist/helpers/countDays.js.map +1 -0
- package/dist/migrations/1788385713-notifications-table.sql +16 -0
- package/dist/migrations/1788385714-notification-recipients-table.sql +16 -0
- package/dist/migrations/1788385715-notification-preferences-table.sql +12 -0
- package/dist/migrations/1788509800-invoiced-balance-items-details.sql +5 -0
- package/dist/migrations/1788900000-document-parent-id.sql +2 -0
- package/dist/models/Document.d.ts +4 -0
- package/dist/models/Document.d.ts.map +1 -1
- package/dist/models/Document.js +7 -0
- package/dist/models/Document.js.map +1 -1
- package/dist/models/DocumentTemplate.d.ts +66 -3
- package/dist/models/DocumentTemplate.d.ts.map +1 -1
- package/dist/models/DocumentTemplate.js +234 -47
- package/dist/models/DocumentTemplate.js.map +1 -1
- package/dist/models/Invoice.d.ts.map +1 -1
- package/dist/models/Invoice.js +2 -2
- package/dist/models/Invoice.js.map +1 -1
- package/dist/models/InvoicedBalanceItem.d.ts +8 -0
- package/dist/models/InvoicedBalanceItem.d.ts.map +1 -1
- package/dist/models/InvoicedBalanceItem.js +21 -0
- package/dist/models/InvoicedBalanceItem.js.map +1 -1
- package/dist/models/Member.d.ts +2 -1
- package/dist/models/Member.d.ts.map +1 -1
- package/dist/models/Member.js +7 -1
- package/dist/models/Member.js.map +1 -1
- package/dist/models/Notification.d.ts +28 -0
- package/dist/models/Notification.d.ts.map +1 -0
- package/dist/models/Notification.js +84 -0
- package/dist/models/Notification.js.map +1 -0
- package/dist/models/NotificationPreference.d.ts +14 -0
- package/dist/models/NotificationPreference.d.ts.map +1 -0
- package/dist/models/NotificationPreference.js +56 -0
- package/dist/models/NotificationPreference.js.map +1 -0
- package/dist/models/NotificationRecipient.d.ts +19 -0
- package/dist/models/NotificationRecipient.d.ts.map +1 -0
- package/dist/models/NotificationRecipient.js +77 -0
- package/dist/models/NotificationRecipient.js.map +1 -0
- package/dist/structures/OrganizationServerMetaData.d.ts +35 -0
- package/dist/structures/OrganizationServerMetaData.d.ts.map +1 -1
- package/dist/structures/OrganizationServerMetaData.js +68 -0
- package/dist/structures/OrganizationServerMetaData.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -0
- package/package.json +66 -66
- package/src/factories/UserFactory.ts +3 -1
- package/src/helpers/Handlebars.ts +2 -10
- package/src/helpers/countDays.ts +15 -0
- package/src/migrations/1788385713-notifications-table.sql +16 -0
- package/src/migrations/1788385714-notification-recipients-table.sql +16 -0
- package/src/migrations/1788385715-notification-preferences-table.sql +12 -0
- package/src/migrations/1788509800-invoiced-balance-items-details.sql +5 -0
- package/src/migrations/1788900000-document-parent-id.sql +2 -0
- package/src/models/Document.ts +6 -0
- package/src/models/DocumentTemplate.test.ts +75 -1
- package/src/models/DocumentTemplate.ts +295 -50
- package/src/models/Invoice.ts +2 -2
- package/src/models/InvoicedBalanceItem.ts +17 -0
- package/src/models/Member.ts +8 -1
- package/src/models/Notification.ts +74 -0
- package/src/models/NotificationPreference.ts +50 -0
- package/src/models/NotificationRecipient.ts +70 -0
- package/src/structures/OrganizationServerMetaData.ts +61 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
3
|
+
import { UserNotification } from '@stamhoofd/structures/notifications/UserNotification.js';
|
|
4
|
+
import { v7 as uuidv7 } from 'uuid';
|
|
5
|
+
import type { Notification } from './Notification.js';
|
|
6
|
+
|
|
7
|
+
export class NotificationRecipient extends QueryableModel {
|
|
8
|
+
static table = 'notification_recipients';
|
|
9
|
+
|
|
10
|
+
@column({
|
|
11
|
+
primary: true, type: 'string', beforeSave(value) {
|
|
12
|
+
return value ?? uuidv7();
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
id!: string;
|
|
16
|
+
|
|
17
|
+
@column({ type: 'string' })
|
|
18
|
+
notificationId: string;
|
|
19
|
+
|
|
20
|
+
@column({ type: 'string' })
|
|
21
|
+
userId: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Notification.groupResourceCount at the moment the user last read it
|
|
25
|
+
*/
|
|
26
|
+
@column({ type: 'integer' })
|
|
27
|
+
readCount = 0;
|
|
28
|
+
|
|
29
|
+
@column({ type: 'datetime', nullable: true })
|
|
30
|
+
readAt: Date | null = null;
|
|
31
|
+
|
|
32
|
+
@column({ type: 'datetime', nullable: true })
|
|
33
|
+
seenAt: Date | null = null;
|
|
34
|
+
|
|
35
|
+
@column({ type: 'datetime', nullable: true })
|
|
36
|
+
dismissedAt: Date | null = null;
|
|
37
|
+
|
|
38
|
+
@column({
|
|
39
|
+
type: 'datetime', beforeSave(old?: any) {
|
|
40
|
+
if (old !== undefined) {
|
|
41
|
+
return old;
|
|
42
|
+
}
|
|
43
|
+
const date = new Date();
|
|
44
|
+
date.setMilliseconds(0);
|
|
45
|
+
return date;
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
createdAt: Date;
|
|
49
|
+
|
|
50
|
+
getStructure(notification: Notification): UserNotification {
|
|
51
|
+
return UserNotification.create({
|
|
52
|
+
id: this.id,
|
|
53
|
+
notificationId: notification.id,
|
|
54
|
+
type: notification.type,
|
|
55
|
+
organizationId: notification.organizationId,
|
|
56
|
+
subjectType: notification.subjectType,
|
|
57
|
+
subjectId: notification.subjectId,
|
|
58
|
+
payload: notification.payload,
|
|
59
|
+
groupKey: notification.groupKey,
|
|
60
|
+
groupResourceCount: notification.groupResourceCount,
|
|
61
|
+
groupResources: notification.groupResources,
|
|
62
|
+
readCount: this.readCount,
|
|
63
|
+
readAt: this.readAt,
|
|
64
|
+
seenAt: this.seenAt,
|
|
65
|
+
dismissedAt: this.dismissedAt,
|
|
66
|
+
createdAt: notification.createdAt,
|
|
67
|
+
updatedAt: notification.updatedAt,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -9,6 +9,58 @@ export class DripEmail extends AutoEncoder {
|
|
|
9
9
|
date = new Date();
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export class BlockedPaymentMandate extends AutoEncoder {
|
|
13
|
+
/**
|
|
14
|
+
* External mandate id of the provider
|
|
15
|
+
*/
|
|
16
|
+
@field({ decoder: StringDecoder })
|
|
17
|
+
id: string;
|
|
18
|
+
|
|
19
|
+
@field({ decoder: DateDecoder })
|
|
20
|
+
blockedAt = new Date();
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Card number or IBAN (PaymentMandate.identifier) of the blocked mandate, so newer mandates for the same
|
|
24
|
+
* card or account stay blocked even when this mandate is revoked at the provider
|
|
25
|
+
*/
|
|
26
|
+
@field({ decoder: StringDecoder, nullable: true })
|
|
27
|
+
identifier: string | null = null;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The (chargeback) payment that caused the block, null when blocked manually
|
|
31
|
+
*/
|
|
32
|
+
@field({ decoder: StringDecoder, nullable: true })
|
|
33
|
+
paymentId: string | null = null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class PaymentMandateChargebacks extends AutoEncoder {
|
|
37
|
+
/**
|
|
38
|
+
* External mandate id of the provider
|
|
39
|
+
*/
|
|
40
|
+
@field({ decoder: StringDecoder })
|
|
41
|
+
id: string;
|
|
42
|
+
|
|
43
|
+
@field({ decoder: StringDecoder, nullable: true })
|
|
44
|
+
identifier: string | null = null;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Dates of the most recent chargebacks (last 12 months, at most 5)
|
|
48
|
+
*/
|
|
49
|
+
@field({ decoder: new ArrayDecoder(DateDecoder) })
|
|
50
|
+
dates: Date[] = [];
|
|
51
|
+
|
|
52
|
+
static readonly maxDates = 5;
|
|
53
|
+
static readonly maxAge = 1000 * 60 * 60 * 24 * 365;
|
|
54
|
+
|
|
55
|
+
add(date: Date) {
|
|
56
|
+
const minimum = new Date(date.getTime() - PaymentMandateChargebacks.maxAge);
|
|
57
|
+
this.dates = [...this.dates, date]
|
|
58
|
+
.filter(d => d >= minimum)
|
|
59
|
+
.sort((a, b) => b.getTime() - a.getTime())
|
|
60
|
+
.slice(0, PaymentMandateChargebacks.maxDates);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
12
64
|
export class OrganizationServerMetaData extends AutoEncoder {
|
|
13
65
|
@field({ decoder: StringDecoder, optional: true })
|
|
14
66
|
privateDKIMKey?: string;
|
|
@@ -52,6 +104,15 @@ export class OrganizationServerMetaData extends AutoEncoder {
|
|
|
52
104
|
@field({ decoder: StringDecoder, optional: true, nullable: true })
|
|
53
105
|
mollieMandateId: string | null = null;
|
|
54
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Mandates that can no longer be used to pay, even if they are still valid at the provider
|
|
109
|
+
*/
|
|
110
|
+
@field({ decoder: new ArrayDecoder(BlockedPaymentMandate), version: 417 })
|
|
111
|
+
blockedMandates: BlockedPaymentMandate[] = [];
|
|
112
|
+
|
|
113
|
+
@field({ decoder: new ArrayDecoder(PaymentMandateChargebacks), version: 417 })
|
|
114
|
+
mandateChargebacks: PaymentMandateChargebacks[] = [];
|
|
115
|
+
|
|
55
116
|
@field({ decoder: OpenIDClientConfiguration, nullable: true, version: 189 })
|
|
56
117
|
ssoConfiguration: OpenIDClientConfiguration | null = null;
|
|
57
118
|
|