@sphereon/ssi-sdk.data-store 0.18.2-next.9 → 0.18.2-unstable.12
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/contact/AbstractContactStore.d.ts +11 -1
- package/dist/contact/AbstractContactStore.d.ts.map +1 -1
- package/dist/contact/AbstractContactStore.js.map +1 -1
- package/dist/contact/ContactStore.d.ts +27 -15
- package/dist/contact/ContactStore.d.ts.map +1 -1
- package/dist/contact/ContactStore.js +199 -36
- package/dist/contact/ContactStore.js.map +1 -1
- package/dist/entities/contact/ElectronicAddressEntity.d.ts +1 -0
- package/dist/entities/contact/ElectronicAddressEntity.d.ts.map +1 -1
- package/dist/entities/contact/ElectronicAddressEntity.js +4 -0
- package/dist/entities/contact/ElectronicAddressEntity.js.map +1 -1
- package/dist/entities/contact/IdentityEntity.d.ts +1 -1
- package/dist/entities/contact/IdentityEntity.d.ts.map +1 -1
- package/dist/entities/contact/PartyEntity.d.ts +2 -0
- package/dist/entities/contact/PartyEntity.d.ts.map +1 -1
- package/dist/entities/contact/PartyEntity.js +12 -1
- package/dist/entities/contact/PartyEntity.js.map +1 -1
- 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/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/issuanceBranding/IssuanceBrandingStore.d.ts.map +1 -1
- package/dist/issuanceBranding/IssuanceBrandingStore.js +76 -60
- package/dist/issuanceBranding/IssuanceBrandingStore.js.map +1 -1
- package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts.map +1 -1
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js +3 -6
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js.map +1 -1
- package/dist/types/contact/IAbstractContactStore.d.ts +36 -1
- package/dist/types/contact/IAbstractContactStore.d.ts.map +1 -1
- package/dist/types/contact/contact.d.ts +27 -4
- package/dist/types/contact/contact.d.ts.map +1 -1
- package/dist/types/contact/contact.js.map +1 -1
- package/dist/utils/contact/MappingUtils.d.ts +4 -1
- package/dist/utils/contact/MappingUtils.d.ts.map +1 -1
- package/dist/utils/contact/MappingUtils.js +37 -1
- package/dist/utils/contact/MappingUtils.js.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/contact.entities.test.ts +323 -23
- package/src/__tests__/contact.store.test.ts +586 -10
- package/src/contact/AbstractContactStore.ts +38 -17
- package/src/contact/ContactStore.ts +276 -62
- 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/index.ts +3 -0
- package/src/issuanceBranding/IssuanceBrandingStore.ts +78 -62
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +3 -8
- package/src/types/contact/IAbstractContactStore.ts +58 -8
- package/src/types/contact/contact.ts +29 -4
- package/src/utils/contact/MappingUtils.ts +39 -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
|
})
|
|
@@ -1,28 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
Identity,
|
|
2
|
+
AddElectronicAddressArgs,
|
|
4
3
|
AddIdentityArgs,
|
|
5
|
-
|
|
4
|
+
AddPartyArgs,
|
|
5
|
+
AddPartyTypeArgs,
|
|
6
|
+
AddPhysicalAddressArgs,
|
|
7
|
+
AddRelationshipArgs,
|
|
8
|
+
ElectronicAddress,
|
|
9
|
+
GetElectronicAddressArgs,
|
|
10
|
+
GetElectronicAddressesArgs,
|
|
6
11
|
GetIdentitiesArgs,
|
|
12
|
+
GetIdentityArgs,
|
|
13
|
+
GetPartiesArgs,
|
|
7
14
|
GetPartyArgs,
|
|
15
|
+
GetPartyTypeArgs,
|
|
16
|
+
GetPartyTypesArgs,
|
|
17
|
+
GetPhysicalAddressArgs,
|
|
18
|
+
GetPhysicalAddressesArgs,
|
|
19
|
+
GetRelationshipArgs,
|
|
20
|
+
GetRelationshipsArgs,
|
|
21
|
+
Identity,
|
|
22
|
+
Party,
|
|
23
|
+
PartyRelationship,
|
|
24
|
+
PartyType, PhysicalAddress,
|
|
25
|
+
RemoveElectronicAddressArgs,
|
|
8
26
|
RemoveIdentityArgs,
|
|
9
|
-
UpdateIdentityArgs,
|
|
10
|
-
AddPartyArgs,
|
|
11
|
-
GetPartiesArgs,
|
|
12
27
|
RemovePartyArgs,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
PartyRelationship,
|
|
28
|
+
RemovePartyTypeArgs,
|
|
29
|
+
RemovePhysicalAddressArgs,
|
|
16
30
|
RemoveRelationshipArgs,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
UpdateElectronicAddressArgs,
|
|
32
|
+
UpdateIdentityArgs,
|
|
33
|
+
UpdatePartyArgs,
|
|
20
34
|
UpdatePartyTypeArgs,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
GetRelationshipsArgs,
|
|
24
|
-
GetRelationshipArgs,
|
|
25
|
-
UpdateRelationshipArgs,
|
|
35
|
+
UpdatePhysicalAddressArgs,
|
|
36
|
+
UpdateRelationshipArgs
|
|
26
37
|
} from '../types'
|
|
27
38
|
|
|
28
39
|
export abstract class AbstractContactStore {
|
|
@@ -46,4 +57,14 @@ export abstract class AbstractContactStore {
|
|
|
46
57
|
abstract addPartyType(args: AddPartyTypeArgs): Promise<PartyType>
|
|
47
58
|
abstract updatePartyType(args: UpdatePartyTypeArgs): Promise<PartyType>
|
|
48
59
|
abstract removePartyType(args: RemovePartyTypeArgs): Promise<void>
|
|
60
|
+
abstract getElectronicAddress(args: GetElectronicAddressArgs): Promise<ElectronicAddress>
|
|
61
|
+
abstract getElectronicAddresses(args?: GetElectronicAddressesArgs): Promise<Array<ElectronicAddress>>
|
|
62
|
+
abstract addElectronicAddress(args: AddElectronicAddressArgs): Promise<ElectronicAddress>
|
|
63
|
+
abstract updateElectronicAddress(args: UpdateElectronicAddressArgs): Promise<ElectronicAddress>
|
|
64
|
+
abstract removeElectronicAddress(args: RemoveElectronicAddressArgs): Promise<void>
|
|
65
|
+
abstract getPhysicalAddress(args: GetPhysicalAddressArgs): Promise<PhysicalAddress>
|
|
66
|
+
abstract getPhysicalAddresses(args?: GetPhysicalAddressesArgs): Promise<Array<PhysicalAddress>>
|
|
67
|
+
abstract addPhysicalAddress(args: AddPhysicalAddressArgs): Promise<PhysicalAddress>
|
|
68
|
+
abstract updatePhysicalAddress(args: UpdatePhysicalAddressArgs): Promise<PhysicalAddress>
|
|
69
|
+
abstract removePhysicalAddress(args: RemovePhysicalAddressArgs): Promise<void>
|
|
49
70
|
}
|