@stamhoofd/models 2.78.2 → 2.78.4

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.
Files changed (67) hide show
  1. package/dist/src/factories/GroupFactory.d.ts +0 -3
  2. package/dist/src/factories/GroupFactory.d.ts.map +1 -1
  3. package/dist/src/factories/GroupFactory.js +0 -20
  4. package/dist/src/factories/GroupFactory.js.map +1 -1
  5. package/dist/src/factories/MemberFactory.js +2 -2
  6. package/dist/src/factories/MemberFactory.js.map +1 -1
  7. package/dist/src/factories/OrganizationFactory.d.ts +1 -0
  8. package/dist/src/factories/OrganizationFactory.d.ts.map +1 -1
  9. package/dist/src/factories/OrganizationFactory.js +4 -0
  10. package/dist/src/factories/OrganizationFactory.js.map +1 -1
  11. package/dist/src/factories/OrganizationTagFactory.d.ts +10 -0
  12. package/dist/src/factories/OrganizationTagFactory.d.ts.map +1 -0
  13. package/dist/src/factories/OrganizationTagFactory.js +23 -0
  14. package/dist/src/factories/OrganizationTagFactory.js.map +1 -0
  15. package/dist/src/factories/RegistrationFactory.d.ts +6 -2
  16. package/dist/src/factories/RegistrationFactory.d.ts.map +1 -1
  17. package/dist/src/factories/RegistrationFactory.js +6 -9
  18. package/dist/src/factories/RegistrationFactory.js.map +1 -1
  19. package/dist/src/factories/UserFactory.d.ts.map +1 -1
  20. package/dist/src/factories/UserFactory.js +7 -4
  21. package/dist/src/factories/UserFactory.js.map +1 -1
  22. package/dist/src/factories/index.d.ts +15 -0
  23. package/dist/src/factories/index.d.ts.map +1 -0
  24. package/dist/src/factories/index.js +18 -0
  25. package/dist/src/factories/index.js.map +1 -0
  26. package/dist/src/helpers/EmailBuilder.d.ts +2 -1
  27. package/dist/src/helpers/EmailBuilder.d.ts.map +1 -1
  28. package/dist/src/helpers/EmailBuilder.js +36 -4
  29. package/dist/src/helpers/EmailBuilder.js.map +1 -1
  30. package/dist/src/index.d.ts +2 -14
  31. package/dist/src/index.d.ts.map +1 -1
  32. package/dist/src/index.js +3 -14
  33. package/dist/src/index.js.map +1 -1
  34. package/dist/src/models/Email.d.ts.map +1 -1
  35. package/dist/src/models/Email.js +39 -38
  36. package/dist/src/models/Email.js.map +1 -1
  37. package/dist/src/models/Email.test.d.ts +2 -0
  38. package/dist/src/models/Email.test.d.ts.map +1 -0
  39. package/dist/src/models/Email.test.js +461 -0
  40. package/dist/src/models/Email.test.js.map +1 -0
  41. package/dist/src/models/Member.d.ts.map +1 -1
  42. package/dist/src/models/Member.js +14 -8
  43. package/dist/src/models/Member.js.map +1 -1
  44. package/dist/src/models/Organization.d.ts +0 -7
  45. package/dist/src/models/Organization.d.ts.map +1 -1
  46. package/dist/src/models/Organization.js +0 -11
  47. package/dist/src/models/Organization.js.map +1 -1
  48. package/dist/tests/jest.global.setup.d.ts.map +1 -1
  49. package/dist/tests/jest.global.setup.js +11 -1
  50. package/dist/tests/jest.global.setup.js.map +1 -1
  51. package/dist/tests/jest.setup.js +14 -0
  52. package/dist/tests/jest.setup.js.map +1 -1
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +4 -3
  55. package/src/factories/GroupFactory.ts +0 -21
  56. package/src/factories/MemberFactory.ts +2 -2
  57. package/src/factories/OrganizationFactory.ts +5 -0
  58. package/src/factories/OrganizationTagFactory.ts +23 -0
  59. package/src/factories/RegistrationFactory.ts +15 -6
  60. package/src/factories/UserFactory.ts +7 -4
  61. package/src/factories/index.ts +14 -0
  62. package/src/helpers/EmailBuilder.ts +43 -6
  63. package/src/index.ts +4 -15
  64. package/src/models/Email.test.ts +533 -0
  65. package/src/models/Email.ts +42 -42
  66. package/src/models/Member.ts +17 -9
  67. package/src/models/Organization.ts +0 -14
@@ -1,6 +1,6 @@
1
1
  import { column, Database, ManyToManyRelation, ManyToOneRelation, OneToManyRelation } from '@simonbackx/simple-database';
2
2
  import { QueryableModel, SQL } from '@stamhoofd/sql';
3
- import { MemberDetails, RegistrationWithMember as RegistrationWithMemberStruct, TinyMember } from '@stamhoofd/structures';
3
+ import { MemberDetails, NationalRegisterNumberOptOut, RegistrationWithMember as RegistrationWithMemberStruct, TinyMember } from '@stamhoofd/structures';
4
4
  import { Formatter } from '@stamhoofd/utility';
5
5
  import { v4 as uuidv4 } from 'uuid';
6
6
 
@@ -353,29 +353,37 @@ export class Member extends QueryableModel {
353
353
  }
354
354
 
355
355
  async isSafeToMergeDuplicateWithoutSecurityCode() {
356
- // If responsibilities: not safe
357
- const responsibilities = await MemberResponsibilityRecord.where({ memberId: this.id }, { limit: 1 });
358
- if (responsibilities.length > 0) {
356
+ if (this.details.recordAnswers.size > 0) {
359
357
  return false;
360
358
  }
361
359
 
362
- if (this.details.recordAnswers.size > 0) {
360
+ if (this.details.parents.length > 0) {
363
361
  return false;
364
362
  }
365
363
 
366
- if (this.details.reviewTimes.isReviewed('details')) {
364
+ if (this.details.emergencyContacts.length > 0) {
367
365
  return false;
368
366
  }
369
367
 
370
- if (this.details.parents.length > 0) {
368
+ if (this.details.uitpasNumber) {
371
369
  return false;
372
370
  }
373
371
 
374
- if (this.details.emergencyContacts.length > 0) {
372
+ if (this.details.nationalRegisterNumber !== null && this.details.nationalRegisterNumber !== NationalRegisterNumberOptOut) {
375
373
  return false;
376
374
  }
377
375
 
378
- if (this.details.uitpasNumber) {
376
+ if (this.details.requiresFinancialSupport !== null) {
377
+ return false;
378
+ }
379
+
380
+ if (this.details.address || this.details.phone || this.details.email || this.details.alternativeEmails.length > 0 || this.details.unverifiedAddresses.length > 0 || this.details.unverifiedPhones.length > 0 || this.details.unverifiedEmails.length > 0) {
381
+ return false;
382
+ }
383
+
384
+ // If responsibilities: not safe
385
+ const responsibilities = await MemberResponsibilityRecord.where({ memberId: this.id }, { limit: 1 });
386
+ if (responsibilities.length > 0) {
379
387
  return false;
380
388
  }
381
389
 
@@ -176,20 +176,6 @@ export class Organization extends QueryableModel {
176
176
  return this.fromRow(rows[0][this.table]);
177
177
  }
178
178
 
179
- /**
180
- * Get an Organization by looking at the host of a request
181
- * Format is 2331c59a-0cbe-4279-871c-ea9d0474cd54.api.stamhoofd.app
182
- * + switch country if needed
183
- */
184
- static async getFromRequest(request: DecodedRequest<any, any, any>): Promise<Organization> {
185
- const organization = await Organization.fromApiHost(request.host);
186
-
187
- const i18n = I18n.fromRequest(request);
188
- i18n.switchToLocale({ country: organization.address.country });
189
-
190
- return organization;
191
- }
192
-
193
179
  /**
194
180
  * Get an Organization by looking at the host of a request
195
181
  * Format is 2331c59a-0cbe-4279-871c-ea9d0474cd54.api.stamhoofd.app