@sphereon/ssi-sdk.data-store 0.18.2-next.58 → 0.18.2-next.77

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 (55) hide show
  1. package/dist/contact/AbstractContactStore.d.ts +11 -1
  2. package/dist/contact/AbstractContactStore.d.ts.map +1 -1
  3. package/dist/contact/AbstractContactStore.js.map +1 -1
  4. package/dist/contact/ContactStore.d.ts +27 -15
  5. package/dist/contact/ContactStore.d.ts.map +1 -1
  6. package/dist/contact/ContactStore.js +199 -36
  7. package/dist/contact/ContactStore.js.map +1 -1
  8. package/dist/entities/contact/ElectronicAddressEntity.d.ts +1 -0
  9. package/dist/entities/contact/ElectronicAddressEntity.d.ts.map +1 -1
  10. package/dist/entities/contact/ElectronicAddressEntity.js +4 -0
  11. package/dist/entities/contact/ElectronicAddressEntity.js.map +1 -1
  12. package/dist/entities/contact/IdentityEntity.d.ts +1 -1
  13. package/dist/entities/contact/IdentityEntity.d.ts.map +1 -1
  14. package/dist/entities/contact/PartyEntity.d.ts +2 -0
  15. package/dist/entities/contact/PartyEntity.d.ts.map +1 -1
  16. package/dist/entities/contact/PartyEntity.js +12 -1
  17. package/dist/entities/contact/PartyEntity.js.map +1 -1
  18. package/dist/entities/contact/PhysicalAddressEntity.d.ts +21 -0
  19. package/dist/entities/contact/PhysicalAddressEntity.d.ts.map +1 -0
  20. package/dist/entities/contact/PhysicalAddressEntity.js +126 -0
  21. package/dist/entities/contact/PhysicalAddressEntity.js.map +1 -0
  22. package/dist/index.d.ts +2 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +4 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/issuanceBranding/IssuanceBrandingStore.d.ts.map +1 -1
  27. package/dist/issuanceBranding/IssuanceBrandingStore.js +76 -60
  28. package/dist/issuanceBranding/IssuanceBrandingStore.js.map +1 -1
  29. package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts.map +1 -1
  30. package/dist/migrations/sqlite/1690925872693-CreateContacts.js +3 -6
  31. package/dist/migrations/sqlite/1690925872693-CreateContacts.js.map +1 -1
  32. package/dist/types/contact/IAbstractContactStore.d.ts +36 -1
  33. package/dist/types/contact/IAbstractContactStore.d.ts.map +1 -1
  34. package/dist/types/contact/contact.d.ts +27 -4
  35. package/dist/types/contact/contact.d.ts.map +1 -1
  36. package/dist/types/contact/contact.js.map +1 -1
  37. package/dist/utils/contact/MappingUtils.d.ts +4 -1
  38. package/dist/utils/contact/MappingUtils.d.ts.map +1 -1
  39. package/dist/utils/contact/MappingUtils.js +37 -1
  40. package/dist/utils/contact/MappingUtils.js.map +1 -1
  41. package/package.json +4 -4
  42. package/src/__tests__/contact.entities.test.ts +323 -23
  43. package/src/__tests__/contact.store.test.ts +586 -10
  44. package/src/contact/AbstractContactStore.ts +38 -17
  45. package/src/contact/ContactStore.ts +276 -62
  46. package/src/entities/contact/ElectronicAddressEntity.ts +3 -0
  47. package/src/entities/contact/IdentityEntity.ts +1 -1
  48. package/src/entities/contact/PartyEntity.ts +11 -1
  49. package/src/entities/contact/PhysicalAddressEntity.ts +87 -0
  50. package/src/index.ts +3 -0
  51. package/src/issuanceBranding/IssuanceBrandingStore.ts +78 -62
  52. package/src/migrations/sqlite/1690925872693-CreateContacts.ts +3 -8
  53. package/src/types/contact/IAbstractContactStore.ts +58 -8
  54. package/src/types/contact/contact.ts +29 -4
  55. package/src/utils/contact/MappingUtils.ts +39 -1
@@ -1,37 +1,41 @@
1
1
  import { DataSource, FindOptionsWhere } from 'typeorm'
2
-
3
2
  import { DataStoreContactEntities, DataStoreMigrations } from '../index'
3
+ import { BaseContactEntity } from '../entities/contact/BaseContactEntity'
4
+ import { ConnectionEntity } from '../entities/contact/ConnectionEntity'
5
+ import { CorrelationIdentifierEntity } from '../entities/contact/CorrelationIdentifierEntity'
6
+ import { DidAuthConfigEntity } from '../entities/contact/DidAuthConfigEntity'
7
+ import { ElectronicAddressEntity } from '../entities/contact/ElectronicAddressEntity'
8
+ import { IdentityEntity } from '../entities/contact/IdentityEntity'
9
+ import { IdentityMetadataItemEntity } from '../entities/contact/IdentityMetadataItemEntity'
4
10
  import { NaturalPersonEntity } from '../entities/contact/NaturalPersonEntity'
11
+ import { OpenIdConfigEntity } from '../entities/contact/OpenIdConfigEntity'
5
12
  import { OrganizationEntity } from '../entities/contact/OrganizationEntity'
13
+ import { PartyEntity } from '../entities/contact/PartyEntity'
6
14
  import { PartyRelationshipEntity } from '../entities/contact/PartyRelationshipEntity'
7
15
  import { PartyTypeEntity } from '../entities/contact/PartyTypeEntity'
8
- import { PartyEntity } from '../entities/contact/PartyEntity'
9
- import { IdentityEntity } from '../entities/contact/IdentityEntity'
10
- import { OpenIdConfigEntity } from '../entities/contact/OpenIdConfigEntity'
11
- import { DidAuthConfigEntity } from '../entities/contact/DidAuthConfigEntity'
12
- import { ConnectionEntity } from '../entities/contact/ConnectionEntity'
13
- import { CorrelationIdentifierEntity } from '../entities/contact/CorrelationIdentifierEntity'
14
- import { IdentityMetadataItemEntity } from '../entities/contact/IdentityMetadataItemEntity'
15
- import { BaseContactEntity } from '../entities/contact/BaseContactEntity'
16
+ import { PhysicalAddressEntity } from '../entities/contact/PhysicalAddressEntity'
16
17
  import {
17
- NonPersistedParty,
18
- PartyTypeEnum,
19
- NaturalPerson,
20
- Organization,
21
- IdentityRoleEnum,
22
- CorrelationIdentifierEnum,
23
18
  ConnectionTypeEnum,
24
- NonPersistedPartyType,
25
- NonPersistedOrganization,
26
- NonPersistedNaturalPerson,
19
+ CorrelationIdentifierEnum,
20
+ IdentityRoleEnum,
21
+ NaturalPerson,
27
22
  NonPersistedConnection,
28
- NonPersistedIdentity,
29
23
  NonPersistedDidAuthConfig,
24
+ NonPersistedElectronicAddress,
25
+ NonPersistedIdentity,
26
+ NonPersistedNaturalPerson,
30
27
  NonPersistedOpenIdConfig,
28
+ NonPersistedOrganization,
29
+ NonPersistedParty,
30
+ NonPersistedPartyType,
31
+ NonPersistedPhysicalAddress,
32
+ Organization,
33
+ PartyTypeEnum
31
34
  } from '../types'
32
35
  import {
33
36
  connectionEntityFrom,
34
37
  didAuthConfigEntityFrom,
38
+ electronicAddressEntityFrom,
35
39
  identityEntityFrom,
36
40
  naturalPersonEntityFrom,
37
41
  openIdConfigEntityFrom,
@@ -39,6 +43,7 @@ import {
39
43
  partyEntityFrom,
40
44
  partyRelationshipEntityFrom,
41
45
  partyTypeEntityFrom,
46
+ physicalAddressEntityFrom,
42
47
  } from '../utils/contact/MappingUtils'
43
48
 
44
49
  // TODO write test adding two contacts reusing the same contactType
@@ -81,12 +86,12 @@ describe('Database entities tests', (): void => {
81
86
  }
82
87
 
83
88
  const partyEntity: PartyEntity = partyEntityFrom(party)
84
- await dbConnection.getRepository(PartyEntity).save(partyEntity, {
89
+ const savedParty: PartyEntity = await dbConnection.getRepository(PartyEntity).save(partyEntity, {
85
90
  transaction: true,
86
91
  })
87
92
 
88
93
  const fromDb: PartyEntity | null = await dbConnection.getRepository(PartyEntity).findOne({
89
- where: { id: partyEntity.id },
94
+ where: { id: savedParty.id },
90
95
  })
91
96
 
92
97
  expect(fromDb).toBeDefined()
@@ -118,12 +123,12 @@ describe('Database entities tests', (): void => {
118
123
  }
119
124
 
120
125
  const partyEntity: PartyEntity = partyEntityFrom(party)
121
- await dbConnection.getRepository(PartyEntity).save(partyEntity, {
126
+ const savedParty: PartyEntity = await dbConnection.getRepository(PartyEntity).save(partyEntity, {
122
127
  transaction: true,
123
128
  })
124
129
 
125
130
  const fromDb: PartyEntity | null = await dbConnection.getRepository(PartyEntity).findOne({
126
- where: { id: partyEntity.id },
131
+ where: { id: savedParty.id },
127
132
  })
128
133
 
129
134
  expect(fromDb).toBeDefined()
@@ -838,6 +843,17 @@ describe('Database entities tests', (): void => {
838
843
 
839
844
  expect(savedIdentity).toBeDefined()
840
845
 
846
+ const electronicAddress: NonPersistedElectronicAddress = {
847
+ type: 'email',
848
+ electronicAddress: 'example_electronic_address'
849
+ }
850
+ const electronicAddressEntity: ElectronicAddressEntity = electronicAddressEntityFrom(electronicAddress)
851
+ electronicAddressEntity.party = savedParty1
852
+
853
+ const savedElectronicAddress: ElectronicAddressEntity | null = await dbConnection.getRepository(ElectronicAddressEntity).save(electronicAddressEntity)
854
+
855
+ expect(savedElectronicAddress).toBeDefined()
856
+
841
857
  const relationship: PartyRelationshipEntity = partyRelationshipEntityFrom({
842
858
  leftId: savedParty1.id,
843
859
  rightId: savedParty2.id,
@@ -899,6 +915,13 @@ describe('Database entities tests', (): void => {
899
915
  })
900
916
  ).toBeNull()
901
917
 
918
+ // check electronic address
919
+ expect(
920
+ await dbConnection.getRepository(ElectronicAddressEntity).findOne({
921
+ where: { id: savedParty1.id },
922
+ })
923
+ ).toBeNull()
924
+
902
925
  // check contact
903
926
  expect(
904
927
  await dbConnection.getRepository(BaseContactEntity).findOne({
@@ -2172,4 +2195,281 @@ describe('Database entities tests', (): void => {
2172
2195
  expect(fromDb).toBeDefined()
2173
2196
  expect(fromDb?.createdAt).toEqual(savedPartyType?.createdAt)
2174
2197
  })
2198
+
2199
+ it('Should save email electronic address to database', async (): Promise<void> => {
2200
+ const electronicAddress: NonPersistedElectronicAddress = {
2201
+ type: 'email',
2202
+ electronicAddress: 'example_email_address'
2203
+ }
2204
+
2205
+ const electronicAddressEntity: ElectronicAddressEntity = electronicAddressEntityFrom(electronicAddress)
2206
+ const savedElectronicAddress: ElectronicAddressEntity = await dbConnection.getRepository(ElectronicAddressEntity).save(electronicAddressEntity, {
2207
+ transaction: true,
2208
+ })
2209
+
2210
+ const fromDb: ElectronicAddressEntity | null = await dbConnection.getRepository(ElectronicAddressEntity).findOne({
2211
+ where: { id: savedElectronicAddress.id },
2212
+ })
2213
+
2214
+ expect(fromDb).toBeDefined()
2215
+ expect(fromDb?.type).toEqual(electronicAddress.type)
2216
+ expect(fromDb?.electronicAddress).toEqual(electronicAddress.electronicAddress)
2217
+ expect(fromDb?.createdAt).toBeDefined()
2218
+ expect(fromDb?.lastUpdatedAt).toBeDefined()
2219
+ })
2220
+
2221
+ it('Should save phone electronic address to database', async (): Promise<void> => {
2222
+ const electronicAddress: NonPersistedElectronicAddress = {
2223
+ type: 'phone',
2224
+ electronicAddress: 'example_phone_number'
2225
+ }
2226
+
2227
+ const electronicAddressEntity: ElectronicAddressEntity = electronicAddressEntityFrom(electronicAddress)
2228
+ const savedElectronicAddress: ElectronicAddressEntity = await dbConnection.getRepository(ElectronicAddressEntity).save(electronicAddressEntity, {
2229
+ transaction: true,
2230
+ })
2231
+
2232
+ const fromDb: ElectronicAddressEntity | null = await dbConnection.getRepository(ElectronicAddressEntity).findOne({
2233
+ where: { id: savedElectronicAddress.id },
2234
+ })
2235
+
2236
+ expect(fromDb).toBeDefined()
2237
+ expect(fromDb?.type).toEqual(electronicAddress.type)
2238
+ expect(fromDb?.electronicAddress).toEqual(electronicAddress.electronicAddress)
2239
+ expect(fromDb?.createdAt).toBeDefined()
2240
+ expect(fromDb?.lastUpdatedAt).toBeDefined()
2241
+ })
2242
+
2243
+ it('should throw error when saving electronic address with blank electronic address', async (): Promise<void> => {
2244
+ const electronicAddress: NonPersistedElectronicAddress = {
2245
+ type: 'email',
2246
+ electronicAddress: ''
2247
+ }
2248
+
2249
+ const electronicAddressEntity: ElectronicAddressEntity = electronicAddressEntityFrom(electronicAddress)
2250
+
2251
+ await expect(dbConnection.getRepository(ElectronicAddressEntity).save(electronicAddressEntity)).rejects.toThrowError('Blank electronic addresses are not allowed')
2252
+ })
2253
+
2254
+ it('Should save home physical address to database', async (): Promise<void> => {
2255
+ const physicalAddress: NonPersistedPhysicalAddress = {
2256
+ type: 'home',
2257
+ streetName: 'example_street_name',
2258
+ streetNumber: 'example_street_number',
2259
+ buildingName: 'example_building_name',
2260
+ postalCode: 'example_postal_code',
2261
+ cityName: 'example_city_name',
2262
+ provinceName: 'example_province_name',
2263
+ countryCode: 'example_country_code',
2264
+ }
2265
+
2266
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2267
+ const savedPhysicalAddress: PhysicalAddressEntity = await dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity, {
2268
+ transaction: true,
2269
+ })
2270
+
2271
+ const fromDb: PhysicalAddressEntity | null = await dbConnection.getRepository(PhysicalAddressEntity).findOne({
2272
+ where: { id: savedPhysicalAddress.id },
2273
+ })
2274
+
2275
+ expect(fromDb).toBeDefined()
2276
+ expect(fromDb?.type).toEqual(physicalAddress.type)
2277
+ expect(fromDb?.streetName).toEqual(physicalAddress.streetName)
2278
+ expect(fromDb?.streetNumber).toEqual(physicalAddress.streetNumber)
2279
+ expect(fromDb?.buildingName).toEqual(physicalAddress.buildingName)
2280
+ expect(fromDb?.postalCode).toEqual(physicalAddress.postalCode)
2281
+ expect(fromDb?.cityName).toEqual(physicalAddress.cityName)
2282
+ expect(fromDb?.provinceName).toEqual(physicalAddress.provinceName)
2283
+ expect(fromDb?.countryCode).toEqual(physicalAddress.countryCode)
2284
+ expect(fromDb?.createdAt).toBeDefined()
2285
+ expect(fromDb?.lastUpdatedAt).toBeDefined()
2286
+ })
2287
+
2288
+ it('Should save visit physical address to database', async (): Promise<void> => {
2289
+ const physicalAddress: NonPersistedPhysicalAddress = {
2290
+ type: 'visit',
2291
+ streetName: 'example_street_name',
2292
+ streetNumber: 'example_street_number',
2293
+ buildingName: 'example_building_name',
2294
+ postalCode: 'example_postal_code',
2295
+ cityName: 'example_city_name',
2296
+ provinceName: 'example_province_name',
2297
+ countryCode: 'example_country_code',
2298
+ }
2299
+
2300
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2301
+ const savedPhysicalAddress: PhysicalAddressEntity = await dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity, {
2302
+ transaction: true,
2303
+ })
2304
+
2305
+ const fromDb: PhysicalAddressEntity | null = await dbConnection.getRepository(PhysicalAddressEntity).findOne({
2306
+ where: { id: savedPhysicalAddress.id },
2307
+ })
2308
+
2309
+ expect(fromDb).toBeDefined()
2310
+ expect(fromDb?.type).toEqual(physicalAddress.type)
2311
+ expect(fromDb?.streetName).toEqual(physicalAddress.streetName)
2312
+ expect(fromDb?.streetNumber).toEqual(physicalAddress.streetNumber)
2313
+ expect(fromDb?.buildingName).toEqual(physicalAddress.buildingName)
2314
+ expect(fromDb?.postalCode).toEqual(physicalAddress.postalCode)
2315
+ expect(fromDb?.cityName).toEqual(physicalAddress.cityName)
2316
+ expect(fromDb?.provinceName).toEqual(physicalAddress.provinceName)
2317
+ expect(fromDb?.countryCode).toEqual(physicalAddress.countryCode)
2318
+ expect(fromDb?.createdAt).toBeDefined()
2319
+ expect(fromDb?.lastUpdatedAt).toBeDefined()
2320
+ })
2321
+
2322
+ it('Should save postal physical address to database', async (): Promise<void> => {
2323
+ const physicalAddress: NonPersistedPhysicalAddress = {
2324
+ type: 'postal',
2325
+ streetName: 'example_street_name',
2326
+ streetNumber: 'example_street_number',
2327
+ buildingName: 'example_building_name',
2328
+ postalCode: 'example_postal_code',
2329
+ cityName: 'example_city_name',
2330
+ provinceName: 'example_province_name',
2331
+ countryCode: 'example_country_code',
2332
+ }
2333
+
2334
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2335
+ const savedPhysicalAddress: PhysicalAddressEntity = await dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity, {
2336
+ transaction: true,
2337
+ })
2338
+
2339
+ const fromDb: PhysicalAddressEntity | null = await dbConnection.getRepository(PhysicalAddressEntity).findOne({
2340
+ where: { id: savedPhysicalAddress.id },
2341
+ })
2342
+
2343
+ expect(fromDb).toBeDefined()
2344
+ expect(fromDb?.type).toEqual(physicalAddress.type)
2345
+ expect(fromDb?.streetName).toEqual(physicalAddress.streetName)
2346
+ expect(fromDb?.streetNumber).toEqual(physicalAddress.streetNumber)
2347
+ expect(fromDb?.buildingName).toEqual(physicalAddress.buildingName)
2348
+ expect(fromDb?.postalCode).toEqual(physicalAddress.postalCode)
2349
+ expect(fromDb?.cityName).toEqual(physicalAddress.cityName)
2350
+ expect(fromDb?.provinceName).toEqual(physicalAddress.provinceName)
2351
+ expect(fromDb?.countryCode).toEqual(physicalAddress.countryCode)
2352
+ expect(fromDb?.createdAt).toBeDefined()
2353
+ expect(fromDb?.lastUpdatedAt).toBeDefined()
2354
+ })
2355
+
2356
+ it('should throw error when saving physical address with blank street name', async (): Promise<void> => {
2357
+ const physicalAddress: NonPersistedPhysicalAddress = {
2358
+ type: 'home',
2359
+ streetName: '',
2360
+ streetNumber: 'example_street_number',
2361
+ buildingName: 'example_building_name',
2362
+ postalCode: 'example_postal_code',
2363
+ cityName: 'example_city_name',
2364
+ provinceName: 'example_province_name',
2365
+ countryCode: 'example_country_code',
2366
+ }
2367
+
2368
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2369
+
2370
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError('Blank street names are not allowed')
2371
+ })
2372
+
2373
+ it('should throw error when saving physical address with blank street number', async (): Promise<void> => {
2374
+ const physicalAddress: NonPersistedPhysicalAddress = {
2375
+ type: 'home',
2376
+ streetName: 'example_street_name',
2377
+ streetNumber: '',
2378
+ buildingName: 'example_building_name',
2379
+ postalCode: 'example_postal_code',
2380
+ cityName: 'example_city_name',
2381
+ provinceName: 'example_province_name',
2382
+ countryCode: 'example_country_code',
2383
+ }
2384
+
2385
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2386
+
2387
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError('Blank street numbers are not allowed')
2388
+ })
2389
+
2390
+ it('should throw error when saving physical address with blank building name', async (): Promise<void> => {
2391
+ const physicalAddress: NonPersistedPhysicalAddress = {
2392
+ type: 'home',
2393
+ streetName: 'example_street_name',
2394
+ streetNumber: 'example_street_number',
2395
+ buildingName: '',
2396
+ postalCode: 'example_postal_code',
2397
+ cityName: 'example_city_name',
2398
+ provinceName: 'example_province_name',
2399
+ countryCode: 'example_country_code',
2400
+ }
2401
+
2402
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2403
+
2404
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError('Blank building names are not allowed')
2405
+ })
2406
+
2407
+ it('should throw error when saving physical address with blank postal code', async (): Promise<void> => {
2408
+ const physicalAddress: NonPersistedPhysicalAddress = {
2409
+ type: 'home',
2410
+ streetName: 'example_street_name',
2411
+ streetNumber: 'example_street_number',
2412
+ buildingName: 'example_building_name',
2413
+ postalCode: '',
2414
+ cityName: 'example_city_name',
2415
+ provinceName: 'example_province_name',
2416
+ countryCode: 'example_country_code',
2417
+ }
2418
+
2419
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2420
+
2421
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError('Blank postal codes are not allowed')
2422
+ })
2423
+
2424
+ it('should throw error when saving physical address with blank city name', async (): Promise<void> => {
2425
+ const physicalAddress: NonPersistedPhysicalAddress = {
2426
+ type: 'home',
2427
+ streetName: 'example_street_name',
2428
+ streetNumber: 'example_street_number',
2429
+ buildingName: 'example_building_name',
2430
+ postalCode: 'example_postal_code',
2431
+ cityName: '',
2432
+ provinceName: 'example_province_name',
2433
+ countryCode: 'example_country_code',
2434
+ }
2435
+
2436
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2437
+
2438
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError('Blank city names are not allowed')
2439
+ })
2440
+
2441
+ it('should throw error when saving physical address with blank province name', async (): Promise<void> => {
2442
+ const physicalAddress: NonPersistedPhysicalAddress = {
2443
+ type: 'home',
2444
+ streetName: 'example_street_name',
2445
+ streetNumber: 'example_street_number',
2446
+ buildingName: 'example_building_name',
2447
+ postalCode: 'example_postal_code',
2448
+ cityName: 'example_city_name',
2449
+ provinceName: '',
2450
+ countryCode: 'example_country_code',
2451
+ }
2452
+
2453
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2454
+
2455
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError('Blank province names are not allowed')
2456
+ })
2457
+
2458
+ it('should throw error when saving physical address with blank country code', async (): Promise<void> => {
2459
+ const physicalAddress: NonPersistedPhysicalAddress = {
2460
+ type: 'home',
2461
+ streetName: 'example_street_name',
2462
+ streetNumber: 'example_street_number',
2463
+ buildingName: 'example_building_name',
2464
+ postalCode: 'example_postal_code',
2465
+ cityName: 'example_city_name',
2466
+ provinceName: 'example_province_name',
2467
+ countryCode: '',
2468
+ }
2469
+
2470
+ const physicalAddressEntity: PhysicalAddressEntity = physicalAddressEntityFrom(physicalAddress)
2471
+
2472
+ await expect(dbConnection.getRepository(PhysicalAddressEntity).save(physicalAddressEntity)).rejects.toThrowError('Blank country codes are not allowed')
2473
+ })
2474
+
2175
2475
  })