@stamhoofd/models 2.64.0 → 2.65.1
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/src/helpers/EmailBuilder.d.ts +6 -1
- package/dist/src/helpers/EmailBuilder.d.ts.map +1 -1
- package/dist/src/helpers/EmailBuilder.js +60 -20
- package/dist/src/helpers/EmailBuilder.js.map +1 -1
- package/dist/src/helpers/MemberMerger.d.ts.map +1 -1
- package/dist/src/helpers/MemberMerger.js +1 -2
- package/dist/src/helpers/MemberMerger.js.map +1 -1
- package/dist/src/migrations/1605262045-import-postcodes.d.ts +2 -2
- package/dist/src/migrations/1605262045-import-postcodes.js +9 -9
- package/dist/src/migrations/1735573520-emails-email-type.sql +2 -0
- package/dist/src/migrations/1735573521-email-recipients-email-type.sql +4 -0
- package/dist/src/migrations/1735573522-emails-indexes.sql +3 -0
- package/dist/src/migrations/1735982691-cached-balance-email-reminder-counts.sql +4 -0
- package/dist/src/migrations/1735994471-default-email-templates.sql +5 -0
- package/dist/src/models/AuditLog.d.ts +2 -7
- package/dist/src/models/AuditLog.d.ts.map +1 -1
- package/dist/src/models/AuditLog.js +1 -15
- package/dist/src/models/AuditLog.js.map +1 -1
- package/dist/src/models/BalanceItem.d.ts +7 -11
- package/dist/src/models/BalanceItem.d.ts.map +1 -1
- package/dist/src/models/BalanceItem.js +20 -22
- package/dist/src/models/BalanceItem.js.map +1 -1
- package/dist/src/models/BalanceItemPayment.d.ts +3 -7
- package/dist/src/models/BalanceItemPayment.d.ts.map +1 -1
- package/dist/src/models/BalanceItemPayment.js +1 -15
- package/dist/src/models/BalanceItemPayment.js.map +1 -1
- package/dist/src/models/BuckarooPayment.d.ts +2 -2
- package/dist/src/models/BuckarooPayment.d.ts.map +1 -1
- package/dist/src/models/BuckarooPayment.js +2 -1
- package/dist/src/models/BuckarooPayment.js.map +1 -1
- package/dist/src/models/CachedBalance.d.ts +7 -9
- package/dist/src/models/CachedBalance.d.ts.map +1 -1
- package/dist/src/models/CachedBalance.js +61 -22
- package/dist/src/models/CachedBalance.js.map +1 -1
- package/dist/src/models/Document.d.ts +3 -3
- package/dist/src/models/Document.d.ts.map +1 -1
- package/dist/src/models/Document.js +2 -1
- package/dist/src/models/Document.js.map +1 -1
- package/dist/src/models/DocumentTemplate.d.ts +2 -2
- package/dist/src/models/DocumentTemplate.d.ts.map +1 -1
- package/dist/src/models/DocumentTemplate.js +2 -1
- package/dist/src/models/DocumentTemplate.js.map +1 -1
- package/dist/src/models/Email.d.ts +10 -4
- package/dist/src/models/Email.d.ts.map +1 -1
- package/dist/src/models/Email.js +68 -25
- package/dist/src/models/Email.js.map +1 -1
- package/dist/src/models/EmailRecipient.d.ts +14 -8
- package/dist/src/models/EmailRecipient.d.ts.map +1 -1
- package/dist/src/models/EmailRecipient.js +19 -14
- package/dist/src/models/EmailRecipient.js.map +1 -1
- package/dist/src/models/EmailTemplate.d.ts +2 -7
- package/dist/src/models/EmailTemplate.d.ts.map +1 -1
- package/dist/src/models/EmailTemplate.js +1 -15
- package/dist/src/models/EmailTemplate.js.map +1 -1
- package/dist/src/models/EmailVerificationCode.d.ts +2 -2
- package/dist/src/models/EmailVerificationCode.d.ts.map +1 -1
- package/dist/src/models/EmailVerificationCode.js +2 -1
- package/dist/src/models/EmailVerificationCode.js.map +1 -1
- package/dist/src/models/Event.d.ts +2 -2
- package/dist/src/models/Event.d.ts.map +1 -1
- package/dist/src/models/Event.js +2 -1
- package/dist/src/models/Event.js.map +1 -1
- package/dist/src/models/Group.d.ts +2 -7
- package/dist/src/models/Group.d.ts.map +1 -1
- package/dist/src/models/Group.js +1 -17
- package/dist/src/models/Group.js.map +1 -1
- package/dist/src/models/Image.d.ts +2 -2
- package/dist/src/models/Image.d.ts.map +1 -1
- package/dist/src/models/Image.js +2 -1
- package/dist/src/models/Image.js.map +1 -1
- package/dist/src/models/Member.d.ts +3 -2
- package/dist/src/models/Member.d.ts.map +1 -1
- package/dist/src/models/Member.js +1 -1
- package/dist/src/models/Member.js.map +1 -1
- package/dist/src/models/MemberPlatformMembership.d.ts +2 -7
- package/dist/src/models/MemberPlatformMembership.d.ts.map +1 -1
- package/dist/src/models/MemberPlatformMembership.js +1 -15
- package/dist/src/models/MemberPlatformMembership.js.map +1 -1
- package/dist/src/models/MemberResponsibilityRecord.d.ts +2 -7
- package/dist/src/models/MemberResponsibilityRecord.d.ts.map +1 -1
- package/dist/src/models/MemberResponsibilityRecord.js +1 -15
- package/dist/src/models/MemberResponsibilityRecord.js.map +1 -1
- package/dist/src/models/MemberUser.d.ts +8 -0
- package/dist/src/models/MemberUser.d.ts.map +1 -0
- package/dist/src/models/MemberUser.js +26 -0
- package/dist/src/models/MemberUser.js.map +1 -0
- package/dist/src/models/MergedMember.d.ts +2 -2
- package/dist/src/models/MergedMember.d.ts.map +1 -1
- package/dist/src/models/MergedMember.js +2 -1
- package/dist/src/models/MergedMember.js.map +1 -1
- package/dist/src/models/MolliePayment.d.ts +2 -2
- package/dist/src/models/MolliePayment.d.ts.map +1 -1
- package/dist/src/models/MolliePayment.js +2 -1
- package/dist/src/models/MolliePayment.js.map +1 -1
- package/dist/src/models/MollieToken.d.ts +2 -2
- package/dist/src/models/MollieToken.d.ts.map +1 -1
- package/dist/src/models/MollieToken.js +2 -1
- package/dist/src/models/MollieToken.js.map +1 -1
- package/dist/src/models/OneTimeToken.d.ts +2 -2
- package/dist/src/models/OneTimeToken.d.ts.map +1 -1
- package/dist/src/models/OneTimeToken.js +2 -1
- package/dist/src/models/OneTimeToken.js.map +1 -1
- package/dist/src/models/Order.d.ts +3 -2
- package/dist/src/models/Order.d.ts.map +1 -1
- package/dist/src/models/Order.js +2 -1
- package/dist/src/models/Order.js.map +1 -1
- package/dist/src/models/Organization.d.ts +2 -2
- package/dist/src/models/Organization.d.ts.map +1 -1
- package/dist/src/models/Organization.js +2 -1
- package/dist/src/models/Organization.js.map +1 -1
- package/dist/src/models/OrganizationRegistrationPeriod.d.ts +2 -2
- package/dist/src/models/OrganizationRegistrationPeriod.d.ts.map +1 -1
- package/dist/src/models/OrganizationRegistrationPeriod.js +2 -1
- package/dist/src/models/OrganizationRegistrationPeriod.js.map +1 -1
- package/dist/src/models/PasswordToken.d.ts +3 -2
- package/dist/src/models/PasswordToken.d.ts.map +1 -1
- package/dist/src/models/PasswordToken.js +2 -1
- package/dist/src/models/PasswordToken.js.map +1 -1
- package/dist/src/models/PayconiqPayment.d.ts +2 -2
- package/dist/src/models/PayconiqPayment.d.ts.map +1 -1
- package/dist/src/models/PayconiqPayment.js +2 -1
- package/dist/src/models/PayconiqPayment.js.map +1 -1
- package/dist/src/models/Payment.d.ts +2 -7
- package/dist/src/models/Payment.d.ts.map +1 -1
- package/dist/src/models/Payment.js +1 -15
- package/dist/src/models/Payment.js.map +1 -1
- package/dist/src/models/Platform.d.ts +3 -3
- package/dist/src/models/Platform.d.ts.map +1 -1
- package/dist/src/models/Platform.js +2 -1
- package/dist/src/models/Platform.js.map +1 -1
- package/dist/src/models/RegisterCode.d.ts +2 -2
- package/dist/src/models/RegisterCode.d.ts.map +1 -1
- package/dist/src/models/RegisterCode.js +2 -1
- package/dist/src/models/RegisterCode.js.map +1 -1
- package/dist/src/models/Registration.d.ts +3 -2
- package/dist/src/models/Registration.d.ts.map +1 -1
- package/dist/src/models/Registration.js +2 -27
- package/dist/src/models/Registration.js.map +1 -1
- package/dist/src/models/RegistrationPeriod.d.ts +2 -7
- package/dist/src/models/RegistrationPeriod.d.ts.map +1 -1
- package/dist/src/models/RegistrationPeriod.js +1 -15
- package/dist/src/models/RegistrationPeriod.js.map +1 -1
- package/dist/src/models/STCredit.d.ts +2 -2
- package/dist/src/models/STCredit.d.ts.map +1 -1
- package/dist/src/models/STCredit.js +2 -1
- package/dist/src/models/STCredit.js.map +1 -1
- package/dist/src/models/STInvoice.d.ts +3 -2
- package/dist/src/models/STInvoice.d.ts.map +1 -1
- package/dist/src/models/STInvoice.js +2 -1
- package/dist/src/models/STInvoice.js.map +1 -1
- package/dist/src/models/STPackage.d.ts +2 -2
- package/dist/src/models/STPackage.d.ts.map +1 -1
- package/dist/src/models/STPackage.js +2 -1
- package/dist/src/models/STPackage.js.map +1 -1
- package/dist/src/models/STPendingInvoice.d.ts +3 -2
- package/dist/src/models/STPendingInvoice.d.ts.map +1 -1
- package/dist/src/models/STPendingInvoice.js +2 -1
- package/dist/src/models/STPendingInvoice.js.map +1 -1
- package/dist/src/models/StripeAccount.d.ts +2 -2
- package/dist/src/models/StripeAccount.d.ts.map +1 -1
- package/dist/src/models/StripeAccount.js +2 -1
- package/dist/src/models/StripeAccount.js.map +1 -1
- package/dist/src/models/StripeCheckoutSession.d.ts +2 -2
- package/dist/src/models/StripeCheckoutSession.d.ts.map +1 -1
- package/dist/src/models/StripeCheckoutSession.js +2 -1
- package/dist/src/models/StripeCheckoutSession.js.map +1 -1
- package/dist/src/models/StripePaymentIntent.d.ts +2 -2
- package/dist/src/models/StripePaymentIntent.d.ts.map +1 -1
- package/dist/src/models/StripePaymentIntent.js +2 -1
- package/dist/src/models/StripePaymentIntent.js.map +1 -1
- package/dist/src/models/Ticket.d.ts +3 -2
- package/dist/src/models/Ticket.d.ts.map +1 -1
- package/dist/src/models/Ticket.js +2 -1
- package/dist/src/models/Ticket.js.map +1 -1
- package/dist/src/models/Token.d.ts +3 -2
- package/dist/src/models/Token.d.ts.map +1 -1
- package/dist/src/models/Token.js +2 -1
- package/dist/src/models/Token.js.map +1 -1
- package/dist/src/models/UsedRegisterCode.d.ts +2 -2
- package/dist/src/models/UsedRegisterCode.d.ts.map +1 -1
- package/dist/src/models/UsedRegisterCode.js +2 -1
- package/dist/src/models/UsedRegisterCode.js.map +1 -1
- package/dist/src/models/User.d.ts +7 -2
- package/dist/src/models/User.d.ts.map +1 -1
- package/dist/src/models/User.js +27 -4
- package/dist/src/models/User.js.map +1 -1
- package/dist/src/models/UserPermissions.d.ts +3 -2
- package/dist/src/models/UserPermissions.d.ts.map +1 -1
- package/dist/src/models/UserPermissions.js +2 -1
- package/dist/src/models/UserPermissions.js.map +1 -1
- package/dist/src/models/Webshop.d.ts +3 -2
- package/dist/src/models/Webshop.d.ts.map +1 -1
- package/dist/src/models/Webshop.js +2 -1
- package/dist/src/models/Webshop.js.map +1 -1
- package/dist/src/models/WebshopDiscountCode.d.ts +2 -2
- package/dist/src/models/WebshopDiscountCode.d.ts.map +1 -1
- package/dist/src/models/WebshopDiscountCode.js +2 -1
- package/dist/src/models/WebshopDiscountCode.js.map +1 -1
- package/dist/src/models/addresses/City.d.ts +3 -2
- package/dist/src/models/addresses/City.d.ts.map +1 -1
- package/dist/src/models/addresses/City.js +2 -1
- package/dist/src/models/addresses/City.js.map +1 -1
- package/dist/src/models/addresses/PostalCode.d.ts +3 -2
- package/dist/src/models/addresses/PostalCode.d.ts.map +1 -1
- package/dist/src/models/addresses/PostalCode.js +2 -1
- package/dist/src/models/addresses/PostalCode.js.map +1 -1
- package/dist/src/models/addresses/Province.d.ts +2 -2
- package/dist/src/models/addresses/Province.d.ts.map +1 -1
- package/dist/src/models/addresses/Province.js +2 -1
- package/dist/src/models/addresses/Province.js.map +1 -1
- package/dist/src/models/addresses/Street.d.ts +3 -2
- package/dist/src/models/addresses/Street.d.ts.map +1 -1
- package/dist/src/models/addresses/Street.js +2 -1
- package/dist/src/models/addresses/Street.js.map +1 -1
- package/dist/src/models/index.d.ts +1 -0
- package/dist/src/models/index.d.ts.map +1 -1
- package/dist/src/models/index.js +1 -0
- package/dist/src/models/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/helpers/EmailBuilder.ts +82 -27
- package/src/helpers/MemberMerger.ts +2 -3
- package/src/migrations/1605262045-import-postcodes.ts +4 -5
- package/src/migrations/1735573520-emails-email-type.sql +2 -0
- package/src/migrations/1735573521-email-recipients-email-type.sql +4 -0
- package/src/migrations/1735573522-emails-indexes.sql +3 -0
- package/src/migrations/1735982691-cached-balance-email-reminder-counts.sql +4 -0
- package/src/migrations/1735994471-default-email-templates.sql +5 -0
- package/src/models/AuditLog.ts +3 -21
- package/src/models/BalanceItem.ts +27 -30
- package/src/models/BalanceItemPayment.ts +3 -21
- package/src/models/BuckarooPayment.ts +3 -2
- package/src/models/CachedBalance.ts +82 -27
- package/src/models/Document.ts +4 -3
- package/src/models/DocumentTemplate.ts +4 -3
- package/src/models/Email.ts +80 -32
- package/src/models/EmailRecipient.ts +20 -20
- package/src/models/EmailTemplate.ts +3 -21
- package/src/models/EmailVerificationCode.ts +3 -2
- package/src/models/Event.ts +3 -2
- package/src/models/Group.ts +4 -23
- package/src/models/Image.ts +3 -2
- package/src/models/Member.ts +4 -4
- package/src/models/MemberPlatformMembership.ts +3 -21
- package/src/models/MemberResponsibilityRecord.ts +3 -21
- package/src/models/MemberUser.ts +18 -0
- package/src/models/MergedMember.ts +3 -2
- package/src/models/MolliePayment.ts +3 -2
- package/src/models/MollieToken.ts +3 -2
- package/src/models/OneTimeToken.ts +3 -2
- package/src/models/Order.ts +3 -2
- package/src/models/Organization.ts +3 -2
- package/src/models/OrganizationRegistrationPeriod.ts +3 -2
- package/src/models/PasswordToken.ts +3 -2
- package/src/models/PayconiqPayment.ts +3 -2
- package/src/models/Payment.ts +3 -21
- package/src/models/Platform.ts +4 -3
- package/src/models/RegisterCode.ts +3 -2
- package/src/models/Registration.ts +3 -28
- package/src/models/RegistrationPeriod.ts +3 -21
- package/src/models/STCredit.ts +3 -2
- package/src/models/STInvoice.ts +3 -2
- package/src/models/STPackage.ts +3 -2
- package/src/models/STPendingInvoice.ts +3 -2
- package/src/models/StripeAccount.ts +3 -2
- package/src/models/StripeCheckoutSession.ts +3 -2
- package/src/models/StripePaymentIntent.ts +3 -2
- package/src/models/Ticket.ts +3 -2
- package/src/models/Token.ts +3 -2
- package/src/models/UsedRegisterCode.ts +3 -2
- package/src/models/User.ts +31 -3
- package/src/models/UserPermissions.ts +3 -2
- package/src/models/Webshop.ts +3 -2
- package/src/models/WebshopDiscountCode.ts +3 -2
- package/src/models/addresses/City.ts +3 -2
- package/src/models/addresses/PostalCode.ts +3 -2
- package/src/models/addresses/Province.ts +3 -2
- package/src/models/addresses/Street.ts +3 -2
- package/src/models/index.ts +1 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { column
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
3
|
import { Group as GroupStruct, OrganizationRegistrationPeriodSettings, OrganizationRegistrationPeriod as OrganizationRegistrationPeriodStruct, SetupSteps } from '@stamhoofd/structures';
|
|
3
4
|
import { Formatter } from '@stamhoofd/utility';
|
|
4
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
6
|
import { Group, RegistrationPeriod } from '.';
|
|
6
7
|
|
|
7
|
-
export class OrganizationRegistrationPeriod extends
|
|
8
|
+
export class OrganizationRegistrationPeriod extends QueryableModel {
|
|
8
9
|
static table = 'organization_registration_periods';
|
|
9
10
|
|
|
10
11
|
@column({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { column, Database, ManyToOneRelation
|
|
1
|
+
import { column, Database, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
2
|
import { I18n } from '@stamhoofd/backend-i18n';
|
|
3
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
3
4
|
import basex from 'base-x';
|
|
4
5
|
import crypto from 'crypto';
|
|
5
6
|
|
|
@@ -21,7 +22,7 @@ async function randomBytes(size: number): Promise<Buffer> {
|
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export class PasswordToken extends
|
|
25
|
+
export class PasswordToken extends QueryableModel {
|
|
25
26
|
static table = 'password_tokens';
|
|
26
27
|
|
|
27
28
|
// Columns
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { column
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
2
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
3
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
3
4
|
import { PayconiqAccount, PaymentStatus, Version } from '@stamhoofd/structures';
|
|
4
5
|
import { IncomingMessage } from 'http';
|
|
5
6
|
import https from 'https';
|
|
@@ -7,7 +8,7 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
7
8
|
|
|
8
9
|
import { Organization, Payment } from './';
|
|
9
10
|
|
|
10
|
-
export class PayconiqPayment extends
|
|
11
|
+
export class PayconiqPayment extends QueryableModel {
|
|
11
12
|
static table = 'payconiq_payments';
|
|
12
13
|
|
|
13
14
|
@column({
|
package/src/models/Payment.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { column
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
2
|
import { BalanceItemDetailed, BalanceItemPaymentDetailed, PaymentCustomer, PaymentGeneral, PaymentMethod, PaymentProvider, PaymentStatus, Settlement, TransferSettings, BaseOrganization, PaymentType } from '@stamhoofd/structures';
|
|
3
3
|
import { Formatter } from '@stamhoofd/utility';
|
|
4
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
5
|
|
|
6
6
|
import { Organization } from './';
|
|
7
|
-
import {
|
|
7
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
8
8
|
|
|
9
|
-
export class Payment extends
|
|
9
|
+
export class Payment extends QueryableModel {
|
|
10
10
|
static table = 'payments';
|
|
11
11
|
|
|
12
12
|
@column({
|
|
@@ -245,22 +245,4 @@ export class Payment extends Model {
|
|
|
245
245
|
|
|
246
246
|
return { registrations, orders };
|
|
247
247
|
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Experimental: needs to move to library
|
|
251
|
-
*/
|
|
252
|
-
static select() {
|
|
253
|
-
const transformer = (row: SQLResultNamespacedRow): Payment => {
|
|
254
|
-
const d = (this as typeof Payment & typeof Model).fromRow(row[this.table] as any) as Payment | undefined;
|
|
255
|
-
|
|
256
|
-
if (!d) {
|
|
257
|
-
throw new Error('EmailTemplate not found');
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
return d;
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
const select = new SQLSelect(transformer, SQL.wildcard(this.table));
|
|
264
|
-
return select.from(SQL.table(this.table));
|
|
265
|
-
}
|
|
266
248
|
}
|
package/src/models/Platform.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { column
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
2
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
3
|
-
import {
|
|
3
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
4
|
+
import { PlatformConfig, PlatformPrivateConfig, Platform as PlatformStruct } from '@stamhoofd/structures';
|
|
4
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
6
|
import { RegistrationPeriod } from './RegistrationPeriod';
|
|
6
7
|
|
|
7
|
-
export class Platform extends
|
|
8
|
+
export class Platform extends QueryableModel {
|
|
8
9
|
static table = 'platform';
|
|
9
10
|
|
|
10
11
|
@column({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { column
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
3
|
import basex from 'base-x';
|
|
3
4
|
import crypto from 'crypto';
|
|
4
5
|
|
|
@@ -17,7 +18,7 @@ async function randomBytes(size: number): Promise<Buffer> {
|
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
export class RegisterCode extends
|
|
21
|
+
export class RegisterCode extends QueryableModel {
|
|
21
22
|
static table = 'register_codes';
|
|
22
23
|
|
|
23
24
|
@column({ type: 'string', primary: true })
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { column, Database, ManyToOneRelation
|
|
1
|
+
import { column, Database, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
2
|
import { EmailTemplateType, GroupPrice, PaymentMethod, PaymentMethodHelper, Recipient, RecordAnswer, RecordAnswerDecoder, RegisterItemOption, Registration as RegistrationStructure, Replacement, StockReservation } from '@stamhoofd/structures';
|
|
3
3
|
import { Formatter } from '@stamhoofd/utility';
|
|
4
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
5
|
|
|
6
6
|
import { ArrayDecoder, MapDecoder, StringDecoder } from '@simonbackx/simple-encoding';
|
|
7
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
7
8
|
import { sendEmailTemplate } from '../helpers/EmailBuilder';
|
|
8
9
|
import { Group, Organization, User } from './';
|
|
9
10
|
|
|
10
|
-
export class Registration extends
|
|
11
|
+
export class Registration extends QueryableModel {
|
|
11
12
|
static table = 'registrations';
|
|
12
13
|
|
|
13
14
|
@column({
|
|
@@ -179,14 +180,6 @@ export class Registration extends Model {
|
|
|
179
180
|
email: user.email,
|
|
180
181
|
userId: user.id,
|
|
181
182
|
replacements: [
|
|
182
|
-
Replacement.create({
|
|
183
|
-
token: 'firstName',
|
|
184
|
-
value: member.details.firstName,
|
|
185
|
-
}),
|
|
186
|
-
Replacement.create({
|
|
187
|
-
token: 'lastName',
|
|
188
|
-
value: member.details.lastName,
|
|
189
|
-
}),
|
|
190
183
|
Replacement.create({
|
|
191
184
|
token: 'firstNameMember',
|
|
192
185
|
value: member.details.firstName,
|
|
@@ -195,27 +188,14 @@ export class Registration extends Model {
|
|
|
195
188
|
token: 'lastNameMember',
|
|
196
189
|
value: member.details.lastName,
|
|
197
190
|
}),
|
|
198
|
-
Replacement.create({
|
|
199
|
-
token: 'email',
|
|
200
|
-
value: user.email,
|
|
201
|
-
}),
|
|
202
191
|
Replacement.create({
|
|
203
192
|
token: 'registerUrl',
|
|
204
193
|
value: 'https://' + organization.getHost(),
|
|
205
194
|
}),
|
|
206
|
-
Replacement.create({
|
|
207
|
-
token: 'organizationName',
|
|
208
|
-
value: organization.name,
|
|
209
|
-
}),
|
|
210
195
|
Replacement.create({
|
|
211
196
|
token: 'groupName',
|
|
212
197
|
value: group.settings.name,
|
|
213
198
|
}),
|
|
214
|
-
Replacement.create({
|
|
215
|
-
token: 'loginDetails',
|
|
216
|
-
value: '',
|
|
217
|
-
html: user.hasAccount() ? `<p class="description"><em>Je kan op het ledenportaal inloggen met <strong>${Formatter.escapeHtml(user.email)}</strong></em></p>` : `<p class="description"><em>Je kan op het ledenportaal een nieuw account aanmaken met het e-mailadres <strong>${Formatter.escapeHtml(user.email)}</strong>, dan krijg je automatisch toegang tot alle bestaande gegevens.</em></p>`,
|
|
218
|
-
}),
|
|
219
199
|
],
|
|
220
200
|
}));
|
|
221
201
|
}
|
|
@@ -310,11 +290,6 @@ export class Registration extends Model {
|
|
|
310
290
|
token: 'organizationName',
|
|
311
291
|
value: organization.name,
|
|
312
292
|
}),
|
|
313
|
-
Replacement.create({
|
|
314
|
-
token: 'loginDetails',
|
|
315
|
-
value: '',
|
|
316
|
-
html: user.hasAccount() ? `<p class="description"><em>Je kan op het ledenportaal inloggen met <strong>${Formatter.escapeHtml(user.email)}</strong></em></p>` : `<p class="description"><em>Je kan op het ledenportaal een nieuw account aanmaken met het e-mailadres <strong>${Formatter.escapeHtml(user.email)}</strong>, dan krijg je automatisch toegang tot alle bestaande gegevens.</em></p>`,
|
|
317
|
-
}),
|
|
318
293
|
],
|
|
319
294
|
}),
|
|
320
295
|
];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { column
|
|
2
|
-
import {
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel, SQL, SQLWhereSign } from '@stamhoofd/sql';
|
|
3
3
|
import { RegistrationPeriodBase, RegistrationPeriodSettings, RegistrationPeriod as RegistrationPeriodStruct } from '@stamhoofd/structures';
|
|
4
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
5
|
|
|
6
|
-
export class RegistrationPeriod extends
|
|
6
|
+
export class RegistrationPeriod extends QueryableModel {
|
|
7
7
|
static table = 'registration_periods';
|
|
8
8
|
|
|
9
9
|
@column({
|
|
@@ -97,22 +97,4 @@ export class RegistrationPeriod extends Model {
|
|
|
97
97
|
|
|
98
98
|
this.previousPeriodId = previousPeriod?.id ?? null;
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Experimental: needs to move to library
|
|
103
|
-
*/
|
|
104
|
-
static select() {
|
|
105
|
-
const transformer = (row: SQLResultNamespacedRow): RegistrationPeriod => {
|
|
106
|
-
const d = (this as typeof RegistrationPeriod & typeof Model).fromRow(row[this.table] as any) as RegistrationPeriod | undefined;
|
|
107
|
-
|
|
108
|
-
if (!d) {
|
|
109
|
-
throw new Error('MemberPlatformMembership not found');
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return d;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const select = new SQLSelect(transformer, SQL.wildcard());
|
|
116
|
-
return select.from(SQL.table(this.table));
|
|
117
|
-
}
|
|
118
100
|
}
|
package/src/models/STCredit.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { column
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
4
|
|
|
4
|
-
export class STCredit extends
|
|
5
|
+
export class STCredit extends QueryableModel {
|
|
5
6
|
static table = 'stamhoofd_credits';
|
|
6
7
|
|
|
7
8
|
// Columns
|
package/src/models/STInvoice.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { column, ManyToOneRelation
|
|
1
|
+
import { column, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
3
|
import { STInvoiceMeta } from '@stamhoofd/structures';
|
|
3
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
5
|
|
|
5
6
|
import { Organization, Payment } from './';
|
|
6
7
|
|
|
7
|
-
export class STInvoice extends
|
|
8
|
+
export class STInvoice extends QueryableModel {
|
|
8
9
|
static table = 'stamhoofd_invoices';
|
|
9
10
|
|
|
10
11
|
private static numberCache: number | null = null;
|
package/src/models/STPackage.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { column
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
2
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
3
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
3
4
|
import { EmailTemplateType, Recipient, Replacement, STPackageMeta, STPackageStatus, STPackageType } from '@stamhoofd/structures';
|
|
4
5
|
import { Formatter } from '@stamhoofd/utility';
|
|
5
6
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -8,7 +9,7 @@ import { sendEmailTemplate } from '../helpers/EmailBuilder';
|
|
|
8
9
|
import { GroupBuilder } from '../helpers/GroupBuilder';
|
|
9
10
|
import { Organization } from './';
|
|
10
11
|
|
|
11
|
-
export class STPackage extends
|
|
12
|
+
export class STPackage extends QueryableModel {
|
|
12
13
|
static table = 'stamhoofd_packages';
|
|
13
14
|
|
|
14
15
|
// Columns
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { column, ManyToOneRelation
|
|
1
|
+
import { column, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
3
|
import { STInvoiceMeta } from '@stamhoofd/structures';
|
|
3
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
5
|
|
|
@@ -15,7 +16,7 @@ import { Organization } from './';
|
|
|
15
16
|
*
|
|
16
17
|
* So please make sure you don't edit existing items, unless you change the id
|
|
17
18
|
*/
|
|
18
|
-
export class STPendingInvoice extends
|
|
19
|
+
export class STPendingInvoice extends QueryableModel {
|
|
19
20
|
static table = 'stamhoofd_pending_invoices';
|
|
20
21
|
|
|
21
22
|
// Columns
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
2
|
-
import { column
|
|
2
|
+
import { column } from '@simonbackx/simple-database';
|
|
3
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
3
4
|
import { Requirements, StripeBusinessProfile, StripeCompany, StripeMetaAccountDashboardSettings, StripeMetaAccountSettings, StripeMetaData } from '@stamhoofd/structures';
|
|
4
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Keeps track of how much a member/user owes or needs to be reimbursed.
|
|
8
9
|
*/
|
|
9
|
-
export class StripeAccount extends
|
|
10
|
+
export class StripeAccount extends QueryableModel {
|
|
10
11
|
static table = 'stripe_accounts';
|
|
11
12
|
|
|
12
13
|
@column({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { column
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
4
|
|
|
4
|
-
export class StripeCheckoutSession extends
|
|
5
|
+
export class StripeCheckoutSession extends QueryableModel {
|
|
5
6
|
static table = 'stripe_checkout_sessions';
|
|
6
7
|
|
|
7
8
|
@column({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { column
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
4
|
|
|
4
|
-
export class StripePaymentIntent extends
|
|
5
|
+
export class StripePaymentIntent extends QueryableModel {
|
|
5
6
|
static table = 'stripe_payment_intents';
|
|
6
7
|
|
|
7
8
|
@column({
|
package/src/models/Ticket.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { column, ManyToOneRelation
|
|
1
|
+
import { column, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
3
|
import { CartReservedSeat } from '@stamhoofd/structures';
|
|
3
4
|
import basex from 'base-x';
|
|
4
5
|
import crypto from 'crypto';
|
|
@@ -27,7 +28,7 @@ async function randomBytes(size: number): Promise<Buffer> {
|
|
|
27
28
|
* This avoids the select in the database, saving some bytes in network communication
|
|
28
29
|
* (especially needed when clients requests all the changed tickets)
|
|
29
30
|
*/
|
|
30
|
-
export class Ticket extends
|
|
31
|
+
export class Ticket extends QueryableModel {
|
|
31
32
|
static table = 'webshop_tickets';
|
|
32
33
|
|
|
33
34
|
// Columns
|
package/src/models/Token.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { column, Database, ManyToOneRelation
|
|
1
|
+
import { column, Database, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
3
|
import { ApiUser } from '@stamhoofd/structures';
|
|
3
4
|
import crypto from 'crypto';
|
|
4
5
|
|
|
@@ -44,7 +45,7 @@ export const apiUserRateLimiter = new RateLimiter({
|
|
|
44
45
|
],
|
|
45
46
|
});
|
|
46
47
|
|
|
47
|
-
export class Token extends
|
|
48
|
+
export class Token extends QueryableModel {
|
|
48
49
|
static table = 'tokens';
|
|
49
50
|
static MAX_DEVICES = 15;
|
|
50
51
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { column
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
4
|
|
|
4
|
-
export class UsedRegisterCode extends
|
|
5
|
+
export class UsedRegisterCode extends QueryableModel {
|
|
5
6
|
static table = 'used_register_codes';
|
|
6
7
|
|
|
7
8
|
@column({
|
package/src/models/User.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { column, Database, ManyToOneRelation
|
|
1
|
+
import { column, Database, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
2
|
import { EmailInterfaceRecipient } from '@stamhoofd/email';
|
|
3
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
3
4
|
import { LoginProviderType, NewUser, Permissions, Recipient, Replacement, UserMeta, UserPermissions, User as UserStruct } from '@stamhoofd/structures';
|
|
4
5
|
import argon2 from 'argon2';
|
|
5
6
|
import { v4 as uuidv4 } from 'uuid';
|
|
6
7
|
|
|
7
8
|
import { Organization } from './';
|
|
9
|
+
import { QueueHandler } from '@stamhoofd/queues';
|
|
8
10
|
|
|
9
|
-
export class User extends
|
|
11
|
+
export class User extends QueryableModel {
|
|
10
12
|
static table = 'users';
|
|
11
13
|
|
|
12
14
|
// Columns
|
|
@@ -140,7 +142,7 @@ export class User extends Model {
|
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
return (
|
|
143
|
-
|
|
145
|
+
|
|
144
146
|
await User.where(query)
|
|
145
147
|
).filter(a => !a.isApiUser);
|
|
146
148
|
}
|
|
@@ -479,4 +481,30 @@ export class User extends Model {
|
|
|
479
481
|
},
|
|
480
482
|
];
|
|
481
483
|
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Get internal system user that can be used on places that require a user object but the system is the actor
|
|
487
|
+
*/
|
|
488
|
+
static async getSystem(): Promise<User> {
|
|
489
|
+
return QueueHandler.schedule('User.getSystem', async () => {
|
|
490
|
+
// Build a new one
|
|
491
|
+
let model = await this.getByID('1');
|
|
492
|
+
if (!model) {
|
|
493
|
+
// Create a new platform
|
|
494
|
+
model = new User();
|
|
495
|
+
model.id = '1';
|
|
496
|
+
model.firstName = 'System';
|
|
497
|
+
model.email = 'webmaster@stamhoofd.be';
|
|
498
|
+
model.verified = true;
|
|
499
|
+
model.permissions = UserPermissions.create({
|
|
500
|
+
globalPermissions: Permissions.full,
|
|
501
|
+
});
|
|
502
|
+
model.organizationId = null;
|
|
503
|
+
|
|
504
|
+
await model.save();
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
return model;
|
|
508
|
+
});
|
|
509
|
+
}
|
|
482
510
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { column, ManyToOneRelation
|
|
1
|
+
import { column, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
3
|
import { Permissions } from '@stamhoofd/structures';
|
|
3
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
5
|
|
|
5
6
|
import { Organization, User } from './';
|
|
6
7
|
|
|
7
|
-
export class UserPermissions extends
|
|
8
|
+
export class UserPermissions extends QueryableModel {
|
|
8
9
|
static table = 'user_permissions';
|
|
9
10
|
|
|
10
11
|
// Columns
|
package/src/models/Webshop.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { column, Database, ManyToOneRelation
|
|
1
|
+
import { column, Database, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
2
|
import { ArrayDecoder } from '@simonbackx/simple-encoding';
|
|
3
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
3
4
|
import { Category, DNSRecordStatus, Product, WebshopMetaData, WebshopPrivateMetaData, WebshopServerMetaData } from '@stamhoofd/structures';
|
|
4
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
6
|
import { validateDNSRecords } from '../helpers/DNSValidator';
|
|
6
7
|
|
|
7
8
|
import { Organization } from './';
|
|
8
9
|
|
|
9
|
-
export class Webshop extends
|
|
10
|
+
export class Webshop extends QueryableModel {
|
|
10
11
|
static table = 'webshops';
|
|
11
12
|
|
|
12
13
|
// Columns
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { column
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
2
|
import { ArrayDecoder } from '@simonbackx/simple-encoding';
|
|
3
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
3
4
|
import { Discount, DiscountCode } from '@stamhoofd/structures';
|
|
4
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
6
|
|
|
6
|
-
export class WebshopDiscountCode extends
|
|
7
|
+
export class WebshopDiscountCode extends QueryableModel {
|
|
7
8
|
static table = 'webshop_discount_codes';
|
|
8
9
|
|
|
9
10
|
// Columns
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { column, ManyToOneRelation
|
|
1
|
+
import { column, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
2
|
import { Country } from '@stamhoofd/structures';
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
4
|
|
|
5
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
5
6
|
import { Province } from './Province';
|
|
6
7
|
|
|
7
|
-
export class City extends
|
|
8
|
+
export class City extends QueryableModel {
|
|
8
9
|
static table = 'cities';
|
|
9
10
|
|
|
10
11
|
@column({
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { column, Database, ManyToOneRelation
|
|
1
|
+
import { column, Database, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
2
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
3
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
3
4
|
import { Country } from '@stamhoofd/structures';
|
|
4
5
|
import { Formatter, StringCompare } from '@stamhoofd/utility';
|
|
5
6
|
import { v4 as uuidv4 } from 'uuid';
|
|
6
7
|
|
|
7
8
|
import { City } from './City';
|
|
8
9
|
|
|
9
|
-
export class PostalCode extends
|
|
10
|
+
export class PostalCode extends QueryableModel {
|
|
10
11
|
static table = 'postal_codes';
|
|
11
12
|
|
|
12
13
|
@column({
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { column
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
3
|
import { Country } from '@stamhoofd/structures';
|
|
3
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
5
|
|
|
5
|
-
export class Province extends
|
|
6
|
+
export class Province extends QueryableModel {
|
|
6
7
|
static table = 'provinces';
|
|
7
8
|
|
|
8
9
|
@column({
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { column, ManyToOneRelation
|
|
1
|
+
import { column, ManyToOneRelation } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
4
|
|
|
4
5
|
import { City } from './City';
|
|
5
6
|
|
|
6
|
-
export class Street extends
|
|
7
|
+
export class Street extends QueryableModel {
|
|
7
8
|
static table = 'streets';
|
|
8
9
|
|
|
9
10
|
@column({
|
package/src/models/index.ts
CHANGED