@sphereon/ssi-sdk.data-store 0.18.2-unstable.7 → 0.18.2-unstable.85
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/LICENSE +201 -201
- package/README.md +77 -77
- package/dist/contact/AbstractContactStore.d.ts +33 -23
- package/dist/contact/AbstractContactStore.d.ts.map +1 -1
- package/dist/contact/AbstractContactStore.js +6 -6
- package/dist/contact/AbstractContactStore.js.map +1 -1
- package/dist/contact/ContactStore.d.ts +44 -32
- package/dist/contact/ContactStore.d.ts.map +1 -1
- package/dist/contact/ContactStore.js +528 -365
- package/dist/contact/ContactStore.js.map +1 -1
- package/dist/digitalCredential/AbstractDigitalCredentialStore.d.ts +10 -0
- package/dist/digitalCredential/AbstractDigitalCredentialStore.d.ts.map +1 -0
- package/dist/digitalCredential/AbstractDigitalCredentialStore.js +7 -0
- package/dist/digitalCredential/AbstractDigitalCredentialStore.js.map +1 -0
- package/dist/digitalCredential/DigitalCredentialStore.d.ts +15 -0
- package/dist/digitalCredential/DigitalCredentialStore.d.ts.map +1 -0
- package/dist/digitalCredential/DigitalCredentialStore.js +97 -0
- package/dist/digitalCredential/DigitalCredentialStore.js.map +1 -0
- package/dist/entities/contact/BaseConfigEntity.d.ts +6 -6
- package/dist/entities/contact/BaseConfigEntity.js +33 -33
- package/dist/entities/contact/BaseContactEntity.d.ts +9 -9
- package/dist/entities/contact/BaseContactEntity.js +53 -53
- package/dist/entities/contact/ConnectionEntity.d.ts +10 -10
- package/dist/entities/contact/ConnectionEntity.js +46 -46
- package/dist/entities/contact/CorrelationIdentifierEntity.d.ts +10 -10
- package/dist/entities/contact/CorrelationIdentifierEntity.js +71 -71
- package/dist/entities/contact/DidAuthConfigEntity.d.ts +6 -6
- package/dist/entities/contact/DidAuthConfigEntity.js +32 -32
- package/dist/entities/contact/ElectronicAddressEntity.d.ts +14 -13
- package/dist/entities/contact/ElectronicAddressEntity.d.ts.map +1 -1
- package/dist/entities/contact/ElectronicAddressEntity.js +95 -91
- package/dist/entities/contact/ElectronicAddressEntity.js.map +1 -1
- package/dist/entities/contact/IdentityEntity.d.ts +20 -20
- package/dist/entities/contact/IdentityEntity.d.ts.map +1 -1
- package/dist/entities/contact/IdentityEntity.js +128 -128
- package/dist/entities/contact/IdentityMetadataItemEntity.d.ts +9 -9
- package/dist/entities/contact/IdentityMetadataItemEntity.js +68 -68
- package/dist/entities/contact/NaturalPersonEntity.d.ts +8 -8
- package/dist/entities/contact/NaturalPersonEntity.js +71 -71
- package/dist/entities/contact/OpenIdConfigEntity.d.ts +10 -10
- package/dist/entities/contact/OpenIdConfigEntity.js +48 -48
- package/dist/entities/contact/OrganizationEntity.d.ts +8 -8
- package/dist/entities/contact/OrganizationEntity.js +66 -66
- package/dist/entities/contact/PartyEntity.d.ts +21 -19
- package/dist/entities/contact/PartyEntity.d.ts.map +1 -1
- package/dist/entities/contact/PartyEntity.js +142 -131
- package/dist/entities/contact/PartyEntity.js.map +1 -1
- package/dist/entities/contact/PartyRelationshipEntity.d.ts +12 -12
- package/dist/entities/contact/PartyRelationshipEntity.js +94 -94
- package/dist/entities/contact/PartyTypeEntity.d.ts +14 -14
- package/dist/entities/contact/PartyTypeEntity.js +103 -103
- package/dist/entities/contact/PhysicalAddressEntity.d.ts +21 -0
- package/dist/entities/contact/PhysicalAddressEntity.d.ts.map +1 -0
- package/dist/entities/contact/PhysicalAddressEntity.js +126 -0
- package/dist/entities/contact/PhysicalAddressEntity.js.map +1 -0
- package/dist/entities/digitalCredential/DigitalCredentialEntity.d.ts +23 -0
- package/dist/entities/digitalCredential/DigitalCredentialEntity.d.ts.map +1 -0
- package/dist/entities/digitalCredential/DigitalCredentialEntity.js +93 -0
- package/dist/entities/digitalCredential/DigitalCredentialEntity.js.map +1 -0
- package/dist/entities/eventLogger/AuditEventEntity.d.ts +26 -26
- package/dist/entities/eventLogger/AuditEventEntity.js +123 -123
- package/dist/entities/eventLogger/AuditEventEntity.js.map +1 -1
- package/dist/entities/issuanceBranding/BackgroundAttributesEntity.d.ts +10 -10
- package/dist/entities/issuanceBranding/BackgroundAttributesEntity.js +73 -73
- package/dist/entities/issuanceBranding/BaseLocaleBrandingEntity.d.ts +17 -17
- package/dist/entities/issuanceBranding/BaseLocaleBrandingEntity.js +119 -119
- package/dist/entities/issuanceBranding/CredentialBrandingEntity.d.ts +14 -14
- package/dist/entities/issuanceBranding/CredentialBrandingEntity.js +101 -101
- package/dist/entities/issuanceBranding/CredentialLocaleBrandingEntity.d.ts +8 -8
- package/dist/entities/issuanceBranding/CredentialLocaleBrandingEntity.js +48 -48
- package/dist/entities/issuanceBranding/ImageAttributesEntity.d.ts +13 -13
- package/dist/entities/issuanceBranding/ImageAttributesEntity.js +91 -91
- package/dist/entities/issuanceBranding/ImageDimensionsEntity.d.ts +8 -8
- package/dist/entities/issuanceBranding/ImageDimensionsEntity.js +38 -38
- package/dist/entities/issuanceBranding/IssuerBrandingEntity.d.ts +13 -13
- package/dist/entities/issuanceBranding/IssuerBrandingEntity.js +94 -94
- package/dist/entities/issuanceBranding/IssuerLocaleBrandingEntity.d.ts +8 -8
- package/dist/entities/issuanceBranding/IssuerLocaleBrandingEntity.js +48 -48
- package/dist/entities/issuanceBranding/TextAttributesEntity.d.ts +8 -8
- package/dist/entities/issuanceBranding/TextAttributesEntity.js +61 -61
- package/dist/entities/statusList2021/StatusList2021Entity.d.ts +18 -18
- package/dist/entities/statusList2021/StatusList2021Entity.js +114 -114
- package/dist/entities/statusList2021/StatusList2021EntryEntity.d.ts +10 -10
- package/dist/entities/statusList2021/StatusList2021EntryEntity.js +50 -50
- package/dist/entities/validators/index.d.ts +6 -6
- package/dist/entities/validators/index.js +26 -26
- package/dist/eventLogger/AbstractEventLoggerStore.d.ts +6 -6
- package/dist/eventLogger/AbstractEventLoggerStore.js +6 -6
- package/dist/eventLogger/EventLoggerStore.d.ts +12 -12
- package/dist/eventLogger/EventLoggerStore.js +43 -43
- package/dist/index.d.ts +45 -41
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +143 -127
- package/dist/index.js.map +1 -1
- package/dist/issuanceBranding/AbstractIssuanceBrandingStore.d.ts +19 -19
- package/dist/issuanceBranding/AbstractIssuanceBrandingStore.js +6 -6
- package/dist/issuanceBranding/IssuanceBrandingStore.d.ts +30 -30
- package/dist/issuanceBranding/IssuanceBrandingStore.d.ts.map +1 -1
- package/dist/issuanceBranding/IssuanceBrandingStore.js +390 -374
- package/dist/issuanceBranding/IssuanceBrandingStore.js.map +1 -1
- package/dist/migrations/generic/1-CreateContacts.d.ts +6 -6
- package/dist/migrations/generic/1-CreateContacts.js +77 -77
- package/dist/migrations/generic/2-CreateIssuanceBranding.d.ts +6 -6
- package/dist/migrations/generic/2-CreateIssuanceBranding.js +77 -77
- package/dist/migrations/generic/3-CreateContacts.d.ts +6 -6
- package/dist/migrations/generic/3-CreateContacts.js +77 -77
- package/dist/migrations/generic/4-CreateStatusList.d.ts +6 -6
- package/dist/migrations/generic/4-CreateStatusList.js +71 -71
- package/dist/migrations/generic/5-CreateAuditEvents.d.ts +6 -6
- package/dist/migrations/generic/5-CreateAuditEvents.js +77 -77
- package/dist/migrations/generic/{2-CreateContacts.d.ts → 6-CreateDigitalCredential.d.ts} +2 -2
- package/dist/migrations/generic/6-CreateDigitalCredential.d.ts.map +1 -0
- package/dist/migrations/generic/{2-CreateContacts.js → 6-CreateDigitalCredential.js} +23 -23
- package/dist/migrations/generic/6-CreateDigitalCredential.js.map +1 -0
- package/dist/migrations/generic/index.d.ts +18 -16
- package/dist/migrations/generic/index.d.ts.map +1 -1
- package/dist/migrations/generic/index.js +30 -27
- package/dist/migrations/generic/index.js.map +1 -1
- package/dist/migrations/index.d.ts +1 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +10 -5
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/internal-migrations-ormconfig.d.ts +6 -6
- package/dist/migrations/internal-migrations-ormconfig.js +26 -26
- package/dist/migrations/postgres/1659463079428-CreateContacts.d.ts +6 -6
- package/dist/migrations/postgres/1659463079428-CreateContacts.js +56 -56
- package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.d.ts +6 -6
- package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.js +68 -68
- package/dist/migrations/postgres/1690925872592-CreateContacts.d.ts +6 -6
- package/dist/migrations/postgres/1690925872592-CreateContacts.js +68 -68
- package/dist/migrations/postgres/1693866470001-CreateStatusList.d.ts +6 -6
- package/dist/migrations/postgres/1693866470001-CreateStatusList.js +31 -31
- package/dist/migrations/postgres/1701634812183-CreateAuditEvents.d.ts +6 -6
- package/dist/migrations/postgres/1701634812183-CreateAuditEvents.js +42 -42
- package/dist/migrations/postgres/1701634812183-CreateAuditEvents.js.map +1 -1
- package/dist/migrations/{generic/3-CreateStatusList.d.ts → postgres/1708525189001-CreateDigitalCredential.d.ts} +2 -2
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.d.ts.map +1 -0
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js +59 -0
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js.map +1 -0
- package/dist/migrations/sqlite/1659463069549-CreateContacts.d.ts +6 -6
- package/dist/migrations/sqlite/1659463069549-CreateContacts.js +78 -78
- package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.d.ts +6 -6
- package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.js +88 -88
- package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts +6 -6
- package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts.map +1 -1
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js +104 -107
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js.map +1 -1
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.d.ts +6 -6
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.js +31 -31
- package/dist/migrations/sqlite/1701634819487-CreateAuditEvents.d.ts +6 -6
- package/dist/migrations/sqlite/1701634819487-CreateAuditEvents.js +28 -28
- package/dist/migrations/sqlite/1701634819487-CreateAuditEvents.js.map +1 -1
- package/dist/migrations/{postgres/CreateStatusList1693866470001-CreateStatusList.d.ts → sqlite/1708525189002-CreateDigitalCredential.d.ts} +2 -2
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.d.ts.map +1 -0
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js +50 -0
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js.map +1 -0
- package/dist/statusList/IStatusListStore.d.ts +19 -19
- package/dist/statusList/IStatusListStore.js +2 -2
- package/dist/statusList/StatusListStore.d.ts +35 -35
- package/dist/statusList/StatusListStore.js +212 -212
- package/dist/types/contact/IAbstractContactStore.d.ts +109 -74
- package/dist/types/contact/IAbstractContactStore.d.ts.map +1 -1
- package/dist/types/contact/IAbstractContactStore.js +2 -2
- package/dist/types/contact/contact.d.ts +196 -173
- package/dist/types/contact/contact.d.ts.map +1 -1
- package/dist/types/contact/contact.js +25 -25
- package/dist/types/contact/contact.js.map +1 -1
- package/dist/types/digitalCredential/IAbstractDigitalCredentialStore.d.ts +27 -0
- package/dist/types/digitalCredential/IAbstractDigitalCredentialStore.d.ts.map +1 -0
- package/dist/types/digitalCredential/IAbstractDigitalCredentialStore.js +3 -0
- package/dist/types/digitalCredential/IAbstractDigitalCredentialStore.js.map +1 -0
- package/dist/types/digitalCredential/digitalCredential.d.ts +41 -0
- package/dist/types/digitalCredential/digitalCredential.d.ts.map +1 -0
- package/dist/types/digitalCredential/digitalCredential.js +28 -0
- package/dist/types/digitalCredential/digitalCredential.js.map +1 -0
- package/dist/types/eventLogger/IAbstractEventLoggerStore.d.ts +9 -9
- package/dist/types/eventLogger/IAbstractEventLoggerStore.js +2 -2
- package/dist/types/eventLogger/eventLogger.d.ts +2 -2
- package/dist/types/eventLogger/eventLogger.js +2 -2
- package/dist/types/index.d.ts +9 -9
- package/dist/types/index.js +25 -25
- package/dist/types/issuanceBranding/IAbstractIssuanceBrandingStore.d.ts +58 -58
- package/dist/types/issuanceBranding/IAbstractIssuanceBrandingStore.js +2 -2
- package/dist/types/issuanceBranding/issuanceBranding.d.ts +114 -114
- package/dist/types/issuanceBranding/issuanceBranding.js +2 -2
- package/dist/types/statusList/IAbstractStatusListStore.d.ts +37 -37
- package/dist/types/statusList/IAbstractStatusListStore.js +2 -2
- package/dist/types/statusList/statusList.d.ts +24 -24
- package/dist/types/statusList/statusList.js +2 -2
- package/dist/types/validation/validation.d.ts +3 -3
- package/dist/types/validation/validation.js +2 -2
- package/dist/utils/ValidatorUtils.d.ts +3 -3
- package/dist/utils/ValidatorUtils.js +12 -12
- package/dist/utils/contact/MappingUtils.d.ts +49 -46
- package/dist/utils/contact/MappingUtils.d.ts.map +1 -1
- package/dist/utils/contact/MappingUtils.js +326 -290
- package/dist/utils/contact/MappingUtils.js.map +1 -1
- package/dist/utils/digitalCredential/MappingUtils.d.ts +9 -0
- package/dist/utils/digitalCredential/MappingUtils.d.ts.map +1 -0
- package/dist/utils/digitalCredential/MappingUtils.js +92 -0
- package/dist/utils/digitalCredential/MappingUtils.js.map +1 -0
- package/package.json +5 -4
- package/src/__tests__/contact.entities.test.ts +323 -23
- package/src/__tests__/contact.store.test.ts +586 -10
- package/src/__tests__/digitalCredential.entities.test.ts +247 -0
- package/src/__tests__/digitalCredential.store.test.ts +194 -0
- package/src/__tests__/eventLogger.entities.test.ts +73 -73
- package/src/__tests__/eventLogger.store.test.ts +136 -136
- package/src/contact/AbstractContactStore.ts +38 -17
- package/src/contact/ContactStore.ts +715 -501
- package/src/digitalCredential/AbstractDigitalCredentialStore.ts +16 -0
- package/src/digitalCredential/DigitalCredentialStore.ts +107 -0
- package/src/entities/contact/ElectronicAddressEntity.ts +3 -0
- package/src/entities/contact/IdentityEntity.ts +1 -1
- package/src/entities/contact/PartyEntity.ts +11 -1
- package/src/entities/contact/PhysicalAddressEntity.ts +87 -0
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +64 -0
- package/src/entities/eventLogger/AuditEventEntity.ts +99 -99
- package/src/entities/statusList2021/StatusList2021Entity.ts +96 -96
- package/src/eventLogger/AbstractEventLoggerStore.ts +7 -7
- package/src/eventLogger/EventLoggerStore.ts +62 -62
- package/src/index.ts +131 -113
- package/src/issuanceBranding/IssuanceBrandingStore.ts +78 -62
- package/src/migrations/generic/1-CreateContacts.ts +66 -66
- package/src/migrations/generic/2-CreateIssuanceBranding.ts +64 -64
- package/src/migrations/generic/3-CreateContacts.ts +66 -66
- package/src/migrations/generic/4-CreateStatusList.ts +54 -54
- package/src/migrations/generic/5-CreateAuditEvents.ts +66 -66
- package/src/migrations/generic/6-CreateDigitalCredential.ts +66 -0
- package/src/migrations/generic/index.ts +30 -27
- package/src/migrations/index.ts +8 -1
- package/src/migrations/postgres/1693866470001-CreateStatusList.ts +24 -24
- package/src/migrations/postgres/1701634812183-CreateAuditEvents.ts +33 -33
- package/src/migrations/postgres/1708525189001-CreateDigitalCredential.ts +44 -0
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +158 -163
- package/src/migrations/sqlite/1701634819487-CreateAuditEvents.ts +15 -15
- package/src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts +34 -0
- package/src/types/contact/IAbstractContactStore.ts +58 -8
- package/src/types/contact/contact.ts +29 -4
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +26 -0
- package/src/types/digitalCredential/digitalCredential.ts +45 -0
- package/src/types/eventLogger/IAbstractEventLoggerStore.ts +12 -12
- package/src/types/eventLogger/eventLogger.ts +3 -3
- package/src/types/index.ts +9 -9
- package/src/utils/contact/MappingUtils.ts +39 -1
- package/src/utils/digitalCredential/MappingUtils.ts +112 -0
- package/dist/entities/contact/ContactEntity.d.ts +0 -16
- package/dist/entities/contact/ContactEntity.d.ts.map +0 -1
- package/dist/entities/contact/ContactEntity.js +0 -164
- package/dist/entities/contact/ContactEntity.js.map +0 -1
- package/dist/migrations/generic/1-CreateIssuanceBranding.d.ts +0 -7
- package/dist/migrations/generic/1-CreateIssuanceBranding.d.ts.map +0 -1
- package/dist/migrations/generic/1-CreateIssuanceBranding.js +0 -96
- package/dist/migrations/generic/1-CreateIssuanceBranding.js.map +0 -1
- package/dist/migrations/generic/2-CreateContacts.d.ts.map +0 -1
- package/dist/migrations/generic/2-CreateContacts.js.map +0 -1
- package/dist/migrations/generic/3-CreateStatusList.d.ts.map +0 -1
- package/dist/migrations/generic/3-CreateStatusList.js +0 -72
- package/dist/migrations/generic/3-CreateStatusList.js.map +0 -1
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.d.ts.map +0 -1
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.js +0 -32
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.js.map +0 -1
- package/dist/migrations/postgres/uuid.d.ts +0 -3
- package/dist/migrations/postgres/uuid.d.ts.map +0 -1
- package/dist/migrations/postgres/uuid.js +0 -25
- package/dist/migrations/postgres/uuid.js.map +0 -1
|
@@ -2,22 +2,28 @@ import { DataSource } from 'typeorm'
|
|
|
2
2
|
import { DataStoreMigrations, DataStoreContactEntities } from '../index'
|
|
3
3
|
import { ContactStore } from '../contact/ContactStore'
|
|
4
4
|
import {
|
|
5
|
-
IdentityRoleEnum,
|
|
6
|
-
PartyTypeEnum,
|
|
7
|
-
NonPersistedParty,
|
|
8
|
-
Party,
|
|
9
5
|
CorrelationIdentifierEnum,
|
|
6
|
+
ElectronicAddress,
|
|
7
|
+
GetElectronicAddressesArgs,
|
|
8
|
+
GetIdentitiesArgs,
|
|
9
|
+
GetPartiesArgs,
|
|
10
|
+
GetPhysicalAddressesArgs,
|
|
11
|
+
GetRelationshipsArgs,
|
|
10
12
|
Identity,
|
|
13
|
+
IdentityRoleEnum,
|
|
11
14
|
NaturalPerson,
|
|
12
|
-
|
|
15
|
+
NonPersistedElectronicAddress,
|
|
13
16
|
NonPersistedIdentity,
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
NonPersistedNaturalPerson,
|
|
18
|
+
NonPersistedParty,
|
|
16
19
|
NonPersistedPartyRelationship,
|
|
20
|
+
NonPersistedPartyType,
|
|
21
|
+
NonPersistedPhysicalAddress,
|
|
22
|
+
Party,
|
|
17
23
|
PartyRelationship,
|
|
18
24
|
PartyType,
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
PartyTypeEnum,
|
|
26
|
+
PhysicalAddress,
|
|
21
27
|
} from '../types'
|
|
22
28
|
|
|
23
29
|
describe('Contact store tests', (): void => {
|
|
@@ -204,7 +210,7 @@ describe('Contact store tests', (): void => {
|
|
|
204
210
|
electronicAddresses: [
|
|
205
211
|
{
|
|
206
212
|
type: 'email',
|
|
207
|
-
electronicAddress: '
|
|
213
|
+
electronicAddress: 'example_electronic_address',
|
|
208
214
|
},
|
|
209
215
|
],
|
|
210
216
|
}
|
|
@@ -1676,6 +1682,7 @@ describe('Contact store tests', (): void => {
|
|
|
1676
1682
|
expect(resultPartyType).toBeDefined()
|
|
1677
1683
|
|
|
1678
1684
|
const includingMigrationPartyTypes: Array<PartyType> = await contactStore.getPartyTypes()
|
|
1685
|
+
// We are checking for 2 types here as we include the one from the migrations
|
|
1679
1686
|
expect(includingMigrationPartyTypes.length).toEqual(2)
|
|
1680
1687
|
|
|
1681
1688
|
await contactStore.removePartyType({ partyTypeId: savedPartyType.id })
|
|
@@ -1776,4 +1783,573 @@ describe('Contact store tests', (): void => {
|
|
|
1776
1783
|
|
|
1777
1784
|
await expect(contactStore.addParty(party)).rejects.toThrow(`Party type ${partyType}, does not match for provided contact`)
|
|
1778
1785
|
})
|
|
1786
|
+
|
|
1787
|
+
it('should get electronic address by id', async (): Promise<void> => {
|
|
1788
|
+
const party: NonPersistedParty = {
|
|
1789
|
+
uri: 'example.com',
|
|
1790
|
+
partyType: {
|
|
1791
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
1792
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
1793
|
+
name: 'example_name',
|
|
1794
|
+
},
|
|
1795
|
+
contact: {
|
|
1796
|
+
firstName: 'example_first_name',
|
|
1797
|
+
middleName: 'example_middle_name',
|
|
1798
|
+
lastName: 'example_last_name',
|
|
1799
|
+
displayName: 'example_display_name',
|
|
1800
|
+
},
|
|
1801
|
+
}
|
|
1802
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
1803
|
+
expect(savedParty).toBeDefined()
|
|
1804
|
+
|
|
1805
|
+
const electronicAddress: NonPersistedElectronicAddress = {
|
|
1806
|
+
type: 'email',
|
|
1807
|
+
electronicAddress: 'example_electronic_address'
|
|
1808
|
+
}
|
|
1809
|
+
const savedElectronicAddress: ElectronicAddress = await contactStore.addElectronicAddress({ partyId: savedParty.id, electronicAddress })
|
|
1810
|
+
expect(savedElectronicAddress).toBeDefined()
|
|
1811
|
+
|
|
1812
|
+
const result: ElectronicAddress = await contactStore.getElectronicAddress({ electronicAddressId: savedElectronicAddress.id })
|
|
1813
|
+
|
|
1814
|
+
expect(result).toBeDefined()
|
|
1815
|
+
})
|
|
1816
|
+
|
|
1817
|
+
it('should throw error when getting electronic address with unknown id', async (): Promise<void> => {
|
|
1818
|
+
const electronicAddressId = 'unknownElectronicAddressId'
|
|
1819
|
+
|
|
1820
|
+
await expect(contactStore.getElectronicAddress({ electronicAddressId })).rejects.toThrow(`No electronic address found for id: ${electronicAddressId}`)
|
|
1821
|
+
})
|
|
1822
|
+
|
|
1823
|
+
it('should get all electronic addresses for contact', async (): Promise<void> => {
|
|
1824
|
+
const party: NonPersistedParty = {
|
|
1825
|
+
uri: 'example.com',
|
|
1826
|
+
partyType: {
|
|
1827
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
1828
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
1829
|
+
name: 'example_name',
|
|
1830
|
+
},
|
|
1831
|
+
contact: {
|
|
1832
|
+
firstName: 'example_first_name',
|
|
1833
|
+
middleName: 'example_middle_name',
|
|
1834
|
+
lastName: 'example_last_name',
|
|
1835
|
+
displayName: 'example_display_name',
|
|
1836
|
+
},
|
|
1837
|
+
}
|
|
1838
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
1839
|
+
expect(savedParty).toBeDefined()
|
|
1840
|
+
|
|
1841
|
+
const electronicAddress1: NonPersistedElectronicAddress = {
|
|
1842
|
+
type: 'email',
|
|
1843
|
+
electronicAddress: 'example_electronic_address1'
|
|
1844
|
+
}
|
|
1845
|
+
const savedElectronicAddress1: ElectronicAddress = await contactStore.addElectronicAddress({ partyId: savedParty.id, electronicAddress: electronicAddress1 })
|
|
1846
|
+
expect(savedElectronicAddress1).toBeDefined()
|
|
1847
|
+
|
|
1848
|
+
const electronicAddress2: NonPersistedElectronicAddress = {
|
|
1849
|
+
type: 'email',
|
|
1850
|
+
electronicAddress: 'example_electronic_address2'
|
|
1851
|
+
}
|
|
1852
|
+
const savedElectronicAddress2: ElectronicAddress = await contactStore.addElectronicAddress({ partyId: savedParty.id, electronicAddress: electronicAddress2 })
|
|
1853
|
+
expect(savedElectronicAddress2).toBeDefined()
|
|
1854
|
+
|
|
1855
|
+
const args: GetElectronicAddressesArgs = {
|
|
1856
|
+
filter: [{ partyId: savedParty.id }],
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
const result: Array<ElectronicAddress> = await contactStore.getElectronicAddresses(args)
|
|
1860
|
+
|
|
1861
|
+
expect(result.length).toEqual(2)
|
|
1862
|
+
})
|
|
1863
|
+
|
|
1864
|
+
it('should get all electronic addresses', async (): Promise<void> => {
|
|
1865
|
+
const party: NonPersistedParty = {
|
|
1866
|
+
uri: 'example.com',
|
|
1867
|
+
partyType: {
|
|
1868
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
1869
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
1870
|
+
name: 'example_name',
|
|
1871
|
+
},
|
|
1872
|
+
contact: {
|
|
1873
|
+
firstName: 'example_first_name',
|
|
1874
|
+
middleName: 'example_middle_name',
|
|
1875
|
+
lastName: 'example_last_name',
|
|
1876
|
+
displayName: 'example_display_name',
|
|
1877
|
+
},
|
|
1878
|
+
}
|
|
1879
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
1880
|
+
expect(savedParty).toBeDefined()
|
|
1881
|
+
|
|
1882
|
+
const electronicAddress1: NonPersistedElectronicAddress = {
|
|
1883
|
+
type: 'email',
|
|
1884
|
+
electronicAddress: 'example_electronic_address1'
|
|
1885
|
+
}
|
|
1886
|
+
const savedElectronicAddress1: ElectronicAddress = await contactStore.addElectronicAddress({ partyId: savedParty.id, electronicAddress: electronicAddress1 })
|
|
1887
|
+
expect(savedElectronicAddress1).toBeDefined()
|
|
1888
|
+
|
|
1889
|
+
const electronicAddress2: NonPersistedElectronicAddress = {
|
|
1890
|
+
type: 'email',
|
|
1891
|
+
electronicAddress: 'example_electronic_address2'
|
|
1892
|
+
}
|
|
1893
|
+
const savedElectronicAddress2: ElectronicAddress = await contactStore.addElectronicAddress({ partyId: savedParty.id, electronicAddress: electronicAddress2 })
|
|
1894
|
+
expect(savedElectronicAddress2).toBeDefined()
|
|
1895
|
+
|
|
1896
|
+
const result: Array<ElectronicAddress> = await contactStore.getElectronicAddresses()
|
|
1897
|
+
|
|
1898
|
+
expect(result.length).toEqual(2)
|
|
1899
|
+
})
|
|
1900
|
+
|
|
1901
|
+
it('should get electronic addresses by filter', async (): Promise<void> => {
|
|
1902
|
+
const party: NonPersistedParty = {
|
|
1903
|
+
uri: 'example.com',
|
|
1904
|
+
partyType: {
|
|
1905
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
1906
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
1907
|
+
name: 'example_name',
|
|
1908
|
+
},
|
|
1909
|
+
contact: {
|
|
1910
|
+
firstName: 'example_first_name',
|
|
1911
|
+
middleName: 'example_middle_name',
|
|
1912
|
+
lastName: 'example_last_name',
|
|
1913
|
+
displayName: 'example_display_name',
|
|
1914
|
+
},
|
|
1915
|
+
}
|
|
1916
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
1917
|
+
expect(savedParty).toBeDefined()
|
|
1918
|
+
|
|
1919
|
+
const electronicAddress = 'example_electronic_address1'
|
|
1920
|
+
const electronicAddress1: NonPersistedElectronicAddress = {
|
|
1921
|
+
type: 'email',
|
|
1922
|
+
electronicAddress
|
|
1923
|
+
}
|
|
1924
|
+
const savedElectronicAddress1: ElectronicAddress = await contactStore.addElectronicAddress({ partyId: savedParty.id, electronicAddress: electronicAddress1 })
|
|
1925
|
+
expect(savedElectronicAddress1).toBeDefined()
|
|
1926
|
+
|
|
1927
|
+
const electronicAddress2: NonPersistedElectronicAddress = {
|
|
1928
|
+
type: 'email',
|
|
1929
|
+
electronicAddress: 'example_electronic_address2'
|
|
1930
|
+
}
|
|
1931
|
+
const savedElectronicAddress2: ElectronicAddress = await contactStore.addElectronicAddress({ partyId: savedParty.id, electronicAddress: electronicAddress2 })
|
|
1932
|
+
expect(savedElectronicAddress2).toBeDefined()
|
|
1933
|
+
|
|
1934
|
+
const args: GetElectronicAddressesArgs = {
|
|
1935
|
+
filter: [{ electronicAddress }],
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
const result: Array<ElectronicAddress> = await contactStore.getElectronicAddresses(args)
|
|
1939
|
+
|
|
1940
|
+
expect(result.length).toEqual(1)
|
|
1941
|
+
})
|
|
1942
|
+
|
|
1943
|
+
it('should add electronic address to contact', async (): Promise<void> => {
|
|
1944
|
+
const party: NonPersistedParty = {
|
|
1945
|
+
uri: 'example.com',
|
|
1946
|
+
partyType: {
|
|
1947
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
1948
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
1949
|
+
name: 'example_name',
|
|
1950
|
+
},
|
|
1951
|
+
contact: {
|
|
1952
|
+
firstName: 'example_first_name',
|
|
1953
|
+
middleName: 'example_middle_name',
|
|
1954
|
+
lastName: 'example_last_name',
|
|
1955
|
+
displayName: 'example_display_name',
|
|
1956
|
+
},
|
|
1957
|
+
}
|
|
1958
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
1959
|
+
expect(savedParty).toBeDefined()
|
|
1960
|
+
|
|
1961
|
+
const electronicAddress: NonPersistedElectronicAddress = {
|
|
1962
|
+
type: 'email',
|
|
1963
|
+
electronicAddress: 'example_electronic_address'
|
|
1964
|
+
}
|
|
1965
|
+
const savedElectronicAddress: ElectronicAddress = await contactStore.addElectronicAddress({ partyId: savedParty.id, electronicAddress })
|
|
1966
|
+
expect(savedElectronicAddress).toBeDefined()
|
|
1967
|
+
|
|
1968
|
+
const result: Party = await contactStore.getParty({ partyId: savedParty.id })
|
|
1969
|
+
expect(result.electronicAddresses.length).toEqual(1)
|
|
1970
|
+
})
|
|
1971
|
+
|
|
1972
|
+
it('should update electronic address by id', async (): Promise<void> => {
|
|
1973
|
+
const party: NonPersistedParty = {
|
|
1974
|
+
uri: 'example.com',
|
|
1975
|
+
partyType: {
|
|
1976
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
1977
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
1978
|
+
name: 'example_name',
|
|
1979
|
+
},
|
|
1980
|
+
contact: {
|
|
1981
|
+
firstName: 'example_first_name',
|
|
1982
|
+
middleName: 'example_middle_name',
|
|
1983
|
+
lastName: 'example_last_name',
|
|
1984
|
+
displayName: 'example_display_name',
|
|
1985
|
+
},
|
|
1986
|
+
}
|
|
1987
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
1988
|
+
expect(savedParty).toBeDefined()
|
|
1989
|
+
|
|
1990
|
+
const electronicAddress: NonPersistedElectronicAddress = {
|
|
1991
|
+
type: 'email',
|
|
1992
|
+
electronicAddress: 'example_electronic_address'
|
|
1993
|
+
}
|
|
1994
|
+
const savedElectronicAddress: ElectronicAddress = await contactStore.addElectronicAddress({ partyId: savedParty.id, electronicAddress })
|
|
1995
|
+
const newElectronicAddress = 'new_example_electronic_address'
|
|
1996
|
+
savedElectronicAddress.electronicAddress = newElectronicAddress
|
|
1997
|
+
|
|
1998
|
+
await contactStore.updateElectronicAddress({ electronicAddress: savedElectronicAddress })
|
|
1999
|
+
const result: ElectronicAddress = await contactStore.getElectronicAddress({ electronicAddressId: savedElectronicAddress.id })
|
|
2000
|
+
|
|
2001
|
+
expect(result).toBeDefined()
|
|
2002
|
+
expect(result.electronicAddress).toEqual(newElectronicAddress)
|
|
2003
|
+
})
|
|
2004
|
+
|
|
2005
|
+
it('should remove electronic address', async (): Promise<void> => {
|
|
2006
|
+
const party: NonPersistedParty = {
|
|
2007
|
+
uri: 'example.com',
|
|
2008
|
+
partyType: {
|
|
2009
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
2010
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
2011
|
+
name: 'example_name',
|
|
2012
|
+
},
|
|
2013
|
+
contact: {
|
|
2014
|
+
firstName: 'example_first_name',
|
|
2015
|
+
middleName: 'example_middle_name',
|
|
2016
|
+
lastName: 'example_last_name',
|
|
2017
|
+
displayName: 'example_display_name',
|
|
2018
|
+
},
|
|
2019
|
+
}
|
|
2020
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
2021
|
+
expect(savedParty).toBeDefined()
|
|
2022
|
+
|
|
2023
|
+
const electronicAddress: NonPersistedElectronicAddress = {
|
|
2024
|
+
type: 'email',
|
|
2025
|
+
electronicAddress: 'example_electronic_address'
|
|
2026
|
+
}
|
|
2027
|
+
const savedElectronicAddress: ElectronicAddress = await contactStore.addElectronicAddress({ partyId: savedParty.id, electronicAddress })
|
|
2028
|
+
expect(savedElectronicAddress).toBeDefined()
|
|
2029
|
+
|
|
2030
|
+
await contactStore.removeElectronicAddress({ electronicAddressId: savedElectronicAddress.id })
|
|
2031
|
+
|
|
2032
|
+
await expect(contactStore.getElectronicAddress({ electronicAddressId: savedElectronicAddress.id })).rejects.toThrow(`No electronic address found for id: ${savedElectronicAddress.id}`)
|
|
2033
|
+
})
|
|
2034
|
+
|
|
2035
|
+
it('should throw error when removing electronic address with unknown id', async (): Promise<void> => {
|
|
2036
|
+
const electronicAddressId = 'unknownElectronicAddressId'
|
|
2037
|
+
|
|
2038
|
+
await expect(contactStore.removeElectronicAddress({ electronicAddressId })).rejects.toThrow(`No electronic address found for id: ${electronicAddressId}`)
|
|
2039
|
+
})
|
|
2040
|
+
|
|
2041
|
+
it('should get physical address by id', async (): Promise<void> => {
|
|
2042
|
+
const party: NonPersistedParty = {
|
|
2043
|
+
uri: 'example.com',
|
|
2044
|
+
partyType: {
|
|
2045
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
2046
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
2047
|
+
name: 'example_name',
|
|
2048
|
+
},
|
|
2049
|
+
contact: {
|
|
2050
|
+
firstName: 'example_first_name',
|
|
2051
|
+
middleName: 'example_middle_name',
|
|
2052
|
+
lastName: 'example_last_name',
|
|
2053
|
+
displayName: 'example_display_name',
|
|
2054
|
+
},
|
|
2055
|
+
}
|
|
2056
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
2057
|
+
expect(savedParty).toBeDefined()
|
|
2058
|
+
|
|
2059
|
+
const physicalAddress: NonPersistedPhysicalAddress = {
|
|
2060
|
+
type: 'home',
|
|
2061
|
+
streetName: 'example_street_name',
|
|
2062
|
+
streetNumber: 'example_street_number',
|
|
2063
|
+
buildingName: 'example_building_name',
|
|
2064
|
+
postalCode: 'example_postal_code',
|
|
2065
|
+
cityName: 'example_city_name',
|
|
2066
|
+
provinceName: 'example_province_name',
|
|
2067
|
+
countryCode: 'example_country_code',
|
|
2068
|
+
}
|
|
2069
|
+
const savedPhysicalAddress: PhysicalAddress = await contactStore.addPhysicalAddress({ partyId: savedParty.id, physicalAddress })
|
|
2070
|
+
expect(savedPhysicalAddress).toBeDefined()
|
|
2071
|
+
|
|
2072
|
+
const result: PhysicalAddress = await contactStore.getPhysicalAddress({ physicalAddressId: savedPhysicalAddress.id })
|
|
2073
|
+
|
|
2074
|
+
expect(result).toBeDefined()
|
|
2075
|
+
})
|
|
2076
|
+
|
|
2077
|
+
it('should throw error when getting physical address with unknown id', async (): Promise<void> => {
|
|
2078
|
+
const physicalAddressId = 'unknownPhysicalAddressId'
|
|
2079
|
+
|
|
2080
|
+
await expect(contactStore.getPhysicalAddress({ physicalAddressId })).rejects.toThrow(`No physical address found for id: ${physicalAddressId}`)
|
|
2081
|
+
})
|
|
2082
|
+
|
|
2083
|
+
it('should get all physical addresses for contact', async (): Promise<void> => {
|
|
2084
|
+
const party: NonPersistedParty = {
|
|
2085
|
+
uri: 'example.com',
|
|
2086
|
+
partyType: {
|
|
2087
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
2088
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
2089
|
+
name: 'example_name',
|
|
2090
|
+
},
|
|
2091
|
+
contact: {
|
|
2092
|
+
firstName: 'example_first_name',
|
|
2093
|
+
middleName: 'example_middle_name',
|
|
2094
|
+
lastName: 'example_last_name',
|
|
2095
|
+
displayName: 'example_display_name',
|
|
2096
|
+
},
|
|
2097
|
+
}
|
|
2098
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
2099
|
+
expect(savedParty).toBeDefined()
|
|
2100
|
+
|
|
2101
|
+
const physicalAddress1: NonPersistedPhysicalAddress = {
|
|
2102
|
+
type: 'home',
|
|
2103
|
+
streetName: 'example_street_name',
|
|
2104
|
+
streetNumber: 'example_street_number',
|
|
2105
|
+
buildingName: 'example_building_name',
|
|
2106
|
+
postalCode: 'example_postal_code',
|
|
2107
|
+
cityName: 'example_city_name',
|
|
2108
|
+
provinceName: 'example_province_name',
|
|
2109
|
+
countryCode: 'example_country_code',
|
|
2110
|
+
}
|
|
2111
|
+
const savedPhysicalAddress1: PhysicalAddress = await contactStore.addPhysicalAddress({ partyId: savedParty.id, physicalAddress: physicalAddress1 })
|
|
2112
|
+
expect(savedPhysicalAddress1).toBeDefined()
|
|
2113
|
+
|
|
2114
|
+
const physicalAddress2: NonPersistedPhysicalAddress = {
|
|
2115
|
+
type: 'home',
|
|
2116
|
+
streetName: 'example_street_name',
|
|
2117
|
+
streetNumber: 'example_street_number',
|
|
2118
|
+
buildingName: 'example_building_name',
|
|
2119
|
+
postalCode: 'example_postal_code',
|
|
2120
|
+
cityName: 'example_city_name',
|
|
2121
|
+
provinceName: 'example_province_name',
|
|
2122
|
+
countryCode: 'example_country_code',
|
|
2123
|
+
}
|
|
2124
|
+
const savedPhysicalAddress2: PhysicalAddress = await contactStore.addPhysicalAddress({ partyId: savedParty.id, physicalAddress: physicalAddress2 })
|
|
2125
|
+
expect(savedPhysicalAddress2).toBeDefined()
|
|
2126
|
+
|
|
2127
|
+
const args: GetPhysicalAddressesArgs = {
|
|
2128
|
+
filter: [{ partyId: savedParty.id }],
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
const result: Array<PhysicalAddress> = await contactStore.getPhysicalAddresses(args)
|
|
2132
|
+
|
|
2133
|
+
expect(result.length). toEqual(2)
|
|
2134
|
+
})
|
|
2135
|
+
|
|
2136
|
+
it('should get all electronic addresses', async (): Promise<void> => {
|
|
2137
|
+
const party: NonPersistedParty = {
|
|
2138
|
+
uri: 'example.com',
|
|
2139
|
+
partyType: {
|
|
2140
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
2141
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
2142
|
+
name: 'example_name',
|
|
2143
|
+
},
|
|
2144
|
+
contact: {
|
|
2145
|
+
firstName: 'example_first_name',
|
|
2146
|
+
middleName: 'example_middle_name',
|
|
2147
|
+
lastName: 'example_last_name',
|
|
2148
|
+
displayName: 'example_display_name',
|
|
2149
|
+
},
|
|
2150
|
+
}
|
|
2151
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
2152
|
+
expect(savedParty).toBeDefined()
|
|
2153
|
+
|
|
2154
|
+
const physicalAddress1: NonPersistedPhysicalAddress = {
|
|
2155
|
+
type: 'home',
|
|
2156
|
+
streetName: 'example_street_name',
|
|
2157
|
+
streetNumber: 'example_street_number',
|
|
2158
|
+
buildingName: 'example_building_name',
|
|
2159
|
+
postalCode: 'example_postal_code',
|
|
2160
|
+
cityName: 'example_city_name',
|
|
2161
|
+
provinceName: 'example_province_name',
|
|
2162
|
+
countryCode: 'example_country_code',
|
|
2163
|
+
}
|
|
2164
|
+
const savedPhysicalAddress1: PhysicalAddress = await contactStore.addPhysicalAddress({ partyId: savedParty.id, physicalAddress: physicalAddress1 })
|
|
2165
|
+
expect(savedPhysicalAddress1).toBeDefined()
|
|
2166
|
+
|
|
2167
|
+
const physicalAddress2: NonPersistedPhysicalAddress = {
|
|
2168
|
+
type: 'home',
|
|
2169
|
+
streetName: 'example_street_name',
|
|
2170
|
+
streetNumber: 'example_street_number',
|
|
2171
|
+
buildingName: 'example_building_name',
|
|
2172
|
+
postalCode: 'example_postal_code',
|
|
2173
|
+
cityName: 'example_city_name',
|
|
2174
|
+
provinceName: 'example_province_name',
|
|
2175
|
+
countryCode: 'example_country_code',
|
|
2176
|
+
}
|
|
2177
|
+
const savedPhysicalAddress2: PhysicalAddress = await contactStore.addPhysicalAddress({ partyId: savedParty.id, physicalAddress: physicalAddress2 })
|
|
2178
|
+
expect(savedPhysicalAddress2).toBeDefined()
|
|
2179
|
+
|
|
2180
|
+
const result: Array<PhysicalAddress> = await contactStore.getPhysicalAddresses()
|
|
2181
|
+
|
|
2182
|
+
expect(result.length).toEqual(2)
|
|
2183
|
+
})
|
|
2184
|
+
|
|
2185
|
+
it('should get electronic addresses by filter', async (): Promise<void> => {
|
|
2186
|
+
const party: NonPersistedParty = {
|
|
2187
|
+
uri: 'example.com',
|
|
2188
|
+
partyType: {
|
|
2189
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
2190
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
2191
|
+
name: 'example_name',
|
|
2192
|
+
},
|
|
2193
|
+
contact: {
|
|
2194
|
+
firstName: 'example_first_name',
|
|
2195
|
+
middleName: 'example_middle_name',
|
|
2196
|
+
lastName: 'example_last_name',
|
|
2197
|
+
displayName: 'example_display_name',
|
|
2198
|
+
},
|
|
2199
|
+
}
|
|
2200
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
2201
|
+
expect(savedParty).toBeDefined()
|
|
2202
|
+
|
|
2203
|
+
const streetName = 'example_electronic_address1'
|
|
2204
|
+
const physicalAddress1: NonPersistedPhysicalAddress = {
|
|
2205
|
+
type: 'home',
|
|
2206
|
+
streetName,
|
|
2207
|
+
streetNumber: 'example_street_number1',
|
|
2208
|
+
buildingName: 'example_building_name1',
|
|
2209
|
+
postalCode: 'example_postal_code1',
|
|
2210
|
+
cityName: 'example_city_name1',
|
|
2211
|
+
provinceName: 'example_province_name1',
|
|
2212
|
+
countryCode: 'example_country_code1',
|
|
2213
|
+
}
|
|
2214
|
+
const savedPhysicalAddress1: PhysicalAddress = await contactStore.addPhysicalAddress({ partyId: savedParty.id, physicalAddress: physicalAddress1 })
|
|
2215
|
+
expect(savedPhysicalAddress1).toBeDefined()
|
|
2216
|
+
|
|
2217
|
+
const physicalAddress2: NonPersistedPhysicalAddress = {
|
|
2218
|
+
type: 'home',
|
|
2219
|
+
streetName: 'example_street_name2',
|
|
2220
|
+
streetNumber: 'example_street_number2',
|
|
2221
|
+
buildingName: 'example_building_name2',
|
|
2222
|
+
postalCode: 'example_postal_code2',
|
|
2223
|
+
cityName: 'example_city_name2',
|
|
2224
|
+
provinceName: 'example_province_name2',
|
|
2225
|
+
countryCode: 'example_country_code2',
|
|
2226
|
+
}
|
|
2227
|
+
const savedPhysicalAddress2: PhysicalAddress = await contactStore.addPhysicalAddress({ partyId: savedParty.id, physicalAddress: physicalAddress2 })
|
|
2228
|
+
expect(savedPhysicalAddress2).toBeDefined()
|
|
2229
|
+
|
|
2230
|
+
const args: GetPhysicalAddressesArgs = {
|
|
2231
|
+
filter: [{ streetName }],
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
const result: Array<PhysicalAddress> = await contactStore.getPhysicalAddresses(args)
|
|
2235
|
+
|
|
2236
|
+
expect(result.length).toEqual(1)
|
|
2237
|
+
})
|
|
2238
|
+
|
|
2239
|
+
it('should add physical address to contact', async (): Promise<void> => {
|
|
2240
|
+
const party: NonPersistedParty = {
|
|
2241
|
+
uri: 'example.com',
|
|
2242
|
+
partyType: {
|
|
2243
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
2244
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
2245
|
+
name: 'example_name',
|
|
2246
|
+
},
|
|
2247
|
+
contact: {
|
|
2248
|
+
firstName: 'example_first_name',
|
|
2249
|
+
middleName: 'example_middle_name',
|
|
2250
|
+
lastName: 'example_last_name',
|
|
2251
|
+
displayName: 'example_display_name',
|
|
2252
|
+
},
|
|
2253
|
+
}
|
|
2254
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
2255
|
+
expect(savedParty).toBeDefined()
|
|
2256
|
+
|
|
2257
|
+
const physicalAddress: NonPersistedPhysicalAddress = {
|
|
2258
|
+
type: 'home',
|
|
2259
|
+
streetName: 'example_street_name',
|
|
2260
|
+
streetNumber: 'example_street_number',
|
|
2261
|
+
buildingName: 'example_building_name',
|
|
2262
|
+
postalCode: 'example_postal_code',
|
|
2263
|
+
cityName: 'example_city_name',
|
|
2264
|
+
provinceName: 'example_province_name',
|
|
2265
|
+
countryCode: 'example_country_code',
|
|
2266
|
+
}
|
|
2267
|
+
const savedPhysicalAddress: PhysicalAddress = await contactStore.addPhysicalAddress({ partyId: savedParty.id, physicalAddress })
|
|
2268
|
+
expect(savedPhysicalAddress).toBeDefined()
|
|
2269
|
+
|
|
2270
|
+
const result: Party = await contactStore.getParty({ partyId: savedParty.id })
|
|
2271
|
+
expect(result.physicalAddresses.length).toEqual(1)
|
|
2272
|
+
})
|
|
2273
|
+
|
|
2274
|
+
it('should update physical address by id', async (): Promise<void> => {
|
|
2275
|
+
const party: NonPersistedParty = {
|
|
2276
|
+
uri: 'example.com',
|
|
2277
|
+
partyType: {
|
|
2278
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
2279
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
2280
|
+
name: 'example_name',
|
|
2281
|
+
},
|
|
2282
|
+
contact: {
|
|
2283
|
+
firstName: 'example_first_name',
|
|
2284
|
+
middleName: 'example_middle_name',
|
|
2285
|
+
lastName: 'example_last_name',
|
|
2286
|
+
displayName: 'example_display_name',
|
|
2287
|
+
},
|
|
2288
|
+
}
|
|
2289
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
2290
|
+
expect(savedParty).toBeDefined()
|
|
2291
|
+
|
|
2292
|
+
const physicalAddress: NonPersistedPhysicalAddress = {
|
|
2293
|
+
type: 'home',
|
|
2294
|
+
streetName: 'example_street_name',
|
|
2295
|
+
streetNumber: 'example_street_number',
|
|
2296
|
+
buildingName: 'example_building_name',
|
|
2297
|
+
postalCode: 'example_postal_code',
|
|
2298
|
+
cityName: 'example_city_name',
|
|
2299
|
+
provinceName: 'example_province_name',
|
|
2300
|
+
countryCode: 'example_country_code',
|
|
2301
|
+
}
|
|
2302
|
+
const savedPhysicalAddress: PhysicalAddress = await contactStore.addPhysicalAddress({ partyId: savedParty.id, physicalAddress })
|
|
2303
|
+
const newStreetName = 'new_example_street_name'
|
|
2304
|
+
savedPhysicalAddress.streetName = newStreetName
|
|
2305
|
+
|
|
2306
|
+
await contactStore.updatePhysicalAddress({ physicalAddress: savedPhysicalAddress })
|
|
2307
|
+
const result: PhysicalAddress = await contactStore.getPhysicalAddress({ physicalAddressId: savedPhysicalAddress.id })
|
|
2308
|
+
|
|
2309
|
+
expect(result).toBeDefined()
|
|
2310
|
+
expect(result.streetName).toEqual(newStreetName)
|
|
2311
|
+
})
|
|
2312
|
+
|
|
2313
|
+
it('should remove physical address', async (): Promise<void> => {
|
|
2314
|
+
const party: NonPersistedParty = {
|
|
2315
|
+
uri: 'example.com',
|
|
2316
|
+
partyType: {
|
|
2317
|
+
type: PartyTypeEnum.NATURAL_PERSON,
|
|
2318
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
2319
|
+
name: 'example_name',
|
|
2320
|
+
},
|
|
2321
|
+
contact: {
|
|
2322
|
+
firstName: 'example_first_name',
|
|
2323
|
+
middleName: 'example_middle_name',
|
|
2324
|
+
lastName: 'example_last_name',
|
|
2325
|
+
displayName: 'example_display_name',
|
|
2326
|
+
},
|
|
2327
|
+
}
|
|
2328
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
2329
|
+
expect(savedParty).toBeDefined()
|
|
2330
|
+
|
|
2331
|
+
const physicalAddress: NonPersistedPhysicalAddress = {
|
|
2332
|
+
type: 'home',
|
|
2333
|
+
streetName: 'example_street_name',
|
|
2334
|
+
streetNumber: 'example_street_number',
|
|
2335
|
+
buildingName: 'example_building_name',
|
|
2336
|
+
postalCode: 'example_postal_code',
|
|
2337
|
+
cityName: 'example_city_name',
|
|
2338
|
+
provinceName: 'example_province_name',
|
|
2339
|
+
countryCode: 'example_country_code',
|
|
2340
|
+
}
|
|
2341
|
+
const savedPhysicalAddress: PhysicalAddress = await contactStore.addPhysicalAddress({ partyId: savedParty.id, physicalAddress })
|
|
2342
|
+
expect(savedPhysicalAddress).toBeDefined()
|
|
2343
|
+
|
|
2344
|
+
await contactStore.removePhysicalAddress({ physicalAddressId: savedPhysicalAddress.id })
|
|
2345
|
+
|
|
2346
|
+
await expect(contactStore.getPhysicalAddress({ physicalAddressId: savedPhysicalAddress.id })).rejects.toThrow(`No physical address found for id: ${savedPhysicalAddress.id}`)
|
|
2347
|
+
})
|
|
2348
|
+
|
|
2349
|
+
it('should throw error when removing physical address with unknown id', async (): Promise<void> => {
|
|
2350
|
+
const physicalAddressId = 'unknownPhysicalAddressId'
|
|
2351
|
+
|
|
2352
|
+
await expect(contactStore.removePhysicalAddress({ physicalAddressId })).rejects.toThrow(`No physical address found for id: ${physicalAddressId}`)
|
|
2353
|
+
})
|
|
2354
|
+
|
|
1779
2355
|
})
|