@stamhoofd/models 2.39.0 → 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/dist/src/factories/AddressFactory.d.ts +3 -4
- package/dist/src/factories/AddressFactory.d.ts.map +1 -1
- package/dist/src/factories/AddressFactory.js +13 -13
- package/dist/src/factories/EmergencyContactFactory.d.ts +3 -4
- package/dist/src/factories/EmergencyContactFactory.d.ts.map +1 -1
- package/dist/src/factories/EmergencyContactFactory.js +27 -27
- package/dist/src/factories/EmergencyContactFactory.js.map +1 -1
- package/dist/src/factories/GroupFactory.d.ts +4 -4
- package/dist/src/factories/GroupFactory.d.ts.map +1 -1
- package/dist/src/factories/GroupFactory.js +8 -8
- package/dist/src/factories/GroupFactory.js.map +1 -1
- package/dist/src/factories/MemberFactory.d.ts +4 -4
- package/dist/src/factories/MemberFactory.d.ts.map +1 -1
- package/dist/src/factories/MemberFactory.js +17 -17
- package/dist/src/factories/MemberFactory.js.map +1 -1
- package/dist/src/factories/OrganizationFactory.d.ts +4 -4
- package/dist/src/factories/OrganizationFactory.js +8 -8
- package/dist/src/factories/OrganizationFactory.js.map +1 -1
- package/dist/src/factories/ParentFactory.d.ts +1 -1
- package/dist/src/factories/ParentFactory.js +19 -19
- package/dist/src/factories/ParentFactory.js.map +1 -1
- package/dist/src/factories/RecordFactory.d.ts +2 -3
- package/dist/src/factories/RecordFactory.d.ts.map +1 -1
- package/dist/src/factories/RecordFactory.js +1 -1
- package/dist/src/factories/RecordFactory.js.map +1 -1
- package/dist/src/factories/RegisterCodeFactory.d.ts +2 -2
- package/dist/src/factories/RegisterCodeFactory.d.ts.map +1 -1
- package/dist/src/factories/RegisterCodeFactory.js +2 -2
- package/dist/src/factories/RegistrationFactory.d.ts +3 -3
- package/dist/src/factories/RegistrationFactory.d.ts.map +1 -1
- package/dist/src/factories/RegistrationFactory.js.map +1 -1
- package/dist/src/factories/RegistrationPeriodFactory.d.ts +2 -2
- package/dist/src/factories/RegistrationPeriodFactory.js.map +1 -1
- package/dist/src/factories/UserFactory.d.ts +3 -3
- package/dist/src/factories/UserFactory.d.ts.map +1 -1
- package/dist/src/factories/UserFactory.js +3 -3
- package/dist/src/factories/UserFactory.js.map +1 -1
- package/dist/src/factories/WebshopFactory.d.ts +4 -4
- package/dist/src/factories/WebshopFactory.d.ts.map +1 -1
- package/dist/src/factories/WebshopFactory.js +1 -1
- package/dist/src/factories/WebshopFactory.js.map +1 -1
- package/dist/src/helpers/DNSValidator.d.ts +1 -1
- package/dist/src/helpers/DNSValidator.d.ts.map +1 -1
- package/dist/src/helpers/DNSValidator.js +33 -33
- package/dist/src/helpers/DNSValidator.js.map +1 -1
- package/dist/src/helpers/EmailBuilder.d.ts +10 -10
- package/dist/src/helpers/EmailBuilder.d.ts.map +1 -1
- package/dist/src/helpers/EmailBuilder.js +34 -34
- package/dist/src/helpers/EmailBuilder.js.map +1 -1
- package/dist/src/helpers/GroupBuilder.d.ts.map +1 -1
- package/dist/src/helpers/GroupBuilder.js +57 -57
- package/dist/src/helpers/GroupBuilder.js.map +1 -1
- package/dist/src/helpers/Handlebars.d.ts.map +1 -1
- package/dist/src/helpers/Handlebars.js +29 -29
- package/dist/src/helpers/Handlebars.js.map +1 -1
- package/dist/src/helpers/MemberMerger.d.ts +1 -1
- package/dist/src/helpers/MemberMerger.d.ts.map +1 -1
- package/dist/src/helpers/MemberMerger.js +33 -33
- package/dist/src/helpers/MemberMerger.js.map +1 -1
- package/dist/src/helpers/MemberMerger.test.js +194 -194
- package/dist/src/helpers/MemberMerger.test.js.map +1 -1
- package/dist/src/helpers/RateLimiter.d.ts.map +1 -1
- package/dist/src/helpers/RateLimiter.js +2 -2
- package/dist/src/helpers/RateLimiter.js.map +1 -1
- package/dist/src/helpers/SetupStepsUpdater.d.ts +22 -0
- package/dist/src/helpers/SetupStepsUpdater.d.ts.map +1 -0
- package/dist/src/helpers/SetupStepsUpdater.js +255 -0
- package/dist/src/helpers/SetupStepsUpdater.js.map +1 -0
- package/dist/src/helpers/WebshopCounter.d.ts +1 -1
- package/dist/src/helpers/WebshopCounter.d.ts.map +1 -1
- package/dist/src/helpers/WebshopCounter.js +1 -1
- package/dist/src/helpers/WebshopCounter.js.map +1 -1
- package/dist/src/helpers/WebshopCounter.test.js +6 -6
- package/dist/src/helpers/WebshopCounter.test.js.map +1 -1
- package/dist/src/index.d.ts +20 -19
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/migrations/1605262045-import-postcodes.js +12 -12
- package/dist/src/migrations/1605262046-import-postcodes-nl.js +10 -10
- package/dist/src/models/BalanceItem.d.ts.map +1 -1
- package/dist/src/models/BalanceItem.js +37 -37
- package/dist/src/models/BalanceItem.js.map +1 -1
- package/dist/src/models/BalanceItemPayment.d.ts.map +1 -1
- package/dist/src/models/BalanceItemPayment.js +13 -13
- package/dist/src/models/BalanceItemPayment.js.map +1 -1
- package/dist/src/models/BuckarooPayment.d.ts +1 -1
- package/dist/src/models/BuckarooPayment.d.ts.map +1 -1
- package/dist/src/models/BuckarooPayment.js +5 -5
- package/dist/src/models/BuckarooPayment.js.map +1 -1
- package/dist/src/models/CachedOutstandingBalance.d.ts.map +1 -1
- package/dist/src/models/CachedOutstandingBalance.js +37 -37
- package/dist/src/models/CachedOutstandingBalance.js.map +1 -1
- package/dist/src/models/Document.d.ts +4 -4
- package/dist/src/models/Document.d.ts.map +1 -1
- package/dist/src/models/Document.js +27 -27
- package/dist/src/models/Document.js.map +1 -1
- package/dist/src/models/DocumentTemplate.d.ts +4 -4
- package/dist/src/models/DocumentTemplate.d.ts.map +1 -1
- package/dist/src/models/DocumentTemplate.js +72 -72
- package/dist/src/models/DocumentTemplate.js.map +1 -1
- package/dist/src/models/Email.d.ts.map +1 -1
- package/dist/src/models/Email.js +63 -64
- package/dist/src/models/Email.js.map +1 -1
- package/dist/src/models/EmailRecipient.d.ts.map +1 -1
- package/dist/src/models/EmailRecipient.js +20 -20
- package/dist/src/models/EmailRecipient.js.map +1 -1
- package/dist/src/models/EmailTemplate.d.ts +3 -3
- package/dist/src/models/EmailTemplate.d.ts.map +1 -1
- package/dist/src/models/EmailTemplate.js +16 -16
- 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 +57 -55
- 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 +15 -15
- package/dist/src/models/Event.js.map +1 -1
- package/dist/src/models/Group.d.ts +3 -1
- package/dist/src/models/Group.d.ts.map +1 -1
- package/dist/src/models/Group.js +46 -35
- package/dist/src/models/Group.js.map +1 -1
- package/dist/src/models/Image.d.ts +1 -1
- package/dist/src/models/Image.d.ts.map +1 -1
- package/dist/src/models/Image.js +26 -26
- package/dist/src/models/Image.js.map +1 -1
- package/dist/src/models/Member.d.ts +8 -8
- package/dist/src/models/Member.d.ts.map +1 -1
- package/dist/src/models/Member.js +60 -60
- package/dist/src/models/Member.js.map +1 -1
- package/dist/src/models/MemberPlatformMembership.d.ts +3 -3
- package/dist/src/models/MemberPlatformMembership.d.ts.map +1 -1
- package/dist/src/models/MemberPlatformMembership.js +26 -26
- package/dist/src/models/MemberPlatformMembership.js.map +1 -1
- package/dist/src/models/MemberResponsibilityRecord.d.ts.map +1 -1
- package/dist/src/models/MemberResponsibilityRecord.js +13 -13
- package/dist/src/models/MemberResponsibilityRecord.js.map +1 -1
- 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 +19 -19
- package/dist/src/models/MergedMember.js.map +1 -1
- package/dist/src/models/MolliePayment.d.ts +1 -1
- package/dist/src/models/MolliePayment.d.ts.map +1 -1
- package/dist/src/models/MolliePayment.js +5 -5
- package/dist/src/models/MolliePayment.js.map +1 -1
- package/dist/src/models/MollieToken.d.ts.map +1 -1
- package/dist/src/models/MollieToken.js +60 -60
- 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 +13 -13
- package/dist/src/models/OneTimeToken.js.map +1 -1
- package/dist/src/models/Order.d.ts +1 -1
- package/dist/src/models/Order.d.ts.map +1 -1
- package/dist/src/models/Order.js +70 -70
- package/dist/src/models/Order.js.map +1 -1
- package/dist/src/models/Organization.d.ts +5 -5
- package/dist/src/models/Organization.d.ts.map +1 -1
- package/dist/src/models/Organization.js +127 -127
- package/dist/src/models/Organization.js.map +1 -1
- package/dist/src/models/OrganizationRegistrationPeriod.d.ts.map +1 -1
- package/dist/src/models/OrganizationRegistrationPeriod.js +15 -15
- package/dist/src/models/OrganizationRegistrationPeriod.js.map +1 -1
- package/dist/src/models/PasswordToken.d.ts +3 -3
- package/dist/src/models/PasswordToken.d.ts.map +1 -1
- package/dist/src/models/PasswordToken.js +17 -17
- package/dist/src/models/PasswordToken.js.map +1 -1
- package/dist/src/models/PayconiqPayment.d.ts +1 -1
- package/dist/src/models/PayconiqPayment.d.ts.map +1 -1
- package/dist/src/models/PayconiqPayment.js +49 -49
- package/dist/src/models/PayconiqPayment.js.map +1 -1
- package/dist/src/models/Payment.d.ts +3 -3
- package/dist/src/models/Payment.d.ts.map +1 -1
- package/dist/src/models/Payment.js +36 -36
- package/dist/src/models/Payment.js.map +1 -1
- package/dist/src/models/Platform.d.ts +2 -2
- package/dist/src/models/Platform.d.ts.map +1 -1
- package/dist/src/models/Platform.js +8 -8
- package/dist/src/models/Platform.js.map +1 -1
- package/dist/src/models/RegisterCode.d.ts +1 -1
- package/dist/src/models/RegisterCode.d.ts.map +1 -1
- package/dist/src/models/RegisterCode.js +11 -11
- package/dist/src/models/RegisterCode.js.map +1 -1
- package/dist/src/models/Registration.d.ts +1 -1
- package/dist/src/models/Registration.d.ts.map +1 -1
- package/dist/src/models/Registration.js +88 -88
- package/dist/src/models/Registration.js.map +1 -1
- package/dist/src/models/RegistrationPeriod.d.ts.map +1 -1
- package/dist/src/models/RegistrationPeriod.js +12 -12
- package/dist/src/models/RegistrationPeriod.js.map +1 -1
- package/dist/src/models/STCredit.d.ts +1 -1
- package/dist/src/models/STCredit.d.ts.map +1 -1
- package/dist/src/models/STCredit.js +12 -12
- package/dist/src/models/STCredit.js.map +1 -1
- package/dist/src/models/STInvoice.d.ts +1 -1
- package/dist/src/models/STInvoice.d.ts.map +1 -1
- package/dist/src/models/STInvoice.js +16 -16
- package/dist/src/models/STInvoice.js.map +1 -1
- package/dist/src/models/STPackage.d.ts +1 -1
- package/dist/src/models/STPackage.d.ts.map +1 -1
- package/dist/src/models/STPackage.js +39 -39
- package/dist/src/models/STPackage.js.map +1 -1
- package/dist/src/models/STPendingInvoice.d.ts +1 -1
- package/dist/src/models/STPendingInvoice.d.ts.map +1 -1
- package/dist/src/models/STPendingInvoice.js +11 -11
- package/dist/src/models/STPendingInvoice.js.map +1 -1
- package/dist/src/models/StripeAccount.d.ts.map +1 -1
- package/dist/src/models/StripeAccount.js +13 -13
- package/dist/src/models/StripeAccount.js.map +1 -1
- package/dist/src/models/StripeCheckoutSession.d.ts +1 -1
- package/dist/src/models/StripeCheckoutSession.d.ts.map +1 -1
- package/dist/src/models/StripeCheckoutSession.js +7 -7
- package/dist/src/models/StripeCheckoutSession.js.map +1 -1
- package/dist/src/models/StripePaymentIntent.d.ts +1 -1
- package/dist/src/models/StripePaymentIntent.d.ts.map +1 -1
- package/dist/src/models/StripePaymentIntent.js +7 -7
- package/dist/src/models/StripePaymentIntent.js.map +1 -1
- package/dist/src/models/Ticket.d.ts +2 -2
- package/dist/src/models/Ticket.d.ts.map +1 -1
- package/dist/src/models/Ticket.js +23 -23
- package/dist/src/models/Ticket.js.map +1 -1
- package/dist/src/models/Token.d.ts +3 -3
- package/dist/src/models/Token.d.ts.map +1 -1
- package/dist/src/models/Token.js +27 -27
- package/dist/src/models/Token.js.map +1 -1
- package/dist/src/models/Token.test.js +11 -11
- package/dist/src/models/UsedRegisterCode.d.ts +1 -1
- package/dist/src/models/UsedRegisterCode.d.ts.map +1 -1
- package/dist/src/models/UsedRegisterCode.js +10 -10
- package/dist/src/models/UsedRegisterCode.js.map +1 -1
- package/dist/src/models/User.d.ts +4 -4
- package/dist/src/models/User.d.ts.map +1 -1
- package/dist/src/models/User.js +53 -51
- package/dist/src/models/User.js.map +1 -1
- package/dist/src/models/UserPermissions.d.ts +3 -3
- package/dist/src/models/UserPermissions.d.ts.map +1 -1
- package/dist/src/models/UserPermissions.js +12 -12
- package/dist/src/models/UserPermissions.js.map +1 -1
- package/dist/src/models/Webshop.d.ts +1 -1
- package/dist/src/models/Webshop.d.ts.map +1 -1
- package/dist/src/models/Webshop.js +23 -23
- package/dist/src/models/Webshop.js.map +1 -1
- package/dist/src/models/WebshopDiscountCode.d.ts +1 -1
- package/dist/src/models/WebshopDiscountCode.d.ts.map +1 -1
- package/dist/src/models/WebshopDiscountCode.js +16 -16
- package/dist/src/models/WebshopDiscountCode.js.map +1 -1
- package/dist/src/models/addresses/City.d.ts.map +1 -1
- package/dist/src/models/addresses/City.js +9 -9
- package/dist/src/models/addresses/City.js.map +1 -1
- package/dist/src/models/addresses/PostalCode.d.ts.map +1 -1
- package/dist/src/models/addresses/PostalCode.js +11 -11
- package/dist/src/models/addresses/PostalCode.js.map +1 -1
- package/dist/src/models/addresses/PostalCode.test.js +22 -22
- package/dist/src/models/addresses/PostalCode.test.js.map +1 -1
- package/dist/src/models/addresses/Province.d.ts.map +1 -1
- package/dist/src/models/addresses/Province.js +5 -5
- package/dist/src/models/addresses/Province.js.map +1 -1
- package/dist/src/models/addresses/Street.d.ts.map +1 -1
- package/dist/src/models/addresses/Street.js +6 -6
- package/dist/src/models/addresses/Street.js.map +1 -1
- package/dist/src/models/index.d.ts +46 -46
- package/dist/src/models/index.d.ts.map +1 -1
- package/dist/src/models/index.js +0 -1
- package/dist/src/models/index.js.map +1 -1
- package/dist/src/structures/OrganizationServerMetaData.d.ts.map +1 -1
- package/dist/src/structures/OrganizationServerMetaData.js +4 -4
- package/dist/src/structures/OrganizationServerMetaData.js.map +1 -1
- package/dist/tests/jest.global.setup.d.ts.map +1 -1
- package/dist/tests/jest.global.setup.js +15 -13
- package/dist/tests/jest.global.setup.js.map +1 -1
- package/dist/tests/jest.setup.js +3 -1
- package/dist/tests/jest.setup.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +3 -3
- package/src/factories/AddressFactory.ts +17 -17
- package/src/factories/EmergencyContactFactory.ts +30 -31
- package/src/factories/GroupFactory.ts +30 -30
- package/src/factories/MemberFactory.ts +41 -38
- package/src/factories/OrganizationFactory.ts +15 -15
- package/src/factories/ParentFactory.ts +24 -24
- package/src/factories/RecordFactory.ts +5 -4
- package/src/factories/RegisterCodeFactory.ts +7 -7
- package/src/factories/RegistrationFactory.ts +16 -16
- package/src/factories/RegistrationPeriodFactory.ts +5 -5
- package/src/factories/UserFactory.ts +20 -19
- package/src/factories/WebshopFactory.ts +14 -14
- package/src/helpers/DNSValidator.ts +89 -84
- package/src/helpers/EmailBuilder.ts +141 -135
- package/src/helpers/GroupBuilder.ts +181 -181
- package/src/helpers/Handlebars.ts +57 -54
- package/src/helpers/MemberMerger.test.ts +702 -702
- package/src/helpers/MemberMerger.ts +83 -77
- package/src/helpers/RateLimiter.ts +25 -27
- package/src/helpers/SetupStepsUpdater.ts +402 -0
- package/src/helpers/WebshopCounter.test.ts +12 -12
- package/src/helpers/WebshopCounter.ts +20 -19
- package/src/index.ts +20 -19
- package/src/migrations/1605262045-import-postcodes.ts +59 -63
- package/src/migrations/1605262046-import-postcodes-nl.ts +41 -43
- package/src/models/BalanceItem.ts +173 -172
- package/src/models/BalanceItemPayment.ts +32 -33
- package/src/models/BuckarooPayment.ts +7 -7
- package/src/models/CachedOutstandingBalance.ts +98 -99
- package/src/models/Document.ts +90 -87
- package/src/models/DocumentTemplate.ts +207 -198
- package/src/models/Email.ts +198 -200
- package/src/models/EmailRecipient.ts +38 -39
- package/src/models/EmailTemplate.ts +36 -37
- package/src/models/EmailVerificationCode.ts +146 -142
- package/src/models/Event.ts +53 -53
- package/src/models/Group.ts +136 -123
- package/src/models/Image.ts +48 -48
- package/src/models/Member.ts +277 -275
- package/src/models/MemberPlatformMembership.ts +71 -71
- package/src/models/MemberResponsibilityRecord.ts +32 -32
- package/src/models/MergedMember.ts +77 -77
- package/src/models/MolliePayment.ts +7 -7
- package/src/models/MollieToken.ts +131 -126
- package/src/models/OneTimeToken.ts +40 -39
- package/src/models/Order.ts +379 -372
- package/src/models/Organization.ts +332 -325
- package/src/models/OrganizationRegistrationPeriod.ts +50 -50
- package/src/models/PasswordToken.ts +42 -42
- package/src/models/PayconiqPayment.ts +80 -76
- package/src/models/Payment.ts +86 -86
- package/src/models/Platform.ts +21 -22
- package/src/models/RegisterCode.ts +26 -26
- package/src/models/Registration.ts +167 -168
- package/src/models/RegistrationPeriod.ts +29 -29
- package/src/models/STCredit.ts +24 -25
- package/src/models/STInvoice.ts +34 -34
- package/src/models/STPackage.ts +143 -136
- package/src/models/STPendingInvoice.ts +26 -26
- package/src/models/StripeAccount.ts +27 -27
- package/src/models/StripeCheckoutSession.ts +10 -10
- package/src/models/StripePaymentIntent.ts +10 -10
- package/src/models/Ticket.ts +51 -52
- package/src/models/Token.test.ts +13 -13
- package/src/models/Token.ts +64 -63
- package/src/models/UsedRegisterCode.ts +20 -21
- package/src/models/User.ts +148 -144
- package/src/models/UserPermissions.ts +25 -28
- package/src/models/Webshop.ts +53 -53
- package/src/models/WebshopDiscountCode.ts +33 -33
- package/src/models/addresses/City.ts +12 -12
- package/src/models/addresses/PostalCode.test.ts +68 -69
- package/src/models/addresses/PostalCode.ts +57 -57
- package/src/models/addresses/Province.ts +8 -8
- package/src/models/addresses/Street.ts +10 -12
- package/src/models/index.ts +54 -55
- package/src/structures/OrganizationServerMetaData.ts +36 -36
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import { column,Database,ManyToOneRelation,Model } from '@simonbackx/simple-database';
|
|
1
|
+
import { column, Database, ManyToOneRelation, Model } from '@simonbackx/simple-database';
|
|
2
2
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
3
3
|
import { Country } from '@stamhoofd/structures';
|
|
4
4
|
import { Formatter, StringCompare } from '@stamhoofd/utility';
|
|
5
|
-
import { v4 as uuidv4 } from
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
6
|
|
|
7
7
|
import { City } from './City';
|
|
8
8
|
|
|
9
9
|
export class PostalCode extends Model {
|
|
10
|
-
static table =
|
|
10
|
+
static table = 'postal_codes';
|
|
11
11
|
|
|
12
12
|
@column({
|
|
13
|
-
primary: true, type:
|
|
13
|
+
primary: true, type: 'string', beforeSave(value) {
|
|
14
14
|
return value ?? uuidv4();
|
|
15
|
-
}
|
|
15
|
+
},
|
|
16
16
|
})
|
|
17
17
|
id!: string;
|
|
18
18
|
|
|
19
|
-
@column({ type:
|
|
19
|
+
@column({ type: 'string' })
|
|
20
20
|
postalCode: string;
|
|
21
21
|
|
|
22
|
-
@column({ type:
|
|
22
|
+
@column({ type: 'string', foreignKey: PostalCode.city })
|
|
23
23
|
cityId: string;
|
|
24
24
|
|
|
25
|
-
@column({ type:
|
|
25
|
+
@column({ type: 'string' })
|
|
26
26
|
country: Country;
|
|
27
27
|
|
|
28
|
-
static city = new ManyToOneRelation(City,
|
|
28
|
+
static city = new ManyToOneRelation(City, 'city');
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Search for a given city via it's postal code and country, collecting information about the city (id), parentCity (id) and province (id)
|
|
32
32
|
*/
|
|
33
33
|
static async getCity(postalCode: string, cityName: string, country: Country): Promise<City | null> {
|
|
34
34
|
let query = `SELECT ${City.getDefaultSelect()}from \`${PostalCode.table}\`\n`;
|
|
35
|
-
query += `JOIN \`${City.table}\` ON \`${PostalCode.table}\`.\`${PostalCode.city.foreignKey}\` = \`${City.table}\`.\`${City.primary.name}\`\n
|
|
35
|
+
query += `JOIN \`${City.table}\` ON \`${PostalCode.table}\`.\`${PostalCode.city.foreignKey}\` = \`${City.table}\`.\`${City.primary.name}\`\n`;
|
|
36
36
|
|
|
37
37
|
// We do an extra join because we also need to get the other registrations of each member (only one regitration has to match the query)
|
|
38
|
-
query += `where \`${PostalCode.table}\`.\`postalCode\` = ? AND \`${PostalCode.table}\`.\`country\` =
|
|
38
|
+
query += `where \`${PostalCode.table}\`.\`postalCode\` = ? AND \`${PostalCode.table}\`.\`country\` = ?`;
|
|
39
39
|
|
|
40
|
-
const [results] = await Database.select(query, [postalCode, country])
|
|
40
|
+
const [results] = await Database.select(query, [postalCode, country]);
|
|
41
41
|
|
|
42
|
-
const cities = City.fromRows(results, City.table)
|
|
42
|
+
const cities = City.fromRows(results, City.table);
|
|
43
43
|
|
|
44
44
|
if (cities.length == 1) {
|
|
45
|
-
return cities[0]
|
|
45
|
+
return cities[0];
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// Search by city name (first exact match, then allow errors)
|
|
49
|
-
let bestScore = 0
|
|
50
|
-
let bestCity: City | null = null
|
|
49
|
+
let bestScore = 0;
|
|
50
|
+
let bestCity: City | null = null;
|
|
51
51
|
|
|
52
52
|
for (const city of cities) {
|
|
53
|
-
const typo = StringCompare.typoCount(cityName, city.name)
|
|
53
|
+
const typo = StringCompare.typoCount(cityName, city.name);
|
|
54
54
|
if (typo == 0) {
|
|
55
|
-
return city
|
|
55
|
+
return city;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
if (bestCity === null || typo < bestScore) {
|
|
59
|
-
bestCity = city
|
|
60
|
-
bestScore = typo
|
|
59
|
+
bestCity = city;
|
|
60
|
+
bestScore = typo;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (bestCity && (bestScore < 3 || StringCompare.contains(cityName, bestCity.name) || StringCompare.contains(bestCity.name, cityName))) {
|
|
65
|
-
return bestCity
|
|
65
|
+
return bestCity;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
bestScore = 0
|
|
69
|
-
bestCity = null
|
|
68
|
+
bestScore = 0;
|
|
69
|
+
bestCity = null;
|
|
70
70
|
|
|
71
71
|
for (const city of cities) {
|
|
72
|
-
const match = StringCompare.matchCount(cityName, city.name)
|
|
72
|
+
const match = StringCompare.matchCount(cityName, city.name);
|
|
73
73
|
|
|
74
74
|
if (bestCity === null || match > bestScore) {
|
|
75
|
-
bestCity = city
|
|
76
|
-
bestScore = match
|
|
75
|
+
bestCity = city;
|
|
76
|
+
bestScore = match;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
if (bestCity && (bestScore > cityName.length/2 || StringCompare.contains(cityName, bestCity.name))) {
|
|
81
|
-
return bestCity
|
|
80
|
+
if (bestCity && (bestScore > cityName.length / 2 || StringCompare.contains(cityName, bestCity.name))) {
|
|
81
|
+
return bestCity;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (cities.length >= 1 && cities[0].parentCityId !== null && cities.every(c => c.parentCityId === cities[0].parentCityId)) {
|
|
85
85
|
// Might have put a postal code of the parent city
|
|
86
|
-
const parent = await City.getByID(cities[0].parentCityId)
|
|
86
|
+
const parent = await City.getByID(cities[0].parentCityId);
|
|
87
87
|
if (parent) {
|
|
88
|
-
const typo = StringCompare.typoCount(cityName, parent.name)
|
|
88
|
+
const typo = StringCompare.typoCount(cityName, parent.name);
|
|
89
89
|
if (typo < 4 || StringCompare.contains(cityName, parent.name)) {
|
|
90
90
|
if (cities.length > 1) {
|
|
91
91
|
throw new SimpleError({
|
|
92
|
-
code:
|
|
93
|
-
message:
|
|
94
|
-
human:
|
|
95
|
-
field:
|
|
96
|
-
})
|
|
92
|
+
code: 'invalid_field',
|
|
93
|
+
message: 'Invalid city. Suggestions: ' + Formatter.joinLast(cities.map(c => c.name), ', ', ' of ') + '?',
|
|
94
|
+
human: 'Welke gemeente bedoel je precies? ' + Formatter.joinLast(cities.map(c => c.name), ', ', ' of ') + '?',
|
|
95
|
+
field: 'city',
|
|
96
|
+
});
|
|
97
97
|
}
|
|
98
|
-
return cities[0] // do not return parent here, because the postal code has priority
|
|
98
|
+
return cities[0]; // do not return parent here, because the postal code has priority
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// Search parent in belgium only
|
|
104
104
|
if (country == Country.Belgium) {
|
|
105
|
-
return this.getCityByParent(postalCode, cityName, country)
|
|
105
|
+
return this.getCityByParent(postalCode, cityName, country);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
return null;
|
|
@@ -113,52 +113,52 @@ export class PostalCode extends Model {
|
|
|
113
113
|
*/
|
|
114
114
|
static async getCityByParent(postalCode: string, cityName: string, country: Country): Promise<City | null> {
|
|
115
115
|
let query = `SELECT ${City.getDefaultSelect()}from \`${PostalCode.table}\`\n`;
|
|
116
|
-
query += `JOIN \`${City.table}\` as parent ON \`${PostalCode.table}\`.\`${PostalCode.city.foreignKey}\` = \`parent\`.\`${City.primary.name}\`\n
|
|
117
|
-
query += `JOIN \`${City.table}\` ON \`parent\`.\`${City.primary.name}\` = \`${City.table}\`.\`${City.parentCity.foreignKey}\`\n
|
|
116
|
+
query += `JOIN \`${City.table}\` as parent ON \`${PostalCode.table}\`.\`${PostalCode.city.foreignKey}\` = \`parent\`.\`${City.primary.name}\`\n`;
|
|
117
|
+
query += `JOIN \`${City.table}\` ON \`parent\`.\`${City.primary.name}\` = \`${City.table}\`.\`${City.parentCity.foreignKey}\`\n`;
|
|
118
118
|
|
|
119
119
|
// We do an extra join because we also need to get the other registrations of each member (only one regitration has to match the query)
|
|
120
|
-
query += `where \`${PostalCode.table}\`.\`postalCode\` = ? AND \`${PostalCode.table}\`.\`country\` =
|
|
120
|
+
query += `where \`${PostalCode.table}\`.\`postalCode\` = ? AND \`${PostalCode.table}\`.\`country\` = ?`;
|
|
121
121
|
|
|
122
|
-
const [results] = await Database.select(query, [postalCode, country])
|
|
122
|
+
const [results] = await Database.select(query, [postalCode, country]);
|
|
123
123
|
|
|
124
|
-
const cities = City.fromRows(results, City.table)
|
|
124
|
+
const cities = City.fromRows(results, City.table);
|
|
125
125
|
|
|
126
126
|
// Search by city name (first exact match, then allow errors)
|
|
127
|
-
let bestScore = 0
|
|
128
|
-
let bestCity: City | null = null
|
|
127
|
+
let bestScore = 0;
|
|
128
|
+
let bestCity: City | null = null;
|
|
129
129
|
|
|
130
130
|
for (const city of cities) {
|
|
131
|
-
const typo = StringCompare.typoCount(cityName, city.name)
|
|
131
|
+
const typo = StringCompare.typoCount(cityName, city.name);
|
|
132
132
|
if (typo == 0) {
|
|
133
|
-
return city
|
|
133
|
+
return city;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
if (bestCity === null || typo < bestScore) {
|
|
137
|
-
bestCity = city
|
|
138
|
-
bestScore = typo
|
|
137
|
+
bestCity = city;
|
|
138
|
+
bestScore = typo;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
if (bestCity && (bestScore < 3 || StringCompare.contains(cityName, bestCity.name) || StringCompare.contains(bestCity.name, cityName))) {
|
|
143
|
-
return bestCity
|
|
143
|
+
return bestCity;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
bestScore = 0
|
|
147
|
-
bestCity = null
|
|
146
|
+
bestScore = 0;
|
|
147
|
+
bestCity = null;
|
|
148
148
|
|
|
149
149
|
for (const city of cities) {
|
|
150
|
-
const match = StringCompare.matchCount(cityName, city.name)
|
|
150
|
+
const match = StringCompare.matchCount(cityName, city.name);
|
|
151
151
|
|
|
152
152
|
if (bestCity === null || match > bestScore) {
|
|
153
|
-
bestCity = city
|
|
154
|
-
bestScore = match
|
|
153
|
+
bestCity = city;
|
|
154
|
+
bestScore = match;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
if (bestCity && (bestScore > cityName.length/2 || StringCompare.contains(cityName, bestCity.name))) {
|
|
159
|
-
return bestCity
|
|
158
|
+
if (bestCity && (bestScore > cityName.length / 2 || StringCompare.contains(cityName, bestCity.name))) {
|
|
159
|
+
return bestCity;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
return null;
|
|
163
163
|
}
|
|
164
|
-
}
|
|
164
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { column,Model } from '@simonbackx/simple-database';
|
|
1
|
+
import { column, Model } from '@simonbackx/simple-database';
|
|
2
2
|
import { Country } from '@stamhoofd/structures';
|
|
3
|
-
import { v4 as uuidv4 } from
|
|
3
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
4
4
|
|
|
5
5
|
export class Province extends Model {
|
|
6
|
-
static table =
|
|
6
|
+
static table = 'provinces';
|
|
7
7
|
|
|
8
8
|
@column({
|
|
9
|
-
primary: true, type:
|
|
9
|
+
primary: true, type: 'string', beforeSave(value) {
|
|
10
10
|
return value ?? uuidv4();
|
|
11
|
-
}
|
|
11
|
+
},
|
|
12
12
|
})
|
|
13
13
|
id!: string;
|
|
14
14
|
|
|
15
|
-
@column({ type:
|
|
15
|
+
@column({ type: 'string' })
|
|
16
16
|
name: string;
|
|
17
17
|
|
|
18
|
-
@column({ type:
|
|
18
|
+
@column({ type: 'string' })
|
|
19
19
|
country: Country;
|
|
20
|
-
}
|
|
20
|
+
}
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import { column, ManyToOneRelation, Model } from '@simonbackx/simple-database';
|
|
2
|
-
import { v4 as uuidv4 } from
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
3
3
|
|
|
4
4
|
import { City } from './City';
|
|
5
5
|
|
|
6
6
|
export class Street extends Model {
|
|
7
|
-
static table =
|
|
7
|
+
static table = 'streets';
|
|
8
8
|
|
|
9
9
|
@column({
|
|
10
|
-
primary: true, type:
|
|
10
|
+
primary: true, type: 'string', beforeSave(value) {
|
|
11
11
|
return value ?? uuidv4();
|
|
12
|
-
}
|
|
12
|
+
},
|
|
13
13
|
})
|
|
14
14
|
id!: string;
|
|
15
|
-
|
|
16
|
-
@column({ type:
|
|
15
|
+
|
|
16
|
+
@column({ type: 'string' })
|
|
17
17
|
name: string;
|
|
18
|
-
|
|
19
|
-
@column({ type: "string", foreignKey: Street.city })
|
|
20
|
-
cityId: string;
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
@column({ type: 'string', foreignKey: Street.city })
|
|
20
|
+
cityId: string;
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
}
|
|
22
|
+
static city = new ManyToOneRelation(City, 'city');
|
|
23
|
+
}
|
package/src/models/index.ts
CHANGED
|
@@ -1,55 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export
|
|
20
|
-
export {
|
|
21
|
-
export
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
25
|
-
export * from
|
|
26
|
-
export * from
|
|
27
|
-
export
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export * from
|
|
33
|
-
export * from
|
|
34
|
-
export * from
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export * from
|
|
38
|
-
export * from
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export * from
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export * from
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export * from
|
|
50
|
-
export * from
|
|
51
|
-
export * from
|
|
52
|
-
export * from
|
|
53
|
-
export * from
|
|
54
|
-
export * from
|
|
55
|
-
export * from "./CachedOutstandingBalance"
|
|
1
|
+
export { Organization } from './Organization';
|
|
2
|
+
export { User } from './User';
|
|
3
|
+
export { Payment } from './Payment';
|
|
4
|
+
export { Registration } from './Registration';
|
|
5
|
+
export { Member, RegistrationWithMember, MemberWithRegistrations } from './Member';
|
|
6
|
+
export { MergedMember } from './MergedMember';
|
|
7
|
+
|
|
8
|
+
export * from './EmailVerificationCode';
|
|
9
|
+
|
|
10
|
+
export * from './Image';
|
|
11
|
+
export * from './MolliePayment';
|
|
12
|
+
export * from './MollieToken';
|
|
13
|
+
export { Order } from './Order';
|
|
14
|
+
export * from './PasswordToken';
|
|
15
|
+
export * from './PayconiqPayment';
|
|
16
|
+
export * from './RegisterCode';
|
|
17
|
+
export * from './STInvoice';
|
|
18
|
+
export * from './STPackage';
|
|
19
|
+
export { STPendingInvoice } from './STPendingInvoice';
|
|
20
|
+
export { Token, TokenWithUser } from './Token';
|
|
21
|
+
export * from './Webshop';
|
|
22
|
+
export * from './STCredit';
|
|
23
|
+
export * from './UsedRegisterCode';
|
|
24
|
+
export * from './Ticket';
|
|
25
|
+
export * from './EmailTemplate';
|
|
26
|
+
export * from './BuckarooPayment';
|
|
27
|
+
export { BalanceItem } from './BalanceItem';
|
|
28
|
+
export { BalanceItemPayment } from './BalanceItemPayment';
|
|
29
|
+
export { Group } from './Group';
|
|
30
|
+
|
|
31
|
+
export * from './addresses/Street';
|
|
32
|
+
export * from './addresses/City';
|
|
33
|
+
export * from './addresses/PostalCode';
|
|
34
|
+
export * from './addresses/Province';
|
|
35
|
+
|
|
36
|
+
export * from './StripeAccount';
|
|
37
|
+
export * from './StripePaymentIntent';
|
|
38
|
+
export * from './StripeCheckoutSession';
|
|
39
|
+
|
|
40
|
+
export * from './Document';
|
|
41
|
+
export * from './DocumentTemplate';
|
|
42
|
+
|
|
43
|
+
export * from './WebshopDiscountCode';
|
|
44
|
+
|
|
45
|
+
export * from './Platform';
|
|
46
|
+
export * from './MemberResponsibilityRecord';
|
|
47
|
+
|
|
48
|
+
export * from './OrganizationRegistrationPeriod';
|
|
49
|
+
export * from './RegistrationPeriod';
|
|
50
|
+
export * from './MemberPlatformMembership';
|
|
51
|
+
export * from './Email';
|
|
52
|
+
export * from './EmailRecipient';
|
|
53
|
+
export * from './Event';
|
|
54
|
+
export * from './CachedOutstandingBalance';
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { ArrayDecoder, AutoEncoder,BooleanDecoder,DateDecoder,field, IntegerDecoder, MapDecoder, StringDecoder } from '@simonbackx/simple-encoding';
|
|
1
|
+
import { ArrayDecoder, AutoEncoder, BooleanDecoder, DateDecoder, field, IntegerDecoder, MapDecoder, StringDecoder } from '@simonbackx/simple-encoding';
|
|
2
2
|
import { OpenIDClientConfiguration } from '@stamhoofd/structures';
|
|
3
3
|
|
|
4
4
|
export class DripEmail extends AutoEncoder {
|
|
5
5
|
@field({ decoder: StringDecoder })
|
|
6
|
-
id: string
|
|
6
|
+
id: string;
|
|
7
7
|
|
|
8
8
|
@field({ decoder: DateDecoder })
|
|
9
|
-
date = new Date()
|
|
9
|
+
date = new Date();
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export class OrganizationServerMetaData extends AutoEncoder {
|
|
13
13
|
@field({ decoder: StringDecoder, optional: true })
|
|
14
|
-
privateDKIMKey?: string
|
|
14
|
+
privateDKIMKey?: string;
|
|
15
15
|
|
|
16
16
|
@field({ decoder: StringDecoder, optional: true })
|
|
17
|
-
publicDKIMKey?: string
|
|
17
|
+
publicDKIMKey?: string;
|
|
18
18
|
|
|
19
19
|
@field({ decoder: StringDecoder, optional: true, version: 24 })
|
|
20
|
-
usedRegisterCode?: string
|
|
20
|
+
usedRegisterCode?: string;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* When the DNS records are invalid for the first time, this timestamp will get set.
|
|
24
24
|
* When DNS is valid again, this will get cleared
|
|
25
25
|
*/
|
|
26
26
|
@field({ decoder: DateDecoder, optional: true, version: 37 })
|
|
27
|
-
firstInvalidDNSRecords?: Date
|
|
27
|
+
firstInvalidDNSRecords?: Date;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Whether an email has been send to say that the domain is setup correctly
|
|
31
31
|
* Set back to false when changing the domain
|
|
32
32
|
*/
|
|
33
33
|
@field({ decoder: BooleanDecoder, optional: true, version: 157 })
|
|
34
|
-
didSendDomainSetupMail = true
|
|
34
|
+
didSendDomainSetupMail = true;
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* When the DNS records are invalid for the first time, this timestamp will get set.
|
|
38
38
|
* When DNS is valid again, this will get cleared
|
|
39
39
|
*/
|
|
40
40
|
@field({ decoder: IntegerDecoder, version: 37 })
|
|
41
|
-
DNSRecordWarningCount = 0
|
|
42
|
-
|
|
41
|
+
DNSRecordWarningCount = 0;
|
|
42
|
+
|
|
43
43
|
@field({ decoder: new ArrayDecoder(DateDecoder), optional: true, version: 230 })
|
|
44
|
-
lastInvalidDNSDates?: Date[]
|
|
44
|
+
lastInvalidDNSDates?: Date[];
|
|
45
45
|
|
|
46
46
|
@field({ decoder: BooleanDecoder, version: 230 })
|
|
47
|
-
isDNSUnstable: boolean = false
|
|
47
|
+
isDNSUnstable: boolean = false;
|
|
48
48
|
|
|
49
49
|
@field({ decoder: StringDecoder, optional: true, version: 86 })
|
|
50
|
-
mollieCustomerId?: string
|
|
50
|
+
mollieCustomerId?: string;
|
|
51
51
|
|
|
52
52
|
@field({ decoder: OpenIDClientConfiguration, nullable: true, version: 189 })
|
|
53
|
-
ssoConfiguration: OpenIDClientConfiguration | null = null
|
|
53
|
+
ssoConfiguration: OpenIDClientConfiguration | null = null;
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* List of specific emails that were send to this organization
|
|
57
57
|
*/
|
|
58
58
|
@field({ decoder: new MapDecoder(StringDecoder, DripEmail), optional: true, version: 230, upgrade: () => {
|
|
59
59
|
const m = new Map<string, DripEmail>();
|
|
60
|
-
const identifier =
|
|
61
|
-
m.set(identifier, DripEmail.create({id: identifier}))
|
|
62
|
-
return m
|
|
60
|
+
const identifier = 'OrganizationDripWelcome';
|
|
61
|
+
m.set(identifier, DripEmail.create({ id: identifier }));
|
|
62
|
+
return m;
|
|
63
63
|
} })
|
|
64
64
|
@field({ decoder: new MapDecoder(StringDecoder, DripEmail), optional: true, version: 232, upgrade: () => {
|
|
65
65
|
const m = new Map<string, DripEmail>();
|
|
66
|
-
const identifier =
|
|
67
|
-
m.set(identifier, DripEmail.create({id: identifier}))
|
|
68
|
-
return m
|
|
66
|
+
const identifier = 'OrganizationDripWelcome';
|
|
67
|
+
m.set(identifier, DripEmail.create({ id: identifier }));
|
|
68
|
+
return m;
|
|
69
69
|
} })
|
|
70
|
-
dripEmailList: Map<string, DripEmail> = new Map()
|
|
70
|
+
dripEmailList: Map<string, DripEmail> = new Map();
|
|
71
71
|
|
|
72
72
|
markDNSValid() {
|
|
73
73
|
// Reset if longer than 14 days without invalid DNS
|
|
74
|
-
this.isDNSUnstable = this.recalculateIsDNSUnstable()
|
|
75
|
-
this.firstInvalidDNSRecords = undefined
|
|
74
|
+
this.isDNSUnstable = this.recalculateIsDNSUnstable();
|
|
75
|
+
this.firstInvalidDNSRecords = undefined;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
markDNSFailure() {
|
|
@@ -80,31 +80,31 @@ export class OrganizationServerMetaData extends AutoEncoder {
|
|
|
80
80
|
// Hasn't been valid
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
-
console.warn(
|
|
84
|
-
this.firstInvalidDNSRecords = new Date()
|
|
85
|
-
|
|
83
|
+
console.warn('DNS settings became invalid');
|
|
84
|
+
this.firstInvalidDNSRecords = new Date();
|
|
85
|
+
|
|
86
86
|
// Remove all dates longer than 14 days ago, or more than 6 events
|
|
87
|
-
const d14 = new Date(Date.now() - 1000 * 60 * 60 * 24 * 14)
|
|
88
|
-
const maxLength = 6
|
|
87
|
+
const d14 = new Date(Date.now() - 1000 * 60 * 60 * 24 * 14);
|
|
88
|
+
const maxLength = 6;
|
|
89
89
|
this.lastInvalidDNSDates = [...(this.lastInvalidDNSDates ?? []), new Date()].filter(d => d > d14).slice(0, maxLength);
|
|
90
|
-
this.isDNSUnstable = this.recalculateIsDNSUnstable()
|
|
90
|
+
this.isDNSUnstable = this.recalculateIsDNSUnstable();
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
* DNS is unstable if it was marked invalid 4 times in the last 2 weeks. Then it stays unstable until there were no invalid DNS moments in the last 2 weeks.
|
|
95
95
|
*/
|
|
96
96
|
recalculateIsDNSUnstable() {
|
|
97
|
-
const d14 = new Date(Date.now() - 1000 * 60 * 60 * 24 * 14)
|
|
98
|
-
return (this.lastInvalidDNSDates ?? []).filter(d => d > d14).length > (this.isDNSUnstable ? 0 : 4)
|
|
97
|
+
const d14 = new Date(Date.now() - 1000 * 60 * 60 * 24 * 14);
|
|
98
|
+
return (this.lastInvalidDNSDates ?? []).filter(d => d > d14).length > (this.isDNSUnstable ? 0 : 4);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
addEmail(identifier: string) {
|
|
102
|
-
console.log(
|
|
103
|
-
const email = DripEmail.create({id: identifier})
|
|
102
|
+
console.log('Marked email ', identifier);
|
|
103
|
+
const email = DripEmail.create({ id: identifier });
|
|
104
104
|
this.dripEmailList.set(email.id, email);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
hasEmail(identifier: string, lastMs: number|null = null) {
|
|
107
|
+
hasEmail(identifier: string, lastMs: number | null = null) {
|
|
108
108
|
if (!this.dripEmailList.has(identifier)) {
|
|
109
109
|
return false;
|
|
110
110
|
}
|
|
@@ -112,6 +112,6 @@ export class OrganizationServerMetaData extends AutoEncoder {
|
|
|
112
112
|
return true;
|
|
113
113
|
}
|
|
114
114
|
const email = this.dripEmailList.get(identifier)!;
|
|
115
|
-
return email.date.getTime() > Date.now() - lastMs
|
|
115
|
+
return email.date.getTime() > Date.now() - lastMs;
|
|
116
116
|
}
|
|
117
|
-
}
|
|
117
|
+
}
|