@stamhoofd/models 2.63.0 → 2.65.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/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 +3 -3
- package/dist/src/migrations/1605262045-import-postcodes.js +10 -13
- package/dist/src/migrations/1734429094-registration-trial-until.sql +3 -0
- package/dist/src/migrations/1734429095-membership-trial-until.sql +2 -0
- package/dist/src/migrations/1734535120-registration-period-previous-period-id.sql +3 -0
- package/dist/src/migrations/1734535121-platform-previous-period-id.sql +3 -0
- package/dist/src/migrations/1734626607-cached-balance-amount-open.sql +2 -0
- package/dist/src/migrations/1734698906-cached-balance-amount-paid.sql +2 -0
- 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 +4 -13
- package/dist/src/models/BalanceItem.d.ts.map +1 -1
- package/dist/src/models/BalanceItem.js +21 -33
- package/dist/src/models/BalanceItem.js.map +1 -1
- package/dist/src/models/BalanceItemPayment.d.ts +3 -2
- package/dist/src/models/BalanceItemPayment.d.ts.map +1 -1
- package/dist/src/models/BalanceItemPayment.js +2 -1
- 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 +12 -10
- package/dist/src/models/CachedBalance.d.ts.map +1 -1
- package/dist/src/models/CachedBalance.js +122 -39
- 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 +38 -10
- 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 +6 -9
- package/dist/src/models/Member.d.ts.map +1 -1
- package/dist/src/models/Member.js +3 -42
- package/dist/src/models/Member.js.map +1 -1
- package/dist/src/models/MemberPlatformMembership.d.ts +12 -8
- package/dist/src/models/MemberPlatformMembership.d.ts.map +1 -1
- package/dist/src/models/MemberPlatformMembership.js +80 -20
- 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 +3 -3
- package/dist/src/models/MergedMember.d.ts.map +1 -1
- package/dist/src/models/MergedMember.js +3 -2
- 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 +5 -3
- package/dist/src/models/Platform.d.ts.map +1 -1
- package/dist/src/models/Platform.js +11 -2
- 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 +20 -7
- package/dist/src/models/Registration.d.ts.map +1 -1
- package/dist/src/models/Registration.js +25 -61
- package/dist/src/models/Registration.js.map +1 -1
- package/dist/src/models/RegistrationPeriod.d.ts +4 -2
- package/dist/src/models/RegistrationPeriod.d.ts.map +1 -1
- package/dist/src/models/RegistrationPeriod.js +23 -1
- 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 +6 -9
- package/src/migrations/1734429094-registration-trial-until.sql +3 -0
- package/src/migrations/1734429095-membership-trial-until.sql +2 -0
- package/src/migrations/1734535120-registration-period-previous-period-id.sql +3 -0
- package/src/migrations/1734535121-platform-previous-period-id.sql +3 -0
- package/src/migrations/1734626607-cached-balance-amount-open.sql +2 -0
- package/src/migrations/1734698906-cached-balance-amount-paid.sql +2 -0
- 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 +30 -46
- package/src/models/BalanceItemPayment.ts +3 -2
- package/src/models/BuckarooPayment.ts +3 -2
- package/src/models/CachedBalance.ts +166 -46
- package/src/models/Document.ts +4 -3
- package/src/models/DocumentTemplate.ts +43 -12
- 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 +6 -52
- package/src/models/MemberPlatformMembership.ts +95 -26
- package/src/models/MemberResponsibilityRecord.ts +3 -21
- package/src/models/MemberUser.ts +18 -0
- package/src/models/MergedMember.ts +4 -3
- 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 +13 -4
- package/src/models/RegisterCode.ts +3 -2
- package/src/models/Registration.ts +24 -68
- package/src/models/RegistrationPeriod.ts +30 -3
- 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,9 +1,9 @@
|
|
|
1
|
-
import { column
|
|
2
|
-
import { SQL, SQLWhereSign } from '@stamhoofd/sql';
|
|
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({
|
|
@@ -13,6 +13,9 @@ export class RegistrationPeriod extends Model {
|
|
|
13
13
|
})
|
|
14
14
|
id!: string;
|
|
15
15
|
|
|
16
|
+
@column({ type: 'string', nullable: true })
|
|
17
|
+
previousPeriodId: string | null = null;
|
|
18
|
+
|
|
16
19
|
@column({ type: 'string', nullable: true })
|
|
17
20
|
organizationId: string | null = null;
|
|
18
21
|
|
|
@@ -70,4 +73,28 @@ export class RegistrationPeriod extends Model {
|
|
|
70
73
|
|
|
71
74
|
return RegistrationPeriod.fromRow(result[this.table]) ?? null;
|
|
72
75
|
}
|
|
76
|
+
|
|
77
|
+
async setPreviousPeriodId() {
|
|
78
|
+
const allPeriods = await RegistrationPeriod.where({ organizationId: this.organizationId });
|
|
79
|
+
|
|
80
|
+
// Include self if not yet in database
|
|
81
|
+
if (!this.existsInDatabase) {
|
|
82
|
+
allPeriods.push(this);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Sort by start date
|
|
86
|
+
allPeriods.sort((a, b) => a.startDate.getTime() - b.startDate.getTime());
|
|
87
|
+
|
|
88
|
+
// Take the one before this.periodId
|
|
89
|
+
let previousPeriod: RegistrationPeriod | null = null;
|
|
90
|
+
|
|
91
|
+
for (const period of allPeriods) {
|
|
92
|
+
if (period.id === this.id) {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
previousPeriod = period;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.previousPeriodId = previousPeriod?.id ?? null;
|
|
99
|
+
}
|
|
73
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